:root {
  color-scheme: light;
  --paper: #f7f6f1;
  --paper-2: #efede6;
  --ink: #171b1f;
  --muted: #626b70;
  --line: #d8d5cc;
  --line-strong: #aaa79f;
  --panel: rgba(255,255,255,.66);
  --static: #667080;
  --dynamic: #e55b31;
  --state: #207a77;
  --write: #7654a8;
  --motion: #df9b27;
  --rglru: #9a4c75;
  --shadow: 0 18px 55px rgba(25, 27, 29, .08);
  --sans: Inter, "Noto Sans SC", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111516;
  --paper-2: #171d1e;
  --ink: #ecf0ed;
  --muted: #a6b0ad;
  --line: #303839;
  --line-strong: #596463;
  --panel: rgba(23,29,30,.75);
  --static: #96a3b3;
  --dynamic: #ff7a50;
  --state: #42bbb5;
  --write: #b28ae7;
  --motion: #f2b84a;
  --rglru: #dc82b1;
  --shadow: 0 20px 60px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 104px; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.72 var(--sans); text-rendering: optimizeLegibility; }
button, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-underline-offset: .2em; }
img, canvas, svg { max-width: 100%; }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.035em; line-height: 1.14; }
h1 { font-size: clamp(2.8rem, 5.2vw, 5.8rem); font-weight: 600; }
h2 { font-size: clamp(1.9rem, 3vw, 3.3rem); font-weight: 600; }
h3 { font-size: 1.42rem; font-weight: 600; }
code, pre, .mono { font-family: var(--mono); }
pre { overflow: auto; padding: 1rem; background: var(--paper-2); border: 1px solid var(--line); font-size: .79rem; line-height: 1.55; }
::selection { background: color-mix(in srgb, var(--dynamic) 24%, transparent); }

.skip-link { position: fixed; z-index: 100; left: 1rem; top: -5rem; padding: .65rem 1rem; background: var(--ink); color: var(--paper); }
.skip-link:focus { top: 1rem; }
.topbar { position: sticky; top: 0; z-index: 40; height: 64px; display: grid; grid-template-columns: 220px 1fr 42px; align-items: center; gap: 1rem; padding: 0 clamp(1rem, 3vw, 3rem); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: blur(16px); }
.brand { display: inline-flex; gap: .7rem; align-items: center; font-weight: 700; text-decoration: none; letter-spacing: -.02em; }
.brand-mark { width: 27px; height: 27px; display: grid; place-items: center; border: 1.5px solid var(--ink); border-radius: 50%; font: 600 .8rem var(--mono); }
.topbar nav { display: flex; justify-content: center; gap: clamp(.7rem, 2.4vw, 2.4rem); }
.topbar nav a { text-decoration: none; color: var(--muted); font-size: .82rem; font-weight: 600; }
.topbar nav a:hover, .topbar nav a:focus-visible { color: var(--ink); }
.theme-toggle { border: 0; background: none; color: var(--ink); cursor: pointer; font-size: 1.15rem; }

.button, button { border: 1px solid var(--line-strong); background: transparent; color: var(--ink); padding: .58rem .9rem; cursor: pointer; text-decoration: none; transition: background .18s, color .18s, border .18s, transform .18s; }
.button:hover, button:hover { border-color: var(--ink); transform: translateY(-1px); }
.button.primary, button.primary { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.text-link { font-size: .88rem; color: var(--muted); }
select { border: 0; border-bottom: 1px solid var(--line-strong); padding: .4rem 1.7rem .4rem .25rem; background: transparent; color: var(--ink); }

.evidence { display: inline-flex; align-items: center; width: max-content; padding: .2rem .42rem; border: 1px solid currentColor; font: 600 .64rem/1.2 var(--mono); letter-spacing: .02em; }
.evidence.measured { color: var(--state); }
.evidence.verified { color: #245daf; }
.evidence.paper { color: var(--static); }
.evidence.derived { color: #a17113; }
.evidence.proposed { color: var(--write); }
.evidence.hypothesis { color: var(--dynamic); }
.part-label, .eyebrow, .aside-title, .context-label, .figure-number, .code-label { font: 600 .7rem/1.3 var(--mono); letter-spacing: .04em; color: var(--muted); }
.figure-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.figure-head h2, .figure-head h3 { margin: .15rem 0 0; }
.transport { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.transport button, .transport select { font: 500 .76rem var(--mono); min-height: 34px; }
.transport .play { min-width: 70px; }
.var { font-family: var(--mono); white-space: nowrap; }
.var.dynamic { color: var(--dynamic); }
.tooltip { position: fixed; z-index: 80; max-width: 270px; padding: .55rem .7rem; background: var(--ink); color: var(--paper); border-radius: 3px; font: .74rem/1.5 var(--mono); pointer-events: none; box-shadow: var(--shadow); }

footer { min-height: 130px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 2rem clamp(1.2rem, 5vw, 5rem); border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
footer p { margin: 0; }

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr 40px; }
  .topbar nav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
