:root {
  --bg: #fbf7f2;
  --surface: #fffdfb;
  --surface-strong: #ffffff;
  --ink: #2b2528;
  --muted: #6b6166;
  --primary: #5b354f;
  --primary-dark: #43243a;
  --primary-soft: #f1e6ec;
  --rose: #c98683;
  --sage: #879786;
  --sand: #d9c5b5;
  --gold: #b8945f;
  --border: #e8ddd6;
  --danger: #8e3f49;
  --success: #486b54;
  --shadow: 0 14px 44px rgba(67, 36, 58, 0.08);
  --radius-sm: 14px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --text-scale: 1;
  --max: 760px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(201, 134, 131, .12), transparent 30rem),
    var(--bg);
  color: var(--ink);
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: calc(16px * var(--text-scale));
  line-height: 1.58;
  min-height: 100vh;
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
}
button, input, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--primary); }

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 999;
  background: var(--primary);
  color: white;
  padding: 10px 14px;
  border-radius: 10px;
}
.skip-link:focus { top: 12px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 10px max(16px, env(safe-area-inset-left));
  background: rgba(251, 247, 242, .94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(232, 221, 214, .86);
}
.brand-button {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  background: transparent;
  padding: 4px;
  text-align: left;
  cursor: pointer;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 50% 50% 46% 54% / 56% 45% 55% 44%;
  background: var(--primary-soft);
  display: grid;
  place-items: center;
  transform: rotate(-8deg);
}
.brand-mark span {
  width: 12px;
  height: 21px;
  border: 2px solid var(--primary);
  border-top: 0;
  border-left: 0;
  border-radius: 0 0 12px 0;
  transform: rotate(45deg) translate(-2px, -1px);
}
.brand-copy { display: grid; line-height: 1.1; }
.brand-copy strong { color: var(--primary); font-size: 15px; }
.brand-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-weight: 700;
}

.app-shell {
  width: min(100%, var(--max));
  margin: 0 auto;
  padding: 24px 18px 48px;
  min-height: 70vh;
}

.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, var(--primary) 0%, #70445f 60%, #865b72 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 34px 26px 30px;
  box-shadow: var(--shadow);
}
.hero::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -72px;
  top: -70px;
  border-radius: 50%;
  border: 28px solid rgba(255,255,255,.08);
}
.hero .eyebrow { color: rgba(255,255,255,.78); }
.hero h1 { margin: 8px 0 14px; max-width: 540px; }
.hero p { color: rgba(255,255,255,.88); max-width: 600px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

h1, h2, h3 {
  font-family: "Playfair Display", Georgia, serif;
  line-height: 1.13;
  letter-spacing: -.02em;
  margin-top: 0;
}
h1 { font-size: clamp(2.15rem, 8vw, 3.5rem); }
h2 { font-size: clamp(1.7rem, 6vw, 2.35rem); }
h3 { font-size: 1.28rem; }
p { margin: 0 0 1em; }
.eyebrow {
  margin: 0 0 7px;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--rose);
}
.lead { font-size: 1.12rem; color: var(--muted); }
.small-print { color: var(--muted); font-size: .83rem; line-height: 1.5; }

.section { margin-top: 34px; }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-heading h2, .section-heading h3 { margin-bottom: 0; }

.card {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: 0 6px 26px rgba(67, 36, 58, .035);
}
.card + .card { margin-top: 12px; }
.soft-card { background: var(--primary-soft); border-color: transparent; }
.notice-card { border-left: 4px solid var(--gold); }

.button {
  min-height: 48px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--primary-dark); }
.button.secondary { background: white; color: var(--primary); border: 1px solid var(--border); }
.button.ghost { background: transparent; color: var(--primary); border: 1px solid currentColor; }
.button.light { background: white; color: var(--primary); }
.button.full { width: 100%; }
.button:disabled { opacity: .45; cursor: not-allowed; }

.progress-wrap { margin: 20px 0; }
.progress-line {
  height: 9px;
  background: #eadfe5;
  border-radius: 999px;
  overflow: hidden;
}
.progress-line > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--rose), var(--primary));
  border-radius: inherit;
  transition: width .35s ease;
}
.progress-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 7px; font-size: .82rem; color: var(--muted); }

.day-list { display: grid; gap: 12px; }
.day-card {
  width: 100%;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: left;
  cursor: pointer;
}
.day-card:hover { border-color: var(--rose); }
.day-card.done { background: #f6faf6; border-color: #cdddcf; }
.day-number {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
}
.day-card.done .day-number { background: #dcebdc; color: var(--success); }
.day-copy strong { display: block; font-size: .96rem; }
.day-copy small { display: block; margin-top: 4px; color: var(--muted); }
.chevron { color: var(--muted); font-size: 1.4rem; }

.bottom-nav {
  position: fixed;
  z-index: 30;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: 72px;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 253, 251, .97);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(16px);
}
.bottom-nav button {
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  color: var(--muted);
  cursor: pointer;
}
.bottom-nav button span { font-size: 1.25rem; }
.bottom-nav button small { font-size: .69rem; font-weight: 650; }
.bottom-nav button.active { color: var(--primary); }

.question-card { padding: 24px 20px; }
.question-number { color: var(--muted); font-size: .83rem; font-weight: 700; }
.question-text { font-family: "Playfair Display", Georgia, serif; font-size: 1.45rem; line-height: 1.3; margin: 10px 0 22px; }
.options { display: grid; gap: 9px; }
.option-button {
  min-height: 52px;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
}
.option-button.selected { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); font-weight: 700; }
.question-actions { display: flex; gap: 10px; justify-content: space-between; margin-top: 20px; }

.score-grid { display: grid; gap: 10px; }
.score-row { display: grid; grid-template-columns: 108px 1fr 34px; gap: 10px; align-items: center; font-size: .85rem; }
.score-bar { height: 8px; border-radius: 999px; background: #eee5e0; overflow: hidden; }
.score-bar span { display: block; height: 100%; border-radius: inherit; background: var(--rose); }
.result-hero { border-top: 6px solid var(--primary); }
.result-pair { display: grid; grid-template-columns: 1fr; gap: 12px; }

.tts-player {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  margin: 18px 0 24px;
}
.tts-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tts-player button { min-height: 42px; padding: 8px 14px; }
.tts-player select { min-height: 42px; border: 1px solid var(--border); border-radius: 999px; padding: 0 12px; background: white; }

.lesson-copy p { font-size: 1.04rem; color: #433b3f; }
.quote-card {
  margin: 26px 0;
  border-left: 4px solid var(--rose);
  padding: 18px 20px;
  background: #fff8f6;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.check-list { padding: 0; margin: 0; list-style: none; display: grid; gap: 10px; }
.check-list li { display: grid; grid-template-columns: 24px 1fr; gap: 8px; }
.check-list li::before { content: "○"; color: var(--rose); font-weight: 800; }

.form-grid { display: grid; gap: 16px; }
.field-label { display: block; margin-bottom: 6px; color: var(--ink); font-weight: 700; }
.text-input, .text-area, .date-input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--ink);
  padding: 12px 14px;
}
.text-area { min-height: 108px; resize: vertical; }
.text-input:focus, .text-area:focus, .date-input:focus, button:focus-visible, a:focus-visible, select:focus-visible {
  outline: 3px solid rgba(201,134,131,.28);
  outline-offset: 2px;
}

.prayer-list { display: grid; gap: 12px; }
.accordion {
  border: 1px solid var(--border);
  background: var(--surface-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.accordion summary { cursor: pointer; padding: 18px 20px; font-weight: 750; list-style: none; }
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after { content: "+"; float: right; color: var(--primary); }
.accordion[open] summary::after { content: "−"; }
.accordion-body { padding: 0 20px 20px; color: #433b3f; }

.dialog-card {
  width: min(92vw, 520px);
  border: 0;
  border-radius: var(--radius-lg);
  padding: 24px;
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(43,37,40,.25);
}
.dialog-card::backdrop { background: rgba(43,37,40,.48); backdrop-filter: blur(4px); }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.dialog-header h2 { font-size: 1.7rem; }
.dialog-card input[type="range"] { width: 100%; accent-color: var(--primary); }
.range-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: .74rem; }
.switch-row { display: flex; align-items: center; gap: 10px; margin: 22px 0; font-weight: 650; }
.switch-row input { width: 20px; height: 20px; accent-color: var(--primary); }

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translate(-50%, 18px);
  width: min(90vw, 420px);
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  text-align: center;
  font-size: .86rem;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.empty-state { text-align: center; padding: 34px 18px; }
.empty-state .symbol { font-size: 2.3rem; color: var(--rose); }
.pill { display: inline-flex; padding: 6px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .76rem; font-weight: 750; }
.split-actions { display: grid; gap: 10px; margin-top: 18px; }
.footer-note { margin-top: 34px; color: var(--muted); font-size: .78rem; text-align: center; }

@media (min-width: 640px) {
  .app-shell { padding: 34px 24px 70px; }
  .hero { padding: 46px 42px 40px; }
  .result-pair { grid-template-columns: 1fr 1fr; }
  .split-actions { grid-template-columns: 1fr 1fr; }
  .bottom-nav { left: 50%; right: auto; width: min(100%, 760px); transform: translateX(-50%); border: 1px solid var(--border); border-bottom: 0; border-radius: 22px 22px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
