/* Layout: a one-screen prayer app. "Pray" is the working screen (timer strip + current prayer + Next),
   sized to the viewport so nothing scrolls mid-prayer. Mysteries, The Hour, and Prayers are reference
   tabs that scroll on their own. Red rubrics for instructions, ink for words said aloud, gold only for
   "where you are now". */
/* Fonts are served from this site (latin subsets, SIL Open Font License: fonts/OFL-*.txt) so the app renders
   offline and never waits on another server. Alegreya and Cinzel are variable: one file serves each weight. */
@font-face { font-family: "Alegreya"; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/alegreya-latin.woff2) format("woff2"); }
@font-face { font-family: "Alegreya"; font-style: normal; font-weight: 500; font-display: swap; src: url(../fonts/alegreya-latin.woff2) format("woff2"); }
@font-face { font-family: "Alegreya"; font-style: normal; font-weight: 700; font-display: swap; src: url(../fonts/alegreya-latin.woff2) format("woff2"); }
@font-face { font-family: "Alegreya"; font-style: italic; font-weight: 400; font-display: swap; src: url(../fonts/alegreya-italic-latin.woff2) format("woff2"); }
@font-face { font-family: "Alegreya Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/alegreya-sans-400-latin.woff2) format("woff2"); }
@font-face { font-family: "Alegreya Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url(../fonts/alegreya-sans-500-latin.woff2) format("woff2"); }
@font-face { font-family: "Alegreya Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url(../fonts/alegreya-sans-700-latin.woff2) format("woff2"); }
@font-face { font-family: "Alegreya SC"; font-style: normal; font-weight: 500; font-display: swap; src: url(../fonts/alegreya-sc-500-latin.woff2) format("woff2"); }
@font-face { font-family: "Alegreya SC"; font-style: normal; font-weight: 700; font-display: swap; src: url(../fonts/alegreya-sc-700-latin.woff2) format("woff2"); }
@font-face { font-family: "Cinzel"; font-style: normal; font-weight: 500; font-display: swap; src: url(../fonts/cinzel-latin.woff2) format("woff2"); }
@font-face { font-family: "Cinzel"; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/cinzel-latin.woff2) format("woff2"); }
:root {
  --bg: #f3f2ef;
  --page: #fbfbf9;
  --ink: #1d1b21;
  --muted: #5e5a65;
  --line: #d8d5d0;
  --rubric: #a3162d;
  --rubric-soft: #f5e2e4;
  --gold: #8b691c;
  --gold-soft: #efe5cb;
  --f-display: "Cinzel", "Trajan Pro", Georgia, serif;
  --f-body: "Alegreya", Georgia, "Times New Roman", serif;
  --f-rubric: "Alegreya SC", "Alegreya", Georgia, serif;
  --f-ui: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  /* only the part of a side inset (a notched iPhone in landscape) that the centered 44rem column's own margin does
     not already clear: counted in full, it cut the title to "Holy Hour Ro..." and narrowed every pane. Where a box
     is full width (phone tab bar, sheets below 641px), 100vw is under 44rem and the whole inset counts. */
  --gutter-l: max(16px, calc(env(safe-area-inset-left, 0px) - max(0px, (100vw - var(--maxw)) / 2)));
  --gutter-r: max(16px, calc(env(safe-area-inset-right, 0px) - max(0px, (100vw - var(--maxw)) / 2)));
  --tabbar-h: 58px;
  --maxw: 44rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111015; --page: #19181e; --ink: #ebe7e0; --muted: #a49fa9; --line: #2e2c34;
    --rubric: #ee727b; --rubric-soft: #301b1f; --gold: #d8b45f; --gold-soft: #2d2718;
    color-scheme: dark;
  }
}
/* Named palettes chosen in Settings. "Auto" removes the attribute and follows the system.
   Light: Parchment (neutral), Vellum (tan), Rose (pink), Marian (blue).
   Dark: Night (neutral), Midnight (blue), Forest (green), Lent (purple).
   Every text/background pair checked at WCAG AA or better. */
:root[data-palette="parchment"] {
  --bg: #f3f2ef; --page: #fbfbf9; --ink: #1d1b21; --muted: #5e5a65; --line: #d8d5d0;
  --rubric: #a3162d; --rubric-soft: #f5e2e4; --gold: #8b691c; --gold-soft: #efe5cb;
  color-scheme: light;
}
:root[data-palette="vellum"] {
  --bg: #e3d3b3; --page: #f0e4c8; --ink: #2f2011; --muted: #6b5538; --line: #cdb88f;
  --rubric: #7d2416; --rubric-soft: #ecd4c3; --gold: #765711; --gold-soft: #e5d4a6;
  color-scheme: light;
}
:root[data-palette="rose"] {
  --bg: #f0d9df; --page: #faeef1; --ink: #2b1a22; --muted: #6d4e5c; --line: #e2c3cc;
  --rubric: #8f1a3e; --rubric-soft: #f4d6df; --gold: #815c18; --gold-soft: #efdfc1;
  color-scheme: light;
}
:root[data-palette="marian"] {
  --bg: #d9e4f2; --page: #f3f7fc; --ink: #152033; --muted: #4f607a; --line: #bfcde0;
  --rubric: #1f4aa0; --rubric-soft: #dde6f6; --gold: #816019; --gold-soft: #eee2c3;
  color-scheme: light;
}
:root[data-palette="night"] {
  --bg: #111015; --page: #19181e; --ink: #ebe7e0; --muted: #a49fa9; --line: #2e2c34;
  --rubric: #ee727b; --rubric-soft: #301b1f; --gold: #d8b45f; --gold-soft: #2d2718;
  color-scheme: dark;
}
:root[data-palette="midnight"] {
  --bg: #0d1730; --page: #142247; --ink: #e6ecf8; --muted: #9fb0d0; --line: #263758;
  --rubric: #ff8fa3; --rubric-soft: #3a2236; --gold: #e8c572; --gold-soft: #3a3120;
  color-scheme: dark;
}
:root[data-palette="forest"] {
  --bg: #0a2016; --page: #113223; --ink: #e4ece5; --muted: #91ad98; --line: #214a33;
  --rubric: #f09a84; --rubric-soft: #44261f; --gold: #d6b86a; --gold-soft: #35301a;
  color-scheme: dark;
}
:root[data-palette="dominican"] {
  --bg: #ecebe9; --page: #ffffff; --ink: #121214; --muted: #55555c; --line: #cfcfd3;
  --rubric: #9b1422; --rubric-soft: #f3e1e3; --gold: #7d6835; --gold-soft: #ebe6d6;
  color-scheme: light;
}
:root[data-palette="franciscan"] {
  --bg: #e2d6c3; --page: #f3ebdd; --ink: #3a2a1c; --muted: #6f5a45; --line: #cdbba0;
  --rubric: #7a3a1c; --rubric-soft: #ecd9cb; --gold: #79581c; --gold-soft: #e8d9b8;
  color-scheme: light;
}
:root[data-palette="carmelite"] {
  --bg: #e7dccd; --page: #fbf8f2; --ink: #352519; --muted: #70594a; --line: #d3c3ad;
  --rubric: #6e2f1f; --rubric-soft: #eed9cf; --gold: #7c5c23; --gold-soft: #ece0c2;
  color-scheme: light;
}
:root[data-palette="jesuit"] {
  --bg: #121212; --page: #1c1b1b; --ink: #ebe7dc; --muted: #a39e93; --line: #343230;
  --rubric: #ef8b7b; --rubric-soft: #3a2420; --gold: #d9b45f; --gold-soft: #332c18;
  color-scheme: dark;
}
:root[data-palette="benedictine"] {
  --bg: #e4e3df; --page: #f5f4f1; --ink: #1f1f22; --muted: #5b5a5e; --line: #cbc9c3;
  --rubric: #7b2d26; --rubric-soft: #efdcd9; --gold: #776335; --gold-soft: #e9e2cf;
  color-scheme: light;
}
:root[data-palette="redemptorist"] {
  --bg: #1b0f0f; --page: #281515; --ink: #efe3dd; --muted: #a8928c; --line: #3f2727;
  --rubric: #f08a8a; --rubric-soft: #3d2222; --gold: #d9b05c; --gold-soft: #352a16;
  color-scheme: dark;
}
:root[data-palette="wojtyla"] {
  --bg: #f1e9e9; --page: #fcf8f8; --ink: #22181a; --muted: #6a5558; --line: #e0cfd1;
  --rubric: #b2182b; --rubric-soft: #f6dcdf; --gold: #846520; --gold-soft: #efe1c4;
  color-scheme: light;
}
:root[data-palette="lent"] {
  --bg: #1a0f2a; --page: #27173e; --ink: #ece3f4; --muted: #ab9ac0; --line: #43305f;
  --rubric: #f29ab4; --rubric-soft: #43213a; --gold: #dcbb6a; --gold-soft: #392f1c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--f-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }

h1, h2 { font-family: var(--f-display); font-weight: 600; letter-spacing: 0.04em; text-wrap: balance; margin: 0; }
h1 { font-size: 1.25rem; line-height: 1.15; white-space: nowrap; }
h2 { font-size: 1.35rem; line-height: 1.2; }
h3, .study li h4 { font-family: var(--f-body); font-weight: 500; font-size: 1.15rem; line-height: 1.3; margin: 0; text-wrap: balance; }
p { margin: 0; }
a { color: var(--rubric); text-underline-offset: 2px; }

.rubric { font-family: var(--f-rubric); color: var(--rubric); letter-spacing: 0.04em; font-size: 0.95rem; }
.note { color: var(--muted); font-size: 0.95rem; }
/* after .note, so "note small" is small */
.small { font-size: 0.88rem; }
.eyebrow { font-family: var(--f-rubric); color: var(--rubric); letter-spacing: 0.06em; font-size: 0.9rem; }

/* ---------- App frame ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.top { flex: none; border-bottom: 1px solid var(--line); background: var(--bg); }
.top-in {
  max-width: var(--maxw); margin: 0 auto;
  padding-left: var(--gutter-l); padding-right: var(--gutter-r); padding-block: 10px 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: grid; gap: 0; min-width: 0; }
.brand .eyebrow { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand h1 { overflow: hidden; text-overflow: ellipsis; }
/* Wider than a phone, the title and the date wrap rather than lose their ends: with text spacing (WCAG 1.4.12) the
   44rem header row left them about 170px, so a 1280px window read "Saturday, November 1..." */
@media (min-width: 641px) {
  .brand h1, .brand .eyebrow { white-space: normal; overflow: visible; }
}
/* The saint names give way (ellipsis); the companion link always shows whole */
.saint { font-family: var(--f-ui); font-size: 0.82rem; color: var(--muted); display: flex; align-items: baseline; gap: 0; white-space: nowrap; margin-top: 2px; min-width: 0; }
.saint .link { font-size: inherit; padding: 0; }
.saint #saint-open { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the "/" between them is its own flex item (it would lose a typed space), so it carries its own margins */
.saint #comp-open { flex: none; }
.saint .sep { flex: none; margin: 0 0.4em; }
/* Wider than a phone (641px up), the header row is shared with the gear and six tabs: the names wrap instead, so a
   day's second saint is not cut away, and the header grows a line on days with a companion */
@media (min-width: 641px) {
  .saint { white-space: normal; flex-wrap: wrap; }
  .saint #saint-open { white-space: normal; overflow: visible; }
  /* stacked links: 24px tall targets that start at the left edge, and the companion on its own line, so no "/" starts a line */
  .saint .link { padding: 4px 0; text-align: left; }
  .saint .sep { display: none; }
  .saint #comp-open { flex-basis: 100%; }
}
.comp-blurb { font-size: 0.95rem; color: var(--muted); max-width: 36rem; }
.cdw.companion { border-left-color: var(--gold); }
.cdw .who { font-family: var(--f-rubric); color: var(--gold); letter-spacing: 0.04em; font-size: 0.9rem; font-style: normal; }
.cdw.compact { font-size: 0.98rem; padding-left: 12px; gap: 4px; }
.cdw.compact > p:first-child { font-style: normal; }
.cdw.compact p:nth-child(2) { font-style: italic; }
.cdw.compact cite { font-size: 0.78rem; }
.sheet-body .saint-item { display: grid; gap: 6px; }
/* a prayer's Latin grows with Prayer text size wherever it is shown: the Pray card (companion closings) and the Prayers tab */
.latin { font-style: italic; color: var(--muted); font-size: calc(0.98rem * var(--tscale)); }

.tabs { display: flex; gap: 2px; }
.tab {
  font-family: var(--f-ui); font-size: 0.95rem; font-weight: 500; color: var(--muted);
  background: none; border: 0; border-radius: 8px; padding: 6px 10px; cursor: pointer;
  display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 44px;
}
.tab svg { width: 20px; height: 20px; display: none; }
/* Not by fill alone: the selected tab's edge is --muted, 3:1 or better against the header in every palette */
.tab[aria-selected="true"] { color: var(--ink); background: var(--page); box-shadow: inset 0 0 0 1px var(--muted); }
.tab:hover { color: var(--ink); }

main { flex: 1 1 auto; min-height: 0; position: relative; }
.pane { height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pane-in {
  max-width: var(--maxw); margin: 0 auto;
  padding-left: var(--gutter-l); padding-right: var(--gutter-r); padding-block: 18px 40px;
  display: grid; gap: 22px; align-content: start;
}

/* Phone: tabs become a bottom bar */
@media (max-width: 640px) {
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
    background: var(--page); border-top: 1px solid var(--line);
    padding-left: var(--gutter-l); padding-right: var(--gutter-r);
    padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    justify-content: space-around; gap: 0;
  }
  .tab { font-size: 0.7rem; padding: 2px 0; border-radius: 6px; flex: 1 1 0; min-width: 0; min-height: 44px; }
  .tab .tl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab svg { display: block; }
  /* Not by hue alone: a top line and bold mark the selected tab */
  .tab[aria-selected="true"] { background: none; box-shadow: inset 0 2px 0 currentColor; font-weight: 700; color: var(--rubric); }
  main { padding-bottom: var(--tabbar-h); }
}
/* Just above the phone layout (a phone in landscape): the six inline tabs leave the title room to show whole */
@media (min-width: 641px) and (max-width: 720px) {
  .top-in { gap: 8px; }
  .tab { padding-left: 6px; padding-right: 6px; min-width: 44px; }
}

/* ---------- Pray pane ---------- */
.pane.pray { overflow: hidden; }
.pane.pray .pane-in { height: 100%; grid-template-rows: auto minmax(0, 1fr) auto; gap: 10px; padding-block: 12px 12px; }
.side { display: none; }
@media (min-width: 641px) {
  /* Desktop: the card sizes to its content instead of filling the window */
  .pane.pray { overflow-y: auto; }
  .pane.pray .pane-in { height: auto; grid-template-rows: auto auto auto; padding-block: 18px 40px; }
  /* a steady card, so Back, Next and the beads stay put from step to step; .pane.pray outranks the later base
     .stepper rule, and the vh cap keeps a phone in landscape (wider than 640px) from pushing Next down */
  .pane.pray .stepper { min-height: min(26rem, 55vh); }
  .s-body { max-height: 50vh; }
}
@media (min-width: 1024px) {
  /* The side panel spans all three rows; the last row takes its extra height, so the strip and card stay together */
  .pane.pray .pane-in { max-width: 72rem; grid-template-columns: minmax(0, 44rem) minmax(18rem, 1fr); grid-template-rows: auto auto 1fr; column-gap: 32px; align-items: start; }
  .pane.pray .tstrip, .pane.pray .rosary-wrap, .pane.pray .s-after { grid-column: 1; }
  .side { display: grid; gap: 16px; grid-column: 2; grid-row: 1 / span 3; position: sticky; top: 0; max-height: calc(100vh - 140px); overflow-y: auto; padding: 4px 4px 24px 0; align-content: start; }
  .side h3 { font-family: var(--f-rubric); color: var(--rubric); font-size: 0.9rem; letter-spacing: 0.04em; margin: 0 0 4px; }
  .side section { display: grid; gap: 8px; font-size: 0.98rem; }
  .side .mname { font-size: 1.25rem; }
  .side ol { margin: 0; padding-left: 1.4rem; display: grid; gap: 4px; font-size: 0.95rem; }
  .side ol li.now { color: var(--gold); font-weight: 500; }
  .side ol li { color: var(--muted); }
  .side .cdw { font-size: 0.95rem; }
  .side ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 6px; }
}
.gear { background: none; border: 1px solid transparent; border-radius: 10px; color: var(--muted); width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; flex: none; }
.gear svg { width: 22px; height: 22px; }
.gear:hover { color: var(--ink); border-color: var(--line); }
.settings { display: grid; gap: 22px; }
.sgroup { display: grid; gap: 12px; }
.sgroup h3 { font-family: var(--f-rubric); color: var(--rubric); font-size: 0.95rem; letter-spacing: 0.04em; margin: 0; }
.tsize-label { font-family: var(--f-ui); font-size: 0.9rem; color: var(--muted); align-self: center; min-width: 4.5rem; text-align: center; }
.rosary .runner { fill: var(--bd-now); opacity: 0.9; pointer-events: none; }

.tstrip {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center;
  background: var(--page); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
/* one line, so the card does not shrink when the phrase grows ("(paused)", the last part): the Hour tab has it whole */
.ts-l { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex-wrap: nowrap; }
.ts-clock { font-family: var(--f-ui); font-weight: 500; font-size: 1.55rem; line-height: 1; font-variant-numeric: tabular-nums; }
.ts-now { font-family: var(--f-ui); color: var(--muted); font-size: 0.92rem; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-now strong { color: var(--ink); }
.hbar { display: flex; gap: 3px; height: 8px; grid-column: 1 / -1; }
.hseg { position: relative; background: var(--line); border-radius: 4px; overflow: hidden; min-width: 6px; }
.hseg.now { background: var(--gold-soft); outline: 1px solid var(--gold); }
.hfill { position: absolute; inset: 0 auto 0 0; background: var(--gold); width: 0; }
/* Start/Pause is short to keep the strip thin; its tap area reaches into the strip's padding instead */
#p-start { position: relative; }
#p-start::before { content: ""; position: absolute; inset: -6px -4px; }

/* The rosary is the card's border: a chain with 54 beads around the prayer, medal at the bottom
   center, pendant hanging down through the channel between Back and Next. */
.rosary-wrap { position: relative; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr); padding: 10px 10px 0; }
.stepper {
  background: var(--page); border: 0; border-radius: 18px;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 10px;
  padding: 16px 18px 16px; min-height: 0;
}
/* Bead look tokens. Ink follows the page palette; the others are fixed materials that read on both themes. */
:root { --bd-fill: var(--page); --bd-stroke: var(--muted); --bd-done: var(--muted); --bd-now: var(--gold); --bd-halo: var(--gold-soft); --bd-chain: var(--line); --bd-sheen: 0; }
:root[data-blook="wood"]   { --bd-stroke: #a67c52; --bd-done: #7d4f2a; --bd-chain: #b59a7a; --bd-sheen: 0.3; }
:root[data-blook="pearl"]  { --bd-stroke: #bfb4a2; --bd-done: #ebe4d8; --bd-chain: #cfc6b6; --bd-sheen: 0.7; }
:root[data-blook="garnet"] { --bd-stroke: #a85a68; --bd-done: #7e1f2f; --bd-chain: #b48892; --bd-sheen: 0.3; }
:root[data-blook="marian"] { --bd-stroke: #6f88bd; --bd-done: #2e4f91; --bd-chain: #93a6cf; --bd-sheen: 0.3; }
:root[data-blook="jet"]    { --bd-stroke: #3a3a40; --bd-done: #16161a; --bd-chain: #8c8c94; --bd-sheen: 0.35; }
:root[data-blook="walnut"] { --bd-stroke: #6b4a2e; --bd-done: #46301f; --bd-chain: #a88a6a; --bd-sheen: 0.3; }
:root[data-palette="redemptorist"][data-blook="jet"], :root[data-palette="jesuit"][data-blook="jet"], :root[data-palette="night"][data-blook="jet"], :root[data-palette="midnight"][data-blook="jet"], :root[data-palette="forest"][data-blook="jet"], :root[data-palette="lent"][data-blook="jet"] { --bd-stroke: #8a8a92; --bd-done: #c9c9d0; --bd-chain: #5a5a62; }
:root[data-palette="marian"][data-blook="marian"] { --bd-stroke: #4d6aa8; --bd-done: #1d3b78; }
/* The dark materials vanish on a dark page, so the dark themes (and Auto on a dark device) get lighter tints:
   done beads at 3:1 or better against page and background, or progress cannot be seen. */
:root[data-palette="redemptorist"][data-blook="wood"], :root[data-palette="jesuit"][data-blook="wood"], :root[data-palette="night"][data-blook="wood"], :root[data-palette="midnight"][data-blook="wood"], :root[data-palette="forest"][data-blook="wood"], :root[data-palette="lent"][data-blook="wood"] { --bd-done: #b08455; }
:root[data-palette="redemptorist"][data-blook="walnut"], :root[data-palette="jesuit"][data-blook="walnut"], :root[data-palette="night"][data-blook="walnut"], :root[data-palette="midnight"][data-blook="walnut"], :root[data-palette="forest"][data-blook="walnut"], :root[data-palette="lent"][data-blook="walnut"] { --bd-stroke: #a58564; --bd-done: #a58564; }
:root[data-palette="redemptorist"][data-blook="garnet"], :root[data-palette="jesuit"][data-blook="garnet"], :root[data-palette="night"][data-blook="garnet"], :root[data-palette="midnight"][data-blook="garnet"], :root[data-palette="forest"][data-blook="garnet"], :root[data-palette="lent"][data-blook="garnet"] { --bd-done: #c86a7a; }
:root[data-palette="redemptorist"][data-blook="marian"], :root[data-palette="jesuit"][data-blook="marian"], :root[data-palette="night"][data-blook="marian"], :root[data-palette="midnight"][data-blook="marian"], :root[data-palette="forest"][data-blook="marian"], :root[data-palette="lent"][data-blook="marian"] { --bd-done: #8aa0d0; }
:root[data-palette="redemptorist"][data-blook="garnet"] { --bd-done: #c4566a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-palette]):not([data-chapel="1"])[data-blook="jet"] { --bd-stroke: #8a8a92; --bd-done: #c9c9d0; --bd-chain: #5a5a62; }
  :root:not([data-palette]):not([data-chapel="1"])[data-blook="wood"] { --bd-done: #b08455; }
  :root:not([data-palette]):not([data-chapel="1"])[data-blook="walnut"] { --bd-stroke: #a58564; --bd-done: #a58564; }
  :root:not([data-palette]):not([data-chapel="1"])[data-blook="garnet"] { --bd-done: #c86a7a; }
  :root:not([data-palette]):not([data-chapel="1"])[data-blook="marian"] { --bd-done: #8aa0d0; }
}
/* Chapel mode: every bead look dims to the chapel's muted ink */
:root[data-chapel="1"][data-blook] { --bd-stroke: var(--muted); --bd-done: var(--muted); --bd-chain: var(--line); --bd-sheen: 0; }
:root[data-blook="pearl"] .rosary .rb.done, :root[data-blook="pearl"] .rosary .medal.done, :root[data-blook="pearl"] .tk-bead.done { stroke: #807362; border-color: #807362; }
:root[data-blook="pearl"] .rosary .cross:not(.now) { fill: #807362; }
:root[data-blook="pearl"] .tk-cross:not(.now) { color: #807362; }

/* Layout switch: border loop (default), compact row, or off */
:root:not([data-rstyle="border"]) .rosary { display: none; }
:root:not([data-rstyle="border"]) .rosary-wrap { padding: 0; }
:root:not([data-rstyle="border"]) .stepper { border: 1px solid var(--line); border-radius: 12px; }
:root:not([data-rstyle="border"]) .s-after { padding: 12px 0 0; }
:root:not([data-rstyle="border"]) .s-ctrl { grid-template-columns: auto minmax(0, 1fr); }
:root:not([data-rstyle="border"]) .s-ctrl .chan { display: none; }
:root:not([data-rstyle="border"]) .s-foot { min-height: 0; align-items: center; }
:root:not([data-rstyle="row"]) .track { display: none; }

.track { display: grid; gap: 8px; }
.decades { display: flex; gap: 6px; flex-wrap: wrap; }
.dec { font-family: var(--f-display); font-size: 0.78rem; min-width: 2.1rem; text-align: center; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); }
.dec.done { color: var(--ink); border-color: var(--muted); }
.dec.now { background: var(--rubric); border-color: var(--rubric); color: var(--page); }
.tk-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; min-height: 22px; }
.tk-bead { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--bd-stroke); background: var(--bd-fill); flex: none; cursor: pointer; position: relative; }
.tk-bead.big { width: 18px; height: 18px; }
.tk-bead.medal { width: 22px; height: 22px; }
.tk-bead.done { background: var(--bd-done); border-color: var(--bd-done); }
.tk-bead.done::after { content: ""; position: absolute; left: 22%; top: 18%; width: 30%; height: 30%; border-radius: 50%; background: #fff; opacity: var(--bd-sheen); }
.tk-bead.now { background: var(--bd-now); border-color: var(--bd-now); box-shadow: 0 0 0 4px var(--bd-halo); }
.tk-bead.pre { border-color: var(--bd-now); border-style: dashed; }
.tk-cross { width: 16px; height: 22px; color: var(--bd-done); flex: none; cursor: pointer; }
.tk-cross.now { color: var(--bd-now); }
.tk-gap { width: 10px; }
.tk-mark { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--bd-now); flex: none; }

.rosary { position: absolute; left: 10px; top: 10px; overflow: visible; pointer-events: none; z-index: 2; }
.rosary .chain { fill: none; stroke: var(--bd-chain); stroke-width: 1.5; }
.rosary .rb { fill: var(--bd-fill); stroke: var(--bd-stroke); stroke-width: 1.5; }
.rosary .rb.done { fill: var(--bd-done); stroke: var(--bd-done); }
.rosary .rb.now { fill: var(--bd-now); stroke: var(--bd-now); }
.rosary .rb.pre { stroke: var(--bd-now); stroke-width: 2; stroke-dasharray: 2.5 2; }
.rosary .halo { fill: var(--bd-halo); }
.rosary .sheen { fill: #fff; opacity: var(--bd-sheen); pointer-events: none; }
.rosary .medal { fill: var(--bd-fill); stroke: var(--bd-stroke); stroke-width: 1.5; }
.rosary .medal.done { fill: var(--bd-done); stroke: var(--bd-done); }
.rosary .medal.now { fill: var(--bd-now); stroke: var(--bd-now); }
.rosary .cross { fill: var(--bd-done); }
.rosary .cross.now { fill: var(--bd-now); }
.rosary .num { font-family: var(--f-display); font-size: 11px; fill: var(--muted); }
.rosary .num.now { fill: var(--rubric); font-weight: 600; }
.rosary .num.done { fill: var(--ink); }
.rosary .mark { fill: var(--bd-fill); stroke: var(--bd-now); stroke-width: 1.5; }
.rosary .hit { fill: transparent; stroke: none; pointer-events: auto; cursor: pointer; }
.s-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.s-meta .rubric { font-size: 0.9rem; }
.s-after { display: grid; gap: 8px; padding: 14px 10px 0; }
.s-ctrl .chan { width: 40px; }
.s-ctrl .ghost { visibility: hidden; pointer-events: none; }
/* The card scrolls, so it clips: 4px of padding (taken back by the margin, so the text box is unchanged) leaves
   room for the focus rings of the links and fields inside it */
.s-body { display: grid; gap: 10px; align-content: start; overflow-y: auto; min-height: 0; padding: 4px 8px 4px 4px; margin: -4px; scroll-padding: 4px; }
/* More below: the bottom edge fades so a clipped prayer never looks finished (markMore in app.js) */
.s-body.more { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); }
.s-body:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.s-body.more:focus-visible { -webkit-mask-image: none; mask-image: none; } /* a mask would clip the focus ring */
/* nor fade a focused control at the bottom edge (its own rule: a browser without :has drops only this one) */
.s-body.more:has(:focus-visible) { -webkit-mask-image: none; mask-image: none; }
/* the side panel, and a sheet with nothing to focus in it, scroll: they take focus themselves (tabindex), as .s-body does */
.side:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sheet-body:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.ctx { font-family: var(--f-ui); font-size: 0.9rem; color: var(--muted); }
.begin-links { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 16px; }
/* up to 340px wide the two Begin links wrapped, and the second line fell into the card's "more" fade (a first-generation
   iPhone SE): at the card's smaller link size (.begin-rows .link) they share one line above it (DECISIONS) */
@media (max-width: 340px) { .begin-links { gap: 0 10px; } .begin-links .link { font-size: 0.85rem; } }
/* a short screen (a 4.7-inch iPhone SE in a Safari tab, about 375x553) left the whole Begin links line in the card's fade:
   the card drops its date line, which the header above shows too (DECISIONS) */
@media (max-height: 600px) { .s-body .begin-date { display: none; } }
.begin-about { font-size: 0.82rem; }
.pane-about { font-family: var(--f-ui); font-size: 0.88rem; color: var(--muted); text-align: center; grid-column: 1 / -1; }
:root { --tscale: 1; }
.ptext { font-size: calc(1.3rem * var(--tscale)); line-height: 1.5; max-width: 34rem; }
/* a prayer of several paragraphs (the chaplet's opening, Holy God three times, the Creed) shows where each begins;
   V. and R. keep the grid gap of .vr */
.ptext:not(.vr) p + p { margin-top: 0.6em; }
.ptext.long { font-size: calc(1.1rem * var(--tscale)); }
.mname { font-size: calc(1.55rem * var(--tscale)); line-height: 1.25; font-style: italic; text-wrap: balance; }
.read { font-size: calc(1.1rem * var(--tscale)); }
.read strong { font-family: var(--f-ui); font-weight: 700; }
.vr { display: grid; gap: 6px; }
.vr b { font-family: var(--f-rubric); color: var(--rubric); font-weight: 700; margin-right: 2px; }
.s-ctrl { display: grid; grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr); gap: 6px; align-items: center; }
.s-foot { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; min-height: 48px; }
.s-foot .note { font-size: 0.82rem; max-width: 42%; }
/* Start over / Settings stay right of the crucifix's tap area (36px, centered) at any text size; they wrap instead */
.s-links { max-width: calc(50% - 18px); flex-wrap: wrap; justify-content: flex-end; }
@media (hover: none) { .kbd-hint { display: none; } }
/* Phone in landscape: too short for a fixed card, so the Pray pane scrolls as it does on wider screens */
@media (max-width: 640px) and (max-height: 520px) {
  .pane.pray { overflow-y: auto; }
  .pane.pray .pane-in { height: auto; grid-template-rows: auto auto auto; }
  .stepper { min-height: 16rem; }
}

.opts { display: flex; flex-wrap: wrap; gap: 12px 24px; }
.opt { display: grid; gap: 6px; }
.opt > span { font-family: var(--f-ui); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

/* ---------- Buttons ---------- */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button, .btn {
  font-family: var(--f-ui); font-size: 0.95rem; font-weight: 500;
  border: 1px solid var(--line); background: var(--page); color: var(--ink);
  border-radius: 999px; padding: 7px 14px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--page); border-color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--page); border-color: var(--ink); }
.btn.big { font-size: 1.15rem; padding: 13px 18px; }
/* "Pray again" fits one line in a 108px Next at 320px, as Begin, Next and Amen do, so the card keeps its height
   (no nowrap: at larger text the label wraps inside the pill rather than spilling out) */
.s-ctrl .btn.big { padding-left: 12px; padding-right: 12px; }
.btn.sm { padding: 6px 12px; font-size: 0.9rem; }
/* 44px tap targets for the actions; the strip's Start keeps its thin look (its ::before tap area reaches 44px) */
.btn { min-height: 44px; }
#p-start { min-height: 0; }
.btn:disabled, .seg button:disabled, .link:disabled { opacity: 0.4; cursor: default; }
.link { font-family: var(--f-ui); font-size: 0.92rem; background: none; border: 0; color: var(--rubric); padding: 4px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; text-align: left; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Mysteries pane ---------- */
.sec-head { display: grid; gap: 6px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.day {
  font-family: var(--f-ui); background: transparent; color: var(--ink);
  border: 1px solid transparent; border-radius: 8px; padding: 6px 0 5px;
  display: grid; gap: 1px; justify-items: center; cursor: pointer; min-width: 0;
}
.day:hover { border-color: var(--line); }
.day .dw { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.day .dn { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
/* the set's name wraps inside its day rather than losing its end: one line at default spacing, but with text spacing
   (WCAG 1.4.12) an ellipsis read "Sorrow..." at 360-414px */
.day .ds { font-size: 0.66rem; color: var(--muted); max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
@media (max-width: 359px) {
  /* Too narrow for "Sorrowful": three letters (the button's label has the full name) */
  .day .ds { font-size: 0; }
  .day .ds::after { content: attr(data-short); font-size: 0.66rem; }
}
.day.has-feast .dn { position: relative; }
.day.has-feast .dn::after { content: ""; position: absolute; right: -8px; top: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }
.mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.mg-h { font-family: var(--f-ui); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); text-align: center; padding: 4px 0; }
.mg-d { font-family: var(--f-ui); background: var(--bg); border: 1px solid transparent; border-radius: 8px; padding: 6px 2px; display: grid; justify-items: center; gap: 1px; cursor: pointer; color: var(--ink); position: relative; }
.mg-d .n { font-weight: 700; font-variant-numeric: tabular-nums; }
.mg-d .k { font-size: 0.68rem; color: var(--muted); }
.mg-d:hover { border-color: var(--line); }
.mg-d.is-today { border-color: var(--rubric); }
.mg-d.sel { background: var(--ink); color: var(--page); }
.mg-d.sel .k { color: var(--page); opacity: 0.8; }
.mg-d.has-feast::after { content: ""; position: absolute; right: 5px; top: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }
.mfeasts { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 4px; font-size: 0.95rem; }
.mfeasts .link { font-family: var(--f-ui); font-weight: 700; min-width: 1.6rem; display: inline-block; text-align: center; }
/* the date in its own column, so a feast name that wraps stays under itself, not under the numbers */
.mfeasts li { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr); column-gap: 0.35em; align-items: baseline; }
.day.is-today .dw::after { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--rubric); margin-left: 3px; vertical-align: 2px; }
.day[aria-pressed="true"] { background: var(--ink); color: var(--page); }
.day[aria-pressed="true"] .dw, .day[aria-pressed="true"] .ds { color: var(--page); opacity: 0.85; }
/* the dots on a selected (ink-filled) day keep their hue and get a page-colored ring, 11:1 or better against --ink */
:root:not([data-chapel="1"]) .day[aria-pressed="true"].has-feast .dn::after, :root:not([data-chapel="1"]) .day[aria-pressed="true"].is-today .dw::after, :root:not([data-chapel="1"]) .mg-d.sel.has-feast::after { box-shadow: 0 0 0 1.5px var(--page); }

.mlist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.mlist li { display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: 2px 10px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.mnum { font-family: var(--f-display); font-size: 1.1rem; color: var(--rubric); line-height: 1.6; }
/* The numeral holds column 1; everything else in the item stays in column 2, however many there are */
.mlist li > .mnum, .study li > .mnum { grid-column: 1; grid-row: 1 / span 3; }
.mlist li > :not(.mnum), .study li > :not(.mnum) { grid-column: 2; }
.mref { font-family: var(--f-ui); font-size: 0.92rem; color: var(--muted); }
.mref strong { color: var(--ink); font-weight: 700; }
.mlist .link { justify-self: start; padding-top: 6px; }

.aside {
  border-left: 3px solid var(--rubric); background: var(--rubric-soft);
  padding: 12px 14px; border-radius: 0 8px 8px 0; font-size: 0.96rem;
}

/* ---------- Hour pane ---------- */
.cdw { margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); display: grid; gap: 6px; }
.cdw p:first-child { font-style: italic; }
/* A companion block: the "In the X voice" label upright, the quotation italic, as in the compact ones */
.cdw p.who { font-style: normal; }
.cdw .who + p { font-style: italic; }
.cdw cite { display: block; font-style: normal; font-family: var(--f-ui); font-size: 0.85rem; color: var(--muted); }
.cdw blockquote { margin: 0; }
.cdw blockquote p { font-style: italic; }
.cdw .vq { margin: 0; }
.cdw .vq p { font-style: italic; }
.card { background: var(--page); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.timer { display: grid; gap: 14px; }
.t-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
.t-clock { font-family: var(--f-ui); font-weight: 500; font-size: 2.6rem; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.t-now { font-family: var(--f-ui); color: var(--muted); min-width: 0; }
.t-now strong { color: var(--ink); }
.timer .hbar { height: 14px; }
.t-ctrl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.t-end { font-family: var(--f-ui); color: var(--muted); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.t-wake { font-family: var(--f-ui); font-size: 0.85rem; color: var(--muted); }
/* read by a screen reader, not shown (#t-live) */
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.segs { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.segs li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.segs li.now h3::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); margin-right: 8px; vertical-align: 2px; }
.segs .sd { color: var(--muted); font-size: 0.95rem; grid-column: 1; }
.segs label { font-family: var(--f-ui); font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 6px; grid-column: 2; grid-row: 1 / span 2; white-space: nowrap; }
.segs input { width: 4.2rem; font: 500 1rem var(--f-ui); font-variant-numeric: tabular-nums; padding: 6px 8px; border: 1px solid var(--muted); border-radius: 8px; background: var(--page); color: var(--ink); }
.seg-total { font-family: var(--f-ui); font-size: 0.92rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Learn pane ---------- */
.msum { font-size: 1.05rem; color: var(--muted); max-width: 34rem; }
.quiz { display: grid; gap: 12px; }
.q-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.q-top .seg button { padding: 5px 11px; font-size: 0.88rem; }
.q-score { font-family: var(--f-ui); font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.q-stem { font-size: 1.3rem; line-height: 1.4; text-wrap: balance; }
.q-stem.story { font-size: 1.1rem; font-style: italic; }
.q-opts { display: grid; gap: 8px; }
.qopt {
  font-family: var(--f-body); font-size: 1.05rem; text-align: left;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 10px; padding: 11px 14px; cursor: pointer; width: 100%;
}
.qopt:hover { border-color: var(--muted); }
.qopt:disabled { cursor: default; }
.qopt.right { border-color: var(--gold); background: var(--gold-soft); }
.qopt.wrong { border-color: var(--rubric); background: var(--rubric-soft); }
.qopt.dim { opacity: 0.55; }
.q-fb { font-size: 1rem; min-height: 1.6em; }
.q-fb strong { font-family: var(--f-rubric); letter-spacing: 0.04em; }
.q-fb.ok strong { color: var(--gold); }
.q-fb.no strong { color: var(--rubric); }

.study { display: grid; gap: 10px; }
/* the Eucharistic reflections (Learn tab): three short lists, each title a link to its sheet, its line below it */
.euch { display: grid; gap: 14px; }
.euch ol { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 10px; }
.euch li .note { margin-top: 2px; }
.euch .ref { white-space: normal; } /* a long source (the Summa, the Adoro te) wraps at 320px */
.study details { border: 1px solid var(--line); border-radius: 12px; background: var(--page); }
.study summary { cursor: pointer; padding: 12px 16px; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; list-style: none; }
.study summary::-webkit-details-marker { display: none; }
.study summary h3 { font-family: var(--f-display); font-weight: 600; font-size: 1rem; letter-spacing: 0.04em; }
/* The flex summary drops the default marker: a drawn chevron (no text, so the heading's name stays clean)
   points right when closed and down when open */
.study summary h3::before { content: ""; display: inline-block; width: 0.45em; height: 0.45em; margin: 0 0.6em 0.12em 0.1em; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); }
.study details[open] > summary h3::before { transform: rotate(45deg); }
.study summary .note { font-size: 0.85rem; text-align: right; }
.study details > .cdw { margin: 0 16px 12px; }
.study ol { list-style: none; margin: 0; padding: 0 16px 6px; border-top: 1px solid var(--line); }
.study li { display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: 2px 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.study li:last-child { border-bottom: 0; }
.study li .msum { font-size: 0.98rem; }
.study li .mref { font-size: 0.88rem; }
.study li .miss { font-family: var(--f-ui); font-size: 0.78rem; color: var(--rubric); }

/* ---------- Bead lines + meditation sheet ---------- */
.bead-line { font-size: calc(1.02rem * var(--tscale)); line-height: 1.45; color: var(--muted); font-style: italic; max-width: 34rem; border-left: 2px solid var(--gold); padding-left: 10px; }
/* a bead line's reference, in the stepper, the side panel, and the meditation sheet's lists */
.ref { font-style: normal; font-family: var(--f-ui); font-size: 0.8rem; white-space: nowrap; }
/* kept whole when it fits on a line (an inline-block moves down as one piece), and wrapped inside only when it is
   wider than the line by itself, so a large text size never pushes it past the card */
.nw { display: inline-block; }
.side ol .note { display: block; white-space: nowrap; }
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet[hidden] { display: none; }
.sheet-back { position: absolute; inset: 0; background: rgba(20, 16, 24, 0.5); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92%;
  background: var(--page); color: var(--ink); border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column; box-shadow: 0 -8px 30px rgba(0,0,0,0.2);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sheet-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px var(--gutter-r) 10px var(--gutter-l); border-bottom: 1px solid var(--line); flex: none;
}
#m-close { min-height: 44px; }
.sheet-body { overflow-y: auto; padding: 16px var(--gutter-r) 28px var(--gutter-l); display: grid; gap: 18px; min-height: 0; }
.sheet-body h2 { font-family: var(--f-body); font-style: italic; font-weight: 500; font-size: 1.6rem; letter-spacing: 0; }
.sheet-body h3 { font-family: var(--f-rubric); color: var(--rubric); font-size: 0.95rem; letter-spacing: 0.04em; margin-bottom: 6px; }
.sheet-body section { display: grid; gap: 8px; }
.sheet-body section p + p { margin-top: 0; }
.sheet-body ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 8px; }
.sheet-body .deeper { font-size: 0.95rem; color: var(--muted); }
.sheet-body .deeper strong { color: var(--ink); font-family: var(--f-ui); font-weight: 700; }
.sheet-body details { border: 1px solid var(--line); border-radius: 10px; }
.sheet-body summary { cursor: pointer; padding: 10px 14px; font-family: var(--f-ui); font-weight: 500; }
.sheet-body details ol { margin: 0; padding: 0 14px 10px 2rem; display: grid; gap: 6px; font-size: 0.98rem; }
.sheet-body details > .learn { padding: 0 14px 12px; display: grid; gap: 8px; } /* a reflection's Learn more: off the frame, spaced as its section */
.sheet-act { display: flex; gap: 10px; flex-wrap: wrap; }
@media (min-width: 641px) {
  .sheet-panel { left: 50%; right: auto; top: 5vh; bottom: auto; transform: translateX(-50%); width: min(42rem, calc(100% - 32px)); max-height: 90vh; border-radius: 16px; }
  .sheet-head { padding: 12px 20px 10px; }
  .sheet-body { padding: 18px 20px 28px; }
}
@media (prefers-reduced-motion: no-preference) {
  .sheet-panel { animation: sheet-up 180ms ease-out; }
  @keyframes sheet-up { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
  @media (min-width: 641px) { @keyframes sheet-up { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } } }
}

/* ---------- Silence, intentions, journal ---------- */
.intent { font-family: var(--f-ui); font-size: 1rem; color: var(--gold); }
.glyph { width: 22px; height: 22px; vertical-align: -5px; margin-right: 8px; color: var(--rubric); flex: none; }
.glyph.big { width: 36px; height: 36px; display: block; margin: 2px 0 6px; }
.glyph.gside { width: 26px; height: 26px; }
.begin-rows { margin: 4px 0 0; display: grid; gap: 8px; }
.begin-rows div { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 8px; align-items: baseline; }
.begin-rows dt { font-family: var(--f-ui); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.begin-rows dd { margin: 0; }
.begin-rows .link { font-size: 0.85rem; margin-left: 6px; }
.sil { display: grid; gap: 14px; justify-items: start; padding-top: 6px; }
.sil-ring {
  --p: 0; width: 112px; height: 112px; border-radius: 50%;
  background: conic-gradient(var(--gold) calc(var(--p) * 360deg), var(--line) 0);
  display: grid; place-items: center; position: relative;
}
.sil-ring::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--page); }
.sil-ring.done { background: var(--gold); }
.sil-num { position: relative; font-family: var(--f-ui); font-weight: 500; font-size: 2rem; font-variant-numeric: tabular-nums; }
.jbox { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
textarea {
  width: 100%; font: 400 1.05rem/1.5 var(--f-body); color: var(--ink); background: var(--bg);
  border: 1px solid var(--muted); border-radius: 10px; padding: 10px 12px; resize: vertical;
}
/* a textarea is a scroll container: in the sheet's grid its minimum height is 0, so a sheet taller than the screen
   squeezed it to one line (the Copy fallback, New entry in landscape) */
.sheet-body textarea { min-height: 7.5rem; }
/* Placeholders carry labels and prompts here ("Decade I", "What stayed with you?"): --muted, not the browser gray */
::placeholder { color: var(--muted); opacity: 1; }
.int-list { display: grid; gap: 10px; }
.int-row { display: grid; grid-template-columns: 2rem minmax(0, 1fr); align-items: center; gap: 8px; }
.int-row input { width: 100%; font: 400 1.05rem var(--f-body); color: var(--ink); background: var(--bg); border: 1px solid var(--muted); border-radius: 10px; padding: 9px 12px; }
.jlist { display: grid; gap: 12px; }
.jentry { background: var(--page); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 6px; }
/* a link typed into a note or an intention breaks instead of widening the grids around it (break-word: Safari before 15.4) */
.jentry p, .intent { overflow-wrap: anywhere; word-break: break-word; }
.jentry .link.small { font-size: 0.82rem; justify-self: start; color: var(--muted); }
/* Settings, Your data: the paste box and the summary before a restore, each with its buttons under it */
.rs-box { display: grid; gap: 8px; }
/* the group's heading (opened from the Journal tab, or after a restore) and the summary take focus: the app's ring */
#data-h:focus-visible, #rs-sum:focus-visible, #rs-msg:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Chapel mode: dim and warm (text size is Prayer text size's) ---------- */
:root[data-chapel="1"] {
  --bg: #0a0908; --page: #121110; --ink: #cfc3b1; --muted: #857b6d; --line: #2a2622;
  --rubric: #be636b; --rubric-soft: #2a1618; --gold: #b3924d; --gold-soft: #2a2213;
  color-scheme: dark;
}
:root[data-chapel="1"] .ptext { line-height: 1.55; }
:root[data-chapel="1"] .btn.primary { background: #2a2622; color: var(--ink); border-color: #3a352f; }
:root[data-chapel="1"] .day[aria-pressed="true"], :root[data-chapel="1"] .seg button[aria-pressed="true"] { background: #2a2622; color: var(--ink); border-color: var(--gold); }
:root[data-chapel="1"] .day[aria-pressed="true"] .dw, :root[data-chapel="1"] .day[aria-pressed="true"] .ds { color: var(--ink); opacity: 0.85; }
/* a gold ring inside the cell: the fill alone is too close to the other days, and a selected today keeps its border */
:root[data-chapel="1"] .mg-d.sel { background: #2a2622; color: var(--ink); box-shadow: inset 0 0 0 2px var(--gold); }
:root[data-chapel="1"] .mg-d.sel .k { color: var(--ink); }
:root[data-chapel="1"] .sheet-back { background: rgba(0,0,0,0.7); }

/* ---------- Prayers pane ---------- */
.plist { display: grid; gap: 26px; }
.prayer { display: grid; gap: 6px; }
.prayer .src { font-family: var(--f-ui); font-size: 0.8rem; color: var(--muted); }
/* Prayer text size reaches the Prayers tab too (Benediction is read here); 1.0625rem is the body size, so Normal is unchanged */
.prayer .body { max-width: 36rem; font-size: calc(1.0625rem * var(--tscale)); }
.prayer .body p + p { margin-top: 8px; }
.prayer .body.exam p + p { margin-top: 12px; }
.prayer .body.exam strong { font-family: var(--f-rubric); font-weight: 700; color: var(--rubric); letter-spacing: 0.03em; }
.sources ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 6px; font-size: 0.95rem; }

@media (max-width: 480px) {
  .ptext { font-size: calc(1.2rem * var(--tscale)); }
  .ptext.long { font-size: calc(1.04rem * var(--tscale)); }
  .mname { font-size: calc(1.35rem * var(--tscale)); }
  .t-clock { font-size: 2.2rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .dec, .day, .hseg, .tab { transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease; }
}
/* Windows High Contrast and other forced colors: backgrounds are dropped, so pressed, selected and progress
   states need system colors to stay visible */
@media (forced-colors: active) {
  .seg button[aria-pressed="true"], .day[aria-pressed="true"], :root[data-chapel="1"] .day[aria-pressed="true"], :root[data-chapel="1"] .seg button[aria-pressed="true"], .mg-d.sel, :root[data-chapel="1"] .mg-d.sel, .dec.now { forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: Highlight; }
  .day[aria-pressed="true"] .dw, .day[aria-pressed="true"] .ds, .mg-d.sel .k, :root[data-chapel="1"] .day[aria-pressed="true"] .dw, :root[data-chapel="1"] .day[aria-pressed="true"] .ds, :root[data-chapel="1"] .mg-d.sel .k { color: HighlightText; opacity: 1; }
  .tab[aria-selected="true"] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
  /* the phone bar's label clips (ellipsis), which cut the underline away: room below, taken back by the margin */
  .tab .tl { padding-bottom: 4px; margin-bottom: -4px; }
  .hseg { border: 1px solid CanvasText; }
  /* the loop is SVG, which keeps its own colors here (preserve-parent-color): a theme darker or lighter than the
     system Canvas (Advent and Lent on Auto, chapel mode, a named theme) would put its beads on the wrong ground, so
     system colors. The !important beats the Pearl look's done-bead and crucifix rules (0,5,0). */
  .rosary .rb, .rosary .medal { fill: Canvas !important; stroke: CanvasText !important; }
  .rosary .rb.done, .rosary .medal.done, .rosary .cross { fill: CanvasText !important; stroke: CanvasText !important; }
  .rosary .rb.now, .rosary .medal.now, .rosary .cross.now, .rosary .runner { fill: Highlight !important; stroke: Highlight !important; }
  .rosary .rb.pre { stroke: Highlight !important; }
  .rosary .mark { fill: Canvas; stroke: Highlight; }
  .rosary .sheen { fill: none; }
  /* the ring keeps the current bead marked by more than its color */
  .rosary .halo { fill: none; stroke: Highlight; stroke-width: 1.5; }
  .rosary .chain { stroke: GrayText; }
  .rosary .num, .rosary .num.done { fill: CanvasText; }
  .rosary .num.now { fill: Highlight; }
  .hfill { forced-color-adjust: none; }
  .tk-bead.done { background: CanvasText; border-color: CanvasText !important; }
  .tk-bead.done::after { display: none; }
  .tk-bead.now { background: Highlight; border-color: Highlight; box-shadow: none; }
  /* the row's crucifix is SVG too: system colors, as for the loop (the !important beats the Pearl rule) */
  .tk-cross { color: CanvasText !important; }
  .tk-cross.now { color: Highlight !important; }
  /* the halo (box-shadow) is dropped here: a ring keeps the current bead marked by more than its hue */
  .tk-bead.now { outline: 2px solid Highlight; outline-offset: 2px; }
  .seg button:disabled, .btn:disabled, .link:disabled { color: GrayText; }
  /* feast dots, today's dot, the current part of the hour: drawn as backgrounds, so system colors keep them */
  .day.has-feast .dn::after, .mg-d.has-feast::after, .day.is-today .dw::after, .segs li.now h3::before { forced-color-adjust: none; background: CanvasText; }
  .day[aria-pressed="true"].has-feast .dn::after, .day[aria-pressed="true"].is-today .dw::after, .mg-d.sel.has-feast::after { background: HighlightText; }
  .mg-d.is-today { border-width: 3px; }
  .dec.done { text-decoration: underline; }
  .sil-ring { forced-color-adjust: none; }
  /* the sheet is set apart by background and shadow alone, both dropped here */
  .sheet-panel { border: 1px solid CanvasText; }
  /* the right answer and a wrong pick are told apart by color here: a heavy edge and a dashed edge keep them apart */
  .qopt.right { border-width: 3px; }
  .qopt.wrong { border-style: dashed; }
}
/* Printing (the Prayers tab before confession or Benediction, the Journal to keep a copy): each pane scrolls inside a
   one-screen frame, so a printout held one page (the Prayers tab stopped in the Glory Be, the Journal after five
   entries), and a dark theme or chapel mode printed pale text on white paper, since the backgrounds are dropped.
   Paper takes the light colors and every line of the open tab, without the tab bar, the gear, the beads, Back and
   Next, or the journal's buttons. Keep it after the palette and chapel rules: it ties them (0,2,0) and wins by coming
   later. */
@media print {
  :root, :root:not([data-theme="light"]), :root[data-palette], :root[data-chapel="1"] {
    --bg: #fff; --page: #fff; --ink: #1d1b21; --muted: #5e5a65; --line: #d8d5d0;
    --rubric: #a3162d; --rubric-soft: #fff; --gold: #8b691c; --gold-soft: #fff;
    color-scheme: light;
  }
  html, body, .app, main, .pane { height: auto !important; overflow: visible !important; }
  :root { padding: 0 !important; }
  main { padding-bottom: 0 !important; }
  body::before, .gear, .tabs, .sheet, .rosary, .s-after, .pane-about, #j-new, #j-backup, .jentry .link { display: none !important; }
  /* a pressed choice or primary button is page-colored text on an ink fill (chapel: #2a2622); paper drops the fill
     unless background graphics are on, so its label printed pale gray, or dark on dark in chapel mode: on paper it is
     ink text in a heavier ink border. The Hour tab's controls and the strip's Start the hour keep their look. */
  .seg button[aria-pressed="true"]:not(#tab-hour *), .day[aria-pressed="true"], .btn.primary:not(#tab-hour *):not(#p-start), .dec.now { background: none !important; color: var(--ink) !important; border: 2px solid var(--ink) !important; }
  .day[aria-pressed="true"] .dw, .day[aria-pressed="true"] .ds { color: var(--ink) !important; opacity: 1 !important; }
  /* the panes and the journal list print as blocks: as grids, Chrome moved a tab (or the whole list) that fit one
     sheet but not after the header to the next sheet, so page 1 held the header alone (Mysteries on many days, the
     Hour tab on A4, the Journal at some lengths); the margins stand in for the screen gaps */
  .pane-in, .jlist { display: block !important; }
  .pane-in > * + * { margin-top: 22px; }
  .pane.pray .pane-in > * + * { margin-top: 10px; }
  .jlist > * + * { margin-top: 12px; }
  /* the prayer card's scroll frame (50vh from 641px) and its fade cut a long prayer on paper */
  .s-body { max-height: none !important; overflow: visible !important; -webkit-mask-image: none !important; mask-image: none !important; }
}
