:root {
  --bg: #0b0b10;
  --surface: #16161f;
  --surface-2: #1f1f2b;
  --text: #f0ead8;
  --muted: #9a9484;
  --gold: #d9a441;
  --gold-bright: #f0c060;
  --border: #2b2b3a;
  --blue: #2f7bff;
  --ok: #57c785;
  --danger: #e05c5c;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Georgia, 'Times New Roman', serif;
  min-height: 100dvh;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.view { display: none; flex: 1; flex-direction: column; padding: 18px 16px 96px; }
.view.active { display: flex; }
.center-view { align-items: center; justify-content: center; text-align: center; padding-bottom: 18px; }

.brand-mark { font-size: 34px; color: var(--gold); }
.brand-mark.big { font-size: 64px; }
.brand-mark.gold { color: var(--gold-bright); }
.brand-mark.small { font-size: 20px; }
.brand-title { margin: 8px 0 4px; font-size: 30px; font-weight: normal; letter-spacing: .5px; }
.brand-sub { line-height: 1.5; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error-text { color: var(--danger); min-height: 18px; font-size: 14px; }
.eyebrow { color: var(--gold); text-transform: uppercase; letter-spacing: 2px; font-size: 12px; margin: 0 0 6px; }

.btn {
  font-family: inherit; border: 1px solid var(--border); border-radius: 999px;
  padding: 12px 22px; font-size: 16px; cursor: pointer; background: var(--surface-2); color: var(--text);
  transition: transform .12s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--gold); border-color: var(--gold); color: #1a1405; font-weight: bold; }
.btn-secondary { background: var(--surface-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { padding: 7px 14px; font-size: 14px; }
.btn-big { padding: 15px 34px; font-size: 18px; width: 100%; margin-top: 14px; }
.btn-google { background: #fff; color: #222; border-color: #fff; display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.g-logo { font-weight: bold; color: #4285f4; font-family: Arial, sans-serif; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 2px 12px;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-title { font-size: 18px; letter-spacing: .5px; }

.tab { display: none; flex-direction: column; gap: 14px; }
.tab.active { display: flex; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.hero-card { text-align: center; padding: 26px 18px; }
.hero-card h2 { margin: 4px 0 2px; font-size: 28px; font-weight: normal; }
.card-title { margin: 0 0 12px; font-size: 17px; font-weight: normal; color: var(--gold-bright); }
.sub-title { margin: 16px 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

.streak-row { display: flex; gap: 10px; justify-content: center; margin: 14px 0 4px; flex-wrap: wrap; }
.streak-chip {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 14px; font-size: 15px; display: flex; gap: 7px; align-items: baseline;
}
.chip-label { color: var(--muted); font-size: 12px; }
.bead-dot { color: var(--blue); font-size: 11px; }

.progress-wrap { margin: 14px 0 2px; }
.progress-bar { background: var(--surface-2); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-fill { background: var(--gold); height: 100%; width: 100%; border-radius: 999px; transform: scaleX(0); transform-origin: left center; transition: transform .3s ease; }

.field {
  width: 100%; padding: 12px 14px; margin: 0 0 10px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-family: inherit; font-size: 16px;
}
.field-label { display: block; color: var(--muted); font-size: 13px; margin: 0 0 6px; }

.member-rows { display: flex; flex-direction: column; }
.member-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 2px; border-bottom: 1px solid var(--border);
}
.member-row:last-child { border-bottom: none; }
.member-name { font-size: 15px; }
.member-meta { color: var(--muted); font-size: 12px; display: block; }
.member-status { text-align: right; font-size: 13px; white-space: nowrap; }
.status-done { color: var(--ok); }
.status-partial { color: var(--gold-bright); }
.status-none { color: var(--muted); }
.btn-mini { padding: 6px 12px; font-size: 13px; border-radius: 999px; }

.stats-grid { display: flex; gap: 10px; }
.stat { flex: 1; background: var(--surface-2); border-radius: 12px; padding: 12px 6px; text-align: center; }
.stat-num { display: block; font-size: 24px; color: var(--gold-bright); }
.stat-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }

.history-rows { display: flex; flex-direction: column; }
.history-row { display: flex; justify-content: space-between; padding: 9px 2px; border-bottom: 1px solid var(--border); font-size: 14px; }
.history-row:last-child { border-bottom: none; }
.history-date { color: var(--muted); }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: center; gap: 4px;
  background: rgba(11,11,16,.96); border-top: 1px solid var(--border);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.tab-btn {
  font-family: inherit; flex: 1; max-width: 130px; padding: 11px 0; font-size: 15px;
  background: transparent; color: var(--muted); border: none; border-radius: 999px; cursor: pointer;
}
.tab-btn.active { background: var(--surface-2); color: var(--gold-bright); }
.tab-btn { transition: transform .12s ease; }
.tab-btn:active { transform: scale(.97); }

/* Prayer mode */
.pray-view { padding: 10px 16px 18px; height: 100dvh; flex: none; }
.pray-top { display: flex; justify-content: space-between; align-items: center; }
.pray-progress-meta { color: var(--muted); font-size: 14px; }
.pray-bar { margin: 8px 0 4px; }
/* Prayer header wrapper (v1.6.5): display:contents in portrait, so the
   header elements lay out exactly as if the wrapper were not there.
   In landscape it becomes the left text column (see media query below). */
.pray-head { display: contents; }
.pray-body { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 12px; touch-action: pan-y; }
.pray-body h2 { font-size: 24px; font-weight: normal; margin: 2px 0 4px; }
.pray-sub { color: var(--muted); font-style: italic; margin: 0 0 8px; min-height: 18px; font-size: 14px; }
/* Opening Hail Mary meditation (v1.6.3): the three opening Hail Marys are
   offered for the increase of faith, hope and charity, in that order.
   Shown in English + Tamil on those three steps only. */
.pray-meditation { color: var(--gold); font-size: 13px; margin: 0 0 6px; }
.pray-meditation[hidden] { display: none; }
/* Reserve the meditation line's height only while it is visible, so the
   bead loop keeps fitting the locked viewport height on those steps. */
.pray-body.has-meditation .loop-stage { width: min(94vw, 400px, calc((100dvh - 304px) * 0.691)); }
.pray-text { font-size: 13.5px; line-height: 1.55; white-space: pre-line; margin: 0; }
/* Rosary loop stage: beads circle the prayer text (v1.5.5). Virtual stage
   is 340x492 (see aspect-ratio); app.js positions beads by percentage. */
.loop-stage { position: relative; width: min(94vw, 400px, calc((100dvh - 280px) * 0.691)); aspect-ratio: 340 / 492; margin: auto 0; }
.loop-ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.loop-ring circle, .loop-ring line { fill: none; stroke: #33333d; stroke-width: 1.5; }
.loop-text { position: absolute; left: 50%; top: 33.3%; transform: translate(-50%, -50%); width: 66%; height: 47%; overflow-y: auto; scrollbar-width: none; padding: 12px 2px; box-sizing: border-box; display: flex; flex-direction: column; -webkit-mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent); mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent); }
.loop-text .pray-text { margin: auto 0; }
.loop-text::-webkit-scrollbar { display: none; }
.loop-circuit { position: absolute; left: 50%; top: 0.5%; transform: translateX(-50%); color: var(--muted); font-size: 12px; letter-spacing: .08em; white-space: nowrap; }
.loop-beads i { position: absolute; transform: translate(-50%, -50%); border-radius: 50%; background: transparent; border: 1.5px solid var(--bead-dim); transition: background .2s, border-color .2s, box-shadow .2s, transform .25s ease; }
.loop-beads i.sz-s { width: 11px; height: 11px; }
.loop-beads i.sz-m { width: 14px; height: 14px; }
.loop-beads i.done { background: var(--bead-dim); border-color: var(--bead-dim); }
.loop-beads i.now { background: var(--bead); border-color: #fff; transform: translate(-50%, -50%) scale(1.4); box-shadow: 0 0 9px var(--bead); animation: beadBreathe 2.4s ease-in-out infinite; }
@keyframes beadBreathe { 0%, 100% { box-shadow: 0 0 9px var(--bead); } 50% { box-shadow: 0 0 15px var(--bead); } }
.loop-beads i.pop { animation: beadPop .22s ease; }
@keyframes beadPop { 0% { transform: translate(-50%, -50%) scale(1); } 40% { transform: translate(-50%, -50%) scale(1.35); } 100% { transform: translate(-50%, -50%) scale(1); } }
.loop-beads i.ripple, .loop-beads .cdot.ripple { animation: rippleGlow .55s ease both; }
@keyframes rippleGlow {
  0% { }
  35% { background: var(--gold-bright); border-color: #fff; box-shadow: 0 0 16px 5px rgba(240, 192, 96, .85); color: var(--gold-bright); text-shadow: 0 0 12px var(--gold); }
  100% { }
}
.loop-beads .cdot { position: absolute; transform: translate(-50%, -50%); font-style: normal; font-weight: 400; font-size: 16px; line-height: 1; text-align: center; color: var(--bead-dim); opacity: .4; transition: color .2s, opacity .2s, transform .2s; }
.loop-beads .cdot.big { font-size: 25px; }
.loop-beads .cdot.done { color: var(--bead-dim); opacity: .85; }
.loop-beads .cdot.now { color: var(--bead); opacity: 1; transform: translate(-50%, -50%) scale(1.35); text-shadow: 0 0 8px var(--bead); }
/* Prayer header follows the finger during a swipe; app.js drives the
   transform inline on #pray-section / #pray-title / #pray-sub (the loop
   and beads stay put). The prayer text refreshes with a gentle fade+rise. */
#pray-text.txt-in { animation: txtIn .18s ease-out; }
@keyframes txtIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.pray-controls { display: flex; gap: 10px; margin-top: 14px; }
.pray-back { flex: 0 0 110px; }
.pray-next { flex: 1; padding: 16px; font-size: 18px; }
.pray-hint { text-align: center; margin: 10px 0 0; }

.flame-line { font-size: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--gold);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 50;
  max-width: 88vw; text-align: center;
}

.pair-code {
  font-size: 34px; letter-spacing: 6px; font-weight: 700; text-align: center;
  color: var(--gold); margin: 14px 0 6px;
}

.app-version {
  text-align: center; font-size: 11px; margin: 8px 0 78px;
}

.topbar-right { display: flex; align-items: center; gap: 8px; }
.lang-toggle { display: flex; border: 1px solid var(--gold); border-radius: 999px; overflow: hidden; }
.lang-toggle button {
  background: transparent; border: 0; color: var(--text); font-size: 12px;
  padding: 6px 10px; cursor: pointer;
}
.lang-toggle button.active { background: var(--gold); color: #0b0b10; font-weight: 700; }
.row-btns { display: flex; gap: 8px; margin: 10px 0 4px; flex-wrap: wrap; }

.seg-control { display: flex; border: 1px solid var(--gold); border-radius: 999px; overflow: hidden; margin: 0 0 12px; }
.seg-control button {
  flex: 1; background: transparent; border: 0; color: var(--text); font-size: 14px;
  padding: 10px; cursor: pointer;
}
.seg-control button.active { background: var(--gold); color: #0b0b10; font-weight: 700; }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.cal-day {
  aspect-ratio: 1; border: 1px solid transparent; border-radius: 10px; background: var(--card2);
  color: var(--text); font-size: 14px; cursor: pointer; padding: 0;
}
.cal-day.cal-other { opacity: 0.35; }
.cal-day.cal-done { background: rgba(46, 160, 80, 0.35); border-color: #2ea050; color: #d7ffe0; font-weight: 700; }
.cal-day.cal-partial { border-color: #b8860b; }
.cal-day.cal-today { box-shadow: inset 0 0 0 2px var(--gold); }
.cal-day.cal-sel { outline: 2px solid var(--gold); outline-offset: 1px; }
.cal-mystery { color: var(--gold); font-weight: 600; margin: 4px 0 8px; }

/* ---------- v1.6.0 animation pass (ANIMATION-SPEC-20261027) ---------- */
/* All motion is transform/opacity only. Curves stay ease-out and calm. */

/* View + tab entrances */
.view-in { animation: viewIn .18s ease both; }
@keyframes viewIn { from { opacity: 0; } to { opacity: 1; } }
#view-pray.view-in, #view-done.view-in { animation-name: viewInPop; }
@keyframes viewInPop { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: scale(1); } }
.tab-in-r { animation: tabInR .24s ease both; }
.tab-in-l { animation: tabInL .24s ease both; }
@keyframes tabInR { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
@keyframes tabInL { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: translateX(0); } }

/* Cards rise in when their tab is shown */
#tab-today.active .card, #tab-journey.active .card { animation: cardUp .3s ease both; }
#tab-journey.active .card:nth-child(2) { animation-delay: .06s; }
#tab-journey.active .card:nth-child(3) { animation-delay: .12s; }
#tab-journey.active .card:nth-child(4) { animation-delay: .18s; }
@keyframes cardUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Loading mark breathes while data loads */
#view-loading .brand-mark { animation: softPulse 1.6s ease-in-out infinite; }
@keyframes softPulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

/* Mystery card (decade transitions in prayer) */
.pray-view { position: relative; }
.mystery-card {
  position: absolute; left: 50%; top: 34%; z-index: 30;
  width: min(78vw, 320px); padding: 20px 18px; text-align: center;
  background: var(--surface-2); border: 1px solid var(--gold); border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .55);
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translate(-50%, -46%);
  transition: opacity .3s ease, transform .3s ease, visibility .3s;
}
.mystery-card.show { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, -50%); }
.mystery-card h3 { margin: 4px 0 6px; font-size: 22px; font-weight: normal; color: var(--gold-bright); }
.mystery-card .eyebrow { margin-bottom: 2px; }

/* Completion celebration (view-done) */
#view-done .brand-mark { position: relative; z-index: 0; }
#view-done .brand-mark::before {
  content: ''; position: absolute; left: 50%; top: 50%; z-index: -1;
  width: 230px; height: 230px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(240, 192, 96, .55) 0%, rgba(240, 192, 96, 0) 70%);
  opacity: 0; transform: translate(-50%, -50%) scale(.4);
}
#view-done.active .brand-mark { animation: doneMark .55s cubic-bezier(.22, .8, .3, 1) both; }
#view-done.active .brand-mark::before { animation: doneBloom 1.25s ease-out both; }
#view-done.milestone.active .brand-mark::before { animation-duration: 1.9s; }
@keyframes doneMark { from { transform: scale(.6); opacity: .4; } to { transform: scale(1); opacity: 1; } }
@keyframes doneBloom {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
  35% { opacity: .9; }
  100% { opacity: .35; transform: translate(-50%, -50%) scale(1.15); }
}
#view-done.active h2 { animation: fadeUp .45s ease .15s both; }
#view-done.active #done-summary { animation: fadeUp .45s ease .3s both; }
#view-done.active .flame-line { animation: fadeUp .45s ease .45s both, flamePulse .5s ease 1.15s 1; }
#view-done.active #done-milestone { animation: fadeUp .45s ease .6s both; }
#view-done.active #btn-done-home { animation: fadeUp .45s ease .65s both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes flamePulse { 0% { transform: scale(1); } 40% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* Reduced motion: everything degrades to near-instant crossfades */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- v1.6.6 landscape prayer layout ---------- */
/* Three-segment prayer screen in landscape ONLY. Every rule in this block
   lives inside the orientation media query; no portrait rule is touched.
   - Left column (.pray-head): mystery line, prayer title, decade line,
     meditation line. Middle column (.loop-text): the prayer words, out of
     the ring at last. Right column (.loop-beads): the bead ring, square.
   - .loop-stage is display:contents here (the v1.6.5 precedent did the
     same for .pray-head), so its children become flex items of .pray-body
     in DOM order: ring svg (hidden — see below), circuit, text, beads.
   - The ring svg is hidden in landscape: the circle is drawn on
     .loop-beads::before (inset 5.88% puts the 1.5px stroke through the bead
     centres, r=150 of a 340 stage) and the folded-in tail is a 1.5px
     background line from the cross (46.9%) down to the first pendant bead
     (90.6%). Both paint under the beads, as the svg did in portrait.
   - Stage width is height-driven and square now (no more 0.691 tall-stage
     factor): (viewport height - 132px) covers the top bar + progress bar +
     hint + view padding. The 252px cap keeps the ring from crowding the
     two text columns on wide-but-short screens (the app column is max
     560px wide). The ring no longer shrinks on meditation steps — the
     meditation line lives in the left column — so the has-meditation
     override from v1.6.5 is gone.
   - Top bar (X / 46 of 80) and the full-width progress bar stay at the
     top; the swipe hint stays centred at the bottom. Swipe gestures,
     colours and type sizes are unchanged. */
@media (orientation: landscape) {
  .pray-view { padding: 8px 20px 12px; }
  .pray-body { flex-direction: row; align-items: center; justify-content: center; gap: 20px; padding-top: 0; position: relative; }
  .pray-head { display: flex; flex-direction: column; align-items: center; text-align: center; flex: 1 1 0; min-width: 0; max-width: 560px; }
  .loop-stage { display: contents; }
  .loop-ring { display: none; }
  .loop-text { position: static; left: auto; top: auto; transform: none; width: auto; height: auto; flex: 1 1 0; min-width: 0; align-self: center; max-height: 100%; }
  .loop-beads { position: relative; flex: none; width: min(calc(100dvh - 132px), 40vw, 252px); aspect-ratio: 1 / 1; margin: 0; background: linear-gradient(to bottom, transparent 46.9%, #33333d 46.9%, #33333d 90.6%, transparent 90.6%) center / 1.5px 100% no-repeat; }
  .loop-beads::before { content: ''; position: absolute; inset: calc(5.88% - 0.75px); border: 1.5px solid #33333d; border-radius: 50%; }
  .loop-circuit { top: auto; bottom: 2px; }
}
