:root {
  --reader-bg: #f7faf8;
  --reader-surface: rgba(255, 255, 255, 0.98);
  --reader-surface-soft: #f7fbf8;
  --reader-line: #dbe7df;
  --reader-line-strong: #b8d2c1;
  --reader-text: var(--text, #0f172a);
  --reader-muted: var(--muted, #64748b);
  --reader-primary: #147a3f;
  --reader-primary-strong: #0f5f33;
  --reader-primary-soft: var(--ok-bg, rgba(22, 163, 74, 0.08));
  --reader-cyan: #0f6b70;
  --reader-selected-bg: #f7fcf9;
  --reader-selected-border: var(--reader-line);
  --reader-selected-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
  --reader-green: var(--ok-text, #15803d);
  --reader-amber: #a16207;
  --reader-red: var(--danger-text, #b91c1c);
  --reader-progress-red: #dc2626;
  --reader-focus: #2563eb;
  --reader-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
  --reader-shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 24px rgba(15, 23, 42, 0.06);
}

:root[data-theme="dark"] {
  --reader-bg: #000000;
  --reader-surface: #050505;
  --reader-surface-soft: #0a0a0a;
  --reader-line: rgba(255, 255, 255, 0.18);
  --reader-line-strong: rgba(255, 255, 255, 0.36);
  --reader-text: #ffffff;
  --reader-muted: #bdbdbd;
  --reader-primary: #ffffff;
  --reader-primary-strong: #ededed;
  --reader-primary-soft: rgba(255, 255, 255, 0.1);
  --reader-cyan: #dadada;
  --reader-selected-bg: rgba(255, 255, 255, 0.12);
  --reader-selected-border: rgba(255, 255, 255, 0.5);
  --reader-selected-shadow: none;
  --reader-green: #ffffff;
  --reader-amber: #dadada;
  --reader-red: #ffffff;
  --reader-progress-red: #ffffff;
  --reader-focus: #ffffff;
  --reader-shadow: none;
  --reader-shadow-soft: none;
}

html:has(body.reader-page),
body.reader-page,
.reader-page .app-shell,
.reader-page .app-body {
  background: var(--reader-bg);
}

html:has(body.reader-page),
body.reader-page {
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

.reader-page .app-shell,
.reader-page .app-body {
  overflow-x: clip;
}

.reader-page .app-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow-y: hidden;
}

.reader-page .app-body {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.reader-page .footer {
  background: var(--reader-bg);
  border-top: 1px solid var(--reader-line);
  color: var(--reader-muted);
  flex: 0 0 auto;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.78rem;
  margin: auto 0 0;
  padding: 10px clamp(18px, 2.4vw, 34px) calc(10px + env(safe-area-inset-bottom));
}

.page-topbar:has(.reader-section-tabs) {
  border-bottom-color: var(--reader-line);
  gap: 14px;
  min-height: 68px;
}

.page-topbar:has(.reader-section-tabs) .page-topbar-title {
  flex: 0 0 auto;
}

.page-topbar:has(.reader-section-tabs) .page-topbar-actions {
  gap: 10px;
  margin-left: auto;
}

.reader-layout {
  background: var(--reader-bg);
  color: var(--reader-text);
  display: grid;
  flex: 0 0 auto;
  gap: 18px;
  min-height: 0;
  padding: 18px clamp(20px, 2.6vw, 38px) 32px;
}

.reader-layout .sr-only {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.reader-head {
  align-items: end;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.reader-kicker {
  color: var(--reader-cyan);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.reader-head h2,
.reader-panel h2,
.reader-player-shell h2 {
  color: var(--reader-text);
  line-height: 1.12;
  margin: 0;
}

.reader-head h2 {
  font-size: clamp(1.55rem, 2.2vw, 2.2rem);
  max-width: 780px;
}

.reader-copy {
  color: var(--reader-muted);
  font-size: 0.95rem;
  line-height: 1.55;
  margin: 7px 0 0;
  max-width: 700px;
}

.reader-actions {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
  min-width: min(460px, 100%);
}

.field,
.search-field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--reader-text);
  font-size: 0.86rem;
  font-weight: 800;
}

.field input,
.field select,
.search-field input {
  background: #fff;
  border: 1px solid var(--reader-line);
  border-radius: 8px;
  color: var(--reader-text);
  font-size: 0.98rem;
  min-height: 44px;
  min-width: 0;
  padding: 0 14px;
}

.field input:focus,
.field select:focus,
.search-field input:focus,
.reader-dropzone:focus-within,
.reader-tab:focus-visible,
.page-topbar-title-btn:focus-visible,
.reader-icon-btn:focus-visible,
.reader-play-btn:focus-visible,
.mini-control-btn:focus-visible,
.mini-play-btn:focus-visible,
.icon-action:focus-visible,
.book-select:focus-visible,
.section-play-btn:focus-visible,
.btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--reader-focus) 62%, transparent);
  outline-offset: 2px;
}

.voice-field {
  min-width: min(310px, 100%);
}

.reader-generate-btn,
.reader-open-recent-btn {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  min-height: 44px;
  padding-inline: 16px;
  white-space: nowrap;
}

.reader-action-icon,
.reader-tab-icon {
  display: inline-flex;
  fill: none;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.reader-action-icon {
  height: 1.18rem;
  width: 1.18rem;
}

.reader-status,
.reader-alert {
  border-radius: 12px;
  font-size: 0.94rem;
  line-height: 1.45;
  margin: 0;
  padding: 11px 14px;
}

.reader-status {
  background: color-mix(in srgb, var(--reader-primary) 8%, white 92%);
  color: var(--reader-primary-strong);
}

.reader-status:empty {
  display: none;
}

.reader-alert {
  background: #fff1f2;
  color: var(--reader-red);
  font-weight: 800;
}

.reader-layout .btn.primary,
.reader-page .page-topbar .btn.primary {
  background: var(--reader-primary);
  border-color: var(--reader-primary);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--reader-primary) 22%, transparent);
  color: #fff;
}

.reader-layout .btn.primary:hover:not(:disabled),
.reader-page .page-topbar .btn.primary:hover:not(:disabled) {
  background: var(--reader-primary-strong);
  border-color: var(--reader-primary-strong);
}

.reader-section-tabs {
  align-items: center;
  display: flex;
  flex: 0 1 auto;
  gap: 4px;
  justify-self: center;
  margin-left: clamp(8px, 2vw, 22px);
  max-width: min(100%, 560px);
  overflow-x: auto;
  scrollbar-width: none;
  width: max-content;
}

.reader-section-tabs::-webkit-scrollbar {
  display: none;
}

.reader-tab {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--reader-muted);
  cursor: pointer;
  flex: 0 0 auto;
  display: inline-flex;
  gap: 8px;
  min-height: 42px;
  padding: 0 15px;
  text-align: center;
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.reader-tab:hover:not(.active) {
  background: #f1f5f9;
  color: var(--reader-text);
}

.reader-tab.active {
  background: var(--reader-primary);
  border-color: var(--reader-primary);
  color: #fff;
  box-shadow: 0 7px 16px color-mix(in srgb, var(--reader-primary) 22%, transparent);
}

.reader-tab-plain {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--reader-muted);
  font-weight: 700;
  padding: 0 10px;
}

.reader-tab-plain:hover:not(.active) {
  background: transparent;
  color: var(--reader-text);
}

.reader-tab-plain.active {
  background: transparent;
  box-shadow: none;
  color: var(--reader-primary-strong);
}

.reader-tab-caret {
  height: 0.8rem;
  margin-left: -2px;
  opacity: 0.7;
  width: 0.8rem;
}

.reader-tab-label {
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.1;
}

.reader-tab-plain .reader-tab-label {
  font-weight: 700;
}

.reader-tab-icon {
  height: 1.05rem;
  width: 1.05rem;
}

.page-topbar-title-btn {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.page-topbar-title-btn:hover {
  color: var(--reader-primary-strong);
}

.reader-upload-btn {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  min-height: 42px;
  padding-inline: 16px;
  white-space: nowrap;
}

.reader-view {
  display: none;
}

.reader-view.active {
  display: grid;
  gap: 14px;
}

.reader-player-shell {
  align-items: start;
  background: var(--reader-surface);
  border: 1px solid var(--reader-line);
  border-radius: 12px;
  box-shadow: var(--reader-shadow);
  display: grid;
  gap: clamp(18px, 2.2vw, 28px);
  grid-template-columns: minmax(122px, 158px) 1fr;
  min-width: 0;
  padding: clamp(18px, 2.2vw, 26px);
}

.reader-cover {
  align-items: stretch;
  align-self: start;
  aspect-ratio: 0.76;
  background: linear-gradient(180deg, #f4fbf6, #eaf7ef);
  border: 1px solid color-mix(in srgb, var(--reader-primary) 18%, var(--reader-line));
  border-radius: 10px;
  color: var(--reader-primary);
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: stretch;
  overflow: hidden;
  padding: 12px;
  width: 100%;
}

.reader-cover::after {
  border-top: 5px solid currentColor;
  content: "";
  display: block;
  opacity: 0.86;
}

.reader-cover.type-pdf {
  background: linear-gradient(180deg, #fff8f6, #fff1ec);
  border-color: #ffd6d6;
  color: #c2410c;
}

.reader-cover.type-docx {
  background: linear-gradient(180deg, #f3fbf5, #eef8f1);
  border-color: color-mix(in srgb, var(--reader-primary) 18%, var(--reader-line));
  color: var(--reader-primary-strong);
}

.reader-cover.type-txt {
  background: #f1fbf6;
  border-color: #cfeedd;
  color: var(--reader-green);
}

.reader-cover svg {
  align-self: center;
  fill: none;
  height: 42px;
  justify-self: center;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
  width: 42px;
}

.reader-cover-type {
  align-items: center;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid currentColor;
  border-radius: 8px;
  display: inline-flex;
  font-size: 0.64rem;
  font-weight: 900;
  justify-self: start;
  min-height: 24px;
  padding: 0 8px;
}

.reader-cover-initials {
  align-self: end;
  color: currentColor;
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  opacity: 0.9;
}

.player-main {
  align-content: start;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.reader-panel-head {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  min-width: 0;
}

.player-doc-head {
  align-items: start;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  min-width: 0;
}

.player-doc-head-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.player-head-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.player-voice-field {
  min-width: min(230px, 42vw);
}

.player-voice-field select {
  min-height: 44px;
}

.selected-title {
  color: var(--reader-text);
  font-size: clamp(1.25rem, 1.9vw, 1.72rem);
  font-weight: 900;
  line-height: 1.12;
  margin: 0;
  overflow-wrap: anywhere;
}

.document-meta {
  color: var(--reader-muted);
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0;
}

.document-meta:empty {
  display: none;
}

.playback-strip {
  background: var(--reader-surface-soft);
  border: 1px solid var(--reader-line);
  border-radius: 14px;
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding: 18px 20px;
}

.playback-strip-title {
  color: var(--reader-text);
  font-size: clamp(1.1rem, 1.6vw, 1.4rem);
  font-weight: 900;
  line-height: 1.16;
  margin: 0;
  overflow-wrap: anywhere;
}

.segment-title {
  color: var(--reader-muted);
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.segment-title:empty {
  display: none;
}

.player-time-row {
  color: var(--reader-muted);
  display: flex;
  font-size: 0.88rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  justify-content: space-between;
  margin-top: 6px;
}

.progress-field {
  gap: 0;
  min-height: 22px;
  width: 100%;
}

#progressRange,
.progress-field input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  accent-color: var(--reader-progress-red);
  background: linear-gradient(
    to right,
    var(--reader-progress-red) 0%,
    var(--reader-progress-red) var(--reader-progress, 0%),
    var(--reader-line) var(--reader-progress, 0%),
    var(--reader-line) 100%
  );
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  height: 10px;
  max-width: none;
  min-height: 10px;
  padding: 0;
  width: 100%;
}

#progressRange::-webkit-slider-runnable-track,
.progress-field input[type="range"]::-webkit-slider-runnable-track,
#miniProgressRange::-webkit-slider-runnable-track {
  background: transparent;
  border: 0;
  height: 8px;
}

#progressRange::-webkit-slider-thumb,
.progress-field input[type="range"]::-webkit-slider-thumb,
#miniProgressRange::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  background: var(--reader-progress-red);
  border: 3px solid #fff;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.34);
  height: 20px;
  margin-top: -6px;
  width: 20px;
}

#progressRange::-moz-range-thumb,
.progress-field input[type="range"]::-moz-range-thumb,
#miniProgressRange::-moz-range-thumb {
  background: var(--reader-progress-red);
  border: 3px solid #fff;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.34);
  height: 20px;
  width: 20px;
}

#progressRange::-moz-range-progress,
.progress-field input[type="range"]::-moz-range-progress,
#miniProgressRange::-moz-range-progress {
  background: var(--reader-progress-red);
}

#progressRange::-moz-range-track,
.progress-field input[type="range"]::-moz-range-track,
#miniProgressRange::-moz-range-track {
  background: var(--reader-line);
}

.transport {
  align-items: center;
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr auto 1fr;
  margin-top: 2px;
}

.transport-spacer {
  min-width: 0;
}

.transport-buttons {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: center;
}

.transport-extras {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  justify-self: end;
  min-width: 0;
}

.transport-speed-field {
  min-width: 76px;
}

.transport-speed-field select {
  min-height: 38px;
  padding: 0 10px;
}

.volume-field {
  align-items: center;
  color: var(--reader-muted);
  display: flex;
  gap: 8px;
  min-width: 0;
}

.volume-field .reader-action-icon {
  flex: 0 0 auto;
  height: 18px;
  width: 18px;
}

.volume-field input[type="range"] {
  accent-color: var(--reader-primary);
  cursor: pointer;
  width: 84px;
}

.reader-icon-btn,
.reader-play-btn,
.section-play-btn {
  align-items: center;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 48px;
  padding: 0;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.control-icon {
  align-items: center;
  background: transparent;
  border-radius: 999px;
  display: inline-flex;
  justify-content: center;
  margin-right: 0;
  min-height: 24px;
  min-width: 24px;
}

.control-icon svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
  width: 18px;
}

.reader-play-btn .control-icon svg path {
  fill: currentColor;
  stroke: currentColor;
}

.reader-play-btn .reader-action-icon path,
.section-play-btn .reader-action-icon path,
.mini-play-btn .reader-action-icon path {
  fill: currentColor;
  stroke: currentColor;
}

.control-text {
  min-width: 0;
}

.reader-icon-btn {
  background: #fff;
  border: 1px solid var(--reader-line);
  color: var(--reader-text);
  width: 48px;
}

.reader-play-btn {
  background: var(--reader-primary);
  border: 1px solid var(--reader-primary);
  box-shadow: 0 12px 24px color-mix(in srgb, var(--reader-primary) 26%, transparent);
  color: #fff;
  min-height: 62px;
  width: 62px;
}

.reader-play-btn .control-icon {
  background: rgba(255, 255, 255, 0.18);
}

.reader-icon-btn:hover:not(:disabled),
.section-play-btn:hover:not(:disabled),
.book-select:hover {
  border-color: var(--reader-primary);
  color: var(--reader-primary-strong);
  transform: translateY(-1px);
}

.reader-play-btn:hover:not(:disabled) {
  background: var(--reader-primary-strong);
}

.reader-icon-btn:active:not(:disabled),
.reader-play-btn:active:not(:disabled),
.section-play-btn:active:not(:disabled),
.mini-control-btn:active:not(:disabled),
.mini-play-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.94);
  transition-duration: 60ms;
}

.reader-icon-btn:disabled,
.reader-play-btn:disabled,
.section-play-btn:disabled,
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.compact-field {
  min-width: 140px;
}

.player-hint {
  color: var(--reader-muted);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
  padding: 0 2px;
}

.narration-options {
  border-top: 1px solid var(--reader-line);
  margin-top: 4px;
  padding-top: 12px;
}

.narration-options summary {
  color: var(--reader-muted);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 800;
  list-style: none;
  padding: 6px 2px;
  user-select: none;
}

.narration-options summary::-webkit-details-marker {
  display: none;
}

.narration-options summary::before {
  content: "\25B8";
  display: inline-block;
  margin-right: 8px;
  transition: transform 160ms ease;
}

.narration-options[open] summary::before {
  transform: rotate(90deg);
}

.narration-options summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--reader-focus) 62%, transparent);
  outline-offset: 2px;
}

.narration-options-body {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  padding-top: 10px;
}

.reader-main-grid,
.reader-support-grid {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(430px, 1.05fr) minmax(360px, 0.95fr);
}

.reader-support-grid {
  grid-template-columns: minmax(300px, 0.78fr) minmax(380px, 1.22fr);
}

.reader-panel {
  align-content: start;
  background: var(--reader-surface);
  border: 1px solid var(--reader-line);
  border-radius: 12px;
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 20px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.reader-panel:hover {
  border-color: color-mix(in srgb, var(--reader-primary) 22%, var(--reader-line));
  box-shadow: var(--reader-shadow-soft);
}

.library-full-panel,
.playlist-full-panel {
  max-width: none;
  width: 100%;
}

.upload-panel {
  max-width: 760px;
  width: 100%;
}

.reader-panel h2 {
  font-size: 1.08rem;
}

.panel-note {
  color: var(--reader-muted);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.5;
  margin: -6px 0 0;
  max-width: 860px;
}

.library-head-controls {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.library-head-controls .compact-field {
  min-width: 150px;
}

.search-field {
  min-width: min(260px, 100%);
  position: relative;
}

/* A single SVG icon, vertically centered as a percentage of the input's
   actual height rather than a fixed pixel offset - so it stays correctly
   positioned whether the field is the default size, the larger library
   search, or a narrower mobile layout, instead of drifting out of the
   input when its height changes. */
.search-field::before {
  background: no-repeat center / 15px 15px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E");
  content: "";
  height: 15px;
  left: 13px;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
}

:root[data-theme="dark"] .search-field::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23BDBDBD' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E");
}

.search-field input {
  padding-left: 38px;
}

.reader-count,
.status-badge {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  font-size: 0.74rem;
  font-weight: 900;
  min-height: 30px;
  padding: 0 11px;
  white-space: nowrap;
}

.reader-count,
.status-badge.neutral {
  background: #eef2f7;
  color: #475569;
}

.status-badge.ready {
  background: #ecfdf3;
  color: var(--reader-green);
}

.status-badge.processing,
.status-badge.pending {
  background: #fff7df;
  color: var(--reader-amber);
}

.status-badge.failed {
  background: #fff1f2;
  color: var(--reader-red);
}

.reader-dropzone {
  align-items: center;
  background: var(--reader-surface-soft);
  border: 1.5px dashed var(--reader-line-strong);
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 24px;
  text-align: center;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

.reader-dropzone:hover {
  background: #fff;
  border-color: var(--reader-primary);
}

.reader-dropzone.dragging {
  background: #f1fbf6;
  border-color: var(--reader-primary);
}

.reader-dropzone span {
  color: var(--reader-text);
  font-weight: 900;
}

.reader-dropzone small,
.reader-count,
.book-meta,
.section-preview,
.section-meta,
.empty-state {
  color: var(--reader-muted);
}

#readerFileInput {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.reader-list,
.segments {
  --reader-visible-rows: 5;
  --reader-row-size: 82px;
  display: grid;
  gap: 8px;
  grid-auto-rows: var(--reader-row-size);
  max-height: calc(var(--reader-visible-rows) * var(--reader-row-size));
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 2px;
  overscroll-behavior: contain;
  scroll-padding-block: 4px;
  scrollbar-color: color-mix(in srgb, var(--reader-primary) 42%, var(--reader-line)) transparent;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.reader-list:has(.empty-state),
.segments:has(.empty-state) {
  grid-auto-rows: auto;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.library-list-large {
  max-height: calc(var(--reader-visible-rows) * var(--reader-row-size));
}

.section-panel .segments {
  --reader-row-size: 88px;
}

.library-panel .reader-list {
  min-height: 0;
  --reader-row-size: 84px;
}

.book-row,
.segment-row,
.bookmark-row {
  background: #fff;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--reader-text);
  min-width: 0;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.bookmark-row {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  height: 100%;
  padding: 12px 14px;
}

.bookmark-row:hover {
  background: #f8fafc;
  border-color: var(--reader-line);
}

.bookmark-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.bookmark-label {
  color: var(--reader-text);
  font-size: 0.94rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark-meta {
  color: var(--reader-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.bookmark-actions {
  align-items: center;
  display: flex;
  gap: 6px;
}

.section-bookmark-row {
  align-items: end;
  border-bottom: 1px solid var(--reader-line);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: space-between;
}

.section-bookmark-row-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  padding-bottom: 8px;
}

.section-bookmark-tabs {
  display: flex;
  gap: 22px;
}

.section-bookmark-tab {
  align-items: center;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--reader-muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.94rem;
  font-weight: 700;
  gap: 8px;
  margin-bottom: -1px;
  padding: 10px 2px 11px;
  transition:
    color 160ms ease,
    border-color 160ms ease;
}

.section-bookmark-tab:hover:not(.active) {
  color: var(--reader-text);
}

.section-bookmark-tab.active {
  border-bottom-color: var(--reader-primary);
  color: var(--reader-primary-strong);
  font-weight: 800;
}

.section-bookmark-tab:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--reader-focus) 62%, transparent);
  outline-offset: 2px;
}

.reader-count-pill {
  align-items: center;
  background: var(--reader-surface-soft);
  border-radius: 999px;
  color: var(--reader-muted);
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 800;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 7px;
}

.section-bookmark-tab.active .reader-count-pill {
  background: color-mix(in srgb, var(--reader-primary) 16%, transparent);
  color: var(--reader-primary-strong);
}

.reader-add-bookmark-btn {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  min-height: 42px;
  padding-inline: 14px;
  white-space: nowrap;
}

.segments-table-head {
  align-items: center;
  color: var(--reader-muted);
  display: grid;
  font-size: 0.72rem;
  font-weight: 800;
  gap: 12px;
  grid-template-columns: 34px minmax(0, 1fr) 66px 82px auto;
  letter-spacing: 0.05em;
  overflow: hidden;
  padding: 2px 10px;
  /* Matches .segments' own scrollbar-gutter reservation below, so this
     row's columns line up with the section rows even though it never
     scrolls itself - without it, the browser only reserves scrollbar
     space in the list, shifting every column after the first in the
     header relative to the rows beneath it. */
  scrollbar-gutter: stable;
  text-transform: uppercase;
}

.outline-jump-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.outline-jump-list.hidden {
  display: none;
}

.outline-chip {
  background: var(--reader-primary-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--reader-text);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  max-width: 260px;
  overflow: hidden;
  padding: 5px 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.outline-chip:hover {
  border-color: var(--reader-primary);
}

.outline-chip[data-level="1"] {
  font-weight: 800;
}

.outline-chip:not([data-level="1"]) {
  color: var(--reader-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.section-heading-row {
  align-items: center;
  color: var(--reader-muted);
  display: flex;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  padding: 0 10px;
  text-transform: uppercase;
}

.section-heading-row[data-level="1"] {
  color: var(--reader-text);
}

.section-heading-row:not([data-level="1"]) {
  padding-left: 26px;
}

.reader-panel-footer {
  align-items: center;
  border-top: 1px solid var(--reader-line);
  color: var(--reader-muted);
  display: flex;
  font-size: 0.84rem;
  font-weight: 700;
  gap: 8px;
  margin: 0;
  padding-top: 12px;
}

.reader-panel-footer[hidden] {
  display: none;
}

.reader-panel-footer .reader-action-icon {
  color: var(--reader-primary);
  flex: 0 0 auto;
  height: 16px;
  width: 16px;
}

.reader-panel-footer-position {
  margin-left: auto;
}

.segment-row {
  min-height: 0;
}

.book-row {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  padding: 12px 10px;
  text-align: left;
  width: 100%;
}

.compact-book-row .book-actions {
  display: none;
}

.book-row[aria-current="true"] {
  background: var(--reader-selected-bg);
  border-color: var(--reader-selected-border);
  box-shadow: var(--reader-selected-shadow);
}

.book-row:hover,
.segment-row:hover {
  background: #f8fafc;
  border-color: var(--reader-line);
}

.book-select {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--reader-text);
  cursor: pointer;
  display: grid;
  gap: 12px;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  min-width: 0;
  padding: 0;
  text-align: left;
  width: 100%;
}

.compact-book-row .book-select {
  grid-template-columns: 48px minmax(0, 1fr);
}

.compact-book-row .book-status {
  display: none;
}

/* One neutral badge style for every document type - the type label text
   (PDF/DOCX/TXT/DOC) is the differentiator, not badge colour, so the type
   indicator stays legible and consistent across light/dark themes instead
   of using a different hardcoded, non-token colour per file type. */
.book-icon {
  align-items: center;
  background: var(--reader-surface-soft);
  border: 1px solid var(--reader-line-strong);
  border-radius: 8px;
  color: var(--reader-text);
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 900;
  height: 48px;
  justify-content: center;
  letter-spacing: 0.02em;
  width: 48px;
}

.book-main,
.section-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.book-title,
.section-title {
  color: var(--reader-text);
  font-weight: 900;
  line-height: 1.25;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-meta,
.section-meta,
.section-preview {
  font-size: 0.86rem;
  line-height: 1.35;
  margin: 0;
}

.section-preview {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.book-status {
  justify-self: end;
}

.book-actions,
.playlist-item-actions,
.playlist-manage-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.btn.danger {
  background: #fff1f2;
  border-color: rgba(185, 28, 28, 0.22);
  color: var(--reader-red);
}

.btn.danger:hover:not(:disabled) {
  background: #ffe4e6;
  border-color: rgba(185, 28, 28, 0.48);
}

.small-btn {
  min-height: 34px;
  padding-inline: 12px;
}

.icon-action {
  align-items: center;
  background: #fff;
  border: 1px solid var(--reader-line);
  border-radius: 8px;
  color: var(--reader-muted);
  cursor: pointer;
  display: inline-flex;
  height: 42px;
  justify-content: center;
  padding: 0;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
  width: 42px;
}

.icon-action:hover:not(:disabled) {
  background: #f1fbf6;
  border-color: color-mix(in srgb, var(--reader-primary) 34%, var(--reader-line));
  color: var(--reader-primary-strong);
  transform: translateY(-1px);
}

.icon-action.danger {
  background: var(--danger-bg, #fff1f2);
  border-color: var(--danger-border, rgba(185, 28, 28, 0.22));
  color: var(--reader-red);
}

.icon-action.danger:hover:not(:disabled) {
  background: var(--btn-danger-bg-hover, #ffe4e6);
  border-color: var(--danger-border, rgba(185, 28, 28, 0.32));
  color: var(--reader-red);
}

.book-actions .btn.danger {
  border-style: dashed;
}

.segment-row {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 34px minmax(0, 1fr) 66px 82px auto;
  height: 100%;
  min-height: 0;
  padding: 12px 10px;
}

.segment-row[aria-current="true"] {
  background: var(--reader-selected-bg);
  border-color: var(--reader-selected-border);
  box-shadow: var(--reader-selected-shadow);
}

.section-index {
  color: var(--reader-muted);
  font-size: 0.9rem;
  font-weight: 900;
  text-align: center;
}

.section-play-btn {
  background: var(--reader-primary);
  border: 1px solid var(--reader-primary);
  color: #fff;
  min-width: 0;
  width: 42px;
}

.section-duration {
  color: var(--reader-muted);
  font-size: 0.86rem;
  font-weight: 900;
  text-align: right;
}

.section-status {
  justify-self: start;
}

.playlist-form {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
}

.playlist-manage-details {
  border-top: 1px solid var(--reader-line);
  margin-top: 4px;
  padding-top: 12px;
}

.playlist-manage-details summary {
  color: var(--reader-text);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
  list-style: none;
  padding: 6px 2px;
  user-select: none;
}

.playlist-manage-details summary::-webkit-details-marker {
  display: none;
}

.playlist-manage-details summary::before {
  content: "\25B8";
  display: inline-block;
  margin-right: 8px;
  transition: transform 160ms ease;
}

.playlist-manage-details[open] summary::before {
  transform: rotate(90deg);
}

.playlist-manage-details summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--reader-focus) 62%, transparent);
  outline-offset: 2px;
}

.playlist-manage {
  background: var(--reader-surface-soft);
  border: 1px solid var(--reader-line);
  border-radius: 10px;
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 14px;
}

.playlist-items {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.playlist-items li {
  align-items: center;
  background: transparent;
  border-bottom: 1px solid var(--reader-line);
  border-radius: 0;
  display: grid;
  gap: 10px;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  min-height: 56px;
  padding: 10px 4px;
}

.playlist-items li:hover {
  background: var(--reader-surface-soft);
}

.playlist-items li.empty-state {
  border: 1px dashed var(--reader-line);
  border-radius: 10px;
  grid-template-columns: 1fr;
  padding: 16px;
}

.playlist-track-index {
  color: var(--reader-muted);
  font-weight: 900;
  text-align: center;
}

.playlist-track-title {
  color: var(--reader-text);
  font-weight: 900;
}

.playlist-items span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.playlist-items button {
  flex: 0 0 auto;
}

.reader-mini-player {
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--reader-line);
  border-radius: 12px;
  bottom: 0;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.1);
  display: grid;
  gap: 14px;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  padding: 12px;
  position: sticky;
  z-index: 4;
}

.mini-cover {
  align-items: center;
  background: #f3f7ff;
  border: 1px solid #d7e2f3;
  border-radius: 8px;
  color: var(--reader-primary);
  display: inline-flex;
  font-size: 0.7rem;
  font-weight: 900;
  height: 48px;
  justify-content: center;
  width: 48px;
}

.reader-mini-player.type-pdf .mini-cover {
  background: #fff5f5;
  border-color: #ffd6d6;
  color: #c2410c;
}

.reader-mini-player.type-txt .mini-cover {
  background: #f1fbf6;
  border-color: #cfeedd;
  color: var(--reader-green);
}

.mini-now-playing {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.mini-now-playing strong,
.mini-now-playing span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-now-playing strong {
  color: var(--reader-text);
  font-size: 0.95rem;
}

.mini-now-playing span {
  color: var(--reader-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

#miniProgressRange {
  -webkit-appearance: none;
  appearance: none;
  accent-color: var(--reader-progress-red);
  /* Thumb below is 20px, so the fill is inset by half that (10px) at each
     end to match WebKit's own thumb-centring - same technique as the main
     player's progress-track rule further down this file. */
  background: linear-gradient(
    to right,
    var(--reader-progress-red) calc(10px + var(--reader-progress-ratio, 0) * (100% - 20px)),
    var(--reader-line) calc(10px + var(--reader-progress-ratio, 0) * (100% - 20px))
  );
  border-radius: 999px;
  border: 0;
  height: 8px;
  min-height: 8px;
  width: 100%;
}

.mini-controls {
  display: flex;
  gap: 6px;
}

.mini-control-btn,
.mini-play-btn {
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 900;
  height: 38px;
  justify-content: center;
  min-height: 38px;
  padding: 0;
  width: 38px;
}

.mini-control-btn {
  background: #fff;
  border: 1px solid var(--reader-line);
  color: var(--reader-text);
}

.mini-play-btn {
  background: var(--reader-primary);
  border: 1px solid var(--reader-primary);
  color: #fff;
}

.mini-control-btn:disabled,
.mini-play-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.empty-state {
  background: var(--reader-surface-soft);
  border: 1px dashed var(--reader-line);
  border-radius: 10px;
  margin: 0;
  padding: 16px;
}

.empty-state-action {
  display: grid;
  gap: 6px;
}

.empty-state-action strong {
  color: var(--reader-text);
  font-size: 0.98rem;
}

.empty-state-action span {
  color: var(--reader-muted);
  line-height: 1.45;
}

.empty-state-featured {
  align-items: start;
  min-height: 220px;
  padding: 28px;
}

.empty-state-btn {
  justify-self: start;
  margin-top: 8px;
}

.hidden {
  display: none !important;
}

.section-search-field {
  min-width: min(200px, 100%);
}

.recent-documents-overlay {
  background: rgba(2, 6, 23, 0.6);
  inset: 0;
  position: fixed;
  z-index: 150;
}

.recent-documents-dialog {
  background: var(--reader-surface);
  border: 1px solid var(--reader-line);
  border-radius: 14px;
  box-shadow: var(--reader-shadow);
  display: grid;
  gap: 14px;
  inset: 8vh 50% auto 50%;
  max-height: 78vh;
  overflow-y: auto;
  padding: 20px;
  position: fixed;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 32px));
  z-index: 151;
}

.recent-documents-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.recent-documents-head h2 {
  font-size: 1.1rem;
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 1180px) {
  .page-topbar:has(.reader-section-tabs) {
    flex-wrap: wrap;
    height: auto;
    padding-block: 8px;
  }

  .page-topbar:has(.reader-section-tabs) .page-topbar-title {
    flex: 1 1 auto;
  }

  .reader-section-tabs {
    flex: 0 1 auto;
    justify-content: flex-start;
    margin-left: 0;
    max-width: calc(100vw - 36px);
    order: 3;
    width: max-content;
  }
}

@media (max-width: 980px) {
  .page-topbar:has(.reader-section-tabs) .page-topbar-actions {
    margin-left: 0;
  }

  .reader-layout {
    padding: 18px;
  }

  .reader-head,
  .reader-panel-head,
  .player-doc-head,
  .player-head-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .player-head-actions {
    justify-content: flex-start;
  }

  .library-head-controls {
    justify-content: flex-start;
    width: 100%;
  }

  .reader-actions {
    align-items: stretch;
    min-width: 0;
  }

  .reader-player-shell,
  .reader-main-grid,
  .reader-support-grid,
  .playlist-form {
    grid-template-columns: 1fr;
  }

  .segment-row {
    grid-template-columns: 30px minmax(0, 1fr) 58px 74px auto;
  }
  .reader-cover {
    min-height: 132px;
    max-width: 240px;
  }

  .player-hint {
    text-align: left;
  }

  .reader-mini-player {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .mini-controls {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .reader-page .page-topbar {
    padding-inline: 12px;
  }

  .page-topbar:has(.reader-section-tabs) {
    gap: 8px;
  }

  .reader-layout {
    gap: 12px;
    padding: 12px;
  }

  .reader-panel,
  .reader-player-shell {
    border-radius: 18px;
  }

  .reader-panel {
    padding: 16px;
  }

  .reader-panel-head {
    gap: 10px;
  }

  .reader-panel-head .search-field {
    width: 100%;
  }

  .section-bookmark-row {
    flex-direction: column;
    align-items: stretch;
  }

  .section-bookmark-row-actions {
    padding-bottom: 12px;
  }

  .section-search-field {
    flex: 1 1 auto;
    min-width: 0;
  }

  .segments-table-head {
    grid-template-columns: 24px minmax(0, 1fr) 44px;
    padding: 2px 0;
  }

  .segments-table-head span:nth-child(4) {
    display: none;
  }

  .library-head-controls {
    width: 100%;
  }

  .library-head-controls .search-field {
    flex: 1 1 100%;
  }

  .library-head-controls .compact-field {
    flex: 1 1 auto;
  }

  .search-field input,
  .field input,
  .field select {
    min-height: 44px;
  }

  .panel-note {
    display: none;
  }

  .reader-tab {
    gap: 7px;
    min-height: 42px;
    padding: 0 14px;
  }

  .transport {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .transport-spacer {
    display: none;
  }

  .transport-buttons {
    gap: 6px;
  }

  .transport-extras {
    justify-content: center;
    justify-self: center;
  }

  .playback-strip {
    padding: 14px 16px;
  }

  .reader-player-shell {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .reader-cover {
    display: none;
  }

  .player-card-head {
    gap: 10px;
  }

  .player-head-actions {
    align-items: stretch;
    width: 100%;
  }

  .player-voice-field,
  .reader-generate-btn {
    width: 100%;
  }

  .selected-title {
    font-size: 1.25rem;
  }

  .segment-title {
    font-size: 0.92rem;
  }

  .reader-icon-btn,
  .reader-play-btn {
    min-height: 46px;
    width: 46px;
  }

  .reader-play-btn {
    min-height: 58px;
    width: 58px;
  }

  .reader-list,
  .segments {
    padding-right: 0;
  }

  .section-panel .segments {
    --reader-row-size: 76px;
    max-height: calc(var(--reader-visible-rows) * var(--reader-row-size));
  }

  .library-panel .reader-list {
    --reader-row-size: 92px;
    max-height: calc(var(--reader-visible-rows) * var(--reader-row-size));
  }

  .library-list-large {
    --reader-row-size: 96px;
    max-height: calc(var(--reader-visible-rows) * var(--reader-row-size));
  }

  .book-row {
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) 44px;
    padding: 8px 0;
  }

  .book-select {
    gap: 10px;
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .book-icon {
    border-radius: 14px;
    font-size: 0.76rem;
    height: 46px;
    width: 46px;
  }

  .book-main {
    gap: 3px;
  }

  .book-title {
    font-size: 0.95rem;
  }

  .book-meta {
    display: -webkit-box;
    font-size: 0.88rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: clip;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .book-status {
    display: none;
  }

  .book-actions {
    align-self: center;
    grid-column: 2;
    grid-row: 1;
    justify-content: center;
  }

  .compact-book-row {
    grid-template-columns: 1fr;
  }

  .compact-book-row .book-select {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .segment-row {
    gap: 8px;
    grid-template-columns: 24px minmax(0, 1fr) 44px;
    padding: 8px 0;
  }

  .segment-row .section-duration {
    grid-column: 2;
    text-align: left;
  }

  .segment-row .section-status {
    display: none;
  }

  .segment-row .section-play-btn {
    grid-column: 3;
    grid-row: 1 / span 2;
  }

  .section-title {
    font-size: 0.95rem;
  }

  .section-preview {
    display: none;
  }

  .section-duration,
  .section-meta {
    font-size: 0.78rem;
  }

  .bookmark-row {
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) auto auto;
    padding: 8px 10px;
  }

  .bookmark-row .status-badge {
    display: none;
  }

  .bookmark-label {
    font-size: 0.88rem;
  }

  .bookmark-meta {
    font-size: 0.76rem;
  }

  .bookmark-row .btn.small-btn {
    padding-inline: 10px;
  }

  .section-play-btn {
    height: 42px;
    width: 42px;
  }

  .playlist-form,
  .playlist-manage {
    grid-template-columns: 1fr;
  }

  .playlist-items li {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .playlist-item-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding-left: 38px;
  }

  .book-status {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .reader-mini-player {
    border-radius: 16px;
    gap: 10px;
    padding: 10px;
  }

  .mini-cover {
    height: 42px;
    width: 42px;
  }

  .mini-controls {
    justify-content: space-between;
    width: 100%;
  }
}

@media (max-width: 520px) {
  .page-topbar:has(.reader-section-tabs) {
    align-items: center;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .page-topbar:has(.reader-section-tabs) .page-topbar-title {
    min-width: 0;
  }

  .reader-section-tabs {
    grid-column: 1 / -1;
    max-width: calc(100vw - 24px);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: visible;
    padding: 4px;
    width: 100%;
  }

  .reader-tab {
    gap: 5px;
    justify-content: center;
    min-height: 40px;
    padding: 0 4px;
    width: 100%;
  }

  .reader-tab-label {
    font-size: 0.78rem;
  }

  .reader-tab-icon {
    height: 0.92rem;
    width: 0.92rem;
  }

  .reader-open-recent-btn {
    min-height: 40px;
    padding-inline: 10px;
  }

  .reader-open-recent-label {
    display: none;
  }

  .reader-panel-head h2,
  .reader-player-shell h2 {
    font-size: 1.15rem;
  }

  .reader-kicker {
    font-size: 0.62rem;
  }

  .reader-player-shell {
    gap: 14px;
  }

  .reader-cover {
    aspect-ratio: 1.22;
    min-height: 112px;
    max-width: 170px;
    padding: 10px;
  }

  .reader-cover svg {
    height: 32px;
    width: 32px;
  }

  .reader-mini-player {
    grid-template-columns: minmax(0, 1fr);
  }

  .reader-mini-player .mini-cover {
    display: none;
  }
}

:root[data-theme="dark"] .reader-section-tabs,
:root[data-theme="dark"] .reader-player-shell,
:root[data-theme="dark"] .reader-panel,
:root[data-theme="dark"] .reader-mini-player,
:root[data-theme="dark"] .reader-list,
:root[data-theme="dark"] .book-card,
:root[data-theme="dark"] .section-row,
:root[data-theme="dark"] .book-row,
:root[data-theme="dark"] .segment-row,
:root[data-theme="dark"] .bookmark-row,
:root[data-theme="dark"] .recent-documents-dialog,
:root[data-theme="dark"] .playlist-manage {
  background: #050505 !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
  box-shadow: none !important;
  color: #ffffff !important;
}

/* The flat dark background above is !important and was silently beating the
   book/segment row's own aria-current="true" (currently open/selected)
   styling too, since that rule sets the same properties without !important
   - so in dark mode there was no way to tell which row was selected.
   Re-assert it here at higher specificity so it wins back. */
:root[data-theme="dark"] .book-row[aria-current="true"],
:root[data-theme="dark"] .segment-row[aria-current="true"] {
  background: var(--reader-selected-bg) !important;
  border-color: var(--reader-selected-border) !important;
  box-shadow: var(--reader-selected-shadow) !important;
}

:root[data-theme="dark"] .reader-tab {
  background: transparent !important;
  border-color: transparent !important;
  color: #d0d0d0 !important;
}

:root[data-theme="dark"] .reader-tab:hover:not(.active) {
  background: #111111 !important;
  color: #ffffff !important;
}

:root[data-theme="dark"] .reader-tab.active,
:root[data-theme="dark"] .reader-layout .btn.primary,
:root[data-theme="dark"] .reader-page .page-topbar .btn.primary,
:root[data-theme="dark"] .reader-play-btn,
:root[data-theme="dark"] .mini-play-btn {
  background: #ffffff !important;
  border-color: #ffffff !important;
  color: #000000 !important;
  box-shadow: none !important;
}

/* section-bookmark-tab is an underline tab, not a filled pill - its colors
   already resolve correctly in dark mode via var(--reader-primary*) tokens,
   so it deliberately gets no !important overrides here. */
:root[data-theme="dark"] .reader-tab-plain {
  color: #d0d0d0 !important;
}

:root[data-theme="dark"] .reader-tab-plain:hover:not(.active) {
  background: transparent !important;
  color: #ffffff !important;
}

:root[data-theme="dark"] .reader-tab-plain.active {
  background: transparent !important;
  color: #ffffff !important;
}

:root[data-theme="dark"] .reader-icon-btn,
:root[data-theme="dark"] .section-play-btn,
:root[data-theme="dark"] .mini-control-btn,
:root[data-theme="dark"] .reader-generate-btn,
:root[data-theme="dark"] .book-select {
  background: #111111 !important;
  border-color: rgba(255, 255, 255, 0.24) !important;
  color: #ffffff !important;
  box-shadow: none !important;
}

:root[data-theme="dark"] .reader-cover,
:root[data-theme="dark"] .reader-cover.type-pdf,
:root[data-theme="dark"] .reader-cover.type-docx,
:root[data-theme="dark"] .reader-cover.type-txt,
:root[data-theme="dark"] .mini-cover,
:root[data-theme="dark"] .reader-mini-player.type-pdf .mini-cover,
:root[data-theme="dark"] .reader-mini-player.type-txt .mini-cover {
  background: #111111 !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  color: #ffffff !important;
}

:root[data-theme="dark"] .reader-cover-type,
:root[data-theme="dark"] .reader-count,
:root[data-theme="dark"] .status-badge,
:root[data-theme="dark"] .book-status,
:root[data-theme="dark"] .section-status,
:root[data-theme="dark"] .reader-status,
:root[data-theme="dark"] .reader-alert {
  background: #111111 !important;
  border-color: rgba(255, 255, 255, 0.24) !important;
  color: #ffffff !important;
}

:root[data-theme="dark"] #progressRange,
:root[data-theme="dark"] .progress-field input[type="range"],
:root[data-theme="dark"] #miniProgressRange {
  accent-color: #ffffff;
  /* Same 20px-thumb inset correction as the light-mode #miniProgressRange
     rule - this dark-theme rule shares that rule's thumb definition
     (::-webkit-slider-thumb below, 20px), so it needs the same 10px inset. */
  background: linear-gradient(
    to right,
    #ffffff calc(10px + var(--reader-progress-ratio, 0) * (100% - 20px)),
    #1a1a1a calc(10px + var(--reader-progress-ratio, 0) * (100% - 20px))
  );
}

:root[data-theme="dark"] #progressRange::-webkit-slider-thumb,
:root[data-theme="dark"] .progress-field input[type="range"]::-webkit-slider-thumb,
:root[data-theme="dark"] #miniProgressRange::-webkit-slider-thumb {
  background: #ffffff;
  border-color: #000000;
  box-shadow: none;
}

:root[data-theme="dark"] #progressRange::-moz-range-thumb,
:root[data-theme="dark"] .progress-field input[type="range"]::-moz-range-thumb,
:root[data-theme="dark"] #miniProgressRange::-moz-range-thumb {
  background: #ffffff;
  border-color: #000000;
  box-shadow: none;
}

/* Reading-view layout; retain legacy DOM hooks used by the player and library. */
.reader-page {
  --reader-bg: #fff;
  --reader-progress-red: var(--reader-primary);
}
.reader-page .reader-layout,
.reader-page .page-topbar {
  font-family: "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}
.reader-page .reader-layout :is(button, input, select, summary),
.reader-page .page-topbar :is(button, input, select) {
  font-family: inherit;
  letter-spacing: 0;
  font-size: 16px;
}
.reader-page .page-topbar {
  min-height: 76px;
  margin: 0;
  padding-inline: 36px;
  gap: 24px;
}
.reader-page .page-topbar-title {
  margin-right: auto;
}
.reader-page .page-topbar-title-btn {
  font-size: 28px;
  font-weight: 600;
}
.reader-page .reader-tab {
  font-weight: 400;
}
.reader-page .reader-upload-btn {
  box-shadow: none;
  border-radius: 4px;
}
.reader-page .reader-layout {
  padding: 24px 36px;
}
.reader-page .reader-kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--reader-muted);
}
.reader-page .transport-speed-field {
  flex: 0 0 90px;
  width: 90px;
}
.reader-page .transport-speed-field select {
  width: 90px;
}
.reader-page .reader-icon-btn {
  width: 44px;
  height: 44px;
}
.reader-page .reader-play-btn {
  width: 72px;
  height: 72px;
}
.reader-page .section-bookmark-tab {
  font-size: 16px;
  font-weight: 500;
}
.reader-page .section-panel .segments {
  display: grid;
  grid-auto-rows: minmax(52px, auto);
  gap: 0;
  max-height: none;
  overflow: visible;
  padding: 0;
  scrollbar-gutter: auto;
}
.reader-page .segments-table-head,
.reader-page .segment-row {
  grid-template-columns: 36px minmax(0, 1fr) 140px 160px 44px;
  gap: 12px;
  padding: 12px 16px;
  scrollbar-gutter: auto;
}
.reader-page .segments-table-head {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  border-bottom: 1px solid var(--reader-line);
}
.reader-page .segment-row {
  height: auto;
  min-height: 52px;
  border: 0;
  border-bottom: 1px solid var(--reader-line);
  border-left: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.reader-page .segment-row[aria-current="true"] {
  background: var(--reader-primary-soft);
  border-left-color: var(--reader-line-strong);
  box-shadow: none;
}
.reader-page .section-title {
  font-size: 16px;
  font-weight: 400;
  white-space: normal;
  overflow-wrap: anywhere;
}
.reader-page .segment-row[aria-current="true"] .section-title {
  font-weight: 600;
}
.reader-page .section-index,
.reader-page .section-duration {
  font-size: 15px;
  font-weight: 400;
}
.reader-page .section-preview {
  font-size: 13px;
  font-weight: 400;
  margin: 3px 0 0;
}
.reader-page .section-preview:empty {
  display: none;
}
.reader-page .section-status {
  background: transparent;
  border: 0;
  padding: 0;
  border-radius: 0;
  font-size: 14px;
  font-weight: 400;
}
.reader-page .section-play-btn {
  background: transparent;
  color: var(--reader-text);
  border: 0;
  box-shadow: none;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 6px;
  opacity: 1;
}
.reader-page .section-duration {
  text-align: left;
  justify-self: start;
}
.reader-page .page-topbar .reader-section-tabs {
  margin-left: auto;
}
.reader-page .page-topbar-title {
  flex: 0 0 auto;
}
.reader-page .reader-play-btn {
  border-color: transparent;
}
.reader-page .reader-play-btn .control-icon {
  background: transparent;
}
.reader-page .control-icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
}
.reader-page .reader-play-btn .control-icon svg {
  width: 30px;
  height: 30px;
}
.reader-page .seek-icon {
  align-items: center;
  color: inherit;
  display: inline-flex;
  flex-direction: column;
  height: 24px;
  justify-content: center;
  width: 24px;
}
.reader-page .seek-arrow {
  fill: none;
  height: 17px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 17px;
}
.reader-page .seek-seconds {
  font:
    700 9px/1 "Segoe UI",
    sans-serif;
  margin-top: 1px;
}
.reader-page .segment-row {
  padding-block: 6px;
}
.reader-page .section-index {
  color: var(--reader-text);
}
.reader-page .section-bookmark-tab,
.reader-page .reader-tab {
  font-weight: 500;
}
.reader-page .section-status {
  color: var(--reader-muted);
}
.reader-page .segment-row[aria-current="true"] .section-status {
  color: var(--reader-primary);
}
.reader-page #progressRange {
  height: 32px;
  min-height: 32px;
  background: transparent;
  border: 0;
  opacity: 1;
}
/* WebKit insets the thumb's centre by half its own width at each end of
   the track (it can never overflow the track bounds), but a gradient
   percentage stop has no such inset - so a fill positioned from raw
   value/max alone drifts up to 9px (half of the 18px thumb below) away
   from the thumb's actual centre, worst at the two ends and exactly
   correct only at the midpoint. calc() corrects for that inset the same
   way the browser's own thumb-position algorithm does. If the thumb's
   width below ever changes, both the "18px" and "9px" here must change
   with it, or this drifts again.
*/
.reader-page #progressRange::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    var(--reader-primary) calc(9px + var(--reader-progress-ratio, 0) * (100% - 18px)),
    var(--reader-line-strong) calc(9px + var(--reader-progress-ratio, 0) * (100% - 18px))
  );
}
.reader-page #progressRange::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -6px;
  background: var(--reader-bg);
  border: 3px solid var(--reader-primary);
  box-shadow: 0 0 0 3px var(--reader-bg);
}
.reader-page #progressRange::-moz-range-track {
  height: 6px;
  background: var(--reader-line-strong);
  border-radius: 3px;
}
.reader-page #progressRange::-moz-range-progress {
  height: 6px;
  background: var(--reader-primary);
  border-radius: 3px;
}
.reader-page #progressRange::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--reader-bg);
  border: 3px solid var(--reader-primary);
  box-shadow: 0 0 0 3px var(--reader-bg);
}
.reader-page #progressRange:disabled {
  opacity: 0.5;
  cursor: default;
}
:root[data-theme="dark"] .reader-page {
  --reader-bg: #000;
}
.reader-page .reader-layout {
  width: 100%;
  max-width: 1600px;
  margin-inline: auto;
}
.reader-page .reader-cover,
.reader-page .reader-main-grid > .library-panel {
  display: none;
}
.reader-page .reader-player-shell,
.reader-page .reader-main-grid > .section-panel {
  display: block;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 12px 0;
}
.reader-page .reader-main-grid {
  grid-template-columns: minmax(0, 1fr);
}
.reader-page .player-main {
  gap: 24px;
}
.reader-page .reader-narration-controls {
  display: flex;
  align-items: end;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}
.reader-page .reader-narration-controls .player-voice-field {
  width: 260px;
  min-width: 0;
  max-width: 100%;
  margin: 0;
}
.reader-page .reader-narration-controls .player-voice-field span {
  font-size: 13px;
  font-weight: 500;
}
.reader-page .reader-narration-controls select {
  width: 100%;
  text-overflow: ellipsis;
}
.reader-page .reader-narration-controls .reader-generate-btn {
  min-height: 44px;
  margin: 0;
  border-radius: 4px;
  box-shadow: none;
}
.reader-page .reader-section-tabs {
  flex-wrap: wrap;
}
@media (max-width: 600px) {
  .reader-page .reader-narration-controls {
    width: 100%;
  }
  .reader-page .reader-narration-controls .player-voice-field {
    flex: 1 1 170px;
  }
  .reader-page .reader-narration-controls .reader-generate-btn {
    flex: 0 0 auto;
  }
}
.reader-page .selected-title {
  font-size: 28px;
  font-weight: 650;
  line-height: 1.3;
}
.reader-page .document-meta,
.reader-page .segment-title {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
}
.reader-page .playback-strip {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(440px, 1.7fr);
  grid-template-rows: auto auto auto auto auto;
  gap: 6px 24px;
  padding: 24px;
  border: 0;
  border-radius: 4px;
}
.reader-page .playback-strip > .reader-kicker {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
}
.reader-page .playback-strip-title {
  grid-column: 1;
  grid-row: 2;
  font-size: 22px;
  font-weight: 600;
}
.reader-page .playback-strip > .segment-title {
  grid-column: 1;
  grid-row: 3;
}
.reader-page .transport {
  grid-column: 2;
  grid-row: 1 / 4;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
}
.reader-page .transport-spacer {
  display: none;
}
.reader-page .transport-buttons {
  gap: 8px;
}
.reader-page .transport-extras {
  gap: 16px;
}
.reader-page .volume-field {
  display: flex;
  flex-direction: row;
  gap: 10px;
  width: 150px;
}
.reader-page #volumeRange {
  appearance: auto;
  accent-color: var(--reader-primary);
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  width: 110px;
  min-width: 0;
  height: 32px;
  min-height: 32px;
}
.reader-page .player-time-row {
  grid-column: 1 / -1;
  grid-row: 4;
  margin-top: 16px;
  font-weight: 400;
}
.reader-page .progress-field {
  grid-column: 1 / -1;
  grid-row: 5;
  margin: 0;
}
.reader-page .reader-play-btn {
  background: var(--reader-text);
  color: var(--reader-bg);
  box-shadow: none;
}
.reader-page .reader-icon-btn {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.reader-page .reader-icon-btn:hover:not(:disabled) {
  border-color: var(--reader-line-strong);
}
.reader-page .reader-icon-btn:active:not(:disabled) {
  background: var(--reader-primary-soft);
}
.reader-page .reader-play-btn:active:not(:disabled) {
  background: var(--reader-muted);
}
.reader-page .narration-options {
  border: 0;
  padding: 0;
  margin: 0;
}
.reader-page .narration-options > summary {
  padding: 12px 16px;
  border: 1px solid var(--reader-line-strong);
  border-radius: 4px;
}
.reader-page .section-bookmark-row {
  gap: 16px;
}
.reader-page .reader-panel:hover {
  box-shadow: none;
}
.reader-page :is(button, input, select, summary):focus-visible {
  outline: 2px solid var(--reader-focus);
  outline-offset: 3px;
}
@media (max-width: 1000px) {
  .reader-page .playback-strip {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .reader-page .transport {
    grid-column: 1;
    grid-row: 4;
    justify-content: space-between;
  }
  .reader-page .player-time-row {
    grid-row: 5;
  }
  .reader-page .progress-field {
    grid-row: 6;
  }
}
@media (max-width: 600px) {
  .reader-page .page-topbar {
    padding: 12px;
    gap: 12px;
  }
  .reader-page .reader-layout {
    padding: 20px 16px;
  }
  .reader-page .page-topbar-title-btn {
    font-size: 22px;
  }
  .reader-page .reader-layout :is(button, input, select, summary),
  .reader-page .page-topbar button {
    font-size: 14px;
  }
  .reader-page .segments-table-head,
  .reader-page .segment-row {
    grid-template-columns: 24px minmax(0, 1fr) 48px 36px;
    gap: 6px;
    padding: 10px 4px;
  }
  .reader-page .section-status {
    display: none;
  }
  .reader-page .segment-row .section-duration {
    grid-column: 3;
    grid-row: 1;
  }
  .reader-page .segment-row .section-play-btn {
    grid-column: 4;
  }
  .reader-page .section-title {
    font-size: 15px;
  }
  .reader-page .selected-title {
    font-size: 23px;
  }
  .reader-page .player-doc-head {
    flex-direction: column;
    gap: 12px;
  }
  .reader-page .player-head-actions {
    justify-content: flex-start;
    width: 100%;
  }
  .reader-page .player-head-actions .status-badge {
    width: auto;
  }
  .reader-page .playback-strip {
    padding: 16px;
  }
  .reader-page .transport {
    justify-content: center;
  }
  .reader-page .transport-buttons {
    gap: 6px;
  }
  .reader-page .transport-extras {
    justify-content: center;
    width: 100%;
  }
  .reader-page .playback-strip-title {
    font-size: 20px;
  }
  .reader-page .player-main {
    gap: 16px;
  }
}
