:root {
  color-scheme: light dark;
  --bg: #faf8f5; --surface: #ffffff; --soft: #f1ede7; --text: #211e1b; --muted: #655f58;
  --line: #e2dcd3; --accent: #9b2c3f; --accent-soft: #e9c9cf; --second: #2f6c7a; --help: #2a2522; --help-text: #fff;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15171b; --surface: #1e2126; --soft: #282c32; --text: #eeebe6; --muted: #aaa59d; --line: #363a41; --accent: #e8798c; --accent-soft: #5a2f38; --second: #6fb8c7; --help: #0d0e10; --help-text: #f4f1ec; }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { width: min(1080px, 100%); margin-inline: auto; padding-inline: 20px; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.015em; margin: 0; }
h1 { font: 700 clamp(2.3rem, 7vw, 4.2rem)/1.05 Georgia, "Times New Roman", serif; }
h2 { font: 700 clamp(1.45rem, 3.4vw, 2rem)/1.2 Georgia, "Times New Roman", serif; }
h3 { font-size: 1.02rem; }
.help { background: var(--help); color: var(--help-text); font-size: .88rem; position: sticky; top: 0; z-index: 5; }
.help .wrap { display: flex; flex-wrap: wrap; gap: 4px 18px; padding-block: 8px; }
.help a { color: inherit; font-weight: 600; text-underline-offset: 3px; }
.hero { padding-block: 60px 28px; }
.eyebrow { color: var(--accent); font-size: .82rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; margin: 0 0 12px; }
.lede { font-size: clamp(1.08rem, 2.2vw, 1.3rem); max-width: 42em; margin: 18px 0 10px; }
.note, .fine, figcaption { color: var(--muted); font-size: .87rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-top: 32px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stats div { background: var(--surface); padding: 18px; }
.stats strong { display: block; font: 700 clamp(1.6rem, 3.5vw, 2.2rem)/1.1 Georgia, serif; color: var(--accent); font-variant-numeric: tabular-nums; }
.stats span { display: block; color: var(--muted); font-size: .86rem; margin-top: 6px; line-height: 1.35; }
section { padding-block: 38px; border-top: 1px solid var(--line); }
.sub, .head p { color: var(--muted); margin: 8px 0 20px; max-width: 46em; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.seg { display: inline-flex; flex: none; padding: 3px; background: var(--soft); border-radius: 9px; }
.seg button { border: 0; background: none; color: var(--muted); padding: 7px 12px; border-radius: 7px; font: inherit; font-size: .86rem; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chart { position: relative; margin: 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
#chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.axis { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.grid { stroke: var(--line); }
.tip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); padding: 6px 9px; border-radius: 6px; font-size: .8rem; line-height: 1.3; white-space: nowrap; transform: translate(-50%, -115%); }
figcaption { margin-top: 10px; }
.dash { display: inline-block; width: 22px; border-top: 2px dashed var(--accent); vertical-align: middle; margin-right: 7px; }
.events { list-style: none; padding: 0; margin: 18px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 22px; font-size: .88rem; }
.events li { display: flex; gap: 9px; color: var(--muted); line-height: 1.4; }
.events b { flex: none; width: 21px; height: 21px; border-radius: 50%; display: grid; place-items: center; background: var(--second); color: var(--surface); font-size: .72rem; }
.events strong { color: var(--text); }
details { margin-top: 10px; } summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .92rem; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.cards article { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.cards p { margin: 7px 0 0; color: var(--muted); font-size: .92rem; line-height: 1.5; }
.cards strong { color: var(--text); }
.callout { margin-top: 16px; padding: 18px 20px; background: var(--soft); border-left: 3px solid var(--accent); border-radius: 0 10px 10px 0; }
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 220px 1fr 74px; gap: 12px; align-items: center; font-size: .92rem; }
.bar-track { height: 26px; background: var(--soft); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); }
.bar-fill.alt { background: var(--second); }
.bar-row b { text-align: right; font-variant-numeric: tabular-nums; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.step { padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.step strong { display: block; font: 700 1.8rem/1.1 Georgia, serif; color: var(--accent); }
.step span { display: block; margin-top: 7px; color: var(--muted); font-size: .88rem; line-height: 1.4; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; margin-top: 8px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: .8rem; }
th button { all: unset; cursor: pointer; font-weight: 700; }
th button::after { content: " ↕"; opacity: .45; }
th[aria-sort="ascending"] button::after { content: " ↑"; opacity: 1; }
th[aria-sort="descending"] button::after { content: " ↓"; opacity: 1; }
.n { text-align: right; font-variant-numeric: tabular-nums; }
.barcol { width: 32%; }
.mini { height: 8px; background: var(--accent); border-radius: 3px; min-width: 1px; }
#find { width: min(240px, 100%); flex: none; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.two h2 { font-size: 1.35rem; } .two ul { padding-left: 20px; color: var(--muted); }
.support h2 { margin-bottom: 20px; }
.support .cards a { font: 700 2rem/1 Georgia, serif; text-decoration: none; }
footer { padding-block: 34px 56px; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
footer h2 { font-size: 1.2rem; color: var(--text); margin-bottom: 8px; }
.hero-title { font-size: clamp(1.9rem, 5vw, 3rem); }

/* ---------- globe stage (always dark) ---------- */
.stage { --g-text: #f6efe6; --g-muted: #aeb2bb; --g-panel: rgba(16, 19, 27, .78); --g-line: rgba(255, 255, 255, .13); --g-hot: #f47a5f;
  position: relative; height: calc(100svh - 38px); min-height: 680px; max-height: 1040px; background: #060a14; color: var(--g-text); overflow: hidden; }
#globe { position: absolute; inset: 0; }
.nogl { position: absolute; top: 45%; left: 50%; transform: translateX(-50%); width: min(420px, 85%); text-align: center; color: var(--g-muted); }
.s-title, .s-readout, .s-side, .s-detail, .s-legend, .s-time { position: absolute; z-index: 2; }
.s-title { top: 20px; left: 26px; width: min(600px, 52vw); pointer-events: none; text-shadow: 0 1px 12px #060a14; }
.s-title p { margin: 0 0 6px; color: #ff9c86; font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.s-title h1 { font-size: clamp(2rem, 3.5vw, 3.1rem); }
.s-title span { display: block; margin-top: 8px; color: #cfd1d6; font-size: .88rem; line-height: 1.4; }
.s-readout { left: 26px; bottom: 112px; width: 300px; padding: 14px 16px; background: var(--g-panel); border: 1px solid var(--g-line); border-radius: 12px; backdrop-filter: blur(8px); }
.s-readout > strong { display: block; font: 700 3.3rem/1 Georgia, serif; font-variant-numeric: tabular-nums; }
.s-readout div { margin-top: 4px; } .s-readout b { font-size: 1.28rem; font-variant-numeric: tabular-nums; } .s-readout span { color: var(--g-muted); font-size: .84rem; }
.s-readout em { display: block; font-style: normal; font-size: .82rem; color: var(--g-muted); }
.s-readout em.up { color: #ff9c86; } .s-readout em.down { color: #8fd3c2; }
.s-readout p { margin: 7px 0 0; min-height: 2.7em; color: #d9dae0; font-size: .8rem; line-height: 1.35; }
.s-side { top: 18px; right: 62px; width: 278px; max-height: calc(100% - 128px); overflow: auto; padding: 12px; background: var(--g-panel); border: 1px solid var(--g-line); border-radius: 12px; backdrop-filter: blur(8px); }
.g-seg { display: flex; padding: 3px; background: rgba(255,255,255,.08); border-radius: 8px; }
.g-seg button { flex: 1; border: 0; border-radius: 6px; padding: 6px 4px; background: none; color: var(--g-muted); font: inherit; font-size: .8rem; cursor: pointer; }
.g-seg button[aria-pressed="true"] { background: #f6efe6; color: #17181d; font-weight: 700; }
.rate-note { margin: 6px 0 0; color: #ffc9a8; font-size: .74rem; }
#statePick { width: 100%; margin-top: 9px; padding: 7px 8px; border: 1px solid var(--g-line); border-radius: 7px; background: #171b24; color: var(--g-text); font: inherit; font-size: .84rem; }
.s-side h2 { margin: 12px 0 5px; font: 700 .76rem/1.3 system-ui, sans-serif; letter-spacing: 0; color: var(--g-muted); }
#rankList { list-style: none; margin: 0; padding: 0; }
#rankList button { position: relative; display: grid; grid-template-columns: 16px 1fr auto; gap: 5px; width: 100%; padding: 5px 2px 7px; border: 0; background: none; color: inherit; font: inherit; font-size: .82rem; text-align: left; cursor: pointer; }
#rankList button:hover .nm { color: #ffd59e; } #rankList .rk { color: var(--g-muted); } #rankList b { font-variant-numeric: tabular-nums; }
#rankList i { position: absolute; left: 2px; bottom: 2px; height: 2px; background: var(--g-hot); border-radius: 2px; }
.view-btns { display: flex; gap: 6px; margin-top: 8px; }
.view-btns button { flex: 1; padding: 6px; border: 1px solid var(--g-line); border-radius: 7px; background: none; color: var(--g-text); font: inherit; font-size: .78rem; cursor: pointer; }
.view-btns button:hover { background: rgba(255,255,255,.09); }
.s-detail { top: 178px; left: 26px; width: 300px; padding: 13px 15px; background: rgba(20, 23, 32, .94); border: 1px solid rgba(255, 213, 158, .4); border-radius: 12px; }
.s-detail h2 { padding-right: 24px; font: 700 1.04rem/1.25 system-ui, sans-serif; letter-spacing: 0; }
#closeDetail { position: absolute; top: 6px; right: 7px; width: 28px; height: 28px; border: 0; border-radius: 6px; background: none; color: var(--g-muted); font-size: 1.2rem; cursor: pointer; }
.d-val strong { font: 700 1.8rem/1.2 Georgia, serif; color: #ffd59e; } .d-val span { color: var(--g-muted); font-size: .78rem; }
#dSpark svg { display: block; width: 100%; height: auto; margin-top: 4px; }
.s-detail p { margin: 3px 0 0; font-size: .78rem; } .d-note { color: #ffc9a8; }
.s-legend { right: 62px; bottom: 136px; display: grid; grid-template-columns: 1fr auto; width: 170px; gap: 3px; padding: 7px 10px; background: var(--g-panel); border: 1px solid var(--g-line); border-radius: 8px; font-size: .72rem; }
.s-legend span { grid-column: 1 / -1; color: var(--g-muted); }
.s-legend i { grid-column: 1 / -1; height: 7px; border-radius: 3px; background: linear-gradient(90deg, #3b2536, #7d2746 30%, #c43a55 55%, #f47a5f 78%, #ffd59e); }
.s-time { left: 26px; right: 26px; bottom: 16px; display: flex; align-items: center; gap: 14px; padding: 9px 16px; background: var(--g-panel); border: 1px solid var(--g-line); border-radius: 12px; backdrop-filter: blur(8px); }
#playBtn { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: #f6efe6; color: #17181d; font-size: .95rem; cursor: pointer; }
.time-track { flex: 1; min-width: 0; }
#yearBars { display: grid; grid-template-columns: repeat(24, 1fr); align-items: end; gap: 2px; height: 30px; }
#yearBars button { display: flex; align-items: flex-end; height: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
#yearBars button:disabled { opacity: .25; cursor: not-allowed; }
#yearBars i { display: block; width: 100%; height: var(--h); background: rgba(255,255,255,.2); border-radius: 2px 2px 0 0; }
#yearBars .past i { background: #9c3350; } #yearBars .on i { background: #ffd59e; }
#yearRange { display: block; width: 100%; height: 16px; margin: 1px 0 0; accent-color: #ffd59e; }
.time-ends { display: flex; justify-content: space-between; color: var(--g-muted); font-size: .68rem; }
.stage button:focus-visible, .stage select:focus-visible, .stage input:focus-visible { outline: 2px solid #ffd59e; outline-offset: 2px; }
.state-pop .maplibregl-popup-content { padding: 7px 10px; background: #f6efe6; color: #17181d; font: 13px/1.35 system-ui, sans-serif; border-radius: 6px; }
.state-pop .maplibregl-popup-tip { display: none; }
.stage .maplibregl-ctrl-top-right { top: 8px; right: 4px; }
.stage .maplibregl-ctrl-bottom-right { bottom: 92px; }
@media (max-width: 1000px) {
  .stage { height: auto; max-height: none; min-height: 0; display: flex; flex-direction: column; overflow: visible; }
  #globe { position: relative; order: 2; height: 56svh; min-height: 360px; }
  .s-title, .s-readout, .s-side, .s-detail, .s-legend, .s-time { position: static; width: auto; max-height: none; backdrop-filter: none; }
  .s-title { order: 1; padding: 18px 16px 12px; }
  .s-time { order: 3; margin: 0; border-radius: 0; border-inline: 0; padding: 8px 12px; }
  .s-readout { order: 4; margin: 10px 12px 0; }
  .s-readout p { min-height: 0; }
  .s-detail { order: 5; margin: 10px 12px 0; position: relative; }
  .s-side { order: 6; margin: 10px 12px 0; }
  .s-legend { order: 7; margin: 10px 12px 14px; }
  .stage .maplibregl-ctrl-bottom-right { bottom: 0; }
}
@media (max-width: 820px) {
  .stats, .steps { grid-template-columns: 1fr 1fr; }
  .cards, .events { grid-template-columns: 1fr 1fr; }
  .head { flex-direction: column; } .two { grid-template-columns: 1fr; gap: 10px; }
}
@media (max-width: 560px) {
  .wrap { padding-inline: 16px; } .hero { padding-top: 38px; }
  .cards, .events { grid-template-columns: 1fr; }
  .chart { padding: 10px; }
  .bar-row { grid-template-columns: 1fr auto; } .bar-track { grid-column: 1 / -1; grid-row: 2; }
  .barcol, #stateTable td:last-child { display: none; }
  th, td { padding: 8px 6px; }
}
