:root {
  --bg: #0b0d12; --panel: #141821; --panel2: #1b2130; --line: #2a3142;
  --ink: #f2f4f8; --mute: #9aa3b5; --ball: #ff6b1a; --ghost: #3ee6ff; --good: #3ddc84; --warn: #ffc542; --bad: #ff5a5f;
  --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  max-width: 760px; margin: 0 auto; min-height: 100vh;
  padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 10px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark { width: 36px; height: 36px; color: var(--ghost); }
.brand b { display: block; font: 800 20px/1 "Arial Narrow", "Roboto Condensed", system-ui, sans-serif; letter-spacing: .08em; }
.brand small { color: var(--mute); font-size: 12px; }
.badge { font-size: 12px; color: var(--mute); border: 1px solid var(--line); padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.badge.ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.badge.busy { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }

.tabs { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  background: var(--bg); padding: 6px 0 10px; }
.tabs button { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 4px; font-weight: 600; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--ball); border-color: var(--ball); color: #fff; }

.panel { display: none; }
.panel[data-active] { display: block; }
.row { display: flex; gap: 8px; margin: 10px 0; align-items: flex-end; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 160px; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--mute); margin: 8px 0; }
.field select, .field input[type=text], .field input:not([type]) {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; color: var(--ink); font-size: 16px; width: 100%;
}
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink); margin: 10px 0; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--ball); }

.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; font-weight: 600; cursor: pointer; min-height: 46px; }
.btn.primary { background: var(--ball); border-color: var(--ball); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: default; }
.btn[aria-pressed="false"] { color: var(--mute); }

.stage { position: relative; background: #000; border-radius: var(--r); overflow: hidden; aspect-ratio: 3 / 4; margin: 8px 0; border: 1px solid var(--line); }
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stage.mirror video, .stage.mirror canvas { transform: scaleX(-1); }
.stage-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--mute); }
.stage-empty b { color: var(--ink); }
.hud { position: absolute; left: 10px; right: 10px; bottom: 10px; display: grid; grid-template-columns: auto auto 1fr; gap: 8px; }
.hud > div { background: rgba(11,13,18,.78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-radius: 12px; padding: 8px 12px; }
.hud span { display: block; font-size: 11px; color: var(--mute); }
.hud b { font-size: 22px; }
.hud .cue { display: flex; align-items: center; font-weight: 700; font-size: 15px; color: var(--ghost); }
.hud .cue.flash { animation: flash .9s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--ball) 70%, transparent); color: #fff; } }

.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; border: 2px dashed var(--line); border-radius: var(--r);
  padding: 22px 16px; margin: 10px 0; cursor: pointer; background: var(--panel); }
.drop b { color: var(--ball); font-size: 16px; }
.drop span { color: var(--mute); font-size: 13px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.progress { position: relative; height: 34px; border-radius: 10px; background: var(--panel); overflow: hidden; margin: 8px 0; border: 1px solid var(--line); }
.progress i { position: absolute; inset: 0 auto 0 0; width: 0; background: color-mix(in srgb, var(--ball) 45%, transparent); transition: width .2s; }
.progress span { position: relative; display: block; padding: 7px 12px; font-size: 13px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 10px 0; }
.score { display: flex; gap: 14px; align-items: center; }
.ring { --p: 0; width: 92px; height: 92px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--c, var(--ball)) calc(var(--p) * 1%), var(--panel2) 0); }
.ring b { width: 74px; height: 74px; border-radius: 50%; background: var(--panel); display: grid; place-items: center; font-size: 26px; }
.score .meta { font-size: 13px; color: var(--mute); }
.score .meta b { color: var(--ink); font-size: 16px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--ball); color: var(--ball); }
.fix { border-left: 3px solid var(--ball); padding: 8px 0 8px 12px; margin: 10px 0; }
.fix h4 { margin: 0 0 2px; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; }
.fix h4 span { color: var(--ball); font-weight: 600; white-space: nowrap; }
.fix p { margin: 2px 0; }
.fix .drill { color: var(--mute); font-size: 13px; }
.ok-note { color: var(--good); }

table.metrics { width: 100%; border-collapse: collapse; font-size: 13px; }
table.metrics th { text-align: left; color: var(--mute); font-weight: 500; padding: 6px 4px; }
table.metrics td { padding: 7px 4px; border-top: 1px solid var(--line); vertical-align: middle; }
table.metrics td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.gapbar { position: relative; height: 8px; background: var(--panel2); border-radius: 4px; min-width: 60px; }
.gapbar::before { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--mute); }
.gapbar i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.muted { color: var(--mute); }
.ignored td { opacity: .45; }

.player { position: relative; background: #000; border-radius: var(--r); overflow: hidden; margin: 8px 0; }
.player video, .player canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--mute); margin: 4px 2px; }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

.feed .item { display: flex; justify-content: space-between; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; margin: 6px 0; font-size: 14px; }
.feed .item small { color: var(--mute); display: block; }
.feed .item .pct { font-weight: 800; font-size: 18px; }
.empty { color: var(--mute); text-align: center; padding: 18px; border: 1px dashed var(--line); border-radius: var(--r); }
h2 { font-size: 20px; margin: 14px 0 6px; }
h3.sub { font-size: 14px; color: var(--mute); font-weight: 600; margin: 18px 0 4px; text-transform: uppercase; letter-spacing: .06em; }
.prose h3 { margin: 18px 0 4px; }
.prose p, .prose li { color: #d6dae3; }
.foot { text-align: center; color: var(--mute); font-size: 12px; margin-top: 28px; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--panel2);
  border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 20; max-width: calc(100% - 32px); font-size: 14px; }
.repline { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.repline:first-child { border-top: 0; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.statgrid div { background: var(--panel2); border-radius: 10px; padding: 8px 10px; font-size: 12px; color: var(--mute); }
.statgrid b { display: block; color: var(--ink); font-size: 15px; }
.statgrid button { margin-top: 4px; }
