:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #111418;
  --ink-2: #3d434d;
  --muted: #6b717c;
  --rule: #dedbd3;
  --rule-strong: #c9c5bb;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --passed: #1a7f5a;
  --proposed: #b7791f;
  --failed: #c2402f;
  --before: #eb6834;
  --after: #2a78d6;
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 17px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 3px; }
code { font-family: var(--mono); font-size: 0.84em; color: var(--ink); background: #eeece6; padding: 0.06em 0.34em; border-radius: 3px; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 560px) { .wrap { padding: 0 16px; } }

/* Header */
.top { position: sticky; top: 0; z-index: 10; background: rgba(246, 245, 241, 0.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.top-row { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-weight: 600; line-height: 1.2; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.mark { width: 26px; height: 26px; border: 2px solid var(--ink); position: relative; flex: none; }
.mark::after { content: ''; position: absolute; inset: 5px; background: var(--accent); }
.top nav { display: flex; gap: 28px; align-items: center; }
.top nav a { color: var(--ink-2); text-decoration: none; font-size: 15px; }
.top nav a:hover { color: var(--ink); }
.nav-cta { border: 1px solid var(--ink); padding: 6px 14px; color: var(--ink) !important; }
.nav-cta:hover { background: var(--ink); color: var(--bg) !important; }
@media (max-width: 860px) { .top nav a:not(.nav-cta) { display: none; } }
@media (max-width: 420px) { .brand small { display: none; } }

/* Hero */
.hero { padding: 72px 0 64px; border-bottom: 1px solid var(--rule); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; align-items: center; }
@media (max-width: 980px) { .hero-grid { grid-template-columns: 1fr; gap: 32px; } }
.kicker { font-family: var(--mono); font-size: 13px; color: var(--accent); margin: 0 0 20px; letter-spacing: 0.02em; }
h1 { font-size: clamp(32px, 3.6vw, 46px); line-height: 1.1; letter-spacing: -0.02em; font-weight: 600; margin: 0 0 24px; }
.lead { font-size: 18px; color: var(--ink-2); margin: 0 0 32px; max-width: 600px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 40px; }
.btn { display: inline-flex; align-items: center; padding: 13px 22px; border: 1px solid var(--ink); color: var(--ink); text-decoration: none; font-weight: 500; font-size: 16px; transition: background .15s, color .15s; }
.btn:hover { background: var(--ink); color: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #1a43bd; border-color: #1a43bd; color: var(--accent-ink); }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 0; border-top: 1px solid var(--rule); }
.facts > div { padding: 18px 18px 0 0; }
.facts > div + div { padding-left: 18px; border-left: 1px solid var(--rule); }
.facts dt { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.facts dd { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; } .facts > div + div { border-left: 0; padding-left: 0; border-top: 1px solid var(--rule); } .facts > div { padding: 14px 0; } }
.hero-model { margin: 0; background: var(--surface); border: 1px solid var(--rule); }
#scene { display: block; width: 100%; aspect-ratio: 5 / 4; }
.hero-model figcaption { display: flex; gap: 20px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--muted); }
.hero-model figcaption span { display: inline-flex; align-items: center; gap: 8px; }
.st { width: 10px; height: 10px; display: inline-block; }
.st-proposed { background: var(--proposed); } .st-failed { background: var(--failed); } .st-passed { background: var(--passed); }
.no-webgl #scene { background: repeating-linear-gradient(0deg, transparent 0 39px, var(--rule) 39px 40px), repeating-linear-gradient(90deg, transparent 0 39px, var(--rule) 39px 40px); }

/* Sections */
.section { padding: 96px 0 0; }
.section-head { display: grid; grid-template-columns: 72px minmax(0, 820px); gap: 8px 24px; margin-bottom: 40px; }
.section-head .num { font-family: var(--mono); font-size: 14px; color: var(--accent); padding-top: 10px; border-top: 2px solid var(--accent); align-self: start; }
@media (max-width: 700px) { .section-head { grid-template-columns: 1fr; } .section-head .num { width: 48px; } }
h2 { font-size: clamp(28px, 3.2vw, 40px); line-height: 1.15; letter-spacing: -0.015em; font-weight: 600; margin: 0 0 16px; }
h3 { font-size: 18px; font-weight: 600; margin: 0 0 8px; line-height: 1.35; }
.sub { color: var(--ink-2); margin: 0; font-size: 17px; }
.note { color: var(--muted); font-size: 14px; margin: 16px 0 0; max-width: 820px; }

/* Method */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); }
.grid-table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 760px; }
.grid-table th { text-align: left; font-weight: 600; font-size: 13px; color: var(--muted); padding: 14px 20px; border-bottom: 1px solid var(--rule-strong); background: #faf9f6; }
.grid-table td { padding: 16px 20px; border-bottom: 1px solid var(--rule); vertical-align: top; color: var(--ink-2); }
.grid-table td:first-child { color: var(--ink); font-weight: 500; width: 28%; }
.grid-table tr:last-child td { border-bottom: 0; }
.pipeline { list-style: none; padding: 0; margin: 24px 0 0; display: grid; grid-template-columns: repeat(6, 1fr); border: 1px solid var(--rule); background: var(--surface); counter-reset: step; }
.pipeline li { padding: 18px 16px; display: flex; flex-direction: column; gap: 4px; counter-increment: step; position: relative; }
.pipeline li + li { border-left: 1px solid var(--rule); }
.pipeline li::before { content: counter(step, decimal-leading-zero); font-family: var(--mono); font-size: 12px; color: var(--muted); }
.pipeline li b { font-weight: 600; font-size: 15px; }
.pipeline li span { font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.pipeline li.gate { background: #eef3ff; }
.pipeline li.gate::before { color: var(--accent); }
@media (max-width: 980px) { .pipeline { grid-template-columns: repeat(3, 1fr); } .pipeline li:nth-child(4) { border-left: 0; } .pipeline li:nth-child(n+4) { border-top: 1px solid var(--rule); } }
@media (max-width: 560px) { .pipeline { grid-template-columns: 1fr; } .pipeline li + li { border-left: 0; border-top: 1px solid var(--rule); } }

/* Cases */
.cases { display: flex; flex-direction: column; gap: 20px; }
.case { background: var(--surface); border: 1px solid var(--rule); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
@media (max-width: 900px) { .case { grid-template-columns: 1fr; } }
.case-main { padding: 28px; border-right: 1px solid var(--rule); display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 900px) { .case-main { border-right: 0; border-bottom: 1px solid var(--rule); } }
.case-tag { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.case h3 { font-size: 22px; margin: 0; }
.case-brief { color: var(--ink-2); font-size: 15.5px; margin: 0; }
.case-change { font-size: 15px; color: var(--ink-2); border-left: 3px solid var(--proposed); padding: 2px 0 2px 14px; margin: 0; }
.case-change b { color: var(--ink); }
.case-link { margin-top: auto; font-weight: 500; }
.case-side { padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.case-metrics { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--rule); }
.case-metrics div { padding: 12px 14px; }
.case-metrics div + div { border-left: 1px solid var(--rule); }
.case-metrics b { display: block; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.case-metrics span { font-size: 12.5px; color: var(--muted); line-height: 1.35; display: block; }
.case-side h4 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: none; }
.invariants { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14.5px; }
.invariants li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; color: var(--ink-2); }
.invariants li::before { content: '✓'; color: var(--passed); font-weight: 600; }
.case-review { font-size: 14px; color: var(--ink-2); background: #faf9f6; border: 1px solid var(--rule); padding: 12px 14px; margin: 0; }
.case-review b { color: var(--ink); }
.case-pending { padding: 28px; color: var(--muted); }

/* Video */
.video-frame { background: #0f1115; border: 1px solid var(--rule); aspect-ratio: 16 / 9; }
.video-frame video { width: 100%; height: 100%; display: block; }

/* Checker */
.checker { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; border: 1px solid var(--rule); background: var(--surface); }
@media (max-width: 860px) { .checker { grid-template-columns: 1fr; } }
.checker-controls { display: flex; flex-direction: column; border-right: 1px solid var(--rule); }
@media (max-width: 860px) { .checker-controls { border-right: 0; border-bottom: 1px solid var(--rule); } }
.toggle { text-align: left; font: inherit; color: var(--ink); background: none; border: 0; border-bottom: 1px solid var(--rule); padding: 18px 20px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; border-left: 3px solid transparent; }
.toggle span { font-weight: 600; }
.toggle code { align-self: flex-start; }
.toggle[aria-pressed="true"] { border-left-color: var(--accent); background: #f3f6ff; }
.toggle[data-variant="bug"][aria-pressed="true"] { border-left-color: var(--failed); background: #fdf3f1; }
.toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.checker-out { padding: 24px; display: flex; flex-direction: column; gap: 18px; min-height: 300px; }
.verdict { display: flex; gap: 12px; align-items: flex-start; font-weight: 600; font-size: 17px; }
.verdict .badge { font-family: var(--mono); font-size: 12px; font-weight: 500; padding: 3px 8px; flex: none; margin-top: 2px; }
.verdict .badge.ok { background: #e3f3ec; color: var(--passed); }
.verdict .badge.bad { background: #fbe5e1; color: var(--failed); }
.verdict small { display: block; font-weight: 400; color: var(--ink-2); font-size: 15px; margin-top: 4px; }
.trace { list-style: none; margin: 0; padding: 0; font-family: var(--mono); font-size: 13.5px; border: 1px solid var(--rule); }
.trace li { display: grid; grid-template-columns: 24px minmax(130px, auto) 1fr; gap: 12px; padding: 10px 14px; opacity: 0; transition: opacity .35s ease; }
.trace li + li { border-top: 1px solid var(--rule); }
.trace li.shown { opacity: 1; }
.trace .n { color: var(--muted); } .trace .act { color: var(--accent); } .trace .st-text { color: var(--ink-2); }
.trace li.boom { background: #fdf3f1; } .trace li.boom .st-text { color: var(--failed); }
.gauge { position: relative; height: 28px; background: #eeece6; margin-top: auto; }
.gauge-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--passed); transition: width .5s ease, background .3s; }
.gauge-fill.over { background: var(--failed); }
.gauge-limit { position: absolute; top: -6px; bottom: -6px; left: 75%; width: 2px; background: var(--ink); }
.gauge-limit span { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); font-family: var(--mono); font-size: 12px; white-space: nowrap; color: var(--ink); }

/* Problems */
.problems { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); background: var(--surface); }
.problems article { padding: 24px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.problems p { margin: 0 0 12px; color: var(--ink-2); font-size: 15px; }
.problems .fix { margin: 0; color: var(--ink); padding-top: 12px; border-top: 1px dashed var(--rule-strong); }
@media (max-width: 980px) { .problems { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .problems { grid-template-columns: 1fr; } }

/* Evidence */
.evidence { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 980px) { .evidence { grid-template-columns: 1fr; } }
.chart { margin: 0; background: var(--surface); border: 1px solid var(--rule); padding: 22px 24px; }
.chart figcaption { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.chart figcaption b { font-weight: 600; }
.legend { display: flex; gap: 8px; align-items: center; color: var(--ink-2); font-size: 14px; flex-wrap: wrap; }
.sw { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.sw.after { margin-left: 10px; }
.sw.before { background: var(--before); } .sw.after { background: var(--after); }
.dumbbell { position: relative; }
.db-row { display: grid; grid-template-columns: minmax(120px, 220px) 1fr 52px; align-items: center; gap: 12px; height: 30px; font-size: 13.5px; }
.db-row:hover { background: #faf9f6; }
.db-name { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-track { position: relative; height: 100%; }
.db-track::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--rule); }
.db-line { position: absolute; top: calc(50% - 1px); height: 2px; background: var(--rule-strong); }
.db-pt { position: absolute; top: 50%; width: 10px; height: 10px; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 2px var(--surface); }
.db-pt.before { background: var(--before); } .db-pt.after { background: var(--after); }
.db-val { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
.db-axis { display: grid; grid-template-columns: minmax(120px, 220px) 1fr 52px; gap: 12px; font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 6px; }
.db-axis div { position: relative; height: 14px; }
.db-axis span { position: absolute; transform: translateX(-50%); }
.db-tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); padding: 7px 10px; font-size: 13px; white-space: nowrap; z-index: 5; transform: translate(-50%, -115%); opacity: 0; transition: opacity .12s; }
.as-table { margin-top: 14px; font-size: 14px; }
.as-table summary { cursor: pointer; color: var(--accent); }
.as-table table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.as-table th, .as-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--rule); }
.as-table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .db-row, .db-axis { grid-template-columns: 96px 1fr 44px; } }
.evidence-side { display: flex; flex-direction: column; gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--rule); padding: 16px 20px; }
.kpi b { display: block; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 14px; }
.limits { border: 1px solid var(--rule); border-left: 3px solid var(--proposed); padding: 16px 20px; background: var(--surface); }
.limits h3 { font-size: 15px; }
.limits ul { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); display: flex; flex-direction: column; gap: 6px; }

/* Value */
.calc { display: grid; grid-template-columns: 1.4fr 1fr; border: 1px solid var(--rule); background: var(--surface); margin-bottom: 20px; }
@media (max-width: 860px) { .calc { grid-template-columns: 1fr; } }
.calc-in { padding: 24px; display: flex; flex-direction: column; gap: 18px; border-right: 1px solid var(--rule); }
@media (max-width: 860px) { .calc-in { border-right: 0; border-bottom: 1px solid var(--rule); } }
.calc-in label { display: grid; grid-template-columns: 1fr 110px; gap: 6px 16px; font-size: 15px; color: var(--ink-2); }
.calc-in input { grid-column: 1 / -1; accent-color: var(--accent); width: 100%; }
.calc-in output { grid-row: 1; grid-column: 2; text-align: right; font-family: var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.calc-out { padding: 28px; display: flex; flex-direction: column; justify-content: center; gap: 6px; background: #f3f6ff; }
.calc-out span { color: var(--ink-2); }
.calc-out b { font-size: clamp(32px, 3.6vw, 46px); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.calc-out small { color: var(--muted); font-size: 14px; }
.formats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); background: var(--surface); }
.formats article { padding: 24px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.formats p { margin: 0; color: var(--ink-2); font-size: 15px; }
@media (max-width: 900px) { .formats { grid-template-columns: 1fr; } }

/* Contact */
.contact { padding-bottom: 24px; }
.contact .wrap { border-top: 2px solid var(--ink); padding-top: 48px; }
.contact .sub { max-width: 640px; margin-bottom: 28px; }
.contact-links { display: flex; gap: 12px; flex-wrap: wrap; }
.foot { padding: 48px 0 40px; color: var(--muted); font-size: 13px; }

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