:root {
  --bg: #fbf8f3;
  --bg-2: #f4efe7;
  --text: #3d3731;
  --strong: #1f1b17;
  --muted: #7a7166;
  --faint: #a39a8e;
  --line: #ebe4d9;
  --line-2: #d9d0c3;
  --accent: #c8642f;
  --accent-ink: #b0531f;
  --accent-soft: #f7e9df;
  --code-bg: #f2ece3;
  --todo-bg: #fbefc9;
  --todo-text: #7a5a06;
  --head: 'Lora', Georgia, serif;
  --sans: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --col: 640px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1714; --bg-2: #221e1a; --text: #cfc6b8; --strong: #f1eadf; --muted: #9a9083; --faint: #6f675d;
    --line: #2c2722; --line-2: #3d362f; --accent: #e3895b; --accent-ink: #eb9a70; --accent-soft: #2f241d;
    --code-bg: #26211d; --todo-bg: #3a3018; --todo-text: #eccf7c; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1714; --bg-2: #221e1a; --text: #cfc6b8; --strong: #f1eadf; --muted: #9a9083; --faint: #6f675d;
  --line: #2c2722; --line-2: #3d362f; --accent: #e3895b; --accent-ink: #eb9a70; --accent-soft: #2f241d;
  --code-bg: #26211d; --todo-bg: #3a3018; --todo-text: #eccf7c; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 18px/1.85 var(--sans); letter-spacing: .002em;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: hidden;
}
a { color: var(--accent-ink); text-decoration: none; }
::selection { background: var(--accent-soft); }
strong, b { font-weight: 600; color: var(--strong); }

/* ---------- chrome ---------- */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); z-index: 60; opacity: .8; }
.top {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 max(20px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.brand { font: 500 17px/1 var(--head); color: var(--strong); letter-spacing: -.01em; }
.brand span { color: var(--accent); margin: 0 .35em; }
.top-actions { display: flex; gap: 2px; }
.icon-btn { display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--bg-2); color: var(--strong); }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 88vw); z-index: 55; background: var(--bg);
  transform: translateX(100%); transition: transform .3s cubic-bezier(.2, .7, .2, 1); overflow-y: auto; padding: 28px 16px 32px;
  box-shadow: -20px 0 60px rgba(0, 0, 0, .08);
}
.drawer.open { transform: none; }
.drawer-h { font: 500 13px var(--sans); color: var(--faint); padding: 0 14px 14px; }
.drawer-inner a { display: flex; gap: 14px; align-items: baseline; padding: 11px 14px; border-radius: 12px; color: var(--text); font-size: 16px; line-height: 1.4; }
.drawer-inner a:hover { background: var(--bg-2); }
.drawer-inner a.active { color: var(--accent-ink); background: var(--accent-soft); }
.n { font: 400 12px/1 var(--mono); color: var(--faint); min-width: 20px; }
.active .n { color: var(--accent); }
.scrim { position: fixed; inset: 0; background: rgba(20, 15, 10, .28); opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 50; }
.scrim.open { opacity: 1; pointer-events: auto; }

/* ---------- layout: one centered column, toc floats in the left margin ---------- */
.page { display: grid; grid-template-columns: 1fr min(var(--col), calc(100% - 40px)) 1fr; padding: 24px 0 40px; }
.article { grid-column: 2; min-width: 0; }
.side { grid-column: 1; grid-row: 1; justify-self: end; width: 230px; margin-right: 56px; display: none; }
@media (min-width: 1240px) { .side { display: block; } .toc-mobile { display: none; } }
.side .toc { position: sticky; top: 96px; max-height: calc(100vh - 120px); overflow-y: auto; }

/* ---------- headers ---------- */
.head { margin: 8px 0 44px; }
.figure { margin: 0 -8px 28px; }
.ill { display: block; width: 100%; height: auto; max-height: 150px; }
.ill .m { stroke: var(--line-2); }
.ill .a { stroke: var(--accent); }
.ill .fill.a { fill: var(--accent); }
.ill .fill2.m { fill: var(--line-2); }
.ill .soft.a { fill: var(--accent-soft); }
.ill .bgfill { fill: var(--bg); }
.eyebrow { font: 500 13.5px/1.4 var(--sans); color: var(--faint); margin-bottom: 14px; }
.eyebrow span { color: var(--accent); margin: 0 .3em; }
.title { font: 500 clamp(32px, 6.4vw, 46px)/1.18 var(--head); color: var(--strong); letter-spacing: -.02em; margin: 0 0 18px; text-wrap: balance; }
.lede { font: italic 400 clamp(19px, 2.6vw, 21px)/1.65 var(--head); color: var(--muted); margin: 0; text-wrap: pretty; }

/* ---------- stats ---------- */
.stats { display: grid; gap: 28px; margin: 0 0 48px; padding: 28px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--muted); }
.stat-g { color: var(--accent-ink); font-weight: 500; }
.stat-n { font: 500 15px var(--sans); color: var(--faint); margin: 2px 0 10px; }
.stat-n b { font: 500 38px/1.1 var(--head); color: var(--strong); letter-spacing: -.02em; }
.stat-n span { margin-left: 10px; text-decoration: line-through; text-decoration-color: var(--line-2); }
.bar { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 6px; background: var(--accent); }

/* ---------- toc ---------- */
.toc { font-size: 14.5px; line-height: 1.45; }
.toc-h { font-size: 13px; color: var(--faint); margin-bottom: 12px; }
.toc a { display: block; padding: 7px 0 7px 14px; color: var(--muted); border-left: 1.5px solid var(--line); transition: color .15s, border-color .15s; }
.toc a:hover { color: var(--strong); }
.toc a.on { color: var(--accent-ink); border-left-color: var(--accent); }
.toc code { font-size: 12px; background: none; padding: 0; }
.toc-mobile { margin: 0 0 48px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.toc-mobile summary { cursor: pointer; padding: 16px 0; font-weight: 500; color: var(--strong); list-style: none; display: flex; justify-content: space-between; align-items: baseline; }
.toc-mobile summary span { font-weight: 400; font-size: 14px; color: var(--faint); }
.toc-mobile summary::-webkit-details-marker { display: none; }
.toc-mobile .toc { padding: 0 0 18px; }

/* ---------- prose ---------- */
.prose { overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose dl { margin: 0 0 1.35em; }
.prose h2 { font: 500 clamp(25px, 4.4vw, 30px)/1.3 var(--head); color: var(--strong); letter-spacing: -.015em; margin: 2.8em 0 .9em; text-wrap: balance; }
.prose h2::before { content: ''; display: block; width: 28px; height: 2px; border-radius: 2px; background: var(--accent); margin-bottom: 22px; }
.prose h3 { font: 600 19px/1.45 var(--sans); color: var(--strong); margin: 2.2em 0 .6em; }
.prose h4 { font: 600 16px/1.45 var(--sans); color: var(--strong); margin: 1.8em 0 .5em; }
.prose ul, .prose ol { padding-left: 1.25em; }
.prose li { margin: .55em 0; padding-left: .2em; }
.prose li::marker { color: var(--accent); }
.prose ol li::marker { font: 500 .9em var(--sans); }
.prose li.dont { list-style: none; position: relative; }
.prose li.dont::before { content: '✕'; position: absolute; left: -1.25em; color: var(--accent); font-size: 13px; top: .35em; }
.prose hr { border: 0; margin: 3.2em 0; text-align: center; height: 1em; }
.prose hr::after { content: '· · ·'; color: var(--faint); letter-spacing: .6em; }
.prose blockquote {
  margin: 1.8em 0; padding: 4px 0 4px 26px; border-left: 2px solid var(--accent);
  font: italic 400 19.5px/1.75 var(--head); color: var(--strong);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose blockquote strong { font-weight: 600; }
.prose blockquote code { font-style: normal; }
code { font: 400 .84em/1.5 var(--mono); background: var(--code-bg); color: var(--strong); padding: .14em .4em; border-radius: 6px; overflow-wrap: anywhere; }
pre { background: var(--code-bg); padding: 18px 20px; border-radius: 14px; overflow-x: auto; font-size: 14.5px; line-height: 1.6; margin: 0 0 1.4em; }
pre code { background: none; padding: 0; overflow-wrap: normal; }
.xref { font-weight: 500; border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.xref::after { content: ' →'; }
mark.todo { background: var(--todo-bg); color: var(--todo-text); font-size: .82em; font-weight: 500; padding: .2em .6em; border-radius: 999px; }

/* definition lists ("**Label:** text" blocks) */
.facts { display: grid; gap: 0; }
.facts > div { display: grid; grid-template-columns: 9.5em 1fr; gap: 4px 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.facts > div:first-child { border-top: 1px solid var(--line); }
.facts dt { font-size: 14.5px; color: var(--muted); padding-top: .15em; }
.facts dd { margin: 0; }
.facts .note dd { grid-column: 1 / -1; }
@media (max-width: 600px) { .facts > div { grid-template-columns: 1fr; } .facts dt { padding: 0; } }

/* dense tables → stacked entries */
.stack { margin: 1.8em 0 2em; border-top: 1px solid var(--line); }
.entry { padding: 20px 0 6px; border-bottom: 1px solid var(--line); }
.entry-k { font-weight: 600; color: var(--strong); margin-bottom: 6px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.entry p { margin: 0 0 14px; }
.lbl { display: block; font-size: 13px; color: var(--faint); font-weight: 400; line-height: 1.4; margin-bottom: 2px; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 14px; font-weight: 500; color: var(--accent-ink); background: var(--accent-soft); padding: 1px 10px; border-radius: 999px; line-height: 1.7; }
.chip .lbl { display: none; }

/* transposed comparison → one block per column */
.compare { display: grid; gap: 20px; margin: 1.8em 0 2.2em; }
.compare section { background: var(--bg-2); border-radius: 18px; padding: 22px 24px 8px; }
.compare h4 { font: 500 21px/1.3 var(--head) !important; margin: 0 0 12px !important; color: var(--strong); }
.compare dl { margin: 0; }
.compare dl > div { padding: 10px 0 12px; border-top: 1px solid var(--line-2); }
.compare dt { font-size: 13px; color: var(--faint); }
.compare dd { margin: 0; font-size: 16.5px; line-height: 1.7; }

/* plain (short) tables */
.table-wrap { overflow-x: auto; margin: 1.8em 0 2em; -webkit-overflow-scrolling: touch; }
.prose table { border-collapse: collapse; width: 100%; font-size: 15.5px; line-height: 1.6; }
.prose th, .prose td { padding: 11px 16px 11px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.prose th { font-weight: 500; color: var(--faint); font-size: 13.5px; white-space: nowrap; border-bottom-color: var(--line-2); }
.prose td:first-child { color: var(--strong); }
.prose td[align="right"], .prose th[align="right"] { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- pager ---------- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 80px; padding-top: 28px; border-top: 1px solid var(--line); }
.pager a { display: flex; flex-direction: column; gap: 4px; color: var(--strong); }
.pager small { color: var(--faint); font-size: 13px; }
.pager span { font: 500 18px/1.35 var(--head); }
.pager a:hover span { color: var(--accent-ink); }
.pager .prev small::before { content: '← '; }
.pager .next { text-align: right; }
.pager .next small::after { content: ' →'; }

/* ---------- home ---------- */
.home { width: min(var(--col), calc(100% - 40px)); margin: 0 auto; padding: 24px 0 24px; }
.home .title { font-size: clamp(34px, 7.4vw, 52px); }
.when { display: flex; flex-wrap: wrap; gap: 14px 48px; padding: 22px 0; margin: 40px 0 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.when small, .bignums span { display: block; font-size: 13.5px; color: var(--faint); line-height: 1.45; }
.when b { font: 500 19px/1.4 var(--head); }
#countdown { color: var(--accent-ink); }
.bignums { display: grid; grid-template-columns: 1fr 1fr; gap: 28px 24px; margin: 40px 0 64px; }
@media (min-width: 620px) { .bignums { grid-template-columns: repeat(4, 1fr); } }
.bignums b { display: block; font: 500 34px/1.1 var(--head); color: var(--strong); letter-spacing: -.02em; margin-bottom: 6px; }
.bignums div:first-child b { color: var(--accent); }
.group { margin: 0 0 56px; }
.group-h { font: 500 13.5px/1 var(--sans); color: var(--faint); margin: 0 0 8px; }
.item { display: grid; grid-template-columns: 32px 1fr auto; gap: 14px; align-items: baseline; padding: 20px 0; border-bottom: 1px solid var(--line); color: var(--text); }
.item:last-child { border-bottom: 0; }
.item-b { display: flex; flex-direction: column; gap: 4px; }
.item-t { font: 500 21px/1.3 var(--head); color: var(--strong); transition: color .15s; }
.item-d { font-size: 15.5px; line-height: 1.55; color: var(--muted); }
.item-arr { color: var(--faint); transition: transform .2s, color .2s; }
.item:hover .item-t, .item:hover .item-arr { color: var(--accent-ink); }
.item:hover .item-arr { transform: translateX(4px); }
.quick { margin: 0 0 64px; }
.quick-list { display: flex; flex-direction: column; margin-top: 12px; }
.quick-list a { display: flex; gap: 16px; align-items: center; padding: 12px 0; font: 500 18px var(--head); color: var(--strong); }
.quick-list a span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font: 500 14px var(--sans); flex: none; }
.quick-list a:hover { color: var(--accent-ink); }
.rules { margin-top: 24px; }
.rules h2 { margin-top: 0; }

.foot { text-align: center; font-size: 13.5px; color: var(--faint); padding: 40px 20px calc(40px + env(safe-area-inset-bottom)); }

@media (max-width: 600px) {
  body { font-size: 17px; line-height: 1.85; }
  .head { margin-bottom: 36px; }
  .figure { margin-bottom: 20px; }
  .prose blockquote { font-size: 18px; padding-left: 18px; }
  .compare section { padding: 18px 18px 6px; border-radius: 16px; }
  .stat-n b { font-size: 34px; }
}
@media print { .top, .drawer, .scrim, .side, .pager, .progress, .toc-mobile { display: none; } }

.prose hr:has(+ h2) { display: none; }
