:root {
  --bg: #0a0d11;
  --panel: rgba(13, 17, 23, 0.86);
  --panel-solid: #131920;
  --line: rgba(255, 255, 255, 0.08);
  --line-gold: rgba(212, 175, 95, 0.35);
  --gold: #d4af5f;
  --gold-hi: #f1d48a;
  --text: #f1ebdd;
  --muted: #a59d8b;
  --live: #e5484d;
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Cinzel', Georgia, serif;
  --font-verse: Georgia, 'Times New Roman', serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font-ui);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }

/* ── Top bar ───────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #121821, #0d1218);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--gold-hi); text-decoration: none; flex: none; }
.brand-mark { width: 30px; height: 30px; }
.brand-name { font: 700 19px/1 var(--font-display); letter-spacing: 0.04em; color: var(--text); }
.brand-tld { color: var(--gold); }

.live-pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 11px; flex: none;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  font: 700 11px/1 var(--font-ui); letter-spacing: 0.1em;
  cursor: pointer;
}
.live-pill:hover { background: rgba(255, 255, 255, 0.1); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live-pill.is-live { border-color: rgba(229, 72, 77, 0.5); background: rgba(229, 72, 77, 0.14); cursor: default; }
.live-pill.is-live .live-dot { background: var(--live); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.8); } }

.search { position: relative; flex: 1; max-width: 560px; margin: 0 auto; }
.search-icon { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 38px;
  padding: 0 40px 0 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: 14px var(--font-ui);
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--line-gold); background: rgba(255, 255, 255, 0.09); }
.search input::-webkit-search-cancel-button { display: none; }
.search-kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font: 600 11px var(--font-ui); color: var(--muted);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px;
}
.search input:focus ~ .search-kbd { display: none; }

.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  max-height: min(460px, 70vh); overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--line-gold);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  padding: 6px;
}
.sr-heading { padding: 8px 10px 6px; color: var(--muted); font-size: 12px; }
.sr-item { padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.sr-item[aria-selected="true"], .sr-item:hover { background: rgba(212, 175, 95, 0.12); }
.sr-ref { font-weight: 700; color: var(--gold-hi); font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sr-from { color: var(--muted); font-weight: 500; }
.sr-text { color: var(--text); font: 14px/1.45 var(--font-verse); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sr-story .sr-text { font-family: var(--font-ui); font-size: 12.5px; color: var(--muted); }
.sr-badge { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; background: rgba(212, 175, 95, 0.2); color: var(--gold-hi); padding: 2px 6px; border-radius: 4px; }
mark { background: rgba(241, 212, 138, 0.28); color: inherit; border-radius: 2px; padding: 0 1px; }

.top-links { flex: none; }
.top-links a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 13px; }
.top-links a:hover { color: var(--text); }

/* ── Timeline ─────────────────────────────────────────── */
.timeline { background: #0d1218; border-bottom: 1px solid var(--line); position: relative; z-index: 10; }
.tl-eras { display: flex; position: relative; height: 20px; }
.tl-era {
  flex: 1 1 0; min-width: 0;
  border: 0; padding: 0 6px;
  background: color-mix(in srgb, var(--era) 32%, #0d1218);
  border-right: 1px solid rgba(0, 0, 0, 0.4);
  color: var(--text);
  font: 600 10px/20px var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.tl-era:hover { background: color-mix(in srgb, var(--era) 55%, #0d1218); }
.tl-playhead {
  position: absolute; top: 0; bottom: -3px; width: 3px; margin-left: -1px;
  background: #fff; box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
  pointer-events: none;
}
.tl-track {
  display: flex; gap: 6px;
  overflow-x: auto; position: relative;
  padding: 8px 16px 9px;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.tl-chip {
  flex: none; position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  min-width: 118px; max-width: 180px;
  padding: 5px 11px 7px;
  text-align: left;
  border-radius: 8px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--era);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
}
.tl-chip:hover { background: rgba(255, 255, 255, 0.08); }
.tl-date { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.tl-title { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tl-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--era); transform: scaleX(0); transform-origin: left; }
.tl-chip.is-active { background: color-mix(in srgb, var(--era) 18%, transparent); border-color: color-mix(in srgb, var(--era) 60%, transparent); }
.tl-chip.is-active .tl-date { color: var(--era); }

/* ── Stage ────────────────────────────────────────────── */
.stage { position: relative; overflow: hidden; min-height: 0; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#world.is-dragging { cursor: grabbing; }
.terrain3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }

.controls {
  position: absolute; top: 12px; left: 12px;
  display: flex; align-items: center; gap: 2px; padding: 4px;
  background: var(--panel); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 12px;
}
.ctl {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; cursor: pointer;
}
.ctl svg { width: 18px; height: 18px; fill: currentColor; }
.ctl svg[fill="none"] { fill: none; }
.ctl:hover { background: rgba(255, 255, 255, 0.09); }
.ctl[aria-pressed="true"] { color: var(--gold-hi); background: rgba(212, 175, 95, 0.15); }
.ctl .i-pause, .ctl.is-playing .i-play { display: none; }
.ctl.is-playing .i-pause { display: block; }
.ctl-speed { width: auto; min-width: 40px; padding: 0 8px; font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.ctl-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

.caption {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  width: min(720px, calc(100% - 520px));
  padding: 14px 20px 14px;
  background: var(--panel); backdrop-filter: blur(10px);
  border: 1px solid var(--line-gold); border-top: 2px solid var(--era, var(--gold));
  border-radius: 14px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.caption.swap > :not(.cap-progress) { animation: rise 0.6s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.cap-meta { display: flex; gap: 10px; align-items: center; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.cap-era { color: var(--era, var(--gold)); }
.cap-date { color: var(--muted); }
.cap-title { margin: 4px 0 6px; font: 700 21px/1.2 var(--font-display); }
.cap-ref { font: 500 13px var(--font-ui); color: var(--muted); letter-spacing: 0; white-space: nowrap; }
.cap-say { margin: 0; font-size: 15px; line-height: 1.5; color: #e9e1cf; }
.cap-verse { margin: 10px 0 2px; padding: 8px 0 0 14px; border-left: 2px solid var(--gold); }
.cap-verse p { margin: 0; font: italic 16.5px/1.5 var(--font-verse); color: var(--gold-hi); }
.cap-verse cite { display: block; margin-top: 4px; font: 600 12px var(--font-ui); font-style: normal; color: var(--muted); }
.cap-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(255, 255, 255, 0.06); }
.cap-progress > div { height: 100%; background: var(--era, var(--gold)); transform-origin: left; transform: scaleX(0); }

.minimap {
  position: absolute; right: 16px; bottom: 18px;
  border-radius: 8px; border: 1px solid var(--line-gold);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  cursor: crosshair; touch-action: none;
}

.watermark {
  display: none;
  position: absolute; right: 22px; top: 18px;
  font: 700 22px var(--font-display); color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}
.watermark span { color: var(--gold-hi); }

.toast {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%);
  padding: 9px 16px; border-radius: 999px;
  background: var(--panel-solid); border: 1px solid var(--line-gold);
  font-weight: 600; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 30; opacity: 0; transition: opacity 0.25s;
}
.toast.show { opacity: 1; }

/* Clean view: map + caption only, for screen-recording clips */
body.clean { grid-template-rows: 0 0 minmax(0, 1fr); }
body.clean .stage { grid-row: 3; } /* hidden bars leave the grid, so pin the map to the tall row */
body.clean .topbar, body.clean .timeline, body.clean .controls, body.clean .minimap { display: none; }
body.clean .watermark { display: block; }
body.clean .caption { width: min(820px, calc(100% - 48px)); bottom: 28px; }

/* ── Quote card ───────────────────────────────────────── */
.qc-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 16px;
  background: rgba(4, 6, 10, 0.7); backdrop-filter: blur(4px);
}
.qc {
  position: relative; width: min(560px, 100%);
  padding: 36px 34px 22px;
  border-radius: 18px;
  background: radial-gradient(circle at 50% 0%, #2a2214, #12161c 70%);
  border: 1px solid var(--line-gold);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  text-align: center;
}
.qc-close { position: absolute; top: 10px; right: 12px; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; font-size: 22px; color: var(--muted); cursor: pointer; }
.qc-close:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.qc-text { margin: 0; font: italic 22px/1.5 var(--font-verse); color: var(--text); }
.qc-ref { margin: 16px 0 0; font: 700 15px var(--font-display); color: var(--gold-hi); letter-spacing: 0.04em; }
.qc-from { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; min-height: 1em; }
.qc-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.btn {
  height: 38px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06);
  font-weight: 600; cursor: pointer;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn-gold { background: var(--gold); color: #1a1408; border-color: var(--gold); }
.btn-gold:hover { background: var(--gold-hi); }
.qc-brand { margin: 18px 0 0; font: 700 13px var(--font-display); color: var(--muted); letter-spacing: 0.06em; }
.qc-brand span { color: var(--gold); }

.noscript { padding: 24px; text-align: center; }

/* ── Smaller screens ──────────────────────────────────── */
@media (max-width: 1180px) {
  .caption { left: 16px; transform: none; width: calc(100% - 32px - 236px); }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .top-links { margin-left: auto; }
  .brand-name { font-size: 17px; }
  .minimap { display: none; }
  .caption { left: 12px; right: 12px; width: auto; bottom: 12px; padding: 12px 14px; }
  .cap-title { font-size: 17px; }
  .cap-say { font-size: 14px; }
  .cap-verse p { font-size: 15px; }
  .controls { top: 8px; left: 8px; right: 8px; overflow-x: auto; }
  .ctl { flex: none; }
  .tl-track { padding: 6px 12px 7px; }
}
@media (prefers-reduced-motion: reduce) {
  .caption.swap > * { animation: none; }
  .live-pill.is-live .live-dot { animation: none; }
}

/* ── Read mode: Scripture line by line, speaker above ─── */
.cap-read {
  position: absolute; right: 14px; top: 12px;
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  border: 1px solid var(--line-gold); border-radius: 999px;
  background: rgba(212, 175, 95, 0.1); color: var(--gold-hi);
  font: 600 11.5px/1 var(--font-ui); letter-spacing: 0.02em; cursor: pointer;
}
.cap-read svg { width: 14px; height: 14px; }
.cap-read:hover { background: rgba(212, 175, 95, 0.22); }
body.clean .cap-read { display: none; }

/* The reading panel: same look as the caption (meta line, gold-ruled italic verse, cite), with the
   speaker's face rising above its top-left edge. */
.readbar {
  display: none;
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  width: min(720px, calc(100% - 520px));
  flex-direction: column; gap: 10px;
  padding: 14px 20px 12px;
  background: var(--panel); backdrop-filter: blur(10px);
  border: 1px solid var(--line-gold); border-top: 2px solid var(--era, var(--gold));
  border-radius: 14px; box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
}
body.reading .readbar { display: flex; }
body.reading .caption { display: none; }
.readbar .cap-progress { border-radius: 0 0 14px 14px; overflow: hidden; }

/* Round speaker portraits rise above the panel. Divine speakers keep the light treatment. */
.rd-face {
  position: absolute; left: 18px; top: -44px; z-index: 1;
  width: 78px; height: 78px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 35%, #3a2f1f, #16120c);
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 4px rgba(212, 175, 95, 0.14), 0 10px 26px rgba(0, 0, 0, 0.55);
}
.rd-face.swap { animation: rd-up 0.45s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes rd-up { from { opacity: 0; transform: translateY(16px) scale(0.92); } }
.rd-img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.rd-face[data-kind="hero"] { border-color: var(--gold-hi); box-shadow: 0 0 0 4px rgba(241, 212, 138, 0.22), 0 0 26px rgba(255, 222, 150, 0.35), 0 10px 26px rgba(0, 0, 0, 0.55); }
.rd-face[data-kind="angel"] { background: radial-gradient(circle at 50% 35%, #4a4334, #1c1912); box-shadow: 0 0 0 4px rgba(255, 246, 220, 0.18), 0 0 24px rgba(255, 246, 220, 0.3), 0 10px 26px rgba(0, 0, 0, 0.55); }
.rd-light { display: none; position: absolute; inset: 0; border-radius: 50%; overflow: hidden; }
.rd-light::before {
  content: ''; position: absolute; inset: -10%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 236, 180, 0.55) 0deg 4deg, rgba(255, 236, 180, 0) 4deg 15deg);
  -webkit-mask: radial-gradient(closest-side, #000 18%, rgba(0, 0, 0, 0.55) 45%, transparent 100%);
  mask: radial-gradient(closest-side, #000 18%, rgba(0, 0, 0, 0.55) 45%, transparent 100%);
  animation: rd-spin 40s linear infinite;
}
.rd-light i {
  position: absolute; left: 50%; top: 50%; width: 36px; height: 36px; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(closest-side, #fffdf5, #fff1c8 35%, rgba(255, 220, 140, 0.55) 62%, transparent);
  box-shadow: 0 0 30px 12px rgba(255, 222, 150, 0.45);
  animation: rd-breathe 4.5s ease-in-out infinite;
}
@keyframes rd-spin { to { transform: rotate(360deg); } }
@keyframes rd-breathe { 50% { transform: translate(-50%, -50%) scale(1.08); } }
.rd-face[data-kind="light"] { background: radial-gradient(circle, #3b3222, #120f0a); border-color: var(--gold-hi); }
.rd-face[data-kind="light"] .rd-light { display: block; }
.rd-face[data-kind="light"] .rd-img { display: none; }

.rd-body { padding-left: 86px; min-height: 64px; }
.rd-body.swap > * { animation: rise 0.6s ease both; }
.rd-name { color: var(--gold-hi); }
.rd-role { color: var(--muted); }
.rd-verse { margin-top: 8px; }
.rd-verse p { min-height: 3em; }
.rd-verse p[data-voice="light"] { color: #ffe6a6; }
.rd-verse p[data-voice="jesus"] { color: #ffcdb8; } /* a gentle nod to red-letter Bibles */

.rb-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-top: 10px; border-top: 1px solid var(--line);
}
.rb-pick { display: flex; gap: 6px; }
.readbar select {
  height: 32px; padding: 0 26px 0 10px; border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a59d8b' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 9px center / 9px;
  color: var(--text); font: 600 13px var(--font-ui); appearance: none; cursor: pointer;
}
.readbar select:hover { background-color: rgba(255, 255, 255, 0.1); }
.readbar select option { background: var(--panel-solid); color: var(--text); }
#rd-chapter { min-width: 62px; }
.rb-ctl { display: flex; gap: 2px; }
.rb-pos { flex: 1; min-width: 0; font: 700 13px var(--font-display); letter-spacing: 0.06em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.rb-close {
  height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-gold);
  background: rgba(212, 175, 95, 0.12); color: var(--gold-hi); font: 600 12.5px var(--font-ui); cursor: pointer; white-space: nowrap;
}
.rb-close:hover { background: rgba(212, 175, 95, 0.24); }
/* Clean view while reading: keep the verse and face for recording, drop the controls. */
body.clean .readbar { width: min(820px, calc(100% - 48px)); bottom: 28px; }
body.clean .rb-row { display: none; }

@media (max-width: 1180px) {
  .readbar { left: 16px; transform: none; width: calc(100% - 32px - 236px); }
}
@media (max-width: 760px) {
  .readbar { left: 12px; right: 12px; width: auto; bottom: 12px; padding: 12px 14px 10px; gap: 8px; }
  .rb-row { gap: 6px; }
  .rb-pos { display: none; }
  .rb-close { margin-left: auto; }
  .cap-read { position: static; margin-top: 8px; }
  .rd-face { left: 12px; top: -36px; width: 62px; height: 62px; }
  .rd-body { padding-left: 68px; min-height: 40px; }
  .rd-verse p { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .rd-body.swap > *, .rd-face.swap { animation: none; }
  .rd-light::before, .rd-light i { animation: none; }
}

/* ── Amazon affiliate picks (caption, read mode, quote card) ── */
.shop {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px;
  margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line);
  font: 500 12px/1.5 var(--font-ui);
}
.shop[hidden] { display: none; }
.shop-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.shop-links { display: contents; }
.shop a { color: var(--gold-hi); text-decoration: none; white-space: nowrap; border-bottom: 1px solid rgba(241, 212, 138, 0.25); }
.shop a::after { content: ' \2197'; font-size: 10px; opacity: 0.7; }
.shop a:hover { color: #fff3d0; border-bottom-color: var(--gold-hi); }
.shop-note { flex-basis: 100%; font-size: 10.5px; color: var(--muted); opacity: 0.75; }
.readbar .shop { margin-top: 0; padding-top: 0; border-top: 0; }
.shop-qc { justify-content: center; margin-top: 18px; padding-top: 14px; }
.shop-qc .shop-label { flex-basis: 100%; }
/* Never in recordings; on phones the caption stays compact (read mode and quote card keep them). */
body.clean .shop { display: none; }
@media (max-width: 760px) {
  .caption .shop { display: none; }
  .readbar .shop { font-size: 11.5px; }
}
