/* ============================================================================
 * Lesson Theater — captions-first audio lesson player.
 *
 * Design language reused from mim-note (server/mim_note/templates/mim_note/index.html):
 *   - Dark base on warm-tinted near-black
 *   - Mim-yellow #f6d365 as the single primary accent
 *   - Mim-cyan #6febdb as the secondary highlight
 *   - Card surfaces tinted slightly green-black for warmth (vs pure greyscale)
 *   - 12px–14px corner radius
 *
 * Layout vibe: Spotify / NotebookLM. Top brand bar, large "now playing" card
 * with the caption text as the hero, optional subordinate visual pane, and a
 * sticky transport bar pinned to the bottom of the viewport.
 *
 * Every element id used by lesson_theater.js is preserved.
 * ============================================================================ */

:root {
  /* Shared with mim-note / lesson_player */
  --theater-bg:          #02040a;
  --theater-bg-1:        #0a1115;
  --theater-bg-2:        #111a1d;
  --theater-card:        #131c20;
  --theater-card-strong: #1a262a;
  --theater-fg:          #f5f8fa;
  --theater-fg-muted:    #b7c1c9;
  --theater-fg-dim:      #7f8a94;
  --theater-accent:      #f6d365;          /* mim yellow */
  --theater-accent-ink:  #1a1500;          /* ink on accent */
  --theater-accent-soft: rgba(246, 211, 101, 0.16);
  --theater-cyan:        #6febdb;          /* mim cyan */
  --theater-cyan-soft:   rgba(111, 235, 219, 0.18);
  --theater-border:      rgba(255, 255, 255, 0.08);
  --theater-border-soft: rgba(255, 255, 255, 0.04);
  --theater-danger:      #f1a4a4;
  --theater-success:     #9be3a8;

  --theater-radius-lg:   18px;
  --theater-radius:      14px;
  --theater-radius-sm:   10px;

  --theater-shadow:      0 24px 60px rgba(0, 0, 0, 0.45);
  --theater-shadow-sm:   0 6px 18px rgba(0, 0, 0, 0.35);

  --theater-font:        "Inter", "Playfair Display", system-ui, -apple-system,
                         Segoe UI, Roboto, sans-serif;
  --theater-font-display: "Playfair Display", "Inter", Georgia, serif;
  --theater-transport-h: 84px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--theater-bg);
  color: var(--theater-fg);
  font-family: var(--theater-font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--theater-fg);
  text-decoration: none;
}
a:hover { color: var(--theater-accent); }

/* ----------------------------------------------------------------------------
 * Topbar — brand + AI disclosure + escape hatch to classic player.
 * ---------------------------------------------------------------------------- */

.mw-theater-topbar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem clamp(0.85rem, 2.5vw, 1.5rem);
  background: linear-gradient(180deg, rgba(246, 211, 101, 0.06), transparent);
  border-bottom: 1px solid var(--theater-border);
  position: sticky;
  top: 0;
  z-index: 4;
  backdrop-filter: blur(8px);
}
.mw-theater-topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.mw-theater-topbar-brand img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #fff;
  padding: 3px;
}
.mw-theater-topbar-brand-mark { color: var(--theater-accent); }
.mw-theater-topbar-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--theater-fg-dim);
  padding-left: 0.65rem;
  margin-left: 0.65rem;
  border-left: 1px solid var(--theater-border);
}
.mw-theater-topbar-ai {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--theater-fg-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.mw-theater-topbar-ai .mw-theater-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--theater-cyan);
  box-shadow: 0 0 0 4px var(--theater-cyan-soft);
}
.mw-theater-topbar-link {
  font-size: 0.78rem;
  border: 1px solid var(--theater-border);
  padding: 0.32rem 0.75rem;
  border-radius: 999px;
  color: var(--theater-fg-muted);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.mw-theater-topbar-link:hover {
  color: var(--theater-fg);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ----------------------------------------------------------------------------
 * Page chrome — main grid, padding for sticky transport bar.
 * ---------------------------------------------------------------------------- */

.mw-theater {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 56px);
  padding: clamp(1rem, 3vw, 2.5rem) clamp(0.85rem, 3vw, 2rem);
  padding-bottom: calc(var(--theater-transport-h) + 1.5rem);
  gap: 1.5rem;
}
.mw-theater[data-state="empty"] #stagePane { display: none; }
.mw-theater:not([data-state="empty"]) #setupPane { display: none; }

/* ----------------------------------------------------------------------------
 * Setup card — first-run UX, file/topic picker.
 * ---------------------------------------------------------------------------- */

.mw-theater-setup {
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  background: var(--theater-card);
  border: 1px solid var(--theater-border);
  border-radius: var(--theater-radius-lg);
  box-shadow: var(--theater-shadow);
  padding: clamp(1.3rem, 3vw, 2.25rem);
}
.mw-theater-setup-head { margin-bottom: 1.5rem; }
.mw-theater-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--theater-fg-dim);
  margin: 0 0 0.4rem;
}
.mw-theater-title {
  margin: 0;
  font-family: var(--theater-font-display);
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.012em;
  line-height: 1.1;
}
.mw-theater-sub {
  margin: 0.65rem 0 0;
  color: var(--theater-fg-muted);
  font-size: 0.95rem;
  max-width: 60ch;
}
.mw-theater-sub--warn {
  color: var(--theater-accent);
  font-size: 0.86rem;
}
.mw-theater-sub--warn code {
  font-size: 0.85em;
  color: var(--theater-fg);
  background: var(--theater-accent-soft);
  padding: 0 0.35rem;
  border-radius: 4px;
}

.mw-theater-setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.85rem;
  margin-top: 1.5rem;
}
.mw-theater-card {
  background: var(--theater-bg-2);
  border: 1px solid var(--theater-border);
  border-radius: var(--theater-radius);
  padding: 1.1rem 1.15rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 168px;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.mw-theater-card:hover {
  border-color: rgba(246, 211, 101, 0.45);
  background: var(--theater-card-strong);
}
.mw-theater-card--upload { cursor: pointer; }
.mw-theater-card-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--theater-fg-dim);
}
.mw-theater-card-label {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--theater-fg);
}
.mw-theater-card-hint {
  font-size: 0.86rem;
  color: var(--theater-fg-muted);
}
.mw-theater-card--topic input {
  background: rgba(0, 0, 0, 0.3);
  color: var(--theater-fg);
  border: 1px solid var(--theater-border);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  font: inherit;
  font-size: 0.92rem;
  margin-top: 0.2rem;
}
.mw-theater-card--topic input:focus {
  outline: none;
  border-color: var(--theater-accent);
}

/* Episode-length picker: short / medium / long.
 * Renders as a horizontal trio of radio "chips" that look like the
 * Spotify quality selector. Selection draws the mim-yellow accent ring. */
.mw-theater-length {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
  padding: 0;
  border: 0;
  flex-wrap: wrap;
}
.mw-theater-length-legend {
  flex-basis: 100%;
  margin: 0 0 0.4rem;
  padding: 0;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--theater-fg-dim);
}
.mw-theater-length label {
  flex: 1 1 140px;
  position: relative;
  cursor: pointer;
}
.mw-theater-length input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.mw-theater-length label span {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  padding: 0.7rem 0.95rem;
  border-radius: 12px;
  border: 1px solid var(--theater-border);
  background: var(--theater-bg-2);
  color: var(--theater-fg);
  font-weight: 600;
  font-size: 0.95rem;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.mw-theater-length label span small {
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--theater-fg-dim);
  letter-spacing: 0.02em;
}
.mw-theater-length label:hover span {
  border-color: rgba(246, 211, 101, 0.45);
  background: var(--theater-card-strong);
}
.mw-theater-length input:checked + span {
  border-color: var(--theater-accent);
  background: var(--theater-accent-soft);
  box-shadow: 0 0 0 1px var(--theater-accent) inset;
}
.mw-theater-length input:focus-visible + span {
  outline: 2px solid var(--theater-accent);
  outline-offset: 2px;
}
.mw-theater-cta {
  align-self: flex-start;
  margin-top: 0.35rem;
  border: 0;
  background: var(--theater-accent);
  color: var(--theater-accent-ink);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  transition: filter 0.15s ease;
}
.mw-theater-cta:hover:not(:disabled) { filter: brightness(1.05); }
.mw-theater-cta:disabled { opacity: 0.55; cursor: not-allowed; }

.mw-theater-status {
  margin: 1.1rem 0 0;
  min-height: 1.2em;
  color: var(--theater-fg-muted);
  font-size: 0.92rem;
}
.mw-theater-status[data-tone="error"]   { color: var(--theater-danger); }
.mw-theater-status[data-tone="success"] { color: var(--theater-success); }

/* ----------------------------------------------------------------------------
 * Now-playing stage — the main "hero" once a lesson is loaded.
 * Layout:
 *   Desktop: caption hero (2fr) + visual sidebar (1fr)
 *   Mobile:  stacked, visual collapses below caption
 * ---------------------------------------------------------------------------- */

.mw-theater-stage {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 1.1rem;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}
@media (max-width: 920px) {
  .mw-theater-stage { grid-template-columns: 1fr; }
}

/* "Now playing" card --------------------------------------------------------- */

.mw-theater-now {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: clamp(1.2rem, 3vw, 2.1rem);
  background:
    radial-gradient(circle at 18% 0%, rgba(246, 211, 101, 0.10), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(111, 235, 219, 0.07), transparent 50%),
    linear-gradient(180deg, var(--theater-card) 0%, #0c1417 100%);
  border: 1px solid var(--theater-border);
  border-radius: var(--theater-radius-lg);
  box-shadow: var(--theater-shadow);
  overflow: hidden;
  min-height: 380px;
}
.mw-theater-now::after {
  /* Soft fade at the bottom so very long captions don't crash into the
     transport bar visually. */
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 60px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(7, 11, 13, 0.55));
}
.mw-theater-now-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem 1rem;
  z-index: 1;
}
.mw-theater-now-eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--theater-accent);
  margin: 0;
}
.mw-theater-step-title {
  margin: 0;
  font-size: 0.92rem;
  color: var(--theater-fg-muted);
  font-weight: 500;
  min-height: 1.2em;
}
.mw-theater-progress {
  margin: 0;
  margin-left: auto;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--theater-fg-dim);
  text-transform: uppercase;
}

.mw-theater-caption-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.4rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.mw-theater-caption-scroll::-webkit-scrollbar { width: 6px; }
.mw-theater-caption-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 3px;
}

.mw-theater-caption {
  margin: 0;
  font-family: var(--theater-font-display);
  /* v2: dial down from "shouty" 1.25-1.9rem to a calmer 1.05-1.25rem. The
     hero card is large; the caption no longer needs to also be the largest
     thing on screen. */
  font-size: clamp(1.05rem, 1.8vw, 1.25rem);
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: -0.003em;
  color: var(--theater-fg);
  max-width: 56ch;
  transition: opacity 180ms ease;
}
.mw-theater-caption.mw-theater-caption--swap { opacity: 0; }

/* Overlay (Start listening / error sticky panel) ----------------------------- */

.mw-theater-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 4, 10, 0.78);
  backdrop-filter: blur(4px);
  z-index: 3;
  padding: 1rem;
}
.mw-theater-overlay[hidden] { display: none; }

.mw-theater-overlay-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 1.1rem 1.6rem;
  border-radius: 999px;
  background: var(--theater-accent);
  color: var(--theater-accent-ink);
  border: 0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 44px rgba(246, 211, 101, 0.32);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.mw-theater-overlay-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 50px rgba(246, 211, 101, 0.4);
}
.mw-theater-overlay-icon { font-size: 1.6rem; line-height: 1; }
.mw-theater-overlay-label { font-size: 1.05rem; }
.mw-theater-overlay-hint {
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(26, 21, 0, 0.78);
  max-width: 28ch;
  text-align: center;
}

/* Visual sidebar ------------------------------------------------------------- */

.mw-theater-visual {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem 1.05rem;
  background: var(--theater-card);
  border: 1px solid var(--theater-border);
  border-radius: var(--theater-radius-lg);
  box-shadow: var(--theater-shadow-sm);
  overflow: hidden;
  min-height: 220px;
  max-height: 100%;
}
.mw-theater-visual[hidden] { display: none; }
.mw-theater-visual-title {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--theater-fg-dim);
}
.mw-theater-visual-body {
  flex: 1;
  overflow: auto;
  font-size: 0.92rem;
  color: var(--theater-fg-muted);
  line-height: 1.45;
}
.mw-theater-visual-body svg,
.mw-theater-visual-body img {
  max-width: 100%;
  height: auto;
  display: block;
}
.mw-theater-visual-body ul {
  margin: 0;
  padding-inline-start: 1.2rem;
}

/* ----------------------------------------------------------------------------
 * Transport bar — sticky to bottom on all viewports (Spotify mobile vibe).
 * Hidden in the empty / setup state.
 * ---------------------------------------------------------------------------- */

.mw-theater-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.65rem clamp(0.85rem, 3vw, 1.5rem) max(0.75rem, env(safe-area-inset-bottom, 0px));
  background: rgba(10, 17, 21, 0.94);
  border-top: 1px solid var(--theater-border);
  backdrop-filter: blur(12px);
  min-height: var(--theater-transport-h);
}
.mw-theater[data-state="empty"]   .mw-theater-bar,
.mw-theater[data-state="loading"] .mw-theater-bar { display: none; }

/* Top progress bar across the full width of the transport bar; click-to-seek. */
.mw-theater-bar-progress {
  appearance: none;
  border: 0;
  background: transparent;
  width: 100%;
  padding: 0;
  cursor: pointer;
}
.mw-theater-bar-progress::-moz-focus-inner { border: 0; }
.mw-theater-bar-progress:focus-visible { outline: none; }
.mw-theater-bar-progress::before {
  content: "";
  display: block;
  height: 3px;
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.mw-theater-bar-progress {
  position: relative;
  height: 14px;
  display: flex;
  align-items: center;
}
.mw-theater-bar-progress-fill {
  position: absolute;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--theater-accent), var(--theater-cyan));
  border-radius: 999px;
  transition: width 0.2s linear;
}
.mw-theater-bar-progress:hover .mw-theater-bar-progress-fill {
  height: 5px;
}

.mw-theater-bar-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
}

.mw-theater-bar-left,
.mw-theater-bar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}
.mw-theater-bar-left  { justify-content: flex-start; }
.mw-theater-bar-right {
  justify-content: flex-end;
  /* Tighter gap + min-width: 0 so the engine badge can sit alongside the
     volume slider, rate selector and Exit button without anyone clipping.
     Previously the cluster squeezed the badge down to "Kok…". */
  gap: 0.55rem;
  min-width: 0;
}
.mw-theater-bar-mid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.mw-theater-track {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.mw-theater-track-eyebrow {
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--theater-fg-dim);
}
.mw-theater-track-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--theater-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: clamp(120px, 26vw, 320px);
}

.mw-theater-ctrl {
  appearance: none;
  border: 1px solid var(--theater-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--theater-fg);
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.mw-theater-ctrl:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
}
.mw-theater-ctrl:active:not(:disabled) { transform: scale(0.96); }
.mw-theater-ctrl:disabled { opacity: 0.4; cursor: not-allowed; }
.mw-theater-ctrl--primary {
  /* v2: a real Spotify-sized play button. Bigger, more shadow, focus-visible. */
  width: 64px;
  height: 64px;
  font-size: 1.45rem;
  background: var(--theater-accent);
  color: var(--theater-accent-ink);
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(246, 211, 101, 0.35);
}
.mw-theater-ctrl--primary:focus-visible {
  outline: 3px solid rgba(246, 211, 101, 0.6);
  outline-offset: 3px;
}
.mw-theater-ctrl--primary:hover:not(:disabled) {
  background: var(--theater-accent);
  filter: brightness(1.05);
}
.mw-theater-ctrl--loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.mw-theater-ctrl--loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--theater-accent-ink);
  border-radius: 50%;
  animation: mw-theater-spin 0.75s linear infinite;
}
@keyframes mw-theater-spin {
  to { transform: rotate(360deg); }
}
.mw-theater-ctrl--ghost {
  width: auto;
  height: auto;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  border-color: transparent;
  color: var(--theater-fg-muted);
  font-size: 0.82rem;
}
.mw-theater-ctrl--ghost:hover:not(:disabled) {
  color: var(--theater-fg);
}

.mw-theater-rate {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--theater-fg-muted);
  flex-shrink: 0;
}
.mw-theater-rate select {
  background: rgba(0, 0, 0, 0.35);
  color: var(--theater-fg);
  border: 1px solid var(--theater-border);
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  font: inherit;
  font-size: 0.82rem;
}

.mw-theater-engine {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--theater-accent-soft);
  color: var(--theater-accent);
  /* No max-width / overflow / text-overflow here — let the badge size to
     its content so "Kokoro · GPU q8" never gets clipped to "Kok…". The
     responsive rule below hides the badge entirely on mobile.
     flex-shrink: 0 stops the right-hand flex cluster (volume slider + rate
     selector + Exit) from squeezing the badge down to its first 3-4 chars. */
  white-space: nowrap;
  flex-shrink: 0;
}
.mw-theater-engine[data-engine="server"] {
  background: var(--theater-cyan-soft);
  color: var(--theater-cyan);
}

.mw-theater-track-meta {
  font-size: 0.74rem;
  color: var(--theater-fg-dim);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* Background-render hint that lives next to the track meta. While the synth
   worker is rendering ahead, this shows "Rendering ahead… 3 of 7 chapters";
   once the whole lesson has been rendered it switches to cyan and reads
   "Lesson fully rendered". Hidden by default via the `hidden` HTML attribute. */
.mw-theater-render {
  font-size: 0.72rem;
  color: var(--theater-fg-dim);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: clamp(140px, 26vw, 320px);
}
.mw-theater-render[data-state="done"] {
  color: var(--theater-cyan);
}

/* Volume slider in the right-hand cluster --------------------------------- */
.mw-theater-volume {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--theater-fg-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}
.mw-theater-volume input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 96px;
  height: 4px;
  background: linear-gradient(
    to right,
    var(--theater-accent) 0%,
    var(--theater-accent) var(--mw-vol, 100%),
    rgba(255, 255, 255, 0.12) var(--mw-vol, 100%),
    rgba(255, 255, 255, 0.12) 100%
  );
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}
.mw-theater-volume input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--theater-fg);
  border: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.mw-theater-volume input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--theater-fg);
  border: 0;
}

/* Pedagogy label pill — small-caps "chapter cue" inside captions. ------------ */
.mw-theater-label {
  display: inline-block;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-family: var(--theater-font);
  font-weight: 700;
  padding: 0.15em 0.6em;
  border-radius: 999px;
  background: var(--theater-accent-soft);
  color: var(--theater-accent);
  margin-right: 0.4em;
  vertical-align: middle;
  white-space: nowrap;
}

/* Stage "solo" mode — visual pane is hidden, caption gets the whole width. */
.mw-theater-stage--solo { grid-template-columns: 1fr; }
.mw-theater-stage--solo .mw-theater-now { min-height: 460px; }
.mw-theater-stage--solo .mw-theater-caption { max-width: 64ch; }

/* Pre-render progress UI inside the overlay -------------------------------- */
.mw-theater-prep {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  background: var(--theater-card);
  border: 1px solid var(--theater-border);
  border-radius: var(--theater-radius);
  box-shadow: var(--theater-shadow);
  min-width: min(420px, 90vw);
  max-width: min(560px, 92vw);
}
.mw-theater-prep[hidden] { display: none; }
.mw-theater-prep-status {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--theater-fg);
}
.mw-theater-prep-label {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--theater-fg-dim);
}
.mw-theater-prep-bar {
  position: relative;
  height: 6px;
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}
.mw-theater-prep-bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--theater-accent), var(--theater-cyan));
  border-radius: 999px;
  transition: width 0.25s ease;
}
.mw-theater-prep-bar-fill--audio {
  background: linear-gradient(90deg, var(--theater-cyan), #7dd3fc);
}
.mw-theater-prep-detail {
  margin: 0;
  font-size: 0.82rem;
  color: var(--theater-fg-muted);
  min-height: 1.2em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mw-theater-prep-cancel {
  align-self: flex-end;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--theater-fg-muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
}
.mw-theater-prep-cancel:hover { color: var(--theater-fg); background: rgba(255, 255, 255, 0.05); }

/* ----------------------------------------------------------------------------
 * Responsive collapses.
 * ---------------------------------------------------------------------------- */

@media (max-width: 720px) {
  .mw-theater-topbar-kicker { display: none; }
  .mw-theater-topbar-ai { display: none; }
  .mw-theater-track-title { max-width: 50vw; }
  .mw-theater-bar { padding: 0.5rem 0.75rem 0.6rem; }
  .mw-theater-bar-row { grid-template-columns: 1fr auto 1fr; gap: 0.6rem; }
  .mw-theater-bar-left .mw-theater-track-eyebrow { display: none; }
  .mw-theater-rate,
  .mw-theater-engine,
  .mw-theater-render,
  .mw-theater-volume { display: none; }
  .mw-theater-ctrl { width: 38px; height: 38px; }
  /* Mobile: bigger primary so the thumb has a real touch target. */
  .mw-theater-ctrl--primary { width: 72px; height: 72px; font-size: 1.7rem; }
  .mw-theater-caption { font-size: 1.05rem; line-height: 1.55; }
  .mw-theater-prep { padding: 1rem; }
}

#theaterDownload[disabled] { opacity: 0.45; cursor: not-allowed; }
