/* ============================================
TTS 朗读功能样式
设计法则：背景色分层 · 无边框线 · 药丸交互
============================================ */

/* ===== 朗读触发按钮（激活态） ===== */
.tts-trigger.active {
  color: var(--accent);
}

/* ===== 朗读迷你条 ===== */
.tts-minibar {
  align-items: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: var(--bg-card);
  bottom: 0;
  display: flex;
  gap: 10px;
  height: 40px;
  left: 0;
  opacity: 0;
  padding: 0 16px;
  pointer-events: none;
  position: fixed;
  right: 0;
  transform: translateY(-4px);
  transition: opacity 0.25s ease, transform 0.25s ease, bottom 0.3s ease-in-out;
  z-index: 99;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
}
.tts-minibar.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* 移动端：底部导航栏可见时，朗读条贴合在导航栏上方 */
@media (max-width: 767px) {
  .tts-minibar.mobile-above-nav {
    bottom: 58px;
  }
}

/* PC 端：无嵌入容器时兜底为底部居中悬浮 */
@media (min-width: 768px) {
  .tts-minibar {
    border-radius: 24px;
    bottom: 20px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    max-width: 480px;
    padding: 0 14px;
    width: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

/* ===== 标题下方朗读触发按钮（PC 端显示，移动端隐藏） ===== */
.tts-inline-wrap {
  display: none;
  margin: 14px 0 6px;
}
@media (min-width: 768px) {
  .tts-inline-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
  }
}
.tts-trigger-btn {
  align-items: center;
  background: var(--bg-surface);
  border: none;
  border-radius: 50px;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 500;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  transition: all 0.2s;
}
.tts-trigger-btn:hover {
  background: var(--bg-hover);
  color: var(--accent);
}
.tts-trigger-btn.active {
  background: var(--bg-active);
  color: var(--accent);
}

/* PC 端：朗读条与触发按钮同一行展开（跟随内容、不悬浮、低调融入主题） */
@media (min-width: 768px) {
  .tts-inline-wrap .tts-minibar {
    background: var(--bg-surface);
    border-radius: 12px;
    bottom: auto;
    box-shadow: none;
    flex: 1;
    height: 36px;
    left: auto;
    max-width: 640px;
    min-width: 0;
    padding: 0 10px;
    position: static;
    right: auto;
    transform: none;
    width: auto;
  }
  .tts-inline-wrap .tts-minibar.visible {
    transform: none;
  }
}

/* ===== 波形动画（朗读中） ===== */
.tts-wave {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 2px;
  height: 18px;
  justify-content: center;
  width: 20px;
}
.tts-wave i {
  background: var(--accent);
  border-radius: 2px;
  width: 3px;
  animation: tts-wave 1s ease-in-out infinite;
}
.tts-wave i:nth-child(1) { height: 8px; animation-delay: 0s; }
.tts-wave i:nth-child(2) { height: 14px; animation-delay: 0.2s; }
.tts-wave i:nth-child(3) { height: 10px; animation-delay: 0.4s; }
@keyframes tts-wave {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1); }
}
.tts-minibar.paused .tts-wave i {
  animation-play-state: paused;
  opacity: 0.5;
}

/* ===== 进度信息 ===== */
.tts-info {
  color: var(--text-secondary);
  flex: 1;
  font-size: 0.78rem;
  min-width: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tts-info .tts-info-section {
  color: var(--accent);
  font-weight: 600;
}
/* 位置前缀（图书·栏目），与区块名用 · 分隔 */
.tts-info .tts-info-loc {
  color: var(--text-muted);
}
.tts-info .tts-info-loc:not(:empty)::after {
  content: ' · ';
  color: var(--text-muted);
}
.tts-info .tts-info-loc:empty {
  display: none;
}

/* ===== 朗读条按钮 ===== */
.tts-btn {
  align-items: center;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 0.95rem;
  height: 32px;
  justify-content: center;
  padding: 0;
  transition: all 0.2s;
  width: 32px;
}
.tts-btn:hover {
  background: var(--bg-hover);
  color: var(--accent);
}
.tts-btn:active {
  transform: scale(0.9);
}
.tts-btn.toggle {
  background: var(--bg-active);
  color: var(--accent);
  font-size: 1.05rem;
  height: 36px;
  width: 36px;
}
.tts-btn.toggle:hover {
  background: var(--accent);
  color: #fff;
}

/* ===== 句子级高亮（文章正文内） ===== */
.reading-content .tts-sentence-active {
  background: rgba(46, 160, 67, 0.16);
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(46, 160, 67, 0.08);
  color: var(--accent);
  font-weight: 500;
  padding: 0 2px;
}
.reading-content .tts-sentence-done {
  color: var(--text-muted);
}
html.light .reading-content .tts-sentence-active {
  background: rgba(46, 160, 67, 0.12);
  color: #1a7a37;
}

/* ===== 朗读设置（阅读设置面板内） ===== */
.tts-settings-divider {
  border-top: 1px solid var(--bg-tertiary);
  margin: 16px 0 0;
  padding-top: 16px;
}
.tts-section-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tts-chip {
  background: var(--bg-surface);
  border: none;
  border-radius: 50px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 14px;
  transition: all var(--transition);
}
.tts-chip:hover {
  background: var(--bg-hover);
  color: var(--accent);
}
.tts-chip.active {
  background: var(--accent);
  color: #fff;
}
.tts-chip:active {
  transform: scale(0.95);
}

/* 朗读开关（简单 toggle） */
.tts-switch-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
}
.tts-switch {
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0;
  height: 24px;
  position: relative;
  width: 44px;
}
.tts-switch input {
  height: 0;
  opacity: 0;
  position: absolute;
  width: 0;
}
.tts-switch .tts-switch-track {
  background: var(--bg-tertiary);
  border-radius: 12px;
  height: 24px;
  position: absolute;
  transition: background 0.2s;
  width: 44px;
}
.tts-switch .tts-switch-thumb {
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  height: 18px;
  left: 3px;
  position: absolute;
  top: 3px;
  transition: transform 0.2s;
  width: 18px;
}
.tts-switch input:checked + .tts-switch-track {
  background: var(--accent);
}
.tts-switch input:checked + .tts-switch-track + .tts-switch-thumb {
  transform: translateX(20px);
}

/* ===== 独立朗读设置弹窗 ===== */
.tts-settings-panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  left: 50%;
  max-height: 70vh;
  opacity: 0;
  overflow-y: auto;
  padding: 14px 18px 14px;
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  visibility: hidden;
  width: 320px;
  z-index: 1000;
}
.tts-settings-panel.open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  visibility: visible;
}
.tts-settings-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}
.tts-settings-title {
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
}
.tts-settings-close {
  align-items: center;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  height: 30px;
  justify-content: center;
  padding: 0;
  transition: all 0.2s;
  width: 30px;
}
.tts-settings-close:hover {
  background: var(--bg-hover);
  color: var(--accent);
}
.tts-settings-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tts-settings-label {
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.tts-settings-body .tts-section-chips {
  margin-bottom: 4px;
}

/* 不支持的浏览器提示（复用全局轻提示，无需额外样式） */
