:root {
  --bg: #fbfbf9; --fg: #1c1c1a; --muted: #5d5d58; --surface: #ffffff;
  --border: #d9d9d2; --accent: #1b5fb5;
  /* QCD order LO..N4LO: one-hue blue ordinal ramp (dataviz --ordinal validated, light surface). */
  --ord-1: #86b6ef; --ord-2: #5598e7; --ord-3: #2a78d6; --ord-4: #1c5cab; --ord-5: #104281;
  /* Precision ratio theory/experiment, diverging blue (<1, theory better) - gray - red (>1, theory is the bottleneck). */
  --rat-1: #2a78d6; --rat-2: #9ec5f4; --rat-3: #cfcec8; --rat-4: #f2a4a3; --rat-5: #e34948;
  --cell-empty: #ecebe6;
  --bad: #b3261e; --bad-bg: #fbe9e7; --good: #1d6b36; --good-bg: #e3f2e7; --chip-bg: #eef3fb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161617; --fg: #e8e8e4; --muted: #a2a29b; --surface: #202022;
    --border: #3a3a3d; --accent: #7db2f0;
    --ord-1: #184f95; --ord-2: #256abf; --ord-3: #3987e5; --ord-4: #6da7ec; --ord-5: #9ec5f4;
    --rat-1: #3987e5; --rat-2: #1c4f8c; --rat-3: #383835; --rat-4: #8c3a3a; --rat-5: #e66767;
    --cell-empty: #2a2a2c;
  --bad: #f2a4a3; --bad-bg: #4a1f1f; --good: #8fd3a3; --good-bg: #1d3a26; --chip-bg: #1f2c3d;
  }
}
:root[data-theme="dark"] {
  --bg: #161617; --fg: #e8e8e4; --muted: #a2a29b; --surface: #202022;
  --border: #3a3a3d; --accent: #7db2f0;
  --ord-1: #184f95; --ord-2: #256abf; --ord-3: #3987e5; --ord-4: #6da7ec; --ord-5: #9ec5f4;
  --rat-1: #3987e5; --rat-2: #1c4f8c; --rat-3: #383835; --rat-4: #8c3a3a; --rat-5: #e66767;
  --cell-empty: #2a2a2c;
  --bad: #f2a4a3; --bad-bg: #4a1f1f; --good: #8fd3a3; --good-bg: #1d3a26; --chip-bg: #1f2c3d;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main:focus { outline: none; }

.skip { position: absolute; left: 16px; top: -3rem; background: var(--surface); padding: .5rem .75rem; z-index: 10; }
.skip:focus { top: .5rem; }

.bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  padding: .75rem 16px; border-bottom: 1px solid var(--border);
}
footer.bar { border-bottom: 0; border-top: 1px solid var(--border); color: var(--muted); font-size: .875rem; }
.brand { font-weight: 700; text-decoration: none; color: var(--fg); }
#search-form { flex: 1 1 12rem; min-width: 0; }
#search-form input {
  width: 100%; padding: .4rem .6rem; font: inherit; color: var(--fg);
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
#theme-toggle {
  font: inherit; color: var(--fg); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: .25rem .6rem; cursor: pointer;
}

main { max-width: 96rem; margin: 0 auto; padding: 16px 24px; }
main p { max-width: 75ch; }
h1 { font-size: 1.5rem; margin: .5rem 0 1rem; }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); }
.tile {
  display: flex; flex-direction: column; gap: .25rem; padding: 1rem; text-decoration: none;
  color: var(--fg); background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.tile:hover { border-color: var(--accent); }
.tile span { color: var(--muted); font-size: .875rem; }

/* Family matrix */
.controls { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: flex-start; margin-bottom: 1rem; }
.controls fieldset { border: 1px solid var(--border); border-radius: 6px; padding: .25rem .75rem .5rem; margin: 0; }
.controls legend { color: var(--muted); font-size: .8125rem; padding: 0 .25rem; }
.controls label { display: inline-block; margin-right: .75rem; white-space: nowrap; }
.controls select { font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: .2rem .4rem; }
.matrix-scroll { overflow-x: auto; max-width: 100%; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
svg.matrix { display: block; width: 100%; height: auto; }
svg.matrix text { fill: var(--fg); font: 13px system-ui, sans-serif; }
svg.matrix .colhead { font-weight: 600; }
svg.matrix .rowhead text { fill: var(--accent); font-weight: 600; font-size: 14px; }
svg.matrix .rowhead:hover text, svg.matrix .rowhead:focus-visible text { text-decoration: underline; }
svg.matrix .muted, svg.matrix .badge-text { fill: var(--fg); font-size: 11px; }
svg.matrix .muted { fill: var(--muted); }
svg.matrix .cell rect.base { stroke: var(--surface); stroke-width: 2; }
svg.matrix a.cell { outline: none; }
svg.matrix a.cell:hover rect.base, svg.matrix a.cell:focus-visible rect.base { stroke: var(--fg); stroke-width: 2.5; }
svg.matrix a.cell.dim { opacity: .3; }
svg.matrix .none { fill: none; stroke: var(--border); stroke-dasharray: 3 3; }
svg.matrix .badge { fill: var(--surface); stroke: var(--border); }
.pat-line { stroke: var(--muted); stroke-width: 1.5; }
.pat-dot { fill: var(--fg); opacity: .55; }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin: .75rem 0; font-size: .875rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend svg { width: 22px; height: 16px; border: 1px solid var(--border); }
.scatter-wrap { max-width: 30rem; margin-top: 1rem; }
svg.scatter { width: 100%; height: auto; }
svg.scatter text { fill: var(--muted); font: 12px system-ui, sans-serif; }
svg.scatter .axis path, svg.scatter .axis line { stroke: var(--border); }
svg.scatter .grid line { stroke: var(--border); stroke-opacity: .5; }
svg.scatter .diag { stroke: var(--muted); stroke-dasharray: 5 4; }
svg.scatter .pt { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
svg.scatter a:hover .pt, svg.scatter a:focus-visible .pt { stroke: var(--fg); }
svg.scatter a { outline: none; }

/* Leaf pages */
.crumbs { font-size: .875rem; color: var(--muted); margin-top: .25rem; }
.leaf { margin-top: 2rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.small, .none-yet { font-size: .875rem; color: var(--muted); }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .2rem 1rem; margin: .5rem 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 30rem) { .facts { grid-template-columns: minmax(0, 1fr); } .facts dd { margin-bottom: .4rem; } }
.actions { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: flex-start; }
.copy { display: inline-flex; flex-direction: column; gap: .25rem; max-width: 100%; }
.btn, .pick select { font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: .25rem .6rem; cursor: pointer; }
.copy-out { font-size: .875rem; color: var(--muted); }
.copy-fallback { display: block; width: min(36rem, 100%); font: 12px/1.4 ui-monospace, monospace; color: var(--fg); background: var(--surface); border: 1px solid var(--border); }
.badge { display: inline-block; padding: 0 .4rem; border-radius: 999px; font-size: .75rem; border: 1px solid var(--border); white-space: nowrap; }
.st-machine-verified, .st-human-verified { color: var(--good); background: var(--good-bg); border-color: var(--good); }
.st-disputed { color: var(--bad); background: var(--bad-bg); border-color: var(--bad); font-weight: 600; }
.prov { font-size: .8125rem; color: var(--muted); }
.vf { text-decoration: none; padding: 0 .15rem; }
.strip-row { margin: .4rem 0; }
.strip-track { height: 12px; background: var(--cell-empty); border-radius: 3px; overflow: hidden; }
.strip-bar { height: 100%; background: var(--accent); }
.table-scroll { overflow-x: auto; max-width: 100%; }
table.meas, table.bb { border-collapse: collapse; font-size: .875rem; }
table.meas th, table.meas td, table.bb th, table.bb td { border-bottom: 1px solid var(--border); padding: .35rem .5rem; text-align: left; vertical-align: top; }
table.meas tr.projected td { font-style: italic; }
table.meas tr.superseded td { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
table.meas tr.superseded td:last-child { text-decoration: none; }
table.meas tr.preliminary td:first-child::after { content: " (prelim.)"; color: var(--muted); }
table.bb td { min-width: 9rem; }
.stamp { --st: var(--good); display: flex; flex-direction: column; gap: .35rem; padding: .4rem .5rem;
  border: 1.5px solid var(--st); border-radius: 8px; background: var(--good-bg); }
.stamp.bb-partial { --st: var(--accent); background: var(--chip-bg); }
.stamp.bb-missing { --st: var(--bad); background: var(--bad-bg); }
.stamp-head { align-self: flex-start; color: var(--st); font-weight: 700; font-size: .8rem; letter-spacing: .08em;
  text-transform: uppercase; border: 1.5px solid var(--st); border-radius: 5px; padding: 0 .4rem; }
.stamp-note { background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: .25rem .4rem; font-size: .8125rem; }
.stamp .small { color: var(--fg); }
.eval { font-size: .75rem; font-weight: 600; padding: 0 .35rem; border-radius: 4px; border: 1px solid; white-space: nowrap; }
.eval-analytic { color: var(--good); }
.eval-semi-analytic { color: var(--accent); }
.eval-numerical { color: var(--fg); }
svg.budget { width: 100%; height: auto; display: block; max-width: 40rem; }
svg.budget text { fill: var(--fg); font: 13px system-ui, sans-serif; }
svg.budget .axis text { fill: var(--muted); font-size: 11px; }
svg.budget .axis path, svg.budget .axis line { stroke: var(--border); }
svg.budget .seg { stroke: var(--surface); stroke-width: 1; cursor: pointer; outline: none; }
svg.budget .seg:hover, svg.budget .seg:focus-visible { stroke: var(--fg); stroke-width: 2; }
svg.budget .tick-total { stroke: var(--fg); stroke-width: 2; }
.budget-list details { margin: .25rem 0; }
.budget-list summary { cursor: pointer; }
.swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; vertical-align: -1px; }
.chips { list-style: none; padding: 0; margin: .25rem 0; display: flex; flex-wrap: wrap; gap: .3rem; }
.chip { display: inline-block; padding: .05rem .5rem; border-radius: 999px; background: var(--chip-bg); font-size: .8125rem; margin-left: .4rem; }
.chips .chip { margin-left: 0; }
.pred { border-top: 1px solid var(--border); padding-top: .25rem; }
.ladder dt { white-space: nowrap; }
