/* Full-page sermon reader. Colours come from the tokens in style.css. */
:root {
  --reading-size: 19px;
  --hl-yellow: #fbe7a1; --hl-green: #cdeccb; --hl-blue: #cfe3f7; --hl-pink: #f6d2e0;
}
@media (prefers-color-scheme: dark) {
  :root { --hl-yellow: #5a4a17; --hl-green: #284a2b; --hl-blue: #23405e; --hl-pink: #5a2a3d; }
}

.progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--accent); z-index: 30; transition: width .1s; }
.back { color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--accent); }
.sermon-page .top { justify-content: space-between; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 40px; max-width: 1240px; margin: 0 auto; padding: 32px 24px 120px; }
.sermon { max-width: 700px; width: 100%; justify-self: center; }

.s-head { margin-bottom: 32px; }
.kicker { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.s-head h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(28px, 4.5vw, 40px); line-height: 1.15; margin: 8px 0 10px; }
.s-meta { color: var(--muted); font-size: 14px; }
.key-text { margin: 22px 0 0; padding: 14px 18px; border-left: 3px solid var(--accent); background: var(--accent-soft);
  border-radius: 0 10px 10px 0; font-family: var(--serif); font-size: 17px; line-height: 1.55; font-style: italic; }
.key-text sup { font-family: var(--sans); font-style: normal; font-size: 10px; color: var(--muted); margin-right: 2px; }
.key-ref { font-family: var(--sans); font-style: normal; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.key-ref a { color: var(--accent); text-decoration: none; }

.s-body { font-family: var(--serif); font-size: var(--reading-size); line-height: 1.75; }
.para { position: relative; border-radius: 6px; transition: background .6s; }
.para p { margin: 0 0 1.1em; }
.pnum { position: absolute; left: -44px; top: .35em; width: 32px; text-align: right; font-family: var(--sans);
  font-size: 11px; color: var(--faint); text-decoration: none; opacity: 0; transition: opacity .2s; }
.para:hover .pnum { opacity: 1; }
.para.found { box-shadow: -14px 0 0 -10px var(--accent); }
.para.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background: var(--hit); } 100% { background: transparent; } }
.s-foot { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--faint); font-size: 13px; }
.s-foot a { color: var(--muted); }

mark.hl { color: inherit; border-radius: 3px; padding: 1px 0; cursor: pointer; }
mark.hl.yellow { background: var(--hl-yellow); }
mark.hl.green { background: var(--hl-green); }
mark.hl.blue { background: var(--hl-blue); }
mark.hl.pink { background: var(--hl-pink); }
mark.hl.has-note { border-bottom: 2px dotted var(--accent); }

/* right rail */
.rail { position: sticky; top: 76px; align-self: start; height: calc(100vh - 100px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 6px; }
.tabs button { border: 0; background: none; padding: 12px 10px; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .count { font-size: 11px; color: var(--faint); }
.rail-close { margin-left: auto; display: none; }
.tab { padding: 16px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.tab[hidden] { display: none; }
#tab-ask { padding: 0; }

.primary { border: 1px solid var(--accent); background: var(--accent); color: var(--bg); border-radius: 9px; padding: 9px 14px; font-weight: 600; font-size: 14px; }
.primary:disabled { opacity: .5; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.callout { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.45; }
.callout a { color: var(--accent); font-weight: 600; }
.error { color: #b42318; font-size: 14px; }
.typing { color: var(--muted); font-style: italic; }

.ai-text { font-size: 15px; line-height: 1.55; }
.ai-text p { margin: 0 0 10px; }
.ai-text ul { margin: 0 0 10px; padding-left: 18px; }
.ai-text li { margin-bottom: 6px; }
a.pref { color: var(--accent); font-size: 12px; font-weight: 600; text-decoration: none; background: var(--accent-soft);
  padding: 0 5px; border-radius: 5px; white-space: nowrap; }

.chat { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat .chips { justify-content: flex-start; }
.msg { font-size: 15px; line-height: 1.5; max-width: 92%; }
.msg p { margin: 0 0 8px; } .msg p:last-child { margin: 0; }
.msg ul { margin: 0 0 8px; padding-left: 18px; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--bg); padding: 8px 12px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); padding: 10px 12px; border-radius: 14px 14px 14px 4px; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; resize: none; font: inherit; font-size: 14px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--bg); color: var(--text); outline: none; }
.chat-form textarea:focus { border-color: var(--accent); }

.hl-list { display: flex; flex-direction: column; gap: 12px; }
.hl-item { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.hl-quote { display: block; font-family: var(--serif); font-size: 15px; line-height: 1.5; color: var(--text); text-decoration: none;
  border-left: 4px solid var(--hl-yellow); padding-left: 10px; }
.hl-quote.green { border-color: var(--hl-green); } .hl-quote.blue { border-color: var(--hl-blue); } .hl-quote.pink { border-color: var(--hl-pink); }
.hl-note { margin: 6px 0 0 14px; font-size: 14px; color: var(--muted); white-space: pre-wrap; }
.hl-actions { display: flex; gap: 12px; margin: 6px 0 0 14px; font-size: 12px; color: var(--faint); }
.hl-actions button { border: 0; background: none; padding: 0; color: var(--muted); font-size: 12px; }
.hl-actions button:hover { color: var(--accent); }

/* floating selection toolbar */
.selbar { position: absolute; z-index: 40; display: flex; gap: 4px; align-items: center; padding: 6px; background: var(--text);
  border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.selbar button { border: 0; background: none; color: var(--bg); font-size: 13px; padding: 6px 8px; border-radius: 6px; }
.selbar button:hover { background: color-mix(in srgb, var(--bg) 15%, transparent); }
.selbar .sw { width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 2px solid var(--bg); }
.sw.yellow { background: #f5d76e; } .sw.green { background: #8fd18b; } .sw.blue { background: #8cbcec; } .sw.pink { background: #ef9fbf; }

.note-dialog { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.35); display: grid; place-items: center; padding: 16px; }
.note-box { width: min(480px, 100%); background: var(--surface); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.note-quote { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 15px; line-height: 1.5; max-height: 140px; overflow: auto; }
.note-box textarea { font: inherit; font-size: 15px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--text); resize: vertical; }
.note-actions { display: flex; justify-content: flex-end; gap: 8px; }
.note-actions button:first-child { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 9px 14px; }

.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 8px 14px; border-radius: 999px; font-size: 14px; z-index: 60; }
.skeleton.tall { height: 60vh; }

.mobile-bar { display: none; }

@media (max-width: 1099px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 24px 16px 120px; }
  .pnum { display: none; }
  .rail { position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: min(78vh, 640px); border-radius: 16px 16px 0 0; z-index: 35;
    transform: translateY(105%); transition: transform .25s ease; }
  body.rail-open .rail { transform: none; }
  .rail-close { display: block; }
  .mobile-bar { display: flex; position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 34; background: var(--surface);
    border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); padding: 4px; gap: 2px; }
  .mobile-bar button { white-space: nowrap; border: 0; background: none; padding: 9px 14px; border-radius: 999px; font-size: 14px; color: var(--text); }
  .mobile-bar button:hover { background: var(--accent-soft); }
  body.rail-open .mobile-bar { display: none; }
  .back { display: none; }
}
@media (max-width: 640px) {
  .sermon-page .top .seg { display: none; }
}

/* ---- Listen */
.listen-btn { border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--surface); color: var(--accent);
  font-weight: 600; font-size: 13.5px; border-radius: 999px; padding: 6px 12px; }
.listen-btn:hover { background: var(--accent-soft); }
.para.speaking { background: var(--hit); box-shadow: 0 0 0 8px var(--hit); border-radius: 4px; }
.player { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 45; display: flex; align-items: center; gap: 6px;
  background: var(--text); color: var(--bg); padding: 8px 10px; border-radius: 999px; box-shadow: 0 8px 30px rgba(0,0,0,.25); max-width: calc(100vw - 24px); }
.player button { border: 0; background: none; color: var(--bg); font-size: 16px; width: 34px; height: 34px; border-radius: 50%; }
.player button:hover { background: color-mix(in srgb, var(--bg) 15%, transparent); }
.player .pp { background: var(--accent); }
.player .pinfo { font-size: 12.5px; opacity: .8; padding: 0 4px; }
.player select { font: inherit; font-size: 12.5px; background: transparent; color: var(--bg); border: 1px solid color-mix(in srgb, var(--bg) 30%, transparent);
  border-radius: 8px; padding: 3px 4px; max-width: 120px; }
.player select option { color: #000; }
body.listening .mobile-bar { display: none; }
@media (max-width: 640px) { .player .pvoice { display: none; } .listen-btn { padding: 5px 10px; } }
