:root {
  /* Structural tokens only. All brand colors, fonts and shadows are injected
     per-brand via {{BRAND_CSS_VARS}} in order.html (see brands.py). Do NOT
     re-add color tokens here — that's what caused the classics order page to
     render in Bible colors. */
  --r:     12px;
  --rl:    20px;
  --passage-fs: .93rem;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--txt);
  min-height: 100vh;
}

/* ── NAV ── */
.nav {
  background: var(--navy); padding: 0 20px;
  height: 56px; display: flex; align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,.3); position: sticky; top: 0; z-index: 100;
}
.nav-brand { position: absolute; left: 20px; display: flex; align-items: center; gap: 10px; text-decoration: none; }
.nav-cross { color: var(--gold); font-size: 20px; }
.nav-title { color: #fff; font-size: 15px; font-weight: 600; font-family: inherit; }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.btn-nav {
  background: transparent; border: 1.5px solid rgba(255,255,255,.3);
  color: rgba(255,255,255,.85); padding: 6px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: none;
  transition: border-color .2s, color .2s;
}
.btn-nav:hover { border-color: var(--gold); color: var(--gold); }

/* hamburger — hidden on desktop */
.nav-burger {
  display: none; background: none; border: none; cursor: pointer;
  padding: 8px; position: fixed; right: 16px; top: 48px; z-index: 201;
}
.nav-burger span {
  display: block; width: 24px; height: 2px; background: #fff;
  border-radius: 2px; transition: transform .3s, opacity .3s;
}
.nav-burger span + span { margin-top: 6px; }
.nav-burger.open span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.nav-burger.open span:nth-child(2) { opacity: 0; }
.nav-burger.open span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* mobile drawer */
@media (max-width: 680px), (orientation: portrait) {
  .nav-burger { display: block; }
  .nav-brand { position: static; margin: 0 auto; }
  .nav-actions {
    display: none; flex-direction: column; align-items: stretch;
    position: fixed; top: 56px; left: 0; right: 0;
    background: var(--navy); padding: 12px 20px 20px;
    box-shadow: 0 8px 24px rgba(0,0,0,.35); margin: 0;
  }
  .nav-actions.open { display: flex; }
  .nav-actions .btn-nav {
    font-size: 15px; padding: 12px 16px; border-radius: 8px;
    text-align: left; border: none; border-bottom: 1px solid rgba(255,255,255,.1);
  }
  .nav-actions .btn-nav:last-child { border-bottom: none; }
  .nav-actions .btn-nav:hover { background: rgba(255,255,255,.08); }
}

/* ── Main layout ── */
.page { max-width: 760px; margin: 0 auto; padding: 32px 16px 64px; }

/* ── Chapter nav (left sidebar on tablet/desktop; hidden on mobile) ── */
.chapter-nav { display: none; }
.chapter-nav-title {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  color: var(--sub); padding: 14px 16px 10px; flex-shrink: 0; border-bottom: 1px solid var(--bdr);
}
.chapter-nav-links { overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; }
.chapter-nav-link {
  display: block; flex-shrink: 0; padding: 7px 16px; text-decoration: none;
  font-size: .85rem; line-height: 1.35; color: var(--sub);
  border-left: 3px solid transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .15s, color .15s, border-color .15s;
}
.chapter-nav-link:hover { background: rgba(0,0,0,.04); color: var(--txt); }
.chapter-nav-link.active {
  color: var(--navy); border-left-color: var(--gold);
  background: rgba(184,145,74,.1); font-weight: 600;
}
.chapter-nav-link.is-book { font-weight: 700; color: var(--txt); }
.chapter-nav-link.is-nested { padding-left: 28px; font-size: .8rem; }
/* Played-chapter tick (device-local reading progress) */
.chapter-nav-link.is-played { color: var(--txt); }
.chapter-nav-link.is-played::before {
  content: '✓'; color: #4ca64c; font-weight: 700; margin-right: 6px;
}
.passage-card.is-played .passage-ref::after {
  content: '✓'; color: #4ca64c; font-weight: 700; margin-left: 8px; font-size: .9em;
}
/* Scroll targets clear the sticky top bar */
.passage-card, .book-group { scroll-margin-top: 80px; }

@media (min-width: 768px) and (orientation: landscape) {
  .order-shell {
    display: flex; align-items: flex-start; justify-content: center;
    gap: 28px; max-width: 1060px; margin: 0 auto; padding: 0 16px;
  }
  .order-shell > .page {
    flex: 1 1 760px; min-width: 0; max-width: 760px;
    margin: 0; padding-left: 0; padding-right: 0;
  }
  .chapter-nav.is-visible {
    display: flex; flex-direction: column; align-self: flex-start;
    position: sticky; top: 72px; margin-top: 32px;
    width: 232px; flex-shrink: 0; max-height: calc(100vh - 96px);
    background: var(--parch); border: 1px solid var(--bdr);
    border-radius: var(--r); box-shadow: var(--sh); overflow: hidden;
  }
}
body.dark .chapter-nav-link:hover { background: rgba(255,255,255,.06); }
body.dark .chapter-nav-link.active { background: rgba(184,145,74,.14); }

/* ── States ── */
#stateLoading, #stateError, #stateProcessing {
  text-align: center;
  padding: 80px 24px;
}
.spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--bdr);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.state-icon { font-size: 3rem; margin-bottom: 16px; }
.state-title { font-size: 1.4rem; font-weight: 600; margin-bottom: 8px; }
.state-sub { color: var(--sub); line-height: 1.6; }
.state-link { color: var(--navy); font-weight: 500; text-decoration: none; }
.state-link:hover { text-decoration: underline; }

/* ── Order header ── */
.order-header {
  background: var(--navy);
  color: #fff;
  border-radius: var(--rl);
  padding: 28px 28px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shl);
}
.order-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.order-header .sub {
  color: rgba(255,255,255,.65);
  font-size: .9rem;
  margin-bottom: 16px;
}
.order-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: .8rem;
  color: rgba(255,255,255,.9);
}
.badge-gold { background: rgba(184,145,74,.25); border-color: var(--gold); color: var(--gold); }

/* ── Order actions ── */
.order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 28px;
}
/* The book shelf of a multi-book order hides the per-book actions + search until
   a book is opened; this file sets display per component, so [hidden] needs the
   explicit override (same pattern as .ready-hero[hidden] below). */
.order-actions[hidden] { display: none; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--r);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
/* Icon-only secondary action: square button, text label hidden but kept for a11y */
.btn-icon { padding: 10px; width: 42px; justify-content: center; }
.btn-icon > span {
  position: absolute; width: 1px; height: 1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.btn-primary { background: var(--gold); color: #fff; }
.btn-primary:hover { background: var(--gold2); }
.btn-ghost {
  background: #fff;
  color: var(--navy);
  border: 1.5px solid var(--bdr);
}
.btn-ghost:hover { border-color: var(--navy); }
.btn-sm { padding: 7px 14px; font-size: .82rem; }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ── Book shelf (multi-book orders show one book at a time) ──
   The shelf rows reuse each brand's .book-group chrome (defined per page, so the
   colours stay brand-owned); only the neutral bits live here. */
.book-shelf-row { cursor: pointer; }
.book-shelf-row .book-group-header { cursor: pointer; }
.book-shelf-row:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.book-shelf-row.is-pending { opacity: .6; }
.book-shelf-empty { color: var(--sub); font-size: .9rem; padding: 14px 4px; }

.book-back-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.book-back-bar[hidden] { display: none; }
.book-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--bdr);
  background: #fff;
  color: var(--navy);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.book-back-btn:hover { border-color: var(--navy); }
.book-back-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--sub);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.dark .book-back-btn { background: var(--parch); color: #cdd9ea; }

/* ── Passage list ── */
.passage-list { display: flex; flex-direction: column; gap: 16px; }

.passage-card {
  background: #fff;
  border-radius: var(--rl);
  box-shadow: var(--sh);
  overflow: hidden;
  transition: box-shadow .15s;
}
.passage-card:hover { box-shadow: var(--shl); }

.passage-head {
  padding: 20px 24px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.passage-ref {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy);
}
.passage-head-right {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.passage-size {
  font-size: .78rem; color: var(--sub);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.passage-size:empty { display: none; }

/* ── Audio player ── */
.audio-wrap { padding: 16px 24px 0; }
.audio-player {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--cream);
  border-radius: 999px;
  padding: 8px 16px;
}
.play-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
  font-size: 14px;
}
.play-btn:hover { background: var(--navy2); }
.play-btn:active { transform: scale(.94); }
.play-btn.playing { background: var(--gold); }
.progress-wrap {
  flex: 1;
  height: 6px;
  background: var(--bdr);
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 999px;
  width: 0%;
  transition: width .1s linear;
  pointer-events: none;
}
.time-label {
  font-size: .75rem;
  color: var(--sub);
  white-space: nowrap;
  min-width: 38px;
  text-align: right;
}
.hd-toggle {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .5px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1.5px solid var(--bdr);
  background: transparent;
  color: var(--sub);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
  line-height: 1;
}
.hd-toggle:hover { border-color: var(--navy); color: var(--navy); }
.hd-toggle.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

/* ── Passage actions ── */
.passage-actions {
  padding: 14px 24px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Text panel ── */
.text-panel {
  display: none;
  border-top: 1px solid var(--bdr);
  padding: 20px 24px;
  background: var(--parch);
}
.text-panel.open { display: block; }
.text-loading { color: var(--sub); font-size: .9rem; }
.passage-text {
  font-size: var(--passage-fs, .93rem);
  line-height: 1.85;
  color: var(--txt);
  white-space: pre-wrap;
}
.passage-text-label {
  font-size: .78rem;
  color: var(--sub);
  margin-bottom: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--navy);
  color: #fff;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Order book / title header ── */
.order-book-title {
  font-family: var(--font-heading);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.01em;
  color: var(--navy);
  margin-bottom: 20px;
}
.order-book-title:empty { display: none; }
@media (max-width: 600px) {
  .order-book-title { font-size: 1.35rem; margin-bottom: 16px; }
}

/* ── Ready hero CTA ── */
.ready-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy2) 100%);
  color: #fff;
  border-radius: var(--r);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shl);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.ready-hero:hover { transform: translateY(-2px); box-shadow: 0 6px 32px rgba(0,0,0,.18); }
.ready-hero:active { transform: scale(.99); }
.ready-hero[hidden] { display: none; }
.ready-hero-play {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--gold);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(184,145,74,.4);
  animation: hero-pulse 2s ease-in-out infinite;
}
@keyframes hero-pulse {
  0%, 100% { box-shadow: 0 2px 12px rgba(184,145,74,.4); }
  50%      { box-shadow: 0 4px 24px rgba(184,145,74,.7); }
}
.ready-hero-text h2 {
  font-size: 1.1rem; font-weight: 600; margin-bottom: 2px;
}
.ready-hero-text p {
  font-size: .88rem; color: rgba(255,255,255,.7); margin: 0;
}

/* ── Processing banner ── */
.processing-banner[hidden] { display: none; }
.processing-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fffbeb;
  border: 1.5px solid #f6c94e;
  border-radius: var(--r);
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: .88rem;
  color: #7a5c00;
  line-height: 1.5;
}
.processing-banner .banner-spinner {
  width: 18px; height: 18px;
  border: 2.5px solid #f6c94e;
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
.processing-banner strong { font-weight: 600; }

/* ── Skeleton passage card ── */
.passage-card-skeleton {
  background: #fff;
  border-radius: var(--rl);
  box-shadow: var(--sh);
  overflow: hidden;
  padding: 20px 24px;
  opacity: .55;
}
.skel-line {
  background: linear-gradient(90deg, var(--bdr) 25%, #e8ecf1 50%, var(--bdr) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-title { height: 18px; width: 45%; margin-bottom: 16px; }
.skel-bar   { height: 42px; border-radius: 999px; margin-bottom: 14px; }
.skel-btns  { height: 32px; width: 70%; }

/* ── Progress bar (progressive delivery) ── */
.progress-section[hidden] { display: none; }
.progress-section {
  background: #fff;
  border-radius: var(--r);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--sh);
}
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: .88rem;
  color: var(--sub);
}
.progress-header .progress-pct {
  font-weight: 700;
  color: var(--gold);
  font-size: .95rem;
}
.progress-track {
  background: #e8e0d0;
  border-radius: 8px;
  height: 10px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold) 0%, #d4ae5a 100%);
  border-radius: 8px;
  width: 0%;
  transition: width 0.6s ease-out;
}

/* ── Card entrance animation ── */
.passage-card-new {
  animation: cardEntrance 0.4s ease-out;
}
@keyframes cardEntrance {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.new-badge {
  display: inline-block;
  background: var(--gold);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
  animation: badgeFade 5s ease-out forwards;
}
@keyframes badgeFade {
  0%, 80% { opacity: 1; }
  100%    { opacity: 0; }
}

/* ── Passage header download icon ── */
.passage-head-dl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--cream);
  color: var(--navy);
  border: none;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
  text-decoration: none;
}
.passage-head-dl:hover { background: var(--bdr); }

/* ── Search bar ── */
.search-wrap {
  position: relative;
  margin-bottom: 20px;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sub);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 10px 36px 10px 40px;
  border: 1.5px solid var(--bdr);
  border-radius: var(--r);
  font-family: inherit;
  font-size: .93rem;
  background: #fff;
  color: var(--txt);
  outline: none;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--navy); }
.search-input::placeholder { color: #a0aec0; }
.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sub);
  padding: 4px;
  display: none;
  line-height: 1;
  font-size: 1rem;
}
.search-clear.visible { display: block; }
.search-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--sub);
  display: none;
}
.search-empty.visible { display: block; }


.badge-lang img { display: block; border-radius: 2px; }

@media (max-width: 520px) {
  .order-header { padding: 22px 18px 20px; }
  .order-header h1 { font-size: 1.25rem; }
  .passage-head, .audio-wrap, .passage-meta { padding-left: 18px; padding-right: 18px; }
  .text-panel { padding: 16px 18px; }
}

/* ── Passage feedback (star rating) ── */
.feedback-row {
  padding: 0 24px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.star-rating {
  display: inline-flex;
  gap: 2px;
}
.star-rating button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--bdr);
  font-size: 1.3rem;
  line-height: 1;
  transition: color .12s, transform .1s;
}
.star-rating button:hover { transform: scale(1.15); }
.star-rating button.active { color: var(--gold); }
.star-rating button.hover-fill { color: var(--gold2); }
/* ── Comment thread ── */
.comment-thread {
  padding: 12px 24px 16px; border-top: 1px solid var(--bdr);
}
.comment-thread-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.comment-thread-header span { font-size: .82rem; font-weight: 600; color: var(--navy); }
.comment-thread-list {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px;
}
.thread-msg {
  padding: 8px 12px; border-radius: 8px; font-size: .85rem; line-height: 1.5;
  max-width: 85%; word-break: break-word;
}
.thread-msg.customer {
  background: #f5f5f0; border: 1px solid var(--bdr); align-self: flex-start;
}
.thread-msg.admin {
  background: rgba(26,58,92,.08); border: 1px solid rgba(26,58,92,.18); align-self: flex-end;
}
.thread-msg-meta {
  font-size: .72rem; color: #8a7060; margin-bottom: 2px;
}
.thread-input-row {
  display: flex; gap: 8px;
}
.thread-input {
  flex: 1; padding: 8px 12px; border: 1.5px solid var(--bdr); border-radius: 8px;
  font-size: .85rem; color: var(--txt); background: #fff; outline: none;
  font-family: inherit;
}
.thread-input:focus { border-color: var(--navy); }
.thread-send {
  padding: 8px 16px; background: var(--navy); color: #fff; border: none;
  border-radius: 8px; font-size: .82rem; font-weight: 600; cursor: pointer;
}
.thread-send:hover { opacity: .9; }
.thread-send:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 520px) {
  .feedback-row { padding-left: 18px; padding-right: 18px; }
  .comment-thread { padding-left: 18px; padding-right: 18px; }
  .thread-msg { max-width: 95%; }
}

/* ── Passage meta row (below the audio): rating + comment toggle ── */
.passage-meta {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px 0;
}
.passage-head-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--cream); color: var(--navy); border: none; cursor: pointer;
  transition: background .15s; flex-shrink: 0;
}
.passage-head-btn:hover { background: var(--bdr); }
.passage-head-btn .comment-count {
  position: absolute; top: -5px; right: -5px;
  min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box;
  border-radius: 999px; background: var(--gold); color: #fff;
  font-size: .62rem; font-weight: 700; line-height: 16px; text-align: center;
}
.passage-head-btn .comment-count:empty { display: none; }

/* Per-passage inline text show/hide toggle (right side of the meta row) */
.text-toggle-btn {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--cream); color: var(--navy);
  border: 1px solid var(--bdr); cursor: pointer;
  font-family: inherit; font-size: .8rem; font-weight: 500; white-space: nowrap;
  transition: background .15s;
}
.text-toggle-btn:hover { background: var(--bdr); }

/* Comment thread is hidden by default; toggled open inline (under the head, above the player) */
.comment-thread { display: none; }
.comment-thread.open { display: block; }

/* ── Share modal ── */
.share-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.share-overlay.open { display: flex; }
.share-modal {
  background: #fff; border-radius: var(--rl); padding: 28px;
  width: 100%; max-width: 420px; box-shadow: 0 12px 48px rgba(0,0,0,.2);
}
.share-modal h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; color: var(--txt); }
.share-modal p { font-size: .88rem; color: var(--sub); margin-bottom: 16px; line-height: 1.5; }
.share-textarea {
  width: 100%; min-height: 90px; padding: 10px 12px;
  border: 1.5px solid var(--bdr); border-radius: var(--r);
  font-family: inherit; font-size: .9rem; resize: vertical; outline: none;
  transition: border-color .15s; color: var(--txt);
}
.share-textarea:focus { border-color: var(--navy); }
.share-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ── View All Text modal ── */
.viewall-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 300;
  display: none; align-items: flex-start; justify-content: center;
  padding: 24px 16px; overflow-y: auto;
}
.viewall-overlay.open { display: flex; }
.viewall-modal {
  background: #fff; border-radius: var(--rl); padding: 0;
  width: 100%; max-width: 720px; box-shadow: 0 16px 64px rgba(0,0,0,.25);
  margin: 24px 0; position: relative;
}
.viewall-toolbar {
  position: sticky; top: 0; z-index: 2;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-radius: var(--rl) var(--rl) 0 0;
}
.viewall-toolbar h3 { font-size: 1.05rem; font-weight: 600; margin: 0; }
.viewall-zoom {
  display: flex; align-items: center; gap: 6px;
}
.viewall-zoom-btn {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.25);
  color: #fff; font-size: 1.1rem; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
  line-height: 1;
}
.viewall-zoom-btn:hover { background: rgba(255,255,255,.25); }
.viewall-zoom-label {
  font-size: .78rem; min-width: 38px; text-align: center;
  color: rgba(255,255,255,.8);
}
.viewall-close {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.25);
  color: #fff; font-size: 1.2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; margin-left: 12px;
}
.viewall-close:hover { background: rgba(255,255,255,.25); }
.viewall-body {
  padding: 32px 28px 40px;
  font-family: 'Georgia', 'Times New Roman', serif;
  line-height: 1.9;
  color: var(--txt);
}
.viewall-passage { margin-bottom: 36px; }
.viewall-passage:last-child { margin-bottom: 0; }
.viewall-passage-ref {
  font-family: Inter, system-ui, sans-serif;
  font-size: .85em; font-weight: 600;
  color: var(--navy); text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--gold);
  display: inline-block;
}
.viewall-passage-text {
  white-space: pre-wrap;
}
.viewall-loading {
  text-align: center; padding: 48px 24px; color: var(--sub);
  font-family: Inter, system-ui, sans-serif;
}
.viewall-loading .spinner { margin: 0 auto 16px; }

@media (max-width: 520px) {
  .viewall-modal { margin: 8px 0; }
  .viewall-toolbar { padding: 12px 16px; border-radius: var(--r) var(--r) 0 0; }
  .viewall-body { padding: 24px 18px 32px; }
}

/* ── Offline audio cache indicator ─────────────────────────────────────────── */
.cache-indicator {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: var(--navy2); color: #fff;
  font-size: 13px; font-family: Inter, system-ui, sans-serif;
  box-shadow: 0 -2px 8px rgba(0,0,0,.15);
}
.cache-bar {
  flex: 1; height: 4px; background: rgba(255,255,255,.15);
  border-radius: 2px; overflow: hidden;
}
.cache-bar-fill {
  height: 100%; background: var(--gold); border-radius: 2px;
  transition: width .3s ease;
}
.cache-bar-fill.warn { background: #e07c3a; }
.cache-bar-fill.full { background: #e04040; }
.cache-label { white-space: nowrap; opacity: .85; min-width: 90px; }
.cache-btn {
  background: none; border: 1px solid rgba(255,255,255,.25); color: #fff;
  border-radius: 6px; padding: 3px 10px; font-size: 12px; cursor: pointer;
  transition: background .15s;
}
.cache-btn:hover { background: rgba(255,255,255,.12); }

/* Cached badge on passage cards */
.cached-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; color: #6cbf6c; opacity: .8; margin-left: 6px;
}
.cached-badge svg { width: 12px; height: 12px; }

/* Offline unavailable state */
.play-btn.offline-unavail { opacity: .35; pointer-events: none; }
.play-btn.offline-unavail::after {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(0,0,0,.08) 3px, rgba(0,0,0,.08) 5px);
  border-radius: inherit;
}

/* Cache settings modal */
.cache-settings-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center;
}
.cache-settings-modal {
  background: #fff; border-radius: var(--rl); padding: 28px 24px;
  max-width: 360px; width: 90%; box-shadow: var(--shl);
  color: var(--txt);
}
.cache-settings-modal h3 { margin-bottom: 16px; font-size: 17px; }
.cache-settings-modal label { display: block; font-size: 14px; margin-bottom: 6px; color: var(--sub); }
.cache-settings-modal input[type=range] { width: 100%; margin: 4px 0 12px; }
.cache-settings-modal .cache-limit-val { font-weight: 600; font-size: 15px; }
.cache-settings-modal .cache-stats { font-size: 13px; color: var(--sub); margin: 12px 0 16px; }
.cache-settings-clear {
  background: #e04040; color: #fff; border: none; border-radius: 8px;
  padding: 8px 18px; font-size: 14px; cursor: pointer; width: 100%;
}
.cache-settings-clear:hover { background: #c83030; }
.cache-settings-close {
  background: var(--navy); color: #fff; border: none; border-radius: 8px;
  padding: 8px 18px; font-size: 14px; cursor: pointer; width: 100%; margin-top: 8px;
}

/* Pad body so fixed cache bar doesn't overlap content */
body.has-cache-bar { padding-bottom: 40px; }

/* ── RESPONSIVE: 480px ── */
@media (max-width: 480px) {
  .share-modal { padding: 20px 16px; }
}

/* ── RESPONSIVE: 374px (small Android, 360px min) ── */
@media (max-width: 374px) {
  .page { padding: 24px 10px 48px; }
  .order-header { padding: 18px 14px 16px; border-radius: 14px; }
  .order-header h1 { font-size: 1.1rem; }
  .passage-head, .audio-wrap, .passage-meta { padding-left: 12px; padding-right: 12px; }
  .text-panel { padding: 12px; }
  .audio-player { padding: 6px 10px; gap: 8px; }
  .time-label { font-size: .7rem; min-width: 32px; }
  .hd-toggle { font-size: .6rem; padding: 1px 4px; }
  .feedback-row, .comment-thread { padding-left: 12px; padding-right: 12px; }
  .share-modal { max-width: 100%; padding: 16px 12px; }
  .viewall-body { padding: 16px 12px 24px; }
  .cache-settings-modal { padding: 20px 16px; }
}

/* ── Reading controls (nav: dark mode + passage font size) ── */
.reader-controls {
  display: inline-flex; align-items: center; gap: 18px;
  margin-left: 4px; padding-left: 10px;
  border-left: 1px solid rgba(255,255,255,.08);
}
.font-control { display: inline-flex; align-items: center; gap: 5px; }
.font-btn {
  width: 32px; height: 32px; border-radius: 8px;
  background: transparent; border: 1px solid rgba(255,255,255,.16);
  color: rgba(255,255,255,.6); cursor: pointer; font-family: inherit; line-height: 1; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
}
.font-btn:hover { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.3); }
.font-btn.lg { font-size: 1.2rem; }
.font-btn.sm { font-size: .9rem; }
.font-label {
  font-size: .85rem; color: rgba(255,255,255,.45);
  min-width: 40px; text-align: center; font-variant-numeric: tabular-nums;
}
.theme-switch {
  display: inline-flex; align-items: center;
  background: none; border: none; padding: 0; cursor: pointer;
}
.theme-switch .track {
  position: relative; width: 48px; height: 26px;
  background: rgba(255,255,255,.1); border-radius: 999px; transition: background .2s;
}
.theme-switch .thumb {
  position: absolute; left: 3px; top: 3px; width: 20px; height: 20px;
  background: rgba(255,255,255,.85); border-radius: 50%; transition: transform .2s, background .2s;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1; color: var(--navy);
}
body.dark .theme-switch .track { background: var(--gold); }
body.dark .theme-switch .thumb { transform: translateX(22px); background: #fff; }

/* HD audio quality toggle (nav) — pill switch, on = 320 kbps, off = 128 kbps */
.hd-switch {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: none; padding: 0; cursor: pointer;
  color: rgba(255,255,255,.55); font-family: inherit;
  font-size: .72rem; font-weight: 700; letter-spacing: .05em;
}
.hd-switch .hd-switch-label { transition: color .2s; }
.hd-switch.on .hd-switch-label { color: var(--gold); }
.hd-switch .hd-switch-track {
  position: relative; width: 40px; height: 22px;
  background: rgba(255,255,255,.14); border-radius: 999px; transition: background .2s;
}
.hd-switch .hd-switch-thumb {
  position: absolute; left: 3px; top: 3px; width: 16px; height: 16px;
  background: rgba(255,255,255,.85); border-radius: 50%; transition: transform .2s, background .2s;
}
.hd-switch.on .hd-switch-track { background: var(--gold); }
.hd-switch.on .hd-switch-thumb { transform: translateX(18px); background: #fff; }

@media (max-width: 680px), (orientation: portrait) {
  /* In the mobile drawer the controls stack below the links as a centered row */
  .nav-actions .reader-controls {
    border-left: none; padding-left: 0; margin: 8px 0 0;
    padding-top: 12px; border-top: 1px solid rgba(255,255,255,.1);
    justify-content: center;
  }
}

/* ── Dark mode ── */
/* Dark-mode palette variables are injected per-brand via
   {{BRAND_CSS_VARS_DARK}} into body.dark in order.html (see brands.py "dark").
   Only element-level dark rules live below. */
body.dark .passage-card,
body.dark .passage-card-skeleton,
body.dark .progress-section,
body.dark .btn-ghost,
body.dark .search-input,
body.dark .thread-input,
body.dark .share-modal,
body.dark .share-textarea,
body.dark .cache-settings-modal { background: var(--parch); color: var(--txt); }
body.dark .btn-ghost { color: #cdd9ea; }
body.dark .thread-msg.customer { background: #232c38; }
body.dark .search-input::placeholder { color: #6b7787; }
body.dark .skel-line {
  background: linear-gradient(90deg, var(--bdr) 25%, #38424f 50%, var(--bdr) 75%);
  background-size: 200% 100%;
}

/* ── Chapters trigger button (mobile only — desktop has the sidebar) ────────── */
.chapters-btn { display: none; }
@media (max-width: 767px), (orientation: portrait) { .chapters-btn { display: inline-flex; } }

/* ── Mobile chapter nav as a slide-up bottom sheet ─────────────────────────── */
/* Reuses the same .chapter-nav aside + #chapterNavLinks as the desktop sidebar. */
.chapter-sheet-handle { display: none; }
.chapter-sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 155; opacity: 0; pointer-events: none; transition: opacity .25s;
}
.chapter-sheet-backdrop.open { opacity: 1; pointer-events: auto; }
@media (min-width: 768px) and (orientation: landscape) { .chapter-sheet-backdrop { display: none; } }

@media (max-width: 767px), (orientation: portrait) {
  .chapter-sheet-handle {
    display: block; width: 40px; height: 4px; border-radius: 999px;
    background: var(--bdr); margin: 10px auto 2px; flex-shrink: 0; cursor: pointer;
  }
  .chapter-nav.is-visible {
    display: flex; flex-direction: column;
    position: fixed; left: 0; right: 0; bottom: 0;
    max-height: 72vh; width: auto; z-index: 160;
    background: var(--parch); border: 1px solid var(--bdr); border-bottom: none;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 32px rgba(0,0,0,.28);
    transform: translateY(100%); visibility: hidden;
    transition: transform .3s cubic-bezier(.4,0,.2,1), visibility .3s;
  }
  .chapter-nav.is-visible.sheet-open { transform: translateY(0); visibility: visible; }
  body.sheet-locked { overflow: hidden; }
}

/* ── Persistent mini-player (sticky bottom bar, mobile + desktop) ───────────── */
#miniPlayer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 140;
  display: none; flex-direction: column;
  background: var(--navy); color: #fff;
  box-shadow: 0 -2px 16px rgba(0,0,0,.28);
}
#miniPlayer.show { display: flex; }
body.has-cache-bar #miniPlayer { bottom: 40px; }
body.has-mini-player { padding-bottom: 64px; }
body.has-mini-player.has-cache-bar { padding-bottom: 104px; }

.mini-progress {
  height: 4px; width: 100%; background: rgba(255,255,255,.18);
  cursor: pointer; position: relative; flex-shrink: 0; touch-action: none;
}
.mini-progress-fill {
  height: 100%; width: 0%; background: var(--gold);
  pointer-events: none; transition: width .1s linear;
}
.mini-row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; }
.mini-title {
  flex: 1; min-width: 0; font-size: .9rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mini-controls { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.mini-btn {
  background: none; border: none; color: #fff; cursor: pointer;
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s; flex-shrink: 0;
}
.mini-btn:hover { background: rgba(255,255,255,.14); }
.mini-btn:active { transform: scale(.92); }
.mini-btn:disabled { opacity: .35; cursor: not-allowed; pointer-events: none; }
.mini-btn.mini-play { background: var(--gold); width: 42px; height: 42px; }
.mini-btn.mini-play:hover { background: var(--gold2); }
.mini-time {
  font-size: .72rem; color: rgba(255,255,255,.72); white-space: nowrap;
  min-width: 78px; text-align: right; font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.mini-chapters-btn { display: none; }
@media (max-width: 767px), (orientation: portrait) {
  .mini-time { min-width: 0; }
  .mini-chapters-btn { display: flex; }
}


/* ── My Orders (the order page doubles as the /orders page) ── */
/* Level 1 — the /orders shelf: one card per order, chapters never shown here.
   The status filter is styled as a segmented control on purpose: only an order
   card may ever carry the "current order" look. */
.orders-shelf[hidden] { display: none; }
.orders-shelf { margin: 0 0 24px; }
.orders-shelf-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.orders-bar-title {
  font-size: .78rem; font-weight: 600; color: var(--sub);
  text-transform: uppercase; letter-spacing: .05em;
}
.orders-filter { display: inline-flex; border: 1.5px solid var(--bdr); border-radius: 10px; overflow: hidden; }
.orders-filter[hidden] { display: none; }
.orders-filter-btn {
  padding: 6px 14px; border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: .78rem; font-weight: 600; color: var(--sub);
  transition: background .15s, color .15s;
}
.orders-filter-btn + .orders-filter-btn { border-left: 1px solid var(--bdr); }
.orders-filter-btn.active { background: var(--navy); color: #fff; }
body.dark .orders-filter-btn.active { background: #cdd9ea; color: #16202e; }

.orders-shelf-list { display: flex; flex-direction: column; gap: 10px; }
.order-card {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  border: 1px solid var(--bdr); border-radius: var(--r);
  background: var(--parch); box-shadow: var(--sh);
  color: var(--txt); text-decoration: none;
  transition: border-color .15s;
}
.order-card:hover { border-color: var(--navy); }
.order-card.archived { opacity: .7; }
.order-card-cover {
  width: 42px; height: 60px; object-fit: cover; border-radius: 4px;
  flex-shrink: 0; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.order-card-body { flex: 1; min-width: 0; }
.order-card-title {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font-weight: 600; font-size: .95rem; margin-bottom: 4px;
}
.order-card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-card-more { color: var(--sub); font-weight: 500; font-size: .8rem; flex-shrink: 0; }
.order-card-badge {
  flex-shrink: 0; padding: 2px 8px; border: 1px solid var(--bdr); border-radius: 999px;
  font-size: .64rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--sub);
}
.order-card-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: .78rem; color: var(--sub);
}
.order-card-bar {
  width: 90px; height: 5px; border-radius: 3px; background: rgba(0,0,0,.1);
  overflow: hidden; flex-shrink: 0;
}
.order-card-bar-fill { display: block; height: 100%; background: var(--gold); border-radius: 3px; }
body.dark .order-card-bar { background: rgba(255,255,255,.14); }
.order-card-chevron { color: var(--sub); font-size: .7rem; flex-shrink: 0; }
.orders-shelf-empty { text-align: center; color: var(--sub); font-size: .88rem; padding: 24px 0; }

/* Level 2 — direct /order/{token} visit: slim return bar back to the shelf.
   Sticks just below the 56px nav so the open order keeps its context in view. */
.orders-return[hidden] { display: none; }
.orders-return {
  position: sticky; top: 56px; z-index: 90;
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 16px; padding: 8px 0;
  background: var(--cream);
}
.orders-return-link {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 6px 13px; border: 1.5px solid var(--bdr); border-radius: 999px;
  background: var(--parch); color: var(--navy);
  font-size: .82rem; font-weight: 600; text-decoration: none;
  transition: border-color .15s;
}
.orders-return-link:hover { border-color: var(--navy); }
.orders-return-title {
  font-size: .88rem; font-weight: 600; color: var(--sub);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
