.page-rosary { padding: 28px 0 96px; }
.page-rosary .kicker { letter-spacing: 0.12em; font-size: 11px; font-weight: 700; color: var(--brand); text-transform: uppercase; }
.ro-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem 2rem; flex-wrap: wrap; margin-bottom: 18px; }
.ro-head h1 { font-size: clamp(1.9rem, 4.4vw, 2.6rem); font-weight: 650; letter-spacing: -0.035em; line-height: 1.08; margin: 4px 0 0; }
.ro-head .sub { color: var(--text-secondary); font-size: 0.9rem; margin-top: 6px; }
.ro-controls { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.ro-controls .auto { font-size: 11px; color: var(--text-muted); letter-spacing: 0.02em; }
.ro-controls .auto b { color: var(--text-secondary); font-weight: 600; }

.seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius); }
.seg button { border: 0; background: transparent; color: var(--text-muted); font: inherit; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 0.34rem 0.6rem; border-radius: 5px; cursor: pointer; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.seg button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.ro-stage { display: grid; grid-template-columns: minmax(0, 1.42fr) minmax(0, 1fr); gap: 18px; align-items: stretch; }

/* Bead box: SVG loop drawn behind content, sized from the box via ResizeObserver */
.ring-card { --edge: 18px; --pad-x: 54px; --pad-top: 50px; --pad-bot: 34px; --below: 72px;
  position: relative; margin: 0; background: var(--bg-deep); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-height: clamp(470px, calc(100vh - 226px), 660px); }
.ring-card svg.beads { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.chain { fill: none; stroke: var(--border); stroke-width: 1.2; }
.bead { fill: var(--surface-2); stroke: var(--border); stroke-width: 1; }
.bead.done { fill: color-mix(in srgb, var(--brand) 55%, var(--surface-2)); stroke: color-mix(in srgb, var(--brand) 70%, var(--border)); }
.bead.now { fill: var(--brand); stroke: var(--text); stroke-width: 1.5; }
.halo { fill: var(--brand); opacity: 0.28; animation: halo 3.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes halo { 0%, 100% { opacity: 0.45; transform: scale(1); } 50% { opacity: 0.22; transform: scale(1.18); } }
.medal { fill: var(--surface); stroke: var(--brand); stroke-width: 1.4; }
.medal-mark { fill: none; stroke: var(--brand); stroke-width: 1.4; }
.cross { fill: color-mix(in srgb, var(--brand) 55%, var(--surface-2)); stroke: color-mix(in srgb, var(--brand) 70%, var(--border)); stroke-width: 1; }

.loop-in { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: center; padding: var(--pad-top) var(--pad-x) var(--pad-bot); text-align: center; }
.prayer-top { margin-bottom: 14px; }
.prayer-top h2 { font-size: 1.2rem; color: var(--text-secondary); font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
.prayer-top h2 span { color: var(--text-muted); font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; margin-left: 8px; letter-spacing: 0; }
.prayer-text { font-family: var(--font-sans); font-size: 1.6rem; line-height: 1.5; color: var(--text); text-wrap: pretty; letter-spacing: -0.005em; max-width: 34em; margin: 0 auto; }
.prayer-text .resp { display: block; margin-top: 0.6em; color: var(--text-secondary); }

.below { height: var(--below); flex: none; }
.loop-in.long .prayer-text { font-size: 1.3rem; line-height: 1.5; }
.cross.now { fill: var(--brand); stroke: var(--text); stroke-width: 1.5; }
.nav-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 2.6rem; padding: 0.55rem 1rem; border-radius: var(--radius); background: var(--surface-2); color: var(--text); border: 1px solid var(--border); font: inherit; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; cursor: pointer; }
.nav-btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.nav-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
kbd { display: inline-block; min-width: 1.15rem; padding: 0.04rem 0.3rem; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); color: var(--text-secondary); font-family: var(--font-mono); font-size: 10px; font-weight: 700; text-align: center; }

/* Combined mystery + scripture box */
.mys-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.ctl { margin-top: auto; border-top: 1px solid var(--border-subtle); padding-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.ctl-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ctl-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.ctl .pos { display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center; font-size: 11px; color: var(--text-muted); }
.ctl .pos b { color: var(--text-secondary); font-size: 12px; }
.ctl .nav-btn { min-width: 6.4rem; }
.ctl .pos .mseg { display: none; }
.mys-head .mk { font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: 0.14em; color: var(--brand); text-transform: uppercase; }
.mys-head h2 { font-size: clamp(1.7rem, 3vw, 2.1rem); font-weight: 640; letter-spacing: -0.03em; line-height: 1.1; margin-top: 6px; }
.mys-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); }
.mys-meta span + span::before { content: "·"; margin-right: 14px; color: var(--text-muted); }
.mys-meta .fruit { color: var(--text-muted); }
.scripture { margin: 0; border-left: 3px solid var(--brand); background: var(--brand-soft); border-radius: 0 var(--radius) var(--radius) 0; padding: 14px 16px; }
.scripture p { font-family: var(--font-sans); font-size: 1.06rem; line-height: 1.62; color: var(--text); font-style: italic; text-wrap: pretty; }
.scripture cite { display: block; margin-top: 8px; font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }


@media (max-width: 860px) {
  .page-rosary { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .ro-stage { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .ro-controls { align-items: flex-start; }
  .ring-card { min-height: 0; }
  /* phone: bead box first, then the combined mystery + scripture box below it */
  .mys-card { padding: 16px 16px 18px; gap: 14px; }
  .mys-head h2 { font-size: 1.5rem; margin-top: 3px; }
  .mys-meta { margin-top: 6px; }
  /* controls become a fixed bottom bar so Prev/Next stay reachable */
  .ctl { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0; flex-direction: row; gap: 0;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px);
    border-top: 1px solid var(--border); box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18);
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .ctl-row.wording { display: none; }
  .ctl-row.nav { flex: 1; width: min(1080px, 100%); margin: 0 auto; }
  .ctl .pos .seg { order: 2; }
  .ctl .nav-btn { min-width: 0; padding: 0.55rem 0.8rem; }
  .key-hint { display: none; }
  .ctl .pos .mseg { display: inline-flex; }
  /* theme switch: move out of the bottom-bar's way, top-right beside "← Projects" */
  .theme-switch { position: absolute; top: 22px; right: 14px; bottom: auto; }
}
@media (max-width: 520px) {
  .ring-card { --edge: 11px; --pad-x: 28px; --pad-top: 32px; --pad-bot: 26px; --below: 58px; }
  .prayer-top { margin-bottom: 10px; }
  .prayer-top h2 { font-size: 1.02rem; }
  .prayer-text { font-size: 1.16rem; line-height: 1.52; }
  .loop-in.long .prayer-text { font-size: 1.06rem; line-height: 1.5; }
  .seg button { padding: 0.34rem 0.48rem; }
  .ro-head { margin-bottom: 14px; }
}
@media (prefers-reduced-motion: reduce) { .halo { animation: none; } }

/* ---- App additions (beyond mockup A5) ---- */
.ring-card svg.beads { z-index: 1; }
.ring-card .hit { pointer-events: auto; cursor: pointer; }
.ring-card .hit:hover { stroke: var(--brand); stroke-width: 2; }
.medal.now { fill: var(--brand-soft); stroke-width: 2.2; }
.loop-in .loading { color: var(--text-muted); }
.prayer-top .intent { display: block; margin-top: 4px; font-family: var(--font-mono); font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--text-muted); }
.prayer-text p + p { margin-top: 0.55em; }
.prayer-text .lead { color: var(--text-secondary); font-size: 0.82em; font-weight: 600; letter-spacing: 0.01em; }
.prayer-text .vr { color: var(--text-secondary); font-size: 0.92em; }
.prayer-text .vr b { color: var(--brand); font-family: var(--font-mono); font-size: 0.8em; margin-right: 0.4em; }
.announce .a-k { font-family: var(--font-mono); font-size: 12px; font-weight: 700; letter-spacing: 0.14em; color: var(--brand); text-transform: uppercase; }
.announce h2 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); font-weight: 640; letter-spacing: -0.03em; line-height: 1.12; margin: 10px 0 12px; text-wrap: balance; }
.announce .a-f { font-family: var(--font-mono); font-size: 13px; color: var(--text-secondary); }
.announce .a-h { margin: 18px auto 0; max-width: 28em; color: var(--text-muted); font-size: 1rem; line-height: 1.55; }
.done-state h2 { font-size: clamp(1.6rem, 3.2vw, 2.2rem); font-weight: 640; letter-spacing: -0.03em; line-height: 1.15; }
.done-state p { margin: 12px auto 22px; max-width: 26em; color: var(--text-secondary); font-size: 1.05rem; line-height: 1.55; }
.nav-btn:disabled { opacity: 0.45; cursor: default; }
.mys-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; counter-reset: m; }
.mys-list li { counter-increment: m; display: flex; gap: 10px; align-items: baseline; padding: 7px 10px; border-radius: 6px; color: var(--text-secondary); font-size: 0.98rem; line-height: 1.35; }
.mys-list li::before { content: counter(m); font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--text-muted); min-width: 1ch; }
.mys-list li.cur { background: var(--brand-soft); color: var(--text); }
.mys-list li.past { color: var(--text-muted); }
.mys-list li.past::before { content: "✓"; color: var(--brand); }
.mys-note { margin-top: 12px; font-size: 0.9rem; line-height: 1.55; color: var(--text-muted); }
.ro-foot { padding: 26px 0 40px; color: var(--text-muted); font-size: 12px; text-align: center; line-height: 1.6; }
.ro-foot .ro-links { font-size: 13px; margin-bottom: 6px; }
.ro-foot a { color: var(--text-secondary); text-decoration: underline; text-underline-offset: 3px; }
.ro-foot a:hover { color: var(--brand); }
.ro-foot span { margin: 0 8px; }
.guide { width: min(620px, calc(100vw - 28px)); max-height: calc(100dvh - 40px); overflow: auto; padding: 22px 26px 26px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: calc(var(--radius) * 1.5); box-shadow: var(--shadow); }
.guide::backdrop { background: rgba(0, 0, 0, 0.5); }
.guide h2 { font-size: 1.5rem; font-weight: 650; letter-spacing: -0.02em; margin-bottom: 10px; }
.guide p, .guide li { font-size: 1rem; line-height: 1.6; color: var(--text-secondary); }
.guide p { margin-top: 10px; }
.guide ol { margin: 12px 0 0 1.2em; display: flex; flex-direction: column; gap: 8px; }
.guide b { color: var(--text); }
.guide-close-row { display: flex; justify-content: flex-end; }
.guide-close { border: 1px solid var(--border); background: var(--surface-2); color: var(--text-secondary); font: inherit; font-size: 12px; font-weight: 700; padding: 0.35rem 0.7rem; border-radius: var(--radius); cursor: pointer; }
@media (min-width: 521px) { .loop-in.xlong .prayer-text { font-size: 1.22rem; } }
@media (max-width: 520px) {
  .loop-in.xlong .prayer-text { font-size: 1.02rem; line-height: 1.48; }
  .announce h2 { font-size: 1.6rem; }
  .announce .a-h { font-size: 0.95rem; }
  .guide { padding: 18px 18px 22px; }
}
.mys-list li, .mys-note, .done-state p, .announce .a-h, .guide p, .guide li, .loop-in .loading, .ro-foot p { font-family: var(--font-sans); }
.announce .a-s { display: none; margin: 16px auto 0; max-width: 30em; text-align: left; }
.announce .a-s p { font-size: 1rem; }
@media (max-width: 860px) { .announce .a-s { display: block; } .announce .a-h { display: none; } }
.guide { margin: auto; position: fixed; inset: 0; }

/* ---- Voice mode (step 1: controls + playback) ---- */
.vswitch { display: inline-flex; align-items: center; gap: 8px; min-height: 2rem; padding: 0.2rem 0.1rem; border: 0; background: transparent; color: var(--text-muted); font: inherit; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; border-radius: 6px; }
.vswitch:hover { color: var(--text); }
.vswitch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.vswitch .track { position: relative; flex: none; width: 32px; height: 18px; border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--border); transition: background-color 0.15s, border-color 0.15s; }
.vswitch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-muted); transition: transform 0.15s, background-color 0.15s; }
.vswitch[aria-pressed="true"] { color: var(--text); }
.vswitch[aria-pressed="true"] .track { background: var(--brand); border-color: var(--brand); }
.vswitch[aria-pressed="true"] .track::after { transform: translateX(14px); background: var(--brand-ink); }
.vswitch .vs-state::before { content: "Off"; }
.vswitch[aria-pressed="true"] .vs-state::before { content: "On"; }
.vswitch .vs-state { min-width: 2.2em; text-align: left; }
.mvoice { display: none; }
.voice-panel[hidden] { display: none; }
.voice-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.vauto .short { display: none; }
.vplay { min-height: 2.25rem; min-width: 6.4rem; padding: 0.4rem 0.9rem; background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 60%, var(--border)); }
.vspeed[hidden] { display: none !important; }
.vspeed { min-height: 2rem; min-width: 3.4rem; padding: 0.3rem 0.55rem; border: 1px solid var(--border); border-radius: var(--radius); background: transparent; color: var(--text-secondary); font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.02em; cursor: pointer; font-variant-numeric: tabular-nums; }
.vspeed:hover { border-color: var(--brand); color: var(--text); }
.vspeed:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.vplay:hover { border-color: var(--brand); }
.vplay:disabled { opacity: 0.45; cursor: default; }
.vicon { display: inline-flex; align-items: center; gap: 2px; width: 10px; height: 11px; color: var(--brand); }
.vicon i { display: none; }
.vicon i:first-child { display: block; width: 0; height: 0; border-left: 9px solid currentColor; border-top: 5.5px solid transparent; border-bottom: 5.5px solid transparent; }
.vplay.is-playing .vicon i { display: block; width: 3px; height: 11px; border: 0; background: currentColor; border-radius: 1px; }
.vplay.is-playing .vicon i:nth-child(3) { display: none; }
.voice-note { font-family: var(--font-sans); font-size: 0.86rem; line-height: 1.45; color: var(--text-muted); }
.voice-note:not(:empty) { margin-top: 10px; }
/* "playing" indicator on the current step: small equalizer before the step heading, and a quicker halo */
.loop-in .speaking { display: none; height: 0.72em; align-items: flex-end; gap: 2px; margin-right: 0.5em; vertical-align: baseline; }
.ring-card.is-speaking .loop-in .speaking { display: inline-flex; }
.loop-in .speaking i { display: block; width: 3px; height: 100%; border-radius: 1px; background: var(--brand); transform-origin: bottom; animation: vbar 0.9s ease-in-out infinite; }
.loop-in .speaking i:nth-child(2) { animation-delay: -0.3s; }
.loop-in .speaking i:nth-child(3) { animation-delay: -0.6s; }
@keyframes vbar { 0%, 100% { transform: scaleY(0.35); } 50% { transform: scaleY(1); } }
.ring-card.is-speaking .halo { animation-duration: 1.5s; }
@media (prefers-reduced-motion: reduce) { .loop-in .speaking i { animation: none; transform: scaleY(0.7); } }
@media (max-width: 860px) {
  .ctl-row.voice-row { display: none; }
  .vspeed.d { display: none; }
  .vspeed.m { min-width: 2.9rem; padding: 0.3rem 0.4rem; min-height: 2.4rem; }
  .mvoice { display: inline-flex; }
  .ctl { flex-wrap: wrap; }
  .voice-panel { flex: 0 0 100%; width: min(1080px, 100%); margin: 0 auto 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border-subtle); }
  .voice-controls { flex-wrap: nowrap; gap: 8px; }
  .vplay { min-width: 0; min-height: 2.4rem; padding: 0.4rem 0.8rem; }
  .voice-panel .seg button { min-height: 2.2rem; }
  .vswitch { min-height: 2.4rem; }
  .voice-note:not(:empty) { margin-top: 8px; font-size: 0.8rem; }
  .page-rosary.voice-on { padding-bottom: calc(160px + env(safe-area-inset-bottom)); }
}
@media (max-width: 520px) {
  .vauto .long { display: none; }
  .vauto .short { display: inline; }
}

/* ---- Voice: offline saving note (step 2) ---- */
/* offline-saving note: lives in the page footer (quiet, muted) on every screen size */
.ro-foot .voice-offline { font-family: var(--font-sans); font-size: 12px; line-height: 1.5; color: var(--text-muted); margin: 0 auto 6px; max-width: 100%; overflow-wrap: anywhere; }
.voice-offline[hidden] { display: none; }
.ro-foot .voice-offline span { margin: 0; }
.ro-foot .voice-offline .count { font-family: var(--font-mono); font-size: 0.92em; color: var(--text-secondary); white-space: nowrap; }
.ro-foot .voice-offline .sep { margin: 0 0.45em; }
.linkish { border: 0; padding: 0; background: none; font: inherit; color: var(--text-secondary); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; cursor: pointer; }
.linkish:hover { color: var(--brand); }
.linkish:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 2px; }

/* ---- Desktop density: keeps the bead box at its minimum height with the Voice row (all sets, incl. Glorious's long titles) ---- */
@media (min-width: 861px) {
  .mys-card { gap: 16px; }
  .mys-list li { padding: 5px 10px; }
  .mys-note { margin-top: 8px; }
  .ctl { gap: 8px; padding-top: 12px; }
  .ctl-row.nav { margin-top: 4px; }
  .ctl .vswitch { min-height: 1.75rem; }
  .vplay { min-height: 2.1rem; }
  .voice-row .vspeed { margin-left: auto; margin-right: 12px; min-height: 1.75rem; }
  .vspeed.m { display: none; }
  .voice-note:not(:empty) { margin-top: 6px; }
}

/* ---- Feedback page (rosary-feedback.html) ---- */
.fb-wrap { width: min(700px, calc(100% - 28px)); }
.fb-head { margin-bottom: 18px; }
.fb-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(20px, 4vw, 34px) clamp(18px, 4.5vw, 40px); }
.fb-note p { font-family: var(--font-sans); font-size: 1.1rem; line-height: 1.68; color: var(--text); text-wrap: pretty; }
.fb-note p + p { margin-top: 1em; }
.fb-note a, .fb-form a { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.fb-note a:hover, .fb-form a:hover { color: var(--text); }
.fb-note a:focus-visible, .fb-form a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 2px; }
.fb-note .fb-sign { color: var(--text-secondary); }
.fb-form { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--border-subtle); }
.fb-form p { font-family: var(--font-sans); font-size: 1.1rem; line-height: 1.5; }
.fb-form a { font-weight: 600; }
.fb-form .fb-muted { margin-top: 6px; font-size: 0.88rem; color: var(--text-muted); }
@media (max-width: 860px) { .page-rosary-feedback { padding-bottom: 72px; } }
@media (max-width: 520px) { .fb-note p, .fb-form p { font-size: 1.04rem; } .fb-form .fb-muted { font-size: 0.86rem; } }
