:root {
  --veil: #EDF0F6;
  --paper: #FBFCFE;
  --ink: #1D2B4F;
  --soft: #4A5778;
  --lapis: #2B4A9B;
  --rose: #9A4155;
  --line: #CDD4E4;
  --bead: #6A80C0;
  --bead-deep: #2B3F78;
  --bead-done: #BAC4E0;
  --string: #A3AECB;
  --current: #D8B25A;
  --current-ring: rgba(184, 144, 58, .4);
  --btn-bg: #1D2B4F;
  --btn-fg: #FFFFFF;
  --serif: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --veil: #101830;
    --paper: #182244;
    --ink: #E9ECF5;
    --soft: #A9B3CF;
    --lapis: #93AAEB;
    --rose: #E8A0B0;
    --line: #2C3963;
    --bead: #6F86CC;
    --bead-deep: #9DB1EE;
    --bead-done: #2F3C69;
    --string: #3B4876;
    --current: #E8C46A;
    --current-ring: rgba(232, 196, 106, .35);
    --btn-bg: #E8C46A;
    --btn-fg: #14203D;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--veil);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
}
:focus-visible { outline: 3px solid var(--lapis); outline-offset: 3px; }

.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 1rem; top: 1rem; background: var(--paper); padding: .5rem 1rem; border-radius: 8px; z-index: 10; }

/* Header and footer */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem clamp(1.25rem, 5vw, 4rem);
}
.brand { font-family: var(--serif); font-weight: 600; font-size: 1.7rem; color: var(--ink); text-decoration: none; }
.site-header nav a { color: var(--soft); text-underline-offset: 6px; }
.site-header nav a:hover, .site-header nav a[aria-current] { color: var(--ink); }
.site-footer { padding: 2.5rem 1rem; text-align: center; color: var(--soft); font-size: .9rem; }

/* Buttons */
.btn {
  display: inline-block; cursor: pointer; text-align: center; text-decoration: none;
  font: 600 1rem/1 var(--sans);
  padding: .95rem 1.6rem; border-radius: 999px;
  border: 2px solid var(--btn-bg); background: var(--btn-bg); color: var(--btn-fg);
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn:disabled { opacity: .4; cursor: default; }

/* Home */
.hero {
  display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: 3rem;
  max-width: 72rem; margin: 0 auto; padding: 1rem clamp(1.25rem, 5vw, 4rem) 3rem;
  min-height: 70vh;
}
.hero h1 {
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(2.7rem, 6.5vw, 4.8rem); line-height: 1.04; letter-spacing: -.01em;
  margin: 0 0 1.25rem; max-width: 11em;
}
.lead { font-size: 1.2rem; color: var(--soft); max-width: 31em; margin: 0 0 2rem; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.hero-beads { display: flex; justify-content: center; }
.hero-beads svg { height: min(66vh, 560px); width: auto; max-width: 100%; }

.today { max-width: 44rem; margin: 0 auto; padding: 3rem 1.25rem 4rem; }
.today h2 { font-family: var(--serif); font-weight: 600; font-size: 2.3rem; line-height: 1.1; margin: 0 0 .25rem; }
.today-sub { margin: 0 0 1.5rem; color: var(--soft); }
.mystery-list { margin: 0 0 2rem; padding-left: 1.75rem; }
.mystery-list li { padding: .8rem 0 .8rem .5rem; border-top: 1px solid var(--line); }
.mystery-list li:last-child { border-bottom: 1px solid var(--line); }
.mystery-list li::marker { font-family: var(--serif); font-weight: 600; color: var(--rose); }
.mystery-list strong { display: block; font-family: var(--serif); font-size: 1.4rem; font-weight: 600; line-height: 1.2; }
.mystery-list span { color: var(--soft); font-size: .95rem; }

/* Guided rosary */
.pray {
  display: grid; grid-template-columns: minmax(260px, 380px) minmax(0, 1fr);
  gap: clamp(1.5rem, 5vw, 4.5rem); align-items: start;
  max-width: 68rem; margin: 0 auto; padding: 1rem clamp(1.25rem, 5vw, 3rem) 3rem;
}
.beads-pane { position: sticky; top: 1rem; }
.beads { height: min(78vh, 640px); display: flex; justify-content: center; }
.beads svg { height: 100%; width: auto; max-width: 100%; }

.set-picker { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.chip {
  cursor: pointer; font: 500 .95rem var(--sans); color: var(--ink);
  background: transparent; border: 1.5px solid var(--line); border-radius: 999px; padding: .5rem 1rem;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--veil); border-color: var(--ink); }
.chip small { margin-left: .4rem; font-size: .8em; opacity: .75; }
.lang-picker { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }

.alt { margin: 0 0 .75rem; color: var(--soft); }
.translation { margin-top: 1.5rem; max-width: 34em; padding-top: 1rem; border-top: 1px solid var(--line); }
.translation summary { cursor: pointer; font-weight: 600; color: var(--lapis); }
.translation-text { margin: .75rem 0 0; font-family: var(--serif); font-size: 1.2rem; line-height: 1.55; color: var(--soft); }

.progress { margin-bottom: 1rem; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
#bar-fill { display: block; height: 100%; width: 0; background: var(--current); transition: width .25s; }
#step-count { margin: .5rem 0 0; font-size: .9rem; color: var(--soft); }

.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 18px;
  padding: clamp(1.5rem, 4vw, 2.5rem); min-height: 21rem;
}
.section { margin: 0 0 .5rem; font-size: .95rem; color: var(--soft); }
.ordinal { margin: 0 0 .25rem; font-weight: 600; color: var(--rose); }
.prayer-title {
  font-family: var(--serif); font-weight: 600; line-height: 1.08;
  font-size: clamp(2rem, 5vw, 2.9rem); margin: 0 0 .75rem;
}
.count { display: inline-block; margin: 0 0 .75rem; font-weight: 600; color: var(--lapis); }
.context { margin: 0 0 1.25rem; color: var(--soft); }
.scripture { margin: 0 0 1.25rem; font-family: var(--serif); font-size: 1.5rem; font-weight: 500; }
.prayer-text {
  margin: 0; max-width: 34em;
  font-family: var(--serif); font-weight: 500; line-height: 1.55;
  font-size: clamp(1.35rem, 3.2vw, 1.8rem);
}
.note { color: var(--soft); margin: 1rem 0 0; max-width: 34em; }
.card .btn { margin-top: 1.5rem; }

.controls {
  display: flex; gap: .75rem; margin-top: 1rem;
  position: sticky; bottom: 0; padding: .9rem 0 .5rem; background: var(--veil);
}
.controls .ghost { flex: 0 0 30%; }
.controls #next { flex: 1; }

/* Rosary drawing */
.rosary .string { fill: none; stroke: var(--string); stroke-width: 2.5; }
.bead { fill: var(--bead); stroke: transparent; stroke-width: 0; transition: fill .2s; }
.bead.large, .bead.mid { fill: var(--bead-deep); }
.bead.done { fill: var(--bead-done); }
.bead.current { fill: var(--current); stroke: var(--current-ring); stroke-width: 7; }
.medal { fill: var(--bead-deep); }
.medal-mark { fill: none; stroke: var(--veil); stroke-width: 2; }
.cross rect { fill: var(--bead-deep); }
.medal.done, .cross.done rect { fill: var(--bead-done); }
.medal.current, .cross.current rect { fill: var(--current); }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; min-height: 0; gap: 2rem; }
  .hero-beads svg { height: 340px; }
  .pray { grid-template-columns: 1fr; gap: 1rem; }
  .beads-pane { position: static; }
  .beads { height: min(32vh, 280px); }
  .card { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Header: back arrow, nav, wrapping on small screens */
.site-header { flex-wrap: wrap; gap: .5rem 1rem; }
.header-left { display: flex; align-items: center; gap: .75rem; }
.site-header nav { display: flex; gap: 1.25rem; }
.back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid var(--line); color: var(--ink);
}
.back:hover { background: var(--paper); }
.back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Home: learn more */
.learn { max-width: 44rem; margin: 0 auto; padding: 0 1.25rem 4rem; }
.learn h2 { font-family: var(--serif); font-weight: 600; font-size: 2.3rem; line-height: 1.1; margin: 0 0 1rem; }
.learn-list { list-style: none; margin: 0; padding: 0; }
.learn-list li { border-top: 1px solid var(--line); }
.learn-list li:last-child { border-bottom: 1px solid var(--line); }
.learn-list a { display: block; padding: 1rem 0; color: inherit; text-decoration: none; }
.learn-list strong { display: block; font-family: var(--serif); font-size: 1.4rem; font-weight: 600; line-height: 1.2; }
.learn-list span { color: var(--soft); font-size: .95rem; }
.learn-list a:hover strong { text-decoration: underline; text-underline-offset: 4px; }

/* Content pages */
.page { max-width: 42rem; margin: 0 auto; padding: 1rem 1.25rem 4rem; }
.page h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(2.4rem, 6vw, 3.6rem); line-height: 1.05; margin: 0 0 1rem; }
.page h2 { font-family: var(--serif); font-weight: 600; font-size: 1.9rem; line-height: 1.15; margin: 2.5rem 0 .5rem; }
.page p, .page ul { max-width: 38em; }
.page ul { padding-left: 1.25rem; }
.page li { margin: .6rem 0; }
.page a:not(.btn) { color: var(--lapis); }
.page-cta { margin-top: 2.5rem; }
.callout { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: .25rem 1.5rem; max-width: 38em; }

.timeline { list-style: none; margin: 2rem 0 0; padding: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; margin: 0; padding: 0 0 1.75rem 1.5rem; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: .6rem; width: 12px; height: 12px; border-radius: 50%; background: var(--current); }
.timeline .when { display: block; font-family: var(--serif); font-weight: 600; font-size: 1.4rem; line-height: 1.2; color: var(--rose); }
.timeline p { margin: .2rem 0 0; }

@media (max-width: 480px) {
  .brand { font-size: 1.45rem; }
  .site-header nav { gap: 1rem; font-size: .95rem; }
}