/* ==========================================================================
   Cadence Voice Reader — Editorial Mobile-First Design System
   Warm Paper / Sepia / OLED Night themes · Crafted for Pixel 11 Pro & Web
   ========================================================================== */

:root {
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --reader-font: var(--font-serif);
  --reader-size: 19px;
  --reader-line-height: 1.76;

  /* Paper Theme (Default) */
  --bg: #FAF7F2;
  --bg-elevated: #FFFFFF;
  --bg-subtle: #F1EBE1;
  --bg-dock: rgba(250, 247, 242, 0.92);
  --ink: #1C1917;
  --ink-secondary: #57514B;
  --ink-muted: #877F76;
  --border: rgba(28, 25, 23, 0.09);
  --border-strong: rgba(28, 25, 23, 0.16);
  --accent: #C25934;
  --accent-hover: #A94927;
  --accent-soft: rgba(194, 89, 52, 0.14);
  --accent-highlight: rgba(212, 114, 62, 0.20);
  --accent-on: #FFFFFF;
  --shadow-dock: 0 -8px 28px rgba(28, 25, 23, 0.08);
  --shadow-sheet: 0 -12px 40px rgba(28, 25, 23, 0.18);
  --ok-dot: #2F8F5B;
  --warn-dot: #C9822B;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --dock-height: 132px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

html[data-theme="sepia"] {
  --bg: #F3E9D2;
  --bg-elevated: #FAF3E3;
  --bg-subtle: #E7DAC0;
  --bg-dock: rgba(243, 233, 210, 0.94);
  --ink: #2C2218;
  --ink-secondary: #5E4E3D;
  --ink-muted: #8A7761;
  --border: rgba(44, 34, 24, 0.10);
  --border-strong: rgba(44, 34, 24, 0.18);
  --accent: #A8501E;
  --accent-hover: #8D4116;
  --accent-soft: rgba(168, 80, 30, 0.15);
  --accent-highlight: rgba(188, 102, 42, 0.22);
  --shadow-dock: 0 -8px 28px rgba(44, 34, 24, 0.10);
}

html[data-theme="night"] {
  --bg: #11100F;
  --bg-elevated: #1A1816;
  --bg-subtle: #24211E;
  --bg-dock: rgba(19, 18, 16, 0.94);
  --ink: #ECE7DF;
  --ink-secondary: #B4ABA0;
  --ink-muted: #7F776D;
  --border: rgba(236, 231, 223, 0.09);
  --border-strong: rgba(236, 231, 223, 0.17);
  --accent: #E07A4F;
  --accent-hover: #EC8D64;
  --accent-soft: rgba(224, 122, 79, 0.16);
  --accent-highlight: rgba(224, 122, 79, 0.24);
  --accent-on: #14110F;
  --shadow-dock: 0 -10px 32px rgba(0, 0, 0, 0.55);
  --shadow-sheet: 0 -16px 48px rgba(0, 0, 0, 0.72);
  --ok-dot: #4BB87E;
  --warn-dot: #E3A047;
}

html[data-font="sans"] {
  --reader-font: var(--font-sans);
  --reader-line-height: 1.72;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  transition: background-color 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
}

button,
input,
textarea {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

/* Top Reading Progress Hairline */
.progress-hairline {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 60;
  background: transparent;
  pointer-events: none;
}

.progress-hairline__fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: var(--bg-dock);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}

.topbar__left,
.topbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand__name {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.engine-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-subtle);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.engine-badge__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok-dot);
}

.engine-badge.is-fallback .engine-badge__dot {
  background: var(--warn-dot);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.icon-btn:hover {
  background: var(--bg-subtle);
}

.icon-btn:active {
  transform: scale(0.93);
}

.icon-btn--text {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 38px;
  padding: 0 14px 0 11px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-on);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.btn-add:hover {
  background: var(--accent-hover);
}

.btn-add:active {
  transform: scale(0.95);
}

/* Main Reader Canvas */
.reader-shell {
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  padding: 24px 20px calc(var(--dock-height) + var(--safe-bottom) + 44px);
}

.article__header {
  margin-bottom: 26px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.article__meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.source-tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  font-weight: 600;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-text {
  font-variant-numeric: tabular-nums;
}

.article__title {
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-size: clamp(1.65rem, 5.2vw, 2.3rem);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.article__subrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.article__author {
  font-size: 0.88rem;
  color: var(--ink-secondary);
  font-weight: 500;
}

.article__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--ink-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.chip-btn:hover {
  background: var(--bg-subtle);
  color: var(--ink);
}

.chip-btn:active {
  transform: scale(0.95);
}

.chip-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

/* Article Body & Interactive Sentences */
.article__body {
  font-family: var(--reader-font);
  font-size: var(--reader-size);
  line-height: var(--reader-line-height);
  color: var(--ink);
}

.reader-para {
  margin: 0 0 1.15em;
}

.reader-heading {
  margin: 1.6em 0 0.55em;
  font-family: var(--font-serif);
  font-size: 1.28em;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.sentence {
  border-radius: 6px;
  padding: 1px 2px;
  margin: 0 -1px;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.28s ease, color 0.2s ease;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.sentence:hover {
  background: var(--accent-soft);
}

.sentence.is-active {
  background: var(--accent-highlight);
  color: var(--ink);
}

/* Focus Dim Mode when actively playing */
body.focus-mode.is-playing .sentence {
  opacity: 0.34;
}

body.focus-mode.is-playing .sentence.is-active {
  opacity: 1;
}

/* End of Document Footer */
.article__footer {
  margin-top: 44px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.end-mark {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 10px;
}

.end-mark span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-muted);
  opacity: 0.5;
}

.end-label {
  margin: 0 0 16px;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.end-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Floating Re-center Pill */
.recenter-pill {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-height) + var(--safe-bottom) + 14px);
  transform: translateX(-50%);
  z-index: 42;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  transition: transform 0.15s ease, opacity 0.2s ease;
}

.recenter-pill:active {
  transform: translateX(-50%) scale(0.95);
}

/* Persistent Mobile Playback Dock */
.player-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  background: var(--bg-dock);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-dock);
  padding: 10px 14px calc(12px + var(--safe-bottom));
}

.player-dock__inner {
  max-width: 680px;
  margin: 0 auto;
}

.scrubber-wrap {
  margin-bottom: 8px;
}

.scrubber {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: var(--bg-subtle);
  outline: none;
  margin: 4px 0 6px;
  cursor: pointer;
}

.scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid var(--bg-elevated);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  transition: transform 0.12s ease;
}

.scrubber::-webkit-slider-thumb:active {
  transform: scale(1.22);
}

.scrubber::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid var(--bg-elevated);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
}

.scrubber-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.sleep-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Primary Thumb Controls Row */
.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.ctrl-pill {
  height: 38px;
  min-width: 54px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.ctrl-pill--voice {
  max-width: 90px;
}

.ctrl-pill--voice span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ctrl-pill:hover {
  background: var(--bg-subtle);
}

.ctrl-pill:active {
  transform: scale(0.94);
}

.ctrl-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.ctrl-btn:hover {
  background: var(--bg-subtle);
}

.ctrl-btn:active {
  transform: scale(0.9);
}

.ctrl-btn--skip .skip-num {
  position: absolute;
  font-size: 0.6rem;
  font-weight: 800;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -44%);
  letter-spacing: -0.04em;
  pointer-events: none;
}

.play-btn {
  position: relative;
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-on);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(194, 89, 52, 0.34);
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.play-btn:hover {
  background: var(--accent-hover);
}

.play-btn:active {
  transform: scale(0.93);
}

.play-btn__spinner {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  border-top-color: var(--accent);
  opacity: 0;
  pointer-events: none;
}

.play-btn.is-loading .play-btn__spinner {
  opacity: 1;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Backdrop & Overlays */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15, 13, 11, 0.48);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Bottom Sheets */
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  z-index: 80;
  background: var(--bg-elevated);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  box-shadow: var(--shadow-sheet);
  padding: 10px 20px calc(22px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  animation: slideUp 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideUp {
  from { transform: translate(-50%, 40px); opacity: 0.4; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.sheet__handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 0 auto 12px;
  flex-shrink: 0;
}

.sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.sheet-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sheet-subtitle {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.sheet__scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

/* Side Drawer (Library) */
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(88vw, 380px);
  z-index: 80;
  background: var(--bg-elevated);
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  animation: slideRight 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideRight {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer__footer {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}

.lib-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.lib-item.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.lib-item__info {
  min-width: 0;
  flex: 1;
}

.lib-item__title {
  margin: 0 0 4px;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lib-item__meta {
  font-size: 0.75rem;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lib-item__bar {
  margin-top: 8px;
  height: 3px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.lib-item__bar-fill {
  height: 100%;
  background: var(--accent);
}

.lib-item__del {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lib-item__del:hover {
  background: var(--bg-subtle);
  color: var(--ink);
}

/* Segmented Controls */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
  background: var(--bg-subtle);
  margin-bottom: 16px;
}

.segmented--inline {
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 0;
  width: 170px;
}

.segmented__tab {
  border: none;
  border-radius: 10px;
  padding: 9px 10px;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 0.84rem;
  font-weight: 600;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.segmented__tab.is-active {
  background: var(--bg-elevated);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Forms & Inputs */
.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.field-hint {
  margin: 8px 0 12px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ink-muted);
}

.input-row {
  display: flex;
  gap: 8px;
}

.text-input,
.text-area {
  width: 100%;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.95rem;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s ease;
}

.text-input:focus,
.text-area:focus {
  border-color: var(--accent);
}

.text-area {
  resize: vertical;
  min-height: 120px;
  line-height: 1.55;
}

.btn-paste-clip {
  flex-shrink: 0;
  padding: 0 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  background: var(--bg-subtle);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 600;
}

.btn-primary {
  border: none;
  border-radius: 13px;
  padding: 13px 18px;
  background: var(--accent);
  color: var(--accent-on);
  font-size: 0.94rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-secondary {
  border: 1.5px solid var(--border-strong);
  border-radius: 13px;
  padding: 12px 18px;
  background: var(--bg-elevated);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
}

.btn-full {
  width: 100%;
}

.quick-samples {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.quick-samples__label {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.sample-pill {
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--bg);
  color: var(--ink-secondary);
  font-size: 0.76rem;
  font-weight: 600;
}

.sample-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Dropzone */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 18px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone.is-dragover,
.dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone__icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--bg-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.dropzone__title {
  font-size: 0.98rem;
  margin-bottom: 4px;
}

.dropzone__sub {
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.sheet-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-subtle);
  font-size: 0.84rem;
  color: var(--ink-secondary);
  line-height: 1.45;
}

.sheet-status.is-error {
  background: rgba(200, 55, 45, 0.12);
  color: #B43228;
}

html[data-theme="night"] .sheet-status.is-error {
  color: #F28B82;
}

/* Speed Controls */
.speed-readout {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.speed-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.stepper-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stepper-btn:active {
  transform: scale(0.93);
}

.range-input {
  flex: 1;
  accent-color: var(--accent);
  height: 6px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.preset-grid--sleep {
  grid-template-columns: repeat(3, 1fr);
}

.preset-btn {
  padding: 10px 6px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: var(--bg);
  color: var(--ink-secondary);
  font-size: 0.84rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: all 0.15s ease;
}

.preset-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Voice Cards */
.section-block {
  margin-bottom: 22px;
}

.section-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-label {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.section-block__head .section-label {
  margin-bottom: 0;
}

.text-link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 2px;
}

.voice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 290px;
  overflow-y: auto;
}

.voice-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 13px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.voice-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.voice-card__main {
  min-width: 0;
  flex: 1;
}

.voice-card__top {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.voice-card__name {
  font-size: 0.94rem;
  font-weight: 700;
}

.voice-card__tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--ink-secondary);
}

.voice-card.is-selected .voice-card__tag {
  background: var(--accent);
  color: var(--accent-on);
}

.voice-card__sub {
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.voice-preview-btn {
  flex-shrink: 0;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.voice-preview-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Toggle Switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-row strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}

.toggle-row span {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-top: 2px;
}

.switch {
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::after {
  transform: translateX(18px);
}

/* Appearance Controls */
.theme-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.theme-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.theme-card.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-swatch {
  width: 100%;
  height: 44px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.theme-swatch--paper {
  background: #FAF7F2;
  color: #1C1917;
}

.theme-swatch--sepia {
  background: #F3E9D2;
  color: #2C2218;
}

.theme-swatch--night {
  background: #11100F;
  color: #ECE7DF;
  border-color: rgba(255, 255, 255, 0.14);
}

.appearance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.appearance-label {
  font-size: 0.9rem;
  font-weight: 600;
}

.font-stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.font-size-val {
  min-width: 44px;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  top: calc(68px + var(--safe-top));
  transform: translateX(-50%);
  z-index: 95;
  max-width: min(92vw, 420px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  text-align: center;
  animation: fadeIn 0.18s ease;
}

/* Desktop refinements */
@media (min-width: 720px) {
  .topbar {
    padding-left: 24px;
    padding-right: 24px;
  }

  .reader-shell {
    padding: 36px 28px calc(var(--dock-height) + 64px);
  }

  .controls-row {
    justify-content: center;
    gap: 16px;
  }
}
