:root {
  color-scheme: light dark;
  --bg: #fbfaf6;
  --surface: #ffffff;
  --sunken: #f2f0e9;
  --ink: #1d2320;
  --muted: #5a635e;
  --line: #dfdcd2;
  --accent: #2350c8;
  --accent-ink: #ffffff;
  --bar-muted: #8b929b;
  --grid: #e6e3da;
  --serif: ui-serif, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111315;
    --surface: #181b1e;
    --sunken: #0c0e10;
    --ink: #e8eaec;
    --muted: #a3a9ae;
    --line: #2d3236;
    --accent: #7ea6ff;
    --accent-ink: #0b1020;
    --bar-muted: #6f7782;
    --grid: #2a2f33;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.6 var(--sans); }
a { color: var(--accent); text-underline-offset: 2px; }
img, video { display: block; max-width: 100%; height: auto; }
code { font: .88em var(--mono); background: var(--sunken); padding: .1em .3em; border-radius: 4px; overflow-wrap: anywhere; }
pre { background: var(--sunken); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow-x: auto; line-height: 1.45; }
pre code { background: none; padding: 0; font-size: 14px; overflow-wrap: normal; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 24px;
  padding: 10px max(16px, calc((100vw - 1080px) / 2));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font: 600 18px var(--serif); color: var(--ink); text-decoration: none; white-space: nowrap; }
.top nav { display: flex; gap: 18px; overflow-x: auto; scrollbar-width: none; white-space: nowrap; font-size: 15px; }
.top nav::-webkit-scrollbar { display: none; }
.top nav a { color: var(--muted); text-decoration: none; padding: 4px 0; }
.top nav a:hover { color: var(--ink); }

main { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
section { padding: 44px 0 8px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; }
h1 { font-size: clamp(30px, 4.4vw, 44px); margin: 8px 0 16px; letter-spacing: -.01em; }
h2 { font-size: 30px; margin: 0 0 14px; padding-top: 22px; border-top: 1px solid var(--line); }
h3 { font-size: 21px; margin: 32px 0 8px; }
p { max-width: 72ch; }
.eyebrow { margin: 0; font-size: 14px; letter-spacing: .04em; color: var(--muted); }
.lead { font-size: 19px; }
.note { font-size: 15px; color: var(--muted); }
.plain { padding-left: 20px; max-width: 72ch; }
.plain li { margin-bottom: 8px; }

.hero { padding-top: 40px; }
.hero p { max-width: 80ch; }
figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; max-width: 80ch; }
.links { display: flex; flex-wrap: wrap; gap: 10px; }
.button { padding: 8px 14px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-size: 15px; font-weight: 500; border: 1px solid var(--accent); }
.button.ghost { background: transparent; color: var(--accent); }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 32px 0 0; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.tile b { display: block; font: 600 30px/1.15 var(--serif); }
.tile span { display: block; font-size: 14px; color: var(--muted); line-height: 1.35; margin-top: 4px; }

.wide { display: block; margin: 20px 0; }
.wide img { width: 100%; }
.video video { width: 100%; border-radius: 10px; background: #000; }
.fig img { background: #ffffff; padding: 10px; border-radius: 10px; border: 1px solid var(--line); }
.fig.narrow img { max-width: 560px; }

.columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.columns h3 { margin-top: 8px; font-size: 19px; }
.columns p { font-size: 16px; }

.palette { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; max-width: 720px; margin: 16px 0 6px; }
.palette span { aspect-ratio: 1; border-radius: 3px; background: #000; }
.idea { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }

.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin: 16px 0; }
table { border-collapse: collapse; width: 100%; font-size: 15px; line-height: 1.4; }
th, td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-weight: 600; background: var(--sunken); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.strong td { font-weight: 600; }

.chart { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 8px; max-width: 620px; margin: 20px 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis text, .chart .lab { fill: var(--muted); font: 13px var(--sans); }
.chart .val { fill: var(--ink); font: 600 14px var(--sans); }
.chart .glab { fill: var(--ink); font: 14px var(--sans); }
.chart .b0 { fill: var(--bar-muted); }
.chart .b1 { fill: var(--accent); }
.chart g.bar:hover path { opacity: .82; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; color: var(--muted); margin: 0 0 4px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .k0 { background: var(--bar-muted); } .legend .k1 { background: var(--accent); }

footer { max-width: 1080px; margin: 40px auto 0; padding: 16px 16px 32px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }

@media (max-width: 860px) {
  body { font-size: 16px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .columns, .idea { grid-template-columns: 1fr; gap: 4px; }
  .top { gap: 14px; }
  .palette { grid-template-columns: repeat(16, 1fr); }
}
@media (max-width: 640px) {
  .brand { display: none; }
  .top nav { -webkit-mask-image: linear-gradient(to right, #000 88%, transparent); mask-image: linear-gradient(to right, #000 88%, transparent); padding-right: 28px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
