/* ============ 基础与主题变量 ============ */
:root {
  --topbar-h: 56px;
  --player-h: 60px;
  --sidebar-w: 260px;
  --panel-w: 340px;
  --radius: 12px;

  /* 正文字体族（「阅读设置」可切换） */
  --font-serif: "Source Han Serif SC", "Noto Serif CJK SC", "Noto Serif SC", "Songti SC", "STSong", "SimSun", "Source Han Serif", Georgia, serif;
  --font-sans-cjk: "Source Han Sans SC", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  --font-ui: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;

  /* 阅读排版参数：以下 6 个变量由「阅读设置」面板写入 */
  --font-para: var(--font-serif);
  --para-base: 18px;    /* 基准字号，移动端在下方媒体查询里下调 */
  --para-scale: 1;      /* 字号档位倍率 */
  --para-lh: 2;         /* 行高（无单位，随字号缩放） */
  --para-ls: .03em;     /* 字距 */
  --para-gap: 1.1em;    /* 段间距 */
  --content-w: 640px;   /* 正文栏宽：决定每行字数（中文舒适区约 25–35 字） */
}
/* 阅读设置：正文切为黑体 */
body[data-readfont="sans"] { --font-para: var(--font-sans-cjk); }
body[data-theme="sepia"] {
  --bg: #f3ead7; --bg-soft: #ece0c8; --surface: #fbf5e9; --surface-2: #f3e8d2;
  --text: #3a3226; --text-soft: #6b5f49; --border: #ddc9a3; --accent: #b5713a;
  --hl-zhongdian: #ffd966; --hl-shendu: #9ec5e8; --hl-youmei: #f3b6c2;
}
body[data-theme="light"] {
  --bg: #eef1f5; --bg-soft: #e4e8ee; --surface: #ffffff; --surface-2: #f4f6fa;
  --text: #1f2530; --text-soft: #5a6473; --border: #d8dee8; --accent: #2f6fb0;
  --hl-zhongdian: #ffe08a; --hl-shendu: #aad4f5; --hl-youmei: #f7c3d0;
}
body[data-theme="dark"] {
  --bg: #15181d; --bg-soft: #1c2027; --surface: #1f242c; --surface-2: #262d37;
  --text: #d8dde6; --text-soft: #9aa4b2; --border: #333b46; --accent: #5b9bd5;
  --hl-zhongdian: #6d5a1f; --hl-shendu: #2f5a7a; --hl-youmei: #6b3b48;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============ 顶部栏 ============ */
.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.hamburger {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; font-size: 20px; flex: 0 0 auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; color: var(--text);
}
/* 站名必须单行显示：CJK 文本一旦被压缩会逐字折行，撑破固定高度的顶栏 */
.brand { display: flex; align-items: baseline; gap: 8px; cursor: pointer; user-select: none; min-width: 0; }
.brand .logo { font-size: 22px; flex: 0 0 auto; line-height: 1; }
.brand-name {
  font-size: 18px; font-weight: 700; letter-spacing: 1px;
  min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub { font-size: 12px; color: var(--text-soft); white-space: nowrap; }
/* 右侧操作区固定宽度，不参与压缩——否则主题/按钮会被挤到折行 */
.topbar-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.theme-switch { display: flex; gap: 4px; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.theme-switch span {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; cursor: pointer; color: var(--text-soft);
  white-space: nowrap; line-height: 1.4;
}
.theme-switch span.active { background: var(--accent); color: #fff; }

/* ============ 布局 ============ */
.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--panel-w);
  min-height: 0;
}

/* ============ 侧栏 ============ */
.sidebar {
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
}
.shelf-title, .toc-title {
  font-size: 13px; color: var(--text-soft); font-weight: 600;
  margin: 4px 2px 10px; letter-spacing: 1px;
}
.book-card {
  display: flex; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; margin-bottom: 10px;
  cursor: pointer; transition: transform .12s, box-shadow .12s;
}
.book-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.book-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.book-cover {
  width: 42px; height: 56px; border-radius: 6px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  background: linear-gradient(135deg, var(--accent), #d99a5e); color: #fff;
}
.book-meta { min-width: 0; }
.book-title { font-weight: 700; font-size: 14px; }
.book-author { font-size: 12px; color: var(--text-soft); }
.book-progress { font-size: 11px; color: var(--accent); margin-top: 3px; }
.book-progress.muted { color: var(--text-soft); }

/* 章节目录 */
.toc-back { font-size: 12px; color: var(--accent); cursor: pointer; margin: 0 2px 8px; }
.toc-back:hover { text-decoration: underline; }
.toc-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 10px; }
.toc-head .toc-title { margin: 0; }
.toc-count { font-size: 11px; color: var(--text-soft); }
.toc-filter {
  width: 100%; box-sizing: border-box; margin-bottom: 8px; padding: 7px 10px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 13px;
}
.toc-filter::placeholder { color: var(--text-soft); }
.toc-list { padding-bottom: 4px; }
.toc-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px;
  color: var(--text-soft); border-left: 3px solid transparent; margin-bottom: 2px;
}
.toc-item:hover { background: var(--surface); color: var(--text); }
.toc-item.active { background: var(--surface); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc-num {
  flex: 0 0 auto; min-width: 20px; height: 20px; line-height: 20px; text-align: center;
  font-size: 11px; border-radius: 999px; background: var(--surface-2); color: var(--text-soft);
}
.toc-item.active .toc-num { background: var(--accent); color: #fff; }
.toc-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-badge {
  flex: 0 0 auto; font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--accent); border: 1px solid var(--border);
}
.toc-done { flex: 0 0 auto; color: #3f9d63; font-size: 12px; display: none; }
.toc-item.visited .toc-done { display: inline; }
.toc-empty { font-size: 12px; color: var(--text-soft); padding: 8px; }

/* ============ 阅读区 ============ */
.reader { overflow-y: auto; padding: 14px 0; background: var(--bg); }
.reader-empty { display: flex; align-items: center; justify-content: center; height: 100%; }
.empty-card {
  max-width: 460px; text-align: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 36px 30px;
}
.empty-emoji { font-size: 46px; }
.empty-card h2 { margin: 12px 0 6px; }
.empty-card p { color: var(--text-soft); }
.feature-list { text-align: left; list-style: none; padding: 0; margin: 20px auto 0; max-width: 320px; }
.feature-list li { padding: 7px 0; font-size: 14px; border-bottom: 1px dashed var(--border); }

.content { max-width: var(--content-w); margin: 0 auto; padding: 0 28px 60px; }
.book-head { text-align: center; margin-bottom: 28px; }
.book-head h1 { font-family: var(--font-para); font-size: 30px; margin: 0 0 6px; }
.book-head .author { color: var(--text-soft); font-size: 14px; }

.chapter-title {
  font-family: var(--font-para); font-size: 21px; font-weight: 700;
  margin: 34px 0 16px; padding-bottom: 8px; border-bottom: 2px solid var(--border);
}
/* 正文：字号 / 行高 / 字距 / 段间距全部走变量，供「阅读设置」实时调节 */
.para {
  font-family: var(--font-para);
  font-size: calc(var(--para-base) * var(--para-scale));
  line-height: var(--para-lh);
  letter-spacing: var(--para-ls);
  color: var(--text);
  margin: 0 0 var(--para-gap);
  text-align: justify; text-indent: 2em;
  overflow-wrap: break-word;
}
.para.speaking { background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 6px; }

/* 高亮词句 */
.anno {
  cursor: pointer; border-radius: 4px; padding: 1px 2px;
  border-bottom: 2px solid transparent; transition: background .12s;
}
.anno-zhongdian { background: var(--hl-zhongdian); border-bottom-color: #e0b020; }
.anno-shendu { background: var(--hl-shendu); border-bottom-color: #4a90c2; }
.anno-youmei { background: var(--hl-youmei); border-bottom-color: #d36a86; }
.anno:hover { filter: brightness(1.06); }
.anno.hidden-mark { background: transparent !important; border-bottom-color: transparent !important; }
.type-hidden .anno-zhongdian,
.type-hidden .anno-shendu,
.type-hidden .anno-youmei { background: transparent !important; border-bottom-color: transparent !important; }

/* ============ 注解面板 ============ */
.annotation-panel {
  background: var(--surface); border-left: 1px solid var(--border);
  overflow-y: auto; padding: 18px;
}
.ap-empty { text-align: center; color: var(--text-soft); margin-top: 40px; }
.ap-empty-emoji { font-size: 40px; }
.ap-empty p { font-size: 13px; line-height: 1.9; }
.ap-legend { display: flex; gap: 14px; justify-content: center; margin-top: 18px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot-zhongdian { background: var(--hl-zhongdian); border: 1px solid #e0b020; }
.dot-shendu { background: var(--hl-shendu); border: 1px solid #4a90c2; }
.dot-youmei { background: var(--hl-youmei); border: 1px solid #d36a86; }

.ap-card { margin-bottom: 16px; }
.ap-badge {
  display: inline-block; font-size: 11px; font-weight: 700; color: #fff;
  padding: 2px 9px; border-radius: 999px; margin-bottom: 8px;
}
.badge-zhongdian { background: #e0a020; }
.badge-shendu { background: #4a90c2; }
.badge-youmei { background: #d36a86; }
.ap-quote {
  font-family: var(--font-para); font-size: calc(17px * var(--para-scale)); line-height: 1.85; letter-spacing: .02em;
  background: var(--surface-2); border-left: 4px solid var(--accent);
  padding: 10px 14px; border-radius: 0 8px 8px 0; margin-bottom: 12px;
}
.ap-section { margin-bottom: 10px; }
.ap-section h4 {
  font-size: 12px; color: var(--accent); margin: 0 0 4px; letter-spacing: 1px;
}
.ap-section p { font-size: calc(14px * var(--para-scale)); line-height: 1.9; margin: 0; color: var(--text); }
.ap-elevate { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.ap-divider { height: 1px; background: var(--border); margin: 12px 0; }
.ap-close { float: right; cursor: pointer; color: var(--text-soft); font-size: 18px; line-height: 1; }
.ap-close:hover { color: var(--accent); }

/* 类型过滤条 */
.filter-bar { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-chip {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); color: var(--text-soft); user-select: none;
}
.filter-chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ============ 播放器 ============ */
.player {
  height: var(--player-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: var(--surface); border-top: 1px solid var(--border);
  font-size: 13px;
}
.pl-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.pl-btn:hover { border-color: var(--accent); color: var(--accent); }
.pl-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
/* select 会按最长选项撑开自身宽度，必须显式允许收缩，否则窄屏溢出播放器 */
.pl-speed, .pl-voice { display: flex; align-items: center; gap: 6px; color: var(--text-soft); min-width: 0; max-width: 100%; }
.pl-speed input[type="range"] { width: 110px; }
.pl-voice select { min-width: 0; max-width: 100%; }
.pl-status { margin-left: auto; color: var(--text-soft); font-size: 12px; }

.hidden { display: none !important; }

/* ============ 阅读进度条 ============ */
.rp-wrap {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 28px; margin: 0 0 8px;
  background: var(--bg);
}
.rp-bar { flex: 1; height: 4px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.rp-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.rp-text { font-size: 12px; color: var(--text-soft); white-space: nowrap; }

/* ============ 遮罩（移动端抽屉/底部弹层） ============ */
.backdrop { display: none; }

/* ============ 滚动条 ============ */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 顶部「找精华」按钮 ============ */
.topbtn {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.topbtn:hover { border-color: var(--accent); color: var(--accent); }

.empty-cta {
  margin-top: 22px; background: var(--accent); color: #fff; border: none;
  padding: 11px 18px; border-radius: 10px; font-size: 14px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
}
.empty-cta:hover { filter: brightness(1.05); }

/* ============ 找精华弹窗 ============ */
.finder-modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-start; justify-content: center;
  background: rgba(0,0,0,.42); padding: 6vh 14px 14px; overflow-y: auto;
}
.finder-card {
  width: 100%; max-width: 580px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px 24px;
  box-shadow: 0 18px 50px rgba(0,0,0,.3);
}
.finder-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 17px; font-weight: 700; margin-bottom: 6px;
}
.finder-x { background: none; border: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--text-soft); }
.finder-x:hover { color: var(--accent); }
.finder-tip { font-size: 13px; color: var(--text-soft); line-height: 1.7; margin: 0 0 14px; }
.finder-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.ftab {
  flex: 1; padding: 9px; border-radius: 10px; cursor: pointer; font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft);
}
.ftab.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.finder-pane textarea {
  width: 100%; min-height: 84px; resize: vertical; padding: 12px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); font-family: var(--font-ui); font-size: 15px; line-height: 1.6;
}
.finder-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.finder-upload {
  display: inline-block; padding: 9px 14px; border-radius: 10px; cursor: pointer;
  background: var(--surface-2); border: 1px dashed var(--border); color: var(--text);
  font-size: 14px;
}
.finder-imgwrap { margin-top: 12px; text-align: center; }
.finder-imgwrap img { max-width: 100%; max-height: 280px; border-radius: 10px; border: 1px solid var(--border); }
.finder-ocr-status { font-size: 12px; color: var(--text-soft); }
.finder-note { font-size: 12px; color: var(--text-soft); line-height: 1.6; margin: 12px 0 0; }

.finder-results { margin-top: 16px; max-height: 42vh; overflow-y: auto; }
.fres {
  border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px;
  margin-bottom: 10px; cursor: pointer; background: var(--surface-2);
  transition: border-color .12s, transform .12s;
}
.fres:hover { border-color: var(--accent); transform: translateY(-1px); }
.fres-meta { font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 5px; }
.fres-meta .fres-anno { color: var(--text-soft); font-weight: 400; margin-left: 6px; }
.fres-text { font-family: var(--font-para); font-size: 15px; line-height: 1.75; color: var(--text); }
.fres-text mark { background: var(--hl-zhongdian); padding: 0 2px; border-radius: 3px; }
.finder-empty { font-size: 13px; color: var(--text-soft); padding: 10px; text-align: center; }

/* 定位段落高亮 */
.para.found {
  animation: foundPulse 1.1s ease 2;
  box-shadow: 0 0 0 3px var(--accent);
  border-radius: 6px;
}
@keyframes foundPulse {
  0%, 100% { background: transparent; }
  50% { background: color-mix(in srgb, var(--accent) 22%, transparent); }
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: rgba(20,22,28,.92); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 13px; z-index: 70; box-shadow: 0 6px 20px rgba(0,0,0,.3); max-width: 88vw;
}
.toast.hidden { display: none; }

/* ============ 目录页浮层 ============ */
.toc-modal {
  position: fixed; inset: 0; z-index: 62;
  display: flex; align-items: flex-start; justify-content: center;
  background: rgba(0,0,0,.42); padding: 5vh 14px 14px; overflow-y: auto;
}
.toc-modal-card {
  width: 100%; max-width: 520px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px 20px;
  box-shadow: 0 18px 50px rgba(0,0,0,.3); display: flex; flex-direction: column;
  max-height: 88vh;
}
.toc-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 16px; font-weight: 700; margin-bottom: 12px;
}
.toc-modal-list { overflow-y: auto; margin-top: 8px; flex: 1 1 auto; }
.toc-modal .toc-filter { margin-bottom: 0; }

/* ============ 阅读设置（排版）面板 ============ */
.sidebar-tools { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.side-tool {
  width: 100%; display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; text-align: left;
}
.side-tool:hover { border-color: var(--accent); color: var(--accent); }

/* flex 项必须显式 min-height:0，否则在 max-height 卡片里不会收缩，内部滚动失效 */
.type-body { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.type-row { display: flex; align-items: center; gap: 10px; }
.type-label { flex: 0 0 auto; width: 56px; font-size: 13px; color: var(--text-soft); }
.type-seg { flex: 1 1 auto; display: flex; gap: 6px; min-width: 0; flex-wrap: wrap; }
.type-seg button {
  flex: 1 1 auto; min-width: 0; padding: 7px 10px; border-radius: 8px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft);
  font-size: 13px; font-family: var(--font-ui); white-space: nowrap;
}
.type-seg button:hover { border-color: var(--accent); color: var(--accent); }
.type-seg button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 实时预览：直接复用正文的排版变量，所见即所得 */
.type-demo {
  font-family: var(--font-para);
  font-size: calc(var(--para-base) * var(--para-scale));
  line-height: var(--para-lh);
  letter-spacing: var(--para-ls);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: justify;
}
.type-demo p { margin: 0 0 var(--para-gap); text-indent: 2em; }
.type-demo p:last-child { margin-bottom: 0; }
.type-note { font-size: 12px; color: var(--text-soft); margin: 0; line-height: 1.7; }
.type-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 600px) {
  #typeModal .toc-modal-card { max-height: 94vh; }
  .type-body { gap: 10px; }
  .type-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .type-label { width: auto; font-size: 12.5px; }
  .type-seg button { padding: 6px 8px; font-size: 12.5px; }
  .type-demo { padding: 10px 12px; }
  .type-note { display: none; }   /* 窄屏省掉说明文字，给控件与预览让出高度 */
}

/* 章节末尾「返回目录」 */
.back-toc-wrap { text-align: center; margin: 34px 0 10px; }
.back-toc {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 9px 18px; border-radius: 999px; cursor: pointer; font-size: 13px;
}
.back-toc:hover { border-color: var(--accent); color: var(--accent); }

/* ============ 响应式 / 移动端 ============ */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .hamburger { display: inline-flex; }
  .sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: 78%; max-width: 300px;
    transform: translateX(-105%); transition: transform .25s ease; z-index: 40;
    box-shadow: 0 0 24px rgba(0,0,0,.25);
  }
  .sidebar.open { transform: translateX(0); }
  .annotation-panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: 100%;
    max-height: 82%; border-left: none; border-top: 2px solid var(--border);
    border-radius: 16px 16px 0 0; transform: translateY(105%); transition: transform .25s ease; z-index: 50;
  }
  .annotation-panel.open { transform: translateY(0); }
  .backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; display: none; }
  .backdrop.show { display: block; }
  .player { flex-wrap: wrap; height: auto; padding: 8px 12px; row-gap: 6px; }
  /* 窄屏：语音下拉独占一行并随容器收缩，避免长语音名把播放器撑破 */
  .player .pl-voice { flex: 1 1 100%; }
  .player .pl-voice select { flex: 1 1 auto; min-width: 0; }
  .content { padding: 0 16px 90px; }
  .rp-wrap { padding: 6px 16px; }
  :root { --para-base: 17px; }   /* 移动端正文字号下调，行高/字距/段间距按倍率自动跟随 */
  .book-head h1 { font-size: 24px; }
  .brand-sub { display: none; }
  .topbar { padding: 0 12px; gap: 8px; }
  /* 只占内容宽（不拉伸），否则站名的点击热区会铺满整条顶栏、容易误触 */
  .brand { flex: 0 1 auto; margin-right: auto; }
  .brand .logo { font-size: 19px; }
  .brand-name { font-size: 16px; letter-spacing: .5px; }
  .hamburger { width: 32px; height: 32px; font-size: 18px; }
  .topbar-actions { gap: 6px; }
  .topbtn { padding: 6px 9px; font-size: 12px; }
  .topbtn .tb-txt { display: none; }
}

/* ============ 窄屏手机（≤600px）：再压一档，主题切换改图标 ============ */
@media (max-width: 600px) {
  .topbar { padding: 0 6px; gap: 4px; }
  .hamburger { width: 28px; height: 28px; font-size: 16px; }
  .brand { gap: 4px; }
  .brand .logo { font-size: 17px; }
  .brand-name { font-size: 15px; letter-spacing: 0; }
  .topbar-actions { gap: 4px; }
  .topbtn { padding: 5px 5px; }
  /* 三个文字胶囊约 130px，是顶栏最大的一笔开销；窄屏换成同尺寸图标胶囊，
     文字仍保留在 DOM 中（font-size:0 视觉隐藏，读屏可读） */
  .theme-switch { padding: 2px; gap: 2px; }
  .theme-switch span { font-size: 0; padding: 4px; line-height: 1; }
  .theme-switch span::before { font-size: 14px; line-height: 1; }
  .theme-switch span[data-theme-val="sepia"]::before { content: "🌿"; }
  .theme-switch span[data-theme-val="light"]::before { content: "☀️"; }
  .theme-switch span[data-theme-val="dark"]::before { content: "🌙"; }
}

/* 超窄屏（≤350px，如 iPhone SE 一代）：舍掉图标，优先保住完整站名 */
@media (max-width: 350px) {
  .brand .logo { display: none; }
  .topbtn { padding: 5px 4px; }
}

/* ============ 备案信息底栏 ============ */
/* 工信部要求：网站首页底部须展示 ICP 备案号，且链接指向 beian.miit.gov.cn */
.site-footer {
  flex: 0 0 auto;
  margin-top: auto;          /* 内容不足一屏时也贴到底部（维护页等非全屏布局） */
  height: 28px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-soft);
  letter-spacing: .2px;
  user-select: none;
}
.site-footer a { color: var(--text-soft); text-decoration: none; }
.site-footer a:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 920px) {
  .site-footer { height: 24px; font-size: 11px; }
}
