/* Sermon Notes — "Stage" look: dark, calm, big type, one amber accent.
   Colors live here as variables; don't hard-code them elsewhere. */
:root {
  --bg: #111214;
  --panel: #1C1E22;
  --panel-2: #23262B;
  --line: #2A2C31;
  --text: #E9E5DC;
  --text-strong: #FFFFFF;
  --muted: #9C978C;
  --past: #6E6A62;
  --gold: #F2B544;
  --gold-soft: #2A2418;
  --gold-ink: #111214;
  --hl-bg: rgba(242, 181, 68, 0.22);
  --danger: #FF8A7A;

  --lib-bg: #F6F4EF;
  --lib-card: #FFFFFF;
  --lib-line: #DAD6CC;
  --lib-text: #1B1C1F;
  --lib-muted: #555A63;
  --lib-accent: #9A6A0E;
  --lib-accent-soft: #FBEFD5;

  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  --size: 25px;
  --lh: 1.6;
  --col: min(760px, calc(100vw - 400px));
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- Library ---------- */
#library {
  min-height: 100%;
  background: var(--lib-bg);
  color: var(--lib-text);
  padding: max(40px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 40px max(24px, env(safe-area-inset-left));
}
.lib-wrap { max-width: 1100px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 40px; }
.lib-main { flex: 999 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.lib-side { flex: 1 1 320px; display: flex; flex-direction: column; gap: 12px; }
#library h1 { margin: 0; font-family: var(--serif); font-size: 40px; font-weight: 600; line-height: 1.15; }
.lede { margin: 0; font-size: 17px; line-height: 1.5; color: var(--lib-muted); }
.import-list { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.import-btn {
  text-align: left; width: 100%; padding: 22px 24px; border-radius: 16px;
  border: 1px solid var(--lib-line); background: var(--lib-card); color: var(--lib-text);
  display: flex; gap: 18px; align-items: center; min-height: 96px;
}
.import-btn.primary { border: 2px solid var(--lib-text); }
.import-btn:active { transform: scale(0.99); }
.import-icon { width: 52px; height: 52px; border-radius: 12px; background: #EEEBE4; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.import-btn.primary .import-icon { background: var(--lib-text); color: #fff; }
.import-text { display: flex; flex-direction: column; gap: 4px; flex-grow: 1; }
.import-title { font-size: 19px; font-weight: 600; }
.import-sub { font-size: 15px; color: var(--lib-muted); }
.tag { font-size: 13px; font-weight: 600; color: var(--lib-accent); background: var(--lib-accent-soft); padding: 6px 10px; border-radius: 8px; }
.lib-error { margin: 0; padding: 14px 16px; border-radius: 12px; background: #FDE8E4; color: #8A2414; font-size: 16px; }
.eyebrow { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--lib-muted); }
.sermon-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.sermon-item { display: flex; align-items: stretch; border-radius: 14px; background: var(--lib-card); border: 1px solid var(--lib-line); overflow: hidden; }
.sermon-open { flex-grow: 1; min-width: 0; text-align: left; border: 0; background: transparent; padding: 16px 18px; display: flex; flex-direction: column; gap: 5px; color: var(--lib-text); }
.sermon-name { font-family: var(--serif); font-size: 20px; font-weight: 600; overflow-wrap: anywhere; }
.sermon-meta { font-size: 14px; color: var(--lib-muted); }
.sermon-resume { font-size: 14px; font-weight: 600; color: var(--lib-accent); }
.sermon-del { width: 56px; border: 0; border-left: 1px solid var(--lib-line); background: transparent; color: var(--lib-muted); display: flex; align-items: center; justify-content: center; }
.empty { margin: 0; font-size: 15px; color: var(--lib-muted); line-height: 1.5; }
.tip { margin: 8px 0 0; padding: 16px 18px; border-radius: 14px; background: #ECE8DE; font-size: 14px; line-height: 1.5; color: #3B3F46; }

/* ---------- Sheets (paste, review, settings) ---------- */
.sheet-backdrop, .drawer-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 10, 12, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.sheet {
  width: min(620px, 100%); max-height: calc(100% - 24px); overflow: auto;
  background: var(--lib-card); color: var(--lib-text);
  border-radius: 20px; padding: 28px; display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.sheet h2 { margin: 0; font-family: var(--serif); font-size: 28px; font-weight: 600; }
.sheet-sub { margin: 0; font-size: 16px; color: var(--lib-muted); line-height: 1.5; }
.paste-box {
  min-height: 180px; border-radius: 14px; border: 2px dashed var(--lib-line); padding: 18px;
  font-size: 17px; color: var(--lib-muted); outline: none; -webkit-user-select: text; user-select: text;
}
.paste-box:focus { border-color: var(--lib-accent); }
.paste-box:empty::before { content: "Tap here, then tap Paste"; color: #8B8F98; }
.sheet-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }
.btn { min-height: 48px; padding: 0 22px; border-radius: 12px; border: 0; font-size: 16px; font-weight: 600; }
.btn.ghost { background: transparent; border: 1px solid var(--lib-line); color: var(--lib-text); }
.btn.gold { background: var(--gold); color: var(--gold-ink); }
.field { display: flex; flex-direction: column; gap: 8px; font-size: 15px; font-weight: 600; color: var(--lib-muted); }
.field input[type=text], .field input[type=number] {
  font: inherit; font-size: 18px; font-weight: 400; color: var(--lib-text);
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--lib-line); background: #fff;
}
.field input[type=range] { width: 100%; accent-color: var(--gold); height: 32px; }
.field output { font-weight: 400; margin-left: 6px; }
.review-outline { margin: 0; padding: 0 0 0 22px; max-height: 280px; overflow: auto; font-size: 16px; line-height: 1.6; color: var(--lib-text); }
.review-outline li.sub { margin-left: 18px; color: var(--lib-muted); }
.sheet.dark { background: var(--panel); color: var(--text); }
.sheet.dark .field { color: var(--muted); }
.sheet.dark .field input[type=number] { background: var(--bg); color: var(--text); border-color: var(--line); }
.sheet.dark .btn.ghost { color: var(--text); border-color: var(--line); }

/* ---------- Preach ---------- */
#preach { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.bar {
  flex-shrink: 0; display: flex; align-items: center; gap: 12px;
  height: calc(64px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
}
.icon-btn { width: 44px; height: 44px; border-radius: 10px; border: 0; background: var(--panel); color: #C9C4B8; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-btn.aa { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.bar-title { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.p-title { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-section { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { display: flex; align-items: center; gap: 8px; padding: 0 14px; height: 44px; border-radius: 10px; border: 0; background: var(--panel); flex-shrink: 0; }
.timer-dot { width: 8px; height: 8px; border-radius: 4px; background: var(--muted); }
.timer.running .timer-dot { background: var(--gold); }
.timer-text { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.timer.running .timer-text { color: var(--gold); }
.timer.over .timer-text { color: var(--danger); }
.timer-goal { font-size: 13px; color: var(--muted); }
.clock { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.lock-btn { height: 44px; padding: 0 14px; border-radius: 10px; border: 0; background: var(--panel); color: #C9C4B8; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; flex-shrink: 0; }
.lock-btn svg { width: 18px; height: 18px; }
.lock-btn[aria-pressed="true"] { background: var(--gold-soft); color: var(--gold); }
.locked .bar .icon-btn { opacity: 0.45; }
.icon-btn[hidden] { display: none; }

.strip { display: none; }
.stage { position: relative; flex-grow: 1; min-height: 0; }
.scroller {
  position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.sermon {
  width: var(--col); margin: 0 auto; padding: 36px 0 55vh;
  font-family: var(--serif); font-size: var(--size); line-height: var(--lh);
  -webkit-user-select: none; user-select: none;
}
.blk { position: relative; margin: 0 0 calc(var(--size) * 1.05); color: var(--text); white-space: pre-line; overflow-wrap: break-word; transition: color 0.25s ease; }
.blk.past { color: var(--past); }
.blk.here { color: var(--text-strong); }
.blk.h { font-family: var(--sans); font-weight: 600; color: var(--gold); letter-spacing: 0.01em; line-height: 1.3; margin-top: calc(var(--size) * 1.6); }
.blk.h1 { font-family: var(--serif); font-size: 1.45em; color: var(--text-strong); }
.blk.h2 { font-size: 0.72em; letter-spacing: 0.12em; text-transform: uppercase; }
.blk.h3 { font-size: 0.86em; }
.blk.h.past { color: #8A7243; }
.blk.h1.past { color: var(--past); }
.blk:first-child { margin-top: 0; }
.blk.quote { padding: 18px 24px; border-radius: 14px; background: #1A1C20; font-style: italic; }
.blk.li { padding-left: 1.4em; }
.blk.li.l2 { margin-left: 1.2em; }
.blk.li.l3 { margin-left: 2.4em; }
.blk.li.l4 { margin-left: 3.6em; }
.blk.li + .blk.li { margin-top: calc(var(--size) * -0.6); }
.bullet { position: absolute; left: 0; top: 0; color: var(--gold); font-family: var(--sans); font-weight: 600; font-size: 0.8em; line-height: calc(var(--lh) / 0.8); }
.blk.hr { height: 1px; background: var(--line); margin: calc(var(--size) * 1.4) 0; }
.blk strong { font-weight: 700; color: var(--gold); }
.blk.past strong { color: inherit; }
.blk.past .tc { opacity: 0.55; }
.blk.h strong { color: inherit; }
.blk em { font-style: italic; }
.blk u { text-decoration-thickness: 2px; text-underline-offset: 0.18em; }
.blk mark { background: var(--hl-bg); color: inherit; border-radius: 4px; padding: 0 0.12em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }

.pin {
  position: absolute; left: -64px; top: calc((var(--size) * var(--lh) - 28px) / 2);
  display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none;
  font-family: var(--sans); font-style: normal; text-transform: none; letter-spacing: 0;
}
.pin-dot { width: 28px; height: 28px; border-radius: 14px; background: var(--gold); color: var(--gold-ink); display: flex; align-items: center; justify-content: center; }
.pin-dot svg { width: 16px; height: 16px; stroke-width: 2.5; }
.pin-label { font-size: 11px; font-weight: 700; color: var(--gold); }
.blk.li .pin { left: calc(-64px - 1.4em); }
.blk.quote .pin { left: -64px; }

.fade { position: absolute; left: 0; right: 0; bottom: 0; height: 110px; pointer-events: none; background: linear-gradient(to bottom, rgba(17, 18, 20, 0), rgba(17, 18, 20, 0.55) 45%, rgba(17, 18, 20, 0.92) 80%, #111214); }

.rail {
  position: absolute; right: max(20px, env(safe-area-inset-right)); top: 24px; bottom: 24px; width: 180px;
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end;
}
.rail::before { content: ""; position: absolute; right: 7px; top: 12px; bottom: 12px; width: 2px; background: var(--line); }
.rail-item {
  position: relative; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  min-height: 36px; max-width: 100%; border: 0; background: transparent; padding: 0; text-align: right;
}
.rail-label { font-size: 13px; line-height: 1.3; color: var(--muted); overflow: hidden; max-width: 150px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rail-dot { width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rail-dot::after { content: ""; width: 10px; height: 10px; border-radius: 5px; box-sizing: border-box; border: 2px solid #4A463E; background: var(--bg); }
.rail-item.done .rail-label { color: var(--past); }
.rail-item.done .rail-dot::after { background: #4A463E; }
.rail-item.now .rail-label { color: var(--gold); font-weight: 600; font-size: 14px; }
.rail-item.now .rail-dot::after { width: 16px; height: 16px; border-radius: 8px; border: 0; background: var(--gold); }

.back-pill {
  position: absolute; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  height: 52px; padding: 0 22px; border-radius: 26px; border: 0; background: var(--gold); color: var(--gold-ink);
  font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); z-index: 5;
}
.back-pill svg { width: 18px; height: 18px; stroke-width: 2.5; }
.toast {
  position: absolute; left: 50%; top: 20px; transform: translateX(-50%); z-index: 6;
  padding: 12px 18px; border-radius: 12px; background: var(--panel-2); color: var(--text); font-size: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* Outline drawer */
.drawer-backdrop { justify-content: flex-start; align-items: stretch; padding: 0; }
.drawer {
  width: min(380px, 85vw); background: var(--panel); color: var(--text); overflow: auto;
  padding: calc(24px + env(safe-area-inset-top)) 16px 24px max(16px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 10px;
}
.drawer .eyebrow { color: var(--muted); padding: 0 12px; }
.drawer .empty { color: var(--muted); padding: 0 12px; }
.outline-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.outline-list button { width: 100%; text-align: left; border: 0; background: transparent; padding: 12px; min-height: 48px; border-radius: 10px; font-size: 17px; color: var(--text); }
.outline-list li.sub button { padding-left: 30px; font-size: 15px; color: var(--muted); }
.outline-list li.done button { color: var(--past); }
.outline-list li.now button { background: var(--gold-soft); color: var(--gold); font-weight: 600; }

/* ---------- Upright (portrait) iPad ---------- */
@media (orientation: portrait) {
  :root { --col: calc(100vw - 150px); }
  .rail { display: none; }
  .strip {
    display: flex; gap: 4px; flex-shrink: 0;
    padding: 10px max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
    border-bottom: 1px solid var(--line);
  }
  .strip-seg { flex: 1 1 0; height: 5px; border-radius: 3px; background: #2F3237; }
  .strip-seg.done { background: #6B5A33; }
  .strip-seg.now { background: var(--gold); }
  .sermon { padding-top: 32px; }
  .clock { display: none; }
  .timer-goal { display: none; }
  .back-pill { bottom: calc(36px + env(safe-area-inset-bottom)); }
}
@media (orientation: portrait) and (min-width: 900px) {
  .clock { display: inline; }
  .timer-goal { display: inline; }
}
@media (orientation: landscape) and (max-width: 1060px) {
  :root { --col: min(720px, calc(100vw - 300px)); }
  .rail { width: 120px; }
  .rail-label { max-width: 90px; }
}
@media (max-width: 700px) {
  :root { --col: calc(100vw - 104px); --size: 21px; }
  .rail { display: none; }
  .pin { left: -46px; }
  .bar { gap: 8px; }
  .lock-btn span { display: none; }
  #library h1 { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* Lots of sections: only the current one keeps its label. */
.rail.dense .rail-item:not(.now) .rail-label { display: none; }
