/*    AI 听书视觉规范：灵动微光胶囊、贴边迷你悬浮球、高亮波纹与音色商店
   ========================================================================== */
.tts-seg {
  position: relative;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  border-radius: 4px;
}
.tts-seg:hover {
  background-color: var(--accent-gold-subtle);
}
.tts-seg.tts-cur {
  background: var(--accent-gold-subtle);
  box-shadow: 0 2px 0 var(--accent-gold);
  border-radius: 4px;
  color: var(--reader-text);
}
#ttsBar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(92vw, 540px);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(18, 18, 22, 0.88);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid rgba(230, 184, 115, 0.25);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45), 0 0 15px rgba(230, 184, 115, 0.1);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none; /* iOS 长按不弹放大镜/菜单 */
}
#ttsBar.hidden {
  display: none !important;
}
@media (max-width: 640px) {
  #ttsBar {
    left: 12px;
    right: 12px;
    transform: none;
    max-width: none;
    justify-content: space-between;
    padding: 6px 8px;
    /* 移动端阅读页有 56px 固定底栏，胶囊必须悬在其上方，否则直接盖住导航按钮 */
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }
  /* 窄屏收纳：状态文字移除、控件压缩，保证 320px 宽度也不溢出不挤压 */
  #ttsBar .tts-status { display: none; }
  #ttsBar .tts-chip { max-width: 64px; font-size: 11px; padding: 5px 8px; }
  #ttsBar .tts-ctl { gap: 0; }
  #ttsBar .tts-ctl button { width: 32px; height: 32px; }
  #ttsBar .tts-ctl .tts-main { width: 38px; height: 38px; }
  #ttsBar .tts-rate { min-width: 30px; padding: 4px; font-size: 10px; }
  #ttsBar .tts-min-btn { width: 28px; height: 28px; }
  #ttsFloatBall {
    /* 同步让开底部导航，避免悬浮球叠在导航按钮上 */
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    width: 44px;
    height: 44px;
  }
}
/* 音色选择胶囊 */
.tts-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 120px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(230, 184, 115, 0.3);
  background: rgba(230, 184, 115, 0.12);
  color: #e6b873;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.tts-chip:active {
  transform: scale(0.95);
  background: rgba(230, 184, 115, 0.22);
}
.tts-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 控制按钮组 */
.tts-ctl {
  display: flex;
  align-items: center;
  gap: 2px;
}
.tts-ctl button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #c7c4ce;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tts-ctl button:active {
  transform: scale(0.9);
  color: #e6b873;
}
.tts-ctl .tts-main {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #e6b873, #d49a4b);
  color: #121216;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(230, 184, 115, 0.35);
}
/* 倍速与最小化 */
.tts-rate {
  min-width: 38px;
  padding: 5px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #c7c4ce;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.tts-rate:active {
  color: #e6b873;
  border-color: #e6b873;
}
.tts-min-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: #9a98a2;
  cursor: pointer;
  transition: all 0.2s ease;
}
.tts-min-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}
.tts-status {
  font-size: 11px;
  color: #9a98a2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}
#ttsFloatBall {
  position: fixed;
  right: 18px;
  bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(18, 18, 22, 0.92);
  border: 1.5px solid rgba(230, 184, 115, 0.5);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 12px rgba(230, 184, 115, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #e6b873;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none; /* iOS 长按关球时不弹系统菜单 */
}
#ttsFloatBall.hidden {
  display: none !important;
}
#ttsFloatBall:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 0 16px rgba(230, 184, 115, 0.45);
}
#ttsFloatBall.is-playing::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid rgba(230, 184, 115, 0.6);
  animation: ttsPulse 2s infinite cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: none;
}
@keyframes ttsPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  100% { transform: scale(1.35); opacity: 0; }
}
.voice-sheet {
  width: 100%;
  max-width: 580px;
  max-height: 82vh;
  background: var(--bg-surface, #18181c);
  color: var(--text-primary, #f2f0f2);
  border-radius: 20px;
  border: 1px solid var(--border-medium, rgba(230, 184, 115, 0.25));
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.5);
  padding: 16px 18px 20px;
  animation: modalPopIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: default;
}
@media (max-width: 640px) {
  .voice-sheet {
    border-radius: 20px 20px 0 0;
    max-height: 85vh;
    padding: 14px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 100%;
  }
}
.vs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.vs-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #e6b873;
  display: flex;
  align-items: center;
  gap: 8px;
}
.vs-body {
  overflow-y: auto;
  padding-top: 12px;
  flex: 1;
}
.vs-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #c7c4ce;
  margin: 12px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.vs-hint {
  font-size: 11px;
  color: #9a98a2;
  font-weight: 400;
}
/* 已安装音色与商店列表 */
.vs-local-list, .vs-store-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.vs-card {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.2s ease;
}
.vs-card:hover {
  background: rgba(230, 184, 115, 0.08);
  border-color: rgba(230, 184, 115, 0.3);
}
.vs-card.active {
  background: rgba(230, 184, 115, 0.15);
  border-color: #e6b873;
}
.vs-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.vs-name {
  font-size: 13px;
  font-weight: 700;
  color: #f2f0f2;
}
.vs-ver {
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(230, 184, 115, 0.2);
  color: #e6b873;
  font-weight: 700;
}
.vs-game-tag {
  font-size: 11px;
  color: #9a98a2;
}
.vs-act-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.vs-btn-use {
  flex: 1;
  padding: 5px 8px;
  border-radius: 6px;
  background: #e6b873;
  color: #121216;
  font-size: 11px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}
.vs-btn-prev {
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #c7c4ce;
  font-size: 11px;
  border: none;
  cursor: pointer;
}
/* 标签与搜索框 */
.vs-game-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 8px;
}
.vs-tab {
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.05);
  color: #9a98a2;
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  white-space: nowrap;
}
.vs-tab.active {
  background: rgba(230, 184, 115, 0.2);
  color: #e6b873;
  border-color: #e6b873;
  font-weight: 700;
}
.vs-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.vs-lang-tabs {
  display: flex;
  gap: 4px;
}
.vs-search {
  flex: 1;
  max-width: 140px;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 11px;
}
.vs-search:focus {
  border-color: #e6b873;
  outline: none;
}
/* 抽屉内列表与行级元素 */
.vs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 6px;
  transition: all 0.2s ease;
}
.vs-row:hover {
  background: rgba(230, 184, 115, 0.08);
  border-color: rgba(230, 184, 115, 0.3);
}
.vs-row.cur {
  background: rgba(230, 184, 115, 0.15);
  border-color: #e6b873;
}
.vs-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.vs-info b {
  font-size: 14px;
  font-weight: 700;
  color: #f2f0f2;
}
.vs-info span {
  font-size: 11px;
  color: #9a98a2;
}
.vs-acts {
  display: flex;
  align-items: center;
  gap: 6px;
}
.vs-btn {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.vs-btn:active {
  transform: scale(0.94);
}
.vs-btn.use {
  background: #e6b873;
  color: #121216;
}
.vs-btn.preview {
  background: rgba(255, 255, 255, 0.08);
  color: #c7c4ce;
}
.vs-btn.preview:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}
.vs-btn.dl {
  background: rgba(230, 184, 115, 0.2);
  color: #e6b873;
  border: 1px solid rgba(230, 184, 115, 0.4);
}
.vs-btn.dl:hover {
  background: #e6b873;
  color: #121216;
}
.vs-using {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  color: #e6b873;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(230, 184, 115, 0.15);
  border: 1px solid rgba(230, 184, 115, 0.3);
}
.vs-down {
  font-style: normal;
  font-size: 11px;
  color: #e6b873;
  animation: pulse 1.5s infinite;
}
.vs-empty, .vs-loading {
  padding: 20px 10px;
  text-align: center;
  font-size: 12px;
  color: #9a98a2;
  width: 100%;
}
