/* ===== Tokens ===== */
:root {
  color-scheme: light;
  --paper: #f2ede2;
  --paper-2: #e9e2d3;
  --card: #fbf8f1;
  --ink: #1d1b16;
  --ink-2: #4a463c;
  --muted: #7a7466;
  --rule: #d5ccb9;
  --rule-strong: #b9ae97;
  --mutant: #c6401f;          /* survived bug / starting evals */
  --mutant-soft: #f5d9cd;
  --caught: #0d7466;          /* caught / improved evals */
  --caught-soft: #cfe8e1;
  --oracle: #8a6a12;          /* ceiling */
  --oracle-soft: #efe2bb;
  --padded: #8a3f74;
  --padded-soft: #efd5e6;
  --heldout: #2f4da0;
  --code-bg: #f7f3ea;
  --code-ink: #2a2720;
  --diff-del-bg: #f6d6cb;
  --diff-add-bg: #cfe9df;
  --skel-a: #e4dccb;
  --skel-b: #efe9dc;
  --focus: #2f4da0;
  --on-accent: #fbf8f1;
  --tooltip-bg: #1d1b16;
  --tooltip-ink: #f2ede2;
  --error-bg: #f6d6cb;
  --error-ink: #7d2410;
  --dev-bg: #efe2bb;
  --dev-ink: #5c460a;
  --grain-opacity: 0.35;
  --shadow: 0 1px 0 #d5ccb9, 0 12px 30px -18px #6b5f45;

  --f-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --f-body: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, monospace;
  --dur: 220ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --gutter: 16px;
  --maxw: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #13120f;
    --paper-2: #1b1915;
    --card: #1c1a16;
    --ink: #eee7d7;
    --ink-2: #c4bba7;
    --muted: #918874;
    --rule: #332f27;
    --rule-strong: #4a443a;
    --mutant: #ff7350;
    --mutant-soft: #3d1d14;
    --caught: #4fd1b9;
    --caught-soft: #12342e;
    --oracle: #e3b649;
    --oracle-soft: #392d10;
    --padded: #e48ac8;
    --padded-soft: #3a1830;
    --heldout: #8ea8ff;
    --code-bg: #171511;
    --code-ink: #e2dac8;
    --diff-del-bg: #4a1f14;
    --diff-add-bg: #143a31;
    --skel-a: #24211c;
    --skel-b: #2d2a23;
    --focus: #8ea8ff;
    --on-accent: #13120f;
    --tooltip-bg: #2c2923;
    --tooltip-ink: #eee7d7;
    --error-bg: #4a1f14;
    --error-ink: #ffb9a6;
    --dev-bg: #392d10;
    --dev-ink: #f0cd78;
    --grain-opacity: 0.18;
    --shadow: 0 1px 0 #332f27, 0 12px 30px -18px #000000;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #13120f;
  --paper-2: #1b1915;
  --card: #1c1a16;
  --ink: #eee7d7;
  --ink-2: #c4bba7;
  --muted: #918874;
  --rule: #332f27;
  --rule-strong: #4a443a;
  --mutant: #ff7350;
  --mutant-soft: #3d1d14;
  --caught: #4fd1b9;
  --caught-soft: #12342e;
  --oracle: #e3b649;
  --oracle-soft: #392d10;
  --padded: #e48ac8;
  --padded-soft: #3a1830;
  --heldout: #8ea8ff;
  --code-bg: #171511;
  --code-ink: #e2dac8;
  --diff-del-bg: #4a1f14;
  --diff-add-bg: #143a31;
  --skel-a: #24211c;
  --skel-b: #2d2a23;
  --focus: #8ea8ff;
  --on-accent: #13120f;
  --tooltip-bg: #2c2923;
  --tooltip-ink: #eee7d7;
  --error-bg: #4a1f14;
  --error-ink: #ffb9a6;
  --dev-bg: #392d10;
  --dev-ink: #f0cd78;
  --grain-opacity: 0.18;
  --shadow: 0 1px 0 #332f27, 0 12px 30px -18px #000000;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.6 var(--f-body);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body::before {
  /* paper grain */
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--grain-opacity);
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .5  0 0 0 0 .5  0 0 0 0 .5  0 0 0 .12 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
:root[data-theme="dark"] body::before { mix-blend-mode: screen; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body::before { mix-blend-mode: screen; } }

main, header, footer, .error-banner { position: relative; z-index: 1; }
.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
@media (min-width: 720px) { :root { --gutter: 32px; } }

a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 3px; }
button { font: inherit; color: inherit; }
code, pre { font-family: var(--f-mono); }
em { font-style: italic; }
[hidden] { display: none !important; }

/* ===== Skeletons (static shade; no idle animation) ===== */
.skel {
  display: block;
  background: linear-gradient(90deg, var(--skel-a), var(--skel-b));
  border-radius: 4px;
  max-width: 100%;
}
.skel-inline { display: inline-block; height: 1em; vertical-align: middle; }
.skel-num { display: inline-block; width: 2.6em; height: 0.8em; }
.skel-line { height: 0.9em; margin: 0.35em 0; width: 100%; }
.skel-line.short { width: 60%; }
.skel-block { width: 100%; }

/* ===== Topbar ===== */
.topbar { border-bottom: 1px solid var(--rule); background: var(--paper); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.brand { font-family: var(--f-display); font-weight: 600; font-size: 1.05rem; text-decoration: none; letter-spacing: -0.01em; white-space: nowrap; }
.brand-glyph { color: var(--mutant); margin-right: 0.2em; }
.topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.stamp { font: 500 0.72rem/1.2 var(--f-mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font: 600 0.66rem/1 var(--f-mono); text-transform: uppercase; letter-spacing: 0.08em; padding: 5px 7px; border-radius: 3px; white-space: nowrap; }
.badge-dev { background: var(--dev-bg); color: var(--dev-ink); }
@media (max-width: 560px) {
  .stamp { display: none; }
  .badge-long { display: none; }
  .topbar-inner { gap: 8px; }
  .brand { font-size: 0.95rem; }
}

.theme-toggle { background: none; border: 0; padding: 4px; cursor: pointer; flex: none; }
.tt-track { display: block; width: 44px; height: 24px; border-radius: 12px; background: var(--paper-2); border: 1px solid var(--rule-strong); position: relative; transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.tt-thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; font-size: 11px; line-height: 1; transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease); }
.tt-sun, .tt-moon { grid-area: 1 / 1; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
.tt-moon { opacity: 0; transform: rotate(-60deg) scale(0.6); }
.is-dark .tt-thumb { transform: translateX(20px); }
.is-dark .tt-sun { opacity: 0; transform: rotate(60deg) scale(0.6); }
.is-dark .tt-moon { opacity: 1; transform: none; }

.error-banner { margin-top: 16px; }
.error-banner .err-box { background: var(--error-bg); color: var(--error-ink); border-radius: 6px; padding: 14px 16px; font-size: 0.95rem; }
.error-banner code { font-size: 0.85em; }

/* ===== Hero ===== */
.hero { padding-top: clamp(32px, 7vw, 84px); padding-bottom: clamp(40px, 6vw, 72px); }
.kicker { font: 500 0.75rem/1.4 var(--f-mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin: 0 0 18px; }
.hero-title {
  font-family: var(--f-display); font-weight: 400; font-variation-settings: "opsz" 144;
  font-size: clamp(2.2rem, 6.4vw, 5rem); line-height: 1.02; letter-spacing: -0.025em;
  margin: 0; max-width: 16ch;
}
.hero-title em { color: var(--mutant); font-weight: 500; }
.hero-lede { font-size: clamp(1rem, 1.6vw, 1.15rem); color: var(--ink-2); max-width: 62ch; margin: 22px 0 0; }

.hero-grid { display: grid; gap: 24px; margin-top: clamp(28px, 5vw, 56px); grid-template-columns: 1fr; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: 1.6fr 1fr; gap: 40px; } }

.hero-number { margin: 0; background: var(--card); border: 1px solid var(--rule); border-radius: 10px; padding: clamp(18px, 3vw, 32px); box-shadow: var(--shadow); min-width: 0; }
.hn-label { font-size: 0.9rem; color: var(--ink-2); }
.hn-row { display: flex; align-items: flex-end; gap: clamp(8px, 3vw, 28px); margin-top: 10px; }
.hn-cell { display: flex; flex-direction: column; min-width: 0; }
.hn-value { font-family: var(--f-display); font-weight: 300; font-variation-settings: "opsz" 144; font-size: clamp(2.9rem, 13vw, 7.5rem); line-height: 0.9; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.hn-value .pct { font-size: 0.45em; letter-spacing: 0; margin-left: 0.04em; }
.hn-start .hn-value { color: var(--mutant); }
.hn-improved .hn-value { color: var(--caught); font-weight: 500; }
.hn-cap { font: 500 0.75rem/1.3 var(--f-mono); color: var(--muted); margin-top: 8px; text-transform: uppercase; letter-spacing: 0.06em; }
.hn-arrow { font-family: var(--f-display); font-size: clamp(1.6rem, 6vw, 3.6rem); color: var(--rule-strong); align-self: center; }
.hn-bars { margin-top: 22px; }
.hn-bars svg { display: block; width: 100%; height: auto; overflow: visible; }

.hero-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.side-stat { border-top: 1px solid var(--rule-strong); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.side-k { font: 500 0.72rem/1.3 var(--f-mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.side-v { font-family: var(--f-display); font-size: 1.7rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.side-v .from { color: var(--mutant); }
.side-v .to { color: var(--caught); }
.side-v .ceil { color: var(--oracle); }
.side-small { font-family: var(--f-body); font-size: 0.95rem; color: var(--ink-2); }
.pitch { font-family: var(--f-display); font-style: italic; font-size: 1.15rem; line-height: 1.4; color: var(--ink-2); margin: 8px 0 0; padding-left: 14px; border-left: 3px solid var(--mutant); }

/* ===== Sections ===== */
.section { padding-block: clamp(40px, 7vw, 88px); border-top: 1px solid var(--rule); }
.sec-head { display: grid; grid-template-columns: auto 1fr; column-gap: 18px; align-items: baseline; margin-bottom: clamp(20px, 3vw, 36px); }
.sec-num { font: 500 0.8rem/1 var(--f-mono); color: var(--mutant); grid-row: 1; }
.sec-head h2 { font-family: var(--f-display); font-weight: 500; font-size: clamp(1.6rem, 3.6vw, 2.6rem); line-height: 1.1; letter-spacing: -0.02em; margin: 0; max-width: 26ch; }
.sec-lede { grid-column: 2; color: var(--ink-2); max-width: 66ch; margin: 12px 0 0; }
@media (max-width: 560px) {
  .sec-head { grid-template-columns: 1fr; }
  .sec-num { margin-bottom: 8px; }
  .sec-lede { grid-column: 1; }
}

/* ===== Loops diagram ===== */
.loops { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 960px) { .loops { grid-template-columns: 240px 1fr; } .loops-caption { grid-column: 2; } }
.loops-steps { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 959px) { .loops-steps { flex-direction: row; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; } }
.step-btn {
  display: flex; gap: 10px; align-items: baseline; text-align: left;
  background: transparent; border: 1px solid var(--rule); border-radius: 6px; padding: 9px 12px; cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
  color: var(--ink-2); flex: none;
}
.step-btn .sn { font: 600 0.75rem/1 var(--f-mono); color: var(--muted); transition: color var(--dur) var(--ease); }
.step-btn .sl { font-size: 0.9rem; white-space: nowrap; }
.step-btn:hover { border-color: var(--rule-strong); }
.step-btn[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.step-btn[aria-selected="true"] .sn { color: var(--paper); }
.loops-canvas { background: var(--card); border: 1px solid var(--rule); border-radius: 10px; padding: 8px; min-width: 0; box-shadow: var(--shadow); }
.loops-canvas svg { display: block; width: 100%; height: auto; }
.loops-caption { font-size: 1rem; color: var(--ink-2); min-height: 4.8em; max-width: 72ch; }
.loops-caption strong { color: var(--ink); font-weight: 600; }

.lnode rect { fill: var(--paper); stroke: var(--rule-strong); stroke-width: 1.2; transition: fill var(--dur) var(--ease), stroke var(--dur) var(--ease); }
.lnode text { fill: var(--ink-2); font: 500 13px var(--f-body); transition: fill var(--dur) var(--ease); }
.lnode .sub { fill: var(--muted); font: 400 11px var(--f-mono); }
.lnode.on rect { fill: var(--ink); stroke: var(--ink); }
.lnode.on text, .lnode.on .sub { fill: var(--paper); }
.lnode.ev.on rect { fill: var(--caught); stroke: var(--caught); }
.lnode.ev.on text, .lnode.ev.on .sub { fill: var(--on-accent); }
.lnode.ag.on rect { fill: var(--heldout); stroke: var(--heldout); }
.lnode.ag.on text, .lnode.ag.on .sub { fill: var(--on-accent); }
.lnode.or.on rect { fill: var(--oracle); stroke: var(--oracle); }
.lnode.or.on text, .lnode.or.on .sub { fill: var(--on-accent); }
.ledge { fill: none; stroke: var(--rule-strong); stroke-width: 1.4; transition: stroke var(--dur) var(--ease), stroke-width var(--dur) var(--ease); }
.ledge.on { stroke: var(--ink); stroke-width: 2.2; }
.lhead { fill: var(--rule-strong); }
.lzone { fill: none; stroke: var(--rule); stroke-dasharray: 3 5; }
.lzone-label { fill: var(--muted); font: 600 11px var(--f-mono); letter-spacing: 0.1em; text-transform: uppercase; }
.ledge-label { fill: var(--muted); font: 400 11px var(--f-mono); }

/* ===== Mutant demo ===== */
.demo-controls { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--paper-2); border-radius: 8px; padding: 4px; max-width: 100%; }
.seg-btn {
  border: 0; background: transparent; padding: 7px 12px; border-radius: 5px; cursor: pointer;
  font: 500 0.82rem/1.2 var(--f-mono); color: var(--ink-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.seg-btn:hover { color: var(--ink); }
.seg-btn[aria-selected="true"], .seg-btn[aria-checked="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 0 var(--rule-strong); }
.seg-suite .seg-btn[data-suite="start"][aria-checked="true"] { background: var(--mutant); color: var(--on-accent); }
.seg-suite .seg-btn[data-suite="improved"][aria-checked="true"] { background: var(--caught); color: var(--on-accent); }
.demo-spec { margin: 16px 0 18px; color: var(--ink-2); max-width: 80ch; font-size: 0.97rem; }
.demo-spec b { font-family: var(--f-mono); font-weight: 600; color: var(--ink); font-size: 0.9em; }

.demo-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .demo-grid { grid-template-columns: 236px minmax(0, 1fr) 300px; } }
.demo-mutants { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
@media (max-width: 999px) { .demo-mutants { flex-direction: row; flex-wrap: wrap; } }
.mut-btn {
  display: flex; align-items: center; gap: 8px; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--rule); border-radius: 6px; padding: 8px 10px;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.mut-btn:hover { border-color: var(--rule-strong); }
.mut-btn[aria-selected="true"] { border-color: var(--ink); box-shadow: inset 3px 0 0 var(--ink); }
.mut-id { font: 600 0.82rem/1 var(--f-mono); }
.mut-kind { font: 500 0.62rem/1 var(--f-mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); border: 1px solid var(--rule-strong); border-radius: 3px; padding: 3px 4px; }
.mut-dot { width: 9px; height: 9px; border-radius: 50%; margin-left: auto; flex: none; transition: background var(--dur) var(--ease); }
.mut-dot.caught { background: var(--caught); }
.mut-dot.survived { background: var(--mutant); }
.mut-dot.equiv { background: var(--oracle); }
.mut-legend { font: 400 0.72rem/1.5 var(--f-mono); color: var(--muted); margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.mut-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
@media (max-width: 999px) { .mut-legend { flex-direction: row; flex-wrap: wrap; gap: 12px; width: 100%; } }

.demo-code-wrap { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.demo-verdict { border-radius: 6px; padding: 10px 14px; font-size: 0.95rem; min-height: 2.9em; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); background: var(--paper-2); }
.demo-verdict.caught { background: var(--caught-soft); }
.demo-verdict.survived { background: var(--mutant-soft); }
.demo-verdict.equiv { background: var(--oracle-soft); }
.demo-verdict .v-tag { font: 700 0.75rem/1 var(--f-mono); letter-spacing: 0.1em; text-transform: uppercase; margin-right: 8px; }
.demo-verdict.caught .v-tag { color: var(--caught); }
.demo-verdict.survived .v-tag { color: var(--mutant); }
.demo-verdict.equiv .v-tag { color: var(--oracle); }
.code {
  margin: 0; background: var(--code-bg); color: var(--code-ink); border: 1px solid var(--rule); border-radius: 8px;
  font-size: 0.8rem; line-height: 1.6; padding: 12px 0; overflow-x: auto; max-width: 100%;
}
.code .ln { display: block; padding: 0 14px 0 0; white-space: pre; min-width: max-content; }
.code .gut { display: inline-block; width: 2.6em; text-align: right; padding-right: 0.9em; color: var(--muted); user-select: none; }
.code .ln.del { background: var(--diff-del-bg); text-decoration: line-through; text-decoration-color: var(--mutant); }
.code .ln.add { background: var(--diff-add-bg); }
.code .ln.del .gut::after { content: "-"; color: var(--mutant); margin-left: 3px; }
.code .ln.add .gut::after { content: "+"; color: var(--caught); margin-left: 3px; }
.code .kw { color: var(--heldout); }
.code .str { color: var(--oracle); }
.code .num { color: var(--mutant); }

.demo-tests { min-width: 0; }
.tests-head { font: 600 0.72rem/1.2 var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; }
.test-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.test {
  font: 400 0.76rem/1.4 var(--f-mono); padding: 6px 8px; border-radius: 5px; border: 1px solid var(--rule);
  background: var(--card); display: grid; grid-template-columns: 1.8em 1fr; gap: 4px; overflow-wrap: anywhere;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.test .tn { color: var(--muted); }
.test .arrow { color: var(--muted); }
.test.new { border-style: dashed; }
.test.hit { background: var(--caught-soft); border-color: var(--caught); }
.test.hit .tn { color: var(--caught); font-weight: 600; }
.test-missing { font: 400 0.76rem/1.4 var(--f-mono); color: var(--mutant); margin-top: 8px; }

.demo-tally { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px 22px; font: 500 0.82rem/1.4 var(--f-mono); color: var(--ink-2); }
.demo-tally .t-start { color: var(--mutant); }
.demo-tally .t-imp { color: var(--caught); }

/* ===== Charts ===== */
.chart-card { background: var(--card); border: 1px solid var(--rule); border-radius: 10px; padding: clamp(12px, 2.4vw, 24px); box-shadow: var(--shadow); min-width: 0; }
.chart-title { font: 600 0.78rem/1.3 var(--f-mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 8px; }
.chart { width: 100%; min-width: 0; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-pair { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 960px) { .chart-pair { grid-template-columns: 1.4fr 1fr; } }
.chart-note { margin-top: 12px; color: var(--ink-2); font-size: 0.92rem; }
.chart-note b { font-weight: 600; color: var(--ink); }

.axis path, .axis line { stroke: var(--rule-strong); }
.axis text { fill: var(--muted); font: 400 11.5px var(--f-mono); }
.grid line { stroke: var(--rule); stroke-dasharray: 2 4; }
.grid path { display: none; }
.axis-title { fill: var(--muted); font: 500 11px var(--f-mono); }
.series { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.s-train { stroke: var(--ink-2); stroke-dasharray: 5 4; }
.s-heldout { stroke: var(--caught); stroke-width: 3; }
.s-fa { stroke: var(--mutant); }
.s-start { stroke: var(--mutant); }
.s-improved { stroke: var(--caught); stroke-width: 3; }
.s-oracle { stroke: var(--oracle); stroke-dasharray: 2 5; }
.s-pass { stroke-width: 1.6; stroke-dasharray: 6 4; opacity: 0.9; }
.f-train { fill: var(--ink-2); } .f-heldout { fill: var(--caught); } .f-fa { fill: var(--mutant); }
.f-start { fill: var(--mutant); } .f-improved { fill: var(--caught); } .f-oracle { fill: var(--oracle); }
.dot { stroke: var(--card); stroke-width: 2; }
.gap-area-start { fill: var(--mutant); opacity: 0.12; }
.gap-area-improved { fill: var(--caught); opacity: 0.12; }
.end-label { font: 600 12px var(--f-body); }
.end-label.sub { font: 400 11px var(--f-mono); }
.t-start { fill: var(--mutant); } .t-improved { fill: var(--caught); } .t-oracle { fill: var(--oracle); }
.t-train { fill: var(--ink-2); } .t-heldout { fill: var(--caught); } .t-fa { fill: var(--mutant); }
.t-muted { fill: var(--muted); } .t-ink { fill: var(--ink); }
.crosshair { stroke: var(--rule-strong); stroke-width: 1; }
.annot-line { stroke: var(--muted); stroke-width: 1; fill: none; }
.annot { fill: var(--ink-2); font: italic 400 12px var(--f-display); }
.bar-pass { fill: var(--rule-strong); opacity: 0.55; }
.bar-true-start { fill: var(--mutant); } .bar-true-improved { fill: var(--caught); } .bar-true-oracle { fill: var(--oracle); }
.gap-bracket { stroke: var(--ink-2); stroke-width: 1.2; fill: none; }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font: 400 0.75rem/1.3 var(--f-mono); color: var(--ink-2); }
.legend-row .sw { display: inline-block; width: 18px; height: 0; border-top: 3px solid; vertical-align: middle; margin-right: 6px; }
.legend-row .sw.dash { border-top-style: dashed; border-top-width: 2px; }
.legend-row .sw.box { width: 12px; height: 12px; border: 0; vertical-align: -1px; }
.legend-row .sw-start { border-top-color: var(--mutant); } .legend-row .sw-improved { border-top-color: var(--caught); } .legend-row .sw-oracle { border-top-color: var(--oracle); }
.legend-row .sw-pass { background: var(--rule-strong); opacity: 0.55; }
.legend-row .sw-true { background: var(--ink-2); }
.hn-bar-bg { fill: var(--paper-2); }
.hn-bar-start { fill: var(--mutant); } .hn-bar-improved { fill: var(--caught); } .hn-bar-oracle { fill: var(--oracle); }
.hn-bar-text { font: 500 12px var(--f-mono); fill: var(--ink-2); }
.hn-bar-val { font: 600 12px var(--f-mono); fill: var(--ink); }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 260px;
  background: var(--tooltip-bg); color: var(--tooltip-ink); border: 1px solid var(--rule-strong); border-radius: 6px; padding: 8px 10px;
  font: 400 0.75rem/1.45 var(--f-mono);
}
.tooltip b { font-weight: 600; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); box-shadow: var(--shadow); max-width: 100%; }
.tasks { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tasks th, .tasks td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.tasks tbody tr:last-child td { border-bottom: 0; }
.tasks tbody tr { transition: background var(--dur) var(--ease); }
.tasks tbody tr:hover { background: var(--paper-2); }
.tasks .num { text-align: right; }
.th-sort { background: none; border: 0; padding: 0; cursor: pointer; font: 600 0.7rem/1.3 var(--f-mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); text-align: inherit; }
.th-sort[aria-sort="descending"]::after { content: " \2193"; color: var(--ink); }
.th-sort[aria-sort="ascending"]::after { content: " \2191"; color: var(--ink); }
.tasks td.pname { font-family: var(--f-mono); font-size: 0.82rem; }
.col-dumb { width: 44%; }
.dumb-html { position: relative; height: 18px; min-width: 90px; }
.dh-track { position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--rule-strong); }
.dh-link { position: absolute; top: calc(50% - 2px); height: 4px; background: var(--rule-strong); border-radius: 2px; }
.dh-dot { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; border: 2px solid var(--card); }
.dh-a { background: var(--mutant); }
.dh-b { background: var(--caught); }
.dh-txt { font: 500 0.74rem/1.2 var(--f-mono); margin-top: 3px; color: var(--muted); }
.dh-txt .from { color: var(--mutant); } .dh-txt .to { color: var(--caught); }
.sr-step { font: 600 0.75rem/1 var(--f-mono); color: var(--muted); }
.agent-pair { font: 600 0.82rem/1 var(--f-mono); white-space: nowrap; }
.mark { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 4px; margin-left: 4px; }
.mark.yes { background: var(--caught-soft); color: var(--caught); }
.mark.no { background: var(--mutant-soft); color: var(--mutant); }
.mark.na { background: var(--paper-2); color: var(--muted); }
.tests-pair { font: 400 0.8rem/1 var(--f-mono); color: var(--ink-2); white-space: nowrap; }
@media (max-width: 640px) {
  .tasks th, .tasks td { padding: 8px 8px; }
  .col-tests, .tasks td.col-tests { display: none; }
  .col-dumb { width: auto; }
}

/* ===== Notes ===== */
.notes { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .notes { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .notes { grid-template-columns: repeat(3, 1fr); } }
.note { border-top: 2px solid var(--ink); padding-top: 12px; min-width: 0; }
.note h3 { font-family: var(--f-display); font-weight: 500; font-size: 1.25rem; margin: 0 0 6px; }
.note p { margin: 0; color: var(--ink-2); font-size: 0.95rem; }
.note-config { border-top-color: var(--mutant); }
.config { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font: 400 0.8rem/1.5 var(--f-mono); }
.config dt { color: var(--muted); }
.config dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }

/* ===== Footer ===== */
.footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; padding-block: 28px 40px; border-top: 1px solid var(--rule); color: var(--muted); font: 400 0.78rem/1.5 var(--f-mono); }
.footer code { color: var(--ink-2); overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
.th-sub { display: block; font-weight: 400; letter-spacing: 0.04em; text-transform: none; }

/* ===== Added: padded arm, bug catch, roles, stats ===== */
.s-padded { stroke: var(--padded); }
.f-padded { fill: var(--padded); } .t-padded { fill: var(--padded); }
.bar-true-padded { fill: var(--padded); }
.hn-bar-padded { fill: var(--padded); }
.hn-bar-first { fill: var(--muted); }
.legend-row .sw-padded { border-top-color: var(--padded); }
.legend-row .sw-muted { border-top-color: var(--muted); }
.s-heldout-llm { stroke: var(--heldout); stroke-dasharray: 1 4; stroke-width: 2.6; }
.f-heldout-llm { fill: var(--heldout); } .t-heldout-llm { fill: var(--heldout); }

.bugcatch { margin-top: clamp(28px, 5vw, 48px); border: 1px solid var(--rule-strong); border-radius: 10px; padding: clamp(18px, 3vw, 32px); background: var(--paper-2); }
.bc-head .kicker { margin-bottom: 8px; color: var(--mutant); }
.bc-title { font-family: var(--f-display); font-weight: 500; font-size: clamp(1.35rem, 3vw, 2rem); line-height: 1.15; letter-spacing: -0.015em; margin: 0; max-width: 32ch; }
.bc-sub { color: var(--ink-2); margin: 10px 0 0; max-width: 70ch; font-size: 0.95rem; }
.bc-grid { display: grid; gap: clamp(10px, 3vw, 18px); grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 22px; }
.bc-cell { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bc-val { font-family: var(--f-display); font-weight: 400; font-variation-settings: "opsz" 144; font-size: clamp(2.1rem, 9vw, 4.6rem); line-height: 0.95; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.bc-val .pct { font-size: 0.45em; }
.bc-meter { display: block; height: 8px; border-radius: 4px; background: var(--card); overflow: hidden; }
.bc-fill { display: block; height: 100%; border-radius: 4px; transition: width var(--dur) var(--ease); }
.bc-cap { font: 600 0.75rem/1.3 var(--f-mono); text-transform: uppercase; letter-spacing: 0.06em; }
.bc-n { font-size: 0.85rem; color: var(--ink-2); }
.bc-start .bc-val, .bc-start .bc-cap { color: var(--mutant); } .bc-start .bc-fill { background: var(--mutant); }
.bc-padded .bc-val, .bc-padded .bc-cap { color: var(--padded); } .bc-padded .bc-fill { background: var(--padded); }
.bc-improved .bc-val, .bc-improved .bc-cap { color: var(--caught); } .bc-improved .bc-fill { background: var(--caught); }

.sub-head { font-family: var(--f-display); font-weight: 500; font-size: 1.35rem; margin: clamp(28px, 4vw, 44px) 0 12px; }
.muted { color: var(--muted); }
.roles, .stats-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.roles th, .roles td, .stats-table th, .stats-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: top; }
.roles thead th, .stats-table thead th { font: 600 0.7rem/1.3 var(--f-mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stats-table thead th.num { text-align: right; }
.roles tbody th { font-weight: 600; white-space: nowrap; }
.roles code { font-size: 0.82rem; color: var(--ink); background: var(--code-bg); border: 1px solid var(--rule); border-radius: 4px; padding: 2px 6px; white-space: nowrap; }
.roles td:last-child { color: var(--ink-2); min-width: 16em; }
.roles tbody tr:last-child th, .roles tbody tr:last-child td { border-bottom: 0; }
.stats-table .num { text-align: right; white-space: nowrap; font-family: var(--f-mono); font-size: 0.82rem; }
.stats-table tr.stratum th { background: var(--paper-2); font-weight: 400; padding-top: 12px; }
.st-name { font-family: var(--f-display); font-weight: 600; font-size: 1.02rem; margin-right: 10px; color: var(--ink); }
.st-n { font: 500 0.75rem/1 var(--f-mono); color: var(--muted); }
.st-why { display: block; font-size: 0.85rem; color: var(--ink-2); margin-top: 3px; }
.stats-table td.ct { font-family: var(--f-mono); font-size: 0.82rem; white-space: nowrap; }
.stats-table tr.ns td { color: var(--muted); }
.stats-table tr.sig td { color: var(--ink); font-weight: 600; }
.stats-table tr.sig td.md.pos { color: var(--caught); }
.stats-table tr.sig td.md.neg { color: var(--mutant); }
.stats-table .unit { font-weight: 400; color: var(--muted); }
.stats-table tr.st-empty td { color: var(--muted); font-style: italic; }
.stats-lists { margin-top: 14px; font-size: 0.9rem; color: var(--ink-2); }
.stats-lists p { margin: 6px 0; }
.stats-lists code { font-size: 0.8rem; }
@media (max-width: 640px) {
  .roles th, .roles td, .stats-table th, .stats-table td { padding: 8px 8px; }
  .col-wl, .stats-table td.col-wl { display: none; }
  .col-fa, .tasks td.col-fa { display: none; }
  .roles tbody th { white-space: normal; }
}

.mut-split { font: 500 0.6rem/1 var(--f-mono); letter-spacing: 0.04em; border-radius: 3px; padding: 3px 4px; }
.mut-split.tr { color: var(--muted); background: var(--paper-2); }
.mut-split.ho { color: var(--heldout); border: 1px solid var(--heldout); }
.v-bug { display: block; margin-top: 4px; font-size: 0.85rem; color: var(--ink-2); }
.v-bug b { font-weight: 600; color: var(--ink); }
.mark.frac { width: auto; padding: 0 4px; }
.dh-sep { color: var(--rule-strong); }
.agent-pair .mark { margin-left: 3px; }
.loops-caption code { font-size: 0.85em; }
@media (max-width: 640px) {
  .bc-cap { font-size: 0.66rem; }
  .bc-n { font-size: 0.78rem; }
  .roles thead { display: none; }
  .roles, .roles tbody, .roles tr { display: block; width: 100%; }
  .roles tr { padding: 10px 12px; border-bottom: 1px solid var(--rule); }
  .roles tbody tr:last-child { border-bottom: 0; }
  .roles th, .roles td { display: inline; padding: 0; border: 0; }
  .roles tbody th { margin-right: 8px; }
  .roles td:last-child { display: block; min-width: 0; margin-top: 6px; }
}
@media (max-width: 640px) {
  .stats-table thead { display: none; }
  .stats-table, .stats-table tbody { display: block; width: 100%; }
  .stats-table tr { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.5fr) minmax(0, 0.6fr); gap: 2px 10px; padding: 8px 10px; border-bottom: 1px solid var(--rule); }
  .stats-table tr.stratum, .stats-table tr.st-empty { display: block; background: var(--paper-2); }
  .stats-table tr.st-empty { background: transparent; }
  .stats-table th, .stats-table td { display: block; padding: 0; border: 0; text-align: left; }
  .stats-table .num { text-align: left; white-space: nowrap; }
  .stats-table td.ct { grid-column: 1 / -1; }
  .stats-table td[data-label]::before { content: attr(data-label); display: block; font: 500 0.62rem/1.4 var(--f-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
  .stats-table tr.stratum th { background: transparent; padding: 0; }
}

/* ===== Real-results narrative ===== */
.hn-sub { margin: 14px 0 0; font-size: 0.88rem; color: var(--ink-2); max-width: 60ch; }
.bc-grid[data-n="5"], .bc-grid[data-n="4"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.bc-grid[data-n="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 760px) { .bc-grid[data-n="5"], .bc-grid[data-n="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.bc-oracle .bc-val, .bc-oracle .bc-cap { color: var(--oracle); } .bc-oracle .bc-fill { background: var(--oracle); }
.bc-first .bc-val, .bc-first .bc-cap { color: var(--muted); } .bc-first .bc-fill { background: var(--muted); }
.bc-sub { max-width: 80ch; }
#agent-lede code, #primary-agent { font-size: 0.88em; }

.agents-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.agents-table th, .agents-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: top; }
.agents-table thead th { font: 600 0.68rem/1.3 var(--f-mono); text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.agents-table thead th.num, .agents-table td.num { text-align: right; }
.agents-table td.num { font-family: var(--f-mono); font-size: 0.8rem; white-space: nowrap; }
.agents-table tbody th { font-weight: 600; white-space: nowrap; }
.agents-table tbody th code { font-size: 0.82rem; }
.agents-table .ci { display: block; font-size: 0.72rem; color: var(--muted); }
.agents-table .ns { color: var(--muted); }
.agents-table .ns b { font-weight: 500; }
.agents-table .sig b { color: var(--ink); }
.agents-table tr.pooled-row th, .agents-table tr.pooled-row td { background: var(--paper-2); border-bottom: 0; }
.cc-start { color: var(--mutant); } .cc-padded { color: var(--padded); } .cc-improved { color: var(--caught); } .cc-oracle { color: var(--oracle); }
.agents-table .from { color: var(--mutant); } .agents-table .to { color: var(--caught); }
.badge-primary { font: 600 0.6rem/1 var(--f-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--heldout); border: 1px solid var(--heldout); border-radius: 3px; padding: 2px 4px; margin-left: 4px; vertical-align: 1px; }
@media (max-width: 900px) {
  .agents-table thead { display: none; }
  .agents-table, .agents-table tbody { display: block; width: 100%; }
  .agents-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; padding: 12px; border-bottom: 1px solid var(--rule); }
  .agents-table th, .agents-table td { display: block; padding: 0; border: 0; text-align: left; }
  .agents-table thead th.num, .agents-table td.num { text-align: left; white-space: normal; }
  .agents-table tbody th { grid-column: 1 / -1; }
  .agents-table td[data-label]::before { content: attr(data-label); display: block; font: 500 0.6rem/1.4 var(--f-mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 2px; }
  .agents-table td:nth-child(3) { grid-column: 1 / -1; }
  .agents-table tr.pooled-row { background: var(--paper-2); }
}
.test .raises { color: var(--oracle); }
.side-ex { font: 400 0.8rem/1.4 var(--f-mono); color: var(--ink-2); margin-top: 2px; }
.side-ex code { font-size: 0.95em; }
.side-ex .from { color: var(--mutant); } .side-ex .to { color: var(--caught); }
.note code { font-size: 0.85em; }
