:root {
  --bg: #0b0b0b;
  --surface: #141414;
  --surface-2: #1c1c1c;
  --line: rgba(255, 255, 255, 0.08);
  --text: #ededed;
  --muted: #8a8a8a;
  --faint: #555;
  --good: #a8d5ba;
  --ok: #e3d3a3;
  --bad: #e3a3a3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  font-weight: 400;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Top bar */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 20px 32px;
}
.topbar h1 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.status { font-size: 12px; color: var(--faint); white-space: nowrap; }
.status.ready { color: var(--muted); }
.status-row { display: flex; align-items: center; gap: 16px; }
.status.listening { color: var(--text); display: flex; align-items: center; gap: 6px; }
.status.listening::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

main { padding: 0 32px 40px; max-width: 1600px; margin: 0 auto; }

/* Stage */
.stage { display: flex; align-items: stretch; }
@media (max-width: 900px) {
  .stage { flex-direction: column; gap: 12px; }
  .screen { height: 56vh; min-height: 280px; }
  .controls { gap: 16px; }
  main, .topbar { padding-left: 16px; padding-right: 16px; }
}

/* Two cards with a draggable divider between them; app.js sets each card's flex-grow from the split */
.panel {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  flex: 1 1 0; transition: flex-grow .35s cubic-bezier(.3, .7, .2, 1), flex-basis .35s cubic-bezier(.3, .7, .2, 1);
}
.panel-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* a closed card shrinks to a ~half-inch strip with just its name */
.strip {
  display: none; flex: 1; border: 0; border-radius: 16px; cursor: pointer; padding: 18px 0;
  background: var(--surface); color: rgba(255, 255, 255, 0.6);
  font: inherit; font-size: 11px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase;
  writing-mode: vertical-rl; text-align: start; transition: background .15s, color .15s;
}
#refPanel .strip { transform: rotate(180deg); text-align: end; }
.strip:hover { background: var(--surface-2); color: var(--text); }
.panel.closed { flex: 0 0 48px !important; }
.panel.closed .strip { display: block; flex: none; height: calc(100vh - 230px); min-height: 360px; }
.panel.closed .panel-body { display: none; }
.stage.dragging .panel, .stage.dragging .screen { transition: none; }
.stage.dragging { cursor: col-resize; user-select: none; }

.divider-handle {
  flex: none; width: 14px; position: relative; cursor: col-resize; touch-action: none; outline: none;
}
.divider-handle::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 44px; border-radius: 4px;
  transform: translate(-50%, -50%); background: rgba(255, 255, 255, 0.18); transition: background .15s, height .15s;
}
.divider-handle:hover::after, .divider-handle:focus-visible::after, .stage.dragging .divider-handle::after {
  background: var(--text); height: 64px;
}

/* one card closed: the other gets more height too */
.stage.single .screen { height: calc(100vh - 230px); min-height: 360px; }
.screen { transition: height .35s cubic-bezier(.3, .7, .2, 1); }

@media (max-width: 900px) {
  .divider-handle { display: none; }
  .panel, .panel.closed { flex: none !important; }
  .panel.closed .strip { display: none; }
  .panel.closed .panel-body { display: flex; }
}

.label {
  position: absolute; top: 16px; left: 18px; z-index: 2; pointer-events: none;
  font-size: 11px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75); text-shadow: 0 0 8px rgba(0, 0, 0, 0.6), 0 1px 2px rgba(0, 0, 0, 0.5);
}

.screen {
  position: relative; display: flex; justify-content: center; align-items: center;
  background: #000; border-radius: 16px; overflow: hidden;
  min-height: 360px; height: min(72vh, 820px);
}
.screen canvas { display: block; width: 100%; height: 100%; }

/* hidden-but-decoding media elements */
#refVideo, #camVideo { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.chip {
  font: inherit; font-size: 12px; color: var(--text); white-space: nowrap;
  padding: 6px 12px; border-radius: 999px; border: 0; cursor: pointer;
  background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(10px);
}
.actions { position: absolute; top: 10px; right: 12px; z-index: 3; display: flex; align-items: center; gap: 6px; }
.chip.timing { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 2; cursor: default; }
.chip.heard { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 3; cursor: default; font-size: 13px; padding: 7px 16px; background: rgba(0, 0, 0, 0.6); }
.chip.timing.good { color: var(--text); }
.chip.timing.warn { color: var(--ok); }

.placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; color: var(--muted); cursor: pointer; padding: 24px;
  background: var(--surface); transition: background .2s;
  font-size: 13px;
}
.placeholder:hover, .placeholder.drag { background: var(--surface-2); }
.placeholder strong { color: var(--text); font-size: 17px; font-weight: 500; }
.placeholder .primary-btn { margin-top: 14px; }

.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 24px; background: rgba(0, 0, 0, 0.6); font-size: 12px; color: var(--muted);
}
.overlay strong { color: var(--text); font-weight: 500; font-size: 14px; }
.progress { width: min(260px, 60%); height: 2px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
#analyzeBar { height: 100%; width: 0; background: var(--text); transition: width .1s; }

.scrub-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.scrub-row input { flex: 1; }

input[type="range"] { -webkit-appearance: none; appearance: none; height: 2px; background: rgba(255, 255, 255, 0.15); border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--text); cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--text); cursor: pointer; }
input[type="range"]:disabled { opacity: .4; }

/* Live overlays */
.score-badge {
  padding: 6px 14px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(10px);
  display: flex; align-items: baseline; gap: 6px;
}
.score-badge span { font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; }
.score-badge small { color: var(--muted); font-size: 11px; }
.score-badge.good span, .rev-score.good { color: var(--good); }
.score-badge.ok span, .rev-score.ok { color: var(--ok); }
.score-badge.bad span, .rev-score.bad { color: var(--bad); }

.cues { position: absolute; left: 16px; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; z-index: 2; }
.cue {
  padding: 8px 14px; border-radius: 10px; font-weight: 500; font-size: 14px;
  background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(10px);
  animation: pop .2s ease-out;
}
.cue.praise { color: var(--good); }
.cue.info { color: var(--muted); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }

.countdown {
  position: absolute; inset: 0; z-index: 4; display: grid; place-items: center;
  font-size: 120px; font-weight: 300; background: rgba(0, 0, 0, 0.5);
}

/* Controls */
.controls {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 22px;
  margin-top: 24px;
}
.divider { width: 1px; height: 18px; background: var(--line); }
.field, .toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle:has(input:checked) { color: var(--text); }

.toggle input {
  -webkit-appearance: none; appearance: none; margin: 0; cursor: pointer;
  width: 26px; height: 16px; border-radius: 999px; background: var(--surface-2); position: relative; transition: background .2s;
}
.toggle input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--faint); transition: transform .2s, background .2s;
}
.toggle input:checked { background: var(--text); }
.toggle input:checked::after { transform: translateX(10px); background: var(--bg); }

select {
  background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 8px; font: inherit; font-size: 13px; cursor: pointer;
}
select option { background: var(--surface); }

.primary-btn, .ghost-btn {
  font: inherit; font-weight: 500; font-size: 13px; border-radius: 999px; cursor: pointer;
  padding: 9px 18px; border: 0; text-decoration: none; transition: opacity .15s, background .15s;
}
.primary-btn { background: var(--text); color: var(--bg); }
.primary-btn:hover:not(:disabled) { opacity: .85; }
.primary-btn.big { font-size: 14px; padding: 11px 32px; min-width: 120px; }
.primary-btn:disabled { opacity: .25; cursor: not-allowed; }
.primary-btn.stop { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4); }
.ghost-btn { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.ghost-btn:hover { background: var(--surface-2); }

.hint { color: var(--faint); font-size: 12px; text-align: center; margin-top: 18px; }
.hidden { display: none !important; }

button:focus-visible, select:focus-visible, input:focus-visible { outline: 1px solid var(--text); outline-offset: 2px; }

/* Summary */
dialog {
  width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 20px; padding: 32px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(6px); }
.sum-head { display: flex; align-items: center; gap: 24px; margin-bottom: 12px; }
.sum-head h2 { margin: 0 0 4px; font-size: 22px; font-weight: 500; letter-spacing: -0.01em; }
.sum-head p { margin: 0; color: var(--muted); font-size: 14px; }
.sum-score {
  width: 104px; height: 104px; border-radius: 50%; display: grid; place-content: center; text-align: center; flex: none;
  background: conic-gradient(var(--text) var(--pct, 0%), var(--surface-2) 0); position: relative;
}
.sum-score::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--surface); }
.sum-score span, .sum-score small { position: relative; }
.sum-score span { font-size: 32px; font-weight: 400; line-height: 1; }
.sum-score small { color: var(--muted); font-size: 11px; }
dialog h3 { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 28px 0 12px; }
.sum-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media (max-width: 700px) { .sum-grid { grid-template-columns: 1fr; } dialog { padding: 22px; } }
.sum-list { margin: 0; padding: 0; list-style: none; font-size: 14px; line-height: 1.5; }
.sum-list li { padding: 8px 0; border-top: 1px solid var(--line); color: var(--text); }
.sum-list li:first-child { border-top: 0; padding-top: 0; }
.sum-list li span { color: var(--muted); }

/* Review player: your take next to the reference, one shared timeline */
.review { margin-top: 20px; }
.review-videos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 700px) { .review-videos { grid-template-columns: 1fr; } }
.review-pane { position: relative; background: #000; border-radius: 12px; overflow: hidden; height: min(44vh, 440px); }
.review-pane video { width: 100%; height: 100%; object-fit: contain; display: block; }
.review-pane canvas { width: 100%; height: 100%; display: block; }
.review-pane .rev-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.rev-score { position: absolute; top: 10px; right: 12px; z-index: 2; cursor: default; font-variant-numeric: tabular-nums; }
.review-note { display: flex; gap: 14px; align-items: baseline; padding: 14px 2px 10px; font-size: 15px; min-height: 48px; }
.review-note .t { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; flex: none; width: 52px; }
.review-transport { display: flex; align-items: center; gap: 8px; }
.rev-play { min-width: 74px; }
.rev-step { width: 34px; padding: 6px 0; font-size: 16px; line-height: 1; }
.review-track { position: relative; flex: 1; height: 28px; margin: 0 6px; }
.review-track canvas { position: absolute; left: 0; right: 0; top: 50%; width: 100%; height: 6px; transform: translateY(-50%); border-radius: 3px; }
.review-track input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; background: transparent; }
.rev-dur { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.moment .t.seek { background: none; border: 0; color: var(--text); font: inherit; font-weight: 500; cursor: pointer; padding: 0; text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.moment { border-top: 1px solid var(--line); padding: 12px 0; display: flex; align-items: center; gap: 14px; font-size: 13px; }
.moment:first-child { border-top: 0; padding-top: 0; }
.moment .t { font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.moment .tip { flex: 1; color: var(--muted); }
.moment .tip b { color: var(--text); font-weight: 500; }
.moment .ghost-btn { padding: 6px 12px; font-size: 12px; }
.sum-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; flex-wrap: wrap; }
