/* Redemption Church — reader styles.
 * Palette taken from redemptionchurchpdx.org: gold #d9c187, warm black #2b2923,
 * warm off-white #f1eceb, cool slate #252e32. Display face is DM Serif Text,
 * the site's own heading font, self-hosted so the app still looks right offline.
 * Scripture body uses the platform reading serif rather than a second download.
 */

@font-face {
  font-family: 'DM Serif Text';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/dm-serif-text-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'DM Serif Text';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/dm-serif-text-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --gold: #d9c187;
  --gold-deep: #a8894a;

  --display: 'DM Serif Text', ui-serif, Georgia, serif;
  --body: ui-serif, 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;

  /* Reader knobs, driven from Settings. */
  --reader-size: 19px;
  --reader-leading: 1.75;
  --reader-measure: 34rem;

  /* Light (default) */
  --bg: #f1eceb;
  --bg-raised: #ffffff;
  --bg-sunken: #e7e0de;
  --ink: #2b2923;
  --ink-soft: #6b6459;
  --ink-faint: #97907f;
  --rule: #ded5d1;
  --accent: var(--gold-deep);
  --accent-soft: #f0e4c6;
  --shadow: 0 1px 2px rgba(43, 41, 35, .06), 0 8px 24px rgba(43, 41, 35, .08);
  --sheet-scrim: rgba(43, 41, 35, .42);
  color-scheme: light;
}

:root[data-theme='sepia'] {
  --bg: #f4ecd8;
  --bg-raised: #fbf6e9;
  --bg-sunken: #eadfc4;
  --ink: #3b3222;
  --ink-soft: #6f6144;
  --ink-faint: #9a8a68;
  --rule: #e0d3b4;
  --accent: #8a6d34;
  --accent-soft: #efe1bd;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #191813;
  --bg-raised: #23221c;
  --bg-sunken: #12110d;
  --ink: #ece7dc;
  --ink-soft: #a9a292;
  --ink-faint: #7b7466;
  --rule: #34322a;
  --accent: var(--gold);
  --accent-soft: #3a3220;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 12px 32px rgba(0, 0, 0, .45);
  --sheet-scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #191813;
    --bg-raised: #23221c;
    --bg-sunken: #12110d;
    --ink: #ece7dc;
    --ink-soft: #a9a292;
    --ink-faint: #7b7466;
    --rule: #34322a;
    --accent: var(--gold);
    --accent-soft: #3a3220;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 12px 32px rgba(0, 0, 0, .45);
    --sheet-scrim: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* Author `display` rules beat the UA stylesheet's [hidden] { display: none },
 * so every element toggled via .hidden in JS — the sheets, the back button, the
 * book list, the chapter grid — needs this or it stays visible and focusable. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* ---------------------------------------------------------------- app frame */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: max(env(safe-area-inset-top), 8px) 10px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--rule);
}

/* The reference button is the primary nav affordance, so it gets the room. */
.ref-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  font-family: var(--display);
  font-size: 1.2rem;
  line-height: 1.15;
  text-align: left;
}
.ref-btn:active { background: var(--bg-sunken); }
.ref-btn .chev { color: var(--accent); flex: none; }
.ref-btn .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-btn .abbr {
  flex: none;
  font-family: var(--ui);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 5px;
  padding: 2px 5px;
}

.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-soft);
}
.icon-btn:active { background: var(--bg-sunken); color: var(--ink); }
.icon-btn svg { width: 21px; height: 21px; }

/* The one labelled control in the top bar, and deliberately larger than its
 * neighbours: it opens the church half of the app — bulletin, sermons,
 * directory, calendar — and a bare hamburger among three other glyphs did not
 * say so. The label is stacked under the icon rather than beside it, so the cost
 * is a few pixels of bar height instead of width: the reference button next to
 * it is already ellipsising long book names at phone width. */
.menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 46px;
  height: auto;
  padding: 4px 0 3px;
}
.menu-btn svg { width: 26px; height: 26px; }
.menu-btn span {
  font-family: var(--ui);
  font-size: .55rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  line-height: 1;
}

/* ------------------------------------------------------------------- reader */

.reader {
  flex: 1;
  width: 100%;
  max-width: var(--reader-measure);
  margin: 0 auto;
  padding: 18px 20px calc(96px + env(safe-area-inset-bottom));
}

.chapter-head {
  margin: 6px 0 22px;
  text-align: center;
}
.chapter-head h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.65rem, 7vw, 2.2rem);
  font-weight: 400;
  letter-spacing: -.01em;
}
.chapter-head .rule {
  width: 46px;
  height: 2px;
  margin: 13px auto 0;
  background: var(--accent);
  opacity: .55;
  border-radius: 2px;
}

.verses {
  font-family: var(--body);
  font-size: var(--reader-size);
  line-height: var(--reader-leading);
  color: var(--ink);
  /* No hyphenation: at this measure it split "beginning" across lines, which
   * reads as a rendering fault on a phone even though print Bibles do it. */
  hyphens: none;
}

/* Paragraph mode: verses flow together, the way a printed Bible reads. */
.verses.flow { text-align: left; }
.verses.flow .v { display: inline; }
.verses.flow .v + .v::before { content: ' '; }

/* Line mode: one verse per line, easier to follow along out loud.
 * Hanging indent — the number sits in a gutter and wrapped lines align under
 * the first word instead of running back out to the margin. The 2.25em matches
 * .num's min-width (1.7em) plus its right margin (.55em). */
.verses.lines .v {
  display: block;
  padding: 3px 0 3px 2.25em;
  text-indent: -2.25em;
}

.v {
  border-radius: 4px;
  transition: background-color .12s ease;
}
.v .num {
  font-family: var(--ui);
  font-size: .62em;
  font-weight: 700;
  color: var(--accent);
  vertical-align: .42em;
  margin-right: .28em;
  user-select: none;
}
.verses.lines .v .num {
  display: inline-block;
  min-width: 1.7em;
  vertical-align: baseline;
  font-size: .68em;
  text-align: right;
  margin-right: .55em;
}

.v.sel { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.v.hl-gold   { background: color-mix(in srgb, #e8c766 42%, transparent); }
.v.hl-rose   { background: color-mix(in srgb, #e59a9a 40%, transparent); }
.v.hl-sage   { background: color-mix(in srgb, #a3c49b 40%, transparent); }
.v.hl-sky    { background: color-mix(in srgb, #97bcd8 40%, transparent); }
.v.has-note .num::after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 2px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: .3em;
}

.chapter-nav {
  display: flex;
  gap: 10px;
  margin: 38px 0 0;
}
.chapter-nav button {
  flex: 1;
  padding: 13px 10px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--bg-raised);
  color: var(--ink-soft);
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chapter-nav button:disabled { opacity: .35; cursor: default; }
.chapter-nav button:not(:disabled):active { background: var(--bg-sunken); }

.credit {
  margin: 30px 0 0;
  font-size: .68rem;
  line-height: 1.5;
  color: var(--ink-faint);
  text-align: center;
}

.loading, .error {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-soft);
  font-size: .9rem;
}
.error { color: #b4553f; }

/* --------------------------------------------------------------- sermon links */

/* A quiet card under the chapter heading naming any sermon preached on this
 * chapter. The same row is reused in the chooser sheet when one verse has more
 * than one sermon. */
.sermon-strip {
  margin: 0 0 22px;
  padding: 9px 11px 11px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--bg-raised);
}
.sermon-strip-label {
  display: block;
  margin: 2px 2px 5px;
  font-family: var(--ui);
  font-size: .63rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.sermon-link {
  display: flex;
  align-items: center;
  width: 100%;
  border-radius: 10px;
}
.sermon-link.playing { background: color-mix(in srgb, var(--accent) 13%, transparent); }

/* The body of the row plays; the small trailing button opens the church page. */
.s-play {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 4px 9px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}
.s-play:active { background: var(--bg-sunken); }
/* Reader strip cue row: same layout as .s-play but no play/pause icon. */
.s-cue {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 4px 9px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}
.s-cue:active { background: var(--bg-sunken); }
.sermon-list .s-cue { padding: 13px 4px 13px 6px; }
.s-open {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
}
.s-open:active { background: var(--bg-sunken); }

.sermon-link .ic { width: 21px; height: 21px; flex: none; color: var(--accent); }
.sermon-link .meta { flex: 1; min-width: 0; }
.sermon-link .t {
  display: block;
  font-family: var(--display);
  font-size: 1.02rem;
  line-height: 1.25;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sermon-link .p {
  display: block;
  margin-top: 1px;
  font-family: var(--ui);
  font-size: .72rem;
  color: var(--ink-faint);
}
.sermon-link .go { width: 16px; height: 16px; flex: none; color: var(--ink-faint); }

/* How far into a part-listened sermon you are. Drawn only when a duration is
 * known, so a row never shows a bar pinned at zero. */
.s-prog {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.s-track {
  flex: none;
  width: 92px;
  height: 3px;
  border-radius: 2px;
  background: var(--rule);
  overflow: hidden;
}
.s-track i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
}
.s-prog b {
  font-family: var(--ui);
  font-size: .62rem;
  font-weight: 600;
  color: var(--ink-faint);
}

/* Chooser sheet: rows become a divided list rather than a rounded card. */
.sermon-list .sermon-link {
  border-radius: 0;
  border-bottom: 1px solid var(--rule);
}
.sermon-list .sermon-link:last-child { border-bottom: 0; }
.sermon-list .s-play { padding: 13px 4px 13px 6px; }

/* ---------------------------------------------------------- sermon audio feed */

/* The archive as a browsable list, grouped by year. Rows are the same
 * .sermon-link used on a chapter and in the chooser, so tapping one behaves
 * identically wherever it is; only the grouping and the sub-line differ. */
.sf-year {
  padding: 18px 4px 6px;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}
.sf-year:first-child { padding-top: 4px; }

/* One line, always: the sub-line carries date, speaker and passage, which wraps
 * to two lines on a narrow phone and makes the list ragged. */
#sermonFeedList .sermon-link .p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Back to Now Playing from inside the sheet, which covers the mini bar. */
.np-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  font-family: var(--ui);
  font-size: .7rem;
  font-weight: 600;
  color: var(--accent);
}
.np-chip svg { width: 12px; height: 12px; }
.np-chip:active { background: var(--bg-sunken); }

/* ------------------------------------------------------------ sermon player */

.player {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 55;                     /* under the sheets, over the reader */
  display: flex;
  align-items: center;
  gap: 6px;
  width: calc(100% - 28px);
  max-width: 30rem;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 15px;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}

.p-toggle {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg-raised);
}
/* Same contrast rule as .btn.primary: the accent is a deep gold on light themes
 * (so a pale glyph reads) and a pale gold on dark (so it needs a dark one). */
:root[data-theme='dark'] .p-toggle { color: #191813; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .p-toggle { color: #191813; }
}
.p-toggle svg { width: 20px; height: 20px; }

/* The tappable middle of the bar: title, byline, and a read-only progress line.
 * A real slider cannot go here — this is a button, and controls do not nest. */
.p-body {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 2px 4px;
  text-align: left;
  border-radius: 10px;
}
.p-body:active { background: var(--bg-sunken); }
.p-title {
  display: block;
  font-family: var(--display);
  font-size: .95rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p-sub {
  display: block;
  margin-top: 1px;
  font-size: .66rem;
  color: var(--ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p-bar {
  display: block;
  height: 3px;
  margin-top: 6px;
  border-radius: 2px;
  background: var(--bg-sunken);
  overflow: hidden;
}
.p-bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}

.p-close {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-faint);
}
.p-close svg { width: 17px; height: 17px; }

/* With the player up, everything that also sits at the bottom moves above it:
 * the verse toolbar, the toast, and the reader's own tail padding. */
body.has-player .actionbar { --ab-bottom: calc(78px + env(safe-area-inset-bottom)); }
body.has-player .toast { bottom: calc(148px + env(safe-area-inset-bottom)); }
body.has-player .reader { padding-bottom: calc(160px + env(safe-area-inset-bottom)); }

/* ------------------------------------------------------ now playing, full screen */

.nowplaying {
  position: fixed;
  inset: 0;
  z-index: 70;                    /* above the sheets: it is a whole screen */
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32, .72, 0, 1);
  padding: max(env(safe-area-inset-top), 10px) 0 calc(18px + env(safe-area-inset-bottom));
}
.nowplaying.open { transform: none; }

.np-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 10px 6px;
}
.np-head .icon-btn svg { width: 24px; height: 24px; }
.np-eyebrow {
  flex: 1;
  text-align: center;
  margin-right: 40px;             /* balance the close button so this reads centred */
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.np-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  width: 100%;
  max-width: 26rem;
  margin: 0 auto;
  padding: 0 26px;
  text-align: center;
  overflow-y: auto;
}

/* The church wordmark stands in for artwork — the sermons have no per-episode
 * image, and the Spotify cover has "Sermons" baked into it. */
.np-art {
  width: 62%;
  max-width: 230px;
  height: auto;
  margin: 0 auto 30px;
  opacity: .92;
}

.np-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.35rem, 6.6vw, 1.8rem);
  font-weight: 400;
  line-height: 1.22;
}
.np-speaker {
  margin: 9px 0 0;
  font-size: .92rem;
  font-weight: 600;
  color: var(--accent);
}
.np-meta {
  margin: 5px 0 0;
  font-size: .78rem;
  color: var(--ink-faint);
}

.np-seek {
  width: 100%;
  margin: 30px 0 0;
  height: 22px;
  accent-color: var(--accent);
}
.np-times {
  display: flex;
  justify-content: space-between;
  margin-top: -2px;
  font-size: .68rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.np-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  margin: 24px 0 4px;
}
.np-skip {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
}
.np-skip:active { background: var(--bg-sunken); }
.np-skip svg { width: 32px; height: 32px; }
/* The number sits inside the circular arrow, whose centre is a little below the
 * icon's own centre because the arrowhead sits above the circle. */
.np-skip span {
  position: absolute;
  top: 57%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.np-play {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg-raised);
  box-shadow: var(--shadow);
}
.np-play svg { width: 34px; height: 34px; }
:root[data-theme='dark'] .np-play { color: #191813; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .np-play { color: #191813; }
}

.np-extra {
  display: flex;
  gap: 9px;
  margin-top: 26px;
}
.np-extra .btn { font-size: .8rem; padding: 11px 10px; }

/* ---------------------------------------------------- verse action toolbar */

/* Hidden off the bottom until verses are selected.
 *
 * The travel has to be its own height *plus* however far up `bottom` puts it —
 * a bare `translateY(130%)` is a percentage of the element only, so it took no
 * account of the offset and left a sliver on screen wherever `bottom` was
 * larger. On a phone with a home indicator that is 14px + a ~34px safe-area
 * inset, so ~32px of the bar sat visible with nothing selected; with the sermon
 * player up (bottom 78px) almost all of it did. It cleared exactly on a desktop
 * viewport, which is why it hid there and not on an iPhone.
 *
 * --ab-bottom is the single source of that offset, so every rule that lifts the
 * bar changes one value and the hidden position follows automatically. */
.actionbar {
  --ab-bottom: calc(14px + env(safe-area-inset-bottom));
  position: fixed;
  left: 50%;
  bottom: var(--ab-bottom);
  transform: translate(-50%, calc(100% + var(--ab-bottom)));
  /* Belt and braces: a sliver that somehow survives cannot be tapped, and the
     buttons leave the tab order while the bar is away. */
  visibility: hidden;
  pointer-events: none;
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 2px;
  width: calc(100% - 28px);
  max-width: 26rem;
  padding: 7px;
  border: 1px solid var(--rule);
  border-radius: 15px;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
  transition: transform .22s cubic-bezier(.32, .72, 0, 1),
              visibility 0s linear .22s;
}
.actionbar.open {
  transform: translate(-50%, 0);
  visibility: visible;
  pointer-events: auto;
  transition: transform .22s cubic-bezier(.32, .72, 0, 1), visibility 0s;
}
.actionbar .act {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: .62rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.actionbar .act:active { background: var(--bg-sunken); }
.actionbar .act svg { width: 19px; height: 19px; }
.actionbar .swatches { display: flex; gap: 5px; padding: 0 5px; }
.actionbar .sw {
  width: 25px;
  height: 25px;
  border: 1px solid rgba(0, 0, 0, .14);
  border-radius: 50%;
  padding: 0;
}
.sw-gold { background: #e8c766; }
.sw-rose { background: #e59a9a; }
.sw-sage { background: #a3c49b; }
.sw-sky  { background: #97bcd8; }
.sw-none {
  background: transparent;
  color: var(--ink-faint);
  display: grid;
  place-items: center;
  font-size: 15px;
  line-height: 1;
}

/* ------------------------------------------------------------------ sheets */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--sheet-scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  max-height: 88dvh;
  transform: translateY(101%);
  background: var(--bg-raised);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow);
  transition: transform .28s cubic-bezier(.32, .72, 0, 1);
}
.sheet.open { transform: translateY(0); }
@media (min-width: 620px) {
  .sheet {
    left: 50%;
    right: auto;
    bottom: 24px;
    width: 34rem;
    margin-left: -17rem;
    border-radius: 18px;
    max-height: 82dvh;
  }
  .sheet:not(.open) { transform: translateY(calc(100% + 40px)); }
}

.sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--rule);
}
.sheet-head h2 {
  flex: 1;
  margin: 0;
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 400;
}
.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 14px calc(18px + env(safe-area-inset-bottom));
}
.grabber {
  width: 36px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: 3px;
  background: var(--rule);
}

/* ------------------------------------------------------------- left drawer */

/* Reuses the sheet scrim and the showSheet/hideSheet open/close machinery; only
 * the slide direction differs — in from the left rather than up from the bottom. */
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: min(84vw, 20rem);
  padding-top: env(safe-area-inset-top);
  transform: translateX(-101%);
  background: var(--bg-raised);
  box-shadow: var(--shadow);
  transition: transform .28s cubic-bezier(.32, .72, 0, 1);
}
.drawer.open { transform: none; }

/* Close on its own row, wordmark centred beneath it with the drawer's full
 * width. Side by side they competed for a 320px drawer and the logo lost — it
 * was capped at 190px to leave room for a button it did not need to share a
 * line with. */
.drawer-head {
  flex: none;
  display: flex;
  flex-direction: column;
  padding: 8px 10px 20px;
  border-bottom: 1px solid var(--rule);
}
.drawer-head .icon-btn { align-self: flex-end; }

/* The church wordmark is gold on transparent, the same treatment as Settings.
 * Intrinsic 800x214, so width alone sets the height at the right ratio. */
.drawer-logo {
  display: block;
  width: min(100%, 15.5rem);
  height: auto;
  margin: 4px auto 0;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 10px calc(18px + env(safe-area-inset-bottom));
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  font-family: var(--display);
  font-size: 1.14rem;
  color: var(--ink);
}
.drawer-item:active { background: var(--bg-sunken); }
.drawer-item svg { width: 22px; height: 22px; flex: none; color: var(--accent); }
/* Account status, pinned to the bottom of the drawer. `margin-top:auto` in the
 * flex column keeps it there however short the menu is. */
.drawer-foot {
  flex: none;
  margin-top: auto;
  padding: 10px 10px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
}

.acct {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 12px;
}
.acct svg { width: 20px; height: 20px; flex: none; color: var(--accent); }
.acct-meta { flex: 1; min-width: 0; }
.acct-label {
  display: block;
  font-family: var(--ui);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.acct-email {
  display: block;
  font-size: .82rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.acct .link-btn { margin: 0; flex: none; padding: 6px 2px; }

.drawer-item .soon {
  margin-left: auto;
  font-family: var(--ui);
  font-size: .56rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 2px 5px;
}

/* Book / chapter picker */
.seg {
  display: flex;
  gap: 3px;
  margin: 10px 0 4px;
  padding: 3px;
  border-radius: 11px;
  background: var(--bg-sunken);
}
.seg button {
  flex: 1;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.seg button[aria-selected='true'] {
  background: var(--bg-raised);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .1);
}

.book-list { display: flex; flex-direction: column; }
.book-list button {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 6px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  text-align: left;
  font-family: var(--display);
  font-size: 1.02rem;
}
.book-list button:active { background: var(--bg-sunken); }
.book-list button .ch-count {
  margin-left: auto;
  font-family: var(--ui);
  font-size: .68rem;
  color: var(--ink-faint);
}
.book-list button[aria-current='true'] { color: var(--accent); }

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
  gap: 7px;
  padding: 12px 0 4px;
}
.chapter-grid button {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: transparent;
  font-family: var(--display);
  font-size: 1.02rem;
}
.chapter-grid button:active { background: var(--bg-sunken); }
.chapter-grid button[aria-current='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-raised);
}
:root[data-theme='dark'] .chapter-grid button[aria-current='true'] { color: #191813; }

/* Search */
.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 6px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--bg-sunken);
}
.search-field svg { width: 17px; height: 17px; color: var(--ink-faint); flex: none; }
.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  outline: none;
}
.search-hint { padding: 4px 2px 10px; font-size: .72rem; color: var(--ink-faint); }

.hit {
  display: block;
  width: 100%;
  padding: 12px 6px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  text-align: left;
}
.hit:active { background: var(--bg-sunken); }
.hit .ref {
  display: block;
  margin-bottom: 3px;
  font-family: var(--ui);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
}
.hit .txt {
  font-family: var(--body);
  font-size: .92rem;
  line-height: 1.5;
  color: var(--ink);
}
.hit mark {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  color: inherit;
  border-radius: 2px;
}

.progress {
  height: 3px;
  margin: 8px 0;
  border-radius: 3px;
  background: var(--bg-sunken);
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .18s ease;
}

/* Settings */
/* The church's own wordmark, gold on transparent. It sits on the sheet
 * background in every theme; on the light and sepia ones the gold is lower
 * contrast than body text, which is how the church uses it on their own site. */
.wordmark {
  display: block;
  width: 280px;
  max-width: 78%;
  height: auto;
  margin: 2px 0 4px;
}

.field { padding: 15px 2px; border-bottom: 1px solid var(--rule); }
.field:last-of-type { border-bottom: 0; }
.field > label,
.field > .field-label {
  display: block;
  margin-bottom: 10px;
  font-size: .82rem;
  font-weight: 600;
}
.field .sub {
  margin: 7px 0 0;
  font-size: .72rem;
  line-height: 1.5;
  color: var(--ink-faint);
  /* The church details are set as newline-separated lines, not one run-on. */
  white-space: pre-line;
}
.field input[type='range'] { width: 100%; accent-color: var(--accent); }

.row { display: flex; align-items: center; gap: 12px; }
.row .grow { flex: 1; min-width: 0; }

.switch {
  flex: none;
  width: 48px;
  height: 29px;
  padding: 2px;
  border: 0;
  border-radius: 15px;
  background: var(--bg-sunken);
  transition: background-color .18s ease;
}
.switch[aria-checked='true'] { background: var(--accent); }
.switch > i {
  display: block;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .28);
  transition: transform .18s cubic-bezier(.32, .72, 0, 1);
}
.switch[aria-checked='true'] > i { transform: translateX(19px); }

.btn {
  width: 100%;
  padding: 13px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--bg-sunken);
  font-size: .88rem;
  font-weight: 600;
}
.btn:active { opacity: .75; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-raised);
}
:root[data-theme='dark'] .btn.primary { color: #191813; }
.btn:disabled { opacity: .5; cursor: default; }

/* The church's outward links, two up. Rows stretch so a label that wraps to two
 * lines does not leave its neighbour a different height. */
.link-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 12px;
}
.link-grid .btn {
  height: 100%;
  padding: 12px 10px;
  line-height: 1.3;
}

.sample {
  margin: 12px 0 0;
  padding: 14px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--bg-sunken);
  font-family: var(--body);
  font-size: var(--reader-size);
  line-height: var(--reader-leading);
}

.trans-opt {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 13px 6px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  text-align: left;
}
.trans-opt:disabled { opacity: .55; cursor: default; }
/* The last row's rule would sit a few pixels above the enclosing field's rule. */
.trans-opt:last-child { border-bottom: 0; }
.trans-opt .tick { width: 18px; flex: none; color: var(--accent); }
/* Both must be blocks — as inline spans the abbreviation ran into the name. */
.trans-opt .name { display: block; font-family: var(--display); font-size: 1rem; }
.trans-opt .why { display: block; font-size: .7rem; line-height: 1.4; color: var(--ink-faint); margin-top: 3px; }

/* ------------------------------------------------------- church directory */

.dir-login { padding: 14px 2px 6px; }

/* The instruction Drew asked for, set off in the accent so it reads first. */
.dir-note {
  margin: 0 0 14px;
  padding: 13px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: .92rem;
  line-height: 1.5;
}

.dir-input {
  width: 100%;
  margin: 0 0 11px;
  padding: 12px 13px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--bg-sunken);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  outline: none;
}
.dir-input:focus { border-color: var(--accent); }

/* The login code: big, spaced and centred, so it is easy to check against the
 * email at a glance. Tabular figures stop the spacing jittering as it is typed.
 * Sized in vw as well as rem because the code length is a Supabase setting — a
 * longer one has to stay on one line on a narrow phone. */
.dir-code {
  text-align: center;
  font-size: clamp(1.05rem, 5.2vw, 1.5rem);
  font-weight: 700;
  letter-spacing: .28em;
  text-indent: .28em;     /* offset the trailing letter-space so it looks centred */
  font-variant-numeric: tabular-nums;
}
/* The placeholder is words, not digits, so it should not be tracked out. */
.dir-code::placeholder {
  font-size: .95rem;
  font-weight: 400;
  letter-spacing: normal;
}

.dir-sub {
  margin: 10px 0 0;
  font-size: .74rem;
  line-height: 1.5;
  color: var(--ink-faint);
}
.dir-error {
  margin: 12px 0 0;
  font-size: .8rem;
  line-height: 1.5;
  color: #b4553f;
}
.dir-notice {
  margin: 12px 0 0;
  padding: 11px 12px;
  border-radius: 10px;
  background: var(--bg-sunken);
  font-size: .8rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* "Keep me logged in" — a real checkbox, sized for a thumb. */
.dir-check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 13px;
  padding: 2px;
  font-size: .84rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.dir-check input {
  flex: none;
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  margin: 0;
}

.link-btn {
  display: block;
  margin: 14px auto 0;
  border: 0;
  background: transparent;
  padding: 6px 10px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--accent);
}

.dir-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 8px;
}

/* A person is a tappable summary row that opens to show the details, so the list
 * stays scannable at 63 people while every contact detail is one tap away. */
.dir-person { border-bottom: 1px solid var(--rule); }

.dir-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 4px;
  border: 0;
  background: transparent;
  text-align: left;
  border-radius: 10px;
}
.dir-head:active { background: var(--bg-sunken); }

.dir-photo {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 11px;
  object-fit: cover;
  background: var(--bg-sunken);
}
/* Initials stand in when the directory has no photo for someone. */
.dir-initials {
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: .95rem;
  color: var(--ink-faint);
}

.dir-who { flex: 1; min-width: 0; }
.dir-name {
  display: block;
  font-family: var(--display);
  font-size: 1.04rem;
  line-height: 1.25;
}
.dir-where {
  display: block;
  margin-top: 1px;
  font-size: .74rem;
  color: var(--ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dir-chev {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--ink-faint);
  transition: transform .2s ease;
}
.dir-person.open .dir-chev { transform: rotate(180deg); }

/* Collapsed by default. The 0fr → 1fr grid trick animates to the content's own
 * height, which a max-height guess cannot do — but it needs exactly one child,
 * hence the inner wrapper. */
.dir-detail {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .24s ease;
}
.dir-person.open .dir-detail { grid-template-rows: 1fr; }
.dir-detail-inner { overflow: hidden; }
.dir-person.open .dir-detail-inner { padding-bottom: 8px; }

.dir-row {
  display: flex;
  gap: 10px;
  padding: 8px 6px 8px 58px;      /* line up with the text, past the photo */
  color: inherit;
  text-decoration: none;
  font-size: .82rem;
}
.dir-row:not(.static):active { background: var(--bg-sunken); }
.dir-label {
  flex: none;
  width: 66px;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-top: 2px;
}
.dir-val { flex: 1; min-width: 0; word-break: break-word; }
/* Tappable values read as links; the household list does not. */
.dir-row:not(.static) .dir-val { color: var(--accent); }

.dir-chip {
  display: inline-block;
  margin: 0 5px 5px 0;
  padding: 3px 9px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: .74rem;
  color: var(--ink-soft);
}

.dir-section {
  padding: 20px 4px 6px;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ------------------------------------------- verse notes and highlights, by book */

/* One heading per book that has something in it, canon order. The count is the
 * point of the heading as much as the name: it tells you where the weight is
 * without scrolling. */
/* Collapsed by default, so the sheet opens as a list of books. A native
 * <details> again — no JS to keep in step, and it stays keyboard operable. */
.mk-group { border-bottom: 1px solid var(--rule); }
.mk-book {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 15px 2px;
  cursor: pointer;
  list-style: none;
}
.mk-book::-webkit-details-marker { display: none; }
.mk-book:active { background: var(--bg-sunken); }
.mk-chev {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--accent);
  transition: transform .18s ease;
}
.mk-group[open] > .mk-book .mk-chev { transform: rotate(180deg); }
/* Breathing room between the heading and the marks once it is open. */
.mk-group[open] > .mk-book { padding-bottom: 8px; }
.mk-name {
  flex: 1;
  min-width: 0;
  font-family: var(--display);
  font-size: 1.16rem;
  color: var(--ink);
}
.mk-count {
  flex: none;
  font-family: var(--ui);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--ink-faint);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 2px 8px;
}

/* --------------------------------------------------------------- sermon notes */

/* The list */
.sn-row {
  display: block;
  width: 100%;
  padding: 13px 4px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  text-align: left;
}
.sn-row:active { background: var(--bg-sunken); }
.sn-when {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ui);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}
.sn-when b {
  font-size: .58rem;
  letter-spacing: .06em;
  color: var(--ink-faint);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 1px 6px;
}
.sn-title {
  display: block;
  margin-top: 4px;
  font-family: var(--display);
  font-size: 1.1rem;
  color: var(--ink);
}
.sn-passage, .sn-has-audio {
  display: block;
  font-family: var(--ui);
  font-size: .7rem;
  color: var(--ink-faint);
}
.sn-has-audio { margin-top: 5px; color: var(--accent); }
.sn-preview {
  display: block;
  margin-top: 5px;
  font-size: .86rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------- the composer */

/* Deliberately not a .sheet. A sheet closes; this shrinks to its own bar, so
 * flipping to the chapter and back costs one tap each way and loses neither the
 * reading position nor the cursor. Same z-index band as the mini player, which
 * it sits above when both are up. */
.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 58;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border-top: 1px solid var(--rule);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow);
  padding-bottom: env(safe-area-inset-bottom);
  transition: transform .26s cubic-bezier(.32, .72, 0, 1);
}

.cp-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 8px 12px;
}
.cp-grip {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  border: 0;
  padding: 4px 0;
  background: transparent;
  text-align: left;
}
.cp-grip svg {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--accent);
  transform: rotate(180deg);
  transition: transform .2s ease;
}
.composer.open .cp-grip svg { transform: rotate(0deg); }
.cp-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.cp-sermon {
  font-family: var(--display);
  font-size: 1rem;
  line-height: 1.25;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cp-sub {
  font-family: var(--ui);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* Collapsed, the sermon title steps aside and "Sermon Notes" becomes the banner
 * itself — the pill should say what it is, not what it is about. */
.composer:not(.open) .cp-sermon { display: none; }
.composer:not(.open) .cp-sub {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}
.cp-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-faint);
}
.cp-close svg { width: 18px; height: 18px; }

/* Collapsed, the body is gone entirely rather than merely hidden, so the pill is
 * only as tall as its bar. */
/* Top-edge grabber for continuous resize when expanded. Hidden while collapsed
 * so the pill stays a single bar. */
.cp-resize {
  display: none;
  flex: none;
  align-items: center;
  justify-content: center;
  /* Large touch target — easy to grab on a phone mid-service. */
  min-height: 44px;
  padding: 14px 0 10px;
  margin: 0;
  touch-action: none;
  cursor: ns-resize;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.composer.open .cp-resize { display: flex; }
.cp-resize-bar {
  width: 56px;
  height: 6px;
  border-radius: 4px;
  background: var(--ink-faint);
  opacity: .7;
}
.cp-resize:active .cp-resize-bar,
.cp-resize.dragging .cp-resize-bar {
  background: var(--accent);
  opacity: 1;
}

.cp-body {
  display: none;
  padding: 0 12px 12px;
}
.composer.open .cp-body { display: block; }

.cp-context {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.cp-passage, .cp-stamp {
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 5px 11px;
  background: transparent;
  font-family: var(--ui);
  font-size: .7rem;
  font-weight: 600;
  color: var(--accent);
}
.cp-passage:active, .cp-stamp:active { background: var(--bg-sunken); }

/* Compact formatting toolbar above the contenteditable note. */
.cp-fmt {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.cp-fmt button {
  display: grid;
  place-items: center;
  min-width: 32px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: .78rem;
  font-weight: 700;
  line-height: 1;
}
.cp-fmt button i { font-style: italic; font-weight: 600; }
.cp-fmt button:active { background: var(--bg-sunken); border-color: var(--accent); color: var(--accent); }
.cp-fmt-sep {
  width: 1px;
  height: 18px;
  margin: 0 2px;
  background: var(--rule);
}

.cp-text {
  display: block;
  width: 100%;
  height: var(--cp-editor-h, 34vh);
  min-height: 140px;
  max-height: 85vh;
  padding: 11px 12px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--bg-sunken);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  outline: none;
  /* contenteditable: keep iOS from zooming on focus */
  -webkit-user-select: text;
  user-select: text;
}
.cp-text:focus { border-color: var(--accent); }
.cp-text.is-empty::before {
  content: attr(data-placeholder);
  color: var(--ink-faint);
  pointer-events: none;
}
.cp-text ul, .cp-text ol {
  margin: 0.35em 0 0.35em 1.25em;
  padding: 0;
}
.cp-text li { margin: 0.15em 0; }
.cp-text font[size="2"], .cp-text .cp-size-sm { font-size: 0.85em; }
.cp-text font[size="5"], .cp-text .cp-size-lg { font-size: 1.2em; }
.cp-saved {
  margin: 6px 2px 0;
  height: 1em;
  font-family: var(--ui);
  font-size: .64rem;
  color: var(--ink-faint);
}

/* Keep the reader, the toast and the verse toolbar clear of the composer.
 * --composer-h is set from JS to the composer’s actual offsetHeight so free
 * resize does not cover Bible text. Fallbacks match the old fixed pill. */
body.has-composer .reader {
  padding-bottom: calc(var(--composer-h, 120px) + 8px);
}
/* Clear the notes pill, and the mini player too when both are up. Setting the
   offset rather than the transform matters: the old rule overrode the closed
   transform outright, pinning the bar on screen whenever a note was open. */
body.has-composer .actionbar {
  --ab-bottom: var(--composer-h, calc(74px + env(safe-area-inset-bottom)));
}
body.has-composer.has-player .actionbar {
  --ab-bottom: calc(var(--composer-h, 74px) + 64px);
}
body.has-composer.has-player .player {
  bottom: var(--composer-h, calc(72px + env(safe-area-inset-bottom)));
}

/* ----------------------------------------------- outdoor service, song lyrics */

/* Only appears on the Sundays listed in scripts/outdoor-services.json. */
.bl-outdoor {
  margin: 10px 0 0;
  font-family: var(--ui);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--accent);
}

/* The one entry point into notes during the service. Outlined rather than solid:
 * the bulletin is a printed-programme pastiche and a filled button would shout
 * over it. */
.bl-notes {
  display: inline-block;
  margin: 10px 0 0;
  padding: 7px 15px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  font-family: var(--ui);
  font-size: .72rem;
  font-weight: 600;
  color: var(--accent);
}
.bl-notes:active { background: var(--bg-sunken); }

.bl-lyrics { margin: 6px 0 0; }
.bl-lyrics > summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
  cursor: pointer;
  list-style: none;
  font-family: var(--ui);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}
.bl-lyrics > summary::-webkit-details-marker { display: none; }
.bl-lyrics > summary svg {
  width: 13px;
  height: 13px;
  transition: transform .18s ease;
}
.bl-lyrics[open] > summary svg { transform: rotate(180deg); }

.bl-ly-section { margin: 12px 0 0; }
.bl-ly-type {
  display: block;
  margin-bottom: 3px;
  font-family: var(--ui);
  font-size: .56rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
/* Sung outdoors from a phone held at arm's length, so the words get real size
 * and generous leading rather than bulletin-detail sizing. */
.bl-ly-line {
  display: block;
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--ink);
}

/* ------------------------------------------------------- reading suggestions */

/* One passage, given room. The reference is the thing you came for, so it is
 * the largest element on the sheet and is itself the control. */
.rd { padding: 22px 0 6px; text-align: center; }

.rd-label {
  display: block;
  font-family: var(--ui);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}
.rd-passage {
  margin: 10px 0 0;
  font-family: var(--display);
  font-size: 1.9rem;
  line-height: 1.2;
}
.rd-ref {
  border: 0;
  padding: 0;
  background: transparent;
  font: inherit;
  color: var(--ink);
  border-bottom: 2px solid var(--accent);
}
.rd-ref:active { opacity: .6; }
.rd-title {
  margin: 12px 0 0;
  font-family: var(--display);
  font-size: 1.05rem;
  color: var(--ink-soft);
}
.rd-meta {
  margin: 6px 0 0;
  font-family: var(--ui);
  font-size: .78rem;
  color: var(--ink-faint);
}
.rd-hint {
  margin: 22px 0 0;
  font-family: var(--ui);
  font-size: .72rem;
  color: var(--ink-faint);
}

/* ---------------------------------------------------------------- serving */

/* One block per Sunday this member is on: their own position first and large,
 * the rest of that day's team under it as a quiet list. */
.sv-day {
  padding: 16px 0 18px;
  border-bottom: 1px solid var(--rule);
}
.sv-day:last-of-type { border-bottom: 0; }

.sv-when {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}
.sv-when b {
  font-size: .58rem;
  letter-spacing: .08em;
  color: var(--ink-faint);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 2px 6px;
}

.sv-mine {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin-top: 9px;
}
.sv-pos {
  font-family: var(--display);
  font-size: 1.22rem;
  color: var(--ink);
}
.sv-team {
  width: 100%;
  font-family: var(--ui);
  font-size: .72rem;
  color: var(--ink-faint);
}
.sv-status {
  font-family: var(--ui);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid currentColor;
}
.sv-status.ok   { color: #5d8a5a; }
.sv-status.wait { color: var(--ink-faint); }
.sv-status.no   { color: #b4553f; }

/* Collapsed by default: it is there to glance at, not to fill the screen. A
 * native <details> so it needs no JS and stays keyboard- and screen-reader
 * operable. */
.sv-also { margin: 14px 0 0; }
.sv-also > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 0;
  cursor: pointer;
  list-style: none;                 /* Firefox */
  font-family: var(--ui);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.sv-also > summary::-webkit-details-marker { display: none; }
.sv-also > summary b {
  font-size: .58rem;
  letter-spacing: .04em;
  color: var(--ink-faint);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 1px 7px;
}
.sv-chev {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--accent);
  transition: transform .18s ease;
}
.sv-also[open] > summary .sv-chev { transform: rotate(180deg); }

.sv-others { margin: 2px 0 0; padding: 0; list-style: none; }
.sv-others li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 0;
  font-size: .88rem;
  color: var(--ink-soft);
}
.sv-others li i {
  margin-left: auto;
  font-style: normal;
  font-family: var(--ui);
  font-size: .7rem;
  color: var(--ink-faint);
  text-align: right;
}

/* ------------------------------------------------------------- weekly email */

.we { border-bottom: 1px solid var(--rule); }

.we-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 4px;
  border: 0;
  background: transparent;
  text-align: left;
}
.we-head:active { background: var(--bg-sunken); }
.we-meta { flex: 1; min-width: 0; }
.we-when {
  display: block;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--accent);
}
.we-subject {
  display: block;
  margin-top: 2px;
  font-family: var(--display);
  font-size: 1.04rem;
  line-height: 1.25;
}
.we-chev {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--ink-faint);
  transition: transform .2s ease;
}
.we.open .we-chev { transform: rotate(180deg); }

/* Same 0fr → 1fr collapse as the directory: animates to the content's own
 * height, and needs exactly one child. */
.we-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .26s ease;
}
.we.open .we-body { grid-template-rows: 1fr; }
.we-inner { overflow: hidden; }

/* The email's own text. Set in the reading serif rather than the UI face —
 * it is prose, and it sits next to scripture in this app. */
.we-inner { font-family: var(--body); }
.we-h {
  margin: 20px 0 2px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.12rem;
  color: var(--accent);
}
.we-h:first-child { margin-top: 6px; }
.we-sub {
  margin: 15px 0 3px;
  font-family: var(--ui);
  font-size: .82rem;
  font-weight: 700;
  color: var(--ink);
}
.we-p, .we-li {
  margin: 6px 0;
  font-size: .92rem;
  line-height: 1.6;
  color: var(--ink-soft);
  /* Hannah's paragraphs carry their own line breaks; keep them. */
  white-space: pre-line;
}
.we-li { margin-left: 18px; list-style: disc; }
.we-inner a { color: var(--accent); }

/* Hannah's images. Rounded and full-bleed to the sheet's text column so they
 * sit as part of the page rather than as pasted-in email furniture. */
.we-img {
  display: block;
  width: 100%;
  height: auto;
  margin: 14px 0;
  border-radius: 12px;
  background: var(--bg-sunken);
}

.we-source {
  display: inline-block;
  margin: 18px 0 16px;
  font-family: var(--ui);
  font-size: .74rem;
  font-weight: 600;
  color: var(--ink-faint);
}

/* ---------------------------------------------------------- church calendar */

.ev-month {
  padding: 18px 4px 6px;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}
.ev-month:first-child { padding-top: 10px; }

.ev {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  padding: 11px 4px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  text-align: left;
}
.ev:active { background: var(--bg-sunken); }

/* The date block: weekday over a large day number, like a torn-off calendar. */
.ev-date {
  flex: none;
  width: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 2px;
}
.ev-dow {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.ev-day {
  font-family: var(--display);
  font-size: 1.5rem;
  line-height: 1.05;
  color: var(--accent);
}

.ev-body { flex: 1; min-width: 0; }
.ev-title {
  display: block;
  font-family: var(--display);
  font-size: 1.04rem;
  line-height: 1.25;
}
.ev-meta {
  display: block;
  margin-top: 2px;
  font-size: .75rem;
  color: var(--ink-faint);
}
.ev-meta b { color: var(--accent); font-weight: 700; }
.ev-desc {
  display: block;
  margin-top: 5px;
  font-size: .78rem;
  line-height: 1.5;
  color: var(--ink-soft);
  /* Long blurbs would push the next event off the screen. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ev-go {
  flex: none;
  width: 15px;
  height: 15px;
  margin-top: 4px;
  color: var(--ink-faint);
}

/* ------------------------------------------------------- Sunday bulletin */

/* Deliberately more formal than the rest of the app: centred masthead, ornament
 * rules, small-caps heading, italic song titles. It should read like the printed
 * order of service someone hands you at the door, in the app's own palette. */
.bulletin {
  padding: 6px 4px 10px;
  text-align: center;
}

.bl-logo {
  display: block;
  width: 200px;
  max-width: 62%;
  height: auto;
  margin: 4px auto 16px;
}

.bl-date {
  margin: 0;
  font-family: var(--display);
  font-size: 1.14rem;
  line-height: 1.3;
}
.bl-time {
  margin: 5px 0 0;
  font-size: .76rem;
  letter-spacing: .04em;
  color: var(--ink-soft);
}

/* Rule with a centre ornament — a bulletin convention, and it keeps the
 * masthead visually separate from the order without a heavy border. */
.bl-rule {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px auto;
  max-width: 15rem;
  color: var(--accent);
  font-size: .66rem;
  line-height: 1;
}
.bl-rule > span {
  flex: 1;
  height: 1px;
  background: currentColor;
  opacity: .5;
}

.bl-heading {
  margin: 0 0 14px;
  font-family: var(--ui);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.bl-list {
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: center;
}

.bl-item + .bl-item { margin-top: 13px; }

.bl-title {
  display: block;
  font-family: var(--display);
  font-size: 1.06rem;
  line-height: 1.35;
  color: var(--ink);
}
/* Printed orders of service italicise hymn titles. Doing the same distinguishes
 * the songs without showing keys, which the congregation has no use for. */
.bl-item.song .bl-title { font-style: italic; }

.bl-detail {
  display: block;
  margin-top: 3px;
}
.bl-note {
  display: block;
  font-size: .8rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* A scripture reference found inside a Planning Center description. A button,
 * not an anchor — it drives the in-app reader rather than navigating. */
.bl-ref {
  border: 0;
  padding: 0 1px;
  background: transparent;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.bl-ref:active { opacity: .6; }

.bl-foot {
  margin: 0;
  font-size: .72rem;
  line-height: 1.5;
  color: var(--ink-faint);
}

/* Any day that is not Sunday, plus the not-published-yet and error states. */
.bulletin.away { padding: 18px 10px 34px; }
.bl-away-msg {
  margin: 0;
  font-family: var(--display);
  font-size: 1.28rem;
  line-height: 1.35;
  color: var(--ink);
}
.bl-away-sub {
  margin: 12px 0 0;
  font-size: .82rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

/* Notes list */
.note-item { padding: 13px 4px; border-bottom: 1px solid var(--rule); }
.note-item .ref {
  font-family: var(--ui);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
}
.note-item .body {
  margin: 5px 0 0;
  font-size: .88rem;
  line-height: 1.5;
  white-space: pre-wrap;
}
.note-item .row { margin-top: 9px; }
.note-item .link {
  border: 0;
  background: transparent;
  padding: 5px 0;
  font-size: .74rem;
  font-weight: 600;
  color: var(--accent);
}
.note-item .link.danger { color: #b4553f; }

.note-edit textarea {
  width: 100%;
  min-height: 130px;
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--bg-sunken);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.55;
  resize: vertical;
}
.note-edit blockquote {
  margin: 0 0 12px;
  padding-left: 12px;
  border-left: 2px solid var(--accent);
  font-family: var(--body);
  font-size: .92rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.empty {
  padding: 44px 16px;
  text-align: center;
  color: var(--ink-faint);
  font-size: .86rem;
  line-height: 1.6;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 80;
  transform: translate(-50%, 14px);
  padding: 9px 16px;
  border-radius: 20px;
  background: var(--ink);
  color: var(--bg);
  font-size: .8rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}


/* ------------------------------------------------------ iPhone Duo, open */

/* Only when the inline detector in index.html sets html.duo-open (the Duo's
 * open inner display, ~626x890 either orientation, or ?duo=1). Nothing here
 * applies on any other device. */
html.duo-open .reader {
  max-width: none;
  padding-left: 28px;
  padding-right: 28px;
}

/* Notes split view: reader top-left (document scroll), notes top-right (own
 * scroll), both sized to the visual viewport so the keyboard keeps the bottom. */
html.duo-open body.has-composer:has(.composer.open) .reader {
  padding-right: calc(50% + 16px);
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
html.duo-open .composer.open {
  top: var(--vvtop, 0px);
  bottom: auto;
  left: auto;
  right: 0;
  width: 50%;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  border-top: 0;
  border-left: 1px solid var(--rule);
  border-radius: 0;
  padding-top: env(safe-area-inset-top);
  padding-bottom: 0;
  transition: none;
  z-index: 58;
}
/* Keyboard up: size to the visual viewport so the bottom stays visible. Otherwise
 * top/bottom pin it to the window, which survives fold/unfold. */
html.duo-open.duo-kb .composer.open { bottom: auto; height: var(--vvh, 100dvh); }
html.duo-open .composer.open .cp-resize { display: none !important; }
html.duo-open .composer.open .cp-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
html.duo-open .composer.open .cp-text {
  flex: 1;
  height: auto !important;
  max-height: none;
  min-height: 80px;
}
/* Verse toolbar and mini player stay centred under the reader half, at their
 * normal height (not lifted by the now full-height composer). */
html.duo-open body.has-composer:has(.composer.open) .actionbar {
  left: 25%;
  --ab-bottom: calc(14px + env(safe-area-inset-bottom));
}
html.duo-open body.has-composer.has-player:has(.composer.open) .actionbar {
  --ab-bottom: calc(78px + env(safe-area-inset-bottom));
}
html.duo-open body.has-composer:has(.composer.open) .player {
  left: 25%;
  bottom: calc(14px + env(safe-area-inset-bottom));
}

/* Keep the mini player inside the reader half (its 100%-wide default spilled
 * off the left edge when centred at 25%). */
html.duo-open body.has-composer:has(.composer.open) .player {
  width: calc(50% - 28px);
}

/* iPhone Duo closed cover: keep the top-right header buttons clear of the camera. */
html.duo-cover .topbar { padding-right: 82px; }

/* iPhone Duo open: clear the status (clock/wifi) indicator in the top-right corner. */
html.duo-open .topbar { padding-right: calc(env(safe-area-inset-right) + 96px); }

/* iPhone Duo cover held sideways: clear the camera at top-left. */
html.duo-cover-land .topbar { padding-left: calc(env(safe-area-inset-left) + 60px); }

/* Sermon Card: a continuous centered paper surface, not a feed of rows.
 * Tint existing raised/gold theme tokens; dark/sepia follow the active theme. */
#sermonCardSheet {
  min-height: 0;
  background: var(--bg-raised);
  background: color-mix(in srgb, var(--bg-raised) 88%, var(--gold) 12%);
}
#sermonCardSheet .sheet-head { border-bottom: 0; }
#sermonCardSheet .sheet-head h2 { text-align: center; color: var(--ink-soft); }
#sermonCardBody {
  min-height: 0;
  overflow-x: hidden;
  overflow-wrap: anywhere;
  text-align: center;
  color: var(--ink);
  font-family: var(--body);
  padding-top: 12px;
}
.sermon-card-church,
.sermon-card-list,
.sermon-card-footer {
  box-sizing: border-box;
  width: 100%;
  max-width: 24rem;
  margin-left: auto;
  margin-right: auto;
}
.sermon-card-church {
  margin-top: 8px;
  margin-bottom: 32px;
  font: 400 1.8rem/1.25 var(--display);
  color: var(--ink);
}
.sermon-card-list { list-style: none; margin-top: 0; margin-bottom: 0; padding: 0; }
.sermon-card-entry { padding: 0; border: 0; background: none; }
.sermon-card-entry + .sermon-card-entry { margin-top: 32px; }
.sermon-card-entry p { margin: 0; }
.sermon-card-date { font: 700 1rem/1.5 var(--body); color: var(--ink); }
.sermon-card-passage { font: 400 1rem/1.5 var(--body); }
.sermon-card-entry h3 {
  margin: 2px 0;
  font: italic 400 1.08rem/1.45 var(--body);
  color: var(--ink);
}
.sermon-card-speaker { font: 400 1rem/1.5 var(--body); color: var(--ink-soft); }
.sermon-card-footer { margin-top: 36px; margin-bottom: 12px; font: 400 .92rem/1.6 var(--body); }
.sermon-card-footer a { color: var(--accent); text-underline-offset: 3px; }

/* Native anchors support keyboard activation and reader deep-link fallback. */
.sermon-card-link {
  color: var(--ink);
  text-decoration-line: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
}
.sermon-card-link:hover { color: var(--accent); }
.sermon-card-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}
