/* Voice Prompter. One dark look on purpose: it sits beside a camera, where a bright screen glares
   and lights the reader's face. Layout: one narrow column (library, then the open script), and a
   full-screen prompter laid over it. */
:root {
  --bg: #0d1117;
  --panel: #151b24;
  --raise: #1c2430;
  --line: #2a3442;
  --fg: #e9edf3;
  --muted: #9aa5b4;
  --dim: #5d6878;
  --accent: #f0b445;
  --accent-ink: #1a1305;
  --danger: #ef6a55;
  --ok: #6cc59a;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --read: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 10px;
  color-scheme: dark;
}
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 var(--font);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 32px;
}
body.locked { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 18px 4px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { margin: 0; font-size: 1.3rem; letter-spacing: 0.01em; font-weight: 700; }
.mark { width: 28px; height: 28px; flex: none; border-radius: 7px; background: var(--raise); position: relative; border: 1px solid var(--line); }
.mark::before { content: ""; position: absolute; left: 5px; top: 9px; border: 5px solid transparent; border-left: 7px solid var(--accent); border-right: 0; }
.mark::after { content: ""; position: absolute; left: 14px; right: 5px; top: 13px; height: 2px; background: var(--fg); border-radius: 1px; box-shadow: 0 -5px 0 var(--dim), 0 5px 0 var(--dim); }

/* ---------- buttons ---------- */
.btn { border: 1px solid var(--line); background: var(--raise); padding: 10px 16px; border-radius: var(--r); font-weight: 600; min-height: 44px; }
.btn:hover { border-color: var(--muted); }
.btn.p { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.p:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.warn { color: var(--danger); background: transparent; }
.btn.warn.armed { background: var(--danger); color: #1b0905; border-color: var(--danger); }
.btn.big { width: 100%; font-size: 1.1rem; min-height: 54px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- library ---------- */
.lib { display: flex; flex-direction: column; gap: 10px; }
.card { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-height: 64px; }
.card:hover { border-color: var(--muted); }
.card .t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card b { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card small { color: var(--muted); font-variant-numeric: tabular-nums; }
.card .go { color: var(--accent); font-weight: 700; font-size: 0.9rem; flex: none; }
.empty { border: 1px dashed var(--line); border-radius: var(--r); padding: 22px; color: var(--muted); text-align: center; }
.tag { display: inline-block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; margin-right: 6px; vertical-align: 1px; }

/* ---------- editor ---------- */
.ed { display: flex; flex-direction: column; gap: 14px; }
.ed label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 6px; }
.in { width: 100%; box-sizing: border-box; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.in:focus { border-color: var(--accent); outline: none; }
textarea.in { min-height: 46vh; resize: vertical; line-height: 1.6; font-size: 1.05rem; }
.meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.saved { color: var(--ok); }
.saved.bad { color: var(--danger); }
.help { color: var(--muted); font-size: 0.85rem; margin: 0; }
.help code { background: var(--raise); padding: 1px 5px; border-radius: 4px; color: var(--fg); }

/* ---------- settings ---------- */
details.set { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
details.set summary { padding: 14px 16px; font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
details.set summary::-webkit-details-marker { display: none; }
details.set summary::after { content: "+"; color: var(--muted); }
details.set[open] summary::after { content: "\2212"; }
.set .body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.opt { display: grid; grid-template-columns: minmax(0, 9rem) minmax(0, 1fr); gap: 12px; align-items: center; }
.opt > span { color: var(--muted); font-size: 0.9rem; }
.opt select, .opt input[type="range"] { width: 100%; }
.opt select { background: var(--raise); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }
.check { display: flex; gap: 10px; align-items: center; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
input[type="range"] { accent-color: var(--accent); }
.note { margin: 0; color: var(--muted); font-size: 0.85rem; }
.note.warnc { color: var(--accent); }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); padding-top: 16px; display: flex; flex-direction: column; gap: 12px; color: var(--muted); font-size: 0.85rem; }
.foot p { margin: 0; }
.msg { min-height: 1.2em; color: var(--accent); font-size: 0.9rem; margin: 0; }

/* ---------- the prompter ---------- */
.ov { position: fixed; inset: 0; background: #000; z-index: 50; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.ov .view { position: absolute; inset: 0; overflow: hidden; }
.ov .text { position: absolute; left: 0; right: 0; top: 0; padding: 0 max(6vw, 20px, env(safe-area-inset-right, 0px)) 80vh max(6vw, 20px, env(safe-area-inset-left, 0px)); font-family: var(--read); font-weight: 600; line-height: 1.35; color: #f4f6f8; will-change: transform; transform-origin: center top; }
.ov .line { margin: 0 0 0.25em; }
.ov .br { display: block; height: 0.6em; }
.ov .h { color: var(--accent); font-size: 0.55em; text-transform: uppercase; letter-spacing: 0.12em; margin: 0.9em 0 0.3em; }
.ov .nt { color: #8d98a8; font-style: italic; font-size: 0.6em; margin: 0.2em 0 0.5em; }
.ov .w { transition: color 0.25s; }
.ov .w.done { color: #4d5764; }
.ov .w.now { color: #fff; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 0.08em; text-underline-offset: 0.18em; }
.ov .rl { position: absolute; left: 0; right: 0; height: 1.35em; pointer-events: none; background: linear-gradient(90deg, rgba(240, 180, 69, 0.14), rgba(240, 180, 69, 0) 60%); border-left: 4px solid var(--accent); }
.ov.paused .text { opacity: 0.55; }
.ov.paused .rl { border-left-color: #8d98a8; background: none; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 10px max(12px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); background: linear-gradient(0deg, rgba(0, 0, 0, 0.92), rgba(0, 0, 0, 0.7)); }
.bar button { background: #1b222c; border: 1px solid #333d4b; color: #e9edf3; border-radius: 9px; min-width: 44px; min-height: 44px; padding: 0 12px; font-weight: 700; }
.bar button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.bar .grow { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #3b4451; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 4px rgba(108, 197, 154, 0.18); }
.heard { color: #8d98a8; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; min-width: 0; }
.ov .pmsg { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom, 0px)); max-width: min(92vw, 560px); margin: 0; background: #1b222c; border: 1px solid #333d4b; color: var(--accent); border-radius: 9px; padding: 10px 14px; font-size: 0.95rem; text-align: center; }
.ov .pmsg:empty { display: none; }
.ov .end { position: absolute; inset: auto 0 calc(90px + env(safe-area-inset-bottom, 0px)) 0; text-align: center; color: #8d98a8; font-size: 0.95rem; pointer-events: none; }

@media (max-width: 420px) {
  .opt { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .bar { gap: 6px; }
  .bar button { padding: 0 9px; }
}
@media (prefers-reduced-motion: reduce) { .ov .w { transition: none; } }
