.viz-root {
  color-scheme: light;
  --surface-0: #f3f2ef; --surface-1: #fcfcfb; --surface-2: #f0efec; --border: #e2e1dc; --grid: #e8e7e2; --axis: #b9b8b1;
  --text-primary: #0b0b0b; --text-secondary: #52514e; --text-muted: #7a7974;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --good: #0ca30c; --warning: #fab219; --critical: #d03b3b;
  --good-bg: #e3f4e3; --warning-bg: #fdf1d3; --critical-bg: #f9e1e1;
  --btn: #0b0b0b; --btn-text: #fcfcfb; --fov: rgba(42,120,214,0.07);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --surface-0: #111110; --surface-1: #1a1a19; --surface-2: #242422; --border: #2e2e2c; --grid: #2a2a28; --axis: #55554f;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --good-bg: #12301a; --warning-bg: #3a2f10; --critical-bg: #3a1717;
    --btn: #f0efec; --btn-text: #1a1a19; --fov: rgba(57,135,229,0.10);
  }
}
:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --surface-0: #111110; --surface-1: #1a1a19; --surface-2: #242422; --border: #2e2e2c; --grid: #2a2a28; --axis: #55554f;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --good-bg: #12301a; --warning-bg: #3a2f10; --critical-bg: #3a1717;
  --btn: #f0efec; --btn-text: #1a1a19; --fov: rgba(57,135,229,0.10);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #f3f2ef; }
.viz-root { min-height: 100vh; background: var(--surface-0); color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 14px 16px 60px; }
header.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
h1 { font-size: 19px; margin: 0; font-weight: 680; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 620; }
h3 { font-size: 13px; margin: 14px 0 6px; font-weight: 600; color: var(--text-secondary); }
.hint { color: var(--text-muted); font-size: 12.5px; font-weight: 400; }
.spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); white-space: nowrap; }
.pill.good { background: var(--good-bg); border-color: transparent; color: var(--text-primary); }
.pill.warn { background: var(--warning-bg); border-color: transparent; color: var(--text-primary); }
.pill.bad { background: var(--critical-bg); border-color: transparent; color: var(--text-primary); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: none; }
.good .dot { background: var(--good); } .warn .dot { background: var(--warning); } .bad .dot { background: var(--critical); }
nav#tabs { display: flex; gap: 4px; margin: 12px 0 14px; overflow-x: auto; border-bottom: 1px solid var(--border); }
nav#tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 8px 8px 0 0; color: var(--text-secondary);
  font: inherit; cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent; }
nav#tabs button.on { color: var(--text-primary); border-bottom-color: var(--text-primary); font-weight: 600; }
button, select, input, textarea { font: inherit; color: var(--text-primary); }
button.btn, .btn { border-radius: 8px; padding: 6px 12px; cursor: pointer; border: 1px solid var(--border); background: var(--surface-1); }
button.btn.primary { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }
button.btn.small { padding: 2px 8px; font-size: 12.5px; }
button.btn:disabled { opacity: .45; cursor: default; }
select, input[type=text], input[type=number], input[type=password], textarea { background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px; }
input[type=number] { width: 84px; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 12px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.tile .label { color: var(--text-secondary); font-size: 12px; }
.tile .value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .sub { color: var(--text-muted); font-size: 12px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-secondary); font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; }
.scroll { overflow-x: auto; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chk { display: inline-flex; gap: 6px; align-items: center; color: var(--text-secondary); font-size: 13px; }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.steps li:last-child { border-bottom: 0; }
.steps .n { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center;
  font-weight: 600; font-size: 12.5px; flex: none; }
.steps .t { font-weight: 600; } .steps .d { color: var(--text-secondary); font-size: 13px; }
.steps .s { margin-left: auto; flex: none; }
.matrix td, .matrix th { text-align: center; border: 2px solid var(--surface-1); padding: 6px 4px; min-width: 76px; }
.matrix td { border-radius: 8px; font-size: 12.5px; }
.matrix td b { display: block; font-size: 12px; }
.cell-good { background: var(--good-bg); } .cell-fair { background: var(--warning-bg); } .cell-weak { background: var(--critical-bg); }
.cell-none { background: var(--surface-2); color: var(--text-muted); }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--series-1); border-radius: 4px; }
canvas { display: block; width: 100%; touch-action: none; }
.coach { text-align: center; padding: 22px 14px; }
.coach .phase { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); }
.coach .say { font-size: clamp(22px, 4.2vw, 38px); font-weight: 650; line-height: 1.2; margin: 10px auto 6px; max-width: 22ch; }
.coach .count { font-size: clamp(48px, 10vw, 92px); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.coach .next { color: var(--text-muted); margin-top: 10px; }
.coach.run { border-color: var(--critical); box-shadow: inset 0 0 0 2px var(--critical); }
#coachbar { position: sticky; top: 0; z-index: 5; background: var(--btn); color: var(--btn-text); padding: 8px 16px;
  display: flex; gap: 12px; align-items: center; font-weight: 600; }
#coachbar .c { margin-left: auto; font-variant-numeric: tabular-nums; }
.camwrap { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 4 / 3; }
.camwrap img, .camwrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--text-secondary); } .kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.probs div { display: grid; grid-template-columns: 78px 1fr 40px; gap: 8px; align-items: center; font-size: 12.5px; margin: 3px 0; }
#login { position: fixed; inset: 0; background: var(--surface-0); display: grid; place-items: center; z-index: 20; }
#login form { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 22px; width: min(92vw, 340px);
  display: grid; gap: 10px; }
pre.log { background: var(--surface-2); padding: 10px; border-radius: 8px; overflow: auto; max-height: 320px; font-size: 12px; white-space: pre-wrap; }
.err { color: var(--critical); }
@media (max-width: 860px) {
  .grid2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}
