/* Nucleus Net — styles. Tokens first, components after. */
:root {
  color-scheme: light;
  --ground: #f4f3f7;
  --surface: #ffffff;
  --surface-2: #ebeaf1;
  --surface-3: #dfdde8;
  --ink: #17161d;
  --ink-2: #4d4b58;
  --ink-3: #85828f;
  --line: #dcdae5;
  --line-strong: #b9b6c6;
  --accent: #4a3aa7;
  --accent-ink: #ffffff;
  --accent-soft: #e9e5f8;
  --regular: #2a78d6;
  --irregular: #eb6834;
  --good: #0ca30c;
  --good-text: #006300;
  --bad: #d03b3b;
  --test-series: #1baf7a;
  --map-zero: #e4e2ea;
  --shadow: 0 1px 2px rgba(23, 22, 29, 0.06), 0 8px 24px -12px rgba(23, 22, 29, 0.18);
  --radius: 10px;
  --font-display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #131217;
    --surface: #1c1b22;
    --surface-2: #26252e;
    --surface-3: #33323c;
    --ink: #f1f0f5;
    --ink-2: #c3c1cd;
    --ink-3: #8d8a99;
    --line: #33323c;
    --line-strong: #4a4856;
    --accent: #9085e9;
    --accent-ink: #14121f;
    --accent-soft: #2a2647;
    --regular: #3987e5;
    --irregular: #d95926;
    --good: #0ca30c;
    --good-text: #4cc94c;
    --bad: #e66767;
    --test-series: #199e70;
    --map-zero: #3a3943;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #131217;
  --surface: #1c1b22;
  --surface-2: #26252e;
  --surface-3: #33323c;
  --ink: #f1f0f5;
  --ink-2: #c3c1cd;
  --ink-3: #8d8a99;
  --line: #33323c;
  --line-strong: #4a4856;
  --accent: #9085e9;
  --accent-ink: #14121f;
  --accent-soft: #2a2647;
  --regular: #3987e5;
  --irregular: #d95926;
  --good: #0ca30c;
  --good-text: #4cc94c;
  --bad: #e66767;
  --test-series: #199e70;
  --map-zero: #3a3943;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  padding-block: 0 48px;
  padding-inline: clamp(16px, 2.5vw, 32px);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; line-height: 1.15; }
h1 { font-size: clamp(26px, 3vw, 34px); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; }
p { margin: 0; }
p + p { margin-top: 0.7em; }
a { color: var(--accent); }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
.num { font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, .thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* ---------- masthead ---------- */
.masthead {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px;
  padding-block: 18px 14px; border-bottom: 1px solid var(--line); margin-bottom: 18px;
}
.brand { flex: 1 1 320px; min-width: 0; }
.tagline { color: var(--ink-2); max-width: 62ch; margin-top: 2px; }
.stages { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; }
.stage {
  border: 0; background: transparent; padding: 8px 16px; border-radius: 999px; cursor: pointer;
  font-weight: 600; color: var(--ink-2); font-family: var(--font-display); font-size: 15px;
}
.stage:hover { color: var(--ink); }
.stage.is-active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.masthead-tools { display: flex; align-items: center; gap: 14px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.toggle input { accent-color: var(--accent); }
.btn-ghost {
  border: 1px solid var(--line-strong); background: transparent; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 13px; color: var(--ink-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- bench layout ---------- */
.bench { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
@media (min-width: 1100px) { .bench { grid-template-columns: minmax(0, 1fr) 360px; } }
.stage-panel { display: grid; gap: 18px; min-width: 0; }
.bench.no-inspector { grid-template-columns: minmax(0, 1fr); }
.fm-two { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .fm-two { grid-template-columns: 380px minmax(0, 1fr); } }
#fm-batch { display: block; width: 348px; max-width: 100%; height: auto; border-radius: 8px; }
#fm-lineup, #fm-views { display: block; width: 100%; height: auto; border-radius: 8px; }
.sl-two { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.sl-two > div { min-width: 0; }
#sl-attmap { max-width: 372px; }
#sl-links-ctl .ctl { min-width: 0; }
#sl-links-ctl .ctl.slim { min-width: 150px; }
#sl-links-seg button { white-space: nowrap; flex: 0 0 auto; }
@media (min-width: 900px) { .sl-two { grid-template-columns: 372px minmax(0, 1fr); align-items: start; } }
#sl-canvas, #sl-data-canvas, #sl-test-canvas { display: block; width: 100%; max-width: 372px; height: auto; border-radius: 8px; }
#sl-rank { display: block; width: 100%; height: auto; border-radius: 8px; }
.sl-rank-wrap, .sl-unrolled-wrap { overflow-x: auto; }
@media (max-width: 899px) { .sl-rank-wrap #sl-rank { min-width: 640px; } .sl-unrolled-wrap .net-wrap { min-width: 720px; } .stages { overflow-x: auto; } }
.tray.slides { grid-template-columns: repeat(auto-fill, 66px); gap: 8px; }
.thumb.slide { width: 66px; height: 54px; }
.thumb.slide canvas { image-rendering: auto; }
.fm-selected { margin-top: 12px; display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; font-size: 13px; color: var(--ink-2); }
.fm-selected .who { flex-basis: 100%; }
.fm-selected .txt { flex: 1 1 220px; display: grid; gap: 6px; align-content: start; }
.fm-selected .txt b { color: var(--ink); font-family: var(--font-mono); font-weight: 500; }
.fm-selected .nb canvas { display: inline-block; width: 32px; height: 32px; border-radius: 4px; border: 2px solid var(--surface-3); vertical-align: middle; margin: 0 4px; }
.fm-selected .btn { padding: 4px 10px; font-size: 12px; }
#fm-worth-legend { display: contents; }
.fm-selected .v { text-align: center; }
.fm-selected canvas { display: block; width: 64px; height: 64px; border-radius: 6px; border: 3px solid var(--surface-3); margin: 0 auto; }
.fm-selected .v.current canvas { border-color: var(--ink); }
.fm-selected .lbl { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin-top: 6px; }
.fm-selected .n { font-family: var(--font-mono); font-size: 12px; margin-top: 2px; }
.fm-selected .code { display: flex; gap: 2px; align-items: flex-end; height: 26px; margin: 4px auto 0; width: 64px; }
.fm-selected .code i { flex: 1; display: block; background: var(--accent); border-radius: 1px; }
.fm-selected .code i.neg { background: var(--regular); } .fm-selected .code i.pos { background: var(--irregular); }
.chart.scatter svg line.seg { stroke: var(--ink-3); stroke-opacity: 0.35; stroke-width: 1; }
.chart.scatter svg .pt.small { opacity: 0.6; }
.thumb.task-atypia.show-q { border-color: #7c3aed; } .thumb.task-enlargement.show-q { border-color: #0e9f6e; } .thumb.task-irregularity.show-q { border-color: #d97706; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.card > h2, .card > h3 { margin-bottom: 8px; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 10px; }
.lede { color: var(--ink-2); max-width: 70ch; }
.two-col { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .two-col { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.prose { max-width: 70ch; color: var(--ink-2); }
.prose strong { color: var(--ink); }
ul.prose { padding-left: 1.2em; margin: 0; }
ul.prose li + li { margin-top: 4px; }

/* class chips / legend */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); }
.chip.neg::before { background: var(--regular); }
.chip.pos::before { background: var(--irregular); }
.chip.neg { color: var(--regular); background: color-mix(in srgb, var(--regular) 12%, transparent); }
.chip.pos { color: var(--irregular); background: color-mix(in srgb, var(--irregular) 14%, transparent); }
.chip.plain::before { display: none; }
.chip.good { color: var(--good-text); background: color-mix(in srgb, var(--good) 14%, transparent); }
.chip.good::before { display: none; }
.chip.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.chip.bad::before { display: none; }
.good-text { color: var(--good-text); font-weight: 600; }
.bad-text { color: var(--bad); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 13px; color: var(--ink-2); }
.legend .swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }
.legend .swatch.ring { border: 3px solid var(--regular); background: transparent; }
.legend .swatch.ring.pos { border-color: var(--irregular); }
.legend .swatch.batch { border: 2px solid var(--accent); background: transparent; border-radius: 50%; }
.legend .swatch.badge { background: var(--bad); border-radius: 50%; color: #fff; font-size: 10px; line-height: 14px; text-align: center; font-weight: 700; }
.legend .line { display: inline-block; width: 22px; height: 0; border-top: 2px solid var(--accent); vertical-align: middle; margin-right: 5px; }
.legend .line.test { border-top: 2px dashed var(--test-series); }
.legend .line.chance { border-top: 1px dashed var(--ink-3); }
.legend .line.ceiling { border-top: 2px dashed var(--bad); }
.legend .line.stop { border-top: 2px dotted var(--test-series); }
.chart svg line.ceiling { stroke: var(--bad); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart svg line.stop { stroke: var(--test-series); stroke-width: 1.5; stroke-dasharray: 2 3; }
.chart svg text.marker { font-size: 9px; font-family: var(--font-mono); }
.chart svg text.marker.ceiling { fill: var(--bad); }
.chart svg text.marker.stop { fill: var(--test-series); }
.legend .swatch.flip { background: var(--bad); border-radius: 50%; color: #fff; font-size: 10px; line-height: 14px; text-align: center; font-weight: 700; }

/* ---------- thumbnails ---------- */
.tray { display: grid; grid-template-columns: repeat(auto-fill, 48px); gap: 7px; }
.thumb {
  position: relative; width: 48px; height: 48px; padding: 0; border: 3px solid var(--surface-3); border-radius: 6px; background: var(--surface-2);
  cursor: pointer; overflow: visible; display: block;
}
.thumb canvas { display: block; width: 100%; height: 100%; border-radius: 3px; image-rendering: auto; }
.thumb.call-0, .thumb.truth-0 { border-color: var(--regular); }
.thumb.call-1, .thumb.truth-1 { border-color: var(--irregular); }
.thumb.unknown { border-style: dashed; border-color: var(--line-strong); }
.thumb.unlabelled { border-style: dashed; border-color: var(--line-strong); opacity: 0.4; }
.thumb.unlabelled.selected { opacity: 0.8; }
.thumb.in-batch { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.thumb.selected { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.thumb.selected.in-batch { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink), 0 0 0 6px var(--accent); }
.thumb .badge {
  position: absolute; top: -8px; right: -8px; width: 18px; height: 18px; border-radius: 50%; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700;
  color: #fff; background: var(--bad); box-shadow: 0 0 0 2px var(--surface); display: none;
}
.thumb.wrong .badge { display: block; }
.thumb.right .badge { display: block; background: var(--good); }
.thumb .badge.q { display: block; background: var(--ink-3); }
.thumb .name { position: absolute; left: 0; right: 0; bottom: -3px; font-size: 9px; text-align: center; color: var(--ink-3); font-family: var(--font-mono); display: none; }
.tray.named .thumb { margin-bottom: 10px; }
.tray.named .thumb .name { display: block; bottom: -15px; }
.thumb .lab { position: absolute; top: -7px; left: -7px; width: 15px; height: 15px; border-radius: 50%; font: 700 9px/15px var(--font-mono); text-align: center; color: #fff; background: var(--ink-3); box-shadow: 0 0 0 2px var(--surface); display: none; }
.thumb.lab-b.show-lab .lab { display: block; }
.thumb .flip { position: absolute; bottom: -7px; left: -7px; width: 15px; height: 15px; border-radius: 50%; font: 700 10px/15px var(--font-mono); text-align: center; color: #fff; background: var(--bad); box-shadow: 0 0 0 2px var(--surface); display: none; }
.thumb.flipped.show-flip .flip { display: block; }
/* the inspector's pair of scans */
.labs { display: flex; gap: 14px; justify-content: center; }
.labs .lab { text-align: center; }
.labs canvas { display: block; width: 96px; height: 96px; border-radius: 6px; border: 3px solid var(--surface-3); margin: 0 auto; }
.labs .lab.current canvas { border-color: var(--ink); }
.labs .lbl { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin-top: 6px; }
.labs .p { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); margin-top: 2px; min-height: 1.3em; }
.labs .p.pos { color: var(--irregular); } .labs .p.neg { color: var(--regular); }
/* scores by test set */
.lab-scores { margin-top: 10px; display: grid; grid-template-columns: max-content repeat(3, max-content); gap: 3px 16px; font-size: 13px; align-items: baseline; }
.lab-scores .hd { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); }
.lab-scores .n { font-family: var(--font-mono); text-align: right; }
.lab-scores .row.current { font-weight: 600; color: var(--ink); }
.lab-scores .row { color: var(--ink-2); }
.sources { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- controls ---------- */
.controls { display: grid; gap: 12px 18px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.ctl { display: grid; gap: 4px; min-width: 0; }
.ctl > label, .ctl .lbl { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); display: flex; justify-content: space-between; gap: 8px; }
.ctl .val { font-family: var(--font-mono); text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 500; }
.ctl input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; }
.ctl select, .ctl input[type="number"] {
  width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px;
}
.ctl.check { display: flex; align-items: center; gap: 8px; font-size: 14px; padding-bottom: 4px; }
.ctl.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 10px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); flex: 1 1 0; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.is-active { background: var(--accent); color: var(--accent-ink); }
.ctl.wide { grid-column: span 2; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.btn { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.big { padding: 10px 18px; font-size: 15px; }
.recipes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); }
.recipe { border: 1px dashed var(--line-strong); background: transparent; border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.recipe:hover { border-style: solid; color: var(--accent); border-color: var(--accent); }
.status { display: flex; flex-wrap: wrap; gap: 6px 18px; font-family: var(--font-mono); font-size: 13px; color: var(--ink-2); margin-top: 12px; }
.status b { color: var(--ink); font-weight: 500; }
.note { font-size: 13px; color: var(--accent); min-height: 1.4em; margin-top: 6px; }
.lesson { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 8px; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); border-left: 3px solid var(--accent); font-size: 13.5px; line-height: 1.45; }
.lesson .step { font-weight: 700; color: var(--accent); font-family: "IBM Plex Mono", ui-monospace, monospace; white-space: nowrap; }
.lesson .lesson-actions { display: flex; gap: 6px; margin-left: auto; }
.lesson .btn { padding: 4px 10px; font-size: 12px; }
.lesson .player-ctl { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; white-space: nowrap; }
.lesson .player-ctl .btn { padding: 3px 8px; font-size: 12px; }
.lesson .player-ctl .speed { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-2); font-family: var(--font-mono); }
.lesson .player-ctl .speed input { width: 84px; }

/* ---------- network diagram ---------- */
.net-wrap { position: relative; width: 100%; }
.net-wrap canvas { display: block; width: 100%; height: auto; border-radius: 8px; }
.tip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--ground); font-family: var(--font-mono); font-size: 12px; padding: 4px 8px; border-radius: 6px;
  transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap; box-shadow: var(--shadow); z-index: 5;
}
.net-legend { margin-top: 8px; }

/* ---------- charts ---------- */
.curves { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .curves { grid-template-columns: 1fr 1fr; } .curves.single { grid-template-columns: minmax(0, 1fr); max-width: 640px; } }
.chart { position: relative; min-width: 0; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .title { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; }
.chart .title .now { font-family: var(--font-mono); font-weight: 500; color: var(--ink); }
.chart text { font-family: var(--font-mono); font-size: 11px; fill: var(--ink-3); }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart .train { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .test { fill: none; stroke: var(--test-series); stroke-width: 2; stroke-dasharray: 5 4; stroke-linejoin: round; stroke-linecap: round; }
.chart .chance { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .end { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .end.test { fill: var(--test-series); stroke: var(--surface); stroke-dasharray: none; }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; }
.chart .tipbox { fill: var(--ink); }
.chart .tiptext { fill: var(--ground); font-size: 11px; }
.chart .endlabel { fill: var(--ink); font-weight: 500; }
.scatter .pt { stroke: var(--surface); stroke-width: 2; cursor: pointer; }
.scatter .pt.neg { fill: var(--regular); }
.scatter .pt.pos { fill: var(--irregular); }
.scatter .pt.test { fill: var(--surface); stroke-width: 2.5; }
.scatter .pt.test.neg { stroke: var(--regular); }
.scatter .pt.test.pos { stroke: var(--irregular); }
.scatter .pt.unknown { fill: var(--surface); stroke: var(--ink-3); stroke-width: 2; }
.scatter .pt.selected { stroke: var(--ink); stroke-width: 3; }
.scatter .axlabel { fill: var(--ink-2); font-family: var(--font-body); font-size: 12px; }
.scatter-controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.scatter-controls select { padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; }

/* ---------- inspector ---------- */
.inspector { position: sticky; top: 12px; display: grid; gap: 12px; }
@media (max-width: 1099px) { .inspector { position: static; } }
.inspector .card { padding: 14px 16px; }
.spec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; margin-bottom: 8px; }
.spec-head h2 { font-size: 22px; }
.spec-head .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.views { display: flex; gap: 4px; margin-bottom: 8px; }
.views button { flex: 1 1 0; border: 1px solid var(--line-strong); background: var(--surface); padding: 5px 4px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--ink-2); border-radius: 6px; }
.views button.is-active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.spec-view { width: 100%; max-width: 288px; aspect-ratio: 1; margin: 0 auto; display: block; border-radius: 8px; background: var(--surface-2); image-rendering: pixelated; }
.spec-caption { font-size: 12px; color: var(--ink-3); text-align: center; margin-top: 6px; min-height: 1.4em; }
.verdict { display: grid; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.verdict .p { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.verdict .p b { font-family: var(--font-display); font-size: 30px; font-weight: 700; line-height: 1; }
.verdict .p b.soft { font-size: 20px; color: var(--ink-2); }
.verdict .p small { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--ink-3); }
.verdict .p small.lbl { font-family: var(--font-body); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; flex-basis: 100%; }
.verdict .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pbar { height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--regular), var(--map-zero) 50%, var(--irregular)); position: relative; margin: 6px 0 2px; }
.pbar .marker { position: absolute; top: -4px; width: 4px; height: 16px; background: var(--ink); border-radius: 2px; transform: translateX(-50%); box-shadow: 0 0 0 2px var(--surface); }
.pbar .thr { position: absolute; top: -2px; width: 1px; height: 12px; background: var(--ink-3); transform: translateX(-50%); }
.pbar-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); font-family: var(--font-mono); }
.evidence-sum { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); margin-top: 6px; line-height: 1.6; }

table.feat { width: 100%; border-collapse: collapse; font-size: 13px; }
table.feat th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; padding: 4px 4px; border-bottom: 1px solid var(--line); }
table.feat td { padding: 5px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.feat tr:last-child td { border-bottom: 0; }
table.feat td.n { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
table.feat td.name { cursor: help; }
table.feat .bar { position: relative; height: 12px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
table.feat .bar i { position: absolute; top: 0; bottom: 0; }
table.feat .bar i.pos { background: var(--irregular); left: 50%; }
table.feat .bar i.neg { background: var(--regular); right: 50%; }
table.feat .bar::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line-strong); }

/* ---------- test panel ---------- */
.scoreboard { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: flex-start; }
.stat { display: grid; gap: 2px; flex: 1 1 110px; }
.stat .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 600; }
.stat .v { font-family: var(--font-display); font-size: 30px; font-weight: 700; line-height: 1.05; }
.stat .sub { font-size: 12px; color: var(--ink-3); font-family: var(--font-mono); }
.confusion { display: grid; grid-template-columns: auto 72px 72px; gap: 4px; font-size: 12px; align-items: center; flex: 0 0 auto; }
.confusion .hd { color: var(--ink-3); font-weight: 600; text-align: center; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.confusion .rh { color: var(--ink-3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; text-align: right; padding-right: 4px; }
.confusion .cell { text-align: center; padding: 8px 4px; border-radius: 6px; background: var(--surface-2); font-family: var(--font-mono); font-size: 16px; font-weight: 500; }
.confusion .cell.hit { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good-text); }
.confusion .cell.miss { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.confusion .cell.empty { color: var(--ink-3); }
.testlog { display: grid; gap: 4px; font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); max-height: 180px; overflow: auto; margin-top: 8px; }

footer { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13px; max-width: 80ch; }
kbd { font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }

@media (prefers-reduced-motion: no-preference) {
  .thumb, .btn, .stage { transition: box-shadow 120ms ease, border-color 160ms ease, background-color 120ms ease; }
  .pbar .marker { transition: left 240ms ease; }
}

/* ---------- inputs picker, score card, unit profile, prevalence ---------- */
.picker { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.picker label { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; color: var(--ink); }
.picker input { accent-color: var(--accent); margin: 0; }
.picker label.off { color: var(--ink-3); text-decoration: line-through; }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.seg.small button { padding: 4px 8px; font-size: 12px; }
table.score { width: 100%; max-width: 520px; border-collapse: collapse; font-size: 13px; }
table.score td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.score td.n { font-family: var(--font-mono); text-align: right; white-space: nowrap; }
table.score .bar { position: relative; height: 10px; background: var(--surface-2); border-radius: 3px; min-width: 120px; }
table.score .bar i { position: absolute; top: 0; bottom: 0; }
table.score .bar i.pos { background: var(--irregular); left: 50%; }
table.score .bar i.neg { background: var(--regular); right: 50%; }
table.score .bar::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line-strong); }
.formula { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); margin-top: 8px; }
table.profile { border-collapse: separate; border-spacing: 3px; font-size: 12px; }
table.profile th { font-weight: 600; color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 6px; text-align: center; white-space: nowrap; }
table.profile th.row { text-align: left; }
table.profile td { padding: 5px 8px; text-align: center; border-radius: 5px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.profile td.row { text-align: left; font-family: var(--font-body); white-space: nowrap; background: transparent; }
table.profile td.row .n { color: var(--ink-3); font-size: 11px; margin-left: 4px; }
table.profile td.row .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
table.profile td.top { font-family: var(--font-body); font-size: 11px; color: var(--ink-2); background: transparent; line-height: 1.35; }
table.profile td.out { background: transparent; font-weight: 600; }
.udot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.profile-wrap { overflow-x: auto; }
.prev-grid { display: flex; flex-wrap: wrap; gap: 16px 28px; align-items: flex-end; }
.prev-grid .ctl { min-width: 240px; flex: 1 1 240px; }
.prev-text { font-size: 13px; color: var(--ink-2); margin-top: 8px; max-width: 70ch; }
table.feat td.flag { font-family: var(--font-mono); font-weight: 600; text-align: center; }
table.feat td.flag.H { color: var(--irregular); }
table.feat td.flag.L { color: var(--regular); }
table.feat td.ref { font-family: var(--font-mono); color: var(--ink-3); white-space: nowrap; font-size: 12px; }
table.feat tr.off td { color: var(--ink-3); }
table.feat tr.off td.name { text-decoration: line-through; }
body[data-kind="tabular"] .toggle.tint { display: none; }

/* ---------- condensed layout: masthead selects, bars, advanced drawer, compact metrics ---------- */
.masthead { padding-block: 12px 10px; margin-bottom: 14px; gap: 10px 20px; }
h1 { font-size: clamp(22px, 2.4vw, 28px); }
.tagline { font-size: 14px; }
.mh-selects { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: flex-end; }
.mh-select { display: grid; gap: 2px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); }
.mh-select select { font: inherit; font-size: 14px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--ink); padding: 6px 30px 6px 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); max-width: 320px; }
.mh-select select#recipe-select { color: var(--accent); }
.card.bar { padding: 12px 16px; }
.bar-row { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: flex-end; }
.bar-row .ctl { min-width: 150px; }
.bar-row .ctl.slim { min-width: 170px; max-width: 220px; }
.actions-inline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-left: auto; }
.btn.primary.big { padding: 9px 18px; }
.card.bar .status { margin-top: 8px; }
details.advanced { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
details.advanced > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); list-style: none; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 4px 0; }
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::before { content: "▸"; color: var(--accent); font-size: 12px; }
details.advanced[open] > summary::before { content: "▾"; }
details.advanced[open] > summary .muted { display: none; }
details.advanced > .controls { margin-top: 10px; }
label.plainlabel { text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 500; color: var(--ink); }
details.fold { margin-top: 8px; }
details.fold > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); }
details.fold > ul { margin-top: 8px; }
.metrics { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
.metric { display: grid; gap: 0; min-width: 76px; }
.metric .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 600; }
.metric b { font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1.1; }
.metric small { font-size: 11px; color: var(--ink-3); font-family: var(--font-mono); white-space: nowrap; }
.confusion.small { grid-template-columns: auto 44px 44px; gap: 3px; }
.confusion.small .cell { padding: 3px 2px; font-size: 13px; }
.confusion.small .hd, .confusion.small .rh { font-size: 9px; letter-spacing: 0.04em; }
@media (max-width: 1099px) { .actions-inline { margin-left: 0; } }
@media (max-width: 1500px) { .tagline { display: none; } .brand { flex: 0 1 auto; } .mh-select select { max-width: 250px; } }
.confusion.small { grid-template-columns: auto 62px 62px; }
.confusion.small .hd { font-size: 9px; line-height: 1.15; }

/* ---- the fields of the invasion question: the field viewers, the two heads side by side, the trays and the tables */
.fd-two { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.fd-two > div { min-width: 0; }
@media (min-width: 960px) { .fd-two { grid-template-columns: 528px minmax(0, 1fr); align-items: start; } }
.fd-heads { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.fd-heads > div { min-width: 0; }
.fd-heads h3 { margin: 0 0 6px; font-size: 13px; font-weight: 600; }
@media (min-width: 900px) { .fd-heads { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fd-heads canvas, #fd-data-canvas { width: 100%; height: auto; display: block; border-radius: 6px; }
.tray.fields { grid-template-columns: repeat(auto-fill, 94px); gap: 8px; }
.thumb.field { width: 94px; height: 70px; }
.thumb.field canvas { image-rendering: auto; }
.fd-patterns table, .fd-mimic table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fd-patterns th, .fd-mimic th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.fd-patterns td, .fd-mimic td { padding: 5px 8px 5px 0; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink-2); }
.fd-patterns td:first-child, .fd-mimic td:first-child { color: var(--ink); font-weight: 600; }
.fd-patterns tr.current td { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.fd-mimic td.num, .fd-mimic th.num { font-family: var(--font-mono); text-align: right; white-space: nowrap; }
.fd-mimic td.good { color: var(--good-text); } .fd-mimic td.bad { color: var(--bad); }
.fd-mimic .truth { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.fd-ctx { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.fd-ctx > div { min-width: 0; }
@media (min-width: 1100px) { .fd-ctx { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; } }
#sl-cards, #fd-cards { display: grid; gap: 18px; min-width: 0; }

/* ---------- the reports question: a small language model ---------- */
.rp-two { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .rp-two { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; } }
.rp-two > div { min-width: 0; }
.rp-two h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); }
.rp-text { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.85; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 120px; white-space: normal; word-break: normal; }
.rp-text .tok { border-radius: 3px; padding: 1px 1px; cursor: default; transition: box-shadow 0.08s; }
.rp-text .tok.hd { font-weight: 700; color: var(--ink); }
.rp-text .tok.sec-findings { color: var(--ink-2); }
.rp-text .tok.hover { outline: 2px solid var(--ink); outline-offset: 1px; }
.rp-text .tok.pinned { outline: 2px dashed var(--ink); outline-offset: 1px; }
.rp-text .tok.cur { outline: 2px solid var(--accent); outline-offset: 1px; }
.rp-text .tok.reads { box-shadow: inset 0 -3px 0 var(--accent-soft); }
.rp-text .cursor { display: inline-block; width: 8px; height: 14px; background: var(--accent); vertical-align: -2px; margin-left: 2px; animation: rp-blink 0.8s steps(2) infinite; }
@keyframes rp-blink { to { opacity: 0; } }
.rp-text .muted { color: var(--ink-3); }
.rp-next { display: grid; gap: 4px; font-family: var(--font-mono); font-size: 12px; }
.rp-next .row { display: grid; grid-template-columns: 120px 1fr 44px; align-items: center; gap: 8px; }
.rp-next .row .w { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-next .row .b { height: 12px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.rp-next .row .b i { display: block; height: 100%; background: var(--accent); }
.rp-next .row.actual .w { font-weight: 700; color: var(--ink); }
.rp-next .row.actual .b i { background: var(--good); }
.rp-next .row.chosen .b i { background: var(--irregular); }
.rp-next .row .p { text-align: right; color: var(--ink-3); }
.rp-next .title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin-bottom: 4px; }
.rp-case { display: grid; gap: 6px; font-size: 13px; }
.rp-case .row { display: grid; grid-template-columns: 150px 1fr; gap: 8px; align-items: baseline; }
.rp-case .row .k { color: var(--ink-3); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.rp-case .row .v { font-family: var(--font-mono); font-size: 12px; }
.rp-case .dx { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 13px; }
.rp-rule { overflow-x: auto; }
.rp-rule table { border-collapse: collapse; font-size: 13px; width: 100%; }
.rp-rule th, .rp-rule td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rp-rule th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); }
.rp-rule td.num { text-align: right; font-family: var(--font-mono); font-size: 12px; }
.rp-form { display: grid; gap: 6px; }
.rp-form .row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 8px; align-items: center; font-family: var(--font-mono); font-size: 12px; }
.rp-form .row select { font-family: var(--font-mono); font-size: 12px; padding: 4px 6px; }
.rp-form .row.off { opacity: 0.45; }
.rp-truth { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; display: grid; gap: 6px; }
.rp-truth b { font-family: var(--font-mono); font-weight: 500; }
.rp-evidence { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .rp-evidence { grid-template-columns: 1fr 1fr; } }
.rp-evidence .title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin-bottom: 6px; }
.tray.reports { grid-template-columns: repeat(auto-fill, 66px); gap: 8px; }
.thumb.report { width: 66px; height: 40px; display: grid; align-content: center; text-align: center; font-family: var(--font-mono); font-size: 10px; line-height: 1.25; color: var(--ink-2); }
.thumb.report .nm { font-weight: 700; color: var(--ink); }
.thumb.report.rp-benign { border-color: var(--regular); }
.thumb.report.rp-cis { border-color: var(--irregular); }
.thumb.report.rp-inv { border-color: var(--bad); }
.legend .swatch.ring.inv { border-color: var(--bad); }

/* ---------- reports: the model's diagrams ---------- */
.rp-text { position: relative; }
.rp-text svg.rp-arcs { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.rp-text svg.rp-arcs path { fill: none; stroke: var(--accent); stroke-linecap: round; }
.rp-text .tok.att-q { outline: 2px solid var(--accent); outline-offset: 1px; }
.rp-text .tok.att-k { outline: 2px dashed var(--accent); outline-offset: 1px; }
.rp-att { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .rp-att { grid-template-columns: 300px 300px minmax(0, 1fr); } }
.rp-ttl { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin-bottom: 6px; }
.rp-att .net-wrap canvas { max-width: 300px; }
.rp-sec-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); margin-top: 14px; }
@media (min-width: 900px) { .rp-sec-grid { grid-template-columns: 1fr 1fr; } }
table.rp-sec { border-collapse: collapse; font-family: var(--font-mono); font-size: 11px; width: 100%; }
table.rp-sec th, table.rp-sec td { padding: 3px 6px; text-align: right; border-bottom: 1px solid var(--line); }
table.rp-sec th { font-weight: 600; color: var(--ink-3); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
table.rp-sec th.row { text-align: left; }
table.rp-sec th .n { font-weight: 400; text-transform: none; letter-spacing: 0; }
.rp-map svg { width: 100%; height: auto; display: block; }
.rp-map text { font-family: var(--font-mono); font-size: 9px; fill: var(--ink-2); pointer-events: none; }
.rp-map text.axlabel { fill: var(--ink-3); font-size: 10px; }
.rp-map line.axis { stroke: var(--line-strong); stroke-width: 1; }
.rp-text svg.rp-arcs path.hop2 { stroke: var(--irregular); stroke-dasharray: 4 3; }
.rp-text .tok.reads2 { box-shadow: inset 0 -3px 0 rgba(235, 104, 52, 0.45); }
