/* ========== 基础重置 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body, html {
  height: 100%;
  font-family: var(--font-family);
  background: var(--bg-color);
  color: var(--text-color);
  transition: background 0.3s ease, color 0.2s ease;
}

/* 隐藏滚动条 */
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
*::-webkit-scrollbar {
  display: none;
}

/* ========== 千禧梦核 ========== */
:root, body.nostalgia {
  --bg-color: #f5ede1;
  --text-color: #3a2e28;
  --accent-color: #a08d7c;
  --accent-light: #c4b5a6;
  --border-color: #d9cdc0;
  --sidebar-bg: #efe5d9;
  --page-bg: transparent;
  --font-family: 'Georgia', 'Times New Roman', '宋体', serif;
  --dropdown-hover: rgba(160, 141, 124, 0.08);
  --divider-color: #a08d7c;
  --title-color: #2a1f1a;
  --heading-weight: 400;
  --btn-bg: rgba(160, 141, 124, 0.12);
  --btn-hover: rgba(160, 141, 124, 0.22);
}

/* ========== 蒸汽波 ========== */
body.vaporwave {
  --bg-color: #1a1a2e;
  --text-color: #d4c5e8;
  --accent-color: #7b6ba3;
  --accent-light: #9a8abf;
  --border-color: #3a2a5a;
  --sidebar-bg: #1f1f3a;
  --page-bg: transparent;
  --font-family: 'Georgia', 'Times New Roman', '宋体', serif;
  --dropdown-hover: rgba(123, 107, 163, 0.12);
  --divider-color: #7b6ba3;
  --title-color: #e8dcff;
  --heading-weight: 400;
  --btn-bg: rgba(123, 107, 163, 0.12);
  --btn-hover: rgba(123, 107, 163, 0.22);
}

/* ========== 电纸书 ========== */
body.ebook {
  --bg-color: #ffffff;
  --text-color: #1a1a1a;
  --accent-color: #333333;
  --accent-light: #666666;
  --border-color: #cccccc;
  --sidebar-bg: #f5f5f5;
  --page-bg: transparent;
  --font-family: '宋体', 'Songti SC', 'SimSun', serif;
  --dropdown-hover: rgba(0,0,0,0.04);
  --divider-color: #333333;
  --title-color: #000000;
  --heading-weight: 500;
  --btn-bg: rgba(0,0,0,0.05);
  --btn-hover: rgba(0,0,0,0.12);
}

/* ========== 封面页 ========== */
.cover {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-color);
  cursor: pointer;
  z-index: 1000;
}

.cover-content {
  text-align: center;
  padding: 2rem;
}

.cover-title {
  font-size: clamp(3rem, 10vw, 6rem);
  font-weight: 300;
  letter-spacing: 8px;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.5rem;
  display: inline-block;
  color: var(--title-color);
}

.cover-author {
  font-size: 1.4rem;
  margin-bottom: 2.5rem;
  opacity: 0.7;
  font-weight: 300;
}

.cover-epigraph {
  font-size: 1.1rem;
  font-style: italic;
  margin-bottom: 3rem;
  opacity: 0.6;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.cover-hint {
  font-size: 0.85rem;
  opacity: 0.35;
  animation: pulse 2.5s infinite;
  margin-top: 3rem;
}

@keyframes pulse {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.45; }
}

/* ========== 阅读器布局 ========== */
.reader {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ========== 右下角按钮容器 ========== */
.floating-buttons {
  position: fixed;
  bottom: 70px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.floating-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--btn-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: none;
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s;
  opacity: 0.8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.floating-btn:hover {
  opacity: 1;
  background: var(--btn-hover);
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

body.ebook .floating-btn {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

body.ebook .floating-btn:hover {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* ========== 侧边栏 ========== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 150;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 2px 0 20px rgba(0,0,0,0.05);
  overflow-y: auto;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px dashed var(--border-color);
  opacity: 0.7;
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 350;
  letter-spacing: 3px;
  color: var(--title-color);
}

.sidebar-close {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 22px;
  cursor: pointer;
  opacity: 0.4;
  padding: 0 5px;
  transition: opacity 0.2s;
}

.sidebar-close:hover {
  opacity: 0.8;
}

/* 最近更新 */
.recent-update {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px dashed var(--border-color);
  opacity: 0.7;
}

.recent-label {
  font-size: 0.7rem;
  opacity: 0.45;
  margin-bottom: 0.5rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* 侧边栏区域标题统一样式 */
.sidebar-section-title {
  font-size: 0.7rem;
  opacity: 0.45;
  margin-bottom: 0.5rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}

.recent-link {
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.5;
  transition: opacity 0.15s;
}

.recent-link:hover {
  opacity: 0.7;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ========== 目录树 ========== */
.toc {
  flex: 1;
  padding: 0.2rem 0 1rem;
  overflow-y: auto;
}

.toc ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.toc-section {
  padding: 0.6rem 1.5rem;
  font-weight: 400;
  font-size: 0.8rem;
  opacity: 0.5;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  transition: opacity 0.15s;
}

.toc-section:hover {
  opacity: 0.7;
}

.toc-section::before {
  content: '▶';
  display: inline-block;
  width: 14px;
  font-size: 0.6rem;
  margin-right: 8px;
  transition: transform 0.2s;
  opacity: 0.5;
}

.toc-section.open::before {
  transform: rotate(90deg);
}

.toc-section-content {
  display: none;
  padding-left: 0.5rem;
}

.toc-section-content.open {
  display: block;
}

.toc-volume {
  padding: 0.4rem 1.5rem 0.4rem 2.5rem;
  font-size: 0.9rem;
  opacity: 0.75;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  transition: all 0.15s;
}

.toc-volume:hover {
  opacity: 1;
  background: var(--dropdown-hover);
}

.toc-volume::before {
  content: '▶';
  display: inline-block;
  width: 12px;
  font-size: 0.55rem;
  margin-right: 8px;
  transition: transform 0.2s;
  opacity: 0.5;
}

.toc-volume.open::before {
  transform: rotate(90deg);
}

.toc-volume-content {
  display: none;
  padding-left: 1rem;
}

.toc-volume-content.open {
  display: block;
}

.toc a {
  display: block;
  padding: 0.3rem 1.5rem 0.3rem 3.5rem;
  color: var(--text-color);
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.15s;
  opacity: 0.7;
}

.toc a:hover {
  background: var(--dropdown-hover);
  opacity: 1;
}

.toc a.active {
  background: var(--accent-color);
  color: var(--bg-color);
  opacity: 1;
}

.toc-file-direct {
  display: block;
  padding: 0.3rem 1.5rem 0.3rem 2.5rem;
  color: var(--text-color);
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.15s;
  opacity: 0.7;
}

.toc-file-direct:hover {
  background: var(--dropdown-hover);
  opacity: 1;
}

.toc-top-link {
  display: block;
  padding: 0.5rem 1.5rem;
  color: var(--text-color);
  text-decoration: none;
  font-size: 0.9rem;
  opacity: 0.75;
  border-bottom: 1px solid var(--border-color);
}

.toc-top-link:hover {
  background: var(--dropdown-hover);
  opacity: 1;
}

/* ========== 主题切换面板 ========== */
.theme-panel {
  position: fixed;
  bottom: 120px;
  right: 80px;
  background: var(--sidebar-bg);
  border: none;
  border-radius: 40px;
  padding: 8px 12px;
  display: none;
  gap: 12px;
  z-index: 199;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.theme-panel.open {
  display: flex;
}

body.ebook .theme-panel {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.theme-panel .theme-btn {
  background: transparent;
  border: none;
  color: var(--text-color);
  font-size: 1.3rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: all 0.15s;
}

.theme-panel .theme-btn:hover {
  opacity: 1;
  background: var(--dropdown-hover);
}

/* ========== 主阅读区 ========== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-color);
  position: relative;
}

.reader-header {
  padding: 1.2rem 2rem 0.8rem;
  text-align: center;
}

#chapterTitle {
  font-size: 1.3rem;
  font-weight: 350;
  letter-spacing: 3px;
  opacity: 0.65;
  color: var(--title-color);
}

/* ========== 单页阅读区域 ========== */
.page-container-single {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0 0;
  display: flex;
  justify-content: center;
}

.page-single {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 3.5rem 3rem;
  background: transparent;
  line-height: 1.95;
  font-size: 1.05rem;
  color: var(--text-color);
}

/* ========== 章内小标题目录 ========== */
.chapter-toc-panel {
  position: fixed;
  bottom: 120px;
  right: 80px;
  width: 260px;
  max-height: 50vh;
  background: var(--sidebar-bg);
  border: none;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  z-index: 198;
  display: none;
  overflow-y: auto;
  padding: 0.6rem 0;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.chapter-toc-panel.open {
  display: block;
}

body.ebook .chapter-toc-panel {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.chapter-toc-panel .toc-header {
  padding: 0.5rem 1rem;
  font-size: 0.7rem;
  opacity: 0.45;
  letter-spacing: 2px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.4rem;
}

.chapter-toc-panel a {
  display: block;
  padding: 0.35rem 1rem;
  color: var(--text-color);
  text-decoration: none;
  font-size: 0.85rem;
  opacity: 0.7;
  transition: all 0.15s;
}

.chapter-toc-panel a:hover {
  background: var(--dropdown-hover);
  opacity: 1;
}

/* ========== 章节导航 ========== */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 2rem 1rem;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  border-top: 1px solid var(--border-color);
  background: var(--bg-color);
  flex-shrink: 0;
}

.chapter-nav .page-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 0.35rem 1.2rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  border-radius: 20px;
  opacity: 0.55;
}

.chapter-nav .page-btn:hover:not(:disabled) {
  opacity: 0.9;
  border-color: var(--accent-color);
  background: var(--dropdown-hover);
}

.chapter-nav .page-btn:disabled {
  opacity: 0.15;
  cursor: not-allowed;
}

.chapter-nav .page-indicator {
  font-size: 0.8rem;
  opacity: 0.45;
  letter-spacing: 1px;
}

/* ========== Markdown 内容样式 ========== */
.page-single h1 {
  font-size: 2.2rem;
  font-weight: var(--heading-weight);
  margin-bottom: 0.8rem;
  text-align: center;
  letter-spacing: 4px;
  padding-bottom: 1.5rem;
  position: relative;
  color: var(--title-color);
  line-height: 1.4;
}

.page-single h1::after {
  content: '❦';
  display: block;
  font-size: 1rem;
  color: var(--divider-color);
  margin-top: 1.2rem;
  opacity: 0.4;
  font-weight: normal;
}

body.ebook .page-single h1::after {
  content: '◆';
  font-size: 0.7rem;
}

.page-single h2 {
  font-size: 1.5rem;
  font-weight: var(--heading-weight);
  margin: 2.2rem 0 1.2rem;
  opacity: 0.8;
  letter-spacing: 2px;
  padding-left: 0.8rem;
  border-left: 3px solid var(--accent-light);
  color: var(--title-color);
}

.page-single h3 {
  font-size: 1.25rem;
  font-weight: var(--heading-weight);
  margin: 1.8rem 0 1rem;
  opacity: 0.75;
  letter-spacing: 1px;
  color: var(--title-color);
}

.page-single p {
  margin-bottom: 1.3rem;
  text-indent: 2em;
  word-break: break-word;
  line-height: 1.95;
}

/* 无序列表样式 */
.page-single ul,
.page-single ol {
  margin: 0.8rem 0 1.2rem 1.5rem;
  padding-left: 1rem;
  color: var(--text-color);
}

.page-single li {
  margin-bottom: 0.4rem;
  line-height: 1.8;
  text-indent: 0;
}

/* 嵌套列表缩进 */
.page-single ul ul,
.page-single ol ol,
.page-single ul ol,
.page-single ol ul {
  margin-top: 0.3rem;
  margin-bottom: 0.3rem;
  margin-left: 1.2rem;
}

/* 列表项内的段落 */
.page-single li p {
  margin-bottom: 0.3rem;
  text-indent: 0;
}

/* 自定义列表符号 */
.page-single ul {
  list-style-type: disc;
}

.page-single ul ul {
  list-style-type: circle;
}

.page-single ul ul ul {
  list-style-type: square;
}

.page-single ol {
  list-style-type: decimal;
}

.page-single ol ol {
  list-style-type: lower-alpha;
}

.page-single ol ol ol {
  list-style-type: lower-roman;
}

.page-single hr {
  border: none;
  text-align: center;
  margin: 2.5rem 0;
}

.page-single hr::before {
  content: '☙ ❦ ❧';
  color: var(--divider-color);
  opacity: 0.3;
  font-size: 0.9rem;
  letter-spacing: 8px;
}

body.ebook .page-single hr::before {
  content: '———';
  letter-spacing: 2px;
}

/* ========== 移动端 ========== */
@media (max-width: 768px) {
  .page-single {
    max-width: 100%;
    padding: 1rem 1.5rem 1rem;
  }
  
  .floating-buttons {
    bottom: 65px;
    right: 16px;
    gap: 8px;
  }
  
  .floating-btn {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  
  .sidebar {
    width: 280px;
  }
  
  .reader-header {
    padding: 0.8rem 1rem 0.5rem;
  }
  
  #chapterTitle {
    font-size: 1.1rem;
  }
  
  .theme-panel {
    bottom: 115px;
    right: 60px;
  }
  
  .chapter-toc-panel {
    bottom: 115px;
    right: 60px;
    width: 240px;
  }
  
.chapter-nav {
  padding: 0.6rem 1rem 0.8rem;
  position: sticky;
  bottom: 0;
  background: var(--bg-color);
}
  
  .chapter-nav .page-btn {
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
  }
  
  .page-indicator {
    font-size: 0.75rem;
  }
}

/* 隐藏旧元素 */
.book-container,
.pagination-controls,
.page.left-page,
.page.right-page,
.mobile-page,
.mobile-pagination,
.chapter-toc-toggle {
  display: none;
}