/* treecode.ai — shared styles. Tokens match the results board so the three pages read as one site. */
@font-face { font-family: "TeX Gyre Pagella"; src: url(/assets/fonts/pagella-regular.woff) format("woff"); font-weight: 400; font-style: normal; font-display: swap }
@font-face { font-family: "TeX Gyre Pagella"; src: url(/assets/fonts/pagella-italic.woff) format("woff"); font-weight: 400; font-style: italic; font-display: swap }
@font-face { font-family: "TeX Gyre Pagella"; src: url(/assets/fonts/pagella-bold.woff) format("woff"); font-weight: 700; font-style: normal; font-display: swap }
@font-face { font-family: "TeX Gyre Pagella"; src: url(/assets/fonts/pagella-bolditalic.woff) format("woff"); font-weight: 700; font-style: italic; font-display: swap }
@font-face { font-family: "Latin Modern Math"; src: url(/assets/fonts/latinmodern-math.woff) format("woff"); font-weight: 400; font-style: normal; font-display: swap }

:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #eef1f5; --fg: #151a21; --fg-2: #4d5868; --muted: #7d8794;
  --grid: #e2e6ec; --axis: #c2c9d3; --ring: rgba(21,26,33,0.10); --plate: #ffffff;
  --accent: #2a78d6; --accent-ink: #1c5cab; --accent-soft: rgba(42,120,214,0.10);
  --chain: #c8382f; --good: #0ca30c; --warn: #b7791f;
  --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-serif: "TeX Gyre Pagella", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --font-math: "Latin Modern Math", "STIX Two Math", "Cambria Math", "Noto Sans Math", math;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0f1217; --surface: #161b22; --surface-2: #1f2630; --fg: #edf1f6; --fg-2: #b4bcc8; --muted: #8b95a3;
  --grid: #28303b; --axis: #3a4350; --ring: rgba(255,255,255,0.10); --plate: #f7f8fa;
  --accent: #3987e5; --accent-ink: #86b6ef; --accent-soft: rgba(57,135,229,0.16);
  --chain: #e05a4f; --good: #3dbb3d; --warn: #d9a441; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0f1217; --surface: #161b22; --surface-2: #1f2630; --fg: #edf1f6; --fg-2: #b4bcc8; --muted: #8b95a3;
  --grid: #28303b; --axis: #3a4350; --ring: rgba(255,255,255,0.10); --plate: #f7f8fa;
  --accent: #3987e5; --accent-ink: #86b6ef; --accent-soft: rgba(57,135,229,0.16);
  --chain: #e05a4f; --good: #3dbb3d; --warn: #d9a441; color-scheme: dark }

* { box-sizing: border-box }
html { -webkit-text-size-adjust: 100% }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 16px; line-height: 1.5 }
img, svg { max-width: 100% }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 2px }
code, .num { font-family: var(--font-num); font-variant-numeric: tabular-nums }
code { font-size: 0.92em }
h1, h2, h3 { text-wrap: balance; margin: 0 }
.serif { font-family: var(--font-serif) }
.eyebrow { font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); font-weight: 600 }
.muted { color: var(--muted) }
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: 20px }

/* ---------- site navigation ---------- */
.nav { border-bottom: 1px solid var(--ring); background: var(--surface) }
.nav .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; flex-wrap: wrap; padding-block: 8px }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-family: var(--font-serif); font-size: 22px; letter-spacing: 0.005em }
.brand svg { width: 26px; height: 26px; display: block }
.brand .org { font-family: var(--font-ui); font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-left: 2px; align-self: flex-end; padding-bottom: 4px }
.navlinks { display: flex; gap: 4px 18px; flex-wrap: wrap; font-size: 14px }
.navlinks a { color: var(--fg-2); text-decoration: none; padding: 6px 0; border-bottom: 2px solid transparent }
.navlinks a:hover { color: var(--fg) }
.navlinks a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent) }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--ring); margin-top: 72px; padding-block: 28px 40px; font-size: 13px; color: var(--fg-2) }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 10px 32px; justify-content: space-between; align-items: baseline }
.foot a { color: var(--fg-2) }

/* ---------- figure plates (TikZ exports are drawn for a white page; keep them on one in both themes) ---------- */
.plate { background: var(--plate); border: 1px solid var(--ring); border-radius: 8px; padding: 14px 16px; min-width: 0 }
.plate img { display: block; width: 100%; height: auto; margin: 0 auto }
figure { margin: 28px 0 }
figcaption { font-size: 13.5px; line-height: 1.5; color: var(--fg-2); margin-top: 10px; max-width: 78ch }
figcaption strong, figcaption .fignum { color: var(--fg); font-weight: 600 }

/* ---------- MathML ---------- */
math { font-family: var(--font-math); font-size: 1.04em }
math[display="block"] { margin: 14px 0; overflow-x: auto; overflow-y: hidden; max-width: 100% }
menclose[notation="box"], .boxed { padding: 2px 6px; border: 1px solid currentColor; border-radius: 3px }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 7px; font-size: 14px; font-weight: 500; text-decoration: none; border: 1px solid var(--ring); background: var(--surface); color: var(--fg); white-space: nowrap }
.btn:hover { border-color: var(--axis) }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink) }
.btn svg { width: 15px; height: 15px }

/* ---------- landing page ---------- */
.hero { padding-block: 56px 28px }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 36px 56px; align-items: center }
.hero h1 { font-family: var(--font-serif); font-weight: 400; font-size: clamp(32px, 4.6vw, 50px); line-height: 1.12; letter-spacing: -0.012em; margin: 14px 0 20px }
.hero h1 em { font-style: italic; color: var(--accent-ink) }
.hero .lede { font-size: 17.5px; line-height: 1.55; color: var(--fg-2); max-width: 62ch; margin: 0 }
.hero .lede b { color: var(--fg); font-weight: 600 }
.cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 26px }
.hero .plate { padding: 18px }
.hero .plate figcaption { font-size: 12.5px }

section.block { padding-block: 44px }
section.block + section.block { border-top: 1px solid var(--ring) }
.block h2 { font-family: var(--font-serif); font-weight: 400; font-size: clamp(26px, 3vw, 34px); line-height: 1.18; letter-spacing: -0.01em; margin: 8px 0 14px }
.block .intro { font-size: 16.5px; color: var(--fg-2); max-width: 66ch; margin: 0 0 10px }
.block p { max-width: 66ch; color: var(--fg-2); margin: 10px 0 }
.block p b { color: var(--fg); font-weight: 600 }
.split { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 6fr); gap: 28px 48px; align-items: start }
.split.rev > .text { order: 2 } .split.rev > .plate { order: 1 }

.formula { background: var(--surface); border: 1px solid var(--ring); border-radius: 8px; padding: 18px 20px; margin: 18px 0; display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: center; justify-content: space-between }
.formula math { font-size: 1.55em }
.formula .label { font-size: 12px; color: var(--muted); max-width: 26ch; line-height: 1.4 }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px }
.chip { display: inline-flex; align-items: baseline; gap: 8px; border: 1px solid var(--ring); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; color: var(--fg-2) }
.chip .num { color: var(--fg); font-weight: 500 }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-top: 22px }
.tile { background: var(--surface); border: 1px solid var(--ring); border-radius: 8px; padding: 16px 18px; min-width: 0; display: flex; flex-direction: column; gap: 6px }
.tile .label { font-size: 12.5px; color: var(--muted); line-height: 1.35 }
.tile .value { font-family: var(--font-num); font-size: 30px; font-weight: 500; line-height: 1.1; color: var(--fg); margin-top: 4px; letter-spacing: -0.01em }
.tile .value small { font-size: 15px; color: var(--muted); font-weight: 400; margin-left: 2px }
.tile .from { font-family: var(--font-num); font-size: 12.5px; color: var(--fg-2) }
.tile .from .arrow { color: var(--muted); margin: 0 4px }
.tile .sub { font-size: 12.5px; color: var(--fg-2); line-height: 1.4; margin-top: auto; padding-top: 4px }
.tile.verdict .value { font-family: var(--font-serif); font-size: 24px; font-weight: 400; line-height: 1.2 }
.tile .tag { display: inline-block; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); border-radius: 4px; padding: 2px 7px; width: max-content }

.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 14px 28px; margin-top: 22px }
.rule { border-top: 2px solid var(--accent); padding-top: 12px; min-width: 0 }
.rule h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px }
.rule p { font-size: 14.5px; margin: 0 }

.timeline { list-style: none; margin: 24px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 14px }
.timeline li { background: var(--surface); border: 1px solid var(--ring); border-radius: 8px; padding: 14px 16px; min-width: 0; display: flex; flex-direction: column; gap: 6px; position: relative }
.timeline .id { font-family: var(--font-num); font-size: 12px; color: var(--muted) }
.timeline .title { font-weight: 600; font-size: 15px; line-height: 1.3 }
.timeline .when { font-size: 12.5px; color: var(--fg-2) }
.timeline .note { font-size: 13px; color: var(--fg-2); line-height: 1.45 }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; color: var(--muted); width: max-content }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--axis) }
.status.done { color: var(--good) } .status.done::before { background: var(--good) }
.status.first { color: var(--accent-ink) } .status.first::before { background: var(--accent) }

.apps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 14px; margin-top: 22px }
.app { background: var(--surface); border: 1px solid var(--ring); border-radius: 8px; padding: 18px 20px; min-width: 0 }
.app .n { font-family: var(--font-num); font-size: 12px; color: var(--muted) }
.app h3 { font-size: 17px; font-weight: 600; margin: 6px 0 8px }
.app p { font-size: 14.5px; margin: 0 }
.app .who { margin-top: 10px; font-size: 13px; color: var(--muted) }

@media (max-width: 860px) {
  .hero .wrap, .split { grid-template-columns: 1fr }
  .split.rev > .text, .split.rev > .plate { order: initial }
  .hero { padding-block: 36px 20px }
  .formula math { font-size: 1.3em }
}

/* ---------- primer page ---------- */
.doc { max-width: 1120px; margin: 0 auto; padding-inline: 20px; display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 0 48px; align-items: start }
.doc-head { grid-column: 1 / -1; padding-block: 40px 18px; border-bottom: 1px solid var(--ring); margin-bottom: 8px }
.doc-head h1 { font-family: var(--font-serif); font-weight: 400; font-size: clamp(30px, 4vw, 44px); line-height: 1.15; letter-spacing: -0.01em; margin: 10px 0 10px }
.doc-head .byline { font-size: 14px; color: var(--fg-2) }
.doc-head .byline span + span::before { content: " · "; color: var(--muted) }
.doc-head .companion { font-family: var(--font-serif); font-style: italic; font-size: 16px; color: var(--fg-2); max-width: 78ch; margin-top: 10px }
.doc-head .cta { margin-top: 18px }
.toc { position: sticky; top: 16px; font-size: 13px; padding-top: 28px; max-height: calc(100vh - 32px); overflow: auto }
.toc .eyebrow { margin-bottom: 8px }
.toc ol { list-style: none; margin: 0; padding: 0 }
.toc li { margin: 0; padding: 0 }
.toc a { display: block; color: var(--fg-2); text-decoration: none; padding: 4px 0 4px 10px; border-left: 2px solid var(--grid); line-height: 1.35 }
.toc a:hover { color: var(--fg); border-left-color: var(--axis) }
.toc .n { font-family: var(--font-num); color: var(--muted); font-size: 11.5px; margin-right: 6px }
.article { font-family: var(--font-serif); font-size: 18px; line-height: 1.58; padding-block: 24px 20px; min-width: 0; counter-reset: sec app }
.article > p, .article li, .article .derivation p, .article .plain p { max-width: 68ch }
.article p { margin: 0 0 14px }
.article h1 { font-family: var(--font-serif); font-weight: 700; font-size: 26px; line-height: 1.25; margin: 44px 0 12px; counter-increment: sec }
.article h1::before { content: counter(sec) ".\2002"; color: var(--muted); font-weight: 400 }
.article h1.appendix { counter-increment: app }
.article h1.appendix::before { content: "Appendix " counter(app, upper-alpha) ".\2002" }
.article h2 { font-family: var(--font-serif); font-weight: 700; font-size: 19.5px; margin: 26px 0 8px }
.article em { font-style: italic }
.article strong { font-weight: 700 }
.article code { font-family: var(--font-num); font-size: 0.82em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px }
.article ol, .article ul { padding-left: 1.4em; margin: 0 0 14px }
.article li { margin-bottom: 6px }
.article li::marker { color: var(--muted) }
.article .derivation, .article .plain { border: 1px solid var(--ring); border-radius: 8px; padding: 16px 20px 6px; margin: 22px 0; background: var(--surface); max-width: none }
.article .derivation > p:first-child { font-family: var(--font-ui); font-size: 13px; letter-spacing: 0.02em; color: var(--accent-ink); margin-bottom: 10px }
.article .derivation > p:first-child strong { font-weight: 600 }
.article .plain { border-color: var(--chain); background: color-mix(in srgb, var(--chain) 5%, var(--surface)) }
.article figure { margin: 26px 0 }
.article figure img { display: block; width: 100%; height: auto; margin: 0 auto }
.article figure img[data-w] { width: var(--w, 100%) }
.article figcaption { font-family: var(--font-ui); font-size: 13.5px; max-width: none }
.article .table-wrap { overflow-x: auto; margin: 10px 0 18px }
.article table { border-collapse: collapse; font-family: var(--font-ui); font-size: 14px; line-height: 1.4; min-width: 100% }
.article th, .article td { text-align: left; padding: 7px 12px 7px 0; border-bottom: 1px solid var(--grid); vertical-align: top }
.article th { font-weight: 600; color: var(--fg); border-bottom: 1px solid var(--axis) }
.article td { color: var(--fg-2) }
.article .lead-in { font-family: var(--font-ui); font-size: 15.5px; line-height: 1.55; color: var(--fg-2); border-left: 3px solid var(--accent); padding: 4px 0 4px 16px; margin: 10px 0 20px }
.article .lead-in strong { color: var(--fg); font-weight: 600 }
.article hr { border: 0; border-top: 1px solid var(--ring); margin: 28px 0 }
.article .endnote { font-family: var(--font-ui); font-size: 13.5px; color: var(--fg-2) }
.article .endnote p { max-width: none }
@media (max-width: 900px) {
  .doc { grid-template-columns: 1fr }
  .article { order: 2 }
  .toc { order: 1; position: static; max-height: none; padding-top: 10px; border-bottom: 1px solid var(--ring); padding-bottom: 14px }
  .toc ol { columns: 2; column-gap: 24px }
  .article { font-size: 17px }
}

/* verdict callout under the tiles */
.verdict { margin-top: 14px; background: var(--surface); border: 1px solid var(--ring); border-left: 3px solid var(--accent); border-radius: 8px; padding: 16px 20px 14px }
.verdict .tag { display: inline-block; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); border-radius: 4px; padding: 2px 7px }
.verdict .headline { font-family: var(--font-serif); font-size: 22px; line-height: 1.3; color: var(--fg); margin: 10px 0 8px; max-width: 60ch }
.verdict p { max-width: 90ch; font-size: 15px }
.tiles { align-items: stretch }
.tile .sub { margin-top: 2px; padding-top: 0 }

.article figure .plate { padding: 12px 14px }
.article figure .plate img { max-width: 100% }
