:root {
  color-scheme: light;
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --border: #e3e0d8;
  --text: #121212;
  --text-2: #4e4d49;
  --muted: #7a7872;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --s2: #2a78d6;   /* degree 2: blue   */
  --s4: #eb6834;   /* degree 4: orange */
  --s6: #1baf7a;   /* degree 6: aqua   */
  --s8: #eda100;   /* degree 8: yellow */
  --grid: #e9e6df;
  --bif-ink: 23, 52, 96;
  --hero-ink: 42, 120, 214;
  --hl: #ffe08a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0f12;
    --surface: #16171b;
    --surface-2: #1d1e23;
    --border: #2c2d33;
    --text: #f4f3ef;
    --text-2: #c3c2b7;
    --muted: #8d8c86;
    --accent: #6aa8f0;
    --accent-ink: #9cc6f6;
    --s2: #3987e5;
    --s4: #d95926;
    --s6: #199e70;
    --s8: #c98500;
    --grid: #26272c;
    --bif-ink: 160, 200, 255;
    --hero-ink: 90, 150, 235;
    --hl: #6b5310;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0f12; --surface: #16171b; --surface-2: #1d1e23; --border: #2c2d33;
  --text: #f4f3ef; --text-2: #c3c2b7; --muted: #8d8c86; --accent: #6aa8f0; --accent-ink: #9cc6f6;
  --s2: #3987e5; --s4: #d95926; --s6: #199e70; --s8: #c98500; --grid: #26272c;
  --bif-ink: 160, 200, 255; --hero-ink: 90, 150, 235; --hl: #6b5310;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.65 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.accent { color: var(--accent); }
.math { font-family: "Fraunces", Georgia, serif; font-style: italic; white-space: nowrap; }
.display-math { font-family: "Fraunces", Georgia, serif; font-size: 1.35rem; text-align: center; margin: 1.2rem 0; font-style: italic; }

/* hero */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--border); }
#hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.55; }
.hero-inner { position: relative; max-width: 1040px; margin: 0 auto; padding: 88px 24px 40px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.78rem; color: var(--muted); margin: 0 0 10px; }
h1 { font-family: "Fraunces", Georgia, serif; font-weight: 500; font-size: clamp(2.2rem, 5.5vw, 4rem); line-height: 1.05; margin: 0 0 20px; letter-spacing: -0.01em; }
.lede { font-size: 1.12rem; color: var(--text-2); max-width: 680px; margin: 0 0 28px; }
.digit-stream { display: flex; gap: 10px; align-items: baseline; font-size: 1.05rem; margin: 6px 0; white-space: nowrap; overflow: hidden; mask-image: linear-gradient(90deg, #000 75%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 75%, transparent); }
.digit-stream .sym { font-family: "Fraunces", serif; font-style: italic; color: var(--accent); min-width: 2.4em; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 34px 0 26px; }
.tile { background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(6px); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; }
.tile-num { font-family: "Fraunces", serif; font-size: 2.4rem; font-weight: 500; line-height: 1; margin-bottom: 8px; }
.tile-label { font-size: 0.92rem; color: var(--text-2); line-height: 1.45; }
.toc { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.92rem; }
.toc a { color: var(--text-2); }

/* sections */
main { max-width: 1040px; margin: 0 auto; padding: 0 24px; }
section { padding: 64px 0 24px; border-bottom: 1px solid var(--border); }
section:last-child { border-bottom: none; }
h2 { font-family: "Fraunces", serif; font-weight: 500; font-size: 2rem; margin: 0 0 14px; letter-spacing: -0.01em; }
h3 { font-family: "Fraunces", serif; font-weight: 500; font-size: 1.35rem; margin: 30px 0 10px; }
section > p { max-width: 760px; color: var(--text-2); }
.caption { font-size: 0.92rem; color: var(--text-2); max-width: 820px; }
ol.caption { padding-left: 1.3em; }
ol.caption li { margin: 0.3em 0; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 18px 0 12px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { background: var(--surface); color: var(--text-2); border: 0; padding: 7px 14px; font: 500 0.95rem Inter, sans-serif; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--accent); color: #fff; }
.btn { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 7px 14px; font: 500 0.92rem Inter, sans-serif; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.slider { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--text-2); }
.slider input { width: 150px; accent-color: var(--accent); }
select, input[type=search] { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; font: 0.92rem Inter, sans-serif; }
input[type=search] { min-width: 220px; }

.figure { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 8px; margin: 8px 0 10px; }
#bif { display: block; width: 100%; height: 520px; border-radius: 8px; cursor: crosshair; touch-action: none; }
.fig-note { position: absolute; right: 18px; bottom: 14px; font-size: 0.78rem; color: var(--muted); pointer-events: none; }
.tip { position: absolute; pointer-events: none; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; font-size: 0.82rem; color: var(--text); white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,0.15); }
.plot { width: 100%; height: 440px; }
.plot.short { height: 340px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
.cols p { color: var(--text-2); }

.table-wrap { overflow-x: auto; margin: 10px 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-weight: 600; color: var(--text-2); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td:first-child { white-space: nowrap; }
td .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: 0; }
.badge { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-ink); margin-left: 6px; }
.badge.new { background: color-mix(in srgb, var(--s6) 22%, transparent); color: var(--text); }

.digits { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; height: 420px; overflow: auto; font-size: 0.88rem; line-height: 1.75; color: var(--text-2); }
.digits .row { display: flex; gap: 14px; }
.digits .idx { color: var(--muted); min-width: 4.5em; text-align: right; user-select: none; }
.digits .grp { margin-right: 0.7em; }
.digits mark { background: var(--hl); color: var(--text); border-radius: 3px; }

footer { border-top: 1px solid var(--border); margin-top: 40px; background: var(--surface-2); }
.foot-cols { max-width: 1040px; margin: 0 auto; padding: 36px 24px 48px; display: grid; grid-template-columns: 2fr 1fr; gap: 32px; font-size: 0.88rem; color: var(--text-2); }
footer h4 { font-family: "Fraunces", serif; font-weight: 500; font-size: 1.1rem; margin: 0 0 10px; color: var(--text); }
footer ul { padding-left: 1.1em; margin: 0; }
footer li { margin: 0.35em 0; }

@media (max-width: 760px) {
  .hero-inner { padding: 56px 16px 28px; }
  main { padding: 0 16px; }
  .tiles { grid-template-columns: 1fr; }
  .cols, .foot-cols { grid-template-columns: 1fr; }
  #bif { height: 380px; }
  .plot { height: 360px; }
  .fig-note { display: none; }
  .digits .idx { display: none; }
}
