/* ========================================
   PRACTICE — practice-*, ctrl-*, subs-*,
   stt-*, mode-*, progress-*, recording,
   results, player, game bars
   ======================================== */

/* --- Practice page layout --- */
.practice-layout {
  display: flex; gap: 1rem; max-width: 1100px; margin: 0 auto;
}
body:has(.practice-layout) { max-width: 1100px; }

/* Episode progress bar */
.episode-progress {
  display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem;
  font-size: 0.85rem; color: var(--muted);
}
.episode-progress .progress-bar-bg { flex: 1; }

/* Segment sidebar */
.seg-sidebar {
  width: 180px; flex-shrink: 0; position: sticky; top: 1rem; align-self: flex-start;
  max-height: calc(100vh - 6rem); overflow-y: auto;
}
.seg-sidebar-header h3 { font-size: 0.95rem; }
.seg-list { list-style: none; padding: 0; }
.seg-item {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.6rem;
  border-radius: var(--radius); text-decoration: none; color: var(--fg);
  font-size: 0.85rem; transition: background 0.15s;
}
.seg-item:hover { background: #e5e7eb; text-decoration: none; }
.seg-current { background: #dbeafe; font-weight: 600; }
.seg-dot {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700; color: var(--muted); flex-shrink: 0;
  background: var(--card-bg);
}
.seg-dot.seg-partial { border-color: var(--warning); color: var(--warning); background: #fef9c3; }
.seg-dot.seg-complete { border-color: var(--success); background: var(--success); color: #fff; }
.seg-label { flex: 1; }
.seg-time { white-space: nowrap; }
.seg-toggle { display: none; margin-bottom: 0.5rem; }

/* Main practice area */
.practice-main { flex: 1; min-width: 0; }

/* Mobile: sidebar overlay */
@media (max-width: 700px) {
  .practice-layout { flex-direction: column; }
  .seg-sidebar {
    position: fixed; top: 0; left: -260px; width: 250px; height: 100vh;
    background: var(--card-bg); z-index: 100; padding: 1rem;
    box-shadow: 2px 0 12px rgba(0,0,0,.15); transition: left 0.25s;
    max-height: 100vh;
  }
  .seg-sidebar.open { left: 0; }
  .seg-toggle { display: inline-block; }
}

/* ========================================================================
   STEPS / GAME BAR
   ======================================================================== */
.steps { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.step-badge {
  padding: 0.4rem 0.75rem; border-radius: 999px; font-size: 0.8rem;
  font-weight: 600; border: none; cursor: pointer; display: flex;
  align-items: center; gap: 0.35rem; transition: all 0.15s;
}
.step-badge .step-num {
  width: 20px; height: 20px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-size: 0.7rem;
  background: rgba(255,255,255,.3);
}
.step-badge.active { background: var(--primary); color: #fff; }
.step-badge.done { background: var(--success); color: #fff; }
.step-badge.pending { background: var(--border); color: var(--muted); cursor: default; }
.step-badge.locked { background: #f3f4f6; color: #c5c7cb; cursor: not-allowed; }
.step-card { border-left: 4px solid var(--primary); }

/* Mandatory badge */
.badge-mandatory {
  display: inline-block; font-size: 0.7rem; font-weight: 600;
  padding: 0.15rem 0.5rem; border-radius: 999px;
  background: #fee2e2; color: var(--danger); margin-top: 0.35rem;
}

/* ========================================================================
   PLAYER
   ======================================================================== */
.player-card { transition: opacity 0.2s; }
.player-controls-row {
  display: flex; align-items: center; gap: 0.75rem;
}
.player-time { font-size: 0.8rem; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.player-progress {
  flex: 1; height: 6px; background: #e5e7eb; border-radius: 3px;
  cursor: pointer; position: relative;
}
.player-progress-fill {
  height: 100%; background: var(--primary); border-radius: 3px;
  width: 0; transition: width 0.1s linear;
}
.player-extras {
  display: flex; align-items: center; gap: 0.75rem; margin-top: 0.75rem;
  flex-wrap: wrap;
}
.speed-controls { display: flex; gap: 0.25rem; }
.speed-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Player (old compat) */
.player-wrap { margin: 1rem 0; }
.player-wrap audio, .player-wrap video { width: 100%; border-radius: var(--radius); }

/* ========================================================================
   SUBTITLES
   ======================================================================== */
.subtitles-box {
  background: #1e293b; color: #e2e8f0; padding: 1rem; border-radius: var(--radius);
  min-height: 60px; margin-bottom: 1rem; font-size: 1.1rem; text-align: center;
  display: flex; align-items: center; justify-content: center;
}
.subs-hidden-msg {
  background: #374151; color: #9ca3af; padding: 1rem; border-radius: var(--radius);
  min-height: 60px; margin-bottom: 1rem; font-size: 0.95rem; text-align: center;
  display: flex; align-items: center; justify-content: center;
  font-style: italic;
}

/* ========================================================================
   RECORDING
   ======================================================================== */
.record-card { }
.record-area { display: flex; align-items: center; gap: 1rem; }
.rec-btn {
  width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--danger);
  background: transparent; cursor: pointer; position: relative;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.2s;
}
.rec-btn-inner {
  width: 24px; height: 24px; background: var(--danger); border-radius: 50%;
  transition: all 0.2s;
}
.rec-btn.recording { background: var(--danger); animation: pulse 1.5s infinite; }
.rec-btn.recording .rec-btn-inner { border-radius: 4px; width: 20px; height: 20px; background: #fff; }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); }
  50% { box-shadow: 0 0 0 16px rgba(220,38,38,0); }
}
.rec-info { display: flex; flex-direction: column; }
.rec-status { font-size: 0.9rem; color: var(--fg); }
.rec-timer { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--danger); }

.attempt-playback { margin-top: 1rem; }
.attempt-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Spinner */
.analysis-spinner { display: flex; align-items: center; gap: 0.75rem; margin-top: 1rem; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ========================================================================
   RESULTS
   ======================================================================== */
.results-card { border-top: 4px solid var(--primary); }
.result-score-row { display: flex; align-items: center; gap: 1rem; }
.score-circle {
  width: 80px; height: 80px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
  border: 4px solid var(--border); background: #f9fafb;
}
.score-circle.score-good { border-color: var(--success); background: #dcfce7; }
.score-circle.score-ok { border-color: var(--warning); background: #fef9c3; }
.score-circle.score-low { border-color: var(--danger); background: #fee2e2; }
.score-value { font-size: 1.5rem; font-weight: 700; }
.score-circle.score-good .score-value { color: var(--success); }
.score-circle.score-ok .score-value { color: var(--warning); }
.score-circle.score-low .score-value { color: var(--danger); }

.result-block { background: #f9fafb; padding: 0.5rem 0.75rem; border-radius: var(--radius); }
.result-text { font-size: 0.9rem; margin-top: 0.25rem; }

/* Word diff */
.word-diff { line-height: 1.8; font-size: 0.9rem; }
.diff-match { color: var(--success); font-weight: 500; }
.diff-missing { color: var(--danger); text-decoration: line-through; font-weight: 500; }
.diff-extra { color: var(--muted); font-style: italic; }

/* Comparison playback */
.compare-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.compare-col { }
@media (max-width: 500px) { .compare-row { grid-template-columns: 1fr; } }

/* Result actions */
.result-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ========================================================================
   COACH: TRANSCRIPT EDIT
   ======================================================================== */
.transcript-edit { width: 100%; }
.transcript-edit textarea {
  width: 100%; min-height: 50px; font-size: 0.9rem; resize: vertical;
}
.transcript-edit .save-row { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.35rem; }

/* Coach: progress bar */
.progress-bar-bg {
  height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; width: 100%;
}
.progress-bar-fill {
  height: 100%; background: var(--success); border-radius: 4px; transition: width 0.3s;
}
.progress-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.25rem; }

/* ========================================================================
   MISC
   ======================================================================== */
/* ========================================================================
   ACTIVITY SUMMARY (student dashboard)
   ======================================================================== */
.activity-summary {
  display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.activity-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem;
  flex: 1; min-width: 120px; text-align: center;
}
.activity-value {
  display: block; font-size: 1.75rem; font-weight: 700; color: var(--primary);
  line-height: 1.2;
}
.activity-label { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }

/* ========================================================================
   ACTIVITY TIMER (practice page)
   ======================================================================== */
.activity-timer {
  display: flex; align-items: center; justify-content: flex-end;
  margin-bottom: 0.5rem; font-size: 0.8rem; color: var(--muted);
}

/* ========================================================================
   COURSE GRID + CARDS (student course browser)
   ======================================================================== */
.course-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.course-card {
  display: block; color: var(--fg); transition: box-shadow 0.15s, border-color 0.15s;
}
.course-card:hover {
  text-decoration: none; border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(37,99,235,.12);
}
.course-meta { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }

/* Module list (course detail) */
.module-list { }
.module-card { }
.module-header { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }

/* Week activity bars (coach dashboard) */
.week-bars {
  display: flex; gap: 3px; align-items: flex-end; height: 32px;
}
.week-bar {
  width: 14px; min-height: 2px; background: var(--primary);
  border-radius: 2px 2px 0 0; transition: height 0.2s;
}

/* ========================================================================
   MISC
   ======================================================================== */
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--muted); } .text-sm { font-size: 0.85rem; }
.text-center { text-align: center; }
.hidden { display: none; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ========================================================================
   PRACTICE PAGE v2 — clean, focused, one-sentence-at-a-time
   ======================================================================== */
.practice-page { max-width: 480px; margin: 0 auto; }

.practice-topbar { position: sticky; top: 0; z-index: 50; background: var(--bg, #fff); display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; padding: 0.35rem 0; transition: padding 0.15s, gap 0.15s; }
.practice-topbar[hidden] { display: none !important; }
.practice-topbar.is-scrolled { padding: 0.15rem 0; gap: 0.4rem; box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
.practice-topbar.is-scrolled .topbar-title { font-size: 0.82rem; }
.practice-topbar.is-scrolled .activity-timer { font-size: 0.68rem; padding: 0.15rem 0.45rem; }
.back-link { font-size: 1.35rem; color: var(--muted); text-decoration: none; line-height: 1; flex-shrink: 0; }
.topbar-info { flex: 1; min-width: 0; }
.topbar-title { font-weight: 600; font-size: 0.92rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.practice-page .activity-timer { font-size: 0.7rem; background: #f0f0f0; padding: 0.2rem 0.5rem; border-radius: 999px; white-space: nowrap; flex-shrink: 0; }
.practice-page .activity-timer.goal-met { background: #dcfce7; color: var(--success); }

.progress-stack { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 2px; }
.sentence-progress-bar {
  height: 6px; background: #e5e7eb; border-radius: 3px;
  cursor: pointer; position: relative;
}
.sentence-progress-fill {
  height: 100%; background: #374151; border-radius: 3px; transition: width 0.3s;
  position: absolute; top: 0; left: 0;
}
.game-progress-bar {
  height: 4px; background: #f3f4f6; border-radius: 2px;
  display: flex; overflow: hidden;
}
.game-progress-bar .seg-tick {
  flex: 1; transition: background 0.3s;
}
.game-progress-bar .seg-tick.done { background: currentColor; }
#game1-bar { color: #ef4444; } /* red — Blind Reader */
#game2-bar { color: #3b82f6; } /* blue — Curved Mirror */
#game3-bar { color: #22c55e; } /* green — Oracle */
#game1-bar .seg-tick { background: #fca5a5; }
#game2-bar .seg-tick { background: #93c5fd; }
#game3-bar .seg-tick { background: #86efac; }
#game1-bar .seg-tick.done { background: #dc2626; }
#game2-bar .seg-tick.done { background: #2563eb; }
#game3-bar .seg-tick.done { background: #16a34a; }
.game-progress-bar .seg-tick.cue { background: #d1d5db; opacity: 0.4; }

/* Subtitle area */

.subs-text {
  font-size: 1.4rem; line-height: 1.5; text-align: center; margin: 0;
  word-break: break-word; transition: font-size 0.15s; flex: 1;
}
.star-btn {
  width: 44px; height: 44px; font-size: 1.3rem; cursor: pointer;
  color: #9ca3af; transition: all 0.15s; background: #f3f4f6;
}
.star-btn:hover { color: #fbbf24; }
.star-btn.starred { color: #fbbf24; }
.subs-area {
  position: relative; background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem 3.9rem; margin-bottom: 1.25rem;
  min-height: 4rem;
}

/* Star + U pinned to top corners of the subs viewport. */
.subs-overlay-btn {
  position: absolute; top: 6px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; padding: 0;
  background: transparent; border: 1px solid transparent;
  cursor: pointer; transition: background 0.12s, border-color 0.12s;
}
.subs-overlay-btn:hover { background: rgba(0,0,0,0.04); border-color: var(--border); }
.subs-overlay-btn-left  { left: 6px; }
.subs-overlay-btn-right { right: 6px; }
/* Override .v2-u-btn-trigger / .star-btn sizing rules when used inside subs-area. */
.subs-area .v2-u-btn-trigger.subs-overlay-btn {
  /* Match the A/B mode pills: rounded square + subtle border, not the harsh
   * black box. Single letter, vertically centred against the star. */
  box-sizing: border-box;
  top: 9px; width: 34px; height: 30px; min-width: 0; padding: 0;
  border-radius: var(--radius, 8px);
  background: var(--card-bg, #fff);
  color: var(--fg, #212529);
  border: 1px solid var(--border, #dee2e6);
  font: 700 0.9rem/1 ui-monospace, SF Mono, Menlo, monospace;
  letter-spacing: 0;
}
.subs-area .v2-u-btn-trigger.subs-overlay-btn:hover {
  background: var(--v2-surface-2, #f3f1ea);
  border-color: var(--primary, #2563eb);
}
.subs-area .star-btn.subs-overlay-btn {
  width: 36px; height: 36px; font-size: 1.2rem;
  background: transparent; color: #9ca3af;
}

/* Blank state: hide the transcript line + caret rendering, surface CC in center.
 * Specificity is .subs-area .subs-cc-center (0,2,0) so it wins over the later
 * .sec-btn { display: flex } rule. */
.subs-area .subs-cc-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: none;
  font-weight: 700; letter-spacing: 0.05em;
}
.subs-area.is-blank .subs-text,
.subs-area.is-blank .subs-prev { visibility: hidden; }
.subs-area.is-blank .subs-cc-center { display: inline-flex; }

/* Contextual cue lines — setup/non-target lines rendered smaller */
.subs-area.cue-line { background: rgba(255,255,255,0.03); border-radius: 6px; }
.subs-area.cue-line .subs-text { font-size:0.75rem !important; opacity:0.55; font-style:italic; line-height:1.3; }
.subs-prev { font-size: 0.95rem; line-height: 1.3; text-align: center; margin: 0 0 0.4rem; color: #9ca3af; font-style: italic; word-break: break-word; }
.subs-text.subs-dotted { border-bottom: 2px dotted #d1d5db; min-height: 1.6em; color: transparent; user-select: none; }
/* Main controls — prev / PLAY / next + delay-in-rec + play-attempt.
 * flex-wrap: nowrap so they stay on a single line; tighter gap so the
 * Play-attempt fits next to Rec without pushing Next off-screen. */
.practice-controls {
  display: flex; align-items: center; justify-content: center; gap: 1.5rem;
  flex-wrap: nowrap;
  margin-bottom: 1rem;
  position: relative;
}
/* Narrow screens: the row now carries 5 controls (prev · play · Delay ·
 * REC-compound · next) and 1.5rem gaps push it past a phone's width. Tighten
 * the gap progressively, and at the smallest sizes trim the circular controls
 * and the Delay pill so the row stays on ONE line without horizontal scroll
 * (Vitaly: "buttons need to come closer together on a narrow screen"). The
 * REC-compound keeps its size — it's the primary action. */
@media (max-width: 560px) {
  .practice-controls { gap: 0.6rem; }
}
@media (max-width: 400px) {
  .practice-controls { gap: 0.35rem; }
  /* Shrink the neutral round controls 44 → 38 to claw back width. */
  .practice-controls .ctrl-nav,
  .practice-controls #play-btn,
  .practice-controls #speed-btn {
    width: 38px; min-width: 38px; height: 38px; flex: 0 0 38px;
  }
  /* Delay pill: drop its inner gap + padding so it's compact. */
  .practice-controls .pause-trigger { gap: 0.15rem; padding: 0 8px; }
}
/* Moved below .ctrl-btn so it wins specificity. See lines after .ctrl-btn. */
/* Unified pill aesthetic — same base as .sec-btn / .rec-trigger so Play,
 * Speed, Delay, Rec, Prev, Next all share one shape language. */
.ctrl-btn {
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  height: 44px; min-width: 44px; padding: 0 0.85rem;
  background: var(--card-bg, #fff);
  color: var(--fg, #212529);
  border: 1px solid var(--border, #dee2e6);
  border-radius: 999px;
  /* No font-family override — inherit page sans so the speed-val number
   * matches the rec-pause / timer / countdown numerals in the same row. */
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
  -webkit-tap-highlight-color: transparent;
}
.ctrl-btn:hover { border-color: var(--primary, #2563eb); color: var(--primary, #2563eb); }
.ctrl-btn:active { transform: scale(0.97); }

/* Play-attempt — listen to your own recording. Red rim + red triangle so it
 * reads as "yours" and is visually distinct from the neutral main Play.
 * Forced square box + 50% radius for a true circle (the inherited
 * border-radius: 999px gives a pill when width != height). */
/* Play-attempt is ALWAYS in the row (no display toggle) so the layout never
 * shifts when a recording appears. Dim grey + non-interactive until there's an
 * attempt to play; turns red (its "yours" color) once a recording exists. */
#play-attempt-btn.ctrl-play-attempt {
  box-sizing: border-box;
  padding: 0;
  width: 44px;
  min-width: 44px;
  height: 44px;
  border: 2px solid var(--border, #dee2e6);
  border-radius: 50%;
  color: #c5c7cb;
  flex: 0 0 44px;
  opacity: 0.5;
  cursor: default;
  transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
#play-attempt-btn.ctrl-play-attempt svg { fill: currentColor; }
/* A recording exists → red rim + red triangle, tappable. */
#play-attempt-btn.ctrl-play-attempt.has-attempt {
  border-color: var(--danger, #dc2626);
  color: var(--danger, #dc2626);
  opacity: 1;
  cursor: pointer;
}
#play-attempt-btn.ctrl-play-attempt.has-attempt:hover {
  background: rgba(220, 38, 38, 0.06);
}
/* While playing — pulse the rim, no shape/icon change. */
#play-attempt-btn.playing {
  animation: pulse-red-rim 1s ease-in-out infinite;
}
@keyframes pulse-red-rim {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
  50%      { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

/* ── REC compound: record half + play-your-take half as ONE two-part pill ──
 * The two child <button>s keep their IDs/JS; we only re-join them visually:
 * REC flattens its right corners, play-attempt drops its circle for a
 * rounded-right segment of equal height, with a hairline divider between. */
.rec-compound {
  display: inline-flex;
  align-items: stretch;
  height: 44px;
}
/* REC = left half: flat right edge, NO right border (the divider span is the
 * only seam line — otherwise REC's border + the divider stack into a double
 * line). */
.rec-compound .rec-trigger {
  height: 44px;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}
/* The single seam line between the two halves. 2px to match play-attempt's
 * border width so the pill outline is one consistent weight all the way round.
 * Neutral grey by default; goes red with REC once a take exists. */
.rec-compound .rec-compound-divider {
  width: 2px;
  align-self: stretch;
  background: var(--border, #dee2e6);
  flex: 0 0 2px;
}
/* play-attempt inside the compound: square off the left, match REC's height,
 * fixed-width right segment (overrides the standalone circle). Drop its own
 * left border — the divider span is the seam. */
.rec-compound #play-attempt-btn.ctrl-play-attempt {
  width: 48px;
  min-width: 48px;
  flex: 0 0 48px;
  height: 44px;
  border-radius: 0 999px 999px 0;
  border-left: none;
}
/* Once a take exists, the whole pill reads as one red unit: the seam picks up
 * REC's red (play-attempt's own border already turns red via .has-attempt). */
.rec-compound:has(#play-attempt-btn.has-attempt) .rec-compound-divider {
  background: var(--danger, #dc2626);
}

/* Prev / Next / Play / 1.0 — 44x44 black circles. Same geometry as
 * play-attempt (which is red); these are the neutral / "page" controls,
 * so black rim + black glyph. Subtle grey fill on hover instead of
 * color-shifting to primary so the row keeps one visual voice. */
.ctrl-nav,
.ctrl-speed,
.ctrl-play {
  box-sizing: border-box;
  padding: 0;
  width: 44px;
  min-width: 44px;
  height: 44px;
  border: 2px solid #000;
  border-radius: 50%;
  color: #000;
  flex: 0 0 44px;
}
.ctrl-nav:hover,
.ctrl-speed:hover,
.ctrl-play:hover {
  border-color: #000;
  color: #000;
  background: rgba(0, 0, 0, 0.06);
}
.ctrl-nav svg,
.ctrl-play svg {
  display: block;
  fill: currentColor;
  width: 22px;
  height: 22px;
}
.ctrl-play.active,
.ctrl-play:active { background: rgba(0, 0, 0, 0.06); }

/* Speed = the "1.0" / "0.75" pill; active state = solid black so it reads
 * as "engaged" without introducing a new accent color. */
.ctrl-speed.active {
  background: #000;
  color: #fff;
  border-color: #000;
}
.ctrl-speed .speed-val {
  text-align: center;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
/* Speed shows the whole cycle "1x›.8x›.6x" (active step bold) — too wide for a
 * 44px circle, so this one control is a pill while the rest stay circles. */
.ctrl-speed {
  width: auto;
  min-width: 44px;
  padding: 0 12px;
  border-radius: 999px;
  flex: 0 0 auto;
}
.ctrl-speed .sv-off { opacity: 0.4; font-weight: 600; }
.ctrl-speed .sv-sep { opacity: 0.3; margin: 0 1px; font-weight: 400; }
.ctrl-speed.active .sv-off { color: #fff; opacity: 0.6; }
.ctrl-speed.active .sv-sep { color: #fff; opacity: 0.5; }
/* On a video (Mode A) the speed control is floated as one 44px circle showing
 * just the current rate (paintSpeed renders a single value in .speed-compact);
 * higher specificity than the pill above, so it overrides width/shape. */
.ctrl-speed.speed-compact {
  width: 44px;
  min-width: 44px;
  padding: 0;
  border-radius: 50%;
}
.ctrl-speed.speed-compact .speed-val { font-size: 0.72rem; }

.ctrl-stop {
  background: var(--danger); color: #fff; border-color: var(--danger);
}
/* Pause-delay toggle: sec-btn pill in yellow (mirrors .rec-trigger's red pattern).
 * Pause-icon left + numeric value right. */
/* Pause/Delay + REC are B-only — A has no recording loop. */
body.v2-mode-A #rec-pause-btn,
body.v2-mode-A #rec-btn { display: none; }

/* Oracle (B3) doesn't need the speed cycle or the delay — the student is
 * reciting from memory before any audio plays. Hide speed + the Delay button. */
body.v2-bmode-3 #rec-pause-btn,
body.v2-bmode-3 #speed-btn { display: none !important; }

/* A mode: collapse every chrome strip between the video and the scrollable
 * transcript so they touch. The transcript IS the subs in A. Lookup popover
 * is positioned absolutely — it's hidden via its own inline display:none
 * and revealed by JS, so we DON'T blanket-hide it here. */
body.v2-mode-A #subs-area,
body.v2-mode-A .practice-secondary,
body.v2-mode-A #stt-result,
body.v2-mode-A #comprehension-area,
body.v2-mode-A #scene-timeline,
body.v2-mode-A .progress-stack { display: none !important; }

/* U overlay parked — hide the global trigger and the unchew/stage4 widgets
 * that auto-mount when shadowing_v1 stages 2/3/4 are active. They render
 * separate panels (#unchew-panel, #stage4-panel) outside the modes I touch
 * directly. Park them as a single unit until U is rebuilt. */
#unchew-panel,
#stage4-panel { display: none !important; }

/* ── B-mode section indicator ────────────────────────────────────── */
/* Inserted by v2-b-section.js right above the subs strip. Quiet by
 * default; bolds the section count + fills round dots as the student
 * cycles B1→B2→B3 on the same section. */
.v2-b-section {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 12px;
  margin: 0 0 4px;
  font: 500 0.78rem/1 Inter, system-ui, sans-serif;
  color: var(--muted, #6b7280);
}
body.v2-mode-B .v2-b-section { display: flex; }
.v2-bsec-name { font-weight: 600; color: var(--fg, #212529); }
.v2-bsec-dot-row { display: inline-flex; gap: 4px; align-items: center; }
.v2-bsec-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border, #dee2e6);
}
.v2-bsec-dot.is-filled {
  background: var(--success, #16a34a);
  border-color: var(--success, #16a34a);
}

/* Round-complete banner — surfaces after B3 of the section's last
 * sentence. Library aesthetic (white card, soft border, primary CTA). */
.v2-bsec-banner {
  position: fixed;
  left: 50%; bottom: 92px;
  transform: translateX(-50%);
  z-index: 70;
  max-width: 92vw;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #dee2e6);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  font: 500 0.95rem/1.4 Inter, system-ui, sans-serif;
  color: var(--fg, #212529);
  animation: v2bsec-rise 200ms ease-out;
}
@keyframes v2bsec-rise {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.v2-bsec-banner-msg { margin: 0 0 10px; text-align: center; }
.v2-bsec-banner-row { display: flex; gap: 10px; justify-content: center; }
.v2-bsec-btn-again,
.v2-bsec-btn-next {
  height: 36px; padding: 0 18px;
  border: 1px solid var(--border, #dee2e6);
  background: var(--card-bg, #fff);
  color: var(--fg, #212529);
  border-radius: 999px;
  font: 600 0.85rem/1 Inter, system-ui, sans-serif;
  cursor: pointer;
}
.v2-bsec-btn-again:hover { border-color: var(--primary, #2563eb); color: var(--primary, #2563eb); }
.v2-bsec-btn-next {
  background: var(--primary, #2563eb);
  border-color: var(--primary, #2563eb);
  color: #fff;
}
.v2-bsec-btn-next:hover { background: var(--primary-hover, #1d4ed8); }

/* A mode: no bottom controls. Play sits overlaid on the video. */
body.v2-mode-A .practice-controls { display: none; }

/* In A mode the video surface itself is the play/pause control (v2-a-mode.js
 * bindVideoTap) — no Play button is floated onto it. .sentence-video-wrap is
 * the positioning anchor for the floated speed toggle below. */
.sentence-video-wrap { position: relative; }
/* Speed toggle: a compact circular control (.speed-compact) in the bottom-LEFT
 * of the video, revealed on pause only — tapping the rest of the surface
 * plays/pauses, so it stays out of the way while watching. */
body.v2-mode-A .sentence-video-wrap #speed-btn.ctrl-speed {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 5;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}
body.v2-mode-A .sentence-video-wrap.media-paused #speed-btn.ctrl-speed {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
/* Center ▶ affordance: visible while paused, fades out as playback starts.
 * pointer-events:none — a tap on it falls through to the video surface, which
 * handles play/pause (v2-a-mode.js). Injected into the wrap by v2-a-mode.js. */
.video-play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.video-play-overlay svg { width: 32px; height: 32px; fill: #fff; margin-left: 3px; }
body.v2-mode-A .sentence-video-wrap.media-paused .video-play-overlay { opacity: 1; }
/* B1/B2 on video: speed control bottom-LEFT of the video (mirror of A). */
body.v2-bmode-1 .sentence-video-wrap #speed-btn.ctrl-speed,
body.v2-bmode-2 .sentence-video-wrap #speed-btn.ctrl-speed {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 5;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
}
/* Practice-section had reserved padding for the fixed controls; in A mode
 * the scroll layer lives OUTSIDE practice-section, so the padding became
 * the visible gap. Zero it here; the layer carries its own bottom margin. */
body.v2-mode-A #practice-section { padding-bottom: 0; margin-bottom: 0; }
body.v2-mode-A #action-layer-A { margin-top: 0; margin-bottom: 76px; }

/* Delay button (#rec-pause-btn): its own pill, yellow to mirror REC's red.
 * Clock icon left + numeric seconds right (0/5/10/15). */
.pause-trigger {
  border-color: var(--v2-target, #b08d34);
  color: var(--v2-target, #b08d34);
  font-variant-numeric: tabular-nums;
  gap: 0.4rem;
}
.pause-trigger .pause-clock-icon { flex: 0 0 auto; }
.pause-trigger .rec-pause-val { font-weight: 700; font-size: 1.05rem; min-width: 1.6ch; text-align: center; }
.pause-trigger.active { background: var(--v2-target-tint, #f3ebd4); }
.pause-trigger:hover { background: var(--v2-target, #b08d34); color: #fff; }

/* REC button: mic icon + (hidden) countdown label + (hidden) live timer.
 * Delay is set on the separate Delay button now; tapping REC only records.
 * Fixed width so the pill doesn't jitter while the countdown / live timer
 * ticks (the two number spans are mutually exclusive and share one slot). */
.rec-trigger {
  width: 84px;
  min-width: 84px;
  padding: 0 14px;
  gap: 8px;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
.rec-trigger .rec-mic-icon {
  flex: 0 0 auto;
  color: var(--danger, #dc2626);
}
/* All three number spans (delay digit / countdown / live timer) share ONE
 * fixed-width slot. flex: 0 0 3.5ch locks the slot regardless of content
 * ("0" / "30" / "0:00") so the mic icon and the numerals never shift between
 * cycle / countdown / recording states. The button width is fixed (100px)
 * and the mic is flex: 0 0 auto, so nothing jumps. */
.rec-trigger .rec-label,
.rec-trigger .rec-timer-inline {
  flex: 0 0 3.5ch;
  width: 3.5ch;
  min-width: 3.5ch;
  text-align: center;
  white-space: nowrap;
}
/* During the v2-rec-pause countdown, v2-rec-pause.js writes the live tick
 * into .rec-label. Show it next to the mic (mic stays visible — just the
 * static digit setting hides, replaced by the live countdown). The button
 * is disabled during countdown; override the base disabled opacity so the
 * red tick reads as a live count, not as a faded-out control. */
.rec-trigger.rec-pause-gated .rec-label {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  color: var(--danger, #dc2626) !important;
  font-weight: 700;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}
.rec-trigger.rec-pause-gated,
.rec-trigger.rec-pause-gated:disabled { opacity: 1 !important; }

/* Hover state: whole pill fills red, mic goes white. */
.rec-trigger:hover .rec-mic-icon { color: #fff; }

/* REC-button countdown gating (when pause toggle armed). The button itself
 * is the original .sec-btn .rec-trigger pill; we just retint the label and
 * pulse the border on each tick. */
.rec-trigger.rec-pause-flash {
  animation: rec-rim-flash 1s ease-in-out;
}
@keyframes rec-rim-flash {
  0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55); }
  50%  { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* Secondary controls */
.practice-secondary {
  display: flex; justify-content: center; align-items: center; gap: 1.25rem; margin-bottom: 1.5rem; min-height: 2.75rem;
}
.sec-btn {
  border: 1px solid var(--border); background: var(--card-bg); color: var(--fg);
  height: 44px; padding: 0 1rem;
  border-radius: 999px; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 0.35rem;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.sec-btn[hidden] { display: none !important; }
.sec-btn:hover { border-color: var(--primary); color: var(--primary); }
.sec-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.sec-btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.rec-trigger { border-color: var(--danger); color: var(--danger); }
.rec-trigger:hover { background: var(--danger); color: #fff; }
#play-attempt-btn.playing { border-color: var(--danger); color: var(--danger); }

/* Recording: inline in REC button */
/* Recording state: red fill, white content, SAME pill shape, flashes via
 * pulse keyframes. Mic stays visible (white via currentColor), the static
 * delay digit hides (no longer settable mid-record), the live timer shows. */
.rec-trigger.recording {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  animation: pulse 1.5s infinite;
}
.rec-trigger.recording .rec-mic-icon { color: #fff; }
.rec-trigger.recording .rec-pause-val,
.rec-trigger.recording .rec-label { display: none; }
.rec-trigger.recording .rec-timer-inline { color: #fff; }
/* Same font (JetBrains Mono via --v2-font-mono token) as the delay digit
 * so the pill keeps one typographic voice across cycle / countdown / recording. */
.rec-timer-inline {
  font-weight: 700;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

/* Listen-first nudge — shown under the controls when the student taps REC
 * before playing the chunk (B1/B2). Same card as the .stt-result feedback box;
 * re-flashes on each repeat tap so the message is acknowledged every time. */
.rec-listen-hint {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 0.75rem 1rem; margin-bottom: 0.75rem;
  font-size: 0.9rem; line-height: 1.45; color: var(--fg); text-align: center;
}
.rec-listen-hint.flash { animation: rec-hint-flash 0.35s ease-out; }
@keyframes rec-hint-flash {
  0%   { opacity: 0.35; transform: translateY(-3px); }
  100% { opacity: 1;    transform: translateY(0); }
}

/* STT result */
.stt-result { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem 1rem; margin-bottom: 0.75rem; }
.stt-score-row { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-bottom: 0.35rem; }
.stt-score { font-size: 1.5rem; font-weight: 800; }
.stt-score.good { color: var(--success); }
.stt-score.ok { color: var(--warning); }
.stt-score.low { color: var(--danger); }
.stt-diff { line-height: 1.6; font-size: 0.9rem; }
.dw-match { color: var(--success); font-weight: 500; }
.dw-miss { color: var(--danger); text-decoration: line-through; }
.dw-extra { color: var(--muted); font-style: italic; }

/* Mode toggle: Watch / Practice — lives inside the sticky topbar */
.practice-topbar .mode-toggle {
  display: flex; gap: 0; margin: 0; justify-content: center; flex-shrink: 0;
}
.practice-topbar .mode-btn {
  padding: 0.3rem 0.65rem; border: 1px solid var(--border); background: var(--card-bg);
  font-size: 0.78rem; font-weight: 500; cursor: pointer;
  text-align: center; transition: all 0.15s;
}
.practice-topbar .mode-btn:first-child { border-radius: 999px 0 0 999px; border-right: none; }
.practice-topbar .mode-btn:last-child  { border-radius: 0 999px 999px 0; }
.practice-topbar .mode-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.practice-topbar.is-scrolled .mode-btn { padding: 0.22rem 0.55rem; font-size: 0.72rem; }

/* Sentence video */
.sentence-video-wrap { margin-bottom: 0.75rem; border-radius: 8px; overflow: hidden; max-height: 40vh; background: #000; }
body.v2-mode-A .sentence-video-wrap { margin-bottom: 0; border-radius: 0; }
.sentence-video-wrap video { max-height: 40vh; object-fit: contain; }

/* HTTPS warning */
.https-warning {
  background: #fef3c7; border: 1px solid #f59e0b; border-radius: var(--radius);
  padding: 0.75rem; text-align: center; margin-top: 1rem;
}
.https-warning a { color: var(--primary); font-weight: 600; }

/* Protocol mode bar */
.mode-bar { margin-bottom: 0.75rem; }
.mode-pills { display: flex; gap: 0.4rem; flex-wrap: nowrap; margin-bottom: 0.35rem; justify-content: center; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mode-pills::-webkit-scrollbar { display: none; }
@media (max-width: 420px) { .mode-pill .pill-label { display: none; } .mode-pill { padding: 0.3rem 0.65rem; min-width: 1.9rem; text-align: center; } }
.mode-pill { padding: 0.3rem 0.75rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: all 0.15s; background: transparent; border: 2px solid #d1d5db; color: var(--muted); }
.mode-pill[data-midx="0"] { border-color: #ef4444; color: #ef4444; }
.mode-pill[data-midx="1"] { border-color: #3b82f6; color: #3b82f6; }
.mode-pill[data-midx="2"] { border-color: #22c55e; color: #22c55e; }
.mode-pill.active[data-midx="0"] { background: #ef4444; color: #fff; }
.mode-pill.active[data-midx="1"] { background: #3b82f6; color: #fff; }
.mode-pill.active[data-midx="2"] { background: #22c55e; color: #fff; }
.mode-pill.done { cursor: pointer; opacity: 0.5; }
.mode-pill.done[data-midx="0"] { background: #ef4444; color: #fff; }
.mode-pill.done[data-midx="1"] { background: #3b82f6; color: #fff; }
.mode-pill.done[data-midx="2"] { background: #22c55e; color: #fff; }
.mode-instruction { display: none; font-size: 0.8rem; margin: 0; }

/* Disabled play button (cold predict) */
.ctrl-play.disabled { opacity: 0.3; cursor: not-allowed; }

/* Glow CTA */
.glow { animation: glowPulse 2s ease-in-out infinite; }
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,0.3); }
  50% { box-shadow: 0 0 0 8px rgba(37,99,235,0); }
}
.rec-trigger.glow { animation-name: glowPulseRec; }
@keyframes glowPulseRec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.3); }
  50% { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}

/* Toast */
.practice-toast {
  position: fixed; bottom: 5rem; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 0.6rem 1.2rem;
  border-radius: 8px; font-size: 0.85rem; z-index: 50;
  animation: toastIn 0.2s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* Required record highlight */
.rec-trigger.rec-required { border-color: var(--danger); background: #fee2e2; color: var(--danger); font-weight: 600; }
.rec-trigger.rec-disabled { opacity: 0.3; cursor: not-allowed; }
/* Locked subs toggle (protocol forces on/off) */
.ctrl-btn.locked { opacity: 0.25; cursor: not-allowed; pointer-events: auto; }
/* Loading state on play button */
.ctrl-play.loading { opacity: 0.5; }
.ctrl-play.loading::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid transparent; border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* Skip step button (appears after listening in optional-record modes) */
.skip-step-btn {
  background: var(--primary); color: #fff; border: none; border-radius: 8px;
  padding: 0.5rem 1.2rem; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; margin-left: auto;
  animation: toastIn 0.2s ease-out;
}
.skip-step-btn:hover { opacity: 0.9; }

.mode-sep { color: var(--muted); font-size: 0.8rem; align-self: center; user-select: none; pointer-events: none; }
.mode-help-pill { padding: 0.3rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; cursor: pointer; border: 1px solid var(--border); background: var(--card-bg); color: var(--muted); margin-left: 0.4rem; }
.mode-help-pill:hover { color: var(--fg); border-color: var(--muted); }
