/* 听书：迷你播放条、播放面板、朗读高亮（listen.js）。 */
.listen-bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--ds-space-3, 12px) + var(--safe-area-bottom, 0px));
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: var(--ds-space-1, 4px);
  width: min(560px, calc(100vw - 24px));
  padding: var(--ds-space-2, 8px) var(--ds-space-3, 12px) calc(var(--ds-space-2, 8px) + 3px);
  border: 1px solid var(--ds-border, rgba(0, 0, 0, 0.12));
  border-radius: var(--ds-radius-lg, 16px);
  background: var(--ds-surface-raised, #fff);
  color: var(--ds-text, #222);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.listen-bar.hidden,
.listen-panel.hidden {
  display: none;
}

.listen-bar-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0 var(--ds-space-1, 4px);
}

.listen-bar-title,
.listen-bar-sub {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.listen-bar-title {
  font-weight: var(--ds-weight-medium, 500);
}

.listen-bar-sub {
  font-size: var(--ds-text-caption, 12px);
  color: var(--ds-text-muted, #666);
}

.listen-icon {
  flex: 0 0 auto;
  min-width: var(--ds-control-touch, 40px);
  min-height: var(--ds-control-touch, 40px);
  border-radius: var(--ds-radius-full, 999px);
  font-size: 16px;
  line-height: 1;
}

.listen-bar-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--ds-accent-soft, rgba(0, 0, 0, 0.06));
}

.listen-bar-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ds-accent, #e85d3f);
  transition: width 0.3s linear;
}

.listen-panel {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-area-bottom, 0px));
  transform: translateX(-50%);
  z-index: 1201;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-3, 12px);
  padding: var(--ds-space-4, 16px);
  border: 1px solid var(--ds-border, rgba(0, 0, 0, 0.12));
  border-radius: var(--ds-radius-lg, 16px);
  background: var(--ds-surface-panel, #fff);
  color: var(--ds-text, #222);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
}

.listen-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ds-space-2, 8px);
}

.listen-panel-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.listen-panel-book,
.listen-panel-status {
  color: var(--ds-text-muted, #666);
  font-size: var(--ds-text-meta, 13px);
}

.listen-seek-row {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2, 8px);
  font-variant-numeric: tabular-nums;
  font-size: var(--ds-text-caption, 12px);
}

.listen-seek-row[hidden],
.listen-voice-field[hidden] {
  display: none;
}

.listen-seek {
  flex: 1 1 auto;
}

.listen-transport {
  display: flex;
  justify-content: center;
  gap: var(--ds-space-2, 8px);
}

.listen-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-3, 12px);
}

.listen-field select {
  flex: 0 1 auto;
  min-width: min(7.5em, 65%);
  max-width: 65%;
}

.listen-field > span {
  min-width: 0;
}

.listen-check {
  justify-content: flex-start;
}

.listen-stop {
  align-self: center;
}

/* 有声书下载（实验功能）：章节范围一行放不下时换行，状态文字完整显示。 */
.listen-download {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-2, 8px);
  padding-top: var(--ds-space-3, 12px);
  border-top: 1px solid var(--ds-border, rgba(0, 0, 0, 0.12));
}

.listen-download[hidden] {
  display: none;
}

.listen-download-title {
  font-weight: 600;
}

.listen-download-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ds-space-2, 8px);
}

.listen-download-range label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.listen-download-range input {
  width: 6em;
}

.listen-download-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.listen-download-name input {
  flex: 1 1 12em;
  min-width: 0;
}

/* #479：听书自己的目录；列表限高可滚动，当前章高亮。 */
.listen-toc {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-2, 8px);
}

.listen-toc-toggle {
  align-self: flex-start;
}

.listen-toc-body[hidden] {
  display: none;
}

.listen-toc-body {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-2, 8px);
}

.listen-toc-note {
  font-size: 0.875em;
  color: var(--ds-text-muted, #666);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.listen-toc-note[hidden] {
  display: none;
}

.listen-toc-jump {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ds-space-2, 8px);
}

.listen-toc-jump label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.listen-toc-jump input {
  width: 6em;
}

.listen-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(40vh, 320px);
  overflow-y: auto;
  border: 1px solid var(--ds-border, rgba(0, 0, 0, 0.12));
  border-radius: var(--ds-radius-sm, 8px);
}

.listen-toc-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.listen-toc-item:hover,
.listen-toc-item:focus-visible {
  background: var(--ds-state-hover, rgba(0, 0, 0, 0.05));
}

.listen-toc-item.is-current {
  font-weight: 600;
  color: var(--ds-accent, #c0392b);
}

.listen-download-status {
  font-size: 0.875em;
  color: var(--ds-text-muted, #666);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.listen-download-status:empty {
  display: none;
}

/* 正在朗读的段落和句子 */
.reader-paragraph.listen-active {
  background: var(--ds-accent-soft, rgba(232, 93, 63, 0.1));
  border-radius: var(--ds-radius-sm, 6px);
  transition: background-color 0.2s ease;
}

::highlight(listen-sentence) {
  background-color: rgba(232, 93, 63, 0.28);
}

/* Issue #442：底部有导航栏或阅读器底栏时，listen.js 量出它的高度写进
   --listen-bar-lift，播放条和面板停在它上面，不再盖住菜单。 */
body.listen-bar-lifted .listen-bar {
  bottom: calc(var(--ds-space-2, 8px) + var(--listen-bar-lift, 0px));
}

body.listen-bar-lifted .listen-panel {
  bottom: calc(72px + var(--listen-bar-lift, 0px));
  max-height: calc(100vh - 128px - var(--listen-bar-lift, 0px));
}

/* 播放条出现时给底部导航和阅读器底栏让位 */
body.listen-active-session .reader-footer {
  margin-bottom: 64px;
}

@media (prefers-reduced-motion: reduce) {
  .listen-bar-progress span,
  .reader-paragraph.listen-active {
    transition: none;
  }
}
