/* 主题：现代阅读器 · 简白风（参考主流阅读 App）
   纯白底 · 大字号衬线正文 · 底部浮动工具栏 · UI 无衬线弱化
   Tailwind 负责布局，这里负责设计系统 */

:root {
  --paper: #ffffff;        /* 页面底 */
  --paper-dark: #f7f8fa;   /* 次级底 */
  --ink: #1f2329;          /* 主文字 */
  --ink-soft: #8a9099;     /* 弱文字 */
  --line: #e5e6eb;         /* 分隔线 */
  --seal: #1f2329;         /* 主操作色（黑） */
  --accent: #3478f6;       /* 链接/选中蓝 */
  --lv1: #3d7d5a; --lv1bg: #e8f3ec;   /* L1 绿 */
  --lv2: #3a6ea8; --lv2bg: #e8effb;   /* L2 蓝 */
  --lv3: #a86a2c; --lv3bg: #fbf1e2;   /* L3 橙 */
  --lv4: #c0453a; --lv4bg: #fdeceb;   /* L4 红 */
  --font-ui: -apple-system, "PingFang SC", "Hiragino Sans GB",
             "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-read: Georgia, "Songti SC", "STSong", "Noto Serif CJK SC", serif;

  /* ---- 设计令牌：圆角 / 阴影 / 动效 ---- */
  --r-sm: 8px;  --r-md: 12px;  --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(31,35,41,.05), 0 4px 16px rgba(31,35,41,.07);
  --shadow-2: 0 12px 40px rgba(31,35,41,.16);
  --ease: cubic-bezier(.4, 0, .2, 1);
  --surface: #ffffff;
  --head-bg: rgba(255, 255, 255, .88);
  --on-ink: #ffffff;
  --line-strong: #d3d7de;
}

/* V9 全站夜间模式（阅读器夜间主题独立于站点暗色） */
html[data-dark="1"] {
  --paper: #17191d;
  --paper-dark: #1f2227;
  --ink: #e6e8eb;
  --ink-soft: #9aa1ab;
  --line: #2c3036;
  --seal: #e6e8eb;
  --accent: #6aa1ff;
  --surface: #1f2227;
  --head-bg: rgba(23, 25, 29, .88);
  --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.5);
  --shadow-2: 0 12px 40px rgba(0,0,0,.6);
  --on-ink: #17191d;
  --line-strong: #3a3f46;
  --lv1bg: #1f2a22; --lv2bg: #1e2731; --lv3bg: #2d2517; --lv4bg: #2e1d1a;
}

body {
  color: var(--ink);
  font-family: var(--font-ui);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 统一键盘焦点环 */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* 统一细滚动条 */
.txt-reader::-webkit-scrollbar, .sheet::-webkit-scrollbar,
.dict-body::-webkit-scrollbar, #reader-body::-webkit-scrollbar { width: 8px; height: 8px; }
.txt-reader::-webkit-scrollbar-thumb, .sheet::-webkit-scrollbar-thumb,
.dict-body::-webkit-scrollbar-thumb, #reader-body::-webkit-scrollbar-thumb {
  background: rgba(31,35,41,.22); border-radius: 8px;
}
.txt-reader, .sheet, .dict-body, #reader-body {
  scrollbar-width: thin; scrollbar-color: rgba(31,35,41,.25) transparent;
}

/* 动画降级偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 骨架屏 */
.sk {
  background: linear-gradient(90deg, var(--line) 25%, var(--paper-dark) 37%, var(--line) 63%);
  background-size: 400% 100%; animation: sk 1.2s ease infinite; border-radius: 6px;
}
@keyframes sk { 0% { background-position: 100% 0 } 100% { background-position: 0 0 } }

::selection { background: rgba(52,120,246,.15); }

/* 阅读正文字体 */
.txt-reader, .txt-reader p { font-family: var(--font-read); }

/* 顶栏 */
.masthead-rule { border-top: none; border-bottom: none; }

/* 难度徽章：小圆角药丸 */
.stamp {
  display: inline-block;
  padding: 2px 9px;
  font-size: 12px;
  letter-spacing: .02em;
  white-space: nowrap;
  border-radius: 999px;
  font-family: var(--font-ui);
}
.stamp.lv1 { color: var(--lv1); background: var(--lv1bg); }
.stamp.lv2 { color: var(--lv2); background: var(--lv2bg); }
.stamp.lv3 { color: var(--lv3); background: var(--lv3bg); }
.stamp.lv4 { color: var(--lv4); background: var(--lv4bg); }
.stamp.na  { color: var(--ink-soft); background: var(--paper-dark); }

.chip {
  display: inline-block; padding: 2px 9px; margin: 1px 3px 1px 0;
  font-size: 12px; border-radius: 6px;
  border: 1px solid var(--line); color: var(--ink-soft); background: var(--surface);
}
button.chip:hover, .chip.link { cursor: pointer; }
.book-card button.chip:hover, .chip.link:hover { border-color: var(--ink-soft); color: var(--ink); }
.chip.link:hover { border-color: var(--accent); color: var(--accent); }

/* 按钮：描边弱化，主按钮实心黑 */
.btn-ticket {
  display: inline-block; padding: 4px 14px;
  font-size: 13px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--ink); background: var(--surface);
  transition: all .14s var(--ease);
}
.btn-ticket:hover { border-color: var(--ink-soft); text-decoration: none; }
.btn-ticket:active { transform: translateY(1px); }
.btn-ticket.seal { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn-ticket.seal:hover { opacity: .85; }

/* 输入控件 */
.field {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  color: var(--ink);
  font-family: var(--font-ui);
}
.field:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52,120,246,.12); }
select.field { padding: 8px 6px; }

/* 书卡 */
.book-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 15px;
  display: flex; flex-direction: column; gap: 6px;
  transition: box-shadow .15s var(--ease), border-color .15s var(--ease);
}
.book-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }

/* 书卡内阅读进度条（继续阅读） */
.progress { height: 3px; border-radius: 999px; background: var(--line); overflow: hidden; }

/* 表格 */
table.gazette { border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); overflow: hidden; }
table.gazette td { border-top: 1px solid var(--line); vertical-align: top; }
table.gazette tr:first-child td { border-top: none; }
table.gazette tbody tr:hover { background: var(--paper-dark); }

/* 桌面列宽 */
td.td-title { width: 44%; }
td.td-meta  { width: 26%; }
td.td-level { width: 8%; }
td.td-dl    { width: 22%; }

/* ---------------------------------------------------------------- 移动端适配 */
@media (max-width: 640px) {
  /* 工具栏：搜索整行 + 下拉双列 */
  .toolbar { display: grid !important; grid-template-columns: 1fr 1fr; }
  .toolbar input[type="search"] { grid-column: 1 / -1; }
  .toolbar select { width: 100%; max-width: 100%; }

  /* 结果表格 → 卡片式堆叠 */
  table.gazette, table.gazette tbody { display: block; }
  table.gazette tr { display: block; padding: 12px 14px;
    border-bottom: 1px solid var(--line); }
  table.gazette tr:last-child { border-bottom: none; }
  table.gazette td { display: block; width: auto !important;
    border-top: none; padding: 3px 0; }
  td.td-title .t { font-size: 15.5px; }
  td.td-meta { margin: 2px 0; }
  td.td-dl { text-align: left; white-space: normal; margin-top: 6px; }
  td.td-dl .btn-ticket { margin: 0 8px 0 0; padding: 7px 22px; }

  /* 阅读器 */
  .txt-reader { padding: 22px 18px 130px; }
  .reader-head { padding: 8px 12px; }
  .dock { gap: 2px; padding: 5px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .dock button { min-width: 70px; }

  /* 防止长词/长类目撑破 */
  .chip, .stamp { max-width: 100%; overflow-wrap: anywhere; }
}

footer .plate { border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- 阅读器 */
#reader {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  background: var(--r-bg, #ffffff);
  color: var(--r-ink, #1f2329);
  transition: background .2s ease;
}
/* 顶栏：极简 */
.reader-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--r-line, rgba(0,0,0,.06));
}
.reader-title {
  font-weight: 600; font-size: 15px; flex: 1 1 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-ui);
}
.reader-tools { display: flex; align-items: center; gap: 6px; }
.reader-tools .btn-ticket { padding: 3px 11px; font-size: 12.5px; }

/* 正文区 */
#reader-body { flex: 1; overflow-y: auto; }
.txt-reader { padding: 44px 24px 140px; }
.txt-reader p {
  max-width: 640px; margin: 0 auto 1em;
  font-size: var(--r-fs, 21px);
  line-height: var(--r-lh, 1.9);
}
.txt-reader p:first-of-type { text-indent: 0; }
.txt-reader .chapter-heading {
  max-width: 640px; margin: 2.2em auto 1.2em;
  font-weight: 700; text-indent: 0 !important;
  font-size: calc(var(--r-fs, 21px) * 1.15);
  scroll-margin-top: 24px;
}

.epub-reader { padding: 0 20px 90px; }

/* 降级提示 */
.fallback-hint {
  max-width: 640px; margin: 0 auto 1.4em;
  font-size: 12.5px; color: var(--ink-soft);
  text-align: center;
  border-bottom: 1px solid var(--line); padding-bottom: 10px;
}

/* 底部浮动工具栏（Dock） */
.dock {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 60;
  display: flex; gap: 4px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 7px;
}
.dock.night { background: rgba(38,41,46,.92); border-color: #33373d; }
.dock button {
  min-width: 88px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 12px 8px;
  border: none; background: transparent; border-radius: 12px;
  color: var(--r-ink, #1f2329); cursor: pointer;
  font-family: var(--font-ui);
  transition: background .14s var(--ease), color .14s var(--ease);
}
.dock.night button { color: #b8bcc2; }
.dock button:hover { background: rgba(31,35,41,.06); }
.dock.night button:hover { background: rgba(255,255,255,.08); }
.dock button:disabled { opacity: .35; cursor: default; }
.dock .d-ico { font-size: 17px; line-height: 1; }
.dock .d-ico svg.lucide { width: 20px; height: 20px; }
.dock .d-lab { font-size: 11.5px; letter-spacing: .02em; }

/* 底部抽屉面板：基础结构样式见文件末尾「V12 阅读体验包」统一面板定义 */
.sheet .toc-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border: none; background: transparent;
  border-radius: 8px; cursor: pointer;
  color: inherit; font-size: 14.5px; font-family: var(--font-ui);
}
.sheet .toc-item:hover { background: rgba(31,35,41,.06); }
.sheet.night .toc-item:hover { background: rgba(255,255,255,.08); }
.sheet .opt-row { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 6px 0; }
.sheet .opt-btn {
  padding: 6px 16px; border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: inherit; cursor: pointer; font-size: 13.5px;
  font-family: var(--font-ui);
}
.sheet .opt-btn:hover { background: var(--paper-dark); }
.sheet .opt-btn.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.sheet input[type="range"] { width: 100%; accent-color: var(--accent); }
.sheet .pct-big { text-align: center; font-size: 30px; font-weight: 700; padding: 4px 0 10px; }

/* 夜间阅读主题的变量覆盖（V12 六主题：原始/纸张/专注/平静/复古/静谧） */
#reader.theme-paper { --r-bg: #f2f3f4; --r-ink: #1f2329; --r-line: rgba(31,35,41,.1); }
#reader.theme-focus { --r-bg: #fbf6e9; --r-ink: #3c3a2f; --r-line: rgba(60,58,47,.14); }
#reader.theme-calm  { --r-bg: #e8ddc3; --r-ink: #453f2f; --r-line: rgba(69,63,47,.18); }
#reader.theme-sepia { --r-bg: #f5efdc; --r-ink: #3a2f1f; --r-line: rgba(58,47,31,.12); }
#reader.theme-night { --r-bg: #454545; --r-ink: #d9dbde; --r-line: rgba(255,255,255,.12); }
#reader.theme-night .reader-head { border-bottom-color: var(--r-line); }
#reader.theme-night .btn-ticket {
  background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.16); color: var(--r-ink);
}
#reader.theme-night .btn-ticket:hover { background: rgba(255,255,255,.16); }

/* ============================================================
   体验打磨层：沉浸模式 / 进度条 / 动效统一
   ============================================================ */

/* 阅读器打开动画 */
#reader { animation: reader-in .2s var(--ease); }
@keyframes reader-in { from { opacity: 0 } }

/* 顶部阅读进度条 */
.reader-progressbar {
  position: absolute; top: 0; left: 0; z-index: 5;
  height: 2px; width: 0%;
  background: var(--accent);
  transition: width .18s linear;
  pointer-events: none;
}

/* 沉浸模式：下滑隐藏顶栏与 Dock，上滑呼出 */
#reader .reader-head, #reader .dock, #reader .tts-bar {
  transition: transform .3s var(--ease), opacity .3s var(--ease);
}
#reader.chrome-hidden .reader-head {
  transform: translateY(-110%); opacity: 0;
}
#reader.chrome-hidden .dock {
  transform: translateX(-50%) translateY(150%); opacity: 0;
  pointer-events: none;
}
#reader.chrome-hidden .sheet { opacity: 0; pointer-events: none; }

/* Dock 选中态 */
.dock button.on { background: rgba(52,120,246,.12); color: var(--accent); }
.dock.night button.on { background: rgba(52,120,246,.28); color: #cfe0ff; }

/* 悬停/按压的统一过渡 */
.book-card, .btn-ticket, .chip, table.gazette tbody tr { transition: all .14s var(--ease); }

/* 生词星弹跳反馈 */
.dict-star { transition: transform .15s var(--ease); }
.dict-star.on { animation: star-pop .32s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes star-pop { 40% { transform: scale(1.4) rotate(-10deg); } }

/* 书内搜索命中定位闪烁 */
.txt-reader p.flash { animation: flash-bg 1.3s var(--ease); }
@keyframes flash-bg { 0%, 40% { background: rgba(52,120,246,.28); } 100% { background: transparent; } }

/* V5 高亮 */
mark.hl { padding: 0 1px; border-radius: 3px; cursor: pointer; }
.hl-y { background: #f7e7a1; }
.hl-g { background: #cde8cf; }
.hl-b { background: #cfe0f7; }

/* 词典弹窗查询动画 */
.dict-spin {
  display: inline-block; width: 12px; height: 12px;
  border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; margin-right: 6px; vertical-align: -2px;
  animation: dict-rotate .7s linear infinite;
}
@keyframes dict-rotate { to { transform: rotate(360deg) } }

/* ============================================================
   V12 阅读体验包：Lucide 图标 / 统一底部面板 / 主题宫格 / 朗读
   ============================================================ */

/* ---------- Lucide 图标基线 ---------- */
svg.lucide { width: 1.05em; height: 1.05em; flex: none; }
.d-ico svg.lucide { width: 19px; height: 19px; }
/* 顶栏深浅色切换：双图标按站点主题显隐（替代 emoji 文本） */
#dark-toggle svg.lucide { width: 19px; height: 19px; display: none; }
html:not([data-dark="1"]) #dark-toggle .ic-moon { display: block; }
html[data-dark="1"] #dark-toggle .ic-sun { display: block; }

/* ---------- 阅读器顶栏 ---------- */
.reader-tools .btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 9px;
}
.reader-tools .btn-icon svg.lucide { width: 17px; height: 17px; }
.reader-tools .btn-icon:disabled { opacity: .35; cursor: default; }

/* ---------- 统一底部面板（目录/标注/主题/排版） ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 58;
  background: rgba(31,35,41,.4);
  opacity: 0; pointer-events: none;
  transition: opacity .3s var(--ease);
}
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }

.sheet {
  /* 面板跟随阅读器主题（而非站点深浅色）：在设计令牌作用域内重映射 */
  --line: var(--r-line, #e5e6eb);
  --ink: var(--r-ink, #1f2329);
  --ink-soft: var(--r-ink-soft, #8a9099);
  --line-strong: var(--r-line, #d3d7de);
  --surface: var(--r-bg, #ffffff);
  --paper-dark: var(--r-bg2, #f7f8fa);
  position: fixed; left: 50%; bottom: 0; z-index: 59;
  transform: translateX(-50%) translateY(105%);
  width: min(640px, 100vw);
  height: min(78vh, 680px);
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--r-bg, #ffffff);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-2);
  font-family: var(--font-ui);
  transition: transform .32s cubic-bezier(.32, .72, 0, 1);
}
.sheet.open { transform: translateX(-50%) translateY(0); }
@media (min-width: 640px) {
  .sheet { bottom: 14px; border-bottom: 1px solid var(--line); border-radius: var(--r-lg); }
}
.sheet.night { --accent: #6aa1ff; --paper-dark: rgba(255,255,255,.08); }

.sheet-grip { flex: none; padding: 9px 0 3px; cursor: grab; touch-action: none; }
.sheet-grip::before {
  content: ""; display: block; width: 40px; height: 4px;
  border-radius: 999px; background: var(--line-strong); margin: 0 auto;
}
.sheet-head {
  flex: none; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 2px 16px 10px;
  border-bottom: 1px solid var(--line);
  cursor: grab;
}
.sheet-head h3 {
  margin: 0; font-size: 15px; font-weight: 700;
  color: var(--ink); letter-spacing: .04em;
}
.sheet-x {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer;
  color: var(--ink-soft); padding: 6px; border-radius: 8px;
}
.sheet-x svg.lucide { width: 18px; height: 18px; }
.sheet-x:hover { color: var(--ink); background: var(--paper-dark); }

.sheet-content { flex: 1; overflow-y: auto; padding: 12px 16px 18px; }

/* 底部 Tab 栏（目录/标注/主题/排版） */
.sheet-tabs {
  flex: none; display: flex;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-tabs button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0 9px; border: none; background: transparent;
  color: var(--ink-soft); font-family: var(--font-ui); font-size: 11.5px;
  cursor: pointer; transition: color .14s var(--ease);
}
.sheet-tabs button svg.lucide { width: 19px; height: 19px; }
.sheet-tabs button:hover { color: var(--ink); }
.sheet-tabs button.on { color: var(--accent); font-weight: 600; }

/* 旧版面板内小型节标题（搜索/进度仍在用） */
.sheet-content .sec-label {
  font-size: 12px; font-weight: 600; color: var(--ink-soft);
  letter-spacing: .08em; margin: 4px 0 8px;
}

/* ---------- 目录面板：分段控件 + 内嵌书内搜索 ---------- */
.seg {
  display: flex; gap: 2px;
  background: var(--paper-dark);
  border-radius: 10px; padding: 3px;
  margin: 2px 0 14px;
}
.seg button {
  flex: 1; border: none; background: transparent; cursor: pointer;
  padding: 7px 0; border-radius: 8px;
  font-family: var(--font-ui); font-size: 13px; color: var(--ink-soft);
  transition: all .15s var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button.on {
  background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 3px rgba(31,35,41,.14);
}
#toc-search { width: 100%; margin-bottom: 12px; }

/* ---------- 目录 Tab ---------- */
.toc-book {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 2px 2px 12px;
  border-bottom: 1px solid var(--line);
}
.toc-book b {
  flex: 1; font-size: 15px; line-height: 1.4;
  word-break: break-all; color: var(--ink);
}
.toc-book svg.lucide { flex: none; color: var(--accent); width: 18px; height: 18px; margin-top: 2px; }
.toc-group {
  padding: 12px 2px 6px;
  font-size: 11.5px; letter-spacing: .12em; color: var(--ink-soft);
}
.toc-chap {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-all;
  width: 100%; text-align: left;
  padding: 12px 6px;
  border: none; border-bottom: 1px solid var(--line);
  background: transparent; cursor: pointer;
  color: var(--ink-soft); font-family: var(--font-ui); font-size: 14px; line-height: 1.5;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.toc-chap:hover { background: var(--paper-dark); color: var(--ink); }
.toc-chap.is-active {
  color: var(--accent); font-weight: 600;
  background: rgba(52,120,246,.07);
  border-radius: 8px; border-bottom-color: transparent;
}
.sheet.night .toc-chap.is-active { background: rgba(106,161,255,.14); }
.toc-empty { padding: 18px 4px; color: var(--ink-soft); font-size: 14px; }

/* ---------- 主题宫格 ---------- */
.theme-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 12px;
  padding: 8px 2px 12px;
}
.theme-tile { border: none; background: transparent; padding: 0; cursor: pointer; font-family: var(--font-ui); }
.theme-tile .swatch {
  height: 88px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(31,35,41,.08);
  transition: box-shadow .15s var(--ease);
}
.theme-tile .swatch span { font-family: var(--font-read); font-size: 27px; font-weight: 600; }
.theme-tile .tname { margin-top: 7px; text-align: center; font-size: 12px; color: var(--ink-soft); }
.theme-tile.on .swatch { box-shadow: inset 0 0 0 2px var(--ink); }  /* 内缩描边：零布局抖动 */
.theme-tile.on .tname { color: var(--ink); font-weight: 600; }

/* ---------- 朗读（TTS） ---------- */
.tts-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 60;
  display: flex; align-items: center; gap: 1px;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 6px;
  font-family: var(--font-ui);
  animation: reader-in .2s var(--ease);
}
.tts-bar.night { background: rgba(38,41,46,.95); border-color: #33373d; }
.tts-bar button {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  border: none; background: transparent; cursor: pointer;
  color: var(--r-ink, #1f2329);
  padding: 9px 10px; border-radius: 11px;
  font-family: var(--font-ui); font-size: 12px;
  transition: background .14s var(--ease);
}
.tts-bar button svg.lucide { width: 18px; height: 18px; }
.tts-bar button:hover { background: rgba(31,35,41,.06); }
.tts-bar.night button { color: #b8bcc2; }
.tts-bar.night button:hover { background: rgba(255,255,255,.08); }
.tts-bar button:disabled { opacity: .35; cursor: default; background: transparent; }
.tts-bar .tts-pos {
  min-width: 70px; text-align: center;
  font-size: 12px; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.tts-bar .tts-rate { min-width: 52px; }

/* 语速调整面板（滑杆 + 快捷预设） */
.tts-rate-pop {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 68px);
  z-index: 61;
  width: min(320px, calc(100vw - 28px));
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  padding: 12px 14px;
  font-family: var(--font-ui);
  animation: reader-in .15s var(--ease);
}
.tts-rate-pop .trp-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12.5px; color: var(--r-ink-soft, var(--ink-soft));
  margin-bottom: 9px;
}
.tts-rate-pop .trp-head b {
  font-size: 14px; color: var(--r-ink, var(--ink));
  font-variant-numeric: tabular-nums;
}
.tts-rate-pop input[type="range"] {
  width: 100%; accent-color: var(--accent); margin: 0;
}
.trp-presets {
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
  margin-top: 10px;
}
.trp-presets button {
  border: 1px solid var(--line); background: transparent;
  color: var(--r-ink, var(--ink));
  font-size: 12px; font-family: var(--font-ui);
  padding: 4px 11px; border-radius: 999px; cursor: pointer;
  transition: all .14s var(--ease);
}
.trp-presets button:hover { border-color: var(--accent); color: var(--accent); }
.trp-presets button.on {
  border-color: var(--accent); color: var(--accent); font-weight: 600;
  background: rgba(52,120,246,.08);
}
.tts-rate-pop.night {
  background: rgba(38,41,46,.97); border-color: #33373d;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.tts-rate-pop.night .trp-presets button { border-color: #3a3f46; }

/* 朗读高亮：优先 CSS Custom Highlight API（不改 DOM），降级为段落底色 */
::highlight(tts-hl) { background-color: rgba(52,120,246,.22); }
.txt-reader p.tts-cur {
  background: rgba(52,120,246,.07);
  border-radius: 6px;
  transition: background .35s var(--ease);
}
