:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #111110;
  --ink-2: #57564f;
  --muted: #8a8880;
  --rule: #e3e1d9;
  --grid: #ecebe5;
  --hover: #f0efe9;
  --s1: #257de0;   /* categorical slots 1-3 (validated, all pairs) */
  --s2: #f47230;
  --s3: #00b894;
  --ghost: #c9c7be;
  --b0: #67ad4b; --b1: #f9d423; --b2: #f0954a; --b3: #d7372a; --b4: #9b1532;
  --k0: #eef4fd; --k1: #0e3d7e;
  --shadow: 0 1px 0 rgba(17, 17, 16, .04), 0 12px 40px -18px rgba(17, 17, 16, .18);
  --ease: cubic-bezier(.2, .7, .1, 1);
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --serif: "Instrument Serif", ui-serif, Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0e0d; --surface: #161615; --ink: #f1f0ea; --ink-2: #b3b1a8; --muted: #7f7d75;
    --rule: #2a2a27; --grid: #22221f; --hover: #1f1f1d;
    --s1: #338ced; --s2: #e76624; --s3: #00a888; --ghost: #4a4944;
    --k0: #1b2533; --k1: #84b9f3;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 18px 50px -20px rgba(0, 0, 0, .7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e0d; --surface: #161615; --ink: #f1f0ea; --ink-2: #b3b1a8; --muted: #7f7d75;
  --rule: #2a2a27; --grid: #22221f; --hover: #1f1f1d;
  --s1: #338ced; --s2: #e76624; --s3: #00a888; --ghost: #4a4944;
  --k0: #1b2533; --k1: #84b9f3;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 18px 50px -20px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: hidden;
  transition: background-color .4s var(--ease), color .4s var(--ease);
}
a { color: inherit; }
::selection { background: var(--b1); color: #111110; }

/* progress + nav */
.progress { position: fixed; inset: 0 0 auto; height: 2px; z-index: 30; }
.progress span { display: block; height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--b0), var(--b1), var(--b2), var(--b3), var(--b4)); }
.nav { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; padding: 14px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid transparent; transition: border-color .3s; }
.nav.scrolled { border-bottom-color: var(--rule); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; letter-spacing: -.01em; text-decoration: none; white-space: nowrap; }
.brand em { font-style: normal; font-family: var(--mono); font-weight: 400; font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.brand-mark { display: inline-flex; align-items: flex-end; gap: 2px; height: 16px; }
.brand-mark i { width: 3px; border-radius: 1px; animation: bar 2.4s var(--ease) infinite; }
.brand-mark i:nth-child(1) { height: 6px; background: var(--b0); }
.brand-mark i:nth-child(2) { height: 9px; background: var(--b1); animation-delay: .15s; }
.brand-mark i:nth-child(3) { height: 12px; background: var(--b2); animation-delay: .3s; }
.brand-mark i:nth-child(4) { height: 16px; background: var(--b3); animation-delay: .45s; }
@keyframes bar { 0%, 70%, 100% { transform: scaleY(1); } 35% { transform: scaleY(.55); } }
.brand-mark i { transform-origin: bottom; }
.nav nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav nav a { font-size: 13px; color: var(--ink-2); text-decoration: none; padding: 6px 10px; border-radius: 999px; white-space: nowrap; transition: color .2s, background .2s; }
.nav nav a:hover, .nav nav a.on { color: var(--ink); background: var(--hover); }
.theme { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--rule); background: var(--surface); cursor: pointer; display: grid; place-items: center; flex: none; }
.theme span { width: 14px; height: 14px; border-radius: 50%; background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); border: 1.5px solid var(--ink); transition: transform .5s var(--ease); }
:root[data-theme="dark"] .theme span { transform: rotate(180deg); }
@media (max-width: 860px) { .nav nav { display: none; } .theme { margin-left: auto; } }

main { max-width: 1160px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }

/* hero */
.hero { padding: clamp(56px, 11vh, 120px) 0 40px; }
.eyebrow, .num { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 22px; }
h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(42px, 7.2vw, 96px); line-height: .98; letter-spacing: -.025em; margin: 0; max-width: 19ch; text-wrap: balance; }
h1 em { font-style: italic; color: var(--ink-2); }
.lede { font-size: clamp(17px, 1.6vw, 20px); color: var(--ink-2); max-width: 62ch; margin: 28px 0 0; line-height: 1.55; }
.hero-viz { margin: 56px 0 0; }
figcaption { font-size: 13px; color: var(--muted); margin-top: 14px; max-width: 80ch; line-height: 1.5; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 18px; overflow: hidden; margin-top: 56px; }
.stat { background: var(--bg); padding: 26px 26px 24px; display: flex; flex-direction: column; gap: 8px; }
.stat-k { font-size: clamp(30px, 3.6vw, 46px); font-weight: 500; letter-spacing: -.035em; line-height: 1; }
.stat-l { font-size: 14px; color: var(--ink-2); max-width: 30ch; }
@media (max-width: 760px) { .stats { grid-template-columns: 1fr; } }

/* blocks */
.block { padding: clamp(72px, 12vh, 128px) 0 0; }
.block-head { display: grid; grid-template-columns: 64px minmax(0, 1fr); column-gap: 24px; max-width: 900px; }
.block-head .num { grid-row: span 2; padding-top: 10px; margin: 0; }
h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(32px, 4.2vw, 54px); line-height: 1.02; letter-spacing: -.02em; margin: 0; }
.block-head p:not(.num) { color: var(--ink-2); font-size: 17px; margin: 16px 0 0; max-width: 64ch; }
@media (max-width: 640px) { .block-head { grid-template-columns: 1fr; } .block-head .num { padding: 0 0 12px; } }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 36px 0 14px; }
.seg { position: relative; display: inline-flex; padding: 3px; border-radius: 999px; background: var(--hover); border: 1px solid var(--rule); max-width: 100%; }
.seg.wrap { flex-wrap: wrap; border-radius: 18px; }
.seg button { position: relative; z-index: 1; border: 0; background: none; font: 500 13px var(--sans); color: var(--ink-2); padding: 8px 14px; border-radius: 999px; cursor: pointer; transition: color .25s; white-space: nowrap; }
.seg button[aria-checked="true"] { color: var(--ink); }
.seg .pill { position: absolute; z-index: 0; border-radius: 999px; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--rule); transition: transform .45s var(--ease), width .45s var(--ease), height .45s var(--ease); }
.seg button:focus-visible, select:focus-visible, .theme:focus-visible, summary:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; }
.select { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.select select { appearance: none; font: 500 13px var(--sans); color: var(--ink); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238a8880' fill='none' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center; border: 1px solid var(--rule); border-radius: 999px; padding: 8px 34px 8px 14px; cursor: pointer; }
[data-show][hidden] { display: none; }

.card { margin: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 22px; padding: clamp(16px, 2.6vw, 30px); box-shadow: var(--shadow); }
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--sans); fill: var(--ink-2); font-size: 12px; }
.chart .val { font-family: var(--mono); fill: var(--ink); font-size: 12px; }
.chart .axis line, .chart .axis path { stroke: var(--rule); }
.chart .grid line { stroke: var(--grid); }
.chart .axis text { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--ink-2); margin-bottom: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.dot { border-radius: 50%; width: 10px; height: 10px; }
.legend i.ring { border-radius: 50%; width: 10px; height: 10px; border: 2px solid var(--ghost); }
.legend i.hatch { background: repeating-linear-gradient(135deg, var(--ink-2) 0 1.5px, transparent 1.5px 5px); border: 1px solid var(--ink-2); }

/* map */
.map-card { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; }
.map-card .table-view { grid-column: 1 / -1; }
@media (max-width: 900px) { .map-card { grid-template-columns: 1fr; } }
.map-wrap { position: relative; }
#map path { stroke: var(--surface); stroke-width: .8; cursor: pointer; transition: opacity .25s, filter .25s; }
#map path.dim { fill-opacity: .3; }
#map path.on { stroke: var(--ink); stroke-width: 1.6; }
.ramp { display: flex; align-items: center; gap: 10px; font: 11px var(--mono); color: var(--muted); margin-top: 8px; }
.ramp .bar { flex: 1; max-width: 260px; height: 8px; border-radius: 999px; }
.mini-h { font-size: 13px; font-weight: 500; margin: 0 0 6px; color: var(--ink); }
.mini-h span { color: var(--muted); font-weight: 400; margin-left: 6px; font-family: var(--mono); font-size: 11px; }
#ranks .row { cursor: pointer; }
#ranks .row:hover rect.hit, #ranks .row.on rect.hit { fill: var(--hover); }

/* table view */
.table-view { margin-top: 18px; border-top: 1px solid var(--rule); padding-top: 10px; }
.table-view summary { cursor: pointer; font-size: 13px; color: var(--muted); list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.table-view summary::before { content: "+"; font-family: var(--mono); width: 12px; }
.table-view[open] summary::before { content: "–"; }
.table-view table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
.table-view th, .table-view td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.table-view th { font-weight: 500; color: var(--ink-2); }
.table-view td { font-family: var(--mono); font-size: 12px; }
.table-view td:first-child { font-family: var(--sans); font-size: 13px; }
.table-view > div { overflow-x: auto; }

/* methods */
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 18px; overflow: hidden; margin: 36px 0 18px; }
.facts > div { background: var(--bg); padding: 22px; }
.facts span { font-size: 34px; font-weight: 500; letter-spacing: -.03em; }
.facts p { margin: 6px 0 0; font-size: 14px; color: var(--ink-2); }
@media (max-width: 860px) { .facts { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .facts { grid-template-columns: 1fr; } }
.models-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.models-table th, .models-table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.models-table th { font-weight: 500; font-size: 12px; color: var(--muted); font-family: var(--mono); text-transform: uppercase; letter-spacing: .05em; }
.models-table div { overflow-x: auto; }
.note { font-size: 14px; color: var(--muted); max-width: 80ch; margin-top: 22px; }

.foot { max-width: 1160px; margin: 120px auto 0; padding: 36px clamp(16px, 4vw, 40px) 56px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--muted); }
.foot .cite { color: var(--ink-2); font-size: 14px; }
.foot b { color: var(--ink); font-weight: 500; }

/* tooltip */
.tip { position: fixed; z-index: 40; pointer-events: none; background: var(--ink); color: var(--bg); border-radius: 12px; padding: 10px 12px; font-size: 12px; line-height: 1.45; min-width: 150px; max-width: 280px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); transform: translate(-50%, calc(-100% - 14px)); transition: opacity .15s; }
.tip strong { display: block; font-family: var(--mono); font-size: 15px; font-weight: 500; letter-spacing: -.01em; }
.tip .t-l { opacity: .7; }
.tip .t-row { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.tip .t-row i { width: 10px; height: 2px; border-radius: 1px; flex: none; }

/* motion */
.reveal { opacity: 0; transform: translateY(22px); filter: blur(6px); transition: opacity 1s var(--ease), transform 1s var(--ease), filter 1s var(--ease); }
.reveal.in { opacity: 1; transform: none; filter: none; }
h1.reveal { transition-delay: .08s; }
.lede.reveal { transition-delay: .18s; }
.stat:nth-child(2) { transition-delay: .1s; }
.stat:nth-child(3) { transition-delay: .2s; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; filter: none; transition: none; }
  .brand-mark i { animation: none; }
  .seg .pill { transition: none; }
}
@media (forced-colors: active) { .legend i, .ramp .bar { forced-color-adjust: none; } }
@media (max-width: 560px) {
  .seg { flex-wrap: wrap; border-radius: 18px; }
  .seg button { padding: 7px 11px; }
  .seg.wrap button { white-space: normal; text-align: left; }
}
.chart text.halo { stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; paint-order: stroke; }
.models-table table { min-width: 720px; }
