:root {
    color-scheme: dark;
    --page: #16161a;
    --surface: #1e1e23;
    --surface-2: #26262c;
    --line: rgba(255, 255, 255, 0.08);
    --text: #f4f4f5;
    --text-2: #b4b4bb;
    --muted: #8b8b93;
    --grid: #2c2c32;
    --axis: #3a3a41;
    --gold: #d4ae63;
    --gold-ink: #141008;
    --gold-tint: rgba(212, 174, 99, 0.12);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --good: #0ca30c;
    --good-text: #3ecf3e;
    --warning: #fab219;
    --critical: #d03b3b;
    --critical-text: #f07272;
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        color-scheme: light;
        --page: #f4f3ef;
        --surface: #fcfcfb;
        --surface-2: #f0efec;
        --line: rgba(11, 11, 11, 0.10);
        --text: #0b0b0b;
        --text-2: #52514e;
        --muted: #706e69;
        --grid: #e1e0d9;
        --axis: #c3c2b7;
        --gold: #8a6a2a;
        --gold-ink: #ffffff;
        --gold-tint: rgba(138, 106, 42, 0.10);
        --s1: #2a78d6;
        --s2: #eb6834;
        --s3: #1baf7a;
        --good-text: #006300;
        --critical-text: #b42323;
    }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 120px; }
body {
    margin: 0;
    background: var(--page);
    color: var(--text);
    font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button { font: inherit; color: inherit; }
a { color: var(--gold); }

/* ── Header ── */
.top {
    position: sticky; top: 0; z-index: 10;
    background: color-mix(in srgb, var(--page) 92%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    padding: 12px 24px 10px;
}
.top-row, .filter-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; max-width: 1240px; margin: 0 auto; }
.filter-row { margin-top: 10px; }
.brand { font-weight: 700; letter-spacing: 0.22em; color: var(--gold); }
.brand span { letter-spacing: 0; font-weight: 500; color: var(--text-2); margin-left: 6px; }
.spacer { flex: 1; }
.loaded { color: var(--muted); font-size: 12.5px; }
.btn {
    background: transparent; border: 1px solid var(--line); border-radius: 8px;
    padding: 6px 12px; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.badge { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.badge.demo { background: var(--gold-tint); color: var(--gold); border: 1px solid var(--gold); }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; flex-wrap: wrap; }
.seg button { background: transparent; border: 0; border-radius: 7px; padding: 5px 12px; cursor: pointer; color: var(--text-2); }
.seg button:hover { background: var(--surface-2); }
.seg button[aria-checked="true"] { background: var(--gold-tint); color: var(--gold); font-weight: 600; box-shadow: inset 0 0 0 1px var(--gold); }
.seg.small button { padding: 4px 10px; font-size: 13px; }

.jump { display: flex; gap: 16px; margin-left: 8px; flex-wrap: wrap; }
.jump a { color: var(--text-2); text-decoration: none; font-size: 13.5px; }
.jump a:hover { color: var(--text); }
.count { background: var(--surface-2); border-radius: 999px; padding: 0 7px; font-size: 11.5px; color: var(--text-2); }
.count:empty { display: none; }

/* ── Layout ── */
main { max-width: 1240px; margin: 0 auto; padding: 8px 24px 80px; transition: opacity 0.2s; }
main.loading { opacity: 0.5; }
section { padding-top: 20px; }
h2 { font-size: 20px; margin: 18px 0 4px; }
.section-sub { color: var(--text-2); margin: 0 0 12px; }
h3 { font-size: 14.5px; margin: 0; }
h3.pad { padding: 16px 18px 6px; }
.sub { color: var(--muted); font-size: 12.5px; margin: 2px 0 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .card + .grid-2, .grid-2 + .grid-2 { margin-top: 16px; }
.notice { background: var(--surface); border: 1px solid var(--gold); border-radius: 14px; padding: 16px 18px; margin: 16px 0; }
.notice h3 { margin-bottom: 6px; }
.notice code { font: inherit; font-weight: 600; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
main.no-data section { display: none; }

/* ── Tiles ── */
.hero-row { display: grid; grid-template-columns: 280px 1fr; gap: 16px; margin-bottom: 16px; }
.hero { margin: 0; display: flex; flex-direction: column; justify-content: center; }
.hero .label { color: var(--text-2); font-size: 13px; }
.hero .value { font-size: 56px; font-weight: 650; line-height: 1.05; margin: 4px 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tiles.wide { margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.tile .label { color: var(--text-2); font-size: 12.5px; }
.tile .value { font-size: 24px; font-weight: 650; margin-top: 2px; }
.tile .value .of { font-size: 13px; font-weight: 500; color: var(--text-2); margin-left: 4px; }
.tile .note { color: var(--muted); font-size: 12px; margin-top: 2px; }
.delta { font-size: 12.5px; }
.delta.up { color: var(--good-text); }
.delta.down { color: var(--critical-text); }
.delta.flat { color: var(--muted); }
.small-n { opacity: 0.5; }
.small-n-note { color: var(--muted); font-size: 11.5px; }

/* ── Charts ── */
.chart { position: relative; height: 220px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .val { fill: var(--text-2); font-weight: 600; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .bar { transition: opacity 0.1s; }
.chart .hit:hover + .bar, .chart .bar.hover { opacity: 0.8; }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); margin: -4px 0 8px; }
.legend .k { display: inline-block; width: 14px; height: 2px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

.tip {
    position: fixed; z-index: 50; pointer-events: none;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
    padding: 8px 10px; font-size: 12.5px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); min-width: 120px;
}
.tip .t-head { color: var(--text-2); margin-bottom: 4px; }
.tip .t-row { display: flex; align-items: center; gap: 8px; }
.tip .t-row b { font-variant-numeric: tabular-nums; }
.tip .t-row span { color: var(--text-2); }
.tip .t-key { width: 12px; height: 2px; border-radius: 2px; }

/* ── Bars in lists (funnel, screens, methods) ── */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar .row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.hbar .row .num { color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar .track { height: 8px; margin-top: 4px; }
.hbar .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--s1); min-width: 2px; }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.muted { color: var(--text-2); }
td.el { font-weight: 500; overflow-wrap: anywhere; }
.card:not(.flush) .table-scroll { margin: 0 -12px; }
.table-scroll { overflow-x: auto; }
.heat { display: inline-block; height: 6px; border-radius: 0 3px 3px 0; background: var(--s1); vertical-align: middle; margin-right: 8px; }
.heat.dead { background: var(--critical); }
.yes { color: var(--good-text); }
.no { color: var(--critical-text); }

/* ── Tap map ── */
.map-wrap { display: grid; grid-template-columns: 250px 1fr; gap: 20px; margin-top: 14px; align-items: start; }
.phone { border: 1px solid var(--axis); border-radius: 26px; padding: 10px; background: var(--page); }
.phone canvas { width: 100%; height: auto; display: block; border-radius: 16px; background: var(--surface-2); }
.key { margin-left: 12px; white-space: nowrap; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.dot.tap { background: var(--s1); }
.dot.dead { background: var(--critical); }

/* ── Errors ── */
.err { border-bottom: 1px solid var(--line); }
.err:last-child { border-bottom: 0; }
.err summary { list-style: none; cursor: pointer; padding: 12px 18px; display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; }
.err summary::-webkit-details-marker { display: none; }
.err summary:hover { background: var(--surface-2); }
.err .msg { font-weight: 500; overflow-wrap: anywhere; }
.err .meta { color: var(--muted); font-size: 12px; grid-column: 1; }
.err .cnt { grid-row: 1 / span 2; grid-column: 2; text-align: right; font-variant-numeric: tabular-nums; }
.err .cnt b { font-size: 18px; display: block; }
.err .cnt span { color: var(--muted); font-size: 12px; }
.err pre { font: inherit; font-size: 12.5px; margin: 0 18px 14px; padding: 10px 12px; background: var(--page); border-radius: 8px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); }
.kind { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); margin-right: 6px; }

/* ── Feedback ── */
.fb { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; margin-bottom: 12px; }
.fb .head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.fb .who { font-weight: 600; }
.fb .when { color: var(--muted); font-size: 12.5px; margin-left: auto; }
.fb .text { margin: 8px 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.fb .ctx { color: var(--muted); font-size: 12px; }
.kind.bug { background: rgba(208, 59, 59, 0.14); color: var(--critical-text); }
.kind.idea { background: var(--gold-tint); color: var(--gold); }

details.defs { color: var(--text-2); margin-top: 8px; font-size: 13px; }
details.defs summary { cursor: pointer; color: var(--muted); }
details.defs li { margin: 4px 0; }

/* ── Overview strips + errors drawer ── */
.pad-x { padding: 0 18px; }
.strip-h { color: var(--text-2); font-weight: 500; font-size: 13px; margin: 14px 0 8px; }
.strip-h .muted { color: var(--muted); font-weight: 400; }
details.drawer { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 18px; }
details.drawer > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 12px 0; }
details.drawer > summary::-webkit-details-marker { display: none; }
details.drawer > summary::before { content: "▸"; color: var(--muted); transition: transform 0.15s; }
details.drawer[open] > summary::before { transform: rotate(90deg); }
details.drawer > summary h2 { margin: 0; font-size: 17px; }
details.drawer .drawer-sum { color: var(--muted); font-size: 13px; }
details.drawer .card { margin-bottom: 16px; }
details.drawer .section-sub { margin-top: 0; }

@media (max-width: 760px) {
    .top { padding: 10px 16px; position: static; }
    main { padding: 8px 16px 60px; }
    .hero-row { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .map-wrap { grid-template-columns: 1fr; }
    .phone { max-width: 250px; }
    .jump { margin-left: 0; }
}
