:root {
  --bg-deep: #14192b;
  --bg-panel: #1b2140;
  --bg-panel-raised: #232a4d;
  --gold: #e8a94c;
  --gold-glow: #f4c869;
  --ivory: #f5f0e6;
  --muted: #9aa3c0;
  --muted-dim: #6b7394;
  --hairline: rgba(245, 240, 230, 0.12);
  --candle-hope: #8a6fae;
  --candle-peace: #7d6bae;
  --candle-joy: #d98ab0;
  --candle-love: #8a6fae;
  --candle-light: #f4c869;
  --font-display: 'Literata', Georgia, serif;
  --font-ui: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--ivory);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  padding-bottom: calc(72px + var(--safe-bottom));
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Loading ---------- */
.loading {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
}
.flame {
  width: 14px;
  height: 22px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 50% 65%, var(--gold-glow), var(--gold) 70%);
  box-shadow: 0 0 16px 4px rgba(232, 169, 76, 0.5);
  animation: flicker 1.6s ease-in-out infinite;
}
@keyframes flicker {
  0%, 100% { transform: scaleY(1) scaleX(1); opacity: 1; }
  50% { transform: scaleY(1.08) scaleX(0.95); opacity: 0.9; }
}

/* ---------- Layout shell ---------- */
#app { min-height: 100vh; }
.screen { max-width: 640px; margin: 0 auto; padding: 0 0 40px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 22px 20px 10px;
  max-width: 640px;
  margin: 0 auto;
}
.topbar h1 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.01em;
}
.topbar .season-range {
  font-size: 12px;
  color: var(--muted-dim);
  font-variant-numeric: tabular-nums;
}

/* ---------- Candle progress ---------- */
.candles {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 4px 20px 22px;
  max-width: 640px;
  margin: 0 auto;
}
.candle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.candle-flame {
  width: 8px;
  height: 12px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: var(--bg-panel-raised);
  opacity: 0.35;
  transition: all 0.4s ease;
}
.candle-flame.lit {
  opacity: 1;
  box-shadow: 0 0 8px 1px currentColor;
}
.candle-flame.lit.active {
  box-shadow: 0 0 16px 4px currentColor;
  animation: candle-flicker 2.4s ease-in-out infinite;
}
@keyframes candle-flicker {
  0%, 100% { box-shadow: 0 0 16px 4px currentColor; opacity: 1; }
  50% { box-shadow: 0 0 12px 3px currentColor; opacity: 0.92; }
}
@media (prefers-reduced-motion: reduce) {
  .candle-flame.lit.active { animation: none; }
}
.candle-body {
  width: 16px;
  height: 34px;
  border-radius: 3px;
  background: var(--bg-panel-raised);
  opacity: 0.5;
}
.candle.lit .candle-body { opacity: 1; }
.candle-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-dim);
}
.candle.active .candle-label { color: var(--gold-glow); }

/* ---------- Day hero ---------- */
.hero {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-panel);
}
.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(20,25,43,0) 40%, rgba(20,25,43,0.92) 100%);
}
.hero-caption {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 16px;
  z-index: 2;
}
.hero-eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold-glow);
  font-weight: 600;
  margin-bottom: 6px;
}
.hero-date {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  line-height: 1.15;
}

/* ---------- Content card ---------- */
.content {
  padding: 24px 20px 8px;
}
.block { margin-bottom: 28px; }
.block-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 10px;
}
.scripture {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 19px;
  line-height: 1.55;
  color: var(--ivory);
  border-left: 2px solid var(--gold);
  padding-left: 16px;
}
.reflection {
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ivory);
  white-space: pre-line;
}
.question-box {
  background: var(--bg-panel);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 18px 18px;
}
.question-box .block-label { margin-bottom: 8px; }
.question-text {
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.5;
}
.journal-area {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  background: var(--bg-panel);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--ivory);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  margin-top: 10px;
}
.journal-area::placeholder { color: var(--muted-dim); }
.journal-area:focus {
  outline: none;
  border-color: var(--gold);
}
.journal-saved {
  font-size: 11px;
  color: var(--muted-dim);
  margin-top: 6px;
  height: 14px;
}
.prayer {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  line-height: 1.6;
  color: var(--muted);
}

.feedback-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  margin-top: 8px;
}
.feedback-btn:active { border-color: var(--gold); color: var(--gold-glow); }

/* ---------- Empty / gate states ---------- */
.gate {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 30px;
  gap: 14px;
}
.gate .flame { margin-bottom: 6px; }
.countdown-number {
  font-family: var(--font-display);
  font-size: 64px;
  font-weight: 600;
  color: var(--gold-glow);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.countdown-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 8px;
}
.gate h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  margin: 0;
}
.gate p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
  max-width: 320px;
}

/* ---------- Archive ---------- */
.archive-list {
  padding: 4px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.archive-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-panel);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 10px;
  text-align: left;
  cursor: pointer;
  color: var(--ivory);
  font-family: var(--font-ui);
}
.archive-thumb {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-panel-raised);
}
.archive-meta { flex: 1; min-width: 0; }
.archive-day {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-dim);
}
.archive-title {
  font-family: var(--font-display);
  font-size: 16px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.archive-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 18px 20px 0;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 0;
  cursor: pointer;
}
.back-btn:active { color: var(--gold-glow); }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: rgba(27, 33, 64, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--hairline);
  padding-bottom: var(--safe-bottom);
  z-index: 10;
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0 8px;
  background: none;
  border: none;
  color: var(--muted-dim);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.tab-btn .tab-icon { font-size: 18px; line-height: 1; }
.tab-btn[aria-current="page"] { color: var(--gold-glow); }

/* Focus visibility */
a:focus-visible, button:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold-glow);
  outline-offset: 2px;
}
