/* ==========================================================================
   《人类手册》现代化禅意阅读器 Design System & Styles
   ========================================================================== */

:root {
  /* 基础尺寸与过渡 */
  --header-height: 56px;
  --sidebar-width: 320px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);

  /* 排版偏好变量 (默认值) */
  --reader-font-size: 18px;
  --reader-line-height: 1.95;
  --reader-max-width: 820px;
  --reader-indent: 2em;
  --reader-font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", "STSong", Georgia, serif;
}

/* ================= 主题色彩体系 ================= */

/* 1. 米纸护眼 (Warm Paper - 默认推荐) */
[data-theme="rice"], :root:not([data-theme]) {
  --bg-primary: #F8F5EE;
  --bg-secondary: #F0EBE0;
  --bg-card: #FCFAF5;
  --bg-surface: #E8E2D2;
  --bg-hover: rgba(145, 110, 60, 0.08);
  --text-primary: #2C2824;
  --text-secondary: #6B6357;
  --text-muted: #9C9384;
  --border: #E4DDCB;
  --border-subtle: #ECE6D7;
  --accent: #8E5A23;
  --accent-light: rgba(142, 90, 35, 0.12);
  --accent-glow: rgba(142, 90, 35, 0.25);
  --quote-bar: #B87E3E;
  --highlight-bg: #FFE58F;
  --highlight-text: #593800;
  --kbd-bg: #EAE3D1;
  --card-border: #E8E1CF;
}

/* 2. 玄墨静夜 (Pure Dark / Midnight) */
[data-theme="dark"] {
  --bg-primary: #141517;
  --bg-secondary: #1B1D21;
  --bg-card: #202328;
  --bg-surface: #272C33;
  --bg-hover: rgba(255, 255, 255, 0.07);
  --text-primary: #E2E4E8;
  --text-secondary: #9BA1AD;
  --text-muted: #656C7A;
  --border: #2C3038;
  --border-subtle: #22262E;
  --accent: #4ADE80;
  --accent-light: rgba(74, 222, 128, 0.14);
  --accent-glow: rgba(74, 222, 128, 0.28);
  --quote-bar: #38BDF8;
  --highlight-bg: #854D0E;
  --highlight-text: #FEF08A;
  --kbd-bg: #272B33;
  --card-border: #2B303A;
}

/* 3. 羊皮古卷 (Antique Parchment) */
[data-theme="sepia"] {
  --bg-primary: #F2E8D3;
  --bg-secondary: #E7DBBF;
  --bg-card: #F7EFE0;
  --bg-surface: #DCCEAE;
  --bg-hover: rgba(120, 70, 20, 0.09);
  --text-primary: #382B1C;
  --text-secondary: #6F583E;
  --text-muted: #9A8062;
  --border: #DFCFAF;
  --border-subtle: #E8DCC2;
  --accent: #8A481B;
  --accent-light: rgba(138, 72, 27, 0.12);
  --accent-glow: rgba(138, 72, 27, 0.25);
  --quote-bar: #A0522D;
  --highlight-bg: #FFD591;
  --highlight-text: #612500;
  --kbd-bg: #E3D4B6;
  --card-border: #E0CFAC;
}

/* 4. 雪境纯白 (Pure White) */
[data-theme="light"] {
  --bg-primary: #FFFFFF;
  --bg-secondary: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-surface: #F1F5F9;
  --bg-hover: rgba(0, 0, 0, 0.05);
  --text-primary: #1E293B;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --border: #E2E8F0;
  --border-subtle: #F1F5F9;
  --accent: #2563EB;
  --accent-light: rgba(37, 99, 235, 0.1);
  --accent-glow: rgba(37, 99, 235, 0.22);
  --quote-bar: #3B82F6;
  --highlight-bg: #BAE6FD;
  --highlight-text: #0369A1;
  --kbd-bg: #E2E8F0;
  --card-border: #E2E8F0;
}

/* ================= 字体设定 ================= */
[data-font="serif"] {
  --reader-font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", "STSong", Georgia, serif;
}
[data-font="sans"] {
  --reader-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
[data-font="kaiti"] {
  --reader-font-family: "Kaiti SC", "STKaiti", "KaiTi", "楷体", serif;
}

/* ================= 基础重置 ================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--reader-font-family);
  min-height: 100vh;
  line-height: 1.6;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}

/* 顶部全屏阅读进度条 */
#readingProgressBar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #D97706);
  z-index: 2000;
  transition: width 0.1s ease-out;
  box-shadow: 0 0 6px var(--accent-glow);
}

/* ================= 页面顶部导航栏 ================= */
.site-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background-color: rgba(var(--bg-primary), 0.94);
  transition: transform var(--transition-normal), background-color var(--transition-normal);
}

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

.menu-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  transition: all var(--transition-fast);
}

.menu-toggle-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.book-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.brand-logo-icon {
  width: 28px;
  height: 28px;
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.08));
}

.brand-text-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.book-brand h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

.book-brand .brand-author {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.header-center {
  display: flex;
  align-items: center;
}

.current-reading-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 380px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.current-reading-indicator:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.reading-pct-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 1px 6px;
  border-radius: 10px;
}

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

.header-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.header-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border);
}

.header-btn.search-btn {
  background: var(--bg-secondary);
  border-color: var(--border-subtle);
  padding: 0 12px;
}

.header-btn.search-btn kbd {
  background: var(--kbd-bg);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  color: var(--text-muted);
  font-family: monospace;
}

/* ================= 侧边栏与抽屉 ================= */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  z-index: 1400;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  z-index: 1500;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform var(--transition-normal);
  box-shadow: var(--shadow-lg);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-book-card {
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
}

.book-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.book-card-author {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.book-card-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.resume-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 10px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.resume-btn:hover {
  opacity: 0.9;
}

.sidebar-search-box {
  position: relative;
}

.sidebar-search-input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast);
}

.sidebar-search-input:focus {
  border-color: var(--accent);
}

.sidebar-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
}

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 6px 10px 4px;
  font-weight: 600;
}

.chapter-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chapter-nav-item {
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: background var(--transition-fast);
}

.chapter-nav-link {
  display: flex;
  flex-direction: column;
  padding: 9px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  transition: all var(--transition-fast);
}

.chapter-nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.chapter-nav-item.active .chapter-nav-link {
  background: var(--accent-light);
  border-left-color: var(--accent);
  color: var(--text-primary);
  font-weight: 600;
}

.nav-ch-title {
  font-size: 14px;
  line-height: 1.4;
}

.nav-ch-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.3;
}

.chapter-nav-item.active .nav-ch-subtitle {
  color: var(--accent);
}

/* 章节内小节大纲列表 */
.sub-sections-list {
  list-style: none;
  padding: 4px 0 6px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sub-section-link {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all var(--transition-fast);
}

.sub-section-link:hover {
  color: var(--accent);
  background: var(--bg-hover);
}

.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

/* ================= 核心正文阅读区 ================= */
.main-wrapper {
  min-height: calc(100vh - var(--header-height));
  display: flex;
  justify-content: center;
  padding: 40px 24px 80px;
  transition: padding var(--transition-normal);
}

.article-container {
  width: 100%;
  max-width: var(--reader-max-width);
  margin: 0 auto;
}

/* 文章头部卡片 */
.chapter-header {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.chapter-number-pill {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}

.chapter-title {
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 800;
  line-height: 1.35;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.chapter-subtitle {
  font-size: 17px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 16px;
}

.chapter-meta-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* 禅意引言/题记卡片 */
.epigraph-card {
  margin: 28px 0 36px;
  padding: 20px 24px;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--quote-bar);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.epigraph-icon {
  font-size: 20px;
  color: var(--quote-bar);
  margin-bottom: 8px;
  opacity: 0.85;
}

.epigraph-text {
  font-size: calc(var(--reader-font-size) * 1.05);
  font-weight: 500;
  line-height: 1.8;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

/* 讲者称谓徽章 */
.salutation-block {
  margin: 24px 0 16px;
  display: inline-block;
  padding: 4px 14px;
  background: var(--bg-surface);
  color: var(--accent);
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
}

/* 正文段落排版 */
.reading-content {
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--text-primary);
}

.reading-content p {
  margin-bottom: 1.6em;
  text-align: justify;
  text-justify: inter-ideograph;
  text-indent: var(--reader-indent);
  letter-spacing: 0.03em;
  position: relative;
}

.reading-content p.highlight-target {
  animation: pulse-glow 2.5s ease-out;
}

@keyframes pulse-glow {
  0% {
    background-color: var(--highlight-bg);
    box-shadow: 0 0 16px var(--accent-glow);
  }
  100% {
    background-color: transparent;
    box-shadow: none;
  }
}

/* 小节标题 */
.reading-content h2.section-heading {
  font-size: calc(var(--reader-font-size) * 1.35);
  font-weight: 700;
  color: var(--text-primary);
  margin: 2.4em 0 1em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
  scroll-margin-top: calc(var(--header-height) + 20px);
}

.reading-content h2.section-heading::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 0.85em;
  background: var(--accent);
  border-radius: 2px;
}

/* 列表美化 */
.reading-content .custom-list {
  list-style: none;
  margin: 1.5em 0 2em;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reading-content .custom-list-item {
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  font-size: calc(var(--reader-font-size) * 0.95);
  line-height: 1.7;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.reading-content .custom-list-item::before {
  content: "✦";
  color: var(--accent);
  font-size: 11px;
  flex-shrink: 0;
}

/* ================= 小节核心图解与总结卡片 ================= */
.section-summary-card {
  margin: 40px 0 48px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 30px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.section-summary-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border-color: var(--accent);
}

.section-summary-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--quote-bar), var(--accent));
  opacity: 0.9;
}

.summary-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border);
}

.summary-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.summary-card-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: 0.02em;
}

/* 核心心法公式条 */
.summary-formula-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  margin-bottom: 20px;
  font-size: 14.5px;
  line-height: 1.6;
}

.formula-icon {
  font-size: 16px;
}

.formula-label {
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.formula-text {
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.summary-diagram-visual {
  width: 100%;
  margin: 16px 0 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: auto;
  padding: 10px 0;
}

.summary-diagram-visual svg {
  width: 100%;
  max-width: 760px;
  height: auto;
  display: block;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.02));
}

.summary-core-takeaway {
  background: var(--bg-surface);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 15.5px;
  line-height: 1.8;
  color: var(--text-primary);
  font-weight: 500;
}

.summary-core-takeaway strong {
  color: var(--accent);
  font-weight: 700;
  margin-right: 6px;
}

/* 日用实修指引栏 */
.summary-practice-guide {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(46, 125, 50, 0.08);
  border: 1px solid rgba(46, 125, 50, 0.28);
  border-radius: 6px;
  padding: 12px 18px;
  margin-bottom: 18px;
  font-size: 14.5px;
  line-height: 1.7;
}

[data-theme="dark"] .summary-practice-guide {
  background: rgba(74, 222, 128, 0.09);
  border-color: rgba(74, 222, 128, 0.28);
}

.practice-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.practice-text {
  color: var(--text-primary);
  font-weight: 500;
}

.summary-keypoints {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.summary-keypoint-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg-secondary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.summary-keypoint-item .kp-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  margin-top: 1px;
}

/* 导读总览卡片群 */
.intro-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  margin: 32px 0 48px;
}

.chapter-card {
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.chapter-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.card-top {
  margin-bottom: 12px;
}

.card-ch-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.card-ch-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 4px;
}

.card-ch-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

.card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
}

.card-read-link {
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 底部章节翻页器 */
.chapter-pagination {
  margin-top: 60px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.page-btn {
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.page-btn:hover {
  border-color: var(--accent);
  background: var(--bg-surface);
}

.page-btn.prev {
  text-align: left;
}

.page-btn.next {
  text-align: right;
}

.page-btn-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.page-btn-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back-to-top-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.back-to-top-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ================= 专注禅定模式 (Zen Mode) ================= */
body.zen-mode .site-header,
body.zen-mode .chapter-pagination,
body.zen-mode .current-reading-indicator,
body.zen-mode .sidebar {
  display: none !important;
}

body.zen-mode .main-wrapper {
  padding-top: 60px;
}

.zen-exit-pill {
  position: fixed;
  top: 20px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0.15;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  z-index: 2500;
  box-shadow: var(--shadow-sm);
}

.zen-exit-pill:hover {
  opacity: 1;
  transform: translateY(-1px);
}

/* ================= 弹窗对话框 (Modals) ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  width: 100%;
  max-width: 640px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  transform: scale(0.96);
  transition: transform var(--transition-normal);
}

.modal-overlay.open .modal-container {
  transform: scale(1);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

/* 搜索面板专有样式 */
.search-input-wrapper {
  padding: 16px 20px;
  position: relative;
  border-bottom: 1px solid var(--border-subtle);
}

.search-dialog-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  font-size: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast);
}

.search-dialog-input:focus {
  border-color: var(--accent);
}

.search-input-icon {
  position: absolute;
  left: 34px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
}

.search-tags {
  padding: 10px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  font-size: 12px;
}

.search-tag-label {
  color: var(--text-muted);
}

.search-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition-fast);
}

.search-chip:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.search-results-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.search-result-item {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-result-item:hover {
  border-color: var(--accent);
  background: var(--bg-surface);
}

.search-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.search-item-ch {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.search-item-line {
  font-size: 11px;
  color: var(--text-muted);
}

.search-item-snippet {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.search-item-snippet mark {
  background: var(--highlight-bg);
  color: var(--highlight-text);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

.empty-search-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* 设置面板专有样式 */
.settings-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setting-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.setting-options-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
}

.setting-option-btn {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: all var(--transition-fast);
}

.setting-option-btn:hover {
  border-color: var(--accent);
}

.setting-option-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
  font-weight: 600;
}

/* 金句采撷卡片弹窗 */
.quote-card-preview {
  padding: 30px;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  margin: 20px;
  position: relative;
  box-shadow: var(--shadow-md);
}

.quote-card-body {
  font-size: 17px;
  line-height: 1.8;
  color: var(--text-primary);
  margin-bottom: 20px;
  font-style: italic;
}

.quote-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.quote-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 20px 20px;
}

/* 浮动选中文本工具条 */
.selection-toolbar {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 2200;
  transform: translate(-50%, -100%);
  margin-top: -10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.selection-toolbar.active {
  opacity: 1;
  pointer-events: auto;
}

.selection-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.selection-btn:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

/* 提示气泡 (Toast) */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: slide-up 0.25s ease-out;
}

@keyframes slide-up {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ================= 响应式调整 (Mobile & Tablet) ================= */
@media (max-width: 768px) {
  :root {
    --header-height: 52px;
    --sidebar-width: 85vw;
    --reader-font-size: 17px;
  }

  .site-header {
    padding: 0 12px;
  }

  .header-btn.search-btn span,
  .header-btn.search-btn kbd {
    display: none;
  }

  .header-btn.search-btn {
    padding: 0 8px;
  }

  .header-center {
    display: none;
  }

  .main-wrapper {
    padding: 24px 16px 60px;
  }

  .chapter-pagination {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .back-to-top-btn {
    justify-content: center;
  }

  .intro-overview-grid {
    grid-template-columns: 1fr;
  }
}
