button, a[href], input[type="range"], .cue, .sheet-item {
  touch-action: manipulation;
}

:root {
  --bg: #000000;
  --card-bg: #151517;
  --card-border: rgba(255, 255, 255, 0.07);
  --dock-bg: rgba(22, 22, 24, 0.9);
  --text-dim: rgba(255, 255, 255, 0.34);
  --text-muted: rgba(255, 255, 255, 0.56);
  --text-bright: #ffffff;
  --word-active: #ffd65a;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-bright);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", sans-serif;
  height: 100%;
  overflow: hidden;
}
.app {
  position: relative;
  max-width: 520px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 22% 5%, rgba(220, 38, 38, 0.24) 0%, rgba(0, 0, 0, 0) 40%), #000000;
}
.app.drag-over::after {
  content: "松开以加载其他 MP3 + ASS / VTT 文件";
  position: fixed;
  inset: 16px;
  z-index: 100;
  background: rgba(15, 15, 18, 0.92);
  border: 2px dashed var(--word-active);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--word-active);
}
.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 10px) + 12px) 18px 12px;
  gap: 12px;
}
#player-exports {
  display: flex;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid #ffffff18;
}
#player-exports a {
  color: #ffd65a;
  font-size: 13px;
  padding: 4px;
  text-decoration: none;
}
.book-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.cover-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(145deg, #ef4444 0%, #991b1b 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 18px rgba(220, 38, 38, 0.35);
  line-height: 1.05;
}
.cover-badge .b-top {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #fff;
}
.cover-badge .b-bot {
  font-size: 8px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}
.title-wrap {
  min-width: 0;
}
.title-en {
  font-size: 15px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.title-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.import-pill {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
#cache-wrap { position: relative; }
#cache[data-state="saving"] { pointer-events: none; }
#cache[data-state="saving"]::after { content: none; }
#cache-detail {
  position: absolute;
  z-index: 90;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #26262a;
  border: 1px solid #ffffff24;
  border-radius: 8px;
  padding: 5px 8px;
  color: #f8fafc;
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  opacity: 0;
}
#cache-wrap:hover #cache-detail,
#cache-wrap:focus-visible #cache-detail { opacity: 1; }
@media (hover: none), (pointer: coarse) {
  #cache-detail { opacity: 1; }
}
#cache {
  white-space: nowrap;
  position: relative;
  font-variant-numeric: tabular-nums;
}
#cache[data-state="saved"] { color: var(--word-active); }
#cache-progress {
  position: absolute;
  inset-inline: 8px;
  bottom: 2px;
  width: calc(100% - 16px);
  height: 3px;
  accent-color: var(--word-active);
}
.import-pill:hover {
  background: rgba(255, 255, 255, 0.16);
}
.import-pill svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.72);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    transform 0.1s;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.icon-btn:active {
  transform: scale(0.92);
}
.icon-btn.active {
  color: var(--word-active);
  background: rgba(255, 214, 90, 0.12);
}
.icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stream-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
}
#subtitle-status {
  position: absolute;
  inset: 24px 18px auto;
  z-index: 2;
  text-align: center;
  color: var(--text-muted);
}
#subtitle-retry {
  margin-inline-start: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #ffffff40;
  color: var(--text-bright);
  background: var(--card-bg);
  cursor: pointer;
}
.stream-wrap::before,
.stream-wrap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 46px;
  pointer-events: none;
  z-index: 5;
}
.stream-wrap::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.94), rgba(0, 0, 0, 0));
}
.stream-wrap::after {
  bottom: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.96), rgba(0, 0, 0, 0));
}
.stream {
  height: 100%;
  overflow-y: auto;
  padding: 36px 18px 235px;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.stream::-webkit-scrollbar {
  display: none;
}

.cue {
  padding: 16px 18px;
  margin-bottom: 10px;
  border-radius: 20px;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background 0.22s ease,
    border-color 0.22s ease;
}
.cue.active {
  background: var(--card-bg);
  border-color: var(--card-border);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}
.cue-text {
  font-size: 20px;
  line-height: 1.54;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-dim);
  transition:
    filter 0.2s ease,
    opacity 0.2s ease;
}
.app.blind-mode .cue-text {
  filter: blur(8px);
  opacity: 0.35;
}
.app.blind-mode .cue.active:hover .cue-text,
.app.blind-mode .cue.reveal .cue-text {
  filter: none;
  opacity: 1;
}

/* ZERO layout jitter */
.word {
  transition: color 0.08s linear;
}
.cue.active .word {
  color: rgba(255, 255, 255, 0.36);
}
.cue.active .word.spoken {
  color: #ffffff;
}
.cue.active .word.current {
  color: var(--word-active);
}
.app.white-sweep .cue.active .word.current {
  color: #ffffff;
}
.cue:not(.active):hover .cue-text {
  color: rgba(255, 255, 255, 0.62);
}

.cue-zh {
  display: none;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 14px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.62);
}
.app.show-zh .cue.active .cue-zh {
  display: block;
}

.cue-tools {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.cue.active .cue-tools {
  display: flex;
}
.cue-tool-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.cue-tool-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}
.cue-tool-btn.active {
  color: var(--word-active);
}
.cue-tool-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cue-time-badge {
  margin-left: auto;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.35);
}

.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: var(--dock-bg);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 28px 28px 0 0;
  padding: 14px 22px calc(env(safe-area-inset-bottom, 12px) + 14px);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.78);
}
.dock-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 0 4px;
}
.speed-pill {
  background: transparent;
  border: 1.5px solid rgba(255, 255, 255, 0.48);
  color: rgba(255, 255, 255, 0.88);
  border-radius: 8px;
  padding: 3px 7px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  min-width: 44px;
  text-align: center;
}
.scrubber-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.time-lbl {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 38px;
}
.time-lbl.right {
  text-align: right;
}
input[type="range"].scrubber {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  cursor: pointer;
}
input[type="range"].scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.45);
}
.dock-row-play {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}
.nav-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.84);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.nav-btn svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-btn .badge-1 {
  position: absolute;
  font-size: 9px;
  font-weight: 700;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -48%);
}
.play-btn {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.buffer-ring {
  display: none;
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 3px solid #ffffff35;
  border-top-color: var(--word-active);
  pointer-events: none;
}
.play-btn.buffering .buffer-ring {
  display: block;
  animation: buffer-spin .8s linear infinite;
}
@keyframes buffer-spin {
  to { transform: rotate(1turn); }
}
@media (prefers-reduced-motion: reduce) {
  .play-btn.buffering .buffer-ring { animation: none; }
}
.buffer-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.play-btn:hover {
  background: rgba(255, 255, 255, 0.26);
}
.play-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: 520px;
  height: 76dvh;
  background: #141416;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px 24px 0 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}
.sheet.open {
  transform: translate(-50%, 0);
}
.sheet-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sheet-header button { min-height: 44px; }
.sheet-header .icon-btn { flex: 0 0 44px; }
.search-input {
  min-width: 0;
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
}
.filter-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: rgba(255, 255, 255, 0.78);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}
.filter-btn.active {
  background: rgba(255, 214, 90, 0.18);
  color: var(--word-active);
}
.sheet-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 28px;
}
.sheet-item {
  width: 100%;
  min-height: 44px;
  text-align: start;
  background: transparent;
  font: inherit;
  border: 0;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.sheet-item:focus-visible { outline: 2px solid var(--word-active); outline-offset: -2px; }
.sheet-item .s-text { min-width: 0; overflow-wrap: anywhere; }
.s-translation, .sheet-empty { display: block; color: #bcbcc1; font-size: 14px; }
.s-translation { margin-top: 3px; }
.sheet-empty { text-align: center; padding: 16px; }
.sheet-item:hover {
  background: rgba(255, 255, 255, 0.06);
}
.sheet-item.active {
  background: rgba(255, 214, 90, 0.1);
}
.sheet-item .s-time {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 38px;
  padding-top: 2px;
}
.sheet-item .s-text {
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.88);
}
.sheet-item.active .s-time,
.sheet-item.active .s-text {
  color: var(--word-active);
}

.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(34, 34, 38, 0.96);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
  z-index: 60;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Instant custom hover tooltips */
[data-tip] {
  position: relative;
}
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(4px);
  background: rgba(38, 38, 42, 0.96);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  transition:
    opacity 0.14s ease,
    transform 0.14s ease;
  z-index: 90;
}
[data-tip].tip-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
[data-tip-pos="bottom"]::after {
  bottom: auto;
  top: calc(100% + 8px);
  transform: translateX(-50%) translateY(-4px);
}
[data-tip-pos="bottom"].tip-visible::after {
  transform: translateX(-50%) translateY(0);
}
[data-tip-align="left"]::after {
  left: 0;
  transform: translateX(0) translateY(4px);
}
[data-tip-align="left"].tip-visible::after {
  transform: translateX(0) translateY(0);
}
[data-tip-align="right"]::after {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(4px);
}
[data-tip-align="right"].tip-visible::after {
  transform: translateX(0) translateY(0);
}
[data-tip-pos="bottom"][data-tip-align="right"]::after {
  transform: translateX(0) translateY(-4px);
}
[data-tip-pos="bottom"][data-tip-align="right"].tip-visible::after {
  transform: translateX(0) translateY(0);
}

.speed-wrap {
  position: relative;
  display: inline-flex;
}
.speed-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 12px);
  background: rgba(28, 28, 32, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  width: 224px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition:
    opacity 0.16s ease,
    transform 0.16s ease;
  z-index: 95;
}
.speed-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.speed-opt {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  border-radius: 9px;
  padding: 7px 0;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s;
}
.speed-opt:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.speed-opt.active {
  background: rgba(255, 214, 90, 0.2);
  color: var(--word-active);
}

.cover-badge {
  font-size: 21px;
  color: white;
  text-decoration: none;
}
.speed-menu:not(.open),
.sheet:not(.open) {
  visibility: hidden;
}
.app.blind-mode .cue.active:not(.reveal) .cue-text {
  filter: blur(8px);
  opacity: 0.35;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

.cue-placeholder { min-height: 110px; }

.dock[hidden], #wake-dock[hidden] { display: none; }
#wake-dock {
  position: absolute;
  z-index: 30;
  bottom: calc(env(safe-area-inset-bottom) + 8px);
  align-self: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  color: #ddd;
  background: #202023;
  border: 1px solid #ffffff24;
}
.dock-hidden .stream { padding-bottom: 68px; }
#btn-mode .to-list, .single-mode #btn-mode .to-single { display: none; }
.single-mode #btn-mode .to-list { display: block; }
.single-mode .stream {
  display: flex;
  flex-direction: column;
  touch-action: pan-y pinch-zoom;
  overflow-x: hidden;
  scroll-behavior: auto;
}
.single-mode .cue { display: none; }
.single-mode .cue.active {
  display: block;
  margin-block: auto;
  flex: none;
}
.single-mode .dock, .single-mode #wake-dock { position: static; flex: none; }
.single-mode #wake-dock { margin-bottom: calc(env(safe-area-inset-bottom) + 8px); }
.single-mode .stream-wrap { min-height: 0; }
.single-mode .stream { padding-block: 18px; }
.single-mode .stream-wrap::before, .single-mode .stream-wrap::after { height: 12px; }
.single-mode .cue-text {
  font-size: clamp(32px, 10vmin, 48px);
  line-height: 1.23;
  overflow-wrap: anywhere;
}
.single-mode .cue-zh {
  font-size: clamp(17px, 4.6vmin, 22px);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.single-mode #btn-follow { visibility: hidden; }

@media (orientation: landscape) and (min-width: 640px) and (max-height: 500px) {
  .single-mode.app { max-width: 900px; }
  .single-mode .dock:not([hidden]) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    column-gap: 24px;
    padding: 6px max(18px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  }
  .single-mode .dock-row-top, .single-mode .scrubber-row { margin-bottom: 0; }
  .single-mode .dock-row-play { grid-column: 2; grid-row: 1 / 3; }
}