:root {
  --bg: #f7f6f2; --panel: #ffffff; --ink: #1d2330; --muted: #5d6677; --line: #dedbd2; --soft: #eef0f4;
  --pw: #2c6fbb; --snr: #e4572e; --good: #1f7a4d; --bad: #b2182b; --accent: #1f5fa8; --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 8px 24px rgba(20, 30, 50, .06);
  --canvas: #eceae3; --mse: #5f6b7a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b; --panel: #1a1e26; --ink: #e5e8ef; --muted: #9aa3b3; --line: #2b323e; --soft: #222833;
    --pw: #6ea8ee; --snr: #ff8a63; --good: #6fcf9b; --bad: #f0877b; --accent: #7fb2ee; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35); --canvas: #0f1218; --mse: #a7b0bf;
  }
}
:root[data-theme="dark"] {
  --bg: #12151b; --panel: #1a1e26; --ink: #e5e8ef; --muted: #9aa3b3; --line: #2b323e; --soft: #222833;
  --pw: #6ea8ee; --snr: #ff8a63; --good: #6fcf9b; --bad: #f0877b; --accent: #7fb2ee; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35); --canvas: #0f1218; --mse: #a7b0bf;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.65 ui-sans-serif, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-variant-numeric: tabular-nums; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
code { background: var(--soft); padding: 1px 6px; border-radius: 5px; font-size: .88em; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 20px; }

.hero { padding: 64px 0 28px; background: radial-gradient(1000px 340px at 78% -10%, color-mix(in srgb, var(--snr) 16%, transparent), transparent), radial-gradient(900px 320px at 8% 0%, color-mix(in srgb, var(--pw) 16%, transparent), transparent); }
.hero h1 { font-size: clamp(2.3rem, 5vw, 3.6rem); line-height: 1.08; margin: 0 0 10px; letter-spacing: -.02em; }
.hero h1 span { color: var(--snr); }
.hero .lede { max-width: 46em; font-size: 1.14rem; color: var(--muted); margin: 0 0 22px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-top: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.55rem; line-height: 1.2; letter-spacing: -.01em; }
.stat small { color: var(--muted); display: block; margin-top: 3px; line-height: 1.45; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.btn { display: inline-block; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: .92rem; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }

nav.toc { position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px); background: color-mix(in srgb, var(--bg) 82%, transparent); border-bottom: 1px solid var(--line); }
nav.toc .wrap { display: flex; gap: 4px; overflow-x: auto; padding-top: 8px; padding-bottom: 8px; }
nav.toc a { white-space: nowrap; padding: 4px 12px; border-radius: 999px; color: var(--muted); font-size: .9rem; }
nav.toc a:hover { background: var(--soft); text-decoration: none; color: var(--ink); }

section { padding: 44px 0 8px; }
section > .wrap > h2 { font-size: 1.6rem; margin: 0 0 6px; letter-spacing: -.01em; }
section > .wrap > p.sub { color: var(--muted); max-width: 52em; margin: 0 0 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.pad { padding: 16px 18px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 880px) { .grid2 { grid-template-columns: 1fr; } }

.viewer { position: relative; background: var(--canvas); min-height: 380px; }
.viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.viewer.tall { height: 470px; } .viewer.mid { height: 380px; }
.viewer .tip { position: absolute; left: 12px; top: 10px; background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: .82rem; pointer-events: none; min-width: 170px; }
.viewer .tip b { font-weight: 600; }
.viewer .loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.legend { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: .82rem; color: var(--muted); border-top: 1px solid var(--line); flex-wrap: wrap; }
.legend canvas { width: 180px; height: 12px; border-radius: 6px; }
.legend .nums { margin-left: auto; color: var(--ink); }
.controls { display: grid; gap: 10px; }
.controls label { display: grid; gap: 3px; font-size: .82rem; color: var(--muted); }
select, input[type=range] { width: 100%; font: inherit; color: var(--ink); }
select { background: var(--soft); border: 1px solid var(--line); border-radius: 9px; padding: 7px 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--soft); }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 7px 12px; font: inherit; font-size: .86rem; cursor: pointer; }
.seg button.on { background: var(--ink); color: var(--bg); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 4px 11px; font: inherit; font-size: .82rem; cursor: pointer; }
.chip:hover { background: var(--soft); } .chip.on { background: var(--soft); border-color: var(--muted); }
.check, .controls label.check, .chartbox label.check { display: flex; gap: 6px; align-items: center; font-size: .86rem; color: var(--ink); }
.controls label .lv { display: flex; justify-content: space-between; }
.controls label .lv b { color: var(--ink); }
.note { font-size: .85rem; color: var(--muted); margin: 8px 0 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: .9rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; }
.pos { color: var(--good); } .neg { color: var(--bad); }
svg text { fill: var(--ink); font: 11px ui-sans-serif, -apple-system, sans-serif; }
svg .m { fill: var(--muted); } svg .ax { stroke: var(--line); } svg .grid { stroke: var(--line); stroke-dasharray: 2 3; opacity: .8; }
svg .zero { stroke: var(--ink); opacity: .6; }
.chartbox { padding: 10px 12px 14px; } .chartbox svg { width: 100%; height: auto; display: block; }
.tt { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--bg); border-radius: 8px; padding: 6px 9px; font-size: .8rem; line-height: 1.4; max-width: 260px; display: none; }
footer { padding: 36px 0 60px; color: var(--muted); font-size: .9rem; }
.tag { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); margin-left: 6px; vertical-align: middle; }
.pill { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

.chartbox > div, .chartbox > div > div { max-width: 100%; }
#forest, #kchart, #tsplot, #pg { overflow-x: auto; }
#forest svg { min-width: 640px; } #kchart svg { min-width: 620px; } #tsplot svg { min-width: 620px; } #pg svg { min-width: 520px; }

/* ---- leaderboard snapshot, geometry playground, parcel pin, lightbox ---- */
a.stat.link { color: inherit; display: block; } a.stat.link:hover { text-decoration: none; border-color: var(--snr); }
.boardgrid { align-items: stretch; }
.shot { position: relative; display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--soft); cursor: zoom-in; }
.shot img { display: block; width: 100%; height: 230px; object-fit: cover; object-position: 50% 75%; }
.shot span { position: absolute; right: 8px; bottom: 8px; background: var(--ink); color: var(--bg); font-size: .75rem; padding: 2px 9px; border-radius: 999px; }
#boardbars svg g.row { transition: transform .55s cubic-bezier(.2, .8, .2, 1); }
#boardbars svg rect.bar { transition: width .55s cubic-bezier(.2, .8, .2, 1); }
#boardbars svg .ours text { font-weight: 600; }
.geo { background: var(--canvas); } .geo svg { display: block; width: 100%; height: auto; touch-action: none; }
.geo .handle { cursor: grab; } .geo .handle:active { cursor: grabbing; }
#pinbars svg { width: 100%; height: auto; display: block; }
.chip[hidden] { display: none; }
#lb { position: fixed; inset: 0; z-index: 80; background: rgba(8, 10, 14, .86); display: grid; place-items: center; padding: 28px 18px 54px; overflow: auto; }
#lb[hidden] { display: none; }
#lb img { max-width: min(1400px, 96vw); width: auto; height: auto; border-radius: 10px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); background: #fff; }
#lb button { position: fixed; top: 12px; right: 18px; font-size: 2rem; line-height: 1; background: transparent; color: #fff; border: 0; cursor: pointer; }
#lb a { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); color: #cfd8e6; font-size: .85rem; }
.geo, .geo svg, .geo svg text { user-select: none; -webkit-user-select: none; }
.chartbox label .lv { display: flex; justify-content: space-between; gap: 8px; }
.chartbox label .lv b { color: var(--ink); }
#boardbars, #pinbars { overflow-x: auto; } #boardbars svg { min-width: 520px; } #pinbars svg { min-width: 500px; }

/* embedded in another page (?embed=1): no hero or footer, the section bar stays */
.embed .hero, .embed footer { display: none; } .embed section:first-of-type { padding-top: 18px; }
