:root {
  --navy: #003087;
  --blue: #0070e0;
  --ink: #06182f;
  --muted: #50617a;
  --line: #d7e4f4;
  --wash: #eef5ff;
  --panel: #ffffff;
  --green: #0b7a53;
  --gold: #8a6500;
  --draft: #a33a3a;
  --shadow: 0 24px 70px rgba(0, 48, 135, .12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: #f5f8fc;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
main { min-height: calc(100vh - 108px); }

.bn-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 34px;
  background: rgba(255,255,255,.97);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand, .top-nav, .user-pill { display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 950; color: var(--navy); }
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--navy);
  color: white;
  font-size: 12px;
}
.top-nav { flex-wrap: wrap; justify-content: center; }
.top-nav a {
  font-size: 13px;
  font-weight: 850;
  color: #30415d;
  padding: 8px 10px;
  border-radius: 999px;
}
.top-nav a:hover { background: var(--wash); color: var(--navy); }
.user-pill { font-size: 12px; font-weight: 800; color: #4d5e78; }
.user-pill a {
  color: white;
  background: var(--navy);
  border-radius: 999px;
  padding: 10px 14px;
}
.subbar {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  color: #45617f;
  font-size: 12px;
  font-weight: 850;
  background: #fbfdff;
}
.subbar span:first-child { color: var(--navy); text-transform: uppercase; letter-spacing: .08em; }

.hero, .section, .studio-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 52px 24px;
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
  gap: 28px;
  align-items: center;
  padding-top: 76px;
}
.eyebrow {
  margin: 0 0 12px;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
  font-weight: 950;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  color: var(--navy);
  font-size: clamp(42px, 6vw, 78px);
  line-height: .94;
  letter-spacing: 0;
  margin-bottom: 22px;
}
h2 {
  color: var(--navy);
  font-size: clamp(28px, 3vw, 44px);
  line-height: 1.02;
  margin-bottom: 12px;
}
h3 { color: var(--navy); margin-bottom: 8px; }
.lead {
  color: var(--muted);
  font-size: 19px;
  line-height: 1.65;
  max-width: 820px;
  font-weight: 600;
}
.hero-actions, .actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  min-height: 42px;
  padding: 0 18px;
  font-size: 13px;
  font-weight: 950;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn.primary { background: var(--navy); color: white; box-shadow: 0 10px 24px rgba(0,48,135,.18); }
.btn.secondary { background: white; color: var(--navy); border-color: var(--line); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 12px; }
.btn.full { width: 100%; }

.panel, .hero-panel, .card, .studio-card, .table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.hero-panel, .panel, .card, .studio-card { padding: 24px; }
.panel-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .13em;
  color: var(--blue);
  font-weight: 950;
  margin-bottom: 10px;
}
.big-stat { font-size: 72px; line-height: .9; color: var(--navy); font-weight: 950; }
.muted { color: var(--muted); }
.metric-grid, .stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}
.metric-grid div, .stat-grid div {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #f8fbff;
}
.metric-grid strong, .stat-grid strong { display: block; color: var(--navy); font-size: 28px; }
.metric-grid span, .stat-grid span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; }

.band { max-width: none; background: white; border-block: 1px solid var(--line); padding: 48px 24px; }
.band > * { max-width: 1240px; margin-inline: auto; }
.section-head { margin-bottom: 26px; max-width: 850px; }
.section-head p { color: var(--muted); line-height: 1.65; font-weight: 600; }
.section-head.split {
  max-width: none;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.card { box-shadow: none; }
.card p { color: var(--muted); line-height: 1.55; font-weight: 600; }
.tag, .badge {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 950;
  border: 1px solid var(--line);
  color: var(--blue);
  background: var(--wash);
}
.badge.green { color: var(--green); background: #f0fbf6; border-color: #bfe8d5; }
.badge.gold { color: var(--gold); background: #fff8e8; border-color: #f1d28b; }
.badge.red { color: var(--draft); background: #fff3f3; border-color: #f0c3c3; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.studio-shell { padding-top: 34px; }
.studio-grid {
  display: grid;
  grid-template-columns: 1fr;   /* stacked rows: controls, then result/analysis, then export */
  gap: 18px;
  align-items: start;
}
.studio-card { box-shadow: none; }
.studio-card.sticky { position: static; top: auto; }   /* no sidebar pin in the rows layout */
.field { display: grid; gap: 7px; margin-bottom: 14px; color: var(--muted); font-size: 12px; font-weight: 900; }
.field input, .field select {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
  color: var(--navy);
  padding: 0 14px;
  font-weight: 900;
  width: 100%;
}
.display {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border-radius: 18px;
  padding: 28px;
}
.display-number {
  color: var(--navy);
  font-size: clamp(58px, 9vw, 112px);
  line-height: .92;
  font-weight: 950;
  overflow-wrap: anywhere;
}
.display-words {
  color: #163b72;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.05;
  font-weight: 900;
  margin-top: 18px;
  overflow-wrap: anywhere;
}
.display-meta { color: var(--muted); font-size: 13px; font-weight: 800; margin-top: 16px; }
.keypad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}
.keypad button {
  min-height: 54px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
  color: var(--navy);
  font-weight: 950;
  cursor: pointer;
}
.keypad button.op { background: var(--wash); color: var(--blue); }
.keypad button.primary { background: var(--navy); color: white; }
.analysis-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.analysis-box {
  border: 1px solid var(--line);
  background: #fbfdff;
  border-radius: 14px;
  padding: 16px;
  min-height: 112px;
}
.analysis-box h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.analysis-box p, .analysis-box li { color: var(--muted); line-height: 1.55; font-weight: 650; }
.parts { display: flex; flex-wrap: wrap; gap: 8px; }
.parts span {
  border: 1px solid var(--line);
  background: var(--wash);
  color: var(--navy);
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 950;
}
.parallel-list { display: grid; gap: 8px; max-height: 620px; overflow: auto; padding-right: 4px; }
.parallel-row {
  display: grid;
  grid-template-columns: 54px minmax(90px, .7fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid #e3ebf5;
  background: #fbfdff;
  border-radius: 12px;
  padding: 10px;
}
.parallel-row strong { color: var(--navy); }
.parallel-row span { color: var(--muted); font-size: 12px; font-weight: 800; }
.parallel-row code { color: #163b72; white-space: normal; overflow-wrap: anywhere; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.toolbar input, .toolbar select {
  min-height: 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  color: var(--navy);
  padding: 0 12px;
  font-weight: 850;
}
.export-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.codebox {
  display: block;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 260px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #06182f;
  color: #dceaff;
  padding: 14px;
  font-size: 12px;
  line-height: 1.5;
}
.table-wrap { overflow: auto; box-shadow: none; }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td { text-align: left; border-top: 1px solid #e8eef6; padding: 12px; vertical-align: top; }
th { color: var(--navy); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
td { color: var(--muted); font-weight: 650; }
.site-footer {
  border-top: 1px solid var(--line);
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 34px;
  color: var(--muted);
}
.site-footer strong { color: var(--navy); }
.site-footer p { margin: 6px 0 0; }
.footer-links { display: flex; gap: 12px; align-items: center; font-weight: 900; color: var(--navy); }

/* ── Enhanced brand mark + nav (ecosystem parity) ───────────────────────── */
.brand-mark {
  border-radius: 11px;
  background: linear-gradient(135deg, #001435, #0070ba);
  font-size: 17px;
  font-weight: 950;
  box-shadow: 0 6px 16px rgba(0,48,135,.22);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-weight: 950; color: var(--navy); font-size: 17px; }
.brand-unit {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9px; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; color: var(--blue);
}
.top-nav a.on { background: var(--navy); color: #fff; }
.top-nav a.on:hover { background: var(--navy); color: #fff; }

/* ── Richer footer ──────────────────────────────────────────────────────── */
.site-footer { flex-wrap: wrap; align-items: flex-start; }
.footer-brand { max-width: 360px; }
.footer-fine { font-size: 12px; color: var(--muted); font-weight: 700; }
.footer-fine a { color: var(--blue); }
.footer-cols { display: flex; gap: 44px; flex-wrap: wrap; }
.footer-col { display: flex; flex-direction: column; gap: 7px; }
.footer-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--navy); font-weight: 950; margin-bottom: 3px;
}
.footer-col a { color: var(--muted); font-weight: 750; font-size: 13px; }
.footer-col a:hover { color: var(--navy); }

/* ── Studio: mode tabs (segmented) ──────────────────────────────────────── */
.mode-tabs {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 16px;
  padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: #f8fbff;
}
.mode-tabs button {
  border: 1px solid transparent; background: transparent; color: #3a4d6b;
  border-radius: 9px; padding: 8px 12px; font-size: 12px; font-weight: 900; cursor: pointer;
}
.mode-tabs button:hover { background: #fff; color: var(--navy); }
.mode-tabs button.on { background: var(--navy); color: #fff; box-shadow: 0 6px 14px rgba(0,48,135,.18); }

.mode-inputs { display: none; gap: 10px; }
.mode-inputs.on { display: grid; }
.mode-inputs.two { grid-template-columns: repeat(2, minmax(0,1fr)); }

/* ── Memory + history strip ─────────────────────────────────────────────── */
.mem-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.mem-row button {
  border: 1px solid var(--line); background: #fff; color: var(--blue);
  border-radius: 9px; padding: 7px 11px; font-size: 12px; font-weight: 900; cursor: pointer; min-height: 36px;
}
.mem-row button:hover { background: var(--wash); }
.mem-row .mem-val { margin-left: auto; align-self: center; font-size: 12px; font-weight: 900; color: var(--navy); }
.history-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; max-height: 220px; overflow: auto; }
.history-list li {
  display: flex; justify-content: space-between; gap: 10px; cursor: pointer;
  border: 1px solid #e6eef8; background: #fbfdff; border-radius: 10px; padding: 8px 10px;
  font-size: 12px; font-weight: 750; color: #314a6c;
}
.history-list li:hover { border-color: var(--blue); background: var(--wash); }
.history-list .h-words { color: var(--navy); font-weight: 900; }

/* ── Sources / provenance + audio chips ─────────────────────────────────── */
.source-line {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 11px;
  color: var(--muted); margin-top: 6px; word-break: break-all;
}
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 6px 11px; font-size: 11px; font-weight: 900; border: 1px solid var(--line); background: var(--wash); color: var(--blue);
}
.chip.audio-planned { color: var(--gold); background: #fff8e8; border-color: #f1d28b; }
.chip.audio-live { color: var(--green); background: #f0fbf6; border-color: #bfe8d5; }
.chip.tier-A { color: var(--green); background: #f0fbf6; border-color: #bfe8d5; }
.chip.tier-B { color: var(--gold); background: #fff8e8; border-color: #f1d28b; }
.chip.tier-C { color: var(--blue); }

/* ── Corpus Factory: scale estimate ─────────────────────────────────────── */
.estimate {
  display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin: 12px 0;
}
.estimate div {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #f8fbff; text-align: center;
}
.estimate strong { display: block; color: var(--navy); font-size: 24px; font-weight: 950; line-height: 1; }
.estimate span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; margin-top: 5px; }
.type-toggles { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.type-toggles label {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 11px; font-size: 12px; font-weight: 850; color: #3a4d6b;
  cursor: pointer; background: #fff;
}
.type-toggles label:has(input:checked) { background: var(--navy); color: #fff; border-color: var(--navy); }
.type-toggles input { accent-color: var(--blue); }

@media (max-width: 1100px) {
  .hero, .studio-grid { grid-template-columns: 1fr; }
  .studio-card.sticky { position: static; }
}
@media (max-width: 820px) {
  .bn-header { align-items: flex-start; flex-direction: column; padding: 14px; }
  .user-pill { width: 100%; justify-content: space-between; }
  .card-grid, .analysis-grid, .export-grid, .metric-grid, .stat-grid, .estimate { grid-template-columns: 1fr; }
  h1 { font-size: 42px; }
  .site-footer { flex-direction: column; }
}
