* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  transition: background-color 0.2s ease, color 0.2s ease;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

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

/* Lucide Icons (local SVG symbols; consistent weight on desktop and mobile). */
.reader-icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.reader-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}

/* Reading Dimmer: Visual dimming without blocking clicks */
.reading-dimmer-overlay {
  position: fixed;
  inset: 0;
  background-color: #000000;
  opacity: var(--dim-opacity, 0);
  pointer-events: none;
  z-index: 900;
  transition: opacity 0.1s ease;
}

/* Modest Contextual Reader Header (No top logo, site name, home link, or language tabs) */
.reader-header {
  position: sticky;
  top: 0;
  z-index: 800;
  background: var(--bg);
  border-bottom: 1px solid var(--hair);
  padding-top: env(safe-area-inset-top, 0px);
  transition: background-color 0.2s ease;
}

.header-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--warm);
  font-size: 20px;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--hair);
  touch-action: manipulation;
}

.header-back-btn:hover {
  background: var(--surface-hover);
}

.header-center {
  flex: 1;
  text-align: center;
  min-width: 0;
}

.chapter-title {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--warm);
  font-size: 14px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--hair);
  touch-action: manipulation;
}

.header-action-btn:hover {
  background: var(--surface-hover);
}

.header-action-btn .reader-icon { width: 18px; height: 18px; }

/* Main Content Area */
.reader-main {
  flex: 1;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 16px calc(76px + env(safe-area-inset-bottom, 16px));
}

/* Status Banner / Loading / Error */
.status-banner {
  padding: 24px 16px;
  text-align: center;
  border-radius: 8px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--hair);
}

.status-banner.error {
  background: #fdf2f2;
  border-color: #f8b4b4;
  color: #9b1c1c;
}

.retry-btn {
  margin-top: 12px;
  display: inline-block;
  padding: 8px 18px;
  background: var(--bronze);
  color: #ffffff;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  touch-action: manipulation;
}

.retry-btn:hover {
  background: var(--warm);
}

/* ==========================================================
   VIEW 1: Verses Reader
   Plain text reading, no highlight boxes or hover fills.
   ========================================================== */
.verses-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  list-style: none;
}

.verse-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 4px;
  background: transparent;
  scroll-margin-top: 70px;
}

.verse-num {
  flex-shrink: 0;
  width: 28px;
  font-size: 13px;
  font-weight: 700;
  color: var(--bronze);
  font-variant-numeric: tabular-nums;
  padding-top: 4px;
  text-align: right;
  user-select: none;
}

.verse-body {
  flex: 1;
  min-width: 0;
}

.verse-primary-text {
  font-size: var(--reader-font-size, 19px);
  line-height: 1.82;
  color: var(--ink);
  font-feature-settings: "palt" 1;
  word-break: break-word;
}

.verse-primary-text[lang="nan-Hant-TW"] {
  font-family: 'FormosaTaigiHanjiFull', var(--serif);
}

.verse-primary-text[lang="nan-Latn-TW"] {
  font-family: 'FormosaTaigiHanjiFull', var(--latin), sans-serif;
  font-size: calc(var(--reader-font-size, 19px) * 0.96);
  line-height: 1.85;
}

.verse-primary-text[lang="zh-Hant-TW"] {
  font-family: var(--serif);
}

.verse-primary-text[lang="en"] {
  font-family: var(--latin);
  font-size: calc(var(--reader-font-size, 19px) * 0.95);
  line-height: 1.7;
}

/* Comparison / Parallel translation text */
.verse-comparison-container {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--hair);
}

.verse-comparison-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-hover);
  color: var(--warm);
  margin-right: 6px;
  vertical-align: middle;
  text-transform: uppercase;
}

.verse-comparison-text {
  font-size: calc(var(--reader-font-size, 19px) * 0.88);
  line-height: 1.68;
  color: var(--sub);
  word-break: break-word;
}

.verse-comparison-text[lang="nan-Hant-TW"] {
  font-family: 'FormosaTaigiHanjiFull', var(--serif);
}

.verse-comparison-text[lang="nan-Latn-TW"] {
  font-family: 'FormosaTaigiHanjiFull', var(--latin), sans-serif;
  font-size: calc(var(--reader-font-size, 19px) * 0.88);
  line-height: 1.7;
}

.verse-comparison-text[lang="en"] {
  font-family: var(--latin);
}

/* Chapter completion trigger at bottom of chapter */
.chapter-completion-box {
  margin-top: 32px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.mark-completed-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  background: var(--bronze);
  color: #ffffff;
  font-weight: 600;
  font-size: 15px;
  touch-action: manipulation;
}

.mark-completed-btn:hover {
  background: var(--warm);
}

.mark-completed-btn.is-completed {
  background: var(--surface-hover);
  color: var(--warm);
  border: 1px solid var(--hair);
}

/* ==========================================================
   VIEW 2: Books Catalog (66 Books)
   ========================================================== */
.books-view {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.testament-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.testament-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 2px solid var(--hair);
  padding-bottom: 6px;
}

.testament-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--warm);
}

.testament-summary {
  font-size: 13px;
  color: var(--sub);
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 10px;
}

.book-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 10px;
  min-height: 72px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 10px;
  text-decoration: none;
  touch-action: manipulation;
  transition: transform 0.1s ease, background 0.1s ease, border-color 0.1s ease;
}

.book-card:hover {
  background: var(--surface-hover);
  border-color: var(--bronze);
  transform: translateY(-1px);
}

.book-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 4px;
}

.book-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--sub);
  font-variant-numeric: tabular-nums;
}

.book-chapters-badge {
  font-size: 11px;
  color: var(--warm);
  background: var(--surface-hover);
  padding: 1px 5px;
  border-radius: 4px;
}

.book-name-cmn {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.book-name-en {
  font-size: 11px;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* ==========================================================
   VIEW 3: Chapter Index
   ========================================================== */
/* The chapter view is shown with display:flex by the router. Without a
   column direction, its header and grid become two narrow side-by-side items. */
.catalog-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  min-width: 0;
}

.catalog-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 10px;
}

.catalog-item-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--hair);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  touch-action: manipulation;
  font-variant-numeric: tabular-nums;
  position: relative;
}

.catalog-item-btn:hover {
  background: var(--surface-hover);
  border-color: var(--bronze);
}

.catalog-item-btn.is-active {
  background: var(--active-verse-bg);
  border-color: var(--active-verse-border);
  color: var(--warm);
  font-weight: 700;
}

.catalog-item-btn.is-completed::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}

/* ==========================================================
   VIEW 4: Settings
   ========================================================== */
.settings-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-label-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Place every Bible version control below its heading and description.
   Keep the same layout on mobile and desktop to avoid long Chinese labels colliding. */
.settings-row-stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.settings-row-stacked .settings-label-group {
  width: 100%;
  min-width: 0;
}
.settings-row-stacked .settings-select {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  box-sizing: border-box;
}
.settings-row-stacked .toggle-switch {
  height: 44px;
}
.settings-row-stacked .toggle-switch .slider-round {
  top: 8px;
  bottom: 8px;
}

.settings-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.settings-desc {
  font-size: 13px;
  color: var(--sub);
  line-height: 1.4;
}

.settings-select {
  padding: 8px 12px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--hair);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}

/* Switch Toggle */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-round {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--nav-disabled-bg);
  border: 1px solid var(--hair);
  transition: 0.2s;
  border-radius: 28px;
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: 0.2s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .slider-round {
  background-color: var(--bronze);
  border-color: var(--bronze);
}

input:checked + .slider-round:before {
  transform: translateX(20px);
}

.settings-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  color: var(--warm);
  font-weight: 600;
  border-bottom: 1px solid var(--hair);
}

.settings-link-row:last-child {
  border-bottom: none;
}

.settings-link-row .reader-icon { width: 16px; height: 16px; }

.settings-preferences-link {
  width: 100%;
  min-height: 44px;
  text-align: left;
}

.settings-share-link {
  width: 100%;
  min-height: 44px;
  text-align: left;
  cursor: pointer;
}
/* Dedicated LINE account share page: warm paper, quiet focus on the QR code. */
.share-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: 100%;
  padding: clamp(24px, 5vh, 52px) 0 24px;
}

.share-qr-frame {
  width: min(100%, 288px);
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--hair);
  border-radius: 18px;
  box-shadow: 0 5px 24px rgba(74, 53, 32, 0.065);
}

.share-qr-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
}

.share-link-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: min(100%, 420px);
}

.share-official-link {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  min-height: 50px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 11px;
  color: var(--warm);
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
  text-align: center;
}

.share-official-link:hover {
  border-color: var(--bronze);
}

.share-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  min-height: 50px;
  flex: 0 0 50px;
  background: var(--surface);
  border: 1px solid var(--bronze);
  border-radius: 11px;
  color: var(--bronze);
  touch-action: manipulation;
}

.share-copy-btn:hover {
  background: var(--surface-hover);
}

.share-copy-btn .reader-icon {
  width: 20px;
  height: 20px;
}

.share-instruction {
  max-width: 420px;
  color: var(--sub);
  font-size: 14px;
  line-height: 1.65;
  text-align: center;
}

.share-copy-status {
  color: var(--bronze);
  font-size: 13px;
  text-align: center;
}
.share-copy-status[hidden] { display: none; }

.poj-info-note {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--sub);
  font-size: 12px;
}

.poj-info-note .reader-icon { width: 16px; height: 16px; }

.settings-disclaimer {
  font-size: 12px;
  color: var(--sub);
  line-height: 1.5;
  text-align: center;
  padding: 8px 12px;
}

/* ==========================================================
   VIEW 5: Reading History
   ========================================================== */
.history-view {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.continue-reading-card {
  background: var(--surface);
  border: 1.5px solid var(--bronze);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.continue-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--bronze);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.continue-chapter {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.continue-btn {
  padding: 8px 16px;
  background: var(--bronze);
  color: #ffffff;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.continue-btn:hover {
  background: var(--warm);
}

/* Calendar Card */
.calendar-card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 12px;
  padding: 16px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.calendar-month-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.calendar-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  min-height: 36px;
  border-radius: 6px;
  background: var(--surface-hover);
  color: var(--warm);
  font-weight: 700;
  font-size: 16px;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  color: var(--sub);
  margin-bottom: 8px;
  font-weight: 600;
}

.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day-btn {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  position: relative;
  touch-action: manipulation;
}

.calendar-day-btn:hover {
  background: var(--surface-hover);
}

.calendar-day-btn.is-empty {
  visibility: hidden;
  pointer-events: none;
}

.calendar-day-btn.is-today {
  border: 1.5px solid var(--bronze);
  font-weight: 700;
}

.calendar-day-btn.is-selected {
  background: var(--bronze);
  color: #ffffff;
}

.calendar-day-btn.has-activity::after {
  content: "";
  position: absolute;
  bottom: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bronze);
}

.calendar-day-btn.is-selected.has-activity::after {
  background: #ffffff;
}

.day-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.day-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--hair);
  border-radius: 8px;
  text-decoration: none;
}

.day-history-item:hover {
  border-color: var(--bronze);
}

.history-item-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.history-item-badge.completed {
  background: #e6f4ea;
  color: #137333;
}

.history-item-badge.visited {
  background: var(--surface-hover);
  color: var(--warm);
}

.clear-history-box {
  margin-top: 16px;
  text-align: center;
}

.clear-history-btn {
  font-size: 13px;
  color: #9b1c1c;
  padding: 6px 14px;
  border-radius: 6px;
  background: #fdf2f2;
  border: 1px solid #f8b4b4;
}

/* ==========================================================
   VIEW 6: Search
   ========================================================== */
.search-view {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 16px;
}

.search-input-box {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  background: var(--surface);
  border: 1.5px solid var(--hair);
  border-radius: 10px;
  padding: 8px 12px;
  gap: 8px;
}

.search-input-box:focus-within {
  border-color: var(--bronze);
}

.search-input-field {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--ink);
  /* iOS LINE/WKWebView auto-zooms focused inputs smaller than 16px. */
  font-size: 16px;
  font-family: inherit;
  outline: none;
}

.search-submit-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  background: var(--bronze);
  color: #ffffff;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.quick-jump-card {
  background: var(--surface);
  border: 1.5px solid var(--gold);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-decoration: none;
}

.quick-jump-card:hover {
  background: var(--surface-hover);
}

.quick-jump-title {
  font-size: 12px;
  color: var(--gold);
  font-weight: 700;
  text-transform: uppercase;
}

.quick-jump-target {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-result-item {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
}

.search-result-item:hover {
  border-color: var(--bronze);
}

.search-result-ref {
  font-size: 13px;
  font-weight: 700;
  color: var(--bronze);
}

.search-result-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
}

.search-result-text[lang="nan-Hant-TW"] {
  font-family: 'FormosaTaigiHanjiFull', var(--serif);
}

.search-result-text[lang="nan-Latn-TW"] {
  font-family: 'FormosaTaigiHanjiFull', var(--latin), sans-serif;
}

.search-result-text mark {
  background: #ffe082;
  color: #1a1812;
  border-radius: 2px;
  padding: 0 2px;
}

/* ==========================================================
   Reading Preferences Bottom Sheet
   ========================================================== */
.pref-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 950;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.pref-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.pref-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 680px;
  margin: 0 auto;
  background: var(--surface);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  z-index: 960;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom, 12px));
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pref-sheet.is-open {
  transform: translateY(0);
}

.pref-drag-handle {
  width: 40px;
  height: 4px;
  background: var(--hair);
  border-radius: 2px;
  margin: 0 auto 4px;
}

.pref-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pref-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.pref-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--sub);
  padding: 4px 8px;
}

.pref-close-btn .reader-icon { width: 20px; height: 20px; }

.pref-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pref-group-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--sub);
}

.font-size-stepper {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--hair);
  border-radius: 10px;
  overflow: hidden;
}

.stepper-btn {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--warm);
}

.stepper-btn:hover {
  background: var(--surface-hover);
}

.stepper-val {
  width: 60px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  border-left: 1px solid var(--hair);
  border-right: 1px solid var(--hair);
  font-variant-numeric: tabular-nums;
}

.theme-options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.theme-btn {
  padding: 10px 8px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: 1.5px solid var(--hair);
  background: var(--bg);
  color: var(--ink);
  text-align: center;
  touch-action: manipulation;
}

.theme-btn.is-active {
  border-color: var(--bronze);
  background: var(--surface-hover);
  color: var(--warm);
  font-weight: 700;
}

.dimmer-slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dimmer-slider-container .reader-icon { width: 16px; height: 16px; }

.dimmer-slider {
  flex: 1;
  accent-color: var(--bronze);
}

/* ==========================================================
   Persistent Bottom Navigation Bar
   ========================================================== */
.reader-footer-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 700;
  background: var(--bg);
  border-top: 1px solid var(--hair);
  padding-bottom: env(safe-area-inset-bottom, 12px);
  transition: background-color 0.2s ease;
}

.bottom-nav-container {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px;
}

.nav-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--warm);
  text-decoration: none;
  touch-action: manipulation;
  text-align: center;
  box-sizing: border-box;
}

.nav-btn:hover:not(.is-disabled) {
  background: var(--surface-hover);
  color: var(--ink);
}

.nav-btn.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  background: var(--nav-disabled-bg);
  color: var(--nav-disabled);
}

.nav-icon {
  width: 16px;
  height: 16px;
}

/* Mobile responsive adjustments */
@media (max-width: 480px) {
  .header-container {
    padding: 8px 12px;
  }
  .chapter-title {
    font-size: 17px;
  }
  .verse-primary-text {
    font-size: calc(var(--reader-font-size, 19px) * 0.95);
  }
  .verse-item {
    padding: 4px 2px;
    gap: 8px;
  }
  .verse-num {
    width: 24px;
    font-size: 12px;
  }
  .reader-main {
    padding: 12px 12px calc(76px + env(safe-area-inset-bottom, 16px));
  }
  .bottom-nav-container {
    padding: 6px 10px;
    gap: 6px;
  }
  .nav-btn {
    font-size: 14px;
    padding: 8px 6px;
    gap: 4px;
  }
  .books-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
    gap: 8px;
  }
}


/* Local Reader backup controls; collapsed until user explicitly opens them. */
.storage-warning {
  max-width: 680px;
  margin: 12px auto;
  padding: 12px;
  border: 1px solid #cf6d50;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-size: 13px;
}
.storage-warning[hidden], .backup-preview[hidden] { display: none; }

.history-backup-card {
  display: block;
  padding: 0;
  overflow: hidden;
}
.history-backup-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 12px 16px;
  list-style: none;
  cursor: pointer;
}
.history-backup-summary::-webkit-details-marker { display: none; }
.history-backup-summary .reader-icon {
  width: 18px;
  height: 18px;
  color: var(--sub);
  transition: transform 160ms ease;
}
.history-backup-card[open] .history-backup-summary .reader-icon {
  transform: rotate(90deg);
}
.history-backup-card:not([open]) .history-backup-content { display: none; }
.history-backup-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 16px 16px;
}
.history-backup-content p { margin: 0; }
.backup-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.backup-action {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--hair);
  border-radius: 8px;
  color: var(--ink);
  background: var(--bg);
  font-weight: 600;
  font-size: 14px;
}
.backup-action-primary {
  background: var(--bronze);
  color: var(--bg);
}
.backup-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.backup-line-tools {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.backup-text-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.backup-text-panel[hidden] { display: none; }
.backup-textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 120px;
  padding: 10px;
  border: 1px solid var(--hair);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.5 monospace;
  resize: vertical;
  overflow-wrap: anywhere;
}
.backup-preview {
  padding: 12px;
  border: 1px solid var(--hair);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.backup-feedback {
  color: var(--warm);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.backup-clear-box {
  display: flex;
  justify-content: center;
  padding-top: 12px;
  border-top: 1px solid var(--hair);
}
