[hidden] { display: none !important; }
:root {
  --font-display: 'Clash Grotesk', 'Satoshi', sans-serif;
  --font-body: 'Satoshi', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.5rem;

  --radius: 10px;
  --radius-lg: 16px;
  --ease: cubic-bezier(.2,.7,.2,1);
}

[data-theme="dark"] {
  --bg: #0d0d0c;
  --surface: #161614;
  --surface-2: #1e1e1b;
  --border: #2b2a26;
  --text: #f1eee6;
  --muted: #a19d92;
  --faint: #6d6a62;
  --accent: #ff4d1a;
  --accent-ink: #120700;
  --good: #7fd17a;
  --warn: #ffb020;
  --bad: #ff4d1a;
  --stage: #050505;
}

[data-theme="light"] {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #ece8de;
  --border: #d9d3c5;
  --text: #171612;
  --muted: #5d5a52;
  --faint: #8b877c;
  --accent: #d93a0b;
  --accent-ink: #ffffff;
  --good: #2f8a2b;
  --warn: #a86a00;
  --bad: #d93a0b;
  --stage: #141412;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.logo { width: 34px; height: 34px; }
.brand-text { font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; letter-spacing: .04em; }
.brand-text span { color: var(--muted); font-weight: 500; }
.badge {
  font-size: var(--text-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid var(--border); color: var(--muted); padding: 2px 8px; border-radius: 99px;
}
.topbar-spacer { flex: 1; }
.privacy-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-xs); color: var(--muted);
  padding: 5px 10px; border-radius: 99px; background: var(--surface);
  border: 1px solid var(--border);
}
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer;
}
.icon-btn:hover { border-color: var(--faint); }

/* Layout */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 24px;
  padding: 24px clamp(16px, 3vw, 32px);
  max-width: 1440px; width: 100%; margin: 0 auto;
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .privacy-pill { display: none; }
}

/* Stage */
.stage {
  position: relative;
  background: var(--stage);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  aspect-ratio: 16 / 10;
  overflow: hidden;
  max-height: calc(100dvh - 220px);
  min-height: 320px;
  width: 100%;
}
.dropzone {
  position: absolute; inset: 0; display: grid; place-items: center;
  background:
    radial-gradient(ellipse at 50% 120%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(255,255,255,.035) 39px 40px),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(255,255,255,.035) 39px 40px);
  color: #f1eee6;
  transition: background-color .2s var(--ease);
}
.dropzone.drag { outline: 2px dashed var(--accent); outline-offset: -14px; }
.dz-inner { text-align: center; padding: 24px; max-width: 440px; }
.dz-inner svg { color: var(--accent); }
.dz-inner h2 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); margin: 12px 0 4px; letter-spacing: .01em; }
.dz-inner p { color: #a19d92; margin: 0 0 20px; font-size: var(--text-sm); }
.dz-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.player { position: absolute; inset: 0; }
.player video, .player canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
}
.hud {
  position: absolute; left: 14px; top: 14px; display: flex; flex-direction: column; gap: 6px;
  pointer-events: none;
}
.hud .chip {
  font-family: var(--font-mono); font-size: var(--text-xs);
  background: rgba(10,10,9,.78); color: #f1eee6; border: 1px solid rgba(255,255,255,.12);
  padding: 4px 8px; border-radius: 6px; backdrop-filter: blur(4px);
}
.hud .chip.bad { border-color: var(--bad); color: #ffd2c4; }
.hud .chip.rep { color: #fff; font-weight: 600; }

.processing {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(5,5,5,.72); backdrop-filter: blur(2px);
}
.proc-card { width: min(360px, 86%); color: #f1eee6; }
.proc-title { font-weight: 700; margin-bottom: 10px; }
.proc-sub { color: #a19d92; font-size: var(--text-xs); margin-top: 8px; }
.bar { height: 6px; border-radius: 99px; background: rgba(255,255,255,.12); overflow: hidden; }
.bar-fill { height: 100%; width: 0%; background: var(--accent); transition: width .15s linear; }

/* Controls */
.controls {
  display: flex; align-items: center; gap: 12px; margin-top: 12px;
}
.timeline {
  position: relative; flex: 1; height: 34px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); cursor: pointer; overflow: hidden;
}
.tl-reps { position: absolute; inset: 0; }
.tl-rep {
  position: absolute; top: 6px; bottom: 6px; border-radius: 4px;
  background: color-mix(in srgb, var(--good) 35%, transparent);
  border: 1px solid color-mix(in srgb, var(--good) 70%, transparent);
  font-family: var(--font-mono); font-size: 10px; color: var(--text);
  display: grid; place-items: center; overflow: hidden;
}
.tl-rep.flag {
  background: color-mix(in srgb, var(--bad) 30%, transparent);
  border-color: color-mix(in srgb, var(--bad) 80%, transparent);
}
.tl-head { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); left: 0; pointer-events: none; }
.time { font-size: var(--text-sm); color: var(--muted); min-width: 40px; text-align: right; }
.select-sm {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px; font-size: var(--text-sm); font-family: var(--font-mono);
}
.attribution { color: var(--faint); font-size: var(--text-xs); margin: 8px 2px 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 10px; padding: 11px 18px; font-weight: 700; font-size: var(--text-sm);
  border: 1px solid transparent; cursor: pointer; transition: transform .12s var(--ease), background .15s, border-color .15s, opacity .15s;
  letter-spacing: .01em;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .35; cursor: not-allowed; filter: none; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.dropzone .btn-ghost { color: #f1eee6; border-color: rgba(255,255,255,.22); }
.btn-ghost:hover { border-color: var(--faint); }
.btn-ghost:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 7px 12px; font-size: var(--text-xs); }
.btn-icon { width: 38px; height: 38px; padding: 0; background: var(--accent); color: var(--accent-ink); border-radius: 10px; }
.btn-block { width: 100%; margin-top: 16px; padding: 14px; font-size: var(--text-base); }

/* Panels */
.side-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px;
}
.panel-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.panel-head h3 { margin: 0; font-size: var(--text-lg); font-weight: 700; }
.step { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--accent); }

.lift-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.lift {
  text-align: left; padding: 10px 12px; border-radius: 10px; cursor: pointer;
  background: var(--surface-2); border: 1px solid transparent;
  display: flex; flex-direction: column; gap: 2px;
  transition: border-color .15s, background .15s;
}
.lift:hover { border-color: var(--border); }
.lift[aria-checked="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); }
.lift b { font-size: var(--text-sm); }
.lift span { font-size: var(--text-xs); color: var(--muted); }

.film-tip {
  margin-top: 14px; padding: 12px 14px; border-radius: 10px;
  background: var(--surface-2); font-size: var(--text-sm); color: var(--muted);
  display: flex; gap: 10px;
}
.film-tip svg { flex: none; color: var(--accent); margin-top: 2px; }
.film-tip b { color: var(--text); }

/* Results */
.results { animation: rise .35s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.score-row { display: flex; gap: 18px; align-items: center; }
.score-ring { position: relative; width: 112px; height: 112px; flex: none; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset .9s var(--ease), stroke .3s; }
.score-num { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.score-num span { font-family: var(--font-display); font-weight: 700; font-size: 2.25rem; line-height: 1; }
.score-num small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-top: 4px; }
.score-meta { flex: 1; min-width: 0; }
.verdict { font-weight: 700; font-size: var(--text-lg); line-height: 1.3; margin-bottom: 10px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0; }
.kpis dt { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.kpis dd { margin: 0; font-size: var(--text-base); font-weight: 600; }

.section-label {
  font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); margin: 22px 0 10px;
}
.fixes { display: flex; flex-direction: column; gap: 10px; }
.fix {
  border: 1px solid var(--border); border-left: 3px solid var(--bad); border-radius: 10px;
  padding: 12px 14px; background: var(--surface-2); cursor: pointer;
}
.fix.warn { border-left-color: var(--warn); }
.fix.good { border-left-color: var(--good); cursor: default; }
.fix-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.fix h4 { margin: 0; font-size: var(--text-sm); font-weight: 700; }
.fix .count { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); white-space: nowrap; }
.fix .cue { margin: 6px 0 0; font-size: var(--text-sm); color: var(--text); }
.fix .drill { margin: 6px 0 0; font-size: var(--text-xs); color: var(--muted); }
.fix .drill b { color: var(--text); }

.table-wrap { overflow-x: auto; }
.reps-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.reps-table th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 6px 6px; border-bottom: 1px solid var(--border); }
.reps-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: var(--text-xs); vertical-align: top; }
.reps-table tr { cursor: pointer; }
.reps-table tr:hover td { background: var(--surface-2); }
.flag-tag { display: inline-block; font-family: var(--font-body); font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; margin: 0 4px 3px 0; background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--text); }
.ok-tag { color: var(--good); font-family: var(--font-body); font-weight: 600; font-size: 11px; }

.coach-cta {
  margin-top: 20px; padding: 14px; border-radius: 10px; border: 1px dashed var(--border);
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
}
.coach-cta strong { font-size: var(--text-sm); }
.coach-cta p { margin: 2px 0 0; font-size: var(--text-xs); color: var(--muted); }

.notice { padding: 12px 14px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 14%, var(--surface-2)); font-size: var(--text-sm); margin-top: 12px; }

.foot { padding: 16px clamp(16px, 3vw, 32px) 28px; color: var(--faint); font-size: var(--text-xs); max-width: 1440px; margin: 0 auto; width: 100%; }
.foot p { margin: 0; max-width: 80ch; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@media (max-width: 600px) {
  .badge { display: none; }
  .brand-text { font-size: 1rem; white-space: nowrap; }
  .controls { flex-wrap: wrap; }
  .timeline { flex: 1 1 100%; order: -1; }
  .time { margin-right: auto; text-align: left; }
  .stage { min-height: 240px; }
  .score-row { gap: 14px; }
  .score-ring { width: 96px; height: 96px; }
  .score-num span { font-size: 1.9rem; }
}
body { overflow-x: hidden; }
.layout > * { min-width: 0; }
.stage-msg { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(5,5,5,.86); padding: 20px; }
.msg-card { max-width: 460px; color: #f1eee6; text-align: center; }
.msg-card strong { font-size: var(--text-lg); }
.msg-card p { color: #c9c4b8; font-size: var(--text-sm); margin: 8px 0 16px; }
.status { margin-top: 12px; font-size: var(--text-sm); color: var(--muted); padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
.status.ok { color: var(--text); border-left: 3px solid var(--good); }
.status.warn { color: var(--text); border-left: 3px solid var(--warn); }
.status.error { color: var(--text); border-left: 3px solid var(--bad); }
.ios-tip {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.ios-tip strong { font-size: var(--text-sm); }
.ios-tip p { margin: 2px 0 0; font-size: var(--text-xs); color: var(--muted); }
.topbar { padding-top: max(14px, env(safe-area-inset-top)); }
