:root {
  color-scheme: dark;

  /* Dusk ground — quiet, evening-reading indigo, not pure black */
  --ink: #171b2c;
  --ink-2: #1f2438;
  --ink-3: #272c45;
  --line: #363b58;
  --line-soft: #2c3150;

  /* The one warm, lit surface: the passage itself, like a page under a lamp */
  --paper: #f6efd9;
  --paper-edge: #e8dcb4;
  --paper-ink: #2b2413;
  --paper-muted: #7d7250;

  /* Brass / gilt accent — restrained, not neon */
  --gold: #c69a3f;
  --gold-bright: #e3bf68;
  --gold-dim: #8a6c2c;

  --text: #ede9db;
  --muted: #a3a8c2;
  --muted-dim: #767c9c;
  --danger: #d97a5f;

  --shadow-paper: 0 30px 60px rgba(8, 9, 16, 0.45), 0 2px 0 rgba(255, 255, 255, 0.4) inset;
  --shadow-soft: 0 18px 40px rgba(6, 7, 14, 0.35);

  --font-display: "Fraunces", "Iowan Old Style", serif;
  --font-reading: "Source Serif 4", Georgia, serif;
  --font-ui: "Inter", ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(198, 154, 63, 0.16), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(90, 60, 130, 0.14), transparent 55%),
    var(--ink);
  font-family: var(--font-ui);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  width: min(880px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 40px 0 56px;
  display: grid;
  place-items: start center;
}

.reader-panel {
  width: 100%;
}

.masthead {
  padding: 4px 2px 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold-bright);
  opacity: 0.9;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

h1 {
  color: var(--text);
  font-size: clamp(2rem, 5vw, 2.9rem);
  font-weight: 600;
  font-variation-settings: "opsz" 40;
  line-height: 1.05;
}

h2 {
  color: var(--paper-ink);
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 600;
  font-variation-settings: "opsz" 30;
}

.status-pill {
  min-width: 100px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ink-2);
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.controls-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.field {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--ink-2);
}

.field label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.voice-field select {
  margin-bottom: 8px;
}

.mini-note {
  margin: 0 0 8px;
  color: var(--muted-dim);
  font-size: 0.76rem;
  line-height: 1.4;
}

.settings-panel {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--ink-2);
  overflow: hidden;
}

.settings-panel summary {
  min-height: 50px;
  padding: 0 14px;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: var(--gold-bright);
  font-family: var(--font-ui);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.settings-panel summary::-webkit-details-marker {
  display: none;
}

.settings-panel summary::before {
  content: "+";
  font-size: 1.2rem;
  line-height: 1;
  color: var(--gold);
}

.settings-panel[open] summary::before {
  content: "\2212";
}

.settings-summary {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  text-align: right;
}

.settings-grid {
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  border-top: 1px solid var(--line-soft);
}

.settings-grid .field {
  padding: 10px;
  border: 0;
  background: transparent;
}

.settings-grid .voice-field {
  grid-column: span 2;
}

.reference-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--ink);
}

select {
  cursor: pointer;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

.hint {
  margin: 9px 0 0;
  color: var(--muted-dim);
  font-size: 0.8rem;
  line-height: 1.4;
}

.inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.inline-control span {
  color: var(--muted);
  font-weight: 600;
}

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 10px;
  align-items: center;
}

.range-row input[type="range"] {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--gold);
}

.range-row output {
  color: var(--gold-bright);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.toggle-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
}

.toggle-copy {
  line-height: 1.25;
}

.hidden {
  display: none;
}

.player-bar {
  margin-top: 16px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: auto auto auto minmax(180px, 1fr);
  gap: 12px;
  align-items: center;
  border-radius: 12px;
  background: var(--ink-2);
  border: 1px solid var(--line-soft);
}

.primary-action,
.pause-action,
.secondary-action,
.ghost-action,
.reference-row button {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-weight: 600;
  transition: transform 0.12s ease, background 0.12s ease;
}

.player-control {
  width: 50px;
  height: 50px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  font-size: 1.05rem;
  line-height: 1;
}

.player-control:not(:disabled):active {
  transform: scale(0.94);
}

.primary-action,
.reference-row button {
  color: #211804;
  background: linear-gradient(160deg, var(--gold-bright), var(--gold));
}

.primary-action:not(:disabled):hover,
.reference-row button:hover {
  background: var(--gold-bright);
}

.secondary-action {
  color: var(--text);
  background: var(--ink-3);
  border: 1px solid var(--line);
}

.secondary-action:not(:disabled):hover {
  border-color: var(--danger);
  color: var(--danger);
}

.pause-action {
  color: var(--text);
  background: var(--ink-3);
  border: 1px solid var(--line);
}

.pause-action:not(:disabled):hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

.ghost-action {
  border: 1px solid var(--paper-edge);
  color: var(--paper-muted);
  background: transparent;
}

.ghost-action:hover {
  border-color: var(--gold-dim);
  color: var(--gold-dim);
}

.progress-copy {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 16px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.progress-copy strong {
  color: var(--gold-bright);
  font-weight: 600;
}

/* The passage card is the one lit, warm surface on the page — a page under a lamp */
.passage-card {
  margin-top: 18px;
  padding: 26px 28px 24px;
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow-paper);
  position: relative;
}

/* Repetition tally — the signature element. Quiet marks that gild in as
   each repeat of the passage completes, echoing a devotional tally. */
.repeat-tally {
  margin-bottom: 14px;
  display: flex;
  gap: 7px;
}

.repeat-tally .bead {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--paper-edge);
  border: 1px solid rgba(43, 36, 19, 0.18);
  transition: background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.repeat-tally .bead.filled {
  background: var(--gold);
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(198, 154, 63, 0.18);
}

.repeat-tally.pulsing .bead {
  animation: tally-breathe 1.8s ease-in-out infinite;
}

.repeat-tally.pulsing .bead:nth-child(2n) {
  animation-delay: 0.3s;
}

@keyframes tally-breathe {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.15); }
}

.passage-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--paper-edge);
}

.passage-heading .eyebrow {
  color: var(--gold-dim);
}

.passage-text {
  margin-top: 18px;
  color: var(--paper-ink);
  font-family: var(--font-reading);
  font-size: clamp(1.14rem, 2vw, 1.45rem);
  line-height: 1.75;
}

.verse {
  margin: 0 0 14px;
}

.verse-number {
  color: var(--gold-dim);
  font-family: var(--font-ui);
  font-size: 0.72em;
  font-weight: 700;
  vertical-align: super;
}

.notice {
  margin: 0;
  color: var(--danger);
  font-family: var(--font-ui);
}

.translation-credit {
  margin-top: 20px;
  padding: 4px 2px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  color: var(--muted-dim);
  font-size: 0.78rem;
  line-height: 1.45;
}

.translation-credit a {
  color: var(--gold-bright);
  font-weight: 600;
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 20px, 640px);
    padding: 22px 0 40px;
  }

  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .masthead {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  h1 {
    max-width: 230px;
    font-size: 1.9rem;
  }

  .controls-grid {
    margin-top: 14px;
    gap: 8px;
  }

  .field {
    padding: 11px;
  }

  .reference-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .settings-panel summary {
    min-height: 46px;
    padding: 0 11px;
  }

  .settings-summary {
    font-size: 0.74rem;
  }

  .player-bar {
    padding: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .player-bar .progress-copy {
    grid-column: 1 / -1;
  }

  .player-control {
    width: 100%;
    border-radius: 10px;
  }

  .progress-copy {
    justify-content: flex-start;
  }

  .passage-heading {
    align-items: center;
  }

  .ghost-action,
  .reference-row button {
    width: 100%;
  }

  .passage-card {
    padding: 18px 18px 16px;
  }

  .passage-heading .ghost-action {
    width: auto;
  }

  .passage-text {
    margin-top: 14px;
    font-size: 1.14rem;
  }
}
