:root {
  --bg: #0d0b09;
  --panel: #1a1612;
  --panel-2: #241e18;
  --ink: #f3ead8;
  --ink-soft: #c9bda6;
  --ink-faint: #8a7f6d;
  --gold: #d4b06a;
  --gold-deep: #a8823e;
  --rubric: #d86a55;
  --line: rgba(243, 234, 216, .14);
  --serif: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --caps: "Cinzel", "Trajan Pro", Georgia, serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { font-family: var(--serif); font-size: 18px; line-height: 1.45; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }
small { display: block; font-size: .78em; color: var(--ink-faint); line-height: 1.3; margin-top: 2px; }

.rubric {
  font-family: var(--caps); font-weight: 400; font-size: 12px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--rubric); margin: 0 0 12px;
}

/* ---------- Home ---------- */
#home { min-height: 100%; padding: calc(var(--safe-t) + 28px) 16px calc(var(--safe-b) + 110px); max-width: 640px; margin: 0 auto; position: relative; }
.home-bg { position: fixed; inset: 0; z-index: -1; background-size: cover; background-position: center; opacity: .22; filter: blur(2px) saturate(.9); transform: scale(1.05); transition: background-image .6s; }
.home-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(13,11,9,.55), var(--bg) 70%); }
.home-head { text-align: center; margin: 12px 0 28px; }
.eyebrow { font-family: var(--caps); letter-spacing: .3em; font-size: 11px; color: var(--gold); margin: 0 0 8px; text-transform: uppercase; }
h1 { font-weight: 500; font-size: clamp(34px, 9vw, 48px); line-height: 1.05; margin: 0 0 10px; letter-spacing: .01em; }
.sub { color: var(--ink-soft); font-style: italic; margin: 0; }

.block { margin: 0 0 26px; }
.sets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.set {
  position: relative; aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden; text-align: left;
  background: var(--panel) center / cover no-repeat; border: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: flex-end; padding: 12px;
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.set::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 35%, rgba(10,8,6,.88)); }
.set > * { position: relative; }
.set-name { font-size: 21px; font-weight: 600; line-height: 1.1; }
.set-days { font-size: 13px; color: var(--ink-soft); margin-top: 3px; }
.set .badge { position: absolute; top: 10px; left: 10px; font-family: var(--caps); font-size: 10px; letter-spacing: .16em; background: var(--gold); color: #1b140a; padding: 4px 8px 3px; border-radius: 99px; }
.set[aria-checked="true"] { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 8px 30px rgba(212,176,106,.25); }
.set:active { transform: scale(.98); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.ribbons { display: grid; gap: 10px; }
.ribbon {
  position: relative; height: 84px; border-radius: 12px; overflow: hidden; text-align: left;
  background: var(--panel) center 30% / cover no-repeat; border: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: center; padding: 0 16px;
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.ribbon::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(10,8,6,.92) 0%, rgba(10,8,6,.7) 55%, rgba(10,8,6,.15)); }
.ribbon > * { position: relative; }
.ribbon-name { font-size: 20px; font-weight: 600; line-height: 1.15; }
.ribbon-sub { font-size: 14px; color: var(--ink-soft); margin-top: 2px; }
.ribbon[aria-checked="true"] { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 8px 30px rgba(212,176,106,.25); }
.ribbon:active { transform: scale(.99); }
.note { color: var(--ink-soft); font-style: italic; margin: 4px 0 0; }
.row { flex-wrap: wrap; row-gap: 8px; }
.row > span { flex: 1; min-width: 130px; }
@media (max-width: 380px) { .seg button { padding: 6px 9px; font-size: 14px; } }

.switch { appearance: none; width: 48px; height: 28px; border-radius: 99px; background: #3a3229; position: relative; flex: none; cursor: pointer; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #e9dfcc; transition: transform .2s; }
.switch:checked { background: var(--gold-deep); }
.switch:checked::after { transform: translateX(20px); }
.switch:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.seg { display: inline-flex; background: #2b241d; border-radius: 99px; padding: 3px; flex: none; }
.seg button { padding: 6px 12px; border-radius: 99px; font-size: 15px; color: var(--ink-soft); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--gold); color: #1b140a; font-weight: 600; }

.resume { margin: 0 0 24px; }
.resume-btn { width: 100%; text-align: left; padding: 14px 16px; border-radius: 14px; background: var(--panel-2); border: 1px solid rgba(212,176,106,.4); display: block; }
.resume-label { display: block; font-weight: 600; color: var(--gold); }
.resume-detail { display: block; font-size: 15px; color: var(--ink-soft); }

.home-foot { text-align: center; margin-top: 10px; }
.linkish { color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; font-size: 16px; }

.begin-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 16px calc(var(--safe-b) + 14px); background: linear-gradient(180deg, rgba(13,11,9,0), var(--bg) 40%); display: flex; justify-content: center; z-index: 5; }
.begin { width: 100%; max-width: 608px; padding: 16px; border-radius: 14px; background: linear-gradient(180deg, #e2c27f, var(--gold-deep)); color: #1b140a; font-family: var(--caps); letter-spacing: .14em; font-size: 15px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.begin:active { transform: translateY(1px); }

/* ---------- Prayer screen ---------- */
#pray { position: fixed; inset: 0; overflow: hidden; background: #000; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
/* the prayer text can scroll vertically; keep horizontal swipes for us */
#pray .words, #pray .words * { touch-action: pan-y; }
.track { position: absolute; inset: 0; will-change: transform; }
.track.anim { transition: transform .38s cubic-bezier(.2, .7, .2, 1); }
.slide { position: absolute; top: 0; bottom: 0; width: 100%; overflow: hidden; background: #000; }
.slide .backdrop { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(28px) brightness(.55) saturate(1.1); transform: scale(1.1); }
.slide .art { position: absolute; inset: 0; transform-origin: center; }
.slide .art img { width: 100%; height: 100%; object-fit: contain; display: block; opacity: 0; transition: opacity .5s; }
.slide .art img.loaded { opacity: 1; }
.fill .slide .art img { object-fit: cover; object-position: var(--fx, 50%) var(--fy, 42%); }
.fill .slide .art { transform-origin: var(--fx, 50%) var(--fy, 42%); }
.fill .slide .backdrop { display: none; }
.slide.kb .art { animation: kenburns var(--kb-dur, 22s) ease-in-out both alternate infinite; }

@keyframes kenburns {
  from { transform: scale(var(--s0)) translate(var(--x0), var(--y0)); }
  to   { transform: scale(var(--s1)) translate(var(--x1), var(--y1)); }
}
@media (prefers-reduced-motion: reduce) {
  .slide.kb .art { animation-duration: 60s; }
}

.slide .scrim { position: absolute; left: 0; right: 0; bottom: 0; height: 62%; background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.55) 40%, rgba(0,0,0,.86)); pointer-events: none; transition: opacity .4s; }
.slide .words {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 22px calc(var(--safe-b) + 30px);
  max-width: 680px; margin: 0 auto; text-shadow: 0 1px 12px rgba(0,0,0,.7); transition: opacity .4s, transform .4s;
}
.words .label { font-family: var(--caps); font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }
.words .title { font-size: 26px; font-weight: 600; line-height: 1.1; margin: 0 0 8px; }
.words .body { font-size: 19px; line-height: 1.42; white-space: pre-line; color: #f6efe2; max-height: 46vh; overflow: auto; }
.words .body.long { font-size: 16.5px; }
.minimal .words .body { display: none; }
.minimal .words.reveal .body { display: block; }
.words .credit { margin-top: 10px; font-size: 13px; color: rgba(243,234,216,.55); font-style: italic; letter-spacing: .02em; }
.words .tap-note { display: none; font-size: 14px; color: var(--ink-soft); font-style: italic; }
.minimal .words:not(.reveal) .tap-note { display: block; }

.immersive .slide .words, .immersive .slide .scrim { opacity: 0; }
.immersive .chrome, .immersive .progress { opacity: 0; pointer-events: none; }

/* Mystery announcement */
.slide.announce .scrim { height: 100%; background: linear-gradient(180deg, rgba(0,0,0,.15), rgba(0,0,0,.5) 35%, rgba(0,0,0,.9)); }
.announce .words { text-align: center; padding-bottom: calc(var(--safe-b) + 46px); }
.announce .ordinal { font-family: var(--caps); font-size: 12px; letter-spacing: .26em; color: var(--rubric); text-transform: uppercase; filter: brightness(1.25); }
.announce .mname { font-size: clamp(32px, 9vw, 46px); font-weight: 500; line-height: 1.05; margin: 8px 0 14px; }
.announce .verse { font-style: italic; font-size: 20px; line-height: 1.4; color: #efe5d1; }
.announce .verse::first-letter { font-family: var(--caps); font-style: normal; font-size: 1.7em; line-height: 0; color: var(--gold); margin-right: 1px; }
.announce .ref { font-size: 14px; color: var(--ink-soft); margin-top: 8px; letter-spacing: .04em; }
.announce .fruit { display: inline-block; margin-top: 14px; font-family: var(--caps); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); border: 1px solid rgba(212,176,106,.5); padding: 6px 12px 5px; border-radius: 99px; }

/* End slide */
.slide.end .words { text-align: center; bottom: 50%; transform: translateY(50%); }
.end .amen { font-size: 56px; font-weight: 500; margin: 0 0 6px; }
.end .actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; align-items: center; }
.end .actions button { min-width: 230px; padding: 13px 18px; border-radius: 12px; border: 1px solid rgba(212,176,106,.6); font-family: var(--caps); font-size: 13px; letter-spacing: .12em; }
.end .actions button.primary { background: var(--gold); color: #1b140a; border-color: var(--gold); }

/* Chrome */
.chrome.top { position: absolute; top: 0; left: 0; right: 0; padding: calc(var(--safe-t) + 8px) 8px 18px; display: flex; align-items: flex-start; gap: 6px; background: linear-gradient(180deg, rgba(0,0,0,.6), rgba(0,0,0,0)); transition: opacity .4s; z-index: 3; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; flex: none; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 3px rgba(0,0,0,.6)); }
.icon-btn:active { background: rgba(255,255,255,.12); }
.where { flex: 1; text-align: center; padding-top: 4px; min-width: 0; }
.where-line { font-family: var(--caps); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: #f1e6cf; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
.beads { display: flex; justify-content: center; align-items: center; gap: 7px; margin-top: 9px; min-height: 12px; }
.bead { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.35); transition: all .25s; box-shadow: 0 0 3px rgba(0,0,0,.6); }
.bead.done { background: rgba(212,176,106,.75); }
.bead.now { background: var(--gold); width: 11px; height: 11px; box-shadow: 0 0 10px rgba(212,176,106,.9); }
.bead.big { width: 10px; height: 10px; border-radius: 2px; transform: rotate(45deg); }
.bead.big.now { width: 12px; height: 12px; }
.bead.sep { width: 4px; height: 4px; background: rgba(255,255,255,.2); }
/* the Jesus Prayer's sets of 25 */
.beads.dense { gap: 3px; }
.beads.dense .bead { width: 5px; height: 5px; }
.beads.dense .bead.now { width: 8px; height: 8px; }
.beads.dense .bead.sep { width: 7px; height: 7px; border-radius: 2px; transform: rotate(45deg); background: rgba(255,255,255,.35); }
.beads.dense .bead.sep.now { background: var(--gold); }
.progress { position: absolute; top: 0; left: 0; right: 0; height: 2px; z-index: 4; transition: opacity .4s; }
.progress div { height: 100%; width: 0; background: var(--gold); transition: width .35s; }
.auto-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; z-index: 4; }
.auto-bar div { height: 100%; width: 0; background: rgba(212,176,106,.8); }

.hint { position: absolute; left: 50%; bottom: calc(var(--safe-b) + 6px); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; font-family: var(--caps); font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: rgba(255,255,255,.75); z-index: 3; animation: nudge 1.6s ease-in-out infinite; pointer-events: none; white-space: nowrap; }
.hint svg { width: 34px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
@keyframes nudge { 0%, 100% { transform: translateX(-50%); } 50% { transform: translateX(calc(-50% - 10px)); } }

.desk-nav { display: none; }
@media (hover: hover) and (pointer: fine) {
  .desk-nav { display: block; }
  .desk-nav .icon-btn { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; background: rgba(0,0,0,.25); opacity: .55; transition: opacity .2s; }
  .desk-nav .icon-btn:hover { opacity: 1; }
  .desk-nav [data-action="prev"] { left: 14px; }
  .desk-nav [data-action="next"] { right: 14px; }
  .immersive .desk-nav { opacity: 0; }
}

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.55); animation: fade .25s backwards; }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 86vh; overflow: auto; overscroll-behavior: contain; background: var(--panel); border-radius: 18px 18px 0 0; padding: 0 18px calc(var(--safe-b) + 22px); max-width: 640px; margin: 0 auto; animation: up .3s cubic-bezier(.2,.7,.2,1) backwards; border-top: 1px solid var(--line); transition: transform .26s cubic-bezier(.3,.7,.3,1); }
.sheet-panel.dragging { transition: none; }
.sheet-scrim { transition: opacity .26s; }
.sheet.closing .sheet-panel { transform: translateY(105%) !important; }
.sheet.closing .sheet-scrim { opacity: 0 !important; }
.sheet-grab { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: center; height: 34px; margin: 0 -18px 6px; background: var(--panel); cursor: grab; touch-action: none; }
.sheet-grip { width: 44px; height: 5px; border-radius: 5px; background: #5a4e42; }
.sheet-close { position: absolute; right: 8px; top: 2px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-soft); font-size: 22px; line-height: 1; }
.sheet-close:active { background: rgba(255,255,255,.08); }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }
.sheet h3 { font-size: 24px; font-weight: 600; margin: 0 0 4px; line-height: 1.15; }
.sheet .meta { color: var(--ink-soft); margin: 0 0 12px; }
.sheet .src { display: inline-flex; gap: 6px; align-items: center; color: var(--gold); text-decoration: none; border-bottom: 1px solid rgba(212,176,106,.4); }
.sheet .thumb { width: 100%; max-height: 40vh; object-fit: contain; border-radius: 10px; background: #000; margin-bottom: 14px; }
.sheet section { margin-top: 20px; }
.jump { display: grid; gap: 6px; }
.jump button { text-align: left; padding: 9px 14px; font-size: 17px; align-items: baseline; border-radius: 10px; background: var(--panel-2); display: flex; justify-content: space-between; gap: 10px; }
.jump button.current { outline: 1px solid var(--gold); }
.jump button span:last-child { color: var(--ink-faint); font-size: 15px; }
.home-foot .linkish + .linkish { margin-left: 18px; }
.offline { margin: 6px 0 4px; }
.save-offline { width: 100%; padding: 12px; border-radius: 12px; background: var(--gold); color: #1b140a; font-family: var(--caps); letter-spacing: .1em; font-size: 13px; }
.save-offline:disabled { opacity: .6; }
.now-playing { margin: 18px 0 0; color: var(--ink-soft); font-size: 16px; font-style: italic; }
.now-playing .linkish { font-size: 15px; font-style: normal; margin-left: 6px; }
.danger { width: 100%; margin-top: 18px; padding: 13px; border-radius: 12px; border: 1px solid rgba(216,106,85,.6); color: var(--rubric); font-family: var(--caps); letter-spacing: .12em; font-size: 13px; }
.credits-list { list-style: none; padding: 0; margin: 0; font-size: 15px; }
.credits-list li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.credits-list a { color: var(--ink); text-decoration: none; }
.credits-list .who { color: var(--ink-faint); }
.prose p { margin: 0 0 10px; color: var(--ink-soft); }
.prose a { color: var(--gold); }

.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 40px); transform: translate(-50%, 20px); background: rgba(30,25,20,.95); border: 1px solid var(--line); padding: 10px 16px; border-radius: 99px; font-size: 16px; opacity: 0; transition: all .3s; pointer-events: none; z-index: 30; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
