/* 全站与阅读器锁定水平晃动 */
html, body {
  overflow-x: hidden !important;
  width: 100%;
  max-width: 100vw;
}

/* ============================================================
   佛学文化资料馆 - 核心阅览器样式 (双模合一：流式大字电子书 + 原版PDF)
   ============================================================ */

:root {
  --bg-page: #f7f2e4;
  --bg-card: #fffdf9;
  --bg-header: rgba(247, 242, 228, 0.96);
  --border-subtle: #e5d8c3;
  --text-main: #2a231b;
  --text-sub: #786957;
  --title-red: #8d3a2a;
  --gold-accent: #b38841;
  --green-btn: #134e34;
  --green-btn-hover: #1b6343;
  --toc-hover: #f1e7d2;
  --font-serif: "Songti SC", "SimSun", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  --font-sans: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ebook-font-size: 20px;
}

/* 主题定制 */
body.theme-white {
  --bg-page: #fbfbfb;
  --bg-card: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.96);
  --border-subtle: #e8e8e8;
  --text-main: #222222;
  --text-sub: #666666;
  --toc-hover: #f4f4f4;
}

body.theme-sepia {
  --bg-page: #f6f0df;
  --bg-card: #fdfaf2;
  --bg-header: rgba(246, 240, 223, 0.96);
  --border-subtle: #e2d4be;
  --text-main: #2d241d;
  --text-sub: #736453;
  --toc-hover: #ece0c9;
}

body.theme-dark {
  --bg-page: #151518;
  --bg-card: #1c1c20;
  --bg-header: rgba(21, 21, 24, 0.96);
  --border-subtle: #2d2d34;
  --text-main: #d3c9b8;
  --text-sub: #8e887d;
  --title-red: #dfb15b;
  --gold-accent: #dfb15b;
  --green-btn: #2b3a32;
  --green-btn-hover: #374a40;
  --toc-hover: #26262c;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
  overflow-x: hidden;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ================= 顶栏导航 ================= */
.reader-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  background: var(--bg-header);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-center {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.reader-header h1 {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--title-red);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.reader-subtitle {
  font-size: 11px;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 按钮通用 */
.back-link,
.header-btn,
.download-link {
  height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  transition: all 0.15s ease;
}

.back-link:hover,
.header-btn:hover,
.download-link:hover {
  border-color: var(--gold-accent);
  color: var(--title-red);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.toc-btn {
  font-weight: 600;
}

/* ================= 模式切换胶囊 (电子书 vs 原版PDF) ================= */
.mode-switch-group {
  display: flex;
  background: rgba(0, 0, 0, 0.05);
  padding: 2px;
  border-radius: 18px;
  border: 1px solid var(--border-subtle);
}

body.theme-dark .mode-switch-group {
  background: rgba(255, 255, 255, 0.06);
}

.mode-pill {
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  transition: all 0.18s ease;
}

.mode-pill:hover {
  color: var(--text-main);
}

.mode-pill.active {
  background: var(--bg-card);
  color: var(--title-red);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

body.theme-dark .mode-pill.active {
  color: var(--gold-accent);
}

/* 字号步进器 */
.font-stepper {
  display: flex;
  align-items: center;
  gap: 3px;
}

.font-btn {
  font-family: var(--font-serif);
  font-weight: 700;
  width: 32px;
  padding: 0;
}

/* 主题颜色选择圆点 */
.theme-picker {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.04);
  padding: 3px 5px;
  border-radius: 16px;
}

.theme-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid transparent;
  font-size: 10px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-btn.white { background: #ffffff; color: #333; border-color: #ddd; }
.theme-btn.sepia { background: #f6f0df; color: #5c4033; border-color: #d8cbb0; }
.theme-btn.dark  { background: #1c1c20; color: #dfb15b; border-color: #3e3e48; }

.theme-btn.active {
  border-color: var(--title-red);
  box-shadow: 0 0 0 1.5px var(--title-red);
  transform: scale(1.1);
}

/* ================= 主阅读舞台 ================= */
.reader-main {
  position: relative;
  min-height: calc(100vh - 56px);
}

/* ---------------- 模式一：流式纯文本电子书视图 ---------------- */
.ebook-view {
  width: 100%;
  display: block;
  padding: 24px 16px 100px;
}

.ebook-content-wrapper {
  max-width: 820px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 40px 48px 60px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.ebook-chapter-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border-subtle);
  font-size: 13px;
  color: var(--text-sub);
}

.ebook-book-badge {
  font-weight: 600;
  color: var(--gold-accent);
}

.ebook-chapter-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  color: var(--title-red);
  text-align: center;
  line-height: 1.45;
  margin-bottom: 32px;
  letter-spacing: 0.02em;
}

.ebook-body {
  font-family: var(--font-serif);
  font-size: var(--ebook-font-size);
  color: var(--text-main);
  line-height: 1.88;
  letter-spacing: 0.03em;
}

.ebook-body p {
  text-indent: 2em;
  margin-bottom: 1.4em;
  word-break: break-word;
  text-align: justify;
}

.ebook-loading-state {
  text-align: center;
  padding: 80px 0;
  color: var(--text-sub);
}

.spin-icon {
  display: inline-block;
  font-size: 32px;
  margin-bottom: 12px;
  animation: spin 3s linear infinite;
  color: var(--gold-accent);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.ebook-chapter-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 48px 0 36px;
  color: var(--gold-accent);
}

.divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border-subtle), transparent);
}

.divider-lotus {
  font-size: 20px;
}

/* 篇末翻篇导航 */
.ebook-bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}

.ebook-nav-btn {
  flex: 1;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.16s ease;
}

.ebook-nav-btn:hover:not(:disabled) {
  border-color: var(--gold-accent);
  color: var(--title-red);
  background: var(--bg-card);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
}

.ebook-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* 底部悬浮快捷翻章条 */
.ebook-floating-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(10px);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.ebook-floating-bar.hidden {
  transform: translateX(-50%) translateY(80px);
  opacity: 0;
  pointer-events: none;
}

.float-btn {
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  transition: all 0.12s ease;
}

.float-btn:hover:not(:disabled) {
  border-color: var(--gold-accent);
  color: var(--title-red);
}

.float-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.float-chap-info {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-sub);
  padding: 0 4px;
  white-space: nowrap;
}

/* ---------------- 模式二：原版 PDF 翻页阅读视图 ---------------- */
.book-reader {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 110px);
  padding: 8px 16px;
  position: relative;
  user-select: text; -webkit-user-select: text;
  overflow: hidden;
}

.page-turn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 64px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--text-main);
  z-index: 20;
  transition: all 0.18s ease;
}

.page-turn-prev { left: 16px; }
.page-turn-next { right: 16px; }

.page-turn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.14);
  color: var(--title-red);
}

.page-turn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.book-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  overflow: auto;
  padding: 16px 20px 28px;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

.book-page {
  display: block;
  margin: auto;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.22);
  border-radius: 4px;
  background: #ffffff;
}

body.theme-sepia .book-page {
  filter: sepia(0.25) contrast(0.96);
}

body.theme-dark .book-page {
  filter: invert(0.9) hue-rotate(180deg) brightness(0.92);
}

.page-loading {
  position: absolute;
  padding: 12px 24px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border-radius: 8px;
  font-size: 14px;
  display: none;
}

.page-loading.show {
  display: block;
}

/* 原版 PDF 底部控制栏 */
.reader-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--bg-header);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  z-index: 95;
}

.reader-controls button {
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-main);
  transition: all 0.15s ease;
}

.reader-controls button:hover:not(:disabled) {
  border-color: var(--gold-accent);
  color: var(--title-red);
}

.page-indicator {
  font-size: 13px;
  color: var(--text-sub);
  padding: 0 8px;
  min-width: 70px;
  text-align: center;
}

/* ================= 目录大纲抽屉 (TOC) ================= */
.toc-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: min(360px, 86vw);
  height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border-subtle);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.16);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease-out;
}

.toc-drawer.hidden {
  transform: translateX(-100%);
}

.toc-header {
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 16px;
  font-weight: 700;
  color: var(--title-red);
}

.toc-count-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-sub);
  margin-left: 6px;
}

.close-toc {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-toc:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-main);
}

.toc-search-wrap {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.toc-search-wrap input {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.toc-search-wrap input:focus {
  border-color: var(--gold-accent);
}

.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.toc-item {
  padding: 12px 18px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-main);
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
  cursor: pointer;
  transition: background-color 0.12s ease;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.toc-item:hover {
  background: var(--toc-hover);
  color: var(--title-red);
}

.toc-item.active {
  background: var(--toc-hover);
  color: var(--title-red);
  font-weight: 700;
  border-left: 3px solid var(--title-red);
}

.toc-item-num {
  font-size: 12px;
  color: var(--text-sub);
  flex-shrink: 0;
}

.toc-empty {
  padding: 30px;
  text-align: center;
  color: var(--text-sub);
  font-size: 13px;
}

.toc-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 1000;
  transition: opacity 0.25s ease;
}

.toc-backdrop.hidden {
  display: none;
}

/* ================= 进度提示 Toast ================= */
.resume-toast {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 120;
  background: var(--bg-card);
  border: 1px solid var(--gold-accent);
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.resume-toast.hidden {
  display: none !important;
}

.resume-actions button#resumeGoBtn {
  background: var(--green-btn);
  color: #ffffff;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
}

/* 通用隐藏 */
.hidden {
  display: none !important;
}

.reader-empty {
  text-align: center;
  padding: 100px 20px;
  color: var(--text-sub);
  font-size: 16px;
  display: none;
}

.reader-empty.show {
  display: block;
}

/* ================= 移动端适配 (≤ 768px 全面深度优化) ================= */
@media (max-width: 768px) {
  /* 解决移动端 iOS 聚焦输入框页面意外放大的问题 */
  input[type="text"], input[type="search"], input[type="number"], select, textarea {
    font-size: 16px !important;
  }

  /* 消除移动端点击蓝色/灰色高亮遮罩 */
  * {
    -webkit-tap-highlight-color: transparent;
  }

  /* 顶栏安全区与紧凑排版 */
  .reader-header {
    height: 48px;
    padding: 0 8px;
    padding-top: max(4px, env(safe-area-inset-top));
    gap: 4px;
    box-sizing: content-box;
  }

  .header-left {
    gap: 4px;
    flex-shrink: 0;
  }

  .header-right {
    gap: 4px;
    flex-shrink: 0;
  }

  .reader-header h1 {
    font-size: 14px;
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
  }

  .reader-subtitle {
    display: none !important;
  }

  .back-link, .header-btn, .download-link {
    height: 28px;
    padding: 0 7px;
    font-size: 11.5px;
    border-radius: 5px;
  }

  .mode-pill {
    padding: 2px 7px;
    font-size: 11px;
  }

  .font-btn {
    width: 24px;
    height: 28px;
    font-size: 12px;
  }

  .theme-btn {
    width: 22px;
    height: 22px;
    font-size: 10.5px;
  }

  .fullscreen-btn {
    display: none !important;
  }

  /* 主阅读区自适应 */
  .book-reader {
    height: calc(100vh - 104px);
    padding: 4px 6px;
  }

  .book-stage {
    padding: 8px 6px 16px;
  }

  .book-pages-wrap {
    gap: 8px;
  }

  /* 原版 PDF 底部控制栏（横向流畅触控滑装，绝不挤压变形） */
  .reader-controls {
    height: 48px;
    padding: 0 8px;
    gap: 5px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    box-sizing: content-box;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-header);
  }

  .reader-controls::-webkit-scrollbar {
    display: none;
  }

  .reader-controls button {
    height: 30px !important;
    padding: 0 8px !important;
    font-size: 11.5px !important;
    flex-shrink: 0;
  }

  .page-indicator {
    min-width: 44px;
    font-size: 11.5px;
    padding: 0 2px;
    flex-shrink: 0;
  }

  /* 移动端加长滑块自适应 */
  .zoom-slider-wrap {
    height: 30px;
    padding: 0 6px;
    gap: 4px;
    flex-shrink: 0;
  }

  #zoomSlider {
    width: 85px !important;
    height: 5px;
    margin: 0 3px;
  }

  .zoom-stepper-btn {
    width: 20px !important;
    height: 20px !important;
    font-size: 13px !important;
  }

  .zoom-pct-badge {
    font-size: 10.5px;
    min-width: 30px;
    padding: 0 2px;
  }

  .fit-btn {
    height: 22px !important;
    padding: 0 6px !important;
    font-size: 11px !important;
  }

  .pdf-layout-selector {
    height: 30px;
    padding: 1px 3px;
    margin-left: 2px;
    flex-shrink: 0;
  }

  .pdf-layout-selector .layout-hint {
    display: none !important;
  }

  .layout-btn {
    height: 22px !important;
    padding: 0 6px !important;
    font-size: 10.5px !important;
  }

  .fullscreen-toggle-btn {
    height: 30px !important;
    padding: 0 8px !important;
    font-size: 11.5px !important;
    flex-shrink: 0;
  }

  /* 电子书排版移动端体验 */
  .ebook-content-wrapper {
    padding: 16px 12px 36px;
    border-radius: 6px;
  }

  .ebook-chapter-title {
    font-size: 19.5px;
    margin-bottom: 18px;
    line-height: 1.4;
  }

  :root {
    --ebook-font-size: 18px;
  }

  .ebook-body {
    line-height: 1.85;
  }

  .ebook-bottom-nav {
    flex-direction: row;
    gap: 6px;
  }

  .ebook-nav-btn {
    flex: 1;
    height: 36px;
    font-size: 12.5px;
  }

  /* 手机端隐藏电脑鼠标箭头，改由手势与半屏点击触控 */
  .page-turn {
    display: none !important;
  }

  /* 底部悬浮快捷翻章条留出 iPhone 底部小黑条高度 */
  .ebook-floating-bar {
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  /* 手机端 (iPhone XS/12等) 锁定所有容器水平位移 */
  .reader-main, .ebook-view, .book-reader {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100vw;
  }

  /* 针对苹果 XS / 12 等机型深度重构底部悬浮胶囊：告别巨大臃肿，变为精致超薄微胶囊 */
  .ebook-floating-bar {
    bottom: max(14px, env(safe-area-inset-bottom)) !important;
    padding: 3px 8px !important;
    gap: 5px !important;
    border-radius: 20px !important;
    background: rgba(255, 255, 255, 0.92) !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    max-width: 86vw !important;
    height: 30px !important;
    box-sizing: border-box !important;
    transition: transform 0.25s ease, opacity 0.25s ease !important;
  }

  [data-theme="dark"] .ebook-floating-bar {
    background: rgba(30, 30, 30, 0.92) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
  }

  [data-theme="warm"] .ebook-floating-bar {
    background: rgba(247, 243, 233, 0.94) !important;
    border-color: rgba(180, 160, 120, 0.2) !important;
  }

  .float-btn {
    height: 24px !important;
    padding: 0 8px !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    border-radius: 12px !important;
    line-height: 22px !important;
    border: 1px solid var(--border-subtle) !important;
  }

  .float-chap-info {
    font-size: 11px !important;
    font-weight: 500 !important;
    padding: 0 3px !important;
    color: var(--text-sub) !important;
    letter-spacing: 0 !important;
  }

  /* 电子书阅读下滑时自动微淡化，阅读完毕停顿时平滑浮现 */
  .ebook-floating-bar.scrolling {
    opacity: 0.2 !important;
    transform: translateX(-50%) translateY(4px) !important;
  }

}
.toc-jumper-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
}
.toc-jumper-wrap input {
  flex: 1;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}
.toc-jumper-wrap button {
  height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--title-red);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.15s ease;
}
.toc-jumper-wrap button:hover {
  opacity: 0.9;
}

/* ================= 经咒诵读注音排版 (Ruby) ================= */
.scripture-verse {
  text-indent: 0 !important;
  text-align: center;
  line-height: 2.7 !important;
  margin-bottom: 1.5em;
  font-family: var(--font-serif);
  word-break: break-word;
}

.scripture-verse ruby {
  ruby-align: center;
  ruby-position: over;
  margin: 0 1.5px;
}

.scripture-verse rt {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 0.52em;
  font-weight: 500;
  color: #b45309;
  letter-spacing: 0.01em;
  line-height: 1;
  user-select: none;
}

body.theme-sepia .scripture-verse rt {
  color: #9b5a2b;
}

body.theme-dark .scripture-verse rt {
  color: #e0a96d;
}

.ritual-note {
  font-size: 0.82em;
  color: var(--gold-accent, #9b5a2b);
  margin-left: 4px;
  margin-right: 4px;
  font-weight: 600;
}

.scripture-section-title {
  text-align: center;
  font-family: var(--font-serif);
  font-size: 1.22em;
  font-weight: 700;
  color: #8b1e0f;
  margin: 2em auto 1em;
  padding: 0.35em 1em;
  max-width: 500px;
  border-bottom: 2px solid rgba(139, 30, 15, 0.25);
  letter-spacing: 0.05em;
}

body.theme-sepia .scripture-section-title {
  color: #78350f;
  border-bottom-color: rgba(120, 53, 15, 0.25);
}

body.theme-dark .scripture-section-title {
  color: #f59e0b;
  border-bottom-color: rgba(245, 158, 11, 0.25);
}


/* 允许读者自由选择与复制经咒及白话佛法正文 */
.ebook-container, .ebook-article, .scripture-container, .scripture-verse, .book-reader, .book-stage, #ebookContainer, #bookStage {
  user-select: text !important;
  -webkit-user-select: text !important;
}


/* ================= 多页并排/对开书本排版样式 ================= */
.book-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  overflow: auto;
  padding: 16px 20px 28px;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

.book-pages-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: auto;
  flex-shrink: 0;
  min-width: min-content;
  min-height: min-content;
  transition: transform 0.16s ease-out;
}

.book-page-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.book-page {
  display: block;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.22);
  border-radius: 4px;
  background: #ffffff;
  transition: filter 0.2s ease;
}

/* 双页书本对开中缝立体阴影质感 */
.book-page-card.page-left .book-page {
  box-shadow: 6px 12px 28px rgba(0, 0, 0, 0.25);
  border-top-right-radius: 2px;
  border-bottom-right-radius: 2px;
}

.book-page-card.page-right .book-page {
  box-shadow: -6px 12px 28px rgba(0, 0, 0, 0.25);
  border-top-left-radius: 2px;
  border-bottom-left-radius: 2px;
}

.book-page-badge {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-sub);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 2px 10px;
  border-radius: 12px;
  letter-spacing: 0.05em;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

body.theme-sepia .book-page-badge {
  background: #fbf0d9;
  border-color: rgba(120, 53, 15, 0.2);
  color: #78350f;
}

body.theme-dark .book-page-badge {
  background: #262626;
  border-color: rgba(245, 158, 11, 0.2);
  color: #d1d5db;
}

/* 原版 PDF 底部控制栏与分栏并排切换胶囊 */
.pdf-layout-selector {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  margin-left: 8px;
  flex-shrink: 0;
}

.pdf-layout-selector .layout-hint {
  font-size: 12px;
  color: var(--text-sub);
  padding: 0 4px 0 6px;
  user-select: none;
}

.layout-btn {
  height: 28px !important;
  padding: 0 10px !important;
  border: none !important;
  border-radius: 6px !important;
  background: transparent !important;
  font-size: 12px !important;
  font-weight: 500;
  color: var(--text-sub) !important;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.layout-btn:hover {
  color: var(--title-red) !important;
  background: rgba(141, 58, 42, 0.08) !important;
}

.layout-btn.active {
  background: var(--title-red) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(141, 58, 42, 0.3);
}

body.theme-sepia .layout-btn.active {
  background: #78350f !important;
  color: #fef3c7 !important;
}

body.theme-dark .layout-btn.active {
  background: #f59e0b !important;
  color: #1a1a1a !important;
}


/* ================= 精准缩放滑块组件样式（适老化长条+悬停膨胀+大触控区） ================= */
.zoom-slider-wrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 2px 10px;
  height: 36px;
  box-sizing: border-box;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.zoom-slider-wrap:hover {
  border-color: rgba(141, 58, 42, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.zoom-stepper-btn {
  width: 26px !important;
  height: 26px !important;
  padding: 0 !important;
  font-size: 16px !important;
  font-weight: bold !important;
  line-height: 1 !important;
  border: 1px solid transparent !important;
  background: var(--bg-page) !important;
  color: var(--text-main) !important;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 6px !important;
  transition: all 0.15s ease;
}

.zoom-stepper-btn:hover {
  color: var(--title-red) !important;
  border-color: var(--gold-accent) !important;
  background: rgba(141, 58, 42, 0.08) !important;
  transform: scale(1.08);
}

/* 加长加粗的滑道，老人长辈更容易看清与点选 */
#zoomSlider {
  -webkit-appearance: none;
  appearance: none;
  width: 160px;
  height: 6px;
  background: var(--border-subtle);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  margin: 0 6px;
  transition: background 0.2s ease, height 0.15s ease;
}

#zoomSlider:hover {
  height: 8px;
  background: rgba(141, 58, 42, 0.22);
}

/* 默认态：圆润大滑钮，直径 18px，外圈带 2px 纯白描边，高对比度 */
#zoomSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--title-red);
  cursor: grab;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 2px solid #ffffff;
}

/* 靠近悬浮变大态：鼠标靠近即瞬间膨胀至 26px，并带 5px 禅红光晕圈，老人一抓即准 */
#zoomSlider:hover::-webkit-slider-thumb,
#zoomSlider::-webkit-slider-thumb:hover {
  width: 26px;
  height: 26px;
  box-shadow: 0 0 0 5px rgba(141, 58, 42, 0.25), 0 3px 8px rgba(0, 0, 0, 0.35);
  transform: scale(1.1);
  cursor: grab;
}

/* 拖拽活跃态：膨胀至 30px，紧实手感反馈 */
#zoomSlider:active::-webkit-slider-thumb,
#zoomSlider::-webkit-slider-thumb:active {
  width: 30px;
  height: 30px;
  background: #78350f;
  box-shadow: 0 0 0 7px rgba(141, 58, 42, 0.35), 0 4px 12px rgba(0, 0, 0, 0.4);
  transform: scale(1.15);
  cursor: grabbing;
}

/* Firefox 兼容 */
#zoomSlider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--title-red);
  border: 2px solid #ffffff;
  cursor: grab;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#zoomSlider:hover::-moz-range-thumb,
#zoomSlider::-moz-range-thumb:hover {
  width: 26px;
  height: 26px;
  box-shadow: 0 0 0 5px rgba(141, 58, 42, 0.25), 0 3px 8px rgba(0, 0, 0, 0.35);
  transform: scale(1.1);
}

#zoomSlider:active::-moz-range-thumb,
#zoomSlider::-moz-range-thumb:active {
  width: 30px;
  height: 30px;
  background: #78350f;
  box-shadow: 0 0 0 7px rgba(141, 58, 42, 0.35), 0 4px 12px rgba(0, 0, 0, 0.4);
}

.fit-btn {
  height: 26px !important;
  padding: 0 10px !important;
  font-size: 12px !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 6px !important;
  background: var(--bg-page) !important;
  color: var(--text-sub) !important;
  white-space: nowrap;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.18s ease;
}

.fit-btn:hover {
  border-color: var(--gold-accent) !important;
  color: var(--title-red) !important;
}

.fit-btn.active {
  background: var(--title-red) !important;
  color: #ffffff !important;
  border-color: var(--title-red) !important;
  box-shadow: 0 2px 6px rgba(141, 58, 42, 0.28);
}

body.theme-sepia .fit-btn.active {
  background: #78350f !important;
  border-color: #78350f !important;
  color: #fef3c7 !important;
}

body.theme-dark .fit-btn.active {
  background: #f59e0b !important;
  border-color: #f59e0b !important;
  color: #1a1a1a !important;
}

/* ================= 全屏沉浸模式与全屏切换按钮样式 ================= */
.fullscreen-toggle-btn {
  height: 32px !important;
  padding: 0 12px !important;
  border-radius: 6px !important;
  background: var(--bg-card) !important;
  border: 1px solid var(--border-subtle) !important;
  font-size: 13px !important;
  color: var(--text-main) !important;
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 500;
}

.fullscreen-toggle-btn:hover {
  border-color: var(--gold-accent) !important;
  color: var(--title-red) !important;
  background: rgba(141, 58, 42, 0.08) !important;
}

.fullscreen-toggle-btn.active {
  background: var(--title-red) !important;
  color: #ffffff !important;
  border-color: var(--title-red) !important;
  box-shadow: 0 2px 6px rgba(141, 58, 42, 0.28);
}

body.theme-sepia .fullscreen-toggle-btn.active {
  background: #78350f !important;
  border-color: #78350f !important;
  color: #fef3c7 !important;
}

body.theme-dark .fullscreen-toggle-btn.active {
  background: #f59e0b !important;
  border-color: #f59e0b !important;
  color: #1a1a1a !important;
}

/* 全屏沉浸态：顶部导航栏平滑收起，鼠标悬停顶部边缘触发显示 */
body.fullscreen-mode .reader-header {
  position: fixed;
  top: -56px;
  left: 0;
  right: 0;
  z-index: 100;
  transition: top 0.25s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

body.fullscreen-mode .reader-header:hover,
body.fullscreen-mode.header-visible .reader-header {
  top: 0;
}

/* 顶部感应区域 */
body.fullscreen-mode::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 18px;
  z-index: 99;
}

/* 全屏模式下主阅读区域纵向铺满 */
body.fullscreen-mode .book-reader {
  height: calc(100vh - 54px);
  padding-top: 4px;
}


/* 缩放实时百分比徽章 */
.zoom-pct-badge {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-sub);
  min-width: 38px;
  text-align: center;
  user-select: none;
  padding: 1px 4px;
}

/* 独立常驻的「适屏」恢复按钮 */
.fit-btn {
  height: 26px !important;
  padding: 0 10px !important;
  font-size: 12px !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 6px !important;
  background: var(--bg-page) !important;
  color: var(--text-sub) !important;
  white-space: nowrap;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.18s ease;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

.fit-btn:hover {
  border-color: var(--gold-accent) !important;
  color: var(--title-red) !important;
  background: rgba(141, 58, 42, 0.08) !important;
}

.fit-btn.active {
  background: var(--title-red) !important;
  color: #ffffff !important;
  border-color: var(--title-red) !important;
  box-shadow: 0 2px 6px rgba(141, 58, 42, 0.28);
}

body.theme-sepia .fit-btn.active {
  background: #78350f !important;
  border-color: #78350f !important;
  color: #fef3c7 !important;
}

body.theme-dark .fit-btn.active {
  background: #f59e0b !important;
  border-color: #f59e0b !important;
  color: #1a1a1a !important;
}


/* ================= 全屏模式分屏点击翻页动态提示与光标 ================= */
body.fullscreen-mode #bookStage {
  cursor: pointer;
}

.fullscreen-turn-hint {
  position: fixed;
  transform: translate(-50%, -50%) scale(0.7);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(141, 58, 42, 0.78);
  color: #ffffff;
  font-size: 30px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.95;
  animation: turnHintFade 0.38s cubic-bezier(0.2, 0, 0, 1) forwards;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}

body.theme-sepia .fullscreen-turn-hint {
  background: rgba(120, 53, 15, 0.82);
  color: #fef3c7;
}

body.theme-dark .fullscreen-turn-hint {
  background: rgba(245, 158, 11, 0.82);
  color: #1a1a1a;
}

@keyframes turnHintFade {
  0% {
    transform: translate(-50%, -50%) scale(0.65);
    opacity: 0.95;
  }
  60% {
    opacity: 0.75;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.35);
    opacity: 0;
  }
}


/* 适屏状态下绝对锁定水平滚动与拖拽抖动，如真实纸书般稳定 */
.book-stage:not(.zoomed-in) {
  overflow-x: hidden !important;
  touch-action: pan-y pinch-zoom !important;
}

/* 仅在放大 > 100% 时允许水平全向漫游平移 */
.book-stage.zoomed-in {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}
