:root {
  --ink: #1c2636;
  --ink-soft: #3d4a5c;
  --muted: #6b788c;
  --paper: #eef2f7;
  --sky: #a8bfd6;
  --mist: #d5e2ef;
  --dawn: #f4f1ec;
  --teal: #2a6b66;
  --teal-deep: #1f524e;
  --teal-wash: rgba(42, 107, 102, 0.12);
  --line: rgba(28, 38, 54, 0.1);
  --glass: rgba(255, 255, 255, 0.42);
  --shadow-soft: 0 18px 40px rgba(28, 38, 54, 0.08);
  --sheet: rgba(248, 250, 252, 0.94);
  --sheet-border: rgba(28, 38, 54, 0.08);
  --switch-off: rgba(28, 38, 54, 0.18);
  --actions-bg: rgba(238, 242, 247, 0.72);
  --secondary-bg: rgba(255, 255, 255, 0.45);
  --secondary-border: rgba(28, 38, 54, 0.1);
  --chapter-bg: rgba(255, 255, 255, 0.4);
  --wash-1: #c7d8ea;
  --wash-2: rgba(168, 191, 214, 0.55);
  --wash-3: rgba(244, 241, 236, 0.9);
  --wash-grad: linear-gradient(180deg, #b7cce0 0%, #e8eef5 42%, #f3f0ea 100%);
  --glow: rgba(255, 255, 255, 0.55);
  --theme-color: #8fa9c4;
  --radius: 14px;
  --font-brand: "Fraunces", Georgia, serif;
  --font-ui: "Figtree", sans-serif;
  --font-read: "Literata", Georgia, serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

html[data-theme="dark"] {
  --ink: #e8eef7;
  --ink-soft: #c2ccd9;
  --muted: #8b96a8;
  --paper: #121820;
  --sky: #2a3848;
  --mist: #1a2430;
  --dawn: #1c222c;
  --teal: #4aa59c;
  --teal-deep: #6fc0b7;
  --teal-wash: rgba(74, 165, 156, 0.16);
  --line: rgba(232, 238, 247, 0.1);
  --glass: rgba(255, 255, 255, 0.08);
  --shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.35);
  --sheet: rgba(22, 28, 36, 0.96);
  --sheet-border: rgba(232, 238, 247, 0.1);
  --switch-off: rgba(232, 238, 247, 0.2);
  --actions-bg: rgba(18, 24, 32, 0.82);
  --secondary-bg: rgba(255, 255, 255, 0.06);
  --secondary-border: rgba(232, 238, 247, 0.12);
  --chapter-bg: rgba(255, 255, 255, 0.06);
  --wash-1: #243445;
  --wash-2: rgba(58, 86, 110, 0.45);
  --wash-3: rgba(28, 34, 44, 0.95);
  --wash-grad: linear-gradient(180deg, #1a2532 0%, #141b24 48%, #121820 100%);
  --glow: rgba(120, 160, 190, 0.18);
  --theme-color: #1a2532;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
  transition: color 0.25s ease, background-color 0.25s ease;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

[hidden] {
  display: none !important;
}

/* Atmosphere */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.atmosphere__wash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--wash-1) 0%, transparent 55%),
    radial-gradient(90% 60% at 100% 20%, var(--wash-2) 0%, transparent 50%),
    radial-gradient(70% 50% at 0% 70%, var(--wash-3) 0%, transparent 45%),
    var(--wash-grad);
  animation: wash-drift 18s ease-in-out infinite alternate;
}

.atmosphere__glow {
  position: absolute;
  width: 140%;
  height: 55%;
  left: -20%;
  top: -8%;
  background: radial-gradient(
    ellipse at center,
    var(--glow) 0%,
    transparent 70%
  );
  animation: glow-rise 12s var(--ease-out) infinite alternate;
}

.atmosphere__grain {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@keyframes wash-drift {
  from {
    transform: scale(1) translateY(0);
  }
  to {
    transform: scale(1.04) translateY(-1.5%);
  }
}

@keyframes glow-rise {
  from {
    transform: translateY(0) scale(1);
    opacity: 0.7;
  }
  to {
    transform: translateY(4%) scale(1.06);
    opacity: 1;
  }
}

/* App shell */
.app {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding:
    calc(1.25rem + var(--safe-top))
    1.35rem
    calc(1.25rem + var(--safe-bottom));
}

.screen {
  min-height: calc(100dvh - 2.5rem - var(--safe-top) - var(--safe-bottom));
  display: flex;
  flex-direction: column;
}

/* Home */
.screen--home {
  position: relative;
  justify-content: space-between;
  padding-top: clamp(2.5rem, 12vh, 5.5rem);
  padding-bottom: 0.5rem;
  animation: screen-enter 0.7s var(--ease-out) both;
}

.settings-trigger {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.brand__mark {
  margin: 0;
  font-family: var(--font-brand);
  font-weight: 650;
  font-size: clamp(2.75rem, 11vw, 3.6rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--ink);
  animation: rise 0.8s var(--ease-out) 0.05s both;
}

.brand__headline {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  animation: rise 0.8s var(--ease-out) 0.15s both;
}

.brand__lede {
  margin: 0;
  max-width: 18rem;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--muted);
  animation: rise 0.8s var(--ease-out) 0.25s both;
}

.home-cta {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
  margin-top: auto;
  padding-top: 2.5rem;
  animation: rise 0.85s var(--ease-out) 0.35s both;
}

.home-meta {
  margin: 0;
  text-align: center;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.progress-strip {
  margin-top: 2rem;
  animation: rise 0.85s var(--ease-out) 0.45s both;
}

.progress-strip__track {
  height: 3px;
  border-radius: 999px;
  background: rgba(28, 38, 54, 0.08);
  overflow: hidden;
}

.progress-strip__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--teal);
  transition: width 0.6s var(--ease-out);
}

.progress-strip__label {
  margin: 0.65rem 0 0;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.15rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.01em;
  transition:
    transform 0.2s var(--ease-out),
    background 0.2s ease,
    color 0.2s ease,
    opacity 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--teal);
  color: #f7fbfa;
}

.btn--primary:hover {
  background: var(--teal-deep);
}

.btn--primary.is-complete {
  background: var(--teal-wash);
  color: var(--teal-deep);
}

.btn--secondary {
  background: var(--secondary-bg);
  color: var(--ink-soft);
  border: 1px solid var(--secondary-border);
  font-weight: 500;
}

.btn--secondary:hover {
  color: var(--ink);
  background: var(--glass);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-soft);
  min-height: 2.75rem;
  font-weight: 500;
  font-size: 0.92rem;
}

.btn--ghost:hover {
  color: var(--ink);
}

.icon-btn {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--ink-soft);
  transition: background 0.2s ease, color 0.2s ease;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--glass);
  color: var(--ink);
}

/* Reading */
.screen--reading {
  height: calc(100dvh - 2.5rem - var(--safe-top) - var(--safe-bottom));
  max-height: calc(100dvh - 2.5rem - var(--safe-top) - var(--safe-bottom));
  overflow: hidden;
  animation: screen-enter 0.55s var(--ease-out) both;
}

.reading-bar {
  display: grid;
  grid-template-columns: 2.5rem 1fr 2.5rem;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.reading-bar__center {
  text-align: center;
  border-radius: 12px;
  padding: 0.2rem 0.4rem;
  transition: background 0.2s ease;
}

.reading-bar__center:hover,
.reading-bar__center:focus-visible {
  background: var(--glass);
}

.reading-bar__book {
  margin: 0;
  font-family: var(--font-brand);
  font-weight: 560;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.reading-bar__day {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.passage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 1.25rem;
  overscroll-behavior: contain;
}

.passage__title {
  margin: 0 0 1.25rem;
  font-family: var(--font-brand);
  font-weight: 560;
  font-size: clamp(1.75rem, 7vw, 2.15rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
  animation: rise 0.55s var(--ease-out) both;
}

.passage__body {
  font-family: var(--font-read);
  font-size: 1.12rem;
  line-height: 1.75;
  color: var(--ink);
  animation: rise 0.65s var(--ease-out) 0.08s both;
}

.passage__body p {
  margin: 0 0 1.1rem;
}

.verse {
  display: block;
  margin-bottom: 0.15rem;
}

.verse__num {
  display: inline-block;
  min-width: 1.4em;
  margin-right: 0.35em;
  font-family: var(--font-ui);
  font-size: 0.72em;
  font-weight: 600;
  vertical-align: super;
  color: var(--teal);
  opacity: 0.85;
}

.passage__loading,
.passage__error {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 1rem;
}

.passage__error {
  color: #8a3b3b;
}

.passage__credit {
  margin: 1.75rem 0 0;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.reading-actions {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 0.4rem;
  align-items: center;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  background: var(--actions-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Book & chapter pickers */
.screen--picker {
  height: calc(100dvh - 2.5rem - var(--safe-top) - var(--safe-bottom));
  max-height: calc(100dvh - 2.5rem - var(--safe-top) - var(--safe-bottom));
  overflow: hidden;
  animation: screen-enter 0.45s var(--ease-out) both;
}

.picker-bar {
  display: grid;
  grid-template-columns: 2.5rem 1fr 2.5rem;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.picker-bar__center {
  text-align: center;
}

.picker-bar__title {
  margin: 0;
  font-family: var(--font-brand);
  font-weight: 560;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.picker-bar__sub {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.picker-bar__spacer {
  width: 2.5rem;
  height: 2.5rem;
}

.book-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  padding-bottom: 0.5rem;
}

.book-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.95rem 0.15rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  transition: background 0.2s ease, color 0.2s ease;
}

.book-row:first-child {
  border-top: 1px solid var(--line);
}

.book-row:active {
  background: var(--glass);
}

.book-row__name {
  font-family: var(--font-brand);
  font-weight: 560;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.book-row__meta {
  flex-shrink: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.book-row.is-current .book-row__name {
  color: var(--teal-deep);
}

.book-row.is-current .book-row__meta {
  color: var(--teal);
}

.chapter-grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.55rem;
  align-content: start;
  padding: 0.25rem 0 0.75rem;
}

.chapter-cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--chapter-bg);
  border: 1px solid var(--line);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink-soft);
  transition:
    transform 0.2s var(--ease-out),
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease;
}

.chapter-cell:active {
  transform: scale(0.96);
}

.chapter-cell.is-done {
  background: var(--teal-wash);
  color: var(--teal-deep);
  border-color: transparent;
}

.chapter-cell.is-current {
  background: var(--teal);
  color: #f7fbfa;
  border-color: transparent;
}

/* Settings modal */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal[hidden] {
  display: none !important;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 16, 22, 0.42);
  border: 0;
  cursor: pointer;
  animation: screen-enter 0.25s ease both;
}

.modal__sheet {
  position: relative;
  z-index: 1;
  width: min(100%, 480px);
  padding:
    0.65rem 1.35rem
    calc(1.35rem + var(--safe-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--sheet);
  border: 1px solid var(--sheet-border);
  border-bottom: 0;
  box-shadow: var(--shadow-soft);
  transform: translateY(100%);
  animation: sheet-up 0.35s var(--ease-out) both;
}

.modal__handle {
  width: 2.4rem;
  height: 0.28rem;
  margin: 0 auto 0.85rem;
  border-radius: 999px;
  background: var(--line);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}

.modal__title {
  margin: 0;
  font-family: var(--font-brand);
  font-weight: 560;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.settings-row__copy {
  min-width: 0;
}

.settings-row__label {
  margin: 0;
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
}

.settings-row__hint {
  margin: 0.25rem 0 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.switch__track {
  width: 3.1rem;
  height: 1.85rem;
  border-radius: 999px;
  background: var(--switch-off);
  display: block;
  position: relative;
  transition: background 0.25s ease;
}

.switch__thumb {
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  transition: transform 0.25s var(--ease-out);
}

.switch input:checked + .switch__track {
  background: var(--teal);
}

.switch input:checked + .switch__track .switch__thumb {
  transform: translateX(1.25rem);
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + var(--safe-bottom));
  transform: translateX(-50%) translateY(120%);
  z-index: 20;
  padding: 0.7rem 1.1rem;
  border-radius: 12px;
  background: var(--ink);
  color: #f4f7fb;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-soft);
  transition: transform 0.35s var(--ease-out), opacity 0.35s ease;
  opacity: 0;
  max-width: calc(100% - 2rem);
}

.toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes screen-enter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (min-width: 480px) {
  .app {
    padding-left: 1.75rem;
    padding-right: 1.75rem;
  }

  .passage__body {
    font-size: 1.18rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .atmosphere__wash,
  .atmosphere__glow,
  .screen--home,
  .screen--reading,
  .screen--picker,
  .brand__mark,
  .brand__headline,
  .brand__lede,
  .home-cta,
  .progress-strip,
  .passage__title,
  .passage__body {
    animation: none !important;
  }

  .progress-strip__fill,
  .toast,
  .btn,
  .modal__sheet,
  .switch__track,
  .switch__thumb {
    transition: none !important;
    animation: none !important;
  }
}
