/* Holy Rosary, web edition. Warm paper in light mode, night blue in dark mode. */
:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-2: #efe8da;
  --ink: #2a241d;
  --muted: #6e6457;
  --line: #ddd3c2;
  --accent: #27457a;
  --accent-ink: #ffffff;
  --accent-soft: #dfe6f2;
  --gold: #a87a25;
  --gold-soft: #f1e2c0;
  --bead: #8e8170;
  --shadow: 0 1px 2px rgb(60 40 10 / 0.06), 0 4px 16px rgb(60 40 10 / 0.06);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif",
    "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  --fs: 17px;
  color-scheme: light;
}
:root[data-size="s"] { --fs: 15px; }
:root[data-size="l"] { --fs: 20px; }
:root[data-size="xl"] { --fs: 23px; }

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #16171c; --surface: #1f2128; --surface-2: #282a33; --ink: #ebe5d8; --muted: #a39c8f;
    --line: #353845; --accent: #9db7e8; --accent-ink: #101522; --accent-soft: #263049;
    --gold: #d9b56a; --gold-soft: #3a3222; --bead: #7d7768;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 18px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16171c; --surface: #1f2128; --surface-2: #282a33; --ink: #ebe5d8; --muted: #a39c8f;
  --line: #353845; --accent: #9db7e8; --accent-ink: #101522; --accent-soft: #263049;
  --gold: #d9b56a; --gold-soft: #3a3222; --bead: #7d7768;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 18px rgb(0 0 0 / 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; }
h1:focus { outline: none; }
svg { display: block; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.noscript { padding: 2rem; font-family: var(--serif); }

.page { max-width: 720px; margin: 0 auto; padding: 0 1rem 3rem; }

/* buttons */
.btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem;
  min-height: 2.75rem; padding: 0.55rem 1.2rem; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer; font-weight: 600;
  transition: background 0.15s, transform 0.08s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.big { min-height: 3.3rem; padding: 0.7rem 1.8rem; font-size: 1.1rem; }
.btn.wide { display: flex; width: 100%; margin: 1rem 0; }
.btn small { font-weight: 400; opacity: 0.85; font-size: 0.8rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 50%;
  border: 0; background: transparent; color: var(--ink); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg, .tile svg, .list svg, .link-row svg { width: 1.4rem; height: 1.4rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* top bar of sub-pages */
.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 0.25rem;
  margin: 0 -1rem 0.5rem; padding: 0.4rem 0.5rem; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.bar h1 { flex: 1; font-size: 1.2rem; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-end { width: 2.75rem; flex: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* home */
.home-head { text-align: center; padding: 2.2rem 0 1.2rem; }
.home-head .date { margin: 0 0 0.3rem; color: var(--muted); letter-spacing: 0.02em; }
.home-head h1 { font-size: 2.3rem; color: var(--ink); }
.today-card { overflow: hidden; }
.thumbs { display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: 7.5rem; overflow: hidden; }
.thumbs img { width: 100%; height: 7.5rem; object-fit: cover; display: block; min-width: 0; }
.card-body { padding: 1.2rem 1.3rem 1.4rem; }
.label { margin: 0 0 0.25rem; color: var(--gold); font-size: 0.85rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.today-card h2 { font-size: 1.7rem; margin-bottom: 0.8rem; }
.mysteries { margin: 0 0 1.3rem; padding: 0; list-style: none; counter-reset: m; }
.mysteries li { counter-increment: m; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.6rem; padding: 0.4rem 0; border-top: 1px solid var(--line); }
.mysteries li::before { content: counter(m); width: 1.4rem; color: var(--gold); font-family: var(--serif); font-weight: 700; }
.mysteries .mt { font-family: var(--serif); font-size: 1.08rem; }
.mysteries .fr { margin-left: auto; color: var(--muted); font-size: 0.85rem; font-style: italic; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.actions .primary { flex: 1 1 12rem; }
.stats { text-align: center; padding: 1.4rem 0 0.4rem; }
.stats p { margin: 0 0 0.2rem; }
.week { display: flex; justify-content: center; gap: 0.7rem; padding: 0; margin: 0.8rem 0 0; list-style: none; font-size: 0.75rem; color: var(--muted); }
.week li { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.week .dot { width: 0.8rem; height: 0.8rem; border-radius: 50%; border: 1.5px solid var(--bead); }
.week .on .dot { background: var(--gold); border-color: var(--gold); }
.week .today { color: var(--ink); font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; margin-top: 1.4rem; }
.tile {
  display: flex; align-items: center; gap: 0.7rem; padding: 1rem; min-height: 4rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; box-shadow: var(--shadow);
}
.tile svg { color: var(--accent); flex: none; }
.tile:hover { border-color: var(--accent); }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(4, 1fr); } .tile { flex-direction: column; text-align: center; justify-content: center; } }

/* choose */
.sets { display: grid; gap: 0.8rem; }
@media (min-width: 640px) { .sets { grid-template-columns: 1fr 1fr; } }
.set-card { display: flex; gap: 0; padding: 0; overflow: hidden; text-align: left; cursor: pointer; }
.set-card img { width: 6.5rem; object-fit: cover; flex: none; }
.set-card:hover { border-color: var(--accent); }
.set-text { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.9rem 1rem; }
.set-name { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; }
.set-list { color: var(--muted); font-size: 0.85rem; }
.set-text b { color: var(--accent); }

/* lists and settings */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.list a { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.85rem 0.3rem; color: var(--ink); text-decoration: none; font-family: var(--serif); font-size: 1.1rem; }
.list a:hover { color: var(--accent); }
.list svg { color: var(--muted); flex: none; }
.group-h { font-family: var(--sans); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 1.6rem 0.4rem 0.5rem; font-weight: 700; }
.group { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.group.pad { padding: 0.4rem 1rem 1rem; }
.group li + li { border-top: 1px solid var(--line); }
.switch-row, .link-row {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.8rem 1rem;
  background: none; border: 0; text-align: left; cursor: pointer; color: var(--ink); text-decoration: none; min-height: 3.2rem;
}
.link-row.card { margin: 0.5rem 0; }
.sw-text { display: flex; flex-direction: column; }
.sw-text small { color: var(--muted); font-size: 0.82rem; font-family: var(--sans); }
.switch { flex: none; width: 3rem; height: 1.75rem; border-radius: 1rem; background: var(--surface-2); border: 1.5px solid var(--line); position: relative; transition: background 0.15s; }
.switch span { position: absolute; top: 0.15rem; left: 0.15rem; width: 1.25rem; height: 1.25rem; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }
[aria-checked="true"] .switch { background: var(--accent); border-color: var(--accent); }
[aria-checked="true"] .switch span { transform: translateX(1.25rem); background: var(--accent-ink); }
.seg-label { margin: 0.8rem 0 0.4rem; font-weight: 600; }
.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 0.2rem; gap: 0.2rem; }
.seg button { flex: 1; border: 0; background: none; padding: 0.5rem 0.4rem; border-radius: 999px; cursor: pointer; font-size: 0.9rem; }
.seg [aria-checked="true"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 700; color: var(--accent); }
.note-box { background: var(--gold-soft); border-radius: var(--radius); padding: 0.9rem 1rem; margin: 0.6rem 0 1rem; }
.save-failed { text-align: center; color: #b3261e; font-size: 0.85rem; }

/* reading pages (prayers, about, the book) */
.prose { font-family: var(--serif); font-size: 1.15rem; line-height: 1.7; padding: 0.5rem 0.2rem; }
.prose .pre { white-space: pre-line; }
.prayer-text { white-space: pre-line; font-size: 1.25rem; margin: 0.2rem 0 1.6rem; }
.lang-h { font-family: var(--sans); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 1rem; }
.howto { padding-left: 1.4rem; } .howto li { margin-bottom: 0.7rem; padding-left: 0.3rem; } .howto li::marker { color: var(--gold); font-weight: 700; }
.promise { padding-left: 0.2rem; }
.intro { font-style: italic; color: var(--muted); }
.about { font-size: 1rem; }
details.part { border-bottom: 1px solid var(--line); }
details.part summary { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.9rem 0.3rem; cursor: pointer; font-family: var(--serif); font-size: 1.2rem; font-weight: 600; list-style: none; }
details.part summary::-webkit-details-marker { display: none; }
details.part summary small { font-family: var(--sans); font-size: 0.8rem; color: var(--muted); font-weight: 400; }
details.part .list { padding: 0 0 0.6rem 1rem; }
details.part .list a { font-size: 1.02rem; padding: 0.6rem 0.3rem; }
.book .b-part { font-size: 1.7rem; text-align: center; margin: 1.5rem 0 0.4rem; }
.book .b-sect { font-size: 1.35rem; margin: 1.6rem 0 0.3rem; color: var(--accent); }
.book .b-sub { font-style: italic; color: var(--muted); margin-top: 0; }
.book blockquote { margin: 0.6rem 0 1rem; padding: 0.3rem 0 0.3rem 1rem; border-left: 3px solid var(--gold); font-style: italic; }
.pgroup { position: relative; scroll-margin-top: 4rem; }
.pnum { display: flex; align-items: center; gap: 0.3rem; margin-top: 1.1rem; color: var(--muted); font-family: var(--sans); font-size: 0.78rem; }
.ribbon { border: 0; background: none; padding: 0.3rem; cursor: pointer; color: var(--bead); display: grid; place-items: center; min-width: 2rem; min-height: 2rem; }
.ribbon svg { width: 0.75rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.8; }
.marked .ribbon { color: #b3261e; } .marked .ribbon svg { fill: currentColor; }
.marked { background: linear-gradient(90deg, var(--gold-soft), transparent 70%); border-radius: 8px; margin-left: -0.6rem; padding-left: 0.6rem; }
.book p { margin: 0.3rem 0 0.9rem; }
.sect-nav { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; margin-top: 2rem; flex-wrap: wrap; }
.marks li a { font-family: var(--sans); font-size: 1rem; }
.marks small { display: block; margin-top: 0.2rem; font-family: var(--serif); }

/* done */
.done { text-align: center; padding-top: 12vh; display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.done-cross { width: 3.5rem; fill: var(--gold); margin-bottom: 0.8rem; }
.done h1 { font-size: 2rem; }
.thanks { font-family: var(--serif); font-size: 1.3rem; font-style: italic; margin: 0; }
.done .btn { margin-top: 1.4rem; min-width: 12rem; }

/* ------------------------------------------------------------ praying */
body[data-view="pray"] { overscroll-behavior: none; }
.pray { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: 1fr; grid-template-areas: "top" "main" "foot"; }
.pray-top {
  grid-area: top; position: sticky; top: 0; z-index: 5; display: flex; align-items: center; padding: 0.3rem 0.5rem;
  background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.pt-mid { flex: 1; display: flex; justify-content: center; gap: 0.8rem; font-size: 0.9rem; color: var(--muted); }
.pt-set { font-weight: 700; color: var(--ink); }
.pt-count { font-variant-numeric: tabular-nums; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line); }
.progress span { display: block; height: 100%; background: var(--gold); transition: width 0.25s; }
.pray-side { display: none; grid-area: side; }
.pray-main { grid-area: main; outline: none; touch-action: pan-y; }
.pray-body { max-width: 680px; margin: 0 auto; padding: 1rem 1.2rem 2rem; cursor: default; }
.cap { margin: 0; color: var(--gold); font-size: 0.85rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.sect { font-size: 1.7rem; margin: 0.2rem 0 0.6rem; }
.strip-wrap { margin: 0.3rem 0 0.8rem; }
.strip { height: 2.2rem; max-width: 100%; }
.pname { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-size: 1.25rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.pcount { font-family: var(--sans); font-size: 1rem; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.blocks .b { font-family: var(--serif); margin: 0 0 1rem; white-space: pre-line; }
.b.words { font-size: 1.45rem; line-height: 1.65; }
.b.verse { font-style: italic; font-size: 1.2rem; line-height: 1.6; margin-bottom: 0.2rem; }
.b.ref { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); margin-top: 0; }
.b.med { font-size: 1.2rem; line-height: 1.6; }
.b.fruit { font-weight: 700; color: var(--accent); }
.b.note { font-style: italic; color: var(--muted); }
.b.mcap { font-family: var(--sans); font-size: 0.78rem; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.2rem; }
.b.mtext { font-size: 1.15rem; line-height: 1.6; padding-left: 0.8rem; border-left: 3px solid var(--gold-soft); }
mark { background: var(--gold-soft); color: inherit; border-radius: 3px; padding: 0; box-shadow: 0 0 0 0.12em var(--gold-soft); }
.art { margin: 0 0 1.2rem; }
.art-btn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.art img { display: block; width: 100%; max-height: 62vh; object-fit: contain; border-radius: 8px; background: var(--surface-2); }
.art figcaption { margin-top: 0.4rem; font-size: 0.82rem; color: var(--muted); text-align: center; }
.art figcaption span { font-style: italic; }
.pray-foot {
  grid-area: foot; position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.8rem calc(0.6rem + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}
.pray-foot .btn { min-width: 6.5rem; }
.pray-foot .primary { min-height: 3.2rem; font-size: 1.05rem; }
.hint { flex: 1; text-align: center; font-size: 0.78rem; color: var(--muted); }
@media (max-width: 420px) { .hint { display: none; } .pray-foot .primary { flex: 1; } }

/* the whole rosary */
.rosary { width: 100%; max-width: 320px; margin: 0 auto; overflow: visible; }
.rosary .chain, .strip .chain { fill: none; stroke: var(--bead); stroke-width: 1.2; opacity: 0.6; }
.bead .shape { fill: var(--bg); stroke: var(--bead); stroke-width: 1.6; transition: fill 0.2s; }
.bead .hit { fill: transparent; stroke: none; }
.rosary .bead { cursor: pointer; }
.rosary .bead:hover .shape { stroke: var(--accent); }
.bead.done .shape { fill: var(--accent); stroke: var(--accent); }
.bead.current .shape { fill: var(--gold); stroke: var(--gold); }
.bead.current { filter: drop-shadow(0 0 4px var(--gold)); }
.side-list { list-style: none; padding: 0; margin: 1rem 0 0; counter-reset: m; }
.side-list li { counter-increment: m; }
.side-list button { width: 100%; display: flex; gap: 0.6rem; padding: 0.45rem 0.6rem; border: 0; background: none; text-align: left; border-radius: 8px; cursor: pointer; font-family: var(--serif); color: var(--muted); }
.side-list button::before { content: counter(m); color: var(--gold); font-weight: 700; }
.side-list button:hover { background: var(--surface-2); }
.side-list .on button { color: var(--ink); background: var(--accent-soft); font-weight: 600; }

@media (min-width: 900px) {
  .pray.with-side { grid-template-columns: minmax(280px, 360px) 1fr; grid-template-areas: "top top" "side main" "side foot"; }
  .pray.with-side .pray-side { display: block; position: sticky; top: 3.5rem; align-self: start; padding: 1.5rem 1.5rem; height: calc(100dvh - 3.5rem); overflow: auto; border-right: 1px solid var(--line); }
  .pray.with-side .strip-wrap { display: none; }
  .pray-body { padding-top: 2rem; }
  .sect { font-size: 2rem; }
}
@media (min-width: 1200px) {
  .pray-body { max-width: 760px; }
}

dialog.lightbox { border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 96vh; }
dialog.lightbox::backdrop { background: rgb(0 0 0 / 0.88); }
.lightbox figure { margin: 0; }
.lightbox img { display: block; max-width: 96vw; max-height: 86vh; object-fit: contain; }
.lightbox figcaption { color: #eee; text-align: center; padding: 0.5rem; font-size: 0.9rem; }
.lightbox .btn { display: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  display: flex; gap: 0.8rem; align-items: center; background: var(--ink); color: var(--bg); padding: 0.7rem 1.1rem; border-radius: 999px; box-shadow: var(--shadow); font-size: 0.9rem;
}
.toast button { background: none; border: 0; color: var(--gold); font-weight: 700; cursor: pointer; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .bar, .pray-top, .pray-foot, .pray-side, .sect-nav { display: none; } }
