/* ==========================================================
   style.css  ——  网站的"外观"
   ----------------------------------------------------------
   这个文件只回答一个问题：东西长什么样？
   颜色、大小、间距、动画，全在这里调。

   注释写得很详细，是为了让你改的时候知道自己在改什么。
   ========================================================== */


/* ---------- 0. 变量：把常用的颜色/尺寸"取个名字" ---------- */

:root {
  /* 主色调 */
  --accent: #534AB7;       /* 主题色（按钮、进度条、选中态） */
  --accent-soft: #EEEBFA;  /* 主题色的浅版（按钮 hover 背景） */

  /* 文字色 */
  --text:        #2A2A2A;  /* 主文字色 */
  --text-sub:    #777777;  /* 次要文字（副标题、提示） */
  --text-faint:  #B0B0B0;  /* 更淡的文字（占位符等） */

  /* 背景与边框 */
  --bg:          #FFFFFF;  /* 卡片/按钮背景 */
  /* 整个页面的背景：暖色渐变 + 顶部极淡的紫色光晕（呼应主题色 #534AB7）。
     卡片仍是白底，渐变只在页面留白处透出，既高级又不伤阅读。 */
  --bg-page:     radial-gradient(120% 80% at 50% -10%, rgba(83,74,183,0.06) 0%, rgba(83,74,183,0) 60%), linear-gradient(165deg, #FBFAF7 0%, #F1EDE5 100%);
  --bg-soft:     #F4F2EE;  /* 浅一档的背景（如输入框） */
  --border:      #E8E5DF;  /* 普通边框色 */
  --border-soft: #F0EEEA;  /* 更淡的边框 */

  /* 阅读区 */
  --reader-size: 18px;     /* 正文字号（用户可调，会被 JS 覆盖） */
  --reader-bg:   #FFFFFF;  /* 阅读页背景 */

  /* 顶部导航条高度（JS 会用到，所以放到变量里好对齐） */
  --topbar-h:    57px;

  /* 全站字号缩放：改这一个值即可整体放大/缩小字体（1 = 原始大小） */
  --font-scale:  1;
}

/* 夜间模式：只覆盖颜色，其他布局不动 */
[data-theme="dark"] {
  --text:        #E8E8E8;
  --text-sub:    #999999;
  --text-faint:  #5C5C5C;
  --bg:          #1E1E1E;
  --bg-page:     radial-gradient(120% 80% at 50% -10%, rgba(83,74,183,0.10) 0%, rgba(83,74,183,0) 60%), linear-gradient(165deg, #1B1B1F 0%, #121214 100%);
  --bg-soft:     #252525;
  --border:      #333333;
  --border-soft: #2A2A2A;
  --accent-soft: #3A3478;
  --reader-bg:   #1A1A1A;
}


/* ---------- 1. 全局重置 + 基础排版 ---------- */

* { box-sizing: border-box; }     /* 盒子宽高算法：用 border-box 更直观 */

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  /* 背景图/色由 applyBg() 直接写在 body.style 上，覆盖这里的 background */
}

button { font-family: inherit; }

a { color: var(--accent); text-decoration: none; }

/* 所有页面默认隐藏，由 .hidden 控制 */
.hidden { display: none !important; }


/* ---------- 2. 顶部栏 + 导航 ---------- */

.topbar {
  height: var(--topbar-h);
  padding: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 100;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }
/* 让「无心阅读网」绝对居中于顶部栏，右侧的用户栏/主题按钮保持原位 */
.topbar-left { position: absolute; left: 50%; transform: translateX(-50%); }
.logo { font-size: 36px; font-weight: 700; white-space: nowrap; }

/* 居中容器：顶部栏、导航、主内容都塞进这个同一宽度的列里 */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}
.topbar .wrap {
  height: 100%;
  position: relative;
  display: flex; align-items: center; justify-content: flex-end;
}

/* 登录信息条：夹在顶部栏与公告之间，右侧显示当前账号手机号 + 返回主页面 */
.userbar {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-soft);
  padding: 6px 0;
  font-size: calc(13px * var(--font-scale));
}
.userbar .wrap { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.top-user { color: var(--text-sub); white-space: nowrap; }

.nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  padding: 0;
  position: sticky; top: var(--topbar-h); z-index: 99;
}
.nav .wrap { display: flex; gap: 4px; justify-content: center; }

/* 公告栏：紧贴在顶部栏下方，内容居中 */
.announcement {
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border-soft);
  padding: 8px 0;
}
.announcement .wrap {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  text-align: center;
}
.ann-badge {
  flex: 0 0 auto;
  background: var(--accent); color: #fff;
  font-weight: 700; padding: 2px 12px; border-radius: 999px;
}
.ann-text { color: var(--text); line-height: 1.5; }
.nav-tab {
  background: none; border: none;
  padding: 14px 16px;
  font-size: 15px; color: var(--text-sub);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active {
  color: var(--text); font-weight: 600;
  border-bottom-color: var(--accent);
}


/* ---------- 3. 主内容区 + 页面头 ---------- */

main {
  max-width: 1200px; margin: 0 auto;
  padding: 24px 20px 80px;
}

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 18px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: calc(24px * var(--font-scale)); }
.page-head .sub { margin: 6px 0 0; color: var(--text-sub); font-size: calc(14px * var(--font-scale)); }

.section-title {
  margin: 32px 0 12px;
  font-size: calc(16px * var(--font-scale)); font-weight: 600;
  color: var(--text);
}


/* ---------- 4. 输入框、按钮 ---------- */

.search {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: calc(14px * var(--font-scale));
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
}
.search:focus { border-color: var(--accent); }
.search-inpage { width: 220px; }

.icon-btn {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: calc(14px * var(--font-scale));
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

.primary-btn {
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  padding: 10px 18px; font-size: calc(14px * var(--font-scale)); font-weight: 600;
  cursor: pointer;
}
.primary-btn:hover { filter: brightness(1.05); }

.danger-btn {
  background: var(--bg); color: #C0392B;
  border: 1px solid #F0D4D2;
  border-radius: 8px;
  padding: 10px 18px; font-size: calc(14px * var(--font-scale));
  cursor: pointer;
}
.danger-btn:hover { background: #FCEBEB; }

.back-btn {
  background: none; border: none;
  color: var(--text-sub);
  font-size: calc(14px * var(--font-scale)); cursor: pointer;
  padding: 4px 0;
}
.back-btn:hover { color: var(--accent); }


/* ---------- 5. 分类按钮 + 搜索框 ---------- */

.filters {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 18px;
}
.filter-btn {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: calc(13px * var(--font-scale));
  color: var(--text-sub);
  cursor: pointer;
}
.filter-btn:hover { color: var(--text); border-color: var(--accent); }
.filter-btn.active {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
}
.filter-more { margin-left: auto; }


/* ---------- 6. 书卡 ---------- */

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 20px;
}

.book-card {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .15s, box-shadow .15s;
  cursor: pointer;                 /* 整张卡片都能点开 */
  touch-action: manipulation;      /* 手机上点按不再有 300ms 延迟，也不会被"双击缩放"吃掉 */
}
.book-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,.06);
}

.cover {
  aspect-ratio: 3 / 4;
  padding: 14px;
  display: flex; flex-direction: column; justify-content: flex-end;
  color: #fff;
  cursor: pointer;
}
.cover-title { font-size: calc(17px * var(--font-scale)); font-weight: 700; line-height: 1.3; }
.cover-author { font-size: calc(12px * var(--font-scale)); opacity: .8; margin-top: 4px; }

.book-info {
  padding: 12px 14px 6px;
  cursor: pointer;
}
.book-name {
  font-size: calc(15px * var(--font-scale)); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.book-by { font-size: calc(12px * var(--font-scale)); color: var(--text-sub); margin-top: 4px; }

.card-actions {
  padding: 8px 12px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.card-action {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 0;
  font-size: calc(13px * var(--font-scale));
  color: var(--text);
  cursor: pointer;
}
.card-action:hover { border-color: var(--accent); color: var(--accent); }
.card-action.done { color: var(--text-faint); cursor: default; }
.card-action.done:hover { border-color: var(--border); color: var(--text-faint); }

/* ---------- 6.5 书架竖列模式 ---------- */

.shelf.list-mode {
  display: flex; flex-direction: column;
  grid-template-columns: none;
  gap: 10px;
}
.shelf.list-mode .book-card {
  flex-direction: row;
  border-radius: 10px;
}
.shelf.list-mode .cover {
  flex: 0 0 54px;
  aspect-ratio: auto;
  height: 78px;
  padding: 8px;
  border-radius: 10px 0 0 10px;
}
.shelf.list-mode .cover-title { font-size: calc(12px * var(--font-scale)); }
.shelf.list-mode .cover-author { display: none; }
.shelf.list-mode .book-info { padding: 8px 12px; }
.shelf.list-mode .book-name { font-size: calc(14px * var(--font-scale)); }
.shelf.list-mode .book-by { font-size: calc(11px * var(--font-scale)); }
.shelf.list-mode .card-actions {
  margin-left: auto;
  padding: 8px 12px;
  flex-direction: row; gap: 8px; align-items: center;
}
.shelf.list-mode .card-action { padding: 6px 12px; font-size: calc(12px * var(--font-scale)); }
.shelf.list-mode .book-card:hover { transform: none; }


/* ---------- 7. 排列方式切换按钮 ---------- */

.view-modes {
  display: flex; gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.view-mode-btn {
  background: none; border: none;
  width: 32px; height: 30px;
  font-size: calc(16px * var(--font-scale));
  color: var(--text-sub);
  cursor: pointer;
  border-radius: 6px;
}
.view-mode-btn:hover { color: var(--text); }
.view-mode-btn.active {
  background: var(--bg);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}


/* ---------- 8. 书架两栏布局：阅读集 + 书架区 ---------- */

.shelf-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.collections {
  flex: 0 0 184px;
  position: sticky; top: calc(var(--topbar-h) + 60px);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 14px;
}
.collections-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: calc(14px * var(--font-scale)); font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}
.collections-head .icon-btn { padding: 2px 8px; font-size: calc(14px * var(--font-scale)); }

.collection-list { display: flex; flex-direction: column; gap: 2px; }
.collection-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px;
  font-size: calc(13px * var(--font-scale));
  color: var(--text-sub);
  border-radius: 6px;
  cursor: pointer;
}
.collection-item:hover { background: var(--bg-soft); color: var(--text); }
.collection-item.active {
  background: var(--accent-soft);
  color: var(--accent); font-weight: 600;
}
.col-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-right { display: flex; align-items: center; gap: 6px; }
.col-count { font-size: calc(11px * var(--font-scale)); color: var(--text-faint); }
.collection-item.active .col-count { color: var(--accent); }
.col-del {
  background: none; border: none;
  color: var(--text-faint);
  font-size: calc(14px * var(--font-scale));
  cursor: pointer;
  padding: 0 4px;
}
.col-del:hover { color: #C0392B; }

.shelf-main { flex: 1; min-width: 0; }


/* 上传小说区 */
.upload-tip {
  margin: 4px 0 12px;
  font-size: calc(12px * var(--font-scale));
  color: var(--text-sub);
  line-height: 1.7;
}
.upload-tip code {
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: calc(12px * var(--font-scale));
}
.uploaded-list {
  display: flex; flex-direction: column;
  margin-top: 6px;
  border-top: 1px solid var(--border-soft);
}
.uploaded-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: calc(13px * var(--font-scale));
}
.uploaded-row:last-child { border-bottom: none; }
.uploaded-title {
  font-size: calc(14px * var(--font-scale)); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.uploaded-sub {
  font-size: calc(12px * var(--font-scale));
  color: var(--text-sub);
  margin-top: 2px;
}

/* ---------- 8.5 背景设置（我的页） ---------- */

/* 调色盘：一排圆形色块 */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  padding: 0;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
}
.swatch.active { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 自定义取色器 */
.bg-custom {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: calc(13px * var(--font-scale)); color: var(--text-sub); cursor: pointer; margin-left: 4px;
}
.bg-custom input[type="color"] {
  width: 26px; height: 26px; padding: 0;
  border: 1px solid var(--border); border-radius: 6px;
  background: none; cursor: pointer;
}

/* 上传本地图片的按钮（其实是隐藏 file 框的外衣） */
.upload-btn {
  display: inline-block; padding: 7px 14px;
  font-size: calc(13px * var(--font-scale)); border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); cursor: pointer;
}
.upload-btn:hover { border-color: var(--accent); }
/* 上传状态文字：成功 / 失败 / 处理中 */
.upload-status { font-size: 13px; }
.upload-status.ok { color: #2e7d32; }
.upload-status.err { color: #c0392b; }
.upload-status.busy { color: var(--text-sub); }

/* 设置行右侧控件：空间不够时自动换行 */
.settings-ctrl { flex-wrap: wrap; justify-content: flex-end; }


/* ---------- 9. 我的页：统计、最近、设置 ---------- */

.stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}
.stat-num { font-size: calc(26px * var(--font-scale)); font-weight: 700; color: var(--accent); }
.stat-label { font-size: calc(12px * var(--font-scale)); color: var(--text-sub); margin-top: 4px; }

.recent-card {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 14px;
  display: flex; align-items: center; gap: 14px;
}
.recent-cover {
  width: 42px; height: 56px; border-radius: 6px;
  flex-shrink: 0;
}
.recent-title { font-size: calc(15px * var(--font-scale)); font-weight: 600; }
.recent-sub { font-size: calc(12px * var(--font-scale)); color: var(--text-sub); margin-top: 4px; }

.settings {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 4px 16px;
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: calc(14px * var(--font-scale));
}
.settings-row:last-child { border-bottom: none; }
.settings-ctrl { display: flex; align-items: center; gap: 8px; }

/* 「我的」页顶部账号卡：手机号 + 退出登录（已从顶部栏移入本页，紧跟"我的"标题） */
.me-account {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
  font-size: calc(14px * var(--font-scale));
}
.me-phone { color: var(--text); font-weight: 600; }
.me-admin-tag {
  color: #c8a14a;
  font-size: 12px;
  font-weight: 600;
  margin-left: 4px;
}

/* 「我的」页的管理员入口区块 */
.admin-entry { margin-bottom: 26px; }
.admin-entry .section-title { margin-top: 0; }


/* ---------- 10. 目录页 + 阅读页 ---------- */

.book-hero {
  display: flex; gap: 18px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
}
.hero-cover {
  flex: 0 0 100px;
  height: 140px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; text-align: center;
  padding: 8px;
}
.hero-title { font-size: calc(20px * var(--font-scale)); font-weight: 700; }
.hero-author { font-size: calc(13px * var(--font-scale)); color: var(--text-sub); margin-top: 4px; }
.hero-desc { font-size: calc(13px * var(--font-scale)); color: var(--text-sub); margin-top: 10px; line-height: 1.6; }

.chapter-list {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  overflow: hidden;
}
.chapter-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  font-size: calc(14px * var(--font-scale));
}
.chapter-item:last-child { border-bottom: none; }
.chapter-item:hover { background: var(--bg-soft); }
.chapter-item.current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chapter-num {
  flex: 0 0 28px; height: 28px;
  background: var(--bg-soft);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(12px * var(--font-scale)); color: var(--text-sub);
}
.chapter-item.current .chapter-num {
  background: var(--accent); color: #fff;
}

.reader-bar {
  position: sticky; top: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  padding: 8px 20px;
  display: flex; align-items: center; gap: 8px;
  z-index: 50;
}
.spacer { flex: 1; }

.progress {
  height: 3px;
  background: var(--border-soft);
  position: sticky; top: calc(var(--topbar-h) + 46px);
  z-index: 49;
}
.progress-fill {
  height: 100%; width: 0;
  background: var(--accent);
  transition: width .15s;
}

.reader {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 20px 24px;
  background: var(--reader-bg);
  font-size: calc(var(--reader-size) * var(--font-scale));
  line-height: 1.8;
  color: var(--text);
}
/* 分页模式下正文贴满剩余屏幕，底部不留大空隙 */
.reader.paged { padding-bottom: 8px; }
.reader h1 { margin: 0 0 6px; font-size: calc(22px * var(--font-scale)); }
.reader-meta { color: var(--text-sub); font-size: calc(13px * var(--font-scale)); margin: 0 0 24px; }
.reader-body p { margin: 0 0 1em; }

/* ---------- 阅读页底部整体区域：背景面板 + 翻章/翻页 + 工具栏 ---------- */
/* 三块包在 .reader-bottom 里一起 sticky 贴屏幕最底，不会互相打架 */
.reader-bottom {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--border-soft);
  z-index: 50;
}

/* 翻章 + 翻页按钮行：上一章 | 上一页 | 下一页 | 下一章 */
.chapter-nav {
  max-width: 680px;
  margin: 0 auto;
  padding: 10px 16px 0;
  display: flex; gap: 8px;
}
.nav-btn {
  flex: 1;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 2px;
  font-size: calc(13px * var(--font-scale));
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.nav-btn:disabled { opacity: .4; cursor: not-allowed; }


/* ---------- 10.5 阅读页底部工具栏（听书 / 背景 / 翻页 / 书签） ---------- */

/* 工具栏（不再单独 sticky——外层 .reader-bottom 统一贴底） */
.reader-toolbar {
  max-width: 680px;
  margin: 0 auto;
  padding: 8px 16px 10px;
  display: flex; gap: 8px;
}
.tool-btn {
  flex: 1;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 4px;
  font-size: calc(13px * var(--font-scale));
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.tool-btn:hover { border-color: var(--accent); color: var(--accent); }
.tool-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
/* 听书按钮组：🐢 / 🎧听书 / 🐇 横向排在一起，占 2 份宽度；语速按钮按内容自适应 */
.tool-cluster { display: flex; gap: 8px; flex: 2; }
.tool-cluster .tool-btn { flex: 1; }
.tts-rate-btn { flex: 0 0 auto; padding-left: 12px; padding-right: 12px; }

/* 背景设置面板（默认收起，点 🎨 背景 弹出；在底部区域内、位于按钮行上方） */
.reader-bg-panel {
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 12px;
  max-width: 680px;
  margin: 0 auto;
}
.reader-bg-panel.hidden { display: none; }
.rbp-row {
  display: flex; align-items: center; gap: 12px;
  font-size: calc(13px * var(--font-scale));
  flex-wrap: wrap;
}
.rbp-label {
  color: var(--text-sub);
  min-width: 80px;
}

/* ---------- 10.55 分页模式（左右翻页） ----------
   原理：正文放进 .reader-body-wrap（高度锁死为一屏），
   里面的 .reader-body 用 CSS 多列横向排成一页一列；
   JS 每次翻页就把 .reader-body 横向平移一格。 */
.reader.paged .reader-body-wrap {
  overflow: hidden;          /* 别的页先藏起来，只露出当前页 */
  position: relative;
}
.reader.paged .reader-body {
  height: 100%;              /* 高度锁定 = 一页的高度，内容装不下就往右开新列 */
  column-fill: auto;         /* 先把一列填满，再开下一列（不要平均分） */
  transition: transform .22s ease;   /* 翻页时的平滑滑动 */
}
/* 上下滑动模式不受影响：.reader-body-wrap / .reader-body 都恢复自然布局 */

/* ---------- 10.56 沉浸阅读（把上下的工具栏都藏起来） ----------
   body.immersive 由 JS 只在"阅读页显示时"才加，所以漫画页不受影响。
   藏起来之后正文可用高度变大，分页模式下一页能多显示好几行。 */
body.immersive .topbar,          /* 顶部 Logo 条 */
body.immersive .userbar,         /* 登录手机号那条 */
body.immersive .announcement,    /* 公告条 */
body.immersive .reader-bar,      /* 阅读页自己的 返回/目录/书签/字号 */
body.immersive .progress,        /* 顶部那条进度线 */
body.immersive .reader-bottom {  /* 底部 翻章/翻页 + 工具栏 */
  display: none !important;
}
/* 沉浸模式：正文上下不用再给工具栏让位，稍微收一点留白看着更舒服 */
body.immersive .reader { padding-top: 16px; padding-bottom: 16px; }

/* 悬浮的"还原"按钮：平时藏着，进了沉浸模式才出现（右下角半透明小圆钮） */
.immersive-fab {
  display: none;
  position: fixed;
  right: 14px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 200;
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(255, 255, 255, .82);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
  opacity: .5;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
body.immersive .immersive-fab { display: block; }
[data-theme="dark"] .immersive-fab { background: rgba(58, 58, 58, .85); }


/* ---------- 10.6 句子书签 ---------- */
/* 每个句子包成 <span class="sentence">，可点击标记 */
.sentence {
  cursor: pointer;
  padding: 0 2px;
  border-radius: 2px;
  transition: background 0.15s;
  /* 关键：不让一句被分页切到两页之间。否则一句的文字从本页底部流到下一页顶部，
     听书时本页只看到半句、下一页又冒出这半句，看起来就像"读完一句又翻回这页接着读"。 */
  break-inside: avoid;
  page-break-inside: avoid;
  -webkit-column-break-inside: avoid;
}
.sentence:hover {
  background: rgba(83, 74, 183, 0.12);
}
/* 已加书签的句子：黄色背景 + 编号徽章 */
.sentence.bookmarked {
  background: rgba(255, 213, 79, 0.40);
}
.sentence.bookmarked::after {
  content: '📌' attr(data-bm-num);
  font-size: calc(10px * var(--font-scale));
  vertical-align: super;
  margin-left: 2px;
  opacity: 0.7;
  font-weight: 700;
}
/* 关闭书签视图时（pure 阅读），所有高亮/编号都隐藏 */
.reader:not(.bm-view) .sentence.bookmarked {
  background: transparent;
}
.reader:not(.bm-view) .sentence.bookmarked::after {
  display: none;
}

/* ---------- 10.7 听书逐字高亮（卡拉OK式） ----------
   听书时把当前句拆成逐字 <span class="tts-ch">，
   已读到的字加 .read → 灰色底纹，随播放一字一字往右推进 */
.tts-ch {
  border-radius: 2px;
  transition: background 0.08s linear;
}
.tts-ch.read {
  background: rgba(120, 120, 120, 0.45);   /* 已读到的字：灰色底纹 */
}
/* 暗色主题下灰色要更亮一点才看得清 */
[data-theme="dark"] .tts-ch.read {
  background: rgba(170, 170, 170, 0.40);
}

/* 听书方案 B：整句高亮（当前句在念 / 已念完）。整句高亮而非逐字，
   因为服务器合成音频没有逐字边界事件，用整句底色提示"念到哪了" */
.sentence.tts-playing {
  background: rgba(83, 74, 183, 0.22);   /* 主题色浅底：正在朗读 */
}
.sentence.tts-done {
  background: rgba(120, 120, 120, 0.16); /* 已念完：淡灰底（区别于书签的黄色） */
}
[data-theme="dark"] .sentence.tts-playing {
  background: rgba(124, 115, 214, 0.30);
}
[data-theme="dark"] .sentence.tts-done {
  background: rgba(170, 170, 170, 0.18);
}

/* 书签抽屉里的每一项 */
.bookmark-drawer-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  font-size: calc(13px * var(--font-scale));
}
.bookmark-drawer-item:hover {
  background: var(--bg-soft);
}
.bookmark-drawer-item:last-child {
  border-bottom: none;
}
.bm-num {
  flex: 0 0 28px; height: 28px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(12px * var(--font-scale)); font-weight: 700;
  flex-shrink: 0;
}
.bm-info {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.bm-info-sub {
  font-size: calc(11px * var(--font-scale));
  color: var(--text-sub);
  margin-top: 2px;
}


/* ---------- 11. 目录抽屉（右侧滑出） ---------- */

.toc-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
}
.toc {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 320px; max-width: 85vw;
  background: var(--bg);
  z-index: 201;
  display: flex; flex-direction: column;
  box-shadow: -4px 0 16px rgba(0,0,0,.1);
}
.toc-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  font-size: calc(15px * var(--font-scale)); font-weight: 600;
}
.toc-head .icon-btn { padding: 2px 8px; }
#toc-list {
  flex: 1; overflow-y: auto;
}

/* ---- 目录检索栏（阅读页「目录」抽屉顶部，小说 / 漫画共用） ---- */
.toc-search {
  position: relative;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.toc-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 34px 8px 12px;
  font-family: inherit;
  font-size: calc(14px * var(--font-scale));
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  outline: none;
}
.toc-search input::placeholder { color: var(--text-faint); }
.toc-search input:focus {
  border-color: var(--accent);
  background: var(--bg);
}
/* 输入内容后出现的“×”清除按钮 */
.toc-search-clear {
  position: absolute;
  right: 20px; top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1;
  color: var(--text-sub);
  background: transparent;
  border: none; border-radius: 50%;
  cursor: pointer;
}
.toc-search-clear:hover { background: var(--border-soft); color: var(--text); }

/* 检索结果提示行（“共 N 章，匹配 M 章” / “没有匹配的章节”） */
.toc-tip {
  padding: 7px 16px;
  font-size: calc(12px * var(--font-scale));
  color: var(--text-sub);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-soft);
}
.toc-tip.warn { color: #B26A00; }
.toc-tip a { color: var(--accent); text-decoration: none; }
.toc-tip a:hover { text-decoration: underline; }

/* 命中的关键词高亮 */
#toc-list mark {
  background: rgba(255, 213, 79, .55);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}


/* ---------- 12. "加入阅读集"浮层 ---------- */

.picker-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
}
.picker {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 360px; max-width: 92vw; max-height: 80vh;
  background: var(--bg);
  border-radius: 14px;
  z-index: 201;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  overflow: hidden;
}
.picker-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  font-size: calc(15px * var(--font-scale)); font-weight: 600;
}
.picker-head .icon-btn { padding: 2px 8px; }
#picker-list {
  flex: 1; overflow-y: auto;
  padding: 8px 0;
}
.picker-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  cursor: pointer;
  font-size: calc(14px * var(--font-scale));
}
.picker-item:hover { background: var(--bg-soft); }
.picker-item .tick { color: var(--accent); font-weight: 700; }
.picker-new {
  display: flex; gap: 6px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-soft);
}
.picker-new .search { flex: 1; }


/* ---------- 13. 空状态 ---------- */

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-sub);
  font-size: calc(14px * var(--font-scale));
  line-height: 1.8;
  grid-column: 1 / -1;
}


/* ---------- 14. 手机端适配（屏幕窄于 768px） ---------- */

@media (max-width: 768px) {
  :root { --topbar-h: 53px; }

  .topbar { padding: 0 12px; }
  .logo { font-size: 28px; }

  .nav { padding: 0 12px; }
  .nav-tab { padding: 12px 10px; font-size: 14px; }

  main { padding: 16px 12px 60px; }

  .page-head { flex-direction: column; align-items: stretch; }
  .search-inpage { width: 100%; }

  /* 书架两栏在手机上改为竖排：阅读集栏顶部横滚 */
  .shelf-layout { flex-direction: column; gap: 12px; }
  .collections {
    flex: none; width: 100%;
    position: static;
    padding: 10px 12px;
  }
  .collection-list {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
  }
  .collection-item { flex-shrink: 0; padding: 6px 12px; }

  /* 手机封面缩小：一行排 3 本（书架 / 书城 / 漫画楼共用 .shelf），整张卡片跟着瘦一圈 */
  .shelf { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 12px; }
  .book-info { padding: 8px 10px 4px; }
  .book-name { font-size: calc(13px * var(--font-scale)); }
  .book-by { font-size: calc(11px * var(--font-scale)); margin-top: 2px; }
  /* 封面：宽度由栅格决定（一行 3 本，约 100~115px），高度固定 120px，比原来的 3:4 矮一截 */
  .cover { padding: 8px; height: 120px; aspect-ratio: auto; overflow: hidden; }
  .cover-title { font-size: calc(13px * var(--font-scale)); line-height: 1.25; }
  .cover-author { font-size: calc(10px * var(--font-scale)); margin-top: 2px; }
  .card-actions { padding: 6px 8px 8px; gap: 5px; }
  .card-action { padding: 6px 0; font-size: calc(12px * var(--font-scale)); }

  /* 竖列模式：手机上不再变回"整张卡那么大的封面"，
     改成左边一个小缩略图 + 右边书名，一行一本书，一屏能看很多本 */
  .shelf.list-mode .book-card { flex-direction: row; align-items: stretch; }
  .shelf.list-mode .cover {
    flex: 0 0 48px;
    width: 48px; height: 64px;
    aspect-ratio: auto;
    padding: 6px;
    border-radius: 10px 0 0 10px;
    overflow: hidden;
  }
  .shelf.list-mode .cover-title { font-size: calc(10px * var(--font-scale)); }
  .shelf.list-mode .cover-author { display: none; }
  .shelf.list-mode .book-info { padding: 8px 10px; min-width: 0; }
  .shelf.list-mode .book-name { font-size: calc(13px * var(--font-scale)); }
  .shelf.list-mode .card-actions {
    margin-left: auto;
    padding: 6px 8px;
    flex-direction: row; gap: 6px; align-items: center;
  }
  .shelf.list-mode .card-action { padding: 5px 8px; font-size: calc(11px * var(--font-scale)); }

  .stats { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .stat { padding: 14px 8px; }
  .stat-num { font-size: calc(22px * var(--font-scale)); }

  .book-hero { flex-direction: column; align-items: stretch; }
  .hero-cover { width: 80px; height: 112px; }

  /* 阅读页底部工具栏在窄屏上缩小内边距/字号，保证 🐢听书🐇 一行放得下 */
  .reader-toolbar { padding: 6px 10px 8px; gap: 6px; }
  .tool-btn { font-size: calc(12px * var(--font-scale)); padding: 9px 2px; }
  .tts-rate-btn { padding-left: 10px; padding-right: 10px; }
}


/* ---------- 15. 漫画楼 + 漫画阅读器 ---------- */

.comic-title {
  font-size: calc(15px * var(--font-scale)); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 55%;
}

.comic-stage {
  display: flex; justify-content: center; align-items: flex-start;
  padding: 16px 12px 12px;
  background: #F7F6F3;
  min-height: calc(100vh - 250px);
}
[data-theme="dark"] .comic-stage { background: #141414; }

.comic-page {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(0,0,0,.12);
  transform-origin: top center;
  transition: transform .15s ease;
  background: #fff;
}

/* 上传漫画后填写名字的小表单（默认隐藏） */
.comic-form {
  border-top: 1px solid var(--border-soft);
  padding-top: 12px;
  margin-top: 4px;
  display: flex; flex-direction: column; gap: 10px;
}
.comic-form.hidden { display: none; }
.comic-form-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }


/* ---------- 排行榜 ---------- */

/* 第一级：书城 / 漫画楼 大分类切换 */
.rank-scope {
  display: flex; gap: 10px; margin: 4px 0 18px; flex-wrap: wrap;
}
.rank-scope-btn {
  padding: 10px 22px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-sub);
  border-radius: 10px;
  font-size: calc(15px * var(--font-scale));
  cursor: pointer;
  transition: all .15s ease;
}
.rank-scope-btn:hover { border-color: var(--accent); color: var(--text); }
.rank-scope-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

/* 榜单列表 */
.rank-list { display: flex; flex-direction: column; gap: 10px; }
.rank-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease;
}
.rank-row:hover { border-color: var(--accent); transform: translateX(2px); }
.rank-no {
  flex: 0 0 34px; height: 34px; line-height: 34px; text-align: center;
  border-radius: 9px; font-size: calc(15px * var(--font-scale)); font-weight: 700;
  background: var(--bg-soft); color: var(--text-sub);
}
.rank-no.top1 { background: #C9544A; color: #fff; }
.rank-no.top2 { background: #B07A3B; color: #fff; }
.rank-no.top3 { background: #8C7B5A; color: #fff; }
.rank-cover {
  flex: 0 0 40px; height: 54px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: calc(20px * var(--font-scale));
}
.rank-main { flex: 1; min-width: 0; }
.rank-title {
  font-size: calc(15px * var(--font-scale)); color: var(--text); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rank-meta { font-size: calc(12px * var(--font-scale)); color: var(--text-sub); margin-top: 3px; }
.rank-count { flex: 0 0 auto; text-align: right; }
.rank-count .n { font-size: calc(17px * var(--font-scale)); color: var(--accent); font-weight: 700; }
.rank-count .u { font-size: calc(12px * var(--font-scale)); color: var(--text-sub); margin-left: 2px; }
.rank-empty { padding: 34px; text-align: center; color: var(--text-sub); }
.comic-form-hint { font-size: calc(12px * var(--font-scale)); color: var(--text-sub); }

/* ---------- 14. 休息提醒（连续阅读 2 小时强制弹出） ---------- */
.rest-mask {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(20, 18, 30, 0.78);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.rest-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  max-width: 440px; width: 100%;
  padding: 22px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  animation: restPop .28s ease;
}
@keyframes restPop {
  from { transform: scale(.92); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.rest-img {
  width: 100%; max-height: 320px; object-fit: contain;
  border-radius: 12px; background: var(--bg-soft);
}
.rest-tip {
  margin-top: 16px; font-size: calc(17px * var(--font-scale)); font-weight: 700; color: var(--text);
}
.rest-sub {
  margin-top: 6px; font-size: calc(13px * var(--font-scale)); color: var(--text-sub);
}
.rest-btns {
  margin-top: 18px; display: flex; gap: 12px; justify-content: center;
}
.rest-btn {
  flex: 1; max-width: 160px;
  padding: 11px 0; border: none; border-radius: 11px;
  background: var(--accent); color: #fff;
  font-size: calc(15px * var(--font-scale)); font-weight: 600; cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}
.rest-btn:hover { transform: translateY(-1px); opacity: .94; }
.rest-btn.ghost {
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border);
}

/* ---------- 15. 内容页（关于/产品/服务/隐私）与页脚 ---------- */
.legal { max-width: 820px; margin: 0 auto; padding: 8px 20px 56px; }
.legal .page-head { margin-bottom: 16px; }
.legal h2 {
  font-size: calc(19px * var(--font-scale)); font-weight: 700;
  color: var(--text); margin: 30px 0 10px;
}
.legal p {
  font-size: calc(15px * var(--font-scale)); line-height: 1.9;
  color: var(--text); margin: 0 0 14px;
}
.legal ul { margin: 0 0 16px; padding-left: 22px; }
.legal li {
  font-size: calc(15px * var(--font-scale)); line-height: 1.9;
  color: var(--text); margin: 6px 0;
}
.legal .muted { color: var(--text-sub); }
/* 可编辑内容区：纯文本渲染，保留回车换行（管理后台编辑后前台按文本显示） */
.legal .page-body {
  white-space: pre-wrap; word-break: break-word;
  font-size: calc(15px * var(--font-scale)); line-height: 1.95;
  color: var(--text); margin: 0;
}
.legal .back-link {
  display: inline-block; margin-top: 12px; color: var(--accent);
  font-size: calc(14px * var(--font-scale)); cursor: pointer;
}
.legal .back-link:hover { text-decoration: underline; }
.legal .lead {
  font-size: calc(17px * var(--font-scale)); line-height: 1.8;
  color: var(--text-sub); margin: 0 0 22px;
}
.legal h3 {
  font-size: calc(16px * var(--font-scale)); font-weight: 600;
  color: var(--text); margin: 22px 0 6px;
}
.legal code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: calc(13px * var(--font-scale));
  background: var(--bg-soft, rgba(127,127,127,.12));
  padding: 2px 6px; border-radius: 4px;
}

/* 页脚 */
.site-footer {
  background: var(--bg); border-top: 1px solid var(--border-soft);
  padding: 22px 0; margin-top: 8px;
}
.site-footer .wrap {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
}
.site-footer .copy { color: var(--text-sub); font-size: calc(13px * var(--font-scale)); }
.site-footer .footer-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--text-sub); font-size: calc(12px * var(--font-scale)); }
.site-footer .footer-meta span:empty { display: none; }
.site-footer .links { display: flex; flex-wrap: wrap; gap: 18px; }
.site-footer .links span {
  color: var(--text-sub); font-size: calc(13px * var(--font-scale)); cursor: pointer;
}
.site-footer .links span:hover { color: var(--accent); }
.site-footer .footer-motto {
  flex-basis: 100%;
  max-width: 800px; margin: 14px auto 0; padding: 0 20px;
  color: var(--text-sub); font-size: calc(13px * var(--font-scale));
  line-height: 1.95; text-align: center;
}

/* 页脚导航链接（关于我们 / 产品 / 服务 / 隐私政策） */
.site-footer .footer-links {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 18px;
  margin-top: 10px; font-size: calc(13px * var(--font-scale));
}
.site-footer .footer-links a { color: var(--text-sub); text-decoration: none; cursor: pointer; }
.site-footer .footer-links a:hover { color: var(--accent); }
.site-footer .footer-contact { color: var(--text-sub); }

/* 营销页（关于我们 / 产品 / 服务 / 隐私政策）正文排版 */
.view .legal {
  max-width: 860px; margin: 0 auto; padding: 8px 20px 40px;
  color: var(--text); font-size: calc(15px * var(--font-scale));
  line-height: 1.9;
}
.view .legal h2 { font-size: calc(19px * var(--font-scale)); margin: 22px 0 10px; }
.view .legal h3 { font-size: calc(16px * var(--font-scale)); margin: 18px 0 8px; }
.view .legal p { margin: 10px 0; }
.view .legal ul { padding-left: 22px; }
.view .legal li { margin: 6px 0; }