:root {
  --bg: #f8f6f2;
  --fg: #1f2933;
  --muted: #6b7280;
  --border: #ddd8cf;
  --primary: #456a8f;
  --primary-fg: #fff;
  --mine: rgba(69, 106, 143, 0.1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --fg: #e5e7eb;
    --muted: #9ca3af;
    --border: #2a323d;
    --primary: #7fa6cc;
    --primary-fg: #0f141b;
    --mine: rgba(127, 166, 204, 0.14);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 42rem; margin: 0 auto; padding: 24px 16px 45vh; }
h1 { font-family: Georgia, serif; margin: 0 0 8px; }
.kicker { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; margin: 0; }
.privacy { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 16px 0; }
.privacy summary { cursor: pointer; font-weight: 600; }
.privacy li { margin: 6px 0; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.controls label { display: flex; flex-direction: column; font-size: 14px; color: var(--muted); flex: 1 1 100%; }
select, button {
  font: inherit;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  padding: 9px 14px;
}
select { margin-top: 4px; }
button { cursor: pointer; }
button:disabled { opacity: 0.5; cursor: default; }
.text { margin-top: 20px; font-family: Georgia, serif; font-size: 18px; line-height: 1.7; }
/* manipulation: no double-tap zoom, so double-tap can mean "start here";
   no text selection, so a double-tap doesn't select a word */
.text { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.speech { margin: 8px -12px 0; padding: 4px 12px; border-radius: 6px; }
/* Finding the reader's place again: the frame goes dashed */
.text.searching .speech.current { outline-style: dashed; }
.speech.current { background: var(--mine); box-shadow: inset 3px 0 0 var(--primary); outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent); }
.speaker { font-weight: 700; letter-spacing: 0.02em; margin-top: 8px; }
.direction { font-style: italic; color: var(--muted); padding-left: 2em; }
.line { padding-left: 1.5em; text-indent: -1.5em; border-radius: 4px; transition: background-color 0.6s ease; }
/* The line being read: a soft tint that fades in and out as the reader moves */
.line.reading { background: color-mix(in srgb, var(--primary) 16%, transparent); }
.bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 8px 16px max(10px, env(safe-area-inset-bottom));
  /* Solid, not a frosted blur: iPhones redraw a blur behind a fixed bar on
     every scroll frame, which made scrolling judder */
  background: var(--bg);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
}
.bar .top { max-width: 42rem; margin: 0 auto 6px; display: flex; gap: 12px; align-items: baseline; }
.bar .info {
  flex: 1; min-width: 0; margin: 0;
  font-size: 14px; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar .pos { color: var(--muted); font-size: 13px; white-space: nowrap; }
.bar progress { display: block; width: 100%; max-width: 42rem; height: 6px; margin: 0 auto 8px; accent-color: var(--primary); }
.bar progress[hidden] { display: none; }
.bar .row { max-width: 42rem; margin: 0 auto; display: flex; gap: 8px; align-items: center; }
.bar .row #voice { flex: 1; }
#voice { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); font-weight: 600; white-space: nowrap; }
#voice[data-state="on"] { background: #b42318; border-color: #b42318; color: #fff; }
#voice[data-state="on"]::before { content: "● "; }
#voice[data-state="loading"] { background: transparent; color: var(--fg); border-color: var(--border); }
@media (prefers-reduced-motion: reduce) {
  .line { transition: none; }
}

a { color: var(--primary); }
.kicker a { color: inherit; text-decoration: none; }
#scene-heading { font-weight: 600; margin: 4px 0 12px; }
#scene-heading a { font-weight: 400; margin-left: 8px; font-size: 14px; }
.consent { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin: 16px 0; }
.consent h2 { font-size: 18px; margin: 0 0 8px; }
.consent dt { font-weight: 600; margin-top: 10px; }
.consent dd { margin: 2px 0 0; font-size: 15px; }
.agree { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 10px; border-radius: 6px; background: var(--mine); font-weight: 600; cursor: pointer; }
.agree input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--primary); }
#voice:disabled { opacity: 0.55; }
.terms { padding-bottom: 48px; }
.terms h2 { font-size: 20px; margin: 28px 0 8px; font-family: Georgia, serif; }
.terms table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 8px 0; }
.terms th, .terms td { text-align: left; vertical-align: top; padding: 8px; border-bottom: 1px solid var(--border); }
.terms li { margin: 6px 0; }
