:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #0e1116;
  --text-2: #4a5160;
  --muted: #6b7280;
  --border: rgba(14, 17, 22, 0.10);
  --grid: #e6e8ec;
  --axis: #c3c7cf;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --good: #006300;
  --bad: #c02f2f;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --shadow: 0 1px 2px rgba(14, 17, 22, 0.04), 0 4px 16px rgba(14, 17, 22, 0.05);
  --radius: 14px;
  --mono: "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Fira Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d12;
  --surface: #12151c;
  --surface-2: #181c25;
  --text: #eef0f3;
  --text-2: #b9bfca;
  --muted: #8b93a1;
  --border: rgba(255, 255, 255, 0.09);
  --grid: #232835;
  --axis: #3a4150;
  --accent: #5598e7;
  --accent-ink: #86b6ef;
  --good: #2fbf4f;
  --bad: #ef6b6b;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 16px; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .wrap { padding: 0 32px; } }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav .wrap { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.brand svg { color: var(--accent); }
.nav-links { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav-links a {
  color: var(--text-2); text-decoration: none; font-size: 15px;
  padding: 8px 12px; border-radius: 8px; min-height: 40px; display: inline-flex; align-items: center;
  transition: background-color .15s, color .15s;
}
.nav-links a:hover, .nav-links a[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer; transition: color .15s, background-color .15s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
@media (max-width: 640px) { .nav-links .hide-sm { display: none; } }

/* ---------- hero ---------- */
.hero { padding: 64px 0 32px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; font: 500 13px/1 var(--mono);
  color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 7px 12px; border-radius: 999px; letter-spacing: 0.02em; line-height: 1.4; max-width: 100%;
}
.hero .wrap > * { max-width: 100%; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.hero h1 { font-size: clamp(32px, 5.2vw, 56px); line-height: 1.08; letter-spacing: -0.03em; margin: 20px 0 16px; font-weight: 700; max-width: 18ch; }
.hero h1 em { font-style: normal; color: var(--accent-ink); }
.lede { font-size: clamp(17px, 1.6vw, 19px); color: var(--text-2); max-width: 64ch; margin: 0 0 28px; }
.byline { color: var(--muted); font-size: 15px; margin-bottom: 28px; }
.byline strong { color: var(--text); font-weight: 600; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 10px; font-weight: 500; text-decoration: none; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); transition: transform .15s, background-color .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
:root[data-theme="dark"] .btn.primary:hover { background: #2a78d6; }

/* ---------- stat tiles ---------- */
.tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 40px 0 8px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.tile .k { font-size: 14px; color: var(--text-2); }
.tile .v { font: 600 34px/1.1 var(--sans); letter-spacing: -0.02em; margin: 8px 0 6px; }
.tile .v small { font-size: 16px; font-weight: 500; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.tile .s { font-size: 14px; color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; padding: 2px 8px; border-radius: 999px; }
.tag.good { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.tag.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }

/* ---------- sections ---------- */
section.block { padding: 56px 0 8px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.sec-head h2 { font-size: clamp(24px, 3vw, 32px); letter-spacing: -0.02em; margin: 0; line-height: 1.2; }
.sec-head p { margin: 6px 0 0; color: var(--text-2); max-width: 62ch; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.card { grid-column: span 12; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
@media (min-width: 900px) { .span-6 { grid-column: span 6; } .span-4 { grid-column: span 4; } .span-8 { grid-column: span 8; } }
.card h3 { font-size: 17px; margin: 0; letter-spacing: -0.01em; }
.card .sub { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-2); margin: 0 0 8px; padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.sq { width: 10px; height: 10px; border-radius: 3px; }
.legend i.dash { background: none !important; border-top: 2px dashed currentColor; height: 0; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font: 12px var(--sans); fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .grid-l { stroke: var(--grid); stroke-width: 1; }
.chart .base-l { stroke: var(--axis); stroke-width: 1; }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 140px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  padding: 8px 10px; font-size: 13px; line-height: 1.45; opacity: 0; transform: translateY(4px);
  transition: opacity .12s, transform .12s;
}
.tip.on { opacity: 1; transform: none; }
.tip b { display: block; font-weight: 600; margin-bottom: 2px; color: var(--text); }
.tip .row { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.tip .row span:last-child { margin-left: auto; padding-left: 12px; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 500; }
.tip .dot { width: 8px; height: 8px; border-radius: 50%; }
details.data { margin-top: 10px; font-size: 14px; }
details.data summary { cursor: pointer; color: var(--muted); min-height: 32px; display: inline-flex; align-items: center; }
details.data summary:hover { color: var(--text); }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tr.hl td { background: color-mix(in srgb, var(--accent) 8%, transparent); font-weight: 600; }
td.neg { color: var(--bad); }
td.pos { color: var(--good); }

/* ---------- pipeline ---------- */
.steps { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); counter-reset: s; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; position: relative; }
.step .n { font: 500 13px var(--mono); color: var(--accent-ink); }
.step h3 { margin: 6px 0 6px; font-size: 17px; }
.step p { margin: 0; color: var(--text-2); font-size: 15px; }
.callout {
  display: flex; gap: 14px; align-items: flex-start; padding: 18px 20px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--s2) 35%, var(--border)); background: color-mix(in srgb, var(--s2) 7%, var(--surface));
  color: var(--text-2);
}
.callout svg { flex: none; color: var(--s2); margin-top: 2px; }
.callout strong { color: var(--text); }

/* ---------- footer ---------- */
footer { margin-top: 72px; border-top: 1px solid var(--border); padding: 32px 0 48px; color: var(--muted); font-size: 14px; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; }
footer a { color: var(--text-2); }

/* ---------- research (prose) ---------- */
.doc { display: grid; gap: 40px; grid-template-columns: minmax(0, 1fr); padding: 40px 0; }
@media (min-width: 1024px) { .doc { grid-template-columns: 240px minmax(0, 1fr); } }
.toc { display: none; }
@media (min-width: 1024px) {
  .toc { display: block; position: sticky; top: 84px; align-self: start; max-height: calc(100dvh - 100px); overflow: auto; font-size: 14px; }
  .toc p { font: 500 12px var(--mono); color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; margin: 0 0 10px; }
  .toc a { display: block; color: var(--text-2); text-decoration: none; padding: 6px 10px; border-left: 2px solid var(--border); transition: color .15s, border-color .15s; }
  .toc a:hover { color: var(--text); }
  .toc a.on { color: var(--accent-ink); border-left-color: var(--accent); }
}
.prose { max-width: 78ch; min-width: 0; }
.prose h1 { font-size: clamp(30px, 4vw, 44px); line-height: 1.12; letter-spacing: -0.025em; margin: 0 0 8px; }
.prose h2 { font-size: 26px; letter-spacing: -0.02em; margin: 56px 0 12px; padding-top: 8px; }
.prose h3 { font-size: 19px; margin: 32px 0 8px; }
.prose p, .prose li { color: var(--text-2); }
.prose strong { color: var(--text); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
.prose blockquote { margin: 16px 0; padding: 12px 16px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 10px 10px 0; color: var(--text-2); }
.prose blockquote p { margin: 0; }
.prose code { font: 0.88em var(--mono); background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
.prose pre { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose table { margin: 16px 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: block; overflow-x: auto; }
.prose table th, .prose table td { white-space: normal; min-width: 64px; vertical-align: top; }
.prose table td:not(:first-child) { text-align: left; }
.prose table th:not(:first-child) { text-align: left; }
.prose h2 + p > a[href^="#"]:only-child { display: none; }
.loading { color: var(--muted); padding: 40px 0; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
