/* Evensong — layout and components. */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html { font-size: 17px; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.5s var(--ease), color 0.5s var(--ease);
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: var(--measure);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 1.1rem) 1.25rem 0.9rem;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.mode-switch {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.mode-tab {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-faint);
  background: none;
  border: none;
  border-bottom: 1.5px solid transparent;
  padding: 0.3rem 0.1rem;
  margin: 0 0.4rem;
  cursor: pointer;
  transition: color 0.25s var(--ease);
}

.mode-tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0.35rem;
  display: flex;
  border-radius: 8px;
  transition: color 0.2s var(--ease);
}
.icon-btn:hover { color: var(--ink); }

/* ---------- View shell ---------- */

.view {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1rem 1.25rem calc(env(safe-area-inset-bottom, 0px) + 4rem);
  animation: rise 0.45s var(--ease);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Home ---------- */

.home-date {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 2.2rem 0 0.5rem;
}

.home-lead {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin-bottom: 2rem;
  max-width: 28rem;
}

.topic-field {
  width: 100%;
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--ink);
  background: var(--bg-inset);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  outline: none;
  transition: border-color 0.25s var(--ease);
}
.topic-field::placeholder { color: var(--ink-faint); font-style: italic; }
.topic-field:focus { border-color: var(--rule-strong); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  padding: 0.9rem 1.5rem;
  transition: opacity 0.2s var(--ease), transform 0.1s var(--ease);
}
.btn:active { transform: scale(0.985); }
.btn[disabled] { opacity: 0.45; cursor: default; }

.btn-primary { background: var(--accent); color: var(--accent-ink); width: 100%; }
.btn-quiet {
  background: none;
  color: var(--ink-soft);
  border: 1px solid var(--rule-strong);
}
.btn-text {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--ink-faint);
  padding: 0.5rem 0.25rem;
  font-weight: 500;
}
.btn-text:hover { color: var(--ink); }

.home-links {
  display: flex;
  gap: 1.5rem;
  margin-top: 2.5rem;
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
}

.shelf-note {
  font-size: 0.82rem;
  color: var(--ink-faint);
  margin-top: 1.2rem;
  line-height: 1.5;
}
.shelf-note a { color: var(--ink-soft); }

/* Source toggle (news / sermon) */
.source-toggle {
  display: flex;
  gap: 0.4rem;
  margin: 0 0 0.6rem;
}
.source-toggle button {
  flex: 1;
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.55rem 0.5rem;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.source-toggle button.active {
  color: var(--ink);
  border-color: var(--accent);
  background: var(--bg-inset);
}
.source-hint {
  font-size: 0.8rem;
  color: var(--ink-faint);
  line-height: 1.5;
  margin: 0 0 1rem;
}
.source-hint a { color: var(--ink-soft); }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--accent-ink);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gen-status {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin-top: 1rem;
  min-height: 1.5em;
}

/* ---------- Reader ---------- */

.reader-kicker {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 1.6rem 0 0.6rem;
}

.reader-title {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -0.015em;
  margin-bottom: 0.4rem;
}

.reader-passage-ref {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1.02rem;
  margin-bottom: 1.6rem;
}

.reader-body {
  font-family: var(--serif);
  font-size: 1.13rem;
  line-height: 1.72;
}

.reader-body h3 {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 2.4rem 0 0.8rem;
}

.reader-body p { margin-bottom: 1.05em; }
.reader-body p:last-child { margin-bottom: 0; }

.scripture-block {
  border-left: 2px solid var(--accent);
  padding: 0.2rem 0 0.2rem 1.1rem;
  margin: 1.4rem 0 1.8rem;
  font-size: 1.16rem;
  line-height: 1.75;
}
.scripture-block .ref {
  display: block;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-style: normal;
  margin-top: 0.7rem;
}

.q-list { list-style: none; counter-reset: q; margin: 0.4rem 0 0; }
.q-list li {
  counter-increment: q;
  position: relative;
  padding: 0.9rem 0 0.9rem 2.2rem;
  border-bottom: 1px solid var(--rule);
}
.q-list li:last-child { border-bottom: none; }
.q-list li::before {
  content: counter(q);
  position: absolute;
  left: 0; top: 1rem;
  font-family: var(--serif);
  font-style: italic;
  color: var(--accent);
  font-size: 1.05rem;
}

.leader-toggle {
  display: block;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-faint);
  background: none;
  border: none;
  padding: 0.4rem 0 0;
  cursor: pointer;
}
.leader-toggle:hover { color: var(--ink-soft); }
.leader-notes {
  display: none;
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--ink-soft);
  background: var(--bg-inset);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  margin-top: 0.5rem;
  line-height: 1.55;
}
.leader-notes.open { display: block; }

.reader-footer {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.source-line {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 2.5rem;
  line-height: 1.5;
}
.source-line a { color: var(--ink-soft); }

/* Feedback (learning loop) */
.feedback {
  margin-top: 2.5rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
}
.feedback-label {
  display: block;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.7rem;
}
.feedback-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.fb-verdict, .fb-chip {
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.45rem 0.95rem;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.fb-chip { font-size: 0.78rem; padding: 0.38rem 0.8rem; }
.fb-verdict:hover, .fb-chip:hover { color: var(--ink); }
.fb-verdict.on, .fb-chip.on {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}
.fb-correct {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.3rem;
}
.fb-note-field {
  flex: 1;
  min-width: 0;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--bg-inset);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  outline: none;
  transition: border-color 0.2s var(--ease);
}
.fb-note-field::placeholder { color: var(--ink-faint); }
.fb-note-field:focus { border-color: var(--rule-strong); }
.fb-send {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0 0.95rem;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.fb-send:hover { color: var(--ink); border-color: var(--accent); }
.fb-notes {
  list-style: none;
  margin: 0.7rem 0 0;
}
.fb-notes li {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.88rem;
  color: var(--ink-soft);
  padding: 0.25rem 0;
}
.feedback-note {
  font-size: 0.76rem;
  color: var(--ink-faint);
  margin-top: 0.6rem;
}

/* Preacher editor */
.preacher-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.preacher-row .topic-field { margin-bottom: 0; font-family: var(--sans); font-size: 0.88rem; }
.preacher-name { flex: 1; }
.preacher-church { flex: 1.3; }
.preacher-remove {
  flex-shrink: 0;
  width: 2rem; height: 2rem;
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  color: var(--ink-faint);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.preacher-remove:hover { color: var(--danger); border-color: var(--danger); }
#addPreacher { margin-top: 0.3rem; }

/* ---------- Player ---------- */

.player {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  padding: 0.8rem 0 0.9rem;
  margin: 0 0 0.5rem;
}

.player-main {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.play-btn {
  flex-shrink: 0;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s var(--ease), opacity 0.2s;
}
.play-btn:active { transform: scale(0.94); }
.play-btn[disabled] { opacity: 0.5; }

.player-meta { flex: 1; min-width: 0; }

.player-track {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: var(--rule-strong);
  outline: none;
  cursor: pointer;
  margin: 0.45rem 0 0.3rem;
}
.player-track::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}
.player-track::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

.player-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.player-section-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.55rem;
}
.player-controls .icon-btn { font-size: 0.75rem; font-weight: 600; font-family: var(--sans); }

.speed-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.player-note {
  font-size: 0.74rem;
  color: var(--ink-faint);
  margin-top: 0.5rem;
}

/* ---------- Lists (archive, prayers) ---------- */

.page-title {
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 500;
  margin: 1.8rem 0 1.2rem;
}

.item-list { list-style: none; }
.item-list li {
  border-bottom: 1px solid var(--rule);
  padding: 0.95rem 0;
}
.item-row {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  cursor: pointer;
}
.item-title { font-family: var(--serif); font-size: 1.08rem; flex: 1; }
.item-sub { font-size: 0.78rem; color: var(--ink-faint); white-space: nowrap; }

.empty-note {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-faint);
  padding: 2rem 0;
}

/* ---------- Settings ---------- */

.setting-group { margin-bottom: 2rem; }
.setting-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.5rem;
}
.setting-help {
  font-size: 0.84rem;
  color: var(--ink-soft);
  line-height: 1.55;
  margin-top: 0.5rem;
}
.setting-help a { color: var(--accent); }

.seg {
  display: inline-flex;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  overflow: hidden;
}
.seg button {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.55rem 1rem;
  cursor: pointer;
  border-right: 1px solid var(--rule);
}
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--bg-inset); color: var(--ink); }

select.topic-field { font-family: var(--sans); font-size: 0.92rem; font-style: normal; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1.4rem);
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-raised);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 0.6rem 1.2rem;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  max-width: 88vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 420px) {
  html { font-size: 16px; }
  .reader-title { font-size: 1.7rem; }
  .topbar { padding-left: 1rem; padding-right: 1rem; }
  .view { padding-left: 1rem; padding-right: 1rem; }
}
