/* ========== 主题变量 ========== */
/* :root 兜底（日间色），保证任何页面即使没有 data-theme 也有完整变量 */
:root {
  --fs: 100%;
  --bg: #f7f5f0; --panel: #ffffff; --text: #2b2a26; --muted: #8a867c;
  --line: #e5e1d8; --accent: #c0392b; --bar: rgba(0,0,0,.05);
}
/* 主题变量挂载到任何带 data-theme 的元素（书架页 body、阅读器 body 通用） */
[data-theme="light"] {
  --bg: #f7f5f0; --panel: #ffffff; --text: #2b2a26; --muted: #8a867c;
  --line: #e5e1d8; --accent: #c0392b; --bar: rgba(0,0,0,.05);
  --speak-bg: rgba(192,57,43,.10);
}
[data-theme="sepia"] {
  --bg: #f1e7d0; --panel: #f8efdb; --text: #4a3f2e; --muted: #9a8a6a;
  --line: #e0d2b0; --accent: #a0522d; --bar: rgba(0,0,0,.06);
  --speak-bg: rgba(160,82,45,.12);
}
[data-theme="dark"] {
  --bg: #1b1b1d; --panel: #26262a; --text: #c8c6c0; --muted: #77756e;
  --line: #3a3a3f; --accent: #e08a3c; --bar: rgba(255,255,255,.06);
  --speak-bg: rgba(224,138,60,.16);
}
/* 网站风格主题（书架页「🎨 主题」选择器，data-theme 挂 body） */
[data-theme="qingci"] {
  --bg: #eef3f0; --panel: #ffffff; --text: #26332d; --muted: #7c8a82;
  --line: #d3e0d8; --accent: #2e7d6b; --bar: rgba(0,0,0,.05);
  --speak-bg: rgba(46,125,107,.12);
}
[data-theme="dailan"] {
  --bg: #eef2f8; --panel: #ffffff; --text: #26303c; --muted: #78838f;
  --line: #d3dce8; --accent: #2c5f9e; --bar: rgba(0,0,0,.05);
  --speak-bg: rgba(44,95,158,.12);
}
[data-theme="yingfen"] {
  --bg: #faf0f2; --panel: #ffffff; --text: #3a2a30; --muted: #9a828a;
  --line: #ecdce1; --accent: #c2546e; --bar: rgba(0,0,0,.05);
  --speak-bg: rgba(194,84,110,.12);
}
[data-theme="ziteng"] {
  --bg: #f3f0fa; --panel: #ffffff; --text: #322a3a; --muted: #8a8094;
  --line: #e0d9ec; --accent: #6b4fa3; --bar: rgba(0,0,0,.05);
  --speak-bg: rgba(107,79,163,.12);
}
[data-theme="moye"] {
  --bg: #17191c; --panel: #20242a; --text: #c4c9cf; --muted: #6f757d;
  --line: #30353c; --accent: #4da3a0; --bar: rgba(255,255,255,.06);
  --speak-bg: rgba(77,163,160,.18);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
/* 修复：hidden 属性被元素自身的 display:flex/grid 覆盖导致无法隐藏 */
[hidden] { display: none !important; }
html, body { height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: none; border-radius: 10px;
  background: transparent; cursor: pointer; color: inherit;
}
.btn-icon svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.btn-icon:hover { background: var(--bar); }
.btn-primary {
  padding: 10px 26px; border: none; border-radius: 24px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 15px;
}
.btn-primary:hover { filter: brightness(1.08); }

/* ========== 书架页 ========== */
.shelf-body { background: var(--bg); color: var(--text); min-height: 100%; }
/* 吸顶导航：滚动时固定在顶部，毛玻璃背景；内容与主栏同宽居中 */
.shelf-header {
  position: sticky; top: 0; z-index: 50;
  padding: 14px 20px 10px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.shelf-top, .shelf-sub { max-width: 1080px; margin-left: auto; margin-right: auto; }
.shelf-brand { font-size: 22px; font-weight: 700; display: flex; align-items: center; }
.brand-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; margin-right: 9px; flex: none;
  border-radius: 9px; background: var(--accent); color: #fff;
}
.brand-logo svg { width: 16px; height: 16px; }
/* 副标题：位于 logo 右下方（与品牌文字左对齐），随导航栏居中行下移 */
.shelf-sub {
  color: var(--muted); font-size: 24px; line-height: 1.3;
  margin: 4px 0 0 39px; text-align: left;
}
/* 导航栏水平居中，位于副标题下方 */
.shelf-nav { display: flex; gap: 4px; margin-top: 10px; justify-content: center; flex-wrap: wrap; }
.shelf-nav-link {
  padding: 5px 14px; border-radius: 16px; text-decoration: none;
  font-size: 26px; color: var(--text); transition: color .15s, background .15s;
}
.shelf-nav-link:hover { color: var(--accent); background: var(--bar); }
/* 导航栏内的管理员「上架新书」入口：品牌色实心胶囊 */
.shelf-nav-link.nav-admin { color: #fff; background: var(--accent); }
.shelf-nav-link.nav-admin:hover { color: #fff; background: var(--accent); filter: brightness(1.08); }
.shelf-main { max-width: 1080px; margin: 0 auto; padding: 20px 20px 40px; }
/* 锚点跳转时预留吸顶导航高度 */
#book-list, #premium-zone { scroll-margin-top: 120px; }
.book-card {
  display: flex; gap: 24px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 24px;
  box-shadow: 0 4px 18px rgba(0,0,0,.05);
}
.book-cover {
  width: 128px; height: 180px; flex: none; border-radius: 8px;
  background: linear-gradient(135deg, #2c3e50, #4a6741);
  color: #fff; font-size: 56px; display: flex; align-items: center; justify-content: center;
}
.book-info { flex: 1; min-width: 0; }
.book-title { font-size: 22px; }
.book-author { color: var(--muted); margin-top: 6px; }
.book-desc { margin-top: 12px; line-height: 1.7; font-size: 14px; color: var(--text); }
.book-tags { margin-top: 8px; line-height: 1.7; }
.book-tags .tag { display: inline-block; margin: 0 6px 4px 0; padding: 1px 10px; border-radius: 999px; font-size: 12px; color: var(--accent); border: 1px solid currentColor; opacity: .9; }
.book-progress { margin-top: 12px; color: var(--accent); font-size: 13px; }
#btn-read { margin-top: 16px; }
.shelf-note { margin-top: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 20px; }
.shelf-note summary {
  cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text);
  user-select: none; padding: 6px 0;
}
.shelf-note summary:hover { color: var(--accent); }
.shelf-note[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.shelf-note ul { padding: 0; }
.shelf-note li { margin: 6px 0 0 20px; line-height: 1.6; font-size: 13px; color: var(--text); }
.shelf-note .uc-actions { margin: 12px 0 4px; }
@media (max-width: 560px) { .book-card { flex-direction: column; } }

/* ========== 账号区与登录弹层 ========== */
.shelf-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.account-area { display: flex; align-items: center; gap: 10px; flex: none; padding-top: 4px; }
.btn-account {
  padding: 9px 20px; border: none; border-radius: 22px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 14px;
}
.btn-account.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-account.ghost:hover { border-color: var(--accent); color: var(--accent); }
.user-email { font-size: 13px; color: var(--muted); }
.sync-state { font-size: 12px; color: var(--accent); }

.auth-overlay {
  position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: ovIn .18s ease;
}
.auth-card {
  background: var(--panel); color: var(--text); border-radius: 16px;
  padding: 26px 28px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
  animation: cardIn .22s ease;
}
@keyframes ovIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.auth-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.auth-tip { font-size: 13px; color: var(--muted); line-height: 1.7; margin-bottom: 14px; }
.auth-tabs { display: flex; gap: 8px; margin-top: 4px; border-bottom: 1px solid var(--line); }
.auth-tab {
  flex: 1; padding: 10px 0; border: none; background: transparent; cursor: pointer;
  font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent;
}
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.auth-links { display: flex; gap: 18px; justify-content: center; margin: 10px 0 2px; }
.auth-links a { font-size: 13px; color: var(--accent); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.auth-row { display: flex; gap: 10px; margin: 10px 0; }
.auth-row select.auth-select,
.auth-select {
  flex: 1; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font-size: 14px; outline: none; min-width: 0;
}
.auth-row input {
  flex: 1; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font-size: 14px; outline: none; min-width: 0;
}
.auth-row input:focus { border-color: var(--accent); }
.auth-textarea {
  flex: 1; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font-size: 14px; outline: none;
  min-width: 0; width: 100%; box-sizing: border-box; resize: vertical;
  font-family: inherit; line-height: 1.6; min-height: 74px;
}
.auth-textarea:focus { border-color: var(--accent); }
.auth-submit { flex: none; }
.auth-error { color: #c0392b; font-size: 13px; margin-top: 8px; }
.auth-note { color: var(--accent); font-size: 13px; margin-top: 8px; line-height: 1.6; }
@media (max-width: 480px) {
  .auth-row { flex-wrap: wrap; }
  .auth-submit { width: 100%; }
  .shelf-top { flex-direction: column; }
}

/* ========== EPUB 上传区（紧凑行） ========== */
.upload-area {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 18px; margin-bottom: 20px;
}
.upload-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.upload-title { font-size: 16px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.upload-count { font-size: 12px; color: var(--muted); font-weight: 400; }
.btn-upload { padding: 10px 24px; border: none; border-radius: 24px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 14px; transition: transform .15s, filter .15s; }
.btn-upload:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-upload.ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); font-size: 13px; padding: 9px 18px;
}
.btn-upload.ghost:hover { color: #c0392b; border-color: #c0392b; filter: none; transform: none; }
.upload-btns { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.upload-hint { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.6; }
.upload-status { margin-top: 10px; font-size: 14px; color: var(--accent); }
.upload-status.error { color: #c0392b; }

/* ========== 书架封面网格（自适应平铺：宽屏最多 4~5 列，手机固定 2 列） ========== */
#book-list.shelf-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px;
}
@media (max-width: 620px) { #book-list.shelf-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.grid-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px; cursor: pointer; position: relative;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  display: flex; flex-direction: column; min-width: 0;
}
.grid-card:hover {
  transform: translateY(-3px); border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(0,0,0,.10);
}
.gc-cover-wrap { position: relative; border-radius: 9px; overflow: hidden; aspect-ratio: 3 / 4; }
.gc-cover {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 40px; line-height: 1;
}
.gc-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gc-badge {
  position: absolute; top: 6px; left: 6px; font-size: 11px; line-height: 1;
  color: #fff; background: rgba(0,0,0,.55); border-radius: 10px; padding: 4px 8px;
}
.gc-badge.warn { background: #e67e22; }
/* 悬停浮层：提示可点击阅读 */
.gc-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.35); opacity: 0; transition: opacity .18s ease;
}
.grid-card:hover .gc-overlay, .grid-card:focus-within .gc-overlay { opacity: 1; }
.gc-read {
  color: #fff; font-size: 13px; border: 1px solid rgba(255,255,255,.8);
  border-radius: 16px; padding: 6px 16px; background: rgba(0,0,0,.25);
}
.gc-title {
  font-size: 14px; font-weight: 600; margin: 9px 2px 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gc-meta {
  font-size: 12px; color: var(--muted); margin: 0 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gc-actions { display: flex; gap: 6px; margin-top: 8px; }
.gc-btn {
  flex: 1; padding: 6px 0; border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 12px;
  transition: color .15s, border-color .15s;
}
.gc-btn:hover { color: var(--accent); border-color: var(--accent); }
.gc-btn[data-del]:hover { color: #c0392b; border-color: #c0392b; }
/* 网格末尾的“导入新书”占位卡 */
.grid-add {
  border: 1.5px dashed var(--line); background: transparent; cursor: pointer;
  align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); font-size: 13px; min-height: 0; display: flex; flex-direction: column;
  aspect-ratio: 3 / 4.2; transition: color .15s, border-color .15s;
}
.grid-add .gc-plus { font-size: 30px; line-height: 1; font-weight: 300; }
.grid-add:hover { color: var(--accent); border-color: var(--accent); transform: none; box-shadow: none; }
/* 空书架引导 */
.shelf-empty-hint {
  grid-column: 1 / -1; color: var(--muted); font-size: 13px;
  text-align: center; margin: 4px 0 0; line-height: 1.7;
}

/* ========== 书籍卡片扩展 ========== */
.book-expire { color: var(--muted); font-size: 12px; margin-top: 6px; }
.book-expire.warn { color: #e67e22; font-weight: 600; }
.book-cover-img { width: 128px; height: 180px; flex: none; border-radius: 8px; object-fit: cover; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.book-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.btn-del {
  padding: 10px 18px; border: 1px solid var(--line); border-radius: 22px;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 14px;
}
.btn-del:hover { border-color: #c0392b; color: #c0392b; }
#book-list .book-card { margin-bottom: 20px; }

/* ========== 阅读器布局 ========== */
.reader-body { background: var(--bg); color: var(--text); display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  background: var(--panel); z-index: 30;
}
.topbar-title { flex: 1; display: flex; align-items: baseline; gap: 10px; min-width: 0; }
#top-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-progress { color: var(--accent); font-size: 13px; flex: none; }

/* 正文 */
.txt-wrap {
  flex: 1; overflow-y: auto; scroll-behavior: smooth;
  padding: 28px 6vw 40px; -webkit-overflow-scrolling: touch;
}
.txt { max-width: 720px; margin: 0 auto; font-size: var(--fs); line-height: 2; }
.txt h1 { font-size: 1.5em; margin: 0 0 22px; line-height: 1.5; }
.txt h2 { font-size: 1.25em; margin: 28px 0 16px; }
.txt h3 { font-size: 1.1em; margin: 24px 0 12px; }
.txt p { margin: 0 0 1em; text-align: justify; }
.txt blockquote {
  margin: 18px 0; padding: 12px 18px; border-left: 4px solid var(--accent);
  background: var(--bar); border-radius: 0 8px 8px 0; color: var(--text);
}
.txt hr { border: none; border-top: 1px solid var(--line); margin: 26px auto; width: 60%; }
/* 三种字体 */
.reader-body[data-font="sans"]  .txt { font-family: "PingFang SC", "Microsoft YaHei", "SimHei", sans-serif; }
.reader-body[data-font="serif"] .txt { font-family: "Songti SC", "SimSun", "Noto Serif SC", serif; }
.reader-body[data-font="kaiti"] .txt { font-family: "Kaiti SC", "KaiTi", "STKaiti", cursive; }

.chapter-nav { max-width: 720px; margin: 30px auto 0; display: flex; justify-content: space-between; }
.btn-chapter {
  padding: 10px 22px; border: 1px solid var(--line); border-radius: 22px;
  background: var(--panel); color: var(--text); cursor: pointer; font-size: 14px;
}
.btn-chapter:disabled { opacity: .35; cursor: default; }
.btn-chapter:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }

/* 底部栏 */
.bottombar {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 16px; border-top: 1px solid var(--line); background: var(--panel);
  font-size: 12px; color: var(--muted); z-index: 30;
}
#bottom-chapter { max-width: 40%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-track { flex: 1; height: 4px; border-radius: 2px; background: var(--bar); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ========== 设置面板 ========== */
.settings-panel {
  position: absolute; top: 56px; right: 12px; z-index: 40;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; width: 300px; box-shadow: 0 10px 30px rgba(0,0,0,.15);
}
.style-row { display: flex; align-items: center; gap: 12px; margin: 12px 0; }
.style-row > label { width: 64px; flex: none; font-size: 13px; color: var(--muted); }
.theme-buttons, .font-btn-group, .font-family-group { display: flex; gap: 8px; }
.theme-btn {
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--line);
}
.theme-btn.light { background: #f7f5f0; }
.theme-btn.sepia { background: #f1e7d0; }
.theme-btn.dark  { background: #1b1b1d; }
.theme-btn.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.font-btn, .font-family-btn {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: var(--text); cursor: pointer; font-size: 13px;
}
.font-btn:hover, .font-family-btn:hover { border-color: var(--accent); }
.font-btn.active, .font-family-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.style-more { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.style-more summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.style-note { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 8px; }

/* ========== 目录抽屉 ========== */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 45;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(320px, 84vw); z-index: 50;
  background: var(--panel); border-right: 1px solid var(--line);
  transform: translateX(-100%); transition: transform .28s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.drawer-list { flex: 1; overflow-y: auto; padding: 10px 8px 20px; }
.toc-group { margin: 14px 8px 4px; font-size: 12px; color: var(--muted); }
.toc-item {
  display: block; width: 100%; text-align: left; padding: 11px 12px;
  border: none; background: transparent; color: var(--text); cursor: pointer;
  border-radius: 8px; font-size: 14px; line-height: 1.5;
}
.toc-item:hover { background: var(--bar); }
.toc-item.current { color: var(--accent); font-weight: 600; background: var(--bar); }

/* ========== 新手引导 ========== */
.guide-overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.guide-card {
  background: var(--panel); color: var(--text); border-radius: 16px;
  padding: 26px 28px; max-width: 420px; width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.guide-card h3 { margin-bottom: 14px; }
.guide-card ul { list-style: none; }
.guide-card li { margin: 9px 0; font-size: 14px; line-height: 1.7; }
.guide-card b { color: var(--accent); }
#btn-guide-ok { width: 100%; margin-top: 18px; }

/* 翻页闪动 */
@keyframes turnFlash { 0% { opacity: .35; } 100% { opacity: 1; } }
.txt.turning { animation: turnFlash .18s ease; }

/* ========== 智能朗读 ========== */
.speaking {
  background: var(--speak-bg);
  border-radius: 6px;
  box-shadow: -4px 0 0 0 var(--accent) inset;
  transition: background .2s;
}
.tts-fab {
  position: fixed; right: 18px; bottom: 64px; z-index: 60;
  width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 20px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center;
}
.tts-fab:hover { filter: brightness(1.08); }
.tts-fab .stop-dot { display: none; }
.tts-panel {
  position: fixed; right: 18px; bottom: 126px; z-index: 61;
  width: 300px; max-width: calc(100vw - 32px);
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 16px;  padding: 16px 18px; box-shadow: 0 16px 40px rgba(0,0,0,.22);
}
.tts-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 700; }
.tts-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.tts-ctl {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; color: var(--text); cursor: pointer; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
}
.tts-ctl:hover { border-color: var(--accent); color: var(--accent); }
.tts-ctl.tts-main { background: var(--accent); color: #fff; border: none; font-size: 17px; }
.tts-setting label { font-size: 13px; color: var(--muted); flex: none; }
.tts-setting select {
  flex: 1; min-width: 0; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font-size: 13px;
}
.tts-setting input[type="range"] { flex: 1; accent-color: var(--accent); }
#tts-rate-val { font-size: 12px; color: var(--muted); width: 38px; text-align: right; }
.tts-check { font-size: 13px; color: var(--text); cursor: pointer; }
.tts-check input { accent-color: var(--accent); }
.tts-tip { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 8px; }
@media (max-width: 560px) { .tts-fab { right: 14px; bottom: 58px; width: 46px; height: 46px; } }

/* ========== 付费专区 ========== */
.premium-zone { margin-top: 32px; }
.premium-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.premium-head h3 { font-size: 20px; }
.premium-sub { font-size: 13px; color: var(--accent); }
/* 专题分组（双列排版，窄屏自动回退单列） */
#premium-list.topic-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0 24px; align-items: start;
}
.premium-topic { margin-bottom: 22px; }
.premium-topic-name {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 16px; margin: 0 0 10px; padding-left: 10px;
  border-left: 3px solid var(--accent); line-height: 1.3;
}
.premium-topic-count { font-size: 12px; color: var(--muted); font-weight: 400; }
/* 可折叠专题标题：点击展开/收起 */
.premium-topic-name.foldable { cursor: pointer; user-select: none; }
.premium-topic-name.foldable:hover { color: var(--accent); }
.premium-topic-chev {
  margin-left: auto; font-size: 13px; color: var(--muted);
  transition: color .15s;
}
.premium-topic-name.foldable:hover .premium-topic-chev { color: var(--accent); }
/* 专题折叠：展开/收起按钮 */
.btn-topic-toggle {
  display: block; width: 100%; margin: 4px 0 8px; padding: 9px 0;
  border: 1px dashed var(--line); border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 13px;
  transition: color .15s, border-color .15s;
}
.btn-topic-toggle:hover { color: var(--accent); border-color: var(--accent); }
.uc-tip-line { font-size: 12px; color: var(--muted); margin: 10px 2px; line-height: 1.6; }
.premium-note { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.premium-card {
  display: flex; gap: 24px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 24px;
  box-shadow: 0 4px 18px rgba(0,0,0,.05); position: relative; margin-bottom: 16px;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.premium-card:hover {
  transform: translateY(-3px); border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(0,0,0,.10);
}
/* 双列专题下卡片自适应：缩小封面与内边距 */
#premium-list.topic-grid .premium-card { padding: 16px; gap: 14px; }
#premium-list.topic-grid .premium-card .book-cover { width: 92px; height: 130px; font-size: 40px; }
@media (max-width: 900px) { #premium-list.topic-grid { grid-template-columns: 1fr; } }
.premium-card .badge-paid {
  position: absolute; top: 14px; right: 14px; font-size: 12px;
  color: #fff; background: #27ae60; border-radius: 12px; padding: 3px 12px;
}
.premium-card .badge-delisted {
  position: absolute; top: 14px; right: 14px; font-size: 12px;
  color: #fff; background: #95a5a6; border-radius: 12px; padding: 3px 12px;
}
.premium-card .badge-paid + .badge-delisted { top: 44px; }
.premium-card.inactive { opacity: .65; }
.premium-admin { display: flex; gap: 10px; justify-content: center; margin: 12px 0 4px; flex-wrap: wrap; }
.btn-prem-main {
  padding: 9px 22px; border: none; border-radius: 20px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 14px;
}
.btn-prem-main:hover { filter: brightness(1.08); }
.btn-prem-main.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-prem-main.ghost:hover { color: var(--accent); border-color: var(--accent); filter: none; }
.prem-admin-btns { display: flex; gap: 8px; margin-top: 10px; }
.btn-prem {
  padding: 7px 16px; border: 1px solid var(--line); border-radius: 16px;
  background: transparent; color: var(--muted); font-size: 13px; cursor: pointer;
}
.btn-prem:hover { color: var(--accent); border-color: var(--accent); }
.btn-prem.danger:hover { color: #c0392b; border-color: #c0392b; }
.btn-prem:disabled { opacity: .5; cursor: default; }

/* ========== 用户中心 / 管理员中心 ========== */
.uc-card { width: min(560px, 94vw); max-height: 82vh; overflow-y: auto; }
.uc-body { margin-top: 6px; }
.uc-tabs { display: flex; gap: 8px; margin-top: 10px; border-bottom: 1px solid var(--line); }
.uc-tab {
  padding: 10px 16px; border: none; background: transparent; cursor: pointer;
  font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent;
}
.uc-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.uc-sec { margin-top: 16px; }
.uc-sec h4 {
  font-size: 13px; color: var(--muted); margin: 0 0 8px;
  font-weight: 600; letter-spacing: .05em;
}
.uc-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 6px; font-size: 14px; background: var(--panel);
}
.uc-row-l { color: var(--text); }
.uc-row-r { color: var(--muted); text-align: right; word-break: break-all; }
.uc-empty { color: var(--muted); font-size: 13px; padding: 6px 2px; }
.uc-loading { color: var(--muted); font-size: 14px; padding: 20px 0; text-align: center; }
.uc-money { color: var(--accent); font-size: 16px; }
.uc-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.ac-book {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  margin-bottom: 8px; background: var(--panel); flex-wrap: wrap;
}
.ac-book-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ac-book-info b { font-size: 14px; }
.ac-book-info span { font-size: 12px; color: var(--muted); }
.ac-book-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.premium-price { font-size: 20px; font-weight: 700; color: var(--accent); margin-top: 12px; }
.premium-price s { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.btn-buy {
  margin-top: 14px; padding: 9px 26px; border: none; border-radius: 22px; cursor: pointer;
  background: linear-gradient(90deg, #c0392b, #e67e22); color: #fff; font-size: 14px;
}
.btn-buy:hover { filter: brightness(1.08); }
.btn-buy[disabled] { opacity: .5; cursor: default; }
.btn-open-premium {
  margin-top: 14px; padding: 9px 26px; border: 1px solid var(--accent); border-radius: 22px;
  background: transparent; color: var(--accent); font-size: 14px; cursor: pointer;
}
.btn-open-premium:hover { background: var(--bar); }

/* ---------- 收银台 ---------- */
.pay-card { max-width: 420px; }
.pay-book {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 14px; display: flex; justify-content: space-between; gap: 12px;
}
.pay-book .pb-title { font-weight: 700; font-size: 14px; }
.pay-book .pb-author { font-size: 12px; color: var(--muted); margin-top: 4px; }
.pay-book .pb-price { font-size: 20px; font-weight: 700; color: var(--accent); flex: none; }
.pay-channels { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.pay-channel {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border: 2px solid var(--line); border-radius: 12px; background: transparent;
  cursor: pointer; text-align: left; color: var(--text);
}
.pay-channel .pay-logo {
  width: 36px; height: 36px; flex: none; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; font-weight: 600;
}
.pay-logo.logo-wx { background: #27ae60; }
.pay-logo.logo-alipay { background: #1677ff; }
.pay-channel b { display: block; font-size: 14px; }
.pay-channel i { font-style: normal; font-size: 12px; color: var(--muted); }
.pay-channel.wx.active { border-color: #27ae60; background: rgba(39,174,96,.08); }
.pay-channel.alipay.active { border-color: #1677ff; background: rgba(22,119,255,.08); }
.pay-btn { width: 100%; font-size: 16px; padding: 12px; }
.pay-note { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 10px; }
.pay-error { color: #c0392b; font-size: 13px; margin-top: 8px; }
.pay-state { text-align: center; padding: 18px 0 6px; }
.pay-state .spinner {
  width: 38px; height: 38px; border-radius: 50%; margin: 0 auto 12px;
  border: 4px solid var(--line); border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pay-state p { font-size: 14px; line-height: 1.7; }
@media (max-width: 560px) { .premium-card { flex-direction: column; } }

/* ========== 阅读笔记面板 ========== */
.notes-panel {
  position: fixed; right: 18px; bottom: 126px; z-index: 62;
  width: 360px; max-width: calc(100vw - 32px);
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0,0,0,.18);
  padding: 14px 16px; display: flex; flex-direction: column;
}
.notes-head { display: flex; align-items: center; justify-content: space-between; }
.notes-head h3 { font-size: 15px; }
.notes-book { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.notes-area {
  width: 100%; min-height: 200px; max-height: 46vh; resize: vertical;
  background: var(--bg, transparent); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; line-height: 1.7;
  font-family: inherit; outline: none; box-sizing: border-box;
}
.notes-area:focus { border-color: var(--accent); }
.notes-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.notes-state { font-size: 12px; color: var(--muted); }
.notes-actions { display: flex; gap: 8px; }
.notes-save { background: var(--accent); color: #fff; border-color: var(--accent); }
@media (max-width: 560px) {
  .notes-panel { right: 12px; left: 12px; width: auto; bottom: 110px; }
}

/* ========== 图书 AI 总结面板（与笔记面板同位置） ========== */
.ai-panel {
  position: fixed; right: 18px; bottom: 126px; z-index: 62;
  width: 380px; max-width: calc(100vw - 32px);
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0,0,0,.18);
  padding: 14px 16px; display: flex; flex-direction: column;
}
.ai-body {
  min-height: 120px; max-height: 44vh; overflow-y: auto;
  background: var(--bg, transparent); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; line-height: 1.75;
  white-space: pre-wrap; word-break: break-word;
}
.ai-empty { color: var(--muted); font-size: 13px; line-height: 1.7; margin: 0; }
.ai-state { font-size: 12px; color: var(--accent); margin: 6px 0 0; }
.ai-state.ai-state-err { color: #c0392b; }
.ai-panel .notes-foot { margin-top: 8px; }
.ai-panel .notes-book { margin-bottom: 8px; }
@media (max-width: 560px) {
  .ai-panel { right: 12px; left: 12px; width: auto; bottom: 110px; }
}

/* ========== 中英互译：点读译文面板 ========== */
.trans-panel {
  position: fixed; right: 18px; bottom: 126px; z-index: 62;
  width: 380px; max-width: calc(100vw - 32px);
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0,0,0,.18);
  padding: 14px 16px;
}
.trans-src {
  font-size: 13px; color: var(--muted); line-height: 1.7;
  max-height: 15vh; overflow-y: auto;
  background: var(--bar); border-radius: 8px; padding: 8px 10px;
}
.trans-out {
  font-size: 14px; line-height: 1.8; margin: 10px 0 0;
  max-height: 34vh; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}
.trans-tip { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 10px; }
@media (max-width: 560px) {
  .trans-panel { right: 12px; left: 12px; width: auto; bottom: 110px; }
}

/* ========== 用户中心·我的笔记 ========== */
.uc-note {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 10px; background: var(--panel);
}
.uc-note-head {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none;
}
.uc-note-head:hover b { color: var(--accent); }
.uc-note-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.uc-note-info b { font-size: 14px; }
.uc-note-info span { font-size: 12px; color: var(--muted); }
.uc-note-arrow { color: var(--muted); flex: none; margin-left: 8px; }
.uc-note-preview {
  font-size: 12px; color: var(--muted); margin-top: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.uc-note-body {
  margin: 8px 0 0; padding: 10px 12px;
  background: var(--bg, rgba(0,0,0,.04)); border: 1px solid var(--line);
  border-radius: 8px; white-space: pre-wrap; word-break: break-word;
  font-family: inherit; font-size: 13px; line-height: 1.8; color: var(--text);
}

/* ========== 分享 / 发布书籍 ========== */
.share-btns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ========== 问题反馈表单 ========== */
.fb-form { display: flex; flex-direction: column; }
.fb-label { font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.fb-types { display: flex; gap: 8px; flex-wrap: wrap; }
.fb-type {
  padding: 7px 14px; border-radius: 18px; cursor: pointer; font-size: 13px;
  border: 1px solid var(--line); background: transparent; color: var(--text);
}
.fb-type.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.fb-input {
  width: 100%; padding: 10px 12px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 10px;
  background: transparent; color: var(--text); outline: none; box-sizing: border-box;
}
.fb-input:focus { border-color: var(--accent); }
.fb-detail { min-height: 90px; resize: vertical; line-height: 1.6; }

/* ========== 沉浸阅读：滚动停止 3 秒后自动隐藏顶栏/底栏 ========== */
.topbar, .bottombar { transition: max-height .28s ease, padding .28s ease, transform .28s ease; overflow: hidden; }
.reader-body.immersive .topbar { max-height: 0; padding-top: 0; padding-bottom: 0; border-bottom-width: 0; }
.reader-body.immersive .bottombar { max-height: 0; padding-top: 0; padding-bottom: 0; border-top-width: 0; }
.settings-panel, .tts-panel, .notes-panel { transition: opacity .2s ease; }
.reader-body.immersive .tts-fab { opacity: .35; }
.reader-body.immersive .tts-fab:hover { opacity: 1; }

/* ========== 移动端底部导航（书架页小屏显示） ========== */
.mnav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  background: var(--panel); border-top: 1px solid var(--line);
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
}
.mnav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 11px; padding: 6px 18px; border-radius: 10px;
}
.mnav-btn svg { width: 22px; height: 22px; }
.mnav-btn:active { color: var(--accent); background: var(--bar); }
@media (max-width: 700px) {
  .mnav { display: flex; }
  .shelf-nav { gap: 2px; margin-top: 8px; }
  .shelf-nav-link { padding: 3px 9px; font-size: 17px; border-radius: 14px; }
  .shelf-body { padding-bottom: 70px; }
  .shelf-header { padding-left: 14px; padding-right: 14px; }
  .shelf-main { padding-left: 14px; padding-right: 14px; }
  .shelf-sub { display: none; }
  .auth-overlay { align-items: flex-end; padding: 12px; }
  .auth-card { max-height: 86vh; overflow-y: auto; border-radius: 18px 18px 0 0; animation: sheetIn .24s ease; }
  @keyframes sheetIn { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
}

/* ========== 触屏设备：保证触控目标不小于 44px ========== */
@media (pointer: coarse) {
  .gc-btn, .btn-del, .btn-prem, .font-btn, .font-family-btn,
  .btn-icon, .mnav-btn, .fb-type, .btn-chapter {
    min-height: 44px; min-width: 44px;
  }
  .gc-btn { padding: 10px 0; }
  .btn-prem { padding: 10px 16px; }
}

/* ========== 网站风格主题选择器（书架页导航「🎨 主题」） ========== */
.theme-pop {
  position: fixed; top: 118px; left: 50%; transform: translateX(-50%);
  z-index: 60; width: min(360px, 88vw);
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; box-shadow: 0 14px 40px rgba(0,0,0,.18);
  animation: themePopIn .18s ease;
}
@keyframes themePopIn { from { opacity: 0; transform: translateX(-50%) translateY(-6px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.theme-pop-head { font-size: 14px; color: var(--muted); margin-bottom: 12px; letter-spacing: 1px; }
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-swatch {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px 8px; border: 1.5px solid var(--line); border-radius: 12px;
  background: transparent; color: var(--text); cursor: pointer; font-size: 13px;
  transition: border-color .15s, color .15s;
}
.theme-swatch .sw { width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(0,0,0,.1); }
.theme-swatch:hover { border-color: var(--accent); }
.theme-swatch.active { border-color: var(--accent); color: var(--accent); }
@media (max-width: 700px) { .theme-pop { top: 96px; } .theme-grid { grid-template-columns: repeat(3, 1fr); } }

/* ========== 自定义整站背景（管理员在「背景设置」上传） ========== */
body.shelf-body.has-bg {
  background: url('/uploads/bg_cover.jpg') center / cover no-repeat fixed, var(--bg);
}
/* 移动端：背景图自适应——iOS 不支持 background-attachment:fixed（会不铺满/抖动），改用 scroll 随内容滚动并始终覆盖，cover 保持不变形 */
@media (max-width: 700px) {
  body.shelf-body.has-bg {
    background-attachment: scroll;
  }
}
body.shelf-body.has-bg .shelf-header {
  background: color-mix(in srgb, var(--panel) calc(var(--bg-alpha, 0.74) * 100%), transparent);
}
body.shelf-body.has-bg .shelf-main {
  background: color-mix(in srgb, var(--panel) calc(var(--bg-alpha, 0.9) * 100%), transparent);
  border-radius: 18px;
  margin-top: 14px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

.uc-field { margin: 10px 0; }
.uc-field-label { display: block; margin-bottom: 8px; font-size: 13px; opacity: .85; }
.alpha-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.alpha-opt { flex: 1 1 auto; min-width: 64px; padding: 7px 10px; border: 1px solid color-mix(in srgb, var(--ink) 25%, transparent); border-radius: 8px; background: transparent; color: var(--ink); font-size: 13px; cursor: pointer; }
.alpha-opt.active { background: var(--brand, #c0392b); border-color: var(--brand, #c0392b); color: #fff; }

