/* When Calibration Data Become Training Data: project page.
   Colors: the validated categorical palette of the paper's figures (one slot per
   calibration source, fixed order), a blue sequential ramp, warm neutral chrome.
   Light and dark are each selected, not flipped. */

@import url("../fonts/fonts.css");

:root {
  color-scheme: light;
  --bg: #fcfcfb;
  --bg-2: #f5f4f0;
  --bg-3: #ecebe5;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #6f6e69;
  --muted: #898781;
  --rule: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --focus: #2a78d6;
  --mark-hover: rgba(11, 11, 11, 0.06);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 8px 24px rgba(11, 11, 11, 0.06);

  /* calibration sources: categorical slots 1-6 */
  --s-wikitext2: #2a78d6;
  --s-c4: #eb6834;
  --s-slimpajama: #1baf7a;
  --s-alpaca: #eda100;
  --s-selfgen: #e87ba4;
  --s-selfdoc: #008300;
  /* toy domains: slots 7 and 8 */
  --s-toyA: #6250d6;
  --s-toyB: #e34948;

  /* sequential blue */
  --q100: #cde2fb; --q150: #b7d3f6; --q200: #9ec5f4; --q250: #86b6ef; --q300: #6da7ec;
  --q350: #5598e7; --q400: #3987e5; --q450: #2a78d6; --q500: #256abf; --q550: #1c5cab;
  --q600: #184f95; --q650: #104281; --q700: #0d366b;

  --good: #0ca30c;
  --good-text: #006300;
  --critical: #d03b3b;

  --font-serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --text-w: 690px;
  --wide-w: 1120px;
  --gutter: 16px;
  --radius: 12px;
  --nav-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1a1a19;
    --bg-2: #222220;
    --bg-3: #2c2c2a;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-3: #a8a79f;
    --muted: #898781;
    --rule: #2c2c2a;
    --axis: #45443f;
    --ring: rgba(255, 255, 255, 0.10);
    --focus: #6da7ec;
    --mark-hover: rgba(255, 255, 255, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --s-wikitext2: #3987e5;
    --s-c4: #d95926;
    --s-slimpajama: #199e70;
    --s-alpaca: #c98500;
    --s-selfgen: #d55181;
    --s-selfdoc: #0ca30c;
    --s-toyA: #9085e9;
    --s-toyB: #e66767;
    --good-text: #0ca30c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1a19;
  --bg-2: #222220;
  --bg-3: #2c2c2a;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --ink-3: #a8a79f;
  --muted: #898781;
  --rule: #2c2c2a;
  --axis: #45443f;
  --ring: rgba(255, 255, 255, 0.10);
  --focus: #6da7ec;
  --mark-hover: rgba(255, 255, 255, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --s-wikitext2: #3987e5;
  --s-c4: #d95926;
  --s-slimpajama: #199e70;
  --s-alpaca: #c98500;
  --s-selfgen: #d55181;
  --s-selfdoc: #0ca30c;
  --s-toyA: #9085e9;
  --s-toyB: #e66767;
  --good-text: #0ca30c;
}

/* ------------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.62;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
@media (max-width: 640px) { body { font-size: 17.5px; line-height: 1.6; } }

a { color: inherit; text-decoration-line: underline; text-decoration-thickness: 1px;
    text-underline-offset: 0.18em; text-decoration-color: var(--axis); transition: text-decoration-color .15s; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

p { margin: 0 0 1em; }
strong { font-weight: 650; }
em { font-style: italic; }
code, kbd, pre { font-family: var(--font-mono); font-size: 0.84em; }
code { background: var(--bg-2); padding: 0.08em 0.32em; border-radius: 4px; }
sup, sub { line-height: 0; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

.sans { font-family: var(--font-sans); }
.muted { color: var(--ink-2); }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* ------------------------------------------------------------------ layout */

.page { display: grid;
  grid-template-columns:
    [full-start] minmax(var(--gutter), 1fr)
    [wide-start] minmax(0, calc((var(--wide-w) - var(--text-w)) / 2))
    [text-start] min(var(--text-w), 100% - 2 * var(--gutter)) [text-end]
    minmax(0, calc((var(--wide-w) - var(--text-w)) / 2)) [wide-end]
    minmax(var(--gutter), 1fr) [full-end]; }
/* chapters are display:contents, so their children are items of the page grid too */
.page > *, .chapter > * { grid-column: text; min-width: 0; }
.page > .l-wide, .chapter > .l-wide { grid-column: wide; }
.page > .l-full, .chapter > .l-full { grid-column: full; }

section.chapter { display: contents; }
/* such an element has no box, so a link to it cannot scroll: the ids are on the chapter heads */

/* ------------------------------------------------------------------ navigation */

.topbar { position: sticky; top: 0; z-index: 50; height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
  font-family: var(--font-sans); font-size: 14px; }
.topbar.scrolled { border-bottom-color: var(--rule); }
.topbar-inner { max-width: calc(var(--wide-w) + 2 * var(--gutter)); margin: 0 auto; height: 100%;
  padding: 0 var(--gutter); display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600;
  letter-spacing: -0.01em; white-space: nowrap; }
.brand svg { width: 22px; height: 22px; flex: none; }
.brand-title { opacity: 0; transform: translateY(4px); transition: opacity .25s, transform .25s; }
.topbar.scrolled .brand-title { opacity: 1; transform: none; }
.navlinks { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.navlinks::-webkit-scrollbar { display: none; }
.navlinks a { text-decoration: none; color: var(--ink-2); padding: 6px 10px; border-radius: 999px;
  white-space: nowrap; transition: background .15s, color .15s; }
.navlinks a:hover { color: var(--ink); background: var(--bg-2); }
.navlinks a.active { color: var(--ink); background: var(--bg-3); }
.theme-btn { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 999px;
  border: 1px solid var(--rule); background: transparent; color: var(--ink); cursor: pointer; }
.theme-btn:hover { background: var(--bg-2); }
.theme-btn svg { width: 17px; height: 17px; }
.progress { position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%; transform-origin: 0 50%;
  transform: scaleX(0); background: var(--ink); opacity: .55; }
@media (max-width: 860px) {
  .navlinks { display: none; }
  .theme-btn { margin-left: auto; }
  .menu-btn { display: grid !important; }
}
.menu-btn { display: none; flex: none; place-items: center; width: 34px; height: 34px; border-radius: 999px;
  border: 1px solid var(--rule); background: transparent; color: var(--ink); cursor: pointer; }
.menu-btn svg { width: 18px; height: 18px; }
.mobile-menu { position: fixed; z-index: 49; top: var(--nav-h); left: 0; right: 0; background: var(--bg);
  border-bottom: 1px solid var(--rule); padding: 8px var(--gutter) 16px; font-family: var(--font-sans);
  display: none; box-shadow: var(--shadow); }
.mobile-menu.open { display: block; }
.mobile-menu a { display: block; padding: 10px 4px; text-decoration: none; border-bottom: 1px solid var(--rule); }

/* ------------------------------------------------------------------ hero */

.hero { padding: clamp(36px, 7vw, 88px) 0 8px; }
.kicker { font-family: var(--font-sans); font-size: 13px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-bottom: 22px; }
.kicker .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); }
.kicker .oa { display: inline-flex; align-items: center; gap: 6px; }
.kicker .oa svg { width: 13px; height: 13px; }
h1.title { font-size: clamp(38px, 6.4vw, 68px); line-height: 1.02; letter-spacing: -0.025em; font-weight: 650;
  margin: 0 0 18px; font-variation-settings: "opsz" 60; text-wrap: balance; }
.subtitle { font-size: clamp(19px, 2.3vw, 24px); line-height: 1.35; color: var(--ink-2); margin: 0 0 30px;
  font-weight: 400; text-wrap: balance; max-width: 34em; }
.byline { font-family: var(--font-sans); font-size: 15px; display: flex; flex-wrap: wrap; align-items: center;
  gap: 4px 10px; margin-bottom: 30px; }
.byline .author { font-weight: 600; font-size: 16px; }
.byline .orcid { display: inline-flex; width: 16px; height: 16px; vertical-align: -2px; }
.byline .affil { color: var(--ink-2); flex-basis: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; font-family: var(--font-sans); margin-bottom: 12px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 999px;
  font-size: 14.5px; font-weight: 550; text-decoration: none; border: 1px solid var(--ink);
  background: var(--ink); color: var(--bg); transition: transform .12s, box-shadow .12s, background .12s; cursor: pointer;
  font-family: var(--font-sans); line-height: 1.2; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--axis); }
.btn.ghost:hover { border-color: var(--ink); }
.btn svg { width: 16px; height: 16px; flex: none; }

/* ------------------------------------------------------------------ text blocks */

.chapter-head { margin-top: clamp(64px, 10vw, 120px); }
.eyebrow { font-family: var(--font-sans); font-size: 12.5px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-2); margin: 0 0 10px; display: flex; gap: 10px; align-items: center; }
.eyebrow::before { content: ""; width: 22px; height: 1px; background: var(--ink-2); }
h2 { font-size: clamp(30px, 4vw, 42px); line-height: 1.1; letter-spacing: -0.02em; font-weight: 650;
  margin: 0 0 22px; font-variation-settings: "opsz" 48; text-wrap: balance; }
h3 { font-size: 24px; line-height: 1.25; letter-spacing: -0.01em; font-weight: 640; margin: 2.2em 0 .6em;
  font-variation-settings: "opsz" 32; text-wrap: balance; }
h3 .sec { font-family: var(--font-sans); font-size: 13px; font-weight: 600; color: var(--muted); margin-right: 8px;
  letter-spacing: .02em; vertical-align: 3px; }
.lede { font-size: 1.12em; line-height: 1.55; color: var(--ink); }
.takeaway { border-left: 3px solid var(--ink); padding: 4px 0 4px 18px; margin: 1.6em 0; font-size: 1.04em; }
.takeaway b { font-family: var(--font-sans); font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase;
  display: block; color: var(--ink-2); margin-bottom: 2px; }
.paper-ref { font-family: var(--font-sans); font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.paper-ref::before { content: "↗ "; }
.note { font-family: var(--font-sans); font-size: 14.5px; line-height: 1.55; color: var(--ink-2);
  background: var(--bg-2); border-radius: 10px; padding: 14px 16px; margin: 1.4em 0; }
.note strong { color: var(--ink); }
ul.clean, ol.clean { padding-left: 1.2em; }
ul.clean li, ol.clean li { margin: .35em 0; }
.prop { background: var(--bg-2); border-radius: var(--radius); padding: 18px 20px; margin: 1.4em 0; }
.prop .prop-title { font-family: var(--font-sans); font-weight: 650; font-size: 14px; letter-spacing: .02em; margin-bottom: 6px; }
.katex-display { margin: 1em 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.katex { font-size: 1.04em; }
.term { text-decoration: underline dotted var(--muted); text-underline-offset: 0.2em; cursor: help; }

/* source swatches inline in prose */
.sw { display: inline-block; width: .62em; height: .62em; border-radius: 50%; margin-right: .3em;
  vertical-align: .05em; background: var(--c, var(--ink)); }

/* ------------------------------------------------------------------ key findings */

.findings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 26px 0 8px; }
@media (max-width: 980px) { .findings { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .findings { grid-template-columns: 1fr; } }
.finding { display: flex; flex-direction: column; gap: 8px; text-decoration: none; padding: 20px 20px 18px;
  border-radius: var(--radius); background: var(--bg-2); border: 1px solid transparent;
  transition: border-color .15s, transform .15s; position: relative; min-width: 0; }
.finding:hover { border-color: var(--axis); transform: translateY(-2px); }
.finding .fig-num { font-family: var(--font-sans); font-weight: 650; font-size: clamp(34px, 4vw, 44px);
  line-height: 1; letter-spacing: -0.03em; }
.finding .fig-num small { font-size: .5em; font-weight: 600; letter-spacing: -0.01em; color: var(--ink-2); margin-left: 2px; }
.finding .fig-label { font-family: var(--font-sans); font-size: 13px; color: var(--ink-2); text-transform: uppercase;
  letter-spacing: .06em; font-weight: 600; }
.finding p { margin: 0; font-size: 16px; line-height: 1.5; }
.finding .go { font-family: var(--font-sans); font-size: 13px; color: var(--ink-2); margin-top: auto; padding-top: 6px; }
.finding .bar { display: flex; gap: 3px; height: 6px; margin-top: 2px; }
.finding .bar i { flex: 1; border-radius: 3px; background: var(--c); }

/* ------------------------------------------------------------------ figures */

figure { margin: 0; }
.fig { margin: 34px 0 30px; }
.fig-frame { background: var(--bg-2); border-radius: var(--radius); padding: 18px 20px 14px; position: relative; }
@media (max-width: 640px) { .fig-frame { padding: 14px 12px 12px; border-radius: 10px; } }
.fig-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px;
  margin-bottom: 12px; font-family: var(--font-sans); }
.fig-title { font-size: 15.5px; font-weight: 650; letter-spacing: -0.005em; margin: 0; line-height: 1.35; }
.fig-sub { font-size: 13.5px; color: var(--ink-2); margin: 2px 0 0; line-height: 1.45; font-family: var(--font-sans); }
.controls { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 0 0 12px;
  font-family: var(--font-sans); font-size: 13px; }
.control { display: inline-flex; align-items: center; gap: 8px; }
.control > .control-label { color: var(--ink-2); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--rule); border-radius: 999px; padding: 2px; gap: 2px; flex-wrap: wrap; }
.seg button { font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--ink-2); padding: 5px 11px;
  border-radius: 999px; cursor: pointer; white-space: nowrap; line-height: 1.25; transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); background: var(--bg-2); }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.seg button:disabled { opacity: .35; cursor: not-allowed; }
.fig-body { position: relative; }
.fig-body svg { display: block; overflow: visible; font-family: var(--font-sans); }
.fig-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 20px;
  margin-top: 12px; font-family: var(--font-sans); font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.fig-foot .caption { flex: 1 1 420px; margin: 0; }
.fig-foot .caption strong { color: var(--ink); font-weight: 600; }
.fig-tools { display: flex; gap: 8px; align-items: center; flex: none; }
.linkbtn { font: inherit; font-size: 13px; background: none; border: 1px solid var(--rule); color: var(--ink-2);
  border-radius: 999px; padding: 4px 11px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.linkbtn:hover { color: var(--ink); border-color: var(--axis); }
.linkbtn[aria-expanded="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.status { font-family: var(--font-sans); font-size: 13.5px; color: var(--ink-2); padding: 8px 0; }

/* chart chrome */
.axis line, .axis path { stroke: var(--axis); shape-rendering: crispEdges; }
.axis text { fill: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.axis .domain { stroke: var(--axis); }
.grid line { stroke: var(--rule); shape-rendering: crispEdges; }
.grid .domain { display: none; }
.axis-title { fill: var(--ink-2); font-size: 12px; }
.ref-line { stroke: var(--ink-3); stroke-width: 1.25; }
.ref-label { fill: var(--ink-2); font-size: 11.5px; }
.lbl { fill: var(--ink); font-size: 12px; }
.lbl-2 { fill: var(--ink-2); font-size: 11.5px; }
.cell-text { font-size: 11.5px; font-variant-numeric: tabular-nums; pointer-events: none; }
.hit { fill: transparent; cursor: pointer; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: 4px 6px; font-family: var(--font-sans); font-size: 13px; margin: 2px 0 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; padding: 3px 9px 3px 7px; border-radius: 999px;
  border: 1px solid transparent; background: none; color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; }
.legend-item:hover, .legend-item.on { border-color: var(--rule); background: var(--bg); }
.legend-item.off { opacity: .4; }
.legend-item svg { flex: none; }
.legend-static { cursor: default; }

/* tooltip */
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--bg); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 10px; box-shadow: var(--shadow); padding: 9px 11px;
  font-family: var(--font-sans); font-size: 12.5px; line-height: 1.4; max-width: 300px; opacity: 0;
  transform: translateY(4px); transition: opacity .1s, transform .1s; }
.tooltip.show { opacity: 1; transform: none; }
.tooltip .tt-title { font-weight: 650; margin-bottom: 4px; font-size: 12.5px; }
.tooltip .tt-sub { color: var(--ink-2); margin-bottom: 5px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .tt-row .k { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tooltip .tt-row .v { font-weight: 650; font-variant-numeric: tabular-nums; }
.tooltip .key { width: 12px; height: 2.5px; border-radius: 2px; display: inline-block; }
.tooltip .tt-note { color: var(--ink-2); margin-top: 5px; }

/* table view (the accessible twin of every chart) */
.table-wrap { margin-top: 12px; overflow-x: auto; border-radius: 8px; border: 1px solid var(--rule); background: var(--bg); }
table.data { border-collapse: collapse; width: 100%; font-family: var(--font-sans); font-size: 13px;
  font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--rule); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { font-weight: 600; color: var(--ink-2); background: var(--bg-2); position: sticky; top: 0; }
table.data tbody tr:hover { background: var(--bg-2); }
table.data td.best { font-weight: 700; }
table.data caption { caption-side: top; text-align: left; padding: 8px 10px; color: var(--ink-2); }

/* ------------------------------------------------------------------ specific figures */

/* hero scatter */
.hero-fig .fig-frame { padding-top: 16px; }
.steps { display: flex; gap: 6px; flex-wrap: wrap; font-family: var(--font-sans); }
.step { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--rule); background: var(--bg);
  color: var(--ink-2); border-radius: 999px; padding: 6px 12px 6px 6px; font: inherit; font-size: 13.5px; cursor: pointer; }
.step .n { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--bg-3);
  color: var(--ink); font-weight: 650; font-size: 12px; }
.step[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); }
.step[aria-pressed="true"] .n { background: var(--ink); color: var(--bg); }
.state-caption { font-family: var(--font-sans); font-size: 14.5px; line-height: 1.55; color: var(--ink); min-height: 4.6em;
  margin: 10px 0 0; max-width: 60em; }
.state-caption .big { font-weight: 700; }

/* toy */
.toy { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 18px; align-items: start; }
@media (max-width: 760px) { .toy { grid-template-columns: minmax(0, 1fr); } }
.toy canvas { width: 100%; height: auto; aspect-ratio: 4 / 3; display: block; cursor: grab; touch-action: none;
  border-radius: 10px; background: var(--bg); }
.toy canvas:active { cursor: grabbing; }
.toy-side { font-family: var(--font-sans); font-size: 13.5px; line-height: 1.5; }
.toy-side .meter { margin: 10px 0 14px; }
.meter-row { display: grid; grid-template-columns: 96px 1fr 48px; align-items: center; gap: 8px; margin: 7px 0; white-space: nowrap; }
.meter-track { height: 10px; border-radius: 5px; background: var(--bg-3); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 5px; transition: width .6s cubic-bezier(.2,.7,.2,1); }
.meter-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
.toggle input { accent-color: var(--ink); width: 16px; height: 16px; }

/* windows */
.win-row-label { font-size: 12.5px; fill: var(--ink); }
.win-row-sub { font-size: 11.5px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }

/* excerpts */
.excerpts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
@media (max-width: 760px) { .excerpts { grid-template-columns: 1fr; } }
.excerpt { background: var(--bg); border: 1px solid var(--rule); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.excerpt .ex-head { font-family: var(--font-sans); font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-2); font-weight: 600; margin-bottom: 6px; display: flex; justify-content: space-between; gap: 8px; }
.excerpt pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12.5px; line-height: 1.5;
  max-height: 15em; overflow: auto; color: var(--ink); }
.tok-special { font-family: var(--font-sans); font-size: 10.5px; font-weight: 650; color: var(--bg); background: var(--ink-2);
  border-radius: 4px; padding: 0 4px; margin: 0 1px; white-space: nowrap; }
.ex-note { font-family: var(--font-sans); font-size: 13.5px; color: var(--ink-2); margin: 10px 0 0; }

/* prefix tree */
.tree-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px; align-items: start; }
@media (max-width: 760px) { .tree-wrap { grid-template-columns: minmax(0, 1fr); } }
.tree-side { font-family: var(--font-sans); font-size: 13.5px; line-height: 1.5; }
.eq-check { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--rule); }
.eq-check .row { display: flex; justify-content: space-between; gap: 10px; margin: 3px 0; }
.eq-check .row b { font-variant-numeric: tabular-nums; }
.eq-check .verdict { margin-top: 6px; font-weight: 650; }
.eq-check .verdict.ok { color: var(--good-text); }

/* uniform-fidelity explorer */
.kl-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(260px, 1fr); gap: 22px; align-items: start; }
@media (max-width: 900px) { .kl-layout { grid-template-columns: minmax(0, 1fr); } }
.weights { font-family: var(--font-sans); font-size: 13px; }
.weights h4 { margin: 0 0 6px; font-size: 13.5px; font-weight: 650; }
.wrow { display: grid; grid-template-columns: 96px 1fr 34px; gap: 8px; align-items: center; margin: 4px 0; }
.wrow label { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wrow input[type="range"] { width: 100%; accent-color: var(--ink); }
.wrow output { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.rank { margin-top: 12px; }
.rank-row { display: grid; grid-template-columns: 92px 1fr 44px; gap: 8px; align-items: center; margin: 5px 0; }
.rank-row .nm { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.rank-bar { height: 12px; border-radius: 0 4px 4px 0; transition: width .45s cubic-bezier(.2,.7,.2,1); }
.rank-row .vv { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.rank-row.first .nm { font-weight: 700; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px; }

/* scorecard (fidelity is not utility) */
.scorecard { display: grid; gap: 10px; font-family: var(--font-sans); }
.sc-row { display: grid; grid-template-columns: 210px minmax(0, 1fr) 150px; gap: 14px; align-items: center; }
@media (max-width: 700px) { .sc-row { grid-template-columns: 1fr; gap: 4px; } }
.sc-name { font-size: 14px; font-weight: 600; }
.sc-name small { display: block; font-weight: 400; color: var(--ink-2); font-size: 12.5px; }
.sc-val { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.45; }
.sc-val b { color: var(--ink); }

/* robustness table */
.robust { width: 100%; border-collapse: collapse; font-family: var(--font-sans); font-size: 14px; }
.robust th, .robust td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.robust th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); font-weight: 600; }
.robust td.ctl { font-weight: 600; width: 28%; }
.robust td.ctl small { display: block; font-weight: 400; color: var(--ink-2); }
.robust .yes { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; color: var(--good-text); white-space: nowrap; }
.robust .yes svg { width: 15px; height: 15px; }
@media (max-width: 700px) { .robust td.ctl { width: auto; } .robust .hide-sm { display: none; } }

/* recommendation helper */
.helper { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 22px; align-items: start; }
@media (max-width: 860px) { .helper { grid-template-columns: minmax(0, 1fr); } }
.q { margin-bottom: 16px; font-family: var(--font-sans); }
.q-label { font-size: 14px; font-weight: 650; margin-bottom: 7px; }
.choice { display: flex; flex-direction: column; gap: 6px; }
.choice button { text-align: left; font: inherit; font-size: 14px; border: 1px solid var(--rule); background: var(--bg);
  color: var(--ink); border-radius: 10px; padding: 9px 12px; cursor: pointer; line-height: 1.35; }
.choice button small { display: block; color: var(--ink-2); font-size: 12.5px; margin-top: 2px; }
.choice button:hover { border-color: var(--axis); }
.choice button[aria-checked="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.advice { background: var(--bg); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px 20px; font-family: var(--font-sans); }
.advice h4 { margin: 0 0 8px; font-size: 17px; font-family: var(--font-serif); font-weight: 650; }
.advice ul { margin: 6px 0 0; padding-left: 1.1em; font-size: 14.5px; line-height: 1.5; }
.advice li { margin: 6px 0; }
.advice .ev { color: var(--ink-2); font-size: 13px; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.pick .chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--rule); font-size: 14px; font-weight: 600; }

/* explorer */
.explorer-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; font-family: var(--font-sans); }
.explorer-filters select, .explorer-filters input { font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--rule); background: var(--bg); color: var(--ink); }
.explorer-filters input { min-width: 200px; flex: 1 1 200px; }
.explorer-scroll { max-height: 520px; overflow: auto; border: 1px solid var(--rule); border-radius: 8px; background: var(--bg); }
.explorer-scroll table.data th { cursor: pointer; user-select: none; }
.explorer-scroll table.data th[aria-sort="ascending"]::after { content: " ↑"; }
.explorer-scroll table.data th[aria-sort="descending"]::after { content: " ↓"; }
.explorer-count { font-family: var(--font-sans); font-size: 13px; color: var(--ink-2); margin: 8px 0 0; }

/* stats strip */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 22px 0; font-family: var(--font-sans); }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { padding: 14px 16px; border-radius: 10px; background: var(--bg-2); }
.stat .v { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
.stat .l { font-size: 13px; color: var(--ink-2); margin-top: 4px; line-height: 1.4; }

/* code blocks */
pre.code { background: var(--bg-2); border-radius: 10px; padding: 14px 16px; overflow-x: auto; font-size: 13.5px;
  line-height: 1.55; margin: 1em 0; position: relative; }
pre.code .c { color: var(--muted); }
.copy-wrap { position: relative; }
.copy-btn { position: absolute; top: 8px; right: 8px; }

/* pipeline diagram */
.pipeline svg { width: 100%; height: auto; display: block; }
.pipeline .box { fill: var(--bg); stroke: var(--axis); }
.pipeline .box-strong { fill: var(--bg); stroke: var(--ink); stroke-width: 1.4; }
.pipeline .flow { stroke: var(--ink-3); stroke-width: 1.5; fill: none; }
.pipeline .data-flow { stroke-width: 2.5; fill: none; }
.pipeline text { font-family: var(--font-sans); fill: var(--ink); }
.pipeline .t-sm { font-size: 12px; fill: var(--ink-2); }
.pipeline .t-md { font-size: 13.5px; font-weight: 600; }
.pipeline .badge { font-size: 11px; font-weight: 700; fill: var(--bg); }

/* merge widget */
.merge { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 18px; align-items: center; }
@media (max-width: 760px) { .merge { grid-template-columns: minmax(0, 1fr); } }
.merge-side { font-family: var(--font-sans); font-size: 13.5px; line-height: 1.55; }
.merge-side input[type="range"] { width: 100%; accent-color: var(--ink); }
.merge-side .num { font-variant-numeric: tabular-nums; font-weight: 650; }

/* BOS widget */
.tokens { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-family: var(--font-mono); font-size: 13.5px; margin: 4px 0 14px; }
.tok { padding: 3px 7px; border-radius: 6px; background: var(--bg); border: 1px solid var(--rule); }
.tok.bos { font-family: var(--font-sans); font-size: 12px; font-weight: 700; background: var(--ink); color: var(--bg); border-color: var(--ink);
  transition: opacity .3s, transform .3s, width .3s; }
.tok.bos.gone { opacity: .25; text-decoration: line-through; background: transparent; color: var(--ink-2); border-style: dashed; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-family: var(--font-sans); font-size: 14px; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 42px; height: 24px; border-radius: 12px; background: var(--axis); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg); transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--ink); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* citation */
.bib { position: relative; }
.bib pre { background: var(--bg-2); border-radius: 10px; padding: 16px 18px; overflow-x: auto; font-size: 13px; line-height: 1.55; margin: 0; }

/* footer */
.footer { margin-top: 110px; padding: 36px 0 60px; border-top: 1px solid var(--rule); font-family: var(--font-sans);
  font-size: 13.5px; color: var(--ink-2); line-height: 1.6; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr; } }
.footer h5 { margin: 0 0 6px; color: var(--ink); font-size: 13px; }
.footer a { color: var(--ink-2); }
.footer ul { list-style: none; padding: 0; margin: 0; }

/* reveal */
.reveal { opacity: 0; transform: translateY(12px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

@media print {
  .topbar, .mobile-menu, .controls, .fig-tools, .theme-btn, .actions { display: none !important; }
  body { font-size: 11pt; }
  .fig-frame { background: none; border: 1px solid #ccc; }
  .reveal { opacity: 1; transform: none; }
}
@media (forced-colors: active) {
  .seg button[aria-checked="true"], .step[aria-pressed="true"] { outline: 2px solid CanvasText; }
}

/* text over marks keeps a halo in the figure's surface color */
.fig-body svg text.lbl, .fig-body svg text.ref-label { paint-order: stroke; stroke: var(--bg-2); stroke-width: 3.5px; stroke-linejoin: round; }

/* phone widths: the method diagram scrolls inside its frame rather than shrinking to illegibility */
@media (max-width: 700px) {
  .pipeline { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .pipeline svg { min-width: 680px; }
  .katex-display > .katex { font-size: 0.92em; }
}
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
