/* Prompter — setup chrome is a normal light UI; the stage is whatever the
   presenter picked. Two visual worlds on purpose: the stage must never inherit
   an accent colour that shows up on a beam-splitter. */

:root {
  --ink: #2d2a26;
  --muted: #7a7468;
  --line: #e2ddd2;
  --paper: #f4f1ea;
  --card: #ffffff;
  --accent: #2d6a4f;
}

* { box-sizing: border-box; }

/* The UA rule for [hidden] is only `display: none`, so ANY author display rule
   beats it. #countdown sets display:flex, which meant hiding the overlay did
   nothing and it covered the script forever. Make [hidden] actually win. */
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, sans-serif;
  background: var(--paper); color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

/* ───────── setup ───────── */
#setup { max-width: 1180px; margin: 0 auto; padding: 28px 22px 96px; }
#setup header h1 { font-size: 1.5rem; margin: 0 0 2px; letter-spacing: -0.01em; }
#setup header .sub { margin: 0 0 20px; color: var(--muted); font-size: 0.93rem; }

#setup main {
  display: grid; gap: 18px;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  grid-template-areas: "script settings" "library settings";
  align-items: start;
}
.script-pane { grid-area: script; }
.settings-pane { grid-area: settings; }
.library-pane { grid-area: library; }
@media (max-width: 860px) {
  #setup main { grid-template-columns: 1fr; grid-template-areas: "script" "settings" "library"; }
}

.pane {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px;
}
.pane-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.pane-head label { font-weight: 650; font-size: 0.9rem; }
.pane-actions { display: flex; gap: 8px; }

button {
  font: inherit; font-size: 0.86rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 13px;
}
button:hover { background: #faf8f4; }
button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  font-weight: 600; padding: 10px 22px; font-size: 0.95rem;
}
button.primary:hover { background: #245740; }
button:disabled { opacity: 0.45; cursor: default; }

/* script box */
#drop { position: relative; }
#script-input {
  width: 100%; min-height: 320px; resize: vertical;
  font: inherit; font-size: 0.94rem; line-height: 1.55;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: #fffdf9; color: var(--ink);
}
#script-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#drop-hint {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center;
  border: 2px dashed var(--accent); border-radius: 10px;
  background: rgba(45, 106, 79, 0.07); color: var(--accent);
  font-weight: 600; pointer-events: none;
}
#drop.over #drop-hint { display: flex; }

.readout { display: flex; gap: 26px; margin-top: 12px; }
.readout div { display: flex; flex-direction: column; }
.readout b { font-size: 1.25rem; font-weight: 650; line-height: 1.2; }
.readout span { color: var(--muted); font-size: 0.8rem; }
.readout i { font-style: normal; }

/* settings */
.group { padding: 12px 0; border-top: 1px solid var(--line); }
.group:first-of-type { border-top: 0; padding-top: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

.field label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.84rem; font-weight: 600; margin-bottom: 6px;
}
.field .val { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.field select {
  width: 100%; font: inherit; font-size: 0.88rem; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.hint { color: var(--muted); font-size: 0.78rem; margin: 6px 0 0; line-height: 1.45; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
input[type="color"] {
  width: 42px; height: 32px; padding: 2px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.swatches { display: flex; gap: 6px; }
.swatch {
  width: 30px; height: 30px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line); font-size: 0.62rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.checks { display: flex; flex-direction: column; gap: 9px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 0.86rem; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.check i { color: var(--muted); font-style: normal; font-size: 0.8rem; }

/* library */
#library { list-style: none; margin: 0; padding: 0; }
#library li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
#library li:last-child { border-bottom: 0; }
#library .name { flex: 1; font-size: 0.9rem; font-weight: 550; }
#library .meta { color: var(--muted); font-size: 0.78rem; }
#library button { padding: 5px 10px; font-size: 0.78rem; }

/* footer bar */
#setup footer {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px; background: rgba(244, 241, 234, 0.94);
  border-top: 1px solid var(--line); backdrop-filter: blur(8px);
}
#setup footer .spacer { flex: 1; }
.foot-hint { color: var(--muted); font-size: 0.82rem; }

/* ───────── stage ───────── */
#stage {
  position: fixed; inset: 0; overflow: hidden;
  background: var(--stage-bg, #000); color: var(--stage-fg, #fff);
  font-family: var(--stage-font, Georgia, serif);
  cursor: none;
}
#stage.controls-visible { cursor: default; }

#viewport { position: absolute; inset: 0; overflow: hidden; }
#flip { will-change: transform; }
#script {
  width: var(--stage-width, 72%); margin: 0 auto;
  font-size: var(--stage-size, 46px);
  line-height: var(--stage-lh, 1.55);
  font-weight: 600;
  padding-top: var(--pad-top, 42vh);
  padding-bottom: var(--pad-bottom, 58vh);
  will-change: transform;
  /* A long word must wrap rather than run off the edge — on a phone column
     "TELEPROMPTER" is wider than the screen. */
  overflow-wrap: break-word;
  word-break: break-word;
}
#script p { margin: 0 0 1.1em; }
#script h2 {
  margin: 0 0 0.7em; font-size: 0.72em; font-weight: 700;
  letter-spacing: 0.13em; text-transform: uppercase; opacity: 0.45;
}
#script .cue {
  opacity: 0.42; font-style: italic; font-weight: 500;
}

#readline {
  position: absolute; left: 0; right: 0; top: var(--readline, 42vh); height: 0;
  border-top: 2px solid rgba(255, 200, 0, 0.42);
  pointer-events: none; z-index: 3;
}
#stage.rolling #readline { border-top-color: rgba(120, 255, 170, 0.42); }
#stage.no-readline #readline { display: none; }

.dim { position: absolute; left: 0; right: 0; pointer-events: none; z-index: 2; }
#dim-top { top: 0; height: var(--readline, 42vh);
  background: linear-gradient(to bottom, var(--stage-bg, #000) 0%, transparent 100%); opacity: 0.72; }
#dim-bottom { top: var(--readline, 42vh); bottom: 0;
  background: linear-gradient(to bottom, transparent 45%, var(--stage-bg, #000) 100%); opacity: 0.72; }
#stage.no-dim .dim { display: none; }

#hud, #help, #touch-hint {
  position: absolute; z-index: 6;
  font-family: -apple-system, Helvetica, sans-serif; font-weight: 500;
  opacity: 0.55; transition: opacity 0.25s;
  user-select: none; pointer-events: none;
}
#hud { top: 14px; right: 20px; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.hud-sep { opacity: 0.4; margin: 0 6px; }
#help { bottom: 44px; left: 0; right: 0; text-align: center; font-size: 0.76rem; }
#help b { font-weight: 700; }
#touch-hint { bottom: 26px; left: 0; right: 0; text-align: center; font-size: 0.72rem; display: none; }
#stage.hide-help #help, #stage.hide-help #touch-hint { display: none; }
#stage.touch #touch-hint { display: block; }
#stage.touch #help { display: none; }

#progress {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: rgba(128, 128, 128, 0.22); z-index: 6;
}
#progress-bar { height: 100%; width: 0%; background: currentColor; opacity: 0.5; }

#countdown {
  position: absolute; inset: 0; z-index: 8;
  display: flex; align-items: center; justify-content: center;
  background: var(--stage-bg, #000);
}
#countdown span { font-size: 22vh; font-weight: 700; opacity: 0.9; }

#chapters {
  position: absolute; inset: 0; z-index: 9; overflow-y: auto;
  background: var(--stage-bg, #000); padding: 8vh 10vw;
  font-family: -apple-system, Helvetica, sans-serif;
}
#chapters h2 { font-size: 1rem; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.5; }
#chapters ul { list-style: none; padding: 0; margin: 0 0 24px; }
#chapters li {
  padding: 14px 0; border-bottom: 1px solid rgba(128, 128, 128, 0.25);
  font-size: 1.25rem; cursor: pointer; display: flex; gap: 16px;
}
#chapters li:hover { opacity: 0.65; }
#chapters li .at { opacity: 0.45; font-variant-numeric: tabular-nums; font-size: 0.95rem; }
#chapters .hint { color: inherit; opacity: 0.45; }
