:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #eceee9;
  --fg: #141718;
  --muted: #5f6864;
  --line: #dde1db;
  --accent: #2346d0;
  --good: #12804a;
  --good-bg: #dff2e7;
  --bad: #c43320;
  --bad-bg: #fbe3de;
  --warn: #9b5f06;
  --warn-bg: #fbeed5;
  --info: #4c5b70;
  --info-bg: #e6eaf0;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1211; --surface: #171b1a; --surface-2: #202624; --fg: #e8ecea; --muted: #9aa5a1; --line: #2b3330;
    --accent: #8fa6ff; --good: #4fcf86; --good-bg: #173326; --bad: #ff7d69; --bad-bg: #3a1c17;
    --warn: #f0b552; --warn-bg: #3a2b12; --info: #a9b6c8; --info-bg: #222a35; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1211; --surface: #171b1a; --surface-2: #202624; --fg: #e8ecea; --muted: #9aa5a1; --line: #2b3330;
  --accent: #8fa6ff; --good: #4fcf86; --good-bg: #173326; --bad: #ff7d69; --bad-bg: #3a1c17;
  --warn: #f0b552; --warn-bg: #3a2b12; --info: #a9b6c8; --info-bg: #222a35; color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
.wrap { max-width: 1200px; margin: 0 auto; padding-inline: 16px; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; }
p { margin: 0; }
a { color: inherit; }
button, input { font: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 14px 8px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; display: block; }
h1 { font-size: 18px; font-weight: 800; }
.sub { color: var(--muted); font-size: 12.5px; }
.source { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.badge { font: 600 11px/1 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; padding: 5px 8px; border-radius: 999px; }
.badge.demo { background: var(--warn-bg); color: var(--warn); }
.badge.live { background: var(--good-bg); color: var(--good); }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-size: 12.5px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 10px 12px 9px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--fg); }
.tabs button:hover { color: var(--fg); }

main { padding-block: 22px 64px; display: grid; gap: 24px; }
main > *, section, .two > * { min-width: 0; }
.loading { color: var(--muted); }
.sh { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sh h2 { font-size: 16px; font-weight: 700; }
.sh span { color: var(--muted); font-size: 12.5px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.empty { padding: 20px; color: var(--muted); text-align: center; }
.banner { overflow-wrap: anywhere; border-radius: 12px; padding: 10px 14px; font-size: 13px; background: var(--warn-bg); color: var(--warn); }
.banner summary { cursor: pointer; font-weight: 600; }
.banner p { margin-top: 6px; }
.two { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- big numbers */
.big { display: grid; gap: 2px; }
.big b { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.big span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.big.good b { color: var(--good); }
.big.bad b { color: var(--bad); }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 24px; max-width: 520px; }
@media (max-width: 420px) { .big b { font-size: 28px; } }

/* ---------------------------------------------------------------- hero */
.hero { padding: 20px 24px; display: flex; gap: 32px; align-items: center; }
.hero > .crew { flex-wrap: nowrap; flex-shrink: 0; }
.hero-body { flex: 1; display: grid; gap: 14px; min-width: 0; }
.eyebrow { font: 600 11px/1.3 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.headline { font-size: 20px; font-weight: 700; max-width: 60ch; }
.pod-hero .pod-h { justify-content: flex-start; gap: 12px; }
.pod-hero .pod-h h2 { font-size: 26px; font-weight: 800; }
.why { color: var(--muted); font-size: 13px; }
@media (max-width: 720px) { .hero { flex-direction: column; align-items: stretch; gap: 16px; } .hero > .crew { justify-content: center; } }

/* ---------------------------------------------------------------- mascots */
/* Transparent, full-body WebPs on a 256×256 canvas: shown whole (contain), one size everywhere. */
/* The canvas has transparent sides, so neighbours overlap a little. One size per screen width, the same for everyone. */
.crew { --m: 104px; display: flex; flex-wrap: nowrap; align-items: flex-end; }
@media (min-width: 641px) and (max-width: 1180px) { .crew { --m: 80px; } }
.mascot { margin: 0; display: grid; justify-items: center; gap: 2px; }
.mascot + .mascot { margin-left: -16px; }
.mascot .frame { position: relative; width: var(--m); height: var(--m); display: grid; place-items: center; }
.mascot .frame::before { content: ""; position: absolute; left: 22%; right: 22%; bottom: 0; height: 9px; border-radius: 50%; background: var(--line); opacity: .9; }
.mascot.happy .frame::before { background: color-mix(in srgb, var(--good) 35%, transparent); }
.mascot.sad .frame::before { background: color-mix(in srgb, var(--bad) 35%, transparent); }
.mascot img { position: relative; width: 100%; height: 100%; object-fit: contain; display: block; }
.mascot .ini { display: none; width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); place-items: center; font-weight: 800; color: var(--muted); font-size: 18px; }
.mascot .frame.missing .ini { display: grid; }
.mascot figcaption { font-size: 12px; font-weight: 600; }

/* ---------------------------------------------------------------- pods */
.pods { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 16px; }
.pod { padding: 18px; display: grid; gap: 16px; cursor: pointer; text-align: left; color: inherit; font: inherit; transition: border-color .15s, box-shadow .15s; }
.pod:hover { border-color: var(--muted); box-shadow: 0 4px 18px rgb(0 0 0 / 0.06); }
.pod-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pod-h h3 { font-size: 18px; font-weight: 800; }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.trio .big b { font-size: 28px; }
.pod .crew { min-height: calc(var(--m) + 20px); }
.pod .why { border-top: 1px solid var(--line); padding-top: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mood { font: 600 11px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.05em; padding: 6px 9px; border-radius: 999px; white-space: nowrap; }
.mood.happy { background: var(--good-bg); color: var(--good); }
.mood.sad { background: var(--bad-bg); color: var(--bad); }
.mood.neutral { background: var(--info-bg); color: var(--info); }

/* ---------------------------------------------------------------- tests table */
.tbl { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font: 600 11px/1.3 var(--mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
tr:first-child td { border-top: 0; }
td.r, th.r { text-align: right; }
.test { font-weight: 650; text-decoration: none; }
a.test:hover { text-decoration: underline; }
td .sub { color: var(--muted); font-size: 12px; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.num.up, .num.down, .num.flat { font-weight: 800; font-size: 15px; }
.up { color: var(--good); }
.down { color: var(--bad); }
.flat { color: var(--muted); }
.chance { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.chance i { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--muted) var(--w), var(--surface-2) var(--w)); position: relative; }
.chance i.hi { background: linear-gradient(90deg, var(--good) var(--w), var(--surface-2) var(--w)); }
.chance i.lo { background: linear-gradient(90deg, var(--bad) var(--w), var(--surface-2) var(--w)); }
.chance i::after { content: ""; position: absolute; left: 95%; top: -2px; bottom: -2px; width: 2px; background: var(--fg); opacity: .25; border-radius: 1px; }
.chance em { font: 700 13px var(--mono); font-style: normal; min-width: 38px; text-align: right; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.off { background: var(--surface-2); color: var(--muted); }
.flag { font: 600 10.5px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.03em; padding: 3px 6px; border-radius: 6px; }
.flag.bad { background: var(--bad-bg); color: var(--bad); }
.flag.warn { background: var(--warn-bg); color: var(--warn); }
.why-row { color: var(--bad); font-size: 12px; margin-top: 4px; max-width: 70ch; }

/* ---------------------------------------------------------------- filters */
.filters { padding: 14px 16px; display: grid; gap: 12px; }
.seg { display: inline-flex; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 999px; justify-self: start; max-width: 100%; overflow-x: auto; }
.seg .chip { border: 0; background: none; }
.seg .chip[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.frow { display: flex; gap: 10px; align-items: baseline; }
.flabel { font: 600 10.5px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); min-width: 44px; }
.chip small { font-weight: 700; opacity: .6; margin-left: 2px; }
.chip.zero { opacity: .5; }
@media (max-width: 640px) { .frow { flex-direction: column; gap: 6px; } }

/* ---------------------------------------------------------------- lists */
.list .row { width: 100%; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); align-items: center; font-size: 13px; }
.list .row:first-child { border-top: 0; }
.list button.row:hover { background: var(--surface-2); }
.list .row:first-child { border-radius: 16px 16px 0 0; }
.pod-tag { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.list .more { padding: 10px 16px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }
.dot.good { background: var(--good); }

/* ---------------------------------------------------------------- what worked */
.intro { padding: 20px 24px; display: grid; gap: 10px; }
.intro h2 { font-size: 24px; font-weight: 800; }
.intro p { color: var(--muted); max-width: 70ch; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.plays { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 16px; }
.play { padding: 18px; display: grid; gap: 12px; align-content: start; }
.play.won { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.play header { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.play .tag { font-size: 12px; font-weight: 700; }
.play h3 { font-size: 17px; font-weight: 700; }
.result { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.result > b { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.result span { font-size: 12.5px; color: var(--muted); }
.result small { font-size: 11.5px; }
.result .impact { margin-left: auto; font-size: 22px; color: var(--good); }
.result .impact small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.changed summary { list-style: none; cursor: pointer; font-size: 13.5px; }
.changed summary::-webkit-details-marker { display: none; }
.changed .clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; overflow-wrap: anywhere; }
.changed summary::after { content: "Read more"; color: var(--accent); font-size: 12.5px; font-weight: 600; }
.changed[open] summary { display: none; }
.changed p { font-size: 13.5px; white-space: pre-line; overflow-wrap: anywhere; }
.where { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.play code { font: 12px var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.open { font-weight: 600; color: var(--accent); text-decoration: none; font-size: 13px; }
.open:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- toolbox */
.toolbox { position: fixed; right: 16px; bottom: 16px; z-index: 6; display: grid; justify-items: end; gap: 8px; }
.tb-toggle { order: 2; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 12px; cursor: pointer; font-size: 16px; box-shadow: 0 4px 14px rgb(0 0 0 / 0.1); }
.tb-toggle.on { border-color: var(--warn); background: var(--warn-bg); }
.tb-toggle small { font: 700 11px var(--mono); color: var(--warn); }
.tb-panel { order: 1; padding: 14px; display: grid; gap: 10px; width: min(300px, calc(100vw - 32px)); box-shadow: 0 8px 28px rgb(0 0 0 / 0.14); }
.tb-title { font-weight: 700; font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.tb-title span { font-weight: 500; color: var(--muted); font-size: 11.5px; }
.tb-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; }
.tb-row .chip { padding: 4px 9px; }
.toolbox .linkish { justify-self: start; }

/* ---------------------------------------------------------------- token dialog */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--fg); padding: 22px; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / 0.35); }
dialog form { display: grid; gap: 12px; }
dialog h2 { font-size: 17px; }
dialog p { color: var(--muted); font-size: 13px; }
dialog input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); }
dialog .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
dialog button { background: var(--fg); color: var(--bg); border: 0; border-radius: 8px; padding: 9px 14px; font-weight: 600; cursor: pointer; }
dialog .ghost { color: var(--accent); font-size: 13px; }
dialog .error { color: var(--bad); }
