:root {
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242422; --line: #2e2e2b; --ink: #fff; --ink-2: #c3c2b7; --muted: #8f8d86;
  --accent: #3987e5; --good: #0ca30c; --warn: #fab219; --bad: #d03b3b; --r: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--page); color: var(--ink); font: 17px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
.view { max-width: 640px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.9rem; line-height: 1.15; margin: .3rem 0 .4rem; }
h2 { font-size: 1.2rem; margin: 1.6rem 0 .6rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.brand { font-weight: 800; letter-spacing: .02em; display: flex; align-items: center; gap: .45rem; color: var(--ink-2); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(12,163,12,.25); }
.hero { margin-bottom: 1rem; }

.weight { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .9rem 1rem; }
.weight label { font-weight: 700; }
.w-row { display: flex; gap: .6rem; margin-top: .4rem; }
.w-row input { flex: 1; min-width: 0; font-size: 1.6rem; font-weight: 800; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: .35rem .7rem; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: none; padding: 0 1rem; border-radius: 9px; min-height: 44px; color: var(--ink-2); font-weight: 700; cursor: pointer; }
.seg button.on { background: var(--ink); color: #000; }

.actions { display: grid; gap: .7rem; margin: 1rem 0; }
.big-btn { display: flex; align-items: center; justify-content: center; gap: .6rem; min-height: 64px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-2); font-size: 1.15rem; font-weight: 800; cursor: pointer; text-align: center; padding: .6rem 1rem; }
.big-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.big-btn.stop { background: var(--bad); border-color: var(--bad); }
.big-btn .ic { font-size: 1rem; }
.btn { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 1.1rem; font-weight: 700; cursor: pointer; }
.btn.danger { color: #ff8a8a; border-color: rgba(208,59,59,.6); background: none; }
.link { background: none; border: 0; color: var(--accent); padding: .4rem 0; cursor: pointer; min-height: 44px; }
.link.danger { color: #ff8a8a; }

.tips { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .7rem 1rem; }
.tips summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.tips ol { margin: .5rem 0 .2rem; padding-left: 1.2rem; display: grid; gap: .3rem; color: var(--ink-2); }

/* history */
.trend { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem 1rem; }
.trend svg { width: 100%; height: 120px; display: block; }
.trend .k { color: var(--muted); font-size: .85rem; }
.sets { display: grid; gap: .5rem; margin-top: .7rem; }
.set-row { display: grid; grid-template-columns: 1fr auto; gap: .2rem .8rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .7rem .9rem; text-decoration: none; color: var(--ink); }
.set-row .big { font-size: 1.25rem; font-weight: 800; }
.set-row .sub { color: var(--muted); font-size: .85rem; }
.badge { min-width: 48px; text-align: center; font-weight: 800; border-radius: 999px; padding: .2rem .6rem; border: 2px solid; grid-row: span 2; }
.b-good { color: #7ee07e; border-color: var(--good); } .b-warn { color: var(--warn); border-color: var(--warn); } .b-bad { color: #ff8a8a; border-color: var(--bad); } .b-none { color: var(--muted); border-color: var(--line); }
.empty { text-align: center; color: var(--muted); padding: 1.4rem 0; }

.foot { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: center; border-top: 1px solid var(--line); padding-top: 1rem; }
.foot label { display: flex; align-items: center; gap: .4rem; min-height: 44px; }
.foot input[type=checkbox] { width: 22px; height: 22px; }
.foot select { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: .4rem .6rem; min-height: 44px; }
.foot p { width: 100%; margin: 0; }

/* run */
.stage { position: relative; background: #000; border-radius: var(--r); overflow: hidden; aspect-ratio: 9 / 16; max-height: 70vh; margin: 0 auto; display: flex; align-items: center; justify-content: center; }
.stage video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.stage canvas { width: 100%; height: 100%; object-fit: contain; }
.count { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 8rem; font-weight: 900; text-shadow: 0 4px 20px rgba(0,0,0,.7); }
.progress { margin-top: .7rem; background: var(--surface); border-radius: 12px; padding: .6rem .8rem; display: grid; gap: .35rem; font-weight: 700; }
.progress .bar { height: 8px; background: rgba(255,255,255,.2); border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }
.status { min-height: 1.5em; text-align: center; font-weight: 700; margin: .7rem 0; }
.run-actions { display: grid; gap: .6rem; }

/* set review */
.back { display: inline-flex; min-height: 44px; align-items: center; color: var(--ink-2); text-decoration: none; }
.verdict { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; display: grid; grid-template-columns: 1fr auto; gap: .4rem 1rem; align-items: center; }
.verdict .num { font-size: 3.4rem; font-weight: 900; line-height: 1; }
.verdict .lbl { color: var(--ink-2); font-weight: 700; }
.score-ring { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-size: 1.7rem; font-weight: 900; border: 6px solid; grid-row: span 2; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .6rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .55rem .6rem; }
.stat .k { color: var(--muted); font-size: .75rem; } .stat .v { font-weight: 800; font-size: 1.1rem; }
.coach { margin-top: .8rem; border-radius: var(--r); padding: .9rem 1rem; background: rgba(57,135,229,.12); border: 1px solid rgba(57,135,229,.55); }
.coach b { display: block; margin-bottom: .2rem; }
.player { margin-top: .8rem; background: #000; border-radius: var(--r); overflow: hidden; }
.player video { width: 100%; display: block; max-height: 60vh; background: #000; }
.marks { position: relative; height: 26px; background: var(--surface); cursor: pointer; }
.marks .m { position: absolute; top: 5px; width: 8px; height: 16px; margin-left: -4px; border-radius: 3px; }
.m.good { background: var(--good); } .m.warn { background: var(--warn); } .m.bad { background: var(--bad); }
.reps { display: grid; gap: .45rem; margin-top: .5rem; }
.rep { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: .2rem .6rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .55rem .7rem; cursor: pointer; text-align: left; width: 100%; }
.rep .n { font-weight: 900; font-size: 1.1rem; color: var(--ink-2); }
.rep .sb { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.rep .sb i { display: block; height: 100%; border-radius: 5px; }
.rep .sc { font-weight: 800; min-width: 2.5rem; text-align: right; }
.rep .why { grid-column: 2 / 4; color: var(--ink-2); font-size: .88rem; }
.w-edit { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .8rem; }
.w-edit input { width: 7rem; font-size: 1.1rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: .45rem .6rem; }
.row-btns { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.2rem; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--line); padding: .7rem 1.1rem; border-radius: 999px; z-index: 50; max-width: calc(100% - 32px); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
