:root {
  --bg: #F9F7F2;
  --bg-card: #FFFFFF;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --border: #e5e0d5;
  --accent: #2563EB;
  --accent-hover: #1d4ed8;
  --mark-bg: #FEF08A;
  --radius-pill: 999px;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  --font-serif: Georgia, 'Libre Baskerville', 'Times New Roman', serif;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-scale: 1;
}

:root[data-theme="dark"] {
  --bg: #111827;
  --bg-card: #1f2937;
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --border: #374151;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --mark-bg: #854d0e;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

:root[data-theme="sepia"] {
  --bg: #F4ECD8;
  --bg-card: #FBF6EA;
  --text: #3d2f1e;
  --text-muted: #7a6548;
  --border: #dcc9a8;
  --accent: #8b5a2b;
  --accent-hover: #6d4520;
  --mark-bg: #f5d76e;
  --shadow: 0 8px 30px rgba(61, 47, 30, 0.12);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
}

body {
  transition: background 0.2s, color 0.2s, padding-bottom 0.2s;
}

body.has-pagination {
  padding-bottom: 68px;
}

/* ── Fixed top: header + search + back ── */
.sticky-top {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  box-shadow: 0 1px 12px rgba(0, 0, 0, 0.04);
}

.site-header {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 14px 10px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  min-height: 40px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-title {
  margin: 0;
  padding: 0;
  min-width: 0;
  text-align: left;
  font-family: var(--font-serif);
  font-size: clamp(1.05rem, 2.4vw, 1.45rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.header-title a {
  color: var(--text);
  text-decoration: none;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-title a:hover {
  color: var(--accent);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(34px * var(--font-scale));
  height: calc(34px * var(--font-scale));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.header-icon-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.header-icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.header-icon-btn svg.hidden {
  display: none;
}

.header-search-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.header-search-row .search-wrap {
  flex: 1;
  min-width: 0;
}

.search-scope-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-pill);
  padding: calc(8px * var(--font-scale)) calc(14px * var(--font-scale));
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.search-scope-btn svg {
  flex-shrink: 0;
  opacity: 0.95;
}

.search-scope-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 3px 14px color-mix(in srgb, var(--accent) 50%, transparent);
}

.search-scope-btn:active {
  transform: scale(0.97);
}

.search-scope-btn.hidden {
  display: none;
}

@media (min-width: 720px) {
  .header-search-row {
    gap: 10px;
  }
}

.header-text-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--radius);
  padding: calc(6px * var(--font-scale)) calc(12px * var(--font-scale));
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.header-text-btn:hover,
.header-text-btn[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.header-text-btn.hidden {
  display: none;
}

.history-wrap {
  position: relative;
}

.search-history-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 130;
  width: min(320px, calc(100vw - 32px));
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.reading-progress-bar {
  height: 3px;
  background: var(--border);
  pointer-events: none;
}

.reading-progress-bar.hidden {
  display: none;
}

.reading-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.12s ease-out;
}

:root {
  --reader-content-width: 680px;
}

.reader-nav-bar {
  background: var(--bg);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}

.reader-nav-bar-inner {
  display: grid;
  grid-template-columns: 1fr minmax(0, var(--reader-content-width)) 1fr;
  align-items: center;
  gap: 8px;
  padding: 5px 16px;
  max-width: 1100px;
  margin: 0 auto;
}

.reader-nav-side--left {
  justify-self: start;
}

.reader-nav-side--right {
  justify-self: end;
  min-width: 0;
}

.reader-chapter-nav {
  display: grid;
  grid-template-columns: auto 32px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.reader-autoscroll {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.autoscroll-btn {
  width: calc(28px * var(--font-scale));
  height: calc(28px * var(--font-scale));
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  border-radius: var(--radius);
  font-size: calc(11px * var(--font-scale));
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.autoscroll-btn:hover,
.autoscroll-btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

.autoscroll-btn.is-active {
  background: rgba(37, 99, 235, 0.08);
}

.autoscroll-speed {
  height: calc(28px * var(--font-scale));
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  border-radius: var(--radius);
  font-size: calc(11px * var(--font-scale));
  padding: 0 calc(4px * var(--font-scale));
  min-width: calc(84px * var(--font-scale));
  max-width: calc(96px * var(--font-scale));
  cursor: pointer;
}

.reader-back-compact {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: calc(5px * var(--font-scale)) calc(10px * var(--font-scale));
  font-size: calc(12px * var(--font-scale));
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.reader-back-compact:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.reader-chapter-search {
  flex-shrink: 0;
  font-size: calc(11px * var(--font-scale));
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.reader-chapter-search.is-empty {
  color: #b45309;
}

@media (max-width: 640px) {
  .reader-nav-bar-inner {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .reader-nav-side--left,
  .reader-nav-side--right {
    justify-self: stretch;
  }

  .reader-chapter-search {
    width: 100%;
    text-align: center;
  }

  .reader-autoscroll {
    justify-self: start;
  }
}

body.is-reading .reader-panel {
  margin-top: 4px;
}

.font-size-control {
  display: flex;
  gap: 4px;
}

.ctrl-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  border-radius: var(--radius);
  width: calc(32px * var(--font-scale));
  height: calc(32px * var(--font-scale));
  font-size: calc(13px * var(--font-scale));
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.ctrl-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ctrl-label {
  font-size: calc(11px * var(--font-scale));
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.reading-theme-select {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--radius);
  padding: calc(6px * var(--font-scale)) calc(8px * var(--font-scale));
  font-size: calc(12px * var(--font-scale));
  cursor: pointer;
}

@media (max-width: 719px) {
  .site-header {
    padding: 8px 10px 10px;
  }

  .header-top {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 8px;
  }

  .header-left {
    flex: none;
    width: 100%;
    gap: 8px;
  }

  .header-title {
    font-size: clamp(1rem, 4.2vw, 1.25rem);
    flex: 1;
    min-width: 0;
  }

  .header-controls {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .header-controls::-webkit-scrollbar {
    display: none;
  }

  .header-text-btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  .theme-btn {
    width: 30px;
    height: 30px;
  }

  .search-scope-btn {
    padding: 8px 12px;
    font-size: 12px;
    max-width: 46%;
  }

  .search-scope-btn-label {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #fullscreen-btn {
    flex-shrink: 0;
  }

  .ctrl-label { display: none; }
}

@media (max-width: 520px) {
  .header-search-row.has-scope-btn {
    flex-wrap: wrap;
  }

  .header-search-row.has-scope-btn .search-wrap {
    flex: 1 1 100%;
    width: 100%;
  }

  .header-search-row.has-scope-btn .search-scope-btn {
    flex: 1 1 100%;
    width: 100%;
    max-width: none;
    padding: 10px 14px;
    font-size: 13px;
  }
}

.header-icon-btn svg.hidden {
  display: none;
}

.chapter-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(4px * var(--font-scale)) calc(10px * var(--font-scale));
  background: transparent;
  border: none;
  border-radius: var(--radius);
  font-size: calc(12px * var(--font-scale));
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 719px) {
  .chapter-context {
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
  }
}

.ctx-clear {
  display: none;
}

.search-wrap {
  position: relative;
}

.search-input {
  width: 100%;
  padding: calc(8px * var(--font-scale)) calc(40px * var(--font-scale)) calc(8px * var(--font-scale)) calc(14px * var(--font-scale));
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: calc(15px * var(--font-scale));
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration {
  -webkit-appearance: none;
  display: none;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  max-height: 240px;
  overflow-y: auto;
}

.history-list li { margin: 0; }

.history-item-btn {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--text);
}

.history-item-btn:hover {
  background: rgba(37, 99, 235, 0.06);
}

.history-item-text {
  display: block;
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-meta {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-muted);
}

.history-empty {
  padding: 16px 14px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.history-settings {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.history-retention-label {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
}

.history-retention-select {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--radius);
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}

.history-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.history-delete-btn:hover {
  border-color: #dc2626;
  color: #dc2626;
}

.search-clear {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  display: none;
}

.search-clear.visible { display: block; }

.search-subnav {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 10px;
}

.back-to-books {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.back-to-books:hover { color: var(--accent); }

.back-icon {
  font-size: 16px;
  line-height: 1;
}

/* ── Main content ── */
.page-body {
  max-width: 100%;
}

.hero {
  text-align: center;
  padding: 28px 16px 16px;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  margin: 0 0 6px;
  font-weight: 700;
}

.hero p {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
}

.theme-switch {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-card);
  flex-shrink: 0;
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(32px * var(--font-scale));
  height: calc(32px * var(--font-scale));
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.theme-btn:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.theme-btn.active {
  background: var(--accent);
  color: #fff;
}

.theme-btn + .theme-btn {
  border-left: 1px solid var(--border);
}

.theme-btn.active + .theme-btn,
.theme-btn + .theme-btn.active {
  border-left-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.lang-switch {
  display: inline-flex;
  gap: 0;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
  padding: calc(8px * var(--font-scale)) calc(16px * var(--font-scale));
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lang-btn:hover {
  color: var(--text);
  background: var(--surface-hover, rgba(0, 0, 0, 0.04));
}

.lang-btn.active {
  background: var(--accent, #2563eb);
  color: #fff;
}

.lang-switch--header {
  margin-bottom: 0;
  flex-shrink: 0;
}

.lang-switch--header .lang-btn {
  padding: calc(6px * var(--font-scale)) calc(10px * var(--font-scale));
  font-size: calc(12px * var(--font-scale));
  min-width: calc(36px * var(--font-scale));
}

@media (max-width: 640px) {
  .lang-switch--header .lang-btn {
    padding: 6px 8px;
    min-width: 32px;
  }
}

.browse-wrap {
  max-width: 900px;
  margin: 0 auto 48px;
  padding: 0 16px;
}

.browse-hint,
.chapter-picker-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 20px;
}

.testament-section { margin-bottom: 32px; }
.testament-section:last-child { margin-bottom: 0; }

.testament-heading {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  margin: 0 0 14px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

@media (max-width: 800px) {
  .book-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 480px) {
  .book-grid { grid-template-columns: repeat(2, 1fr); }
}

.book-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.book-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.chapter-picker {
  max-width: 720px;
  margin: 16px auto 48px;
  padding: 0 16px;
}

.chapter-picker-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 8px;
}

.book-nav-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--radius);
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.book-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.chapter-picker-title {
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  margin: 0;
  font-weight: 700;
  text-align: center;
  flex: 1;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 10px;
}

@media (max-width: 640px) {
  .chapter-grid { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 400px) {
  .chapter-grid { grid-template-columns: repeat(4, 1fr); }
}

.chapter-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--radius);
  padding: 14px 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.chapter-btn:hover {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.06);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.text-link-btn {
  display: block;
  margin: 28px auto 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
}

.text-link-btn:hover { color: var(--accent); }

/* ── Search results (main content) ── */
.results-panel {
  display: none;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 24px;
}

.results-panel.visible { display: block; }

.count-banner {
  text-align: center;
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 20px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.count-banner strong {
  color: var(--text);
  font-weight: 700;
}

.results-filters {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.testament-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.tab-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active,
.tab-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(37, 99, 235, 0.06);
}

.book-filter-panel summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}

.book-filter-summary {
  color: var(--text-muted);
  font-weight: 500;
}

.book-filter-actions {
  display: flex;
  gap: 12px;
  margin: 10px 0;
}

.filter-action-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.filter-action-btn:hover {
  text-decoration: underline;
}

.results-collapse-actions {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  margin: 0 0 10px;
  padding: 0 2px;
}

.results-collapse-actions.hidden {
  display: none;
}

.book-filter-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px 12px;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px 0;
}

.book-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.book-filter-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-filter-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.book-group { margin-bottom: 12px; }

.match-tier-section {
  margin-bottom: 20px;
}

.match-tier-heading {
  margin: 0 0 10px;
  padding: 0 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.book-heading-bar,
.chapter-heading-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.book-heading-bar {
  padding: 8px 14px;
  background: rgba(37, 99, 235, 0.06);
  border-radius: var(--radius);
  margin-bottom: 0;
}

.chapter-heading-bar {
  padding: 6px 14px 6px 20px;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 6px;
  margin: 6px 0 0;
  border-top: none;
}

.book-heading-bar:hover,
.chapter-heading-bar:hover {
  background: rgba(37, 99, 235, 0.1);
}

.collapse-chevron {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
  width: 14px;
}

.collapsible-toggle.is-collapsed .collapse-chevron {
  transform: rotate(-90deg);
}

.book-heading {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  flex: 1;
}

.chapter-heading {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0;
  flex: 1;
}

.book-count-badge,
.chapter-count-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.book-body,
.chapter-body {
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.book-body.collapsed,
.chapter-body.collapsed {
  display: none;
}

.chapter-group { margin-bottom: 4px; }

.verse-block {
  margin-bottom: 0;
  padding: 10px 12px 12px 28px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: 0;
  transition: background 0.12s;
}

.verse-block:last-child { border-bottom: none; }

.verse-block:hover {
  background: rgba(37, 99, 235, 0.06);
}

.verse-ref {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.verse-text {
  font-family: var(--font-serif);
  font-size: calc(16px * var(--font-scale));
  line-height: 1.75;
}

mark {
  background: var(--mark-bg);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

mark.mark--current {
  background: #facc15;
  outline: 2px solid #ca8a04;
  border-radius: 2px;
}

:root[data-theme="dark"] mark.mark--current {
  background: #a16207;
  outline-color: #fbbf24;
}

.loading, .empty, .error {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 15px;
}

.error { color: #dc2626; }

.hidden { display: none !important; }

/* ── Fixed bottom pagination ── */
.pagination-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}

.page-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-info {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  min-width: 180px;
}

/* ── Reader ── */
.reader-panel {
  max-width: var(--reader-content-width);
  margin: 8px auto 48px;
  padding: 0 16px;
  padding-right: 72px;
}

@media (max-width: 640px) {
  .reader-panel { padding-right: 16px; }
}

.reader-toolbar-bottom {
  margin-top: 20px;
  margin-bottom: 48px;
}

.reader-toolbar-bottom .reader-chapter-nav {
  padding-top: 8px;
  border-top: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
}

.reader-title {
  font-family: var(--font-serif);
  font-size: clamp(
    calc(1rem * var(--font-scale)),
    calc(2.5vw * var(--font-scale)),
    calc(1.35rem * var(--font-scale))
  );
  margin: 0;
  font-weight: 700;
  text-align: center;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}

.reader-title:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.reader-title:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .reader-toolbar-bottom {
    margin-bottom: 64px;
  }
}

.reader-ch-nav {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--radius);
  width: calc(32px * var(--font-scale));
  height: calc(32px * var(--font-scale));
  font-size: calc(15px * var(--font-scale));
  cursor: pointer;
  flex-shrink: 0;
}

.reader-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.reader-ch-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.reader-body {
  font-family: var(--font-serif);
  font-size: calc(17px * var(--font-scale));
  line-height: 1.85;
}

.reader-verse {
  margin-bottom: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  scroll-margin-top: calc(var(--sticky-header-height, 120px) + 12px);
}

.reader-verse--target {
  background: rgba(254, 240, 138, 0.35);
  outline: 1px solid var(--mark-bg);
}

.reader-verse-num {
  color: var(--text-muted);
  font-size: calc(11px * var(--font-scale));
  font-weight: 700;
  margin-right: 6px;
  user-select: text;
  -webkit-user-select: text;
}

.reader-verse-text {
  color: var(--text);
  user-select: text;
  -webkit-user-select: text;
}

/* ── Fixed right occurrence nav ── */
.reader-goto-top {
  position: fixed;
  right: 16px;
  bottom: 88px;
  z-index: 95;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--radius);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.reader-goto-top:hover {
  border-color: var(--accent);
  color: var(--accent);
}

body.has-pagination .reader-goto-top {
  bottom: 120px;
}

@media (max-width: 640px) {
  .reader-goto-top {
    right: 8px;
    bottom: 96px;
    width: 36px;
    height: 36px;
  }

  body.has-pagination .reader-goto-top {
    bottom: 128px;
  }
}

.occ-nav-fixed {
  position: fixed;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 72px;
}

@media (max-width: 640px) {
  .occ-nav-fixed {
    right: 8px;
    padding: 10px 8px;
    min-width: 60px;
  }
}

.reader-occ-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
}

.reader-occ-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.reader-occ-hint {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
  max-width: 80px;
}

.occ-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius);
  width: 40px;
  height: 36px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.occ-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.occ-btn:not(:disabled):hover {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.06);
}

/* ── Site footer ── */
.site-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 20px 16px 28px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

body.has-pagination .site-footer {
  padding-bottom: 72px;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  margin-bottom: 12px;
}

.footer-nav a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.footer-nav a:hover {
  text-decoration: underline;
}

.footer-copy {
  margin: 0 0 10px;
  line-height: 1.5;
}

.footer-copy a {
  color: var(--accent);
  text-decoration: none;
}

.footer-copy a:hover {
  text-decoration: underline;
}

.footer-contact {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  font-size: 12px;
}

.footer-contact a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-contact a:hover {
  color: var(--accent);
}
