:root {
  --bg: #fbfaf7; --surface: #ffffff; --ink: #1d1f24; --muted: #5d6270; --line: #e3e1da;
  --accent: #127a63; --accent-soft: #e3f2ee; --warn: #c2560c; --purple: #6a63b5; --grey: #6b6b6b;
  --code-bg: #f1efe9;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a; --surface: #1c1f25; --ink: #e8e8ea; --muted: #a0a5b1; --line: #2e323a;
    --accent: #3cc4a0; --accent-soft: #173a32; --warn: #f08a4b; --purple: #9d97e6; --grey: #a3a3a3;
    --code-bg: #23262d;
  }
}
:root[data-theme="dark"] {
  --bg: #14161a; --surface: #1c1f25; --ink: #e8e8ea; --muted: #a0a5b1; --line: #2e323a;
  --accent: #3cc4a0; --accent-soft: #173a32; --warn: #f08a4b; --purple: #9d97e6; --grey: #a3a3a3;
  --code-bg: #23262d;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
code, pre { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 0.9em; }
code { background: var(--code-bg); padding: 1px 4px; border-radius: 4px; }
pre { background: var(--code-bg); padding: 14px; border-radius: 8px; overflow-x: auto; }
pre code { background: none; padding: 0; }
.muted { color: var(--muted); } .small { font-size: 0.86rem; }

.hero { padding: 56px 0 32px; border-bottom: 1px solid var(--line); }
.kicker { color: var(--muted); font-size: 0.85rem; letter-spacing: .02em; margin: 0 0 8px; }
h1 { font-size: clamp(2rem, 5vw, 3rem); line-height: 1.1; margin: 0 0 16px; letter-spacing: -0.02em; }
.lede { font-size: 1.12rem; max-width: 760px; margin: 0 0 22px; }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 26px; }
.btn { display: inline-block; background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: 8px; padding: 9px 16px; text-decoration: none; font: inherit; font-weight: 600; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn:disabled { opacity: .55; cursor: progress; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.stat b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.86rem; }

.toc { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.toc .wrap { display: flex; gap: 14px; overflow-x: auto; padding-top: 10px; padding-bottom: 10px; white-space: nowrap; }
.toc a { text-decoration: none; color: var(--muted); font-size: 0.9rem; }
.toc a:hover { color: var(--accent); }

section { padding: 40px 0 8px; scroll-margin-top: 48px; }
h2 { font-size: 1.55rem; margin: 0 0 14px; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; margin: 18px 0 8px; }
.card h3 { margin-top: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
.card.accent { border-color: var(--accent); background: var(--accent-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 14px 0; }
.methods p { margin: 0; font-size: 0.95rem; }
.note { border-left: 3px solid var(--warn); padding: 4px 0 4px 14px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 16px 0 0; }
.facts div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.facts dt { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 4px 0 0; }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 340px; }

.table-wrap { overflow-x: auto; margin: 10px 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.84rem; font-variant-numeric: tabular-nums; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
th, td { padding: 7px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { font-weight: 600; color: var(--muted); font-size: 0.82rem; }
tr.ours td { background: var(--accent-soft); }
tr:last-child td { border-bottom: none; }

.controls { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.seg button { background: var(--surface); color: var(--ink); border: 0; padding: 7px 12px; font: inherit; font-size: 0.9rem; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; }
.takeaways { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.takeaways div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 0.95rem; }

.live-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.live-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; color: var(--muted); }
.live-form output { color: var(--ink); font-weight: 600; }
.live-form select, .live-form input { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px; }
.live-form input[type=range] { padding: 0; accent-color: var(--accent); }
.status { font-size: 0.92rem; color: var(--muted); min-height: 1.5em; }
.status.err { color: var(--warn); }

footer { border-top: 1px solid var(--line); margin-top: 48px; padding: 20px 0 40px; }

@media (max-width: 720px) {
  .grid2, .takeaways { grid-template-columns: 1fr; }
  .chart-box.tall { height: 300px; }
}

/* ---------- multipage shell ---------- */
.site-head { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.site-head .wrap { display: flex; align-items: center; gap: 18px; padding-top: 10px; padding-bottom: 10px; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; }
.site-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.site-nav a { text-decoration: none; color: var(--muted); font-size: 0.92rem; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.site-nav a:hover { color: var(--ink); background: var(--code-bg); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.page-head { padding: 40px 0 6px; }
.page-head h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin-bottom: 8px; }
.page-head p { color: var(--muted); max-width: 720px; margin: 0; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin: 48px 0 0; padding-top: 18px; border-top: 1px solid var(--line); }
.pager a { text-decoration: none; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 18px 0; }
a.card { text-decoration: none; color: var(--ink); transition: border-color .15s; }
a.card:hover { border-color: var(--accent); }
a.card p { color: var(--muted); margin: 0; font-size: 0.94rem; }
.findings { display: grid; gap: 12px; margin: 16px 0; }
.findings div { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 12px 14px; }
.findings div.warn { border-left-color: var(--warn); }

/* ---------- playground ---------- */
.step { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin: 18px 0; }
.step.locked { opacity: .5; pointer-events: none; }
.step-title { display: flex; align-items: baseline; gap: 10px; margin: 0 0 6px; font-size: 1.15rem; }
.step-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 0.85rem; flex: none; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 12px 0; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.86rem; color: var(--muted); min-width: 140px; }
.field output { color: var(--ink); font-weight: 600; }
select, input[type=text], input[type=number], input[type=search] { font: inherit; font-size: 0.92rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
input[type=range] { accent-color: var(--accent); }
.dataset-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; cursor: pointer; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { display: none; }
.coltable td, .coltable th { text-align: left; }
.coltable select { padding: 3px 6px; }
.coltable tr.is-target td { background: var(--accent-soft); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); margin: 10px 0 14px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; font: inherit; color: var(--muted); cursor: pointer; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel[hidden] { display: none; }
.cond { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); cursor: pointer; padding: 4px 9px; font: inherit; }
.icon-btn:hover { color: var(--warn); border-color: var(--warn); }
.pill { display: inline-block; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 10px; font-size: 0.85rem; font-weight: 600; }
.pill.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.picktable td:first-child, .picktable th:first-child { width: 34px; text-align: center; }
.picktable th[data-sort] { cursor: pointer; }
.picktable th[data-sort]:hover { color: var(--accent); }
.picktable tr.picked td { background: color-mix(in srgb, var(--warn) 12%, transparent); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0; }
.kv div { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.kv b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.kv span { font-size: 0.8rem; color: var(--muted); }
.btn.small { padding: 6px 12px; font-size: 0.9rem; }
@media (max-width: 720px) { .dataset-choice { grid-template-columns: 1fr; } .brand { display: none; } }
