/* player.css — listening: the mini player, the full player, car mode, the
   Listen page, the voice picker, and the narrator's status. Tokens only. */

/* ================================================================ mini player */
.dock {
  position: fixed; z-index: var(--z-player);
  left: calc(248px + 12px); right: 12px;
  bottom: calc(12px + var(--safe-bottom));
  height: 76px;
  display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--s2) 0 8px;
  background: var(--raise);
  border: var(--stroke) solid var(--outline);
  border-radius: var(--r-lg);
  box-shadow: 0 4px 0 var(--outline), var(--shadow-2);
  overflow: hidden;
  max-width: 980px;
  margin-inline: auto;
}
.dock-bar { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--progress-track); }
.dock-bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.4s linear; }
.dock-open {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: var(--s3);
  height: 100%; padding: 0 var(--s2) 0 0;
  border: 0; background: none; text-align: left;
}
.dock-cover { width: 40px; flex: none; }
.dock-cover .cover { border-radius: 4px; box-shadow: var(--shadow-1); }
.dock-cover .cover-gen .gt { font-size: 6px; }
.dock-cover .cover-gen .ga, .dock-cover .cover-gen .gb { display: none; }
.dock-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.dock-text strong { font-weight: 800; }
.dock-sub { font-size: var(--fs-sm); color: var(--text-2); font-weight: 600; }
.dock-buttons { display: flex; align-items: center; gap: 2px; }
.dock-play { width: 50px; min-height: 50px; margin-bottom: var(--press-depth); }
.dock-play .icon { width: 24px; height: 24px; }
.dock-close { color: var(--text-3); }
@media (min-width: 761px) and (max-width: 1100px) {
  .dock { left: calc(92px + 12px); }
}
@media (max-width: 760px) {
  .dock {
    left: 8px; right: 8px;
    bottom: calc(64px + var(--safe-bottom) + 8px);
    height: 68px;
    border-radius: var(--r-md);
    box-shadow: 0 3px 0 var(--outline), var(--shadow-2);
  }
  .dock-back { display: none; }
  .dock-play { width: 46px; min-height: 46px; }
  .dock-close { width: 30px; min-height: 30px; }
}

/* ================================================================ full player */
.route-player { background: var(--bg); overflow: auto; overscroll-behavior: contain; }
.player-backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; background: color-mix(in srgb, var(--tint, var(--brand)) 26%, var(--bg)); }
.player-backdrop img { width: 100%; height: 100%; object-fit: cover; filter: blur(60px) saturate(1.3); transform: scale(1.3); opacity: .42; }
.player-backdrop::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 35%, transparent), var(--bg) 88%); }
:root[data-theme="dark"] .player-backdrop img { opacity: .3; }

.player-top {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: var(--s2);
  padding: calc(var(--s2) + var(--safe-top)) var(--gutter) var(--s2);
}
.player-top-title { flex: 1; min-width: 0; text-align: center; font-weight: 800; font-size: var(--fs-sm); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-body { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--s6); max-width: 1240px; margin: 0 auto; padding: var(--s3) var(--gutter) calc(var(--s7) + var(--safe-bottom)); }
.player-main { display: grid; grid-template-columns: minmax(220px, 380px) minmax(0, 1fr); gap: var(--s6); align-items: center; }
.player-main.is-narrate { grid-column: 1 / -1; align-items: start; max-width: 1000px; margin: 0 auto; width: 100%; }
.player-art { width: 100%; max-width: 380px; justify-self: center; }
.player-art .cover { box-shadow: var(--shadow-3); border-radius: 10px; transition: transform var(--t-slow) var(--ease); }
.player-art .cover-gen { font-size: 26px; }
.player-art:not(.is-playing) .cover { transform: scale(.97); }
.player-info { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.player-title { font-size: clamp(1.5rem, 2.6vw, 2.2rem); }
.player-author { margin: 0; color: var(--text-2); font-weight: 700; }
.player-chapter { margin: var(--s2) 0 0; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.player-chapter-n { font-size: var(--fs-sm); font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--accent-deep); }
.player-chapter-t { font-family: var(--font-brand); font-weight: 500; font-size: var(--fs-lg); }
.player-scrubwrap { margin-top: var(--s2); }
.player-scrub { height: 32px; }
.player-times { display: flex; justify-content: space-between; font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); margin-top: -4px; }
.player-controls { display: flex; align-items: center; justify-content: center; gap: clamp(4px, 1.6vw, 18px); margin: var(--s3) 0 var(--s2); }
.player-controls .btn-ghost .icon { width: 26px; height: 26px; }
.player-skip { position: relative; }
.player-skip .icon { width: 34px !important; height: 34px !important; }
.player-skip .skip-n { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; font-weight: 900; padding-top: 1px; }
.player-play { width: 84px; min-height: 84px; flex: none; }
.player-play .icon { width: 36px; height: 36px; }
.player-play.is-loading { background: var(--accent-soft); }
.player-bookleft { margin: 0; text-align: center; font-size: var(--fs-sm); color: var(--text-2); font-weight: 700; min-height: 1.5em; }
.player-actions { display: flex; gap: var(--s1); margin-top: var(--s3); padding: var(--s2); border-radius: var(--r-lg); background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--line); }
.player-action { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 60px; padding: 6px 2px; border: 0; border-radius: var(--r-md); background: none; color: var(--text-2); font-weight: 800; font-size: 12px; }
.player-action .icon { width: 22px; height: 22px; }
.player-action:hover { background: var(--bg-sunk); color: var(--text); }
.player-action.is-on { color: var(--accent-deep); background: var(--accent-soft); }
.pa-label { max-width: 100%; text-align: center; line-height: 1.15; overflow-wrap: anywhere; }
.player-notice { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s3); }
.player-notice .notice { margin: 0; align-items: center; }
.player-notice .notice .btn { margin-left: auto; }

.player-side { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; max-height: calc(100dvh - 120px); position: sticky; top: 72px; align-self: start; padding: var(--s3); border-radius: var(--r-lg); background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--line); }
.player-side .segmented { align-self: stretch; }
.player-side .segmented button { flex: 1; justify-content: center; }
.player-side-list { overflow: auto; overscroll-behavior: contain; margin: 0 calc(var(--s3) * -1); padding: 0 var(--s3); }
.pa-chapters { display: none; }

.chapter-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.chapter-row { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 50px; padding: 6px var(--s3); border: 0; border-radius: var(--r-md); background: none; text-align: left; }
.chapter-row:hover:not(:disabled) { background: var(--bg-sunk); }
.chapter-row:disabled { cursor: default; opacity: .65; }
.chapter-row[aria-current="true"] { background: var(--accent-soft); }
.cr-n { width: 2.2em; flex: none; text-align: right; color: var(--text-3); font-weight: 800; font-size: var(--fs-sm); }
.cr-t { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-row[aria-current="true"] .cr-t { font-weight: 900; }
.cr-d { flex: none; font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); }
.cr-eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.cr-eq i { width: 3px; background: var(--accent-deep); border-radius: 2px; animation: sb-eq 1s ease-in-out infinite; }
.cr-eq i:nth-child(2) { animation-delay: -.3s; }
.cr-eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes sb-eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }

.clip-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.clip-row { display: flex; align-items: center; gap: var(--s2); }
.clip-go { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s3); min-height: 48px; padding: 0 var(--s3); border: 0; border-radius: var(--r-md); background: none; text-align: left; }
.clip-go:hover { background: var(--bg-sunk); }
.clip-go .icon { color: var(--accent-deep); }
.clip-empty { padding: var(--s3); }

.speed-now { font-family: var(--font-brand); font-weight: 600; font-size: 3rem; text-align: center; font-variant-numeric: tabular-nums; }
.speed-presets { display: flex; flex-wrap: wrap; gap: var(--s2); justify-content: center; }
.sleep-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.sleep-grid .btn:last-child { grid-column: 1 / -1; }

/* not narrated yet */
.narrate-panel { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.narrate-panel > p { margin: 0; }
.narrate-h { margin-top: var(--s3); }
.narrate-go {
  position: sticky; bottom: 0; z-index: 1;
  margin: 0 calc(var(--s3) * -1); padding: var(--s5) var(--s3) calc(var(--s3) + var(--safe-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 45%);
}
.narrate-status { display: flex; flex-direction: column; gap: var(--s3); align-items: flex-start; margin-top: var(--s3); }
.narrate-status .bar { width: 100%; max-width: 420px; }
.narrate-now { display: flex; align-items: center; gap: var(--s2); font-weight: 800; font-size: var(--fs-lg); margin: 0; }
.narrate-now .icon { color: var(--accent-deep); }
.narrate-eta { display: flex; align-items: flex-start; gap: var(--s2); margin: 0; font-weight: 700; }
.narrate-eta .icon { flex: none; color: var(--text-3); margin-top: 2px; }
.player-empty { grid-column: 1 / -1; text-align: center; padding: var(--s8) 0; display: flex; flex-direction: column; align-items: center; gap: var(--s3); }

@media (max-width: 1000px) {
  .player-body { grid-template-columns: 1fr; }
  .player-side { display: none; }
  .pa-chapters { display: flex; }
}
@media (max-width: 760px) {
  .player-main { grid-template-columns: 1fr; gap: var(--s4); }
  /* the whole player fits one phone screen: the cover gives way first */
  .player-art { max-width: min(260px, 62vw, calc(34dvh * 2 / 3)); }
  .player-body { padding-top: 0; gap: var(--s4); }
  .player-controls { margin: var(--s2) 0 0; }
  .player-info { text-align: center; }
  .player-chapter { justify-content: center; }
  .player-title { font-size: 1.5rem; }
  .player-play { width: 76px; min-height: 76px; }
  .player-actions { margin-top: var(--s2); }
  .player-main.is-narrate .player-art { max-width: 180px; }
  .narrate-panel { text-align: left; }
  .narrate-go .btn { width: 100%; }
}
@media (max-width: 380px) {
  .player-controls { gap: 0; }
  .player-play { width: 68px; min-height: 68px; }
}

/* ================================================================ car mode */
.car {
  position: fixed; inset: 0; z-index: var(--z-top);
  display: flex; flex-direction: column; justify-content: space-between; gap: var(--s5);
  padding: calc(var(--s4) + var(--safe-top)) var(--s5) calc(var(--s5) + var(--safe-bottom));
  background: #000; color: #F3E6D2;
  font-family: var(--font-ui);
}
.car-head { display: flex; }
.car-exit { display: inline-flex; align-items: center; gap: var(--s2); min-height: 56px; padding: 0 var(--s4); border-radius: var(--r-pill); border: 2px solid #3a3a3a; background: #111; color: inherit; font-weight: 800; font-size: 1.1rem; }
.car-text { text-align: center; }
.car-title { font-family: var(--font-brand); font-weight: 600; font-size: clamp(1.8rem, 6vw, 3.4rem); line-height: 1.1; }
.car-chapter { margin-top: var(--s2); font-size: clamp(1.1rem, 3.5vw, 1.8rem); font-weight: 800; color: var(--sb-sun); }
.car-time { margin-top: var(--s2); font-size: clamp(1rem, 3vw, 1.4rem); color: #b8ab98; font-weight: 700; }
.car-row { display: grid; grid-template-columns: 1fr 1.35fr 1fr; gap: var(--s4); align-items: center; }
.car-row-small { grid-template-columns: 1fr 1fr; }
.car-btn, .car-play, .car-small { border: 0; color: inherit; display: flex; align-items: center; justify-content: center; gap: var(--s2); font-weight: 900; }
.car-btn { position: relative; aspect-ratio: 1; max-height: 34vh; border-radius: 50%; background: #1c1c1c; border: 3px solid #333; }
.car-btn .icon { width: 50%; height: 50%; stroke-width: 1.6; }
.car-btn span { position: absolute; font-size: clamp(1rem, 3.5vw, 1.6rem); }
.car-play { aspect-ratio: 1; max-height: 42vh; border-radius: 50%; background: var(--sb-honey); color: var(--sb-ink); border: 4px solid #000; box-shadow: 0 0 0 4px var(--sb-honey); }
.car-play .icon { width: 44%; height: 44%; }
.car-small { min-height: 72px; border-radius: var(--r-lg); background: #151515; border: 2px solid #2c2c2c; font-size: 1.2rem; }
.car-small .icon { width: 30px; height: 30px; }
@media (orientation: landscape) and (max-height: 520px) {
  .car { flex-direction: row; flex-wrap: wrap; align-content: center; }
  .car-head { position: absolute; top: calc(var(--s3) + var(--safe-top)); left: var(--s4); }
  .car-text { flex: 1 1 100%; }
  .car-row { flex: 1 1 60%; }
  .car-row-small { flex: 1 1 30%; grid-template-columns: 1fr; }
}

/* ================================================================ the Listen page */
.listen-continue { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--s4); }
.listen-card {
  position: relative;
  display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: var(--s4); align-items: center;
  padding: var(--s3); border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line);
  cursor: pointer;
}
.listen-card:hover { border-color: var(--line-2); }
.listen-card h3 { font-size: var(--fs-md); }
.lc-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.lc-body p { margin: 0; font-size: var(--fs-sm); }
.lc-play { width: 56px; min-height: 56px; }
.lc-play .icon { width: 24px; height: 24px; }
.listen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s5) var(--s4); }
.listen-tile { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text); min-width: 0; }
.lt-title { font-weight: 800; font-size: var(--fs-sm); line-height: 1.3; }
.lt-meta { font-size: var(--fs-xs); font-weight: 700; }
.listen-queue { display: flex; flex-direction: column; gap: var(--s2); }
/* a fixed column for the buttons, so every book's bar ends at the same place */
.queue-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) minmax(15.5rem, auto); gap: var(--s3); align-items: center; padding: var(--s2) var(--s3); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.qr-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.qr-body .faint { font-size: var(--fs-sm); }
.qr-actions { display: flex; gap: var(--s2); flex-wrap: wrap; justify-content: flex-end; }
.qr-time { display: flex; gap: 6px; align-items: flex-start; font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); min-width: 0; }
.qr-time .icon { flex: none; color: var(--text-3); margin-top: 2px; }
.qr-time.is-now { color: var(--text); }
.qr-time.is-now .icon { color: var(--accent-deep); }
.qr-time > span { min-width: 0; }
.tw { white-space: nowrap; }
/* the whole queue at a glance, above its books */
.queue-summary { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s4) var(--s5); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.qs-head { display: flex; align-items: center; gap: var(--s4); min-width: 0; }
.qs-pct { flex: none; display: flex; flex-direction: column; align-items: center; min-width: 72px; line-height: 1; }
.qs-num { font-family: var(--font-brand); font-size: var(--fs-2xl); font-weight: 600; font-variant-numeric: tabular-nums; }
.qs-cap { font-size: var(--fs-xs); font-weight: 800; color: var(--text-3); margin-top: 4px; }
.qs-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.qs-text strong { font-size: var(--fs-md); }
.qs-when { display: flex; gap: 6px; align-items: flex-start; font-weight: 700; color: var(--text); }
.qs-when .icon { flex: none; color: var(--accent-deep); margin-top: 2px; }
.queue-summary .qs-bar { height: 12px; }
.queue-summary .qs-bar > i { background: var(--brand-deep); }
.qs-foot { margin: 0; font-size: var(--fs-sm); }
.qr-cover .cover-gen .gt { font-size: 7px; }
.qr-cover .cover-gen .ga, .qr-cover .cover-gen .gb, .dock-cover .cover-gen .gb { display: none; }
@media (max-width: 760px) {
  .listen-continue { grid-template-columns: 1fr; }
  .listen-card { grid-template-columns: 72px minmax(0, 1fr) auto; }
  .listen-grid { grid-template-columns: repeat(3, 1fr); gap: var(--s4) var(--s3); }
  .queue-row { grid-template-columns: 44px minmax(0, 1fr); }
  .queue-summary { padding: var(--s4); }
  .qs-head { gap: var(--s3); align-items: flex-start; }
  .qs-pct { min-width: 56px; }
  .qr-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ================================================================ the narrator */
.narr-panel { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s4) var(--s5); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.narr-panel.is-compact { padding: var(--s4); }
.narr-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.narr-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--text-3); border: 2px solid var(--outline); flex: none; }
.narr-dot.is-on { background: var(--ok); }
.narr-dot.is-busy { background: var(--accent); }
.narr-dot.is-off { background: var(--bg-sunk); }
.narr-rows { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px var(--s4); }
.narr-row { display: contents; }
.narr-k { font-size: var(--fs-sm); font-weight: 800; color: var(--text-3); padding-top: 1px; }
.narr-v { font-weight: 600; }
.narr-safe { display: flex; gap: var(--s2); align-items: flex-start; margin: 0; padding: var(--s3); border-radius: var(--r-md); background: var(--ok-soft); font-weight: 700; }
.narr-safe .icon { color: var(--ok); margin-top: 2px; }
@media (max-width: 520px) {
  .narr-rows { grid-template-columns: 1fr; gap: 2px; }
  .narr-k { margin-top: var(--s2); }
}

/* the sidebar chip, only while something is being narrated */
.narr-chip { display: flex; flex-direction: column; gap: 6px; padding: var(--s3); border-radius: var(--r-md); background: var(--bg); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: var(--fs-sm); }
.narr-chip:hover { border-color: var(--line-2); }
.narr-chip-top { display: flex; gap: var(--s2); align-items: flex-start; font-weight: 800; }
.narr-chip-top .icon { color: var(--accent-deep); flex: none; margin-top: 1px; }
.narr-chip-sub { color: var(--text-2); font-weight: 700; padding-left: 28px; }
.narr-chip .bar { height: 4px; margin-left: 28px; }
.narr-chip-eta { display: flex; gap: 6px; align-items: center; color: var(--text-2); font-weight: 700; font-size: var(--fs-xs); padding-left: 28px; }
.narr-chip-eta .icon { flex: none; color: var(--text-3); }
.narr-chip-safe { display: flex; gap: 6px; align-items: center; color: var(--ok); font-weight: 800; font-size: var(--fs-xs); padding-left: 28px; }

/* ================================================================ voices */
.voice-picker { display: flex; flex-direction: column; gap: var(--s3); }
.voice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--s2); }
.voice-card {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 60px; padding: var(--s2) var(--s2) var(--s2) var(--s3);
  border-radius: var(--r-md); border: var(--stroke) solid var(--line-2);
  background: var(--raise); cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.voice-card:hover { border-color: var(--text-2); }
.voice-card[aria-checked="true"] { border-color: var(--outline); background: var(--accent-soft); }
.voice-card[aria-disabled="true"] { cursor: default; }
.voice-card[aria-disabled="true"]:hover { border-color: var(--line-2); }
.voice-dot { width: 20px; height: 20px; flex: none; border-radius: 50%; border: var(--stroke) solid var(--line-2); background: var(--raise); display: grid; place-items: center; }
.voice-card[aria-checked="true"] .voice-dot { border-color: var(--outline); background: var(--accent); box-shadow: inset 0 0 0 3px var(--raise); }
.voice-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.voice-text span { font-size: var(--fs-sm); color: var(--text-2); font-weight: 600; }
.voice-play.is-playing { background: var(--accent); border-color: var(--outline); }
.voice-other-hint { margin: var(--s2) 0 0; }

/* ================================================================ settings section */
.ls-section h3 { margin-top: var(--s4); }
.ls-switches { display: flex; flex-direction: column; gap: var(--s3); }
.ls-skips { display: flex; gap: var(--s5); flex-wrap: wrap; }
.ls-time { display: flex; gap: 6px; align-items: flex-start; margin-top: 2px; font-weight: 700; color: var(--text-2); }
.ls-time .icon { flex: none; color: var(--text-3); margin-top: 2px; }
.ls-pos { width: 1.8em; text-align: right; color: var(--text-3); font-weight: 800; }
.ls-queue .list-row { flex-wrap: wrap; }
.ls-queue .btn-group { margin-left: auto; }
