:root {
  --bg: #0c0b0a;
  --paper: #1a1612;
  --ink: #f3ead7;
  --dim: rgba(243, 234, 215, 0.62);
  --accent: #c4a36a;
  --chip: #2a2118;
  --span-on: rgba(196, 163, 106, 0.18);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink);
             font-family: Georgia, "Times New Roman", serif; }
header {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--paper);
  border-bottom: 1px solid #3a3228;
  position: sticky; top: 0; z-index: 10;
}
#btn-play { flex-shrink: 0; }
header h1 { margin: 0; font-size: 20px; font-weight: 500; }
.sub, .crumb, .status { font-size: 12px; color: var(--dim);
                        font-family: system-ui, sans-serif; }
.crumb { color: var(--accent); text-decoration: none; }
.spacer { flex: 1; }
button {
  background: var(--accent); color: #1a140c; border: 0; border-radius: 4px;
  padding: 7px 16px; font: 13px system-ui, sans-serif; cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: default; }
button.ghost, .chapter-btn {
  background: transparent; color: var(--ink);
  border: 1px solid #3a3228;
}
.chapter-btn.on {
  background: var(--accent); color: #1a140c; border-color: var(--accent);
}
main { max-width: 980px; margin: 0 auto; padding: 20px; }
#stage {
  position: relative; width: 100%; aspect-ratio: 16 / 10;
  background: #111; border: 1px solid #3a3228; overflow: hidden;
  border-radius: 6px;
}
.still {
  position: absolute; inset: 0; background: #111 center/contain no-repeat;
  opacity: 0; transition: opacity 700ms ease;
}
.still.on { opacity: 1; }
#speaker-chip {
  position: absolute; left: 16px; bottom: 16px;
  background: var(--chip); color: var(--ink);
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--accent); font-family: system-ui, sans-serif;
  font-size: 14px; letter-spacing: 0.02em; z-index: 3;
}
#speaker-chip .who {
  display: block; font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--accent);
}
#still-reason {
  position: absolute; right: 16px; bottom: 16px; z-index: 3;
  font-family: system-ui, sans-serif; font-size: 11px; color: var(--dim);
}
#on-screen { color: var(--dim); font-size: 13px; font-family: system-ui, sans-serif; }
#line { font-size: 18px; line-height: 1.5; min-height: 3em; }
audio { width: 100%; margin-top: 8px; }

#chapter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 10px;
}
.sr-controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 12px 0; font-family: system-ui, sans-serif;
}
.sr-ctrl-btn {
  min-width: 44px; min-height: 40px;
  padding: 8px 12px;
}
.sr-speed-control {
  display: flex; align-items: center; gap: 8px; flex: 1 1 220px;
  min-width: 180px;
}
.sr-slider {
  flex: 1; accent-color: var(--accent); min-width: 80px; height: 32px;
}
.sr-wpm-label, .sr-rate-label, .sr-time {
  font-size: 12px; color: var(--dim); white-space: nowrap;
}
.sr-wpm-label { color: var(--accent); min-width: 72px; }
#sr-progress {
  position: relative; height: 10px; background: #2a2118;
  border-radius: 999px; cursor: pointer; margin: 8px 0 4px;
}
#sr-progress-fill {
  height: 100%; width: 0; background: var(--accent); border-radius: 999px;
}

#teleprompter {
  max-height: min(48vh, 420px); overflow-y: auto;
  padding: 8px 4px 48px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.sr-span {
  margin: 0 0 12px; padding: 10px 12px; border-radius: 6px;
  line-height: 1.55; font-size: 17px; color: var(--dim);
  cursor: pointer;
}
.sr-span.on {
  background: var(--span-on); color: var(--ink);
  box-shadow: inset 3px 0 0 var(--accent);
}
.sr-who {
  display: inline-block; font-family: system-ui, sans-serif;
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); margin-right: 6px;
}

@media (max-width: 640px) {
  header { padding: 10px 12px; }
  header h1 { font-size: 16px; }
  main { padding: 12px; }
  #stage { aspect-ratio: 4 / 3; }
  #line { font-size: 16px; min-height: 2.4em; }
  .sr-span { font-size: 16px; }
  #teleprompter { max-height: 42vh; }
  #speaker-chip { left: 10px; bottom: 10px; font-size: 13px; }
  button, .sr-ctrl-btn { min-height: 40px; }
}
