/* ============================================
   听书 PWA — 样式系统
   移动端优先 · 亮色/暗色主题 · 毛玻璃效果
   ============================================ */

/* ===== CSS 变量 ===== */
:root {
  /* 主色调 */
  --primary: #6C5CE7;
  --primary-light: #a29bfe;
  --primary-dark: #5649e0;
  --accent: #00cec9;
  --accent-warm: #fd79a8;

  /* 亮色主题 */
  --bg-primary: #f5f5fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eeeef5;
  --bg-elevated: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.72);
  --bg-glass-strong: rgba(255, 255, 255, 0.88);

  --text-primary: #2d3436;
  --text-secondary: #636e72;
  --text-tertiary: #b2bec3;
  --text-on-primary: #ffffff;

  --border-color: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.15);

  /* 封面色板 */
  --cover-1: linear-gradient(135deg, #667eea, #764ba2);
  --cover-2: linear-gradient(135deg, #f093fb, #f5576c);
  --cover-3: linear-gradient(135deg, #4facfe, #00f2fe);
  --cover-4: linear-gradient(135deg, #43e97b, #38f9d7);
  --cover-5: linear-gradient(135deg, #fa709a, #fee140);
  --cover-6: linear-gradient(135deg, #30cfd0, #330867);
  --cover-7: linear-gradient(135deg, #a8edea, #fed6e3);
  --cover-8: linear-gradient(135deg, #ff9a9e, #fecfef);

  /* 尺寸 */
  --header-h: 56px;
  --tabbar-h: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* 阴影 */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
  --shadow-glow: 0 0 24px rgba(108, 92, 231, 0.3);

  /* 动画 */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-fast: 0.2s var(--ease-out);
  --transition: 0.3s var(--ease-out);
  --transition-slow: 0.5s var(--ease-out);

  /* 安全区域 */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== 暗色主题 ===== */
[data-theme="dark"] {
  --bg-primary: #1a1a2e;
  --bg-secondary: #242442;
  --bg-tertiary: #1e1e38;
  --bg-elevated: #2a2a4a;
  --bg-glass: rgba(36, 36, 66, 0.72);
  --bg-glass-strong: rgba(36, 36, 66, 0.92);

  --text-primary: #e8e8f0;
  --text-secondary: #a0a0b8;
  --text-tertiary: #6c6c8a;
  --text-on-primary: #ffffff;

  --border-color: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* ===== 全局重置 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
  user-select: none;
  -webkit-user-select: none;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

/* ===== App 容器 ===== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--bg-primary);
}

/* ===== 顶部导航 ===== */
.app-header {
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 20px;
  padding-right: 12px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 0.5px solid var(--border-color);
  position: relative;
  z-index: 100;
  transition: background var(--transition), border-color var(--transition);
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.icon-btn:active {
  background: var(--bg-tertiary);
  transform: scale(0.92);
}

.theme-btn .icon-moon { display: none; }
[data-theme="dark"] .theme-btn .icon-sun { display: none; }
[data-theme="dark"] .theme-btn .icon-moon { display: block; }

/* ===== 页面容器 ===== */
.pages-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.page {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px);
  transition: opacity var(--transition), transform var(--transition);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.page.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
  z-index: 1;
}

.page-content {
  padding: 16px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 20px);
  min-height: 100%;
}

/* ===== 书架页 ===== */
.library-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  transition: all var(--transition-fast);
}

.tab.active {
  background: var(--primary);
  color: var(--text-on-primary);
  box-shadow: var(--shadow-glow);
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.book-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.book-card:active {
  transform: scale(0.96);
}

.book-cover-mini {
  height: 120px;
  position: relative;
  overflow: hidden;
}

.book-cover-mini::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.4));
}

.book-cover-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.6);
}

.book-fav-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.book-fav-badge svg {
  width: 16px;
  height: 16px;
  fill: #fdcb6e;
  stroke: #fdcb6e;
}

.book-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.3);
  z-index: 2;
}

.book-progress-fill {
  height: 100%;
  background: #fff;
  border-radius: 0 2px 2px 0;
}

.book-info-mini {
  padding: 10px 12px;
}

.book-title-mini {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-author-mini {
  font-size: 12px;
  color: var(--text-tertiary);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}

.empty-state p {
  margin-top: 12px;
  font-size: 16px;
}

.empty-state .sub {
  font-size: 13px;
  margin-top: 4px;
}

/* ===== 播放器页 ===== */
/* 播放器页特殊布局：禁止页面级滚动，内容仅限文本预览区内滚动 */
.page-player {
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: auto;
  /* 关键：固定播放器页高度，防止内容超出 */
  height: 100%;
}

.page-player .page-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0; /* 关键：覆盖通用的 min-height:100%，否则 flex 布局被撑破 */
  overflow: hidden; /* 兜底：杜绝任何内容溢出到页面层 */
  padding: 12px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
}

.page-player .text-preview {
  flex: 1 1 0; /* flex-basis:0 确保从零开始分配空间，不会被内容撑破 */
  min-height: 60px;
  max-height: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y; /* 只允许垂直触摸滚动 */
}

.player-book-info {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.book-cover {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
  flex-shrink: 0;
  background: var(--cover-1);
}

.book-meta {
  flex: 1;
  min-width: 0;
}

.book-title {
  font-size: 18px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-author {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* 章节选择器 */
.chapter-selector {
  position: relative;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.chapter-current {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.chapter-label {
  font-size: 12px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.chapter-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 50;
}

.chapter-dropdown.show {
  display: block;
  animation: dropIn 0.2s var(--ease-out);
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chapter-item {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 0.5px solid var(--border-color);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.chapter-item:last-child { border-bottom: none; }
.chapter-item:active { background: var(--bg-tertiary); }
.chapter-item.current {
  color: var(--primary);
  font-weight: 600;
}

/* 进度条 */
.progress-section {
  margin-bottom: 16px;
  flex-shrink: 0;
}

.progress-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
  position: relative;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 16px;
  height: 16px;
  background: var(--primary);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow-md);
  transition: left 0.3s ease;
  opacity: 0;
}

.progress-bar:active .progress-thumb {
  opacity: 1;
}

.progress-times {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* 主播放控制 */
.player-controls-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.ctrl-btn:active { transform: scale(0.9); }

.ctrl-label {
  font-size: 11px;
  color: var(--text-tertiary);
}

.ctrl-play {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--text-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.ctrl-play:active {
  transform: scale(0.92);
}

/* 副控制栏 */
.player-controls-sub {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.sub-control {
  position: relative;
}

.sub-btn {
  width: 100%;
  min-height: 64px;
  padding: 8px 4px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
}

.sub-btn:active {
  background: var(--bg-tertiary);
  transform: scale(0.96);
}

.sub-btn.active {
  background: var(--primary);
  color: var(--text-on-primary);
}

.sub-btn svg {
  flex-shrink: 0;
}

.sub-value {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.sub-label {
  font-size: 10px;
  color: var(--text-tertiary);
  line-height: 1;
}

.sub-btn.active .sub-label {
  color: rgba(255, 255, 255, 0.8);
}

/* 弹出面板 */
.speed-popup, .timer-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  min-width: 180px;
  display: none;
  z-index: 60;
}

.speed-popup.show, .timer-popup.show {
  display: block;
  animation: popUp 0.2s var(--ease-out);
}

@keyframes popUp {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* BGM 和语音弹窗：底部弹出式面板 */
.voice-popup, .bgm-popup {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--bg-elevated);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.15);
  padding: 16px 16px calc(var(--safe-bottom) + 16px);
  display: none;
  z-index: 200;
  max-height: 70vh;
  overflow-y: auto;
}

.voice-popup.show, .bgm-popup.show {
  display: block;
  animation: sheetUp 0.3s var(--ease-out);
}

@keyframes sheetUp {
  from { transform: translateX(-50%) translateY(100%); }
  to { transform: translateX(-50%) translateY(0); }
}

/* 底部弹窗的拖动指示器 */
.voice-popup::before, .bgm-popup::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 0 auto 12px;
}

/* 底部弹窗遮罩 */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 199;
  animation: fadeInBg 0.2s ease;
}

@keyframes fadeInBg {
  from { opacity: 0; }
  to { opacity: 1; }
}

.speed-popup input[type="range"] {
  width: 100%;
  margin-bottom: 8px;
}

.speed-presets {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.speed-presets button {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.speed-presets button.active {
  background: var(--primary);
  color: var(--text-on-primary);
}

.timer-popup {
  display: none;
}

.timer-popup button {
  display: block;
  width: 100%;
  padding: 10px 12px;
  text-align: center;
  font-size: 13px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  margin-bottom: 2px;
}

.timer-popup button:hover { background: var(--bg-tertiary); }
.timer-popup button.active {
  background: var(--primary);
  color: var(--text-on-primary);
}

.voice-list {
  max-height: 240px;
  overflow-y: auto;
}

.voice-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.voice-item:active { background: var(--bg-tertiary); }
.voice-item.active {
  color: var(--primary);
  font-weight: 600;
}

.voice-item-main {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
}

.voice-item-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-item .voice-lang {
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  margin-left: 8px;
}

/* 语音分配按钮 */
.voice-assign-btn {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--primary);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.voice-assign-btn:active {
  background: var(--primary);
  color: var(--text-on-primary);
  border-color: var(--primary);
}

/* 分配预设对话框 - 预设选项列表 */
.assign-preset-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}

.assign-preset-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: background var(--transition-fast);
  border: 1.5px solid transparent;
}

.assign-preset-option:has(input:checked) {
  background: rgba(108, 92, 231, 0.08);
  border-color: var(--primary);
}

.assign-preset-option input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.assign-preset-option-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.assign-preset-option-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.assign-preset-option-current {
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.bgm-volume {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 0.5px solid var(--border-color);
}

.bgm-volume label {
  font-size: 12px;
  color: var(--text-tertiary);
  display: block;
  margin-bottom: 4px;
}

/* 文本预览 */
.text-preview {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 16px;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
  scroll-behavior: smooth;
  /* 防止滚动穿透到外层页面 */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.text-preview-content {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.text-preview-content p {
  margin-bottom: 8px;
  transition: background 0.3s, color 0.3s;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
}

.text-preview-content .preview-p.reading-now {
  background: rgba(108, 92, 231, 0.1);
  color: var(--text-primary);
  border-left-color: var(--primary);
  font-weight: 500;
}

.text-preview-content .highlight {
  background: rgba(108, 92, 231, 0.15);
  border-radius: 4px;
  padding: 0 2px;
}

.text-placeholder {
  color: var(--text-tertiary);
  text-align: center;
  padding: 20px 0;
}

/* ===== 导入页 ===== */
.import-tabs, .ai-mode-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: 20px;
}

.import-tab, .ai-mode-tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.import-tab.active, .ai-mode-tab.active {
  background: var(--bg-secondary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.import-panel, .ai-panel {
  display: none;
}

.import-panel.active, .ai-panel.active {
  display: block;
  animation: fadeIn 0.3s var(--ease-out);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 表单 */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.text-input, .textarea-input, .select-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--transition-fast);
}

.text-input:focus, .textarea-input:focus, .select-input:focus {
  outline: none;
  border-color: var(--primary);
}

.textarea-input {
  resize: vertical;
  line-height: 1.6;
}

.char-count {
  text-align: right;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* 按钮 */
.btn-primary {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--text-on-primary);
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-glow);
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 0 16px rgba(108, 92, 231, 0.2);
}

.btn-primary:disabled {
  opacity: 0.5;
}

.btn-secondary {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.btn-secondary:active { transform: scale(0.98); }

.btn-danger {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(231, 76, 60, 0.1);
  color: #e74c3c;
  font-size: 14px;
  font-weight: 600;
  margin-top: 12px;
  transition: all var(--transition-fast);
}

.btn-danger:active { transform: scale(0.98); }

.btn-generate {
  margin-top: 8px;
}

/* 文件拖放区 */
.file-drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.file-drop-zone:active, .file-drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(108, 92, 231, 0.05);
}

.file-drop-zone p {
  margin-top: 12px;
  font-size: 15px;
}

.file-drop-zone .sub {
  font-size: 13px;
  margin-top: 4px;
}

/* ===== 文件导入增强 ===== */

.file-info {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 16px;
}

.file-info-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}

.file-info-label {
  color: var(--text-tertiary);
}

.file-info-value {
  font-weight: 500;
}

/* 目录预览 */
.chapter-preview {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 12px;
  max-height: 220px;
  overflow-y: auto;
}

.chapter-preview-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 0.5px solid var(--border-color);
}

.chapter-preview-item {
  padding: 6px 8px;
  font-size: 13px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-preview-item:nth-child(even) {
  background: var(--bg-tertiary);
}

/* 搜索 */
.search-box {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-search {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--text-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.btn-search:active { transform: scale(0.92); }

.search-results {
  min-height: 200px;
}

.search-tip {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
}

.search-tip p { font-size: 15px; }
.search-tip .sub { font-size: 13px; margin-top: 4px; }

.search-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 10px;
  display: flex;
  gap: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-item:active { transform: scale(0.98); }

.search-item-cover {
  width: 48px;
  height: 64px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.search-item-info {
  flex: 1;
  min-width: 0;
}

.search-item-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.search-item-author {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.search-item-desc {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search-item-action {
  display: flex;
  align-items: flex-end;
}

.search-item-import {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--text-on-primary);
  font-size: 12px;
  font-weight: 600;
}

/* ===== AI 生成页 ===== */
.ai-header {
  text-align: center;
  margin-bottom: 20px;
}

.ai-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.ai-header p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.genre-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.genre-btn {
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.genre-btn.active {
  background: var(--primary);
  color: var(--text-on-primary);
  border-color: var(--primary);
}

.length-options {
  display: flex;
  gap: 8px;
}

.length-btn {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.length-btn.active {
  background: var(--primary);
  color: var(--text-on-primary);
  border-color: var(--primary);
}

/* 随机生成 */
.random-preview {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  margin-bottom: 16px;
}

.random-tags {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.random-tag {
  padding: 6px 14px;
  border-radius: 16px;
  background: var(--bg-tertiary);
  font-size: 13px;
  color: var(--text-secondary);
}

.random-desc {
  font-size: 14px;
  color: var(--text-tertiary);
}

/* 生成动画 */
.ai-generating {
  text-align: center;
  padding: 40px 20px;
}

.generating-animation {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.gen-orb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  animation: genPulse 1.4s ease-in-out infinite;
}

.gen-orb:nth-child(2) { animation-delay: 0.2s; background: var(--accent); }
.gen-orb:nth-child(3) { animation-delay: 0.4s; background: var(--accent-warm); }

@keyframes genPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1.2); opacity: 1; }
}

.ai-generating p {
  font-size: 15px;
  color: var(--text-secondary);
}

/* 生成结果 */
.ai-result {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-top: 16px;
}

.ai-result h4 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.ai-result-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.ai-result-content {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
  max-height: 300px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.ai-result-actions {
  display: flex;
  gap: 8px;
}

/* ===== 设置页 ===== */
.settings-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}

.settings-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  min-height: 40px;
}

.settings-row + .settings-row {
  border-top: 0.5px solid var(--border-color);
}

.settings-label {
  font-size: 14px;
  color: var(--text-primary);
}

.settings-value {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.settings-slider {
  flex: 1;
  margin: 0;
  accent-color: var(--primary);
}

.theme-options {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.theme-opt {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.theme-opt.active {
  background: var(--bg-secondary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* 开关 */
.toggle-row {
  cursor: pointer;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 28px;
  display: inline-block;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-tertiary);
  border-radius: 14px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.btn-test-voice {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

/* ===== 底部导航栏 ===== */
.tab-bar {
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 0.5px solid var(--border-color);
  position: relative;
  z-index: 100;
  transition: background var(--transition), border-color var(--transition);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-tertiary);
  font-size: 11px;
  transition: color var(--transition-fast);
}

.tab-item.active {
  color: var(--primary);
}

.tab-item svg {
  transition: transform var(--transition-fast);
}

.tab-item.active svg {
  transform: scale(1.1);
}

/* ===== 迷你播放器 ===== */
.mini-player {
  position: absolute;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  left: 8px;
  right: 8px;
  height: 56px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  z-index: 90;
  animation: slideUp 0.3s var(--ease-out);
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.mini-player-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mini-cover {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--cover-1);
  flex-shrink: 0;
}

.mini-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mini-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-chapter {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--text-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s var(--ease-spring);
  max-width: 80%;
  text-align: center;
  backdrop-filter: blur(10px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  animation: modalIn 0.3s var(--ease-spring);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.modal-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.modal-actions button {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.modal-actions .btn-cancel {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.modal-actions .btn-confirm {
  background: var(--primary);
  color: var(--text-on-primary);
}

/* ===== Range 滑块通用样式 ===== */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* ===== 收藏星标 ===== */
.icon-star.favorited {
  fill: #fdcb6e;
  stroke: #fdcb6e;
}

/* ===== 响应式 ===== */
@media (min-width: 481px) {
  #app {
    box-shadow: var(--shadow-lg);
  }
}

@media (max-width: 360px) {
  .player-controls-sub {
    grid-template-columns: repeat(3, 1fr);
  }
  .genre-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== 加载动画 ===== */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--bg-tertiary);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.search-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-tertiary);
  font-size: 14px;
}

/* ===== 查看原文按钮 ===== */
.btn-reader {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-reader:active {
  background: var(--bg-tertiary);
  transform: scale(0.98);
}

/* ===== BGM 弹窗增强 ===== */
.bgm-list button {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  margin-bottom: 2px;
}

.bgm-list button:hover { background: var(--bg-tertiary); }
.bgm-list button.active {
  background: rgba(108, 92, 231, 0.12);
  color: var(--primary);
  font-weight: 600;
}

.bgm-custom-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 0.5px solid var(--border-color);
}

.bgm-custom-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  padding: 0 4px;
  margin-bottom: 6px;
}

.bgm-custom-list {
  max-height: 160px;
  overflow-y: auto;
}

.bgm-empty {
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
}

.bgm-custom-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.bgm-custom-item:hover { background: var(--bg-tertiary); }
.bgm-custom-item.active {
  background: rgba(108, 92, 231, 0.12);
  color: var(--primary);
}

.bgm-custom-item .bgm-custom-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bgm-custom-item .bgm-custom-del {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 16px;
  opacity: 0;
  transition: all var(--transition-fast);
}

.bgm-custom-item:hover .bgm-custom-del {
  opacity: 1;
}

.bgm-custom-item .bgm-custom-del:active {
  background: rgba(231, 76, 60, 0.12);
  color: #e74c3c;
}

.bgm-import-row {
  margin-top: 8px;
}

.btn-bgm-import {
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border-strong);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  transition: all var(--transition-fast);
}

.btn-bgm-import:active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(108, 92, 231, 0.05);
}

/* ===== 语音预设 ===== */
.voice-presets {
  padding: 4px;
}

.voice-presets-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  padding-left: 4px;
}

.voice-presets-info {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.5;
  padding: 8px 10px;
  margin-top: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

/* 语音加载/空状态 */
.voice-status, .presets-status {
  padding: 24px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  min-height: 80px;
  justify-content: center;
}

.voice-status.loading, .presets-status.loading {
  color: var(--text-tertiary);
}

.voice-status.unsupported, .presets-status.unsupported {
  color: var(--text-secondary);
}

.voice-status.basic-only, .presets-status.basic-only {
  color: var(--primary);
}

.voice-status-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.5;
}

/* 简易 spinner */
.voice-status-spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--bg-tertiary);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.voice-status-icon {
  font-size: 28px;
  margin-bottom: 4px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.voice-presets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.voice-preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  text-align: center;
  transition: all var(--transition-fast);
  border: 2px solid transparent;
}

.voice-preset-btn:active { transform: scale(0.94); }
.voice-preset-btn.active {
  background: rgba(108, 92, 231, 0.08);
  border-color: var(--primary);
  color: var(--primary);
}

/* ---- 语音预设卡片（新版，支持编辑和默认标记） ---- */
.voice-preset-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  text-align: center;
  transition: all var(--transition-fast);
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
}

.voice-preset-card:active { transform: scale(0.94); }
.voice-preset-card.active {
  background: rgba(108, 92, 231, 0.08);
  border-color: var(--primary);
  color: var(--primary);
}

.voice-preset-card.is-default {
  background: rgba(108, 92, 231, 0.06);
  border-color: rgba(108, 92, 231, 0.2);
}

.voice-preset-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  position: relative;
}

.voice-preset-default-badge {
  position: absolute;
  top: -2px;
  right: 2px;
  font-size: 8px;
  font-weight: 700;
  color: var(--primary);
  background: rgba(108, 92, 231, 0.12);
  padding: 1px 5px;
  border-radius: 6px;
  line-height: 1.3;
}

.voice-preset-edit-btn {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  opacity: 0;
  transition: all var(--transition-fast);
  border: 1px solid var(--border-color);
}

.voice-preset-card:hover .voice-preset-edit-btn,
.voice-preset-card:active .voice-preset-edit-btn {
  opacity: 1;
}

.voice-preset-edit-btn:active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.voice-preset-card.is-default .voice-preset-edit-btn {
  right: -2px;
}

/* 隐藏旧版 preset-btn（保留兼容但不显示） */
.voice-preset-btn {
  display: none;
}

.voice-preset-icon {
  font-size: 20px;
}

.voice-preset-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.voice-preset-btn.active .voice-preset-name,
.voice-preset-card.active .voice-preset-name {
  color: var(--primary);
}

.voice-preset-matched {
  font-size: 9px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  margin-top: 2px;
}

.voice-divider {
  height: 0.5px;
  background: var(--border-color);
  margin: 10px 4px;
}

.voice-list-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  padding-left: 4px;
}

/* ===== 全文阅读模态框 ===== */
.reader-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  animation: readerSlideIn 0.3s var(--ease-out);
}

@keyframes readerSlideIn {
  from { transform: translateX(30px); opacity: 0.8; }
  to { transform: translateX(0); opacity: 1; }
}

.reader-header {
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
  padding-right: 8px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--border-color);
  overflow: hidden;
}

.reader-back-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.reader-back-btn:active {
  background: var(--bg-tertiary);
  transform: scale(0.9);
}

.reader-header-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.reader-title {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-meta {
  font-size: 11px;
  color: var(--text-tertiary);
}

.reader-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 2px;
  flex-shrink: 0;
}

.reader-tab {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.reader-tab.active {
  background: var(--bg-secondary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.reader-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.reader-content {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
  padding: 16px 20px;
}

.reader-content.active { display: block; }

.reader-text {
  font-size: 16px;
  line-height: 2;
  color: var(--text-primary);
  padding-bottom: 80px;
}

.reader-text .chapter-title-inline {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin: 32px 0 20px;
  padding: 0;
  color: var(--primary);
}

.reader-text .reading-highlight {
  background: rgba(108, 92, 231, 0.15);
  border-radius: 2px;
  padding: 1px 0;
  transition: background 0.5s;
}

.reader-text p {
  text-indent: 2em;
  margin-bottom: 12px;
}

.reader-toc {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
  padding: 12px 16px;
}

.reader-toc.active { display: block; }

.reader-toc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
  border-bottom: 0.5px solid var(--border-color);
}

.reader-toc-item:active { background: var(--bg-tertiary); }
.reader-toc-item.current {
  background: rgba(108, 92, 231, 0.06);
  color: var(--primary);
  font-weight: 600;
}

.reader-toc-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.reader-toc-item.current .reader-toc-num {
  background: var(--primary);
  color: var(--text-on-primary);
}

.reader-toc-title {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-toc-words {
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.reader-bottom-bar {
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--border-color);
}

.reader-bottom-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--primary);
  background: rgba(108, 92, 231, 0.08);
  transition: all var(--transition-fast);
}

.reader-bottom-btn:active { transform: scale(0.94); }
.reader-bottom-btn:disabled {
  opacity: 0.3;
  pointer-events: none;
}

.reader-position {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* 章节导入预览 */
.chapter-preview {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-top: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.chapter-preview-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.chapter-preview-item {
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 0.5px solid var(--border-color);
}

/* ===== 语音不支持 / 重试状态 ===== */
.voice-no-support {
  padding: 20px 12px;
  text-align: center;
}

.voice-no-support-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.voice-no-support-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.voice-no-support-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.5;
}

.voice-no-support-hint strong {
  color: var(--primary);
}

.presets-empty {
  padding: 16px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.6;
}

.btn-voice-retry {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-voice-retry:active {
  transform: scale(0.95);
  opacity: 0.85;
}

/* ===== 手机端触摸优化 ===== */
/* 消除 300ms 延迟，防止双击缩放 */
button, .sub-btn, .icon-btn, .tab-item, .voice-item, .voice-preset-card,
.voice-item-main, .voice-assign-btn, .voice-preset-edit-btn,
.bgm-list button, .btn-bgm-import, .btn-primary, .btn-secondary {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* 底部抽屉弹窗触摸穿透修复 */
.voice-popup, .bgm-popup {
  touch-action: auto;
  -webkit-overflow-scrolling: touch;
}

.voice-popup button, .voice-popup input,
.bgm-popup button, .bgm-popup input {
  pointer-events: auto;
}

/* 手机端长按不弹出选择菜单 */
.sub-control, .voice-preset-card, .voice-item {
  -webkit-touch-callout: none;
}

.chapter-preview-item:last-child { border-bottom: none; }
