/* ============================================================================
   E-band distribution comparison tool — stylesheet
   Dense engineering-instrument aesthetic. Theme-aware (light default + dark).
   ========================================================================= */

:root {
  --bg:            #f7f7f5;
  --bg-panel:      #ffffff;
  --bg-sunken:     #f0efec;
  --bg-hover:      #f4f3f0;
  --ink:           #16181d;
  --ink-2:         #4a4f59;
  /* Tertiary text carries chart axis labels and field hints at 10.5px, so it
     has to clear 4.5:1 on all three light surfaces, not just on white:
     5.36 on #fff, 5.00 on the page ground, 4.66 on sunken panels. */
  --ink-3:         #656b76;
  --rule:          #dedcd6;
  --rule-strong:   #c4c1b8;
  --accent:        #1c5f8b;
  --accent-soft:   #e3eef6;
  --on-accent:     #ffffff;
  --pass:          #1c6b3f;
  --pass-soft:     #e2f0e7;
  --warn:          #8a5a00;
  --warn-soft:     #faefd8;
  --fail:          #9b2226;
  --fail-soft:     #f8e4e4;
  /* IBM Plex: drawn for technical documentation, and Plex Mono has the
     tabular figures this page leans on in every table and chart axis. */
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* series colours — chosen for light+dark legibility */
  --s1: #1c5f8b;
  --s2: #b3591a;
  --s3: #6b4d9b;
  --s4: #1c7a6b;
  --s5: #9b2226;
  /* A6 needs its own hue: the six-series palette used to end in --accent,
     which is byte-identical to --s1 in both themes, so A1 and A6 drew in the
     same colour in every chart - and A1 vs A6 is the comparison the phase
     noise view exists to make. */
  --s6: #7a6300;
  /* A7 (radial feed): orchid, the hue family the first six leave free. In
     OKLab it sits 13.5 from its nearest neighbour here (the closest existing
     pair is 10.9) and 12.5 in dark (closest existing 7.5), and it clears
     4.8:1 on every light surface and 5.0:1 on every dark one. */
  --s7: #a32bc9;
  --grid: #e6e4de;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #14161a;
    --bg-panel:    #1b1e24;
    --bg-sunken:   #101215;
    --bg-hover:    #232730;
    --ink:         #e8e9ec;
    --ink-2:       #b0b5bf;
    --ink-3:       #7d838f;
    --rule:        #2c313a;
    --rule-strong: #414753;
    --accent:      #6fb4e0;
    --accent-soft: #1b3040;
    --on-accent:   #0d1116;
    --pass:        #63c58c;
    --pass-soft:   #17301f;
    --warn:        #e0b155;
    --warn-soft:   #33260d;
    --fail:        #e9797d;
    --fail-soft:   #34191b;
    --s1: #6fb4e0;
    --s2: #e79a5c;
    --s3: #b39ae0;
    --s4: #5fc9b6;
    --s5: #e9797d;
    --s6: #c9a227;
    --s7: #cb6cff;
    --grid: #262b33;
  }
}

:root[data-theme="dark"] {
  --bg:          #14161a;
  --bg-panel:    #1b1e24;
  --bg-sunken:   #101215;
  --bg-hover:    #232730;
  --ink:         #e8e9ec;
  --ink-2:       #b0b5bf;
  --ink-3:       #7d838f;
  --rule:        #2c313a;
  --rule-strong: #414753;
  --accent:      #6fb4e0;
  --accent-soft: #1b3040;
  --on-accent:   #0d1116;
  --pass:        #63c58c;
  --pass-soft:   #17301f;
  --warn:        #e0b155;
  --warn-soft:   #33260d;
  --fail:        #e9797d;
  --fail-soft:   #34191b;
  --s1: #6fb4e0;
  --s2: #e79a5c;
  --s3: #b39ae0;
  --s4: #5fc9b6;
  --s5: #e9797d;
  --s6: #c9a227;
  --s7: #cb6cff;
  --grid: #262b33;
}

* { box-sizing: border-box; }

/* Keyboard focus must be visible everywhere, not only on the number inputs. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* ---------- layout ---------- */
/* A flex column so the panels above the views can be REORDERED per view.
   On the Hardware map the picture is the point, and it used to sit below a
   1215 px case selector and a 722 px requirement panel — nearly five screens
   down. There, the selector stays on top (it is what changes the drawing, so
   it has to be reachable) but compact, and the requirement panel moves below
   the map, where it belongs as reference. Everywhere else the requirement is
   the thing the numbers are judged against, so it stays first. */
.wrap {
  max-width: 1560px; margin: 0 auto; padding: 0 20px 80px;
  display: flex; flex-direction: column;
}
/* Every child needs an explicit order once .wrap is a flex container: the
   default is 0, which sent the footer to the TOP of the page. */
.wrap > * { order: 5; }
.wrap > #budgetPanel { order: 1; }
.wrap > .cols { order: 2; }
.wrap > footer.foot { order: 9; }
/* On the map the requirement panel is reference material, so it goes after
   the map; on every other view it is the thing the numbers are judged
   against, so it stays first. */
body[data-view="map"] .wrap > .cols { order: 1; }
body[data-view="map"] .wrap > #budgetPanel { order: 2; }

header.top {
  border-bottom: 1px solid var(--rule);
  background: var(--bg-panel);
  position: sticky; top: 0; z-index: 40;
}
header.top .inner {
  max-width: 1560px; margin: 0 auto; padding: 11px 20px;
  display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap;
}
/* The home link reads as a breadcrumb in front of the title: tertiary ink,
   the sub-title's size, and a separator kept out of the hover underline
   (inline-block does not inherit text-decoration). */
header.top .home { font-size: 12.5px; color: var(--ink-3); text-decoration: none; margin-right: -6px; }
header.top .home::after { content: "/"; display: inline-block; margin-left: 9px; color: var(--rule-strong); }
header.top .home:hover { color: var(--accent); text-decoration: underline; }
/* On a phone the title cannot share the breadcrumb's row, so the link took a
   row of the sticky header to itself, its "/" pointing at nothing. Below
   480px the copy at the end of the nav takes over instead, which fits on the
   nav's last row at most phone widths. Declared before nav a:hover so
   hovering still inks it. */
header.top nav a.navhome { display: none; color: var(--ink-3); }
@media (max-width: 480px) {
  header.top .home { display: none; }
  header.top nav a.navhome { display: inline-block; }
}
header.top h1 { font-size: 15.5px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
header.top .sub { color: var(--ink-3); font-size: 12.5px; }
header.top nav { margin-left: auto; display: flex; gap: 3px; flex-wrap: wrap; }
header.top nav a, header.top nav button {
  font: inherit; font-size: 12.5px; color: var(--ink-2); text-decoration: none;
  padding: 4px 9px; border-radius: 5px; border: 1px solid transparent;
  background: none; cursor: pointer;
}
header.top nav a:hover, header.top nav button:hover { background: var(--bg-hover); color: var(--ink); }
header.top nav a.on { background: var(--accent-soft); color: var(--accent); border-color: var(--rule); }

/* ---------- compact case selector ----------
   A control strip inside the map panel, not a panel of its own. */
.pk-bar { padding: 9px 14px; border-bottom: 1px solid var(--rule); background: var(--bg-panel); }
.pk-bar.hidden { display: none !important; }
.pk-geo { font-size: 11.5px; color: var(--ink-3); }
.pk-warn > summary {
  cursor: pointer; list-style: none; font-size: 11.5px; color: var(--warn);
  display: inline-flex; align-items: center; gap: 5px; width: fit-content;
}
.pk-warn.hard > summary { color: var(--fail); }
.pk-warn > summary::-webkit-details-marker { display: none; }
.pk-warn > summary::before { content: "\25B8"; font-size: 9px; transition: transform .12s; }
.pk-warn[open] > summary::before { transform: rotate(90deg); }

.pk { display: flex; flex-direction: column; gap: 7px; }
/* Row gap is asymmetric on purpose: 8px between wrapped LINES, 20px between
   the groups on a line. A family's label sits 6px from its own chips (see
   .pk-grp) and 20px from the next family, so proximity alone says what
   belongs to what — which is the only cue there is once a row wraps. */
.pk-row { display: flex; gap: 8px 20px; align-items: center; flex-wrap: wrap; }
.pk-row-sel { gap: 8px 14px; }

/* ONE flex item per family, so a wrap can never separate a label from the
   options it names. They used to be siblings of the row: at 1440 px the
   "Baseband" label sat at the end of line one while its B1-B5 chips began
   line two underneath the LO chips, so the label read as part of the LO row
   and the chips read as unlabelled. Grouping is the fix; the gaps above are
   what make the grouping visible. */
/* baseline, not center: once the window is narrow enough that a family's
   chips wrap to two or three lines inside the group, centring floats the
   label to the middle of the block — at 375 px the "LO" label sat 81 px
   BELOW its own first option. A baseline ties it to the first row of chips
   at every width. */
.pk-grp { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
/* Inside a group the label hugs its options — the 58px gutter below exists to
   align labels in the stacked chooser rows, and here it would only push the
   name away from the thing it names. */
.pk-grp > .pk-lab { min-width: 0; }
.pk-lab {
  font: 10px var(--mono); text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); flex: none; min-width: 58px;
}
.pk-chips { display: flex; gap: 4px; flex-wrap: wrap; min-width: 0; }
.pk-chips .pchip { white-space: nowrap; }
.pk-chips .pchip.on {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600;
}
.pk-sel { display: flex; align-items: center; gap: 5px; }
.pk-sel .pk-lab { min-width: 0; }
.pk-sel select {
  font: 11.5px var(--sans); padding: 3px 5px; max-width: 200px;
  border: 1px solid var(--rule-strong); border-radius: 4px;
  background: var(--bg-panel); color: var(--ink);
}
.pk-foot { gap: 14px; }
.pk-foot .pk-geo { flex: 1 1 340px; min-width: 0; }
.pk-foot .pk-why { flex: none; }
.pk-why > summary {
  cursor: pointer; list-style: none; font-size: 11.5px; color: var(--accent);
  display: inline-flex; align-items: center; gap: 5px; width: fit-content;
}
.pk-why > summary::-webkit-details-marker { display: none; }
.pk-why > summary::before { content: "\25B8"; font-size: 9px; transition: transform .12s; }
.pk-why[open] > summary::before { transform: rotate(90deg); }
.pk-why-body { padding-top: 6px; max-width: 78ch; }
.pk-why-body .note { margin: 0 0 7px; font-size: 12px; }
.pk-why-body .note:last-child { margin-bottom: 0; }

/* ---------- glossary ----------
   A term the tool has defined. Underlined, not coloured: these sit inside
   dense tables and prose, and a page of blue links would be worse than the
   problem. */
button.gterm {
  font: inherit; color: inherit; background: none; border: 0; padding: 0;
  cursor: help; text-decoration: underline dotted;
  text-underline-offset: 2px; text-decoration-thickness: 1px;
  text-decoration-color: var(--ink-3);
}
button.gterm:hover { text-decoration-color: var(--accent); color: var(--accent); }
.gpop {
  position: absolute; z-index: 80; max-width: 320px;
  background: var(--bg-panel); border: 1px solid var(--rule-strong);
  border-radius: 7px; padding: 10px 12px;
  box-shadow: 0 6px 22px rgba(0,0,0,.18);
}
.gpop-h { font: 600 12.5px var(--sans); color: var(--ink); }
.gpop-s { font: 11.5px var(--mono); color: var(--accent); margin: 2px 0 6px; }
.gpop-l { font-size: 12px; line-height: 1.45; color: var(--ink-2); }

/* ---------- context bar ----------
   Says which architecture is selected and what the model concluded, on every
   view. Lives inside the sticky header so it never scrolls away. */
.ctxbar {
  max-width: 1560px; margin: 0 auto; padding: 0 20px 8px;
  display: flex; gap: 7px; align-items: center; flex-wrap: wrap;
  font-size: 11.5px;
}
.ctxchip {
  display: inline-flex; align-items: baseline; gap: 5px;
  padding: 2px 8px; border-radius: 20px; text-decoration: none;
  border: 1px solid var(--rule-strong); color: var(--ink-2);
  background: var(--bg-panel); white-space: nowrap;
}
.ctxchip:hover { background: var(--bg-hover); color: var(--ink); border-color: var(--accent); }
.ctxchip .ck { color: var(--ink-3); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.ctxchip .cv { font-weight: 600; color: var(--ink); }
.ctxchip.verdict-chip { background: var(--pass-soft); border-color: transparent; }
.ctxchip.verdict-chip .ck { color: var(--pass); }
.ctxchip.warn-chip { background: var(--fail-soft); border-color: transparent; }
.ctxchip.warn-chip .ck { color: var(--fail); font-weight: 700; }
.ctxchip.hidden { display: none !important; }
/* A verdict such as "A4 Mid + ×M + B3 H-tree active ≈ B4 Current-mode" is
   wider than a phone, so unwrapped it scrolled every view but Start sideways.
   On a phone the value wraps; the "model picks" label stays on one line. */
@media (max-width: 480px) {
  .ctxchip.verdict-chip { white-space: normal; min-width: 0; }
  .ctxchip.verdict-chip .ck { white-space: nowrap; }
}
.ctxsep { width: 1px; height: 15px; background: var(--rule); }
.ctxgrow { margin-left: auto; color: var(--ink-3); }
@media (max-width: 720px) { .ctxgrow { margin-left: 0; flex-basis: 100%; } }

/* One line under each view's heading saying what the view is FOR and whether
   it shows ALL options or only the selected build. The nine views silently
   split into those two kinds, and a reader who changed the picker, opened
   Phase noise and saw six unchanged curves concluded the control was broken. */
.viewintro {
  margin: 16px 0 -4px; font-size: 12.5px; color: var(--ink-2);
  display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
}
.viewintro .scope {
  font: 10px var(--mono); text-transform: uppercase; letter-spacing: .05em;
  padding: 1px 6px; border-radius: 3px; flex: none;
  background: var(--bg-sunken); color: var(--ink-3); border: 1px solid var(--rule);
}
.viewintro .scope.all { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.viewintro .scope.one { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.cols { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 22px; align-items: start; }
/* minmax(0,1fr), not 1fr: a bare 1fr floors at min-content, so the whole
   document went 714 px wide at a 375 px viewport and the header and half of
   every panel panned off-screen. */
/* Collapsed to one column, the RESULTS go first. The source order puts the
   parameter column first because that is where it belongs beside the results
   on a wide screen — but stacked it meant seventy inputs between the reader
   and any number at all: the map SVG started 1912 px down at a 900 px width,
   and about 4000 px down on a phone. */
@media (max-width: 1080px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .cols > main { order: 1; }
  .cols > aside.params { order: 2; }
}

main { min-width: 0; }
/* The rail pins under a STICKY header whose height is not a constant: 121px
   at a desktop width, 177px at 1080 where the nav wraps, 90px on the start
   view where the context bar is hidden. `top: 60px` therefore parked the
   rail's first 61px - its panel heading, and now the quick-reconfiguration
   rows - permanently behind the header on every scrolled view, because the
   header carries z-index 40 and the rail carries none. --hdr-h is measured by
   syncRailTop() in js/app.js; the 121px fallback is the desktop value, so the
   rule is already right before the first measurement. */
aside.params {
  position: sticky; top: calc(var(--hdr-h, 121px) + 4px);
  max-height: calc(100vh - var(--hdr-h, 121px) - 20px);
  overflow-y: auto; padding-right: 3px;
}
@media (max-width: 1080px) { aside.params { position: static; max-height: none; } }

/* ---------- panels ---------- */
.panel {
  background: var(--bg-panel); border: 1px solid var(--rule);
  border-radius: 8px; margin: 18px 0; overflow: hidden;
}
.panel > h2 {
  margin: 0; padding: 10px 14px; font-size: 13px; font-weight: 650;
  border-bottom: 1px solid var(--rule); background: var(--bg-sunken);
  letter-spacing: 0.01em; display: flex; align-items: center; gap: 8px;
}
.panel > h2 .tag {
  font: 10.5px var(--mono); color: var(--ink-3); font-weight: 400;
  border: 1px solid var(--rule); border-radius: 4px; padding: 1px 5px;
}
.panel > h2 .grow { margin-left: auto; font-weight: 400; font-size: 11.5px; color: var(--ink-3); }
.panel .body { padding: 14px; }
.panel .body.flush { padding: 0; }
.note { color: var(--ink-2); font-size: 12.5px; margin: 0 0 10px; }
.note:last-child { margin-bottom: 0; }
.note code, code.ic { font: 11.5px var(--mono); background: var(--bg-sunken); padding: 1px 4px; border-radius: 3px; }

/* ---------- parameter controls ---------- */
.pgroup { border-bottom: 1px solid var(--rule); }
.pgroup:last-child { border-bottom: 0; }
.pgroup > summary {
  padding: 9px 13px; cursor: pointer; font-size: 12.5px; font-weight: 600;
  list-style: none; display: flex; align-items: center; gap: 7px; background: var(--bg-panel);
}
.pgroup > summary::-webkit-details-marker { display: none; }
.pgroup > summary::before { content: "\25B8"; color: var(--ink-3); font-size: 10px; transition: transform .12s; }
.pgroup[open] > summary::before { transform: rotate(90deg); }
.pgroup > summary:hover { background: var(--bg-hover); }
.pgroup > summary .cnt { margin-left: auto; font: 10.5px var(--mono); color: var(--ink-3); font-weight: 400; }
.pgroup .fields { padding: 2px 13px 12px; }

/* 1fr for the label, a fixed field, and a hair for the per-parameter undo */
.field { display: grid; grid-template-columns: 1fr 92px 16px; gap: 5px 6px; align-items: center; margin: 7px 0; }
.field .hint { grid-column: 1 / -1; }
button.pundo {
  border: 0; background: none; cursor: pointer; padding: 0; line-height: 1;
  font-size: 12px; color: var(--ink-3); border-radius: 3px;
}
button.pundo:hover { color: var(--accent); background: var(--bg-hover); }
button.pundo:disabled { opacity: 0; cursor: default; pointer-events: none; }
.field > label .conf { margin-left: 4px; vertical-align: 1px; }

/* parameter search + chips */
.pfilter { display: flex; gap: 6px; padding: 9px 13px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; align-items: center; }
.pfilter input[type=search] {
  flex: 1 1 120px; min-width: 0; font: 12px var(--sans);
  padding: 4px 7px; border: 1px solid var(--rule-strong); border-radius: 4px;
  background: var(--bg-panel); color: var(--ink);
}
.pchip {
  font: 11px var(--sans); padding: 3px 8px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--rule-strong); background: var(--bg-panel); color: var(--ink-2);
}
.pchip:hover { background: var(--bg-hover); }
.pchip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.pfilter .pcount { flex-basis: 100%; font-size: 11px; color: var(--ink-3); }
.field > label { font-size: 12px; color: var(--ink-2); line-height: 1.3; }
.field > label .u { color: var(--ink-3); font: 10.5px var(--mono); }
.field input[type=number], .field select, .field input[type=text] {
  font: 12px var(--mono); text-align: right; width: 100%;
  padding: 4px 6px; border: 1px solid var(--rule-strong); border-radius: 4px;
  background: var(--bg-panel); color: var(--ink);
}
.field select { text-align: left; }
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.field .hint { grid-column: 1 / -1; font-size: 11px; color: var(--ink-3); margin-top: -2px; }
.field.wide { grid-template-columns: 1fr; }
.field.dirty > label { color: var(--accent); font-weight: 600; }

.rowbtns { display: flex; gap: 6px; padding: 10px 13px; border-top: 1px solid var(--rule); background: var(--bg-sunken); flex-wrap: wrap; }
button.btn {
  font: 12px var(--sans); padding: 5px 11px; border-radius: 5px;
  border: 1px solid var(--rule-strong); background: var(--bg-panel); color: var(--ink); cursor: pointer;
}
button.btn:hover { background: var(--bg-hover); }
button.btn.pri { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
button.btn.pri:hover { filter: brightness(1.08); }
button.btn:disabled { opacity: .5; cursor: default; }

/* ---------- quick reconfiguration, at the top of the rail ----------
   Four segmented rows of code chips. `flex: 1 1 0` is what makes this fit:
   the run divides whatever inner width the rail actually has, so nothing
   here hard-codes the 284px a classic 15px scrollbar leaves, it is equally
   correct at the 299px an overlay scrollbar leaves and at the full width
   the rail takes when it restacks below 1080px, and it cannot produce a
   horizontal scrollbar at any width. Everything else is the existing .pchip
   and the existing palette tokens, in both themes. */
.qk { padding: 9px 13px 10px; display: flex; flex-direction: column; gap: 5px; }
.qk-grp { display: flex; align-items: center; gap: 6px; min-width: 0; }
/* 26px aligns LO / BB / ANT / K on one gutter so the four rows read as one
   control; the picker's 58px would spend a fifth of the rail on labels. */
.qk-lab {
  font: 10px var(--mono); text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); flex: none; min-width: 26px;
}
.qk-chips { display: flex; gap: 4px; flex: 1 1 auto; min-width: 0; }
.qk-chips .pchip {
  flex: 1 1 0; min-width: 0; padding: 3px 2px; text-align: center;
  white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums;
}
.qk-chips .pchip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* A K the selected arrangement does not allow: the model clamps it and the
   banner reports it, and this is that same fact in the control - the chip
   marks the value the model is ACTUALLY using, dashed to say it is a clamp
   and not your choice. The map picker's equivalent silently displays its
   first option instead. */
.qk-chips .pchip.qk-clamped { border-style: dashed; }
.panel > h2 .grow.qk-ok { color: var(--pass); }
.panel > h2 .grow.qk-over { color: var(--fail); }

/* ---------- tables ---------- */
/* Wide content scrolls inside its own box; the PAGE must never scroll
   sideways. overflow-x alone does not achieve that — a block in a grid or
   flex track still takes its content's width unless it is told not to, and
   a 14-column systems comparison is 4200 px wide. max-width plus min-width:0
   pins it to the panel and lets the internal scrollbar do the work. */
.tscroll { overflow-x: auto; max-width: 100%; min-width: 0; }
/* thead's `position: sticky` was dead: .tscroll never scrolls vertically, so
   the header simply left with the page and by row 40 of 54 the reader had six
   columns of numbers and nothing saying whose. Capping the height gives the
   sticky header something to stick inside. Short viewports opt out — a 300 px
   scroll box is worse than no box. */
.tscroll.tall { max-height: calc(100vh - 148px); overflow-y: auto; }
@media (max-height: 620px) { .tscroll.tall { max-height: none; } }
table.grid { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.grid th, table.grid td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--rule); white-space: nowrap; }
table.grid th { font-weight: 600; font-size: 11.5px; color: var(--ink-2); background: var(--bg-sunken); }
table.grid thead th { position: sticky; top: -1px; z-index: 2; }
table.grid th:first-child, table.grid td:first-child { text-align: left; white-space: normal; min-width: 200px; }
/* Cells holding a SENTENCE, not a number. Without this the blanket
   `white-space: nowrap` above made the Feasibility and Risk rows set the
   column width for the whole table: the LO comparison was ~2600 px wide
   inside a ~1030 px panel, so six numbers that fit on one screen needed two
   and a half screens of sideways scrolling. */
table.grid td.vw {
  white-space: normal; min-width: 150px; max-width: 210px;
  font: 11.5px/1.35 var(--sans); text-align: left;
  font-variant-numeric: normal;
}
/* Systems comparison: with up to twelve columns the table scrolls sideways
   and the metric name is the first thing to leave the screen, which makes
   the numbers unreadable. Pin it. The explicit background matters — a
   transparent sticky cell lets the scrolled columns show through it. */
/* The roster's first column is a checkbox, and the 200px minimum meant for
   metric names left it absurdly wide. Only that table opts out. */
table.grid.narrow1 th:first-child, table.grid.narrow1 td:first-child {
  min-width: 0; width: 1%; white-space: nowrap; text-align: center;
}
table.grid.sticky1 th:first-child, table.grid.sticky1 td:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--bg-panel);
  box-shadow: 1px 0 0 var(--rule);
}
table.grid.sticky1 thead th:first-child { z-index: 3; background: var(--bg-sunken); }
table.grid.sticky1 tr.sect td:first-child { background: var(--bg-sunken); }
table.grid.sticky1 tbody tr:hover td:first-child { background: var(--bg-hover); }
table.grid td.v { font: 12px var(--mono); font-variant-numeric: tabular-nums; }
table.grid tbody tr:hover { background: var(--bg-hover); }
table.grid tr.sect td {
  background: var(--bg-sunken); font-weight: 650; font-size: 11px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); text-align: left;
}
table.grid .mn { font-weight: 500; }
table.grid .mn small { display: block; font-weight: 400; color: var(--ink-3); font-size: 11px; }
table.grid th.rec { color: var(--accent); }
table.grid td.rec, table.grid th.rec { background: var(--accent-soft); }
/* The column the reader has actually selected in the picker. An underline,
   deliberately, so it never competes with the accent-soft tint that marks the
   model's recommendation — the two are different claims and used to be
   conflated into one badge reading "selected". */
table.grid th.cur, table.grid td.cur { box-shadow: inset 0 -2px 0 var(--warn); }
table.grid td.best { font-weight: 650; }
/* Neutral, not green: only four of ~54 rows carry a requirement at all, so a
   green marker on the other fifty read as "meets spec" when it means nothing
   of the kind. */
table.grid td.best::after { content: " \25C0"; font-size: 8px; color: var(--ink-2); vertical-align: 2px; }

/* Verdicts carried a colour and nothing else — invisible printed, projected,
   or with red-green deficiency. The glyph is the primary channel now. */
.v.pass { color: var(--pass); }
.v.warn { color: var(--warn); }
.v.fail { color: var(--fail); }
.v.pass::after, .v.warn::after, .v.fail::after { font-size: 9px; vertical-align: 1px; opacity: .85; }
.v.pass::after { content: " \2713"; }
.v.warn::after { content: " !"; }
.v.fail::after { content: " \2717"; }
.badge {
  display: inline-block; font: 10px var(--mono); padding: 1px 5px; border-radius: 3px;
  border: 1px solid var(--rule-strong); color: var(--ink-3); vertical-align: 1px;
}
.badge.pass { background: var(--pass-soft); color: var(--pass); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.fail { background: var(--fail-soft); color: var(--fail); border-color: transparent; }
.badge.acc  { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* confidence pips */
.conf { font: 10px var(--mono); padding: 1px 5px; border-radius: 3px; white-space: nowrap; }
.conf.c-datasheet   { background: var(--pass-soft); color: var(--pass); }
.conf.c-literature  { background: var(--accent-soft); color: var(--accent); }
.conf.c-scaled      { background: var(--warn-soft); color: var(--warn); }
.conf.c-guess       { background: var(--fail-soft); color: var(--fail); }

/* ---------- spec banner ---------- */
.budget { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--rule); }
.budget .cell { background: var(--bg-panel); padding: 10px 13px; }
.budget .cell .k { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .045em; }
.budget .cell .n { font: 600 19px/1.25 var(--mono); font-variant-numeric: tabular-nums; margin-top: 3px; }
.budget .cell .n small { font-size: 12px; font-weight: 400; color: var(--ink-3); }
.budget .cell .d { font-size: 11px; color: var(--ink-3); margin-top: 2px; line-height: 1.35; }
.budget .cell.bind { background: var(--fail-soft); }
.budget .cell.bind .k { color: var(--fail); font-weight: 700; }
/* The binding cell sits on a tinted ground, where tertiary text falls just
   under 4.5:1 — and this is the cell that most needs reading anyway. */
.budget .cell.bind .d, .budget .cell.bind .n small { color: var(--ink-2); }

/* ---------- hardware map: drawing beside inspector ----------
   The map's viewBox is taller than wide and the element is capped at 76vh, so
   preserveAspectRatio letterboxes it horizontally — the wider the window, the
   more empty band. The inspector lives in that band. The drawing keeps
   flex:1 and min-width:0 so it still gets everything the aside does not take,
   and because it is HEIGHT-bound at these sizes, taking 340px off its width
   does not shrink it at all. */
.mapsplit { display: flex; align-items: stretch; gap: 0; }
.mapsplit > .chartbox { flex: 1 1 auto; min-width: 0; }
.mapsplit > .mapside {
  flex: 0 0 340px; min-width: 0;
  border-left: 1px solid var(--rule);
  max-height: 76vh; overflow-y: auto;
}
.mapside-h {
  padding: 10px 13px; font-size: 13px; font-weight: 650;
  border-bottom: 1px solid var(--rule); background: var(--bg-sunken);
  display: flex; align-items: center; gap: 8px;
}
.mapside-h .tag {
  font: 10.5px var(--mono); color: var(--ink-3); font-weight: 400;
  border: 1px solid var(--rule); border-radius: 4px; padding: 1px 5px;
}
/* The inspector is a two-column table in a 340px rail, and table.grid is
   dimensioned for the WIDE comparison tables: a 200px floor under the label
   column, and nowrap on every cell so columns of figures stay on one line.
   In the rail those two together made the table 674px inside a 324px box —
   350px of overflow, a horizontal scrollbar, and values cut mid-value ("32 (4"
   for a row that reads "32 (4 RX + 4 TX per die, each an IQ pair at
   baseband)"). Here the value is a sentence, not a column of figures, so it
   should wrap; auto layout then fits the table to the rail at any width,
   including the stacked full-width case below 1300px. */
.mapside .inspector table.grid { width: 100%; }
.mapside .inspector table.grid td {
  white-space: normal; overflow-wrap: break-word; padding: 5px 9px;
}
.mapside .inspector table.grid td:first-child { min-width: 0; }
/* No width floor on the value column: measured with and without one, auto
   layout gives the same 119/205 split in the rail either way, and a floor
   only distorted the stacked full-width case into a 735px value column. */
/* Below this the band is no longer wide enough to give away: the drawing
   would start losing width to the aside, so they stack instead. */
@media (max-width: 1300px) {
  .mapsplit { display: block; }
  .mapsplit > .mapside {
    flex: none; border-left: 0; border-top: 1px solid var(--rule);
    max-height: none; overflow-y: visible;
  }
}

/* ---------- charts ---------- */
.chartbox { padding: 8px 6px 0; }
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
/* The aperture map is nearly square plus board margins top and bottom, so at
   full container width it grows taller than the viewport. Cap it so the whole
   floorplan is visible at once — preserveAspectRatio letterboxes it. */
svg.chart.map {
  display: block; width: 100%; height: auto; max-height: 76vh;
  /* min-height wins over max-height in CSS, so the map cannot collapse in an
     embedding context where vh resolves to zero during layout */
  min-height: 320px;
  margin: 0 auto;
  /* pan-y, not none: with `none` the map swallowed one-finger vertical swipes,
     so on a phone the landing view could not be scrolled past at all. The
     browser keeps vertical gestures; horizontal drags still pan the map, and
     an in-flight pan gets a pointercancel that endDrag already handles. */
  touch-action: pan-y;
}
/* THE MAP'S DECORATION MUST NOT EAT THE TILE CLICK.
   Every glyph in an SVG is hit-testable by default, so the routing traces,
   the LO/baseband nodes and the labels drawn OVER the tiles were intercepting
   clicks meant for the tile underneath: measured at the default build, 8 of
   the 20 visible tiles could not be selected at any of five sample points,
   because a line or a node sat on top. These four tag types carry no <title>
   and no handler anywhere in the map — 412 elements, 0 tooltips, 0 cursors —
   so making them transparent to the pointer costs nothing and gives every
   tile its whole area back. The tile rects, the block glyphs and the port
   cells keep their hit testing; they are the things with something to say. */
svg.chart.map line,
svg.chart.map circle,
svg.chart.map path,
svg.chart.map text { pointer-events: none; }

svg.chart text { font: 10.5px var(--sans); fill: var(--ink-3); }
svg.chart text.axlabel { font-size: 11px; fill: var(--ink-2); }
svg.chart .gl { stroke: var(--grid); stroke-width: 1; }
svg.chart .ax { stroke: var(--rule-strong); stroke-width: 1; }
svg.chart .ser { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .mask { fill: none; stroke: var(--s5); stroke-width: 1.6; stroke-dasharray: 5 3; }
svg.chart .bar { stroke: none; }
svg.chart .blab { font: 10px var(--mono); fill: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: 5px 16px; padding: 4px 12px 12px; font-size: 11.5px; color: var(--ink-2); }
.legend .li { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 15px; height: 3px; border-radius: 2px; flex: none; }
/* currentColor, not --s5: the swatch must be the series' own colour, or it
   points at the wrong curve. charts.js sets `color` on the element. */
.legend .sw.dash { height: 0; border-top: 2px dashed currentColor; color: var(--s5); }
.chartgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 18px; }
@media (max-width: 560px) { .chartgrid { grid-template-columns: 1fr; } }

/* ---------- prose / decision ---------- */
.prose { max-width: 76ch; }
.prose h3 { font-size: 13.5px; margin: 22px 0 7px; }
.prose h3:first-child { margin-top: 0; }
.prose h4 { font-size: 12.5px; margin: 16px 0 5px; color: var(--ink-2); }
.prose p { margin: 0 0 11px; color: var(--ink-2); font-size: 13px; }
.prose ul, .prose ol { margin: 0 0 11px; padding-left: 20px; color: var(--ink-2); font-size: 13px; }
.prose li { margin: 3px 0; }
.prose strong { color: var(--ink); font-weight: 600; }
.kv { font: 12px var(--mono); color: var(--ink); background: var(--bg-sunken); padding: 1px 4px; border-radius: 3px; font-variant-numeric: tabular-nums; }
.callout {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 10px 13px; border-radius: 0 6px 6px 0; margin: 0 0 14px; font-size: 12.5px; color: var(--ink-2);
}
.callout.warnc { border-left-color: var(--warn); background: var(--warn-soft); }
.callout.failc { border-left-color: var(--fail); background: var(--fail-soft); }
.callout strong { color: var(--ink); }
.callout p { margin: 0 0 8px; font-size: 12.5px; }
.callout p:last-child { margin: 0; }

.verdict { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border-bottom: 1px solid var(--rule); background: var(--pass-soft); flex-wrap: wrap; }
.verdict .vlab { font: 10.5px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--pass); padding-top: 3px; flex: none; }
.verdict .vmain { min-width: 240px; flex: 1; }
.verdict .pick { font: 650 14.5px var(--sans); color: var(--ink); }
.verdict .why { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }

/* ---------- misc ---------- */
.toolbar { display: flex; gap: 7px; flex-wrap: wrap; padding: 11px 14px; align-items: center; }
.toolbar .sp { margin-left: auto; }
.hidden { display: none !important; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); padding: 0 8px; background: var(--bg-sunken); overflow-x: auto; }
.tabs button {
  font: 12.5px var(--sans); padding: 8px 12px; border: 0; border-bottom: 2px solid transparent;
  background: none; color: var(--ink-3); cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
footer.foot { border-top: 1px solid var(--rule); margin-top: 36px; padding: 20px; text-align: center; color: var(--ink-3); font-size: 12px; }
footer.foot a { color: var(--ink-2); }
.eqn { font: 11.5px/1.6 var(--mono); background: var(--bg-sunken); padding: 9px 11px; border-radius: 5px; overflow-x: auto; color: var(--ink); margin: 0 0 10px; white-space: pre; }
.flash {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 6px;
  font-size: 12.5px; z-index: 90; box-shadow: 0 4px 14px rgba(0,0,0,.22);
}

/* ---------- the start page ----------
   The landing view. Everything here exists to make the first screen answer
   "what is this, what did it conclude, where do I click" and nothing else.

   The three chrome elements that make every other view dense are hidden:
   the 101-control parameter rail, the derived-requirement banner and the
   context bar. The rail needs BOTH halves of this rule - display:none alone
   leaves `main` auto-placed into the 330px track, so the whole page renders
   a third of its width. */
body[data-view="start"] .cols { grid-template-columns: minmax(0, 1fr); }
body[data-view="start"] .cols > aside.params { display: none; }
body[data-view="start"] .ctxbar { display: none; }

.start { max-width: 900px; padding: 4px 0 0; }
.start h2 {
  margin: 22px 0 10px; font-size: 19px; font-weight: 650;
  letter-spacing: -0.01em; line-height: 1.3; color: var(--ink);
}
.start h3 {
  margin: 26px 0 11px; font-size: 13.5px; font-weight: 650;
  letter-spacing: 0.01em; color: var(--ink);
}
.startlede { margin: 0; max-width: 72ch; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }

/* The verdict line. `is` carries the live clause; the LIVE pill marks it as
   recomputed rather than written, because every other sentence on this page
   is a fixed definition and the reader cannot otherwise tell them apart. */
.startverdict {
  margin: 16px 0 0; max-width: 78ch; font-size: 13.5px; line-height: 1.6; color: var(--ink);
  padding: 11px 13px; border: 1px solid var(--rule);
  border-left: 3px solid var(--accent); border-radius: 6px; background: var(--bg-panel);
}
.startverdict .lv {
  font: 500 9.5px var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 3px; padding: 2px 5px; margin-right: 8px; vertical-align: 1px;
}
.startverdict b { font-weight: 650; }
/* A tie is not a verdict, so it does not get the verdict's accent rule. */
.startverdict .tie { color: var(--warn); font-weight: 650; }
.startverdict.failc { border-left-color: var(--fail); background: var(--fail-soft); }
.startverdict.failc .lv { color: var(--fail); background: transparent; border: 1px solid var(--fail); }

.startgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
a.startcard {
  display: flex; flex-direction: column; gap: 7px;
  padding: 13px 14px 11px; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--bg-panel); text-decoration: none; color: inherit;
}
/* No colour transition here, deliberately. A transition whose endpoint is a
   var() latches at its start value when the variable itself changes, so
   fading the card on hover also left all three cards painted light over a
   dark page after the theme button was pressed — measured, not theorised.
   Everything else in this stylesheet transitions only `transform`. */
a.startcard:hover { border-color: var(--rule-strong); background: var(--bg-hover); }
a.startcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a.startcard .sw {
  font: 500 10px var(--mono); letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-3);
}
a.startcard .sq { font-size: 14.5px; font-weight: 650; line-height: 1.3; color: var(--ink); }
/* flex:1 so the three rules along the card feet line up whatever the copy */
a.startcard .sd { font-size: 12.5px; line-height: 1.5; color: var(--ink-2); flex: 1 1 auto; }
a.startcard .sg {
  display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  margin-top: 3px; padding-top: 8px; border-top: 1px solid var(--rule);
  font: 11.5px var(--mono); color: var(--ink-3);
}
a.startcard .sgo { color: var(--accent); font-weight: 500; }
a.startcard:hover .sw, a.startcard:hover .sg { color: var(--ink-2); }

.startmore { margin: 20px 0 0; max-width: 78ch; font-size: 12.5px; line-height: 1.55; color: var(--ink-3); }

@media (max-width: 640px) {
  .start h2 { font-size: 17px; }
  .startgrid { grid-template-columns: minmax(0, 1fr); }
}
