:root {
  --bg: #0b0b0c;
  --panel: #151517;
  --line: #2a2a2e;
  --fg: #f4f1ea;
  --muted: #9a968d;
  --accent: #e8b84a;
  --size: 64px;
  --lh: 1.35;
  --width: 80%;
  --guide: 33%;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ───────── Editor ───────── */
.editor { display: flex; flex-direction: column; height: 100%; max-width: 1200px; margin: 0 auto; padding: 24px; }
.ed-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.ed-head h1 { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: .02em; }
.stats { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats b { color: var(--accent); font-weight: 600; }

.ed-body { flex: 1; display: grid; grid-template-columns: 1fr 280px; gap: 20px; min-height: 0; }
textarea {
  width: 100%; height: 100%; resize: none; padding: 20px;
  background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 10px;
  font: 18px/1.6 system-ui, sans-serif; outline: none;
}
textarea:focus { border-color: #4a4a50; }
textarea.drop { border-color: var(--accent); }

.settings { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; overflow-x: hidden; padding: 2px; }
.field label { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.field output { color: var(--fg); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.actions { display: flex; gap: 10px; margin-top: 6px; }
.btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 14px; border-radius: 8px; border: 1px solid var(--line);
  font: 600 15px system-ui, sans-serif; cursor: pointer; background: transparent; color: var(--fg);
}
.btn.primary { background: var(--accent); color: #17130a; border-color: var(--accent); }
.btn.primary:disabled { opacity: .4; cursor: not-allowed; }
.btn:focus-visible, .ic:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.keys { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }
.keys summary { cursor: pointer; color: var(--fg); }
.keys dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0; }
.keys dt { color: var(--fg); white-space: nowrap; }
.keys dd { margin: 0; }

@media (max-width: 760px) {
  .editor { padding: 16px; height: auto; min-height: 100%; }
  .ed-body { grid-template-columns: 1fr; }
  textarea { height: 45vh; }
}

/* ───────── Prompter ───────── */
.prompter { position: fixed; inset: 0; background: #000; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.prompter.idle { cursor: none; }

.stage { position: absolute; inset: 0; }
.stage.mirror { transform: scaleX(-1); }
.track { position: absolute; left: 0; right: 0; top: var(--guide); will-change: transform; }
.text {
  width: var(--width); margin: 0 auto;
  font-size: var(--size); line-height: var(--lh); font-weight: 500;
  color: var(--fg); text-align: left; overflow-wrap: break-word; hyphens: manual;
}
.text.center { text-align: center; }
.text p { margin: 0 0 calc(var(--size) * .9); }
.text .cue { font-size: .45em; color: var(--accent); opacity: .75; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

/* Leseband: genau eine Zeilenhöhe ab der Leselinie */
.band {
  position: absolute; left: 0; right: 0; top: var(--guide);
  height: calc(var(--size) * var(--lh));
  background: rgba(232, 184, 74, .07);
  border-top: 1px solid rgba(232, 184, 74, .25);
  border-bottom: 1px solid rgba(232, 184, 74, .25);
  pointer-events: none;
}
.band::before, .band::after {
  content: ""; position: absolute; top: 50%; transform: translateY(-50%);
  border: 12px solid transparent;
}
.band::before { left: 6px; border-left-color: var(--accent); }
.band::after { right: 6px; border-right-color: var(--accent); }

.fade { position: absolute; left: 0; right: 0; pointer-events: none; }
.fade.top { top: 0; height: calc(var(--guide) - 4px); background: linear-gradient(#000 0%, rgba(0,0,0,.55) 100%); }
.fade.bottom { bottom: 0; height: 22%; background: linear-gradient(rgba(0,0,0,0), #000); }

.count {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 700 28vmin/1 system-ui, sans-serif; color: var(--accent); pointer-events: none;
}
.count.tick { animation: tick .9s ease-out both; }
@keyframes tick { from { opacity: 1; transform: scale(1.15); } to { opacity: .15; transform: scale(.9); } }

.hud {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.85) 40%);
  transition: opacity .3s ease;
}
.prompter.idle .hud { opacity: 0; pointer-events: none; }
.progress { height: 3px; background: #222; border-radius: 2px; margin: 18px 0 12px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); }
.hud-row { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.ic {
  min-width: 44px; height: 44px; padding: 0 12px; border-radius: 22px;
  background: rgba(255,255,255,.08); color: var(--fg); border: 0;
  font: 600 17px system-ui, sans-serif; cursor: pointer;
}
.ic:hover { background: rgba(255,255,255,.16); }
.ic.play { background: var(--accent); color: #17130a; min-width: 60px; }
.ic.on { color: var(--accent); }
.hud-info { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 15px; padding: 0 10px; }

@media (prefers-reduced-motion: reduce) {
  .count.tick { animation: none; }
  .hud { transition: none; }
}

.text .cue { hyphens: manual; }

/* Schmale Bildschirme (Handy im Prompter-Glas): Steuerleiste in zwei Zeilen */
@media (max-width: 520px) {
  .hud { padding-left: 8px; padding-right: 8px; }
  .hud-row { gap: 5px; }
  .hud-info { order: -1; flex-basis: 100%; text-align: center; padding-bottom: 4px; }
  .ic { min-width: 38px; height: 40px; padding: 0 8px; font-size: 15px; }
  .ic.play { min-width: 50px; }
  #fs { display: none; }
}

/* ───────── Stimm-Modus ───────── */
.text { position: relative; }
.voicebox { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.voicebox .inline { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); }
.voicebox select { background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font: 14px system-ui, sans-serif; }
.note { margin: 0; font-size: 12px; line-height: 1.45; color: var(--muted); }

/* Gelesenes tritt zurück, damit das Auge vorne bleibt */
.text .w { transition: opacity .35s ease; }
.text .w.done { opacity: .38; }

/* Zuhör-Anzeige: Punkt pulsiert nur, solange das Mikrofon wirklich läuft */
.live { display: none; width: 8px; height: 8px; border-radius: 50%; background: #e5534b; margin-right: 8px; vertical-align: middle; }
.prompter.voice .live { display: inline-block; opacity: .35; }
.prompter.voice.listening .live { opacity: 1; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.voice-msg {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%); margin: 0;
  max-width: 90%; padding: 8px 14px; border-radius: 8px;
  background: rgba(229, 83, 75, .15); color: #f2b8b4; font-size: 15px; text-align: center;
}
.voice-msg:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  .text .w { transition: none; }
  .prompter.voice.listening .live { animation: none; }
}

/* Im Stimm-Modus gibt es kein festes Tempo */
.prompter.voice #slower, .prompter.voice #faster { display: none; }
