/* ==========================================================================
   Truyện Lười — Production Design System (styles.css)
   - Wrapped Category Grid (Zero horizontal clipping!)
   - Sticky Reader Top Chapter Bar (`<` | Chương X | `>`)
   - Symmetric Bottom Player Dock (`[Giọng]` | CENTER `< ▶ >` | `[Tốc độ]`)
   ========================================================================== */

:root,
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --surface-glass: rgba(255, 255, 255, 0.95);
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --accent: #d97706;
  --accent-hover: #b45309;
  --accent-soft: rgba(217, 119, 6, 0.12);
  --accent-border: rgba(217, 119, 6, 0.35);
  --accent-contrast: #ffffff;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);
  --cover-placeholder: #e2e8f0;
  --sentence-hover: rgba(15, 23, 42, 0.04);
  --sentence-active-bg: rgba(217, 119, 6, 0.14);
  --sentence-active-text: #0f172a;
  --skeleton-base: #e2e8f0;
  --skeleton-highlight: #f1f5f9;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f17;
  --bg-elevated: #111827;
  --surface: #151d2c;
  --surface-2: #1e293b;
  --surface-3: #334155;
  --surface-glass: rgba(21, 29, 44, 0.96);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --muted: #94a3b8;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-soft: rgba(245, 158, 11, 0.15);
  --accent-border: rgba(245, 158, 11, 0.38);
  --accent-contrast: #0f172a;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.65);
  --cover-placeholder: #1e293b;
  --sentence-hover: rgba(255, 255, 255, 0.04);
  --sentence-active-bg: rgba(245, 158, 11, 0.18);
  --sentence-active-text: #ffffff;
  --skeleton-base: #1e293b;
  --skeleton-highlight: #293548;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0f17;
    --bg-elevated: #111827;
    --surface: #151d2c;
    --surface-2: #1e293b;
    --surface-3: #334155;
    --surface-glass: rgba(21, 29, 44, 0.96);
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #f8fafc;
    --text-secondary: #cbd5e1;
    --muted: #94a3b8;
    --accent: #f59e0b;
    --accent-hover: #fbbf24;
    --accent-soft: rgba(245, 158, 11, 0.15);
    --accent-border: rgba(245, 158, 11, 0.38);
    --accent-contrast: #0f172a;
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.15);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.65);
    --cover-placeholder: #1e293b;
    --sentence-hover: rgba(255, 255, 255, 0.04);
    --sentence-active-bg: rgba(245, 158, 11, 0.18);
    --sentence-active-text: #ffffff;
    --skeleton-base: #1e293b;
    --skeleton-highlight: #293548;
  }
}

:root {
  --safe-top: 0px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --reader-font-size: 18px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   1. Offline & Toast Banners
   ========================================================================== */
.offline-banner {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--danger);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  text-align: center;
  z-index: 100;
  flex-shrink: 0;
}

.offline-banner.visible {
  display: flex;
}

.toast-container {
  position: fixed;
  top: calc(var(--safe-top) + 52px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(90vw, 380px);
  pointer-events: none;
}

.toast-msg {
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: fadeSlideDown 0.18s ease-out;
}

.toast-msg.error {
  background: var(--danger);
  color: #ffffff;
}

.toast-msg.success {
  background: var(--accent);
  color: var(--accent-contrast);
}

@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   2. Minimal App Top Header (Clean, No Clutter)
   ========================================================================== */
.app-top-nav {
  padding: 6px max(12px, var(--safe-right)) 6px max(12px, var(--safe-left));
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 30;
  flex-shrink: 0;
}

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

.brand-logo {
  height: 30px;
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ptd-logo-img {
  height: 22px;
  width: auto;
  object-fit: contain;
  display: block;
}

.app-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text);
}

.header-db-badge {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

/* ==========================================================================
   3. Main Scrollable Viewport
   ========================================================================== */
.app-main {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-view {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px max(12px, var(--safe-right)) 24px max(12px, var(--safe-left));
  display: none;
  -webkit-overflow-scrolling: touch;
}

.tab-view.reader-view-pad {
  padding-top: 0;
}

.tab-view.active {
  display: block;
}

.tab-container {
  max-width: 920px;
  margin: 0 auto;
}

/* ==========================================================================
   4. Search Bar & Wrapped Category Grid (100% Visible, Never Cut Off!)
   ========================================================================== */
.search-bar-wrap {
  position: relative;
  margin-bottom: 10px;
}

.search-input {
  width: 100%;
  min-height: 40px;
  padding: 8px 36px 8px 38px;
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 13.5px;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-clear-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.search-clear-btn.visible {
  display: inline-flex;
}

/* Wrapped Category Grid — All pills wrap cleanly onto rows, ZERO clipping! */
.cat-wrap-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.cat-pill {
  min-height: 32px;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s ease;
}

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

.cat-pill.active {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  font-weight: 700;
}

/* ==========================================================================
   5. Hot Stories Spotlight & Book Catalog Grid
   ========================================================================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 14px 0 8px;
}

.section-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}

.section-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.hot-books-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

@media (min-width: 640px) {
  .hot-books-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.hot-mini-card {
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  box-shadow: var(--shadow-sm);
}

.hot-mini-card:hover {
  border-color: var(--accent);
}

.hot-mini-cover {
  width: 42px;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--cover-placeholder);
}

.hot-mini-info {
  flex: 1;
  min-width: 0;
}

.hot-mini-cat {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
}

.hot-mini-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.25;
}

.hot-mini-chaps {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (min-width: 600px) {
  .book-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 860px) {
  .book-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.book-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  text-align: left;
  padding: 0;
  color: inherit;
}

.book-card:hover {
  border-color: var(--accent-border);
}

.cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--cover-placeholder);
  overflow: hidden;
  flex-shrink: 0;
}

.cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  text-align: center;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.cover-badge-top {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(15, 23, 42, 0.82);
  color: #f8fafc;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.cover-fav-indicator {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.82);
  color: var(--accent);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cover-badge-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 18px 8px 5px;
  background: linear-gradient(to top, rgba(11, 15, 23, 0.92), transparent);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
  font-weight: 600;
  color: #e2e8f0;
}

.book-meta {
  padding: 8px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 3px;
}

.book-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}

.book-author {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Continue Listening Banner */
.continue-card {
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.continue-cover {
  width: 40px;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.continue-info {
  flex: 1;
  min-width: 0;
}

.continue-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
}

.continue-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.continue-meta {
  font-size: 11.5px;
  color: var(--muted);
}

/* ==========================================================================
   6. Tab 2: Reader with STICKY `< Chương >` Header Bar
   ========================================================================== */
.reader-sticky-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  margin: 0 -12px 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.nav-arrow-btn {
  width: 38px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-size: 16px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.nav-arrow-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.nav-arrow-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sticky-chap-picker {
  flex: 1;
  min-width: 0;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
}

.sticky-chap-picker:hover {
  border-color: var(--accent);
}

.sticky-chap-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sticky-chap-caret {
  color: var(--accent);
  flex-shrink: 0;
}

.reader-compact-meta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.reader-cover-mini {
  width: 40px;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.reader-book-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}

.reader-chap-title {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text);
  margin: 1px 0 3px;
  line-height: 1.3;
}

.reader-progress-line {
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sentences-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}

.sentence {
  display: block;
  padding: 8px 12px;
  margin: 3px 0;
  border-radius: var(--radius-sm);
  font-size: var(--reader-font-size);
  line-height: 1.75;
  color: var(--text-secondary);
  cursor: pointer;
  border-left: 3px solid transparent;
  word-break: break-word;
}

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

.sentence.active {
  background: var(--sentence-active-bg);
  color: var(--sentence-active-text);
  font-weight: 600;
  border-left-color: var(--accent);
}

.chapter-nav-footer {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.chapter-nav-footer button {
  flex: 1;
}

.floating-follow-btn {
  position: fixed;
  right: 16px;
  bottom: 175px;
  z-index: 60;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: var(--radius-full);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
}

/* ==========================================================================
   7. Symmetric Bottom Audio Player Dock (`[Giọng]` | CENTER `< ▶ >` | `[Tốc độ]`)
   ========================================================================== */
.audio-dock {
  flex-shrink: 0;
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 6px max(12px, var(--safe-right)) 6px max(12px, var(--safe-left));
  z-index: 35;
}

.dock-now-playing-strip {
  max-width: 920px;
  margin: 0 auto 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.mini-strip-cover {
  width: 24px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.mini-strip-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mini-strip-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-strip-sub {
  font-size: 10.5px;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-strip-open {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.speed-control-strip {
  max-width: 920px;
  margin: 0 auto 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.speed-control-strip.collapsed {
  display: none;
}

.speed-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.speed-close-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.speed-label {
  font-size: 11.5px;
  color: var(--text-secondary);
  min-width: 82px;
}

.speed-label strong {
  color: var(--accent);
  font-weight: 800;
}

.speed-slider {
  flex: 1;
  height: 5px;
  accent-color: var(--accent);
  cursor: pointer;
}

.speed-presets-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.speed-chip {
  flex: 1;
  min-height: 24px;
  padding: 0 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.speed-chip.active {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  font-weight: 700;
}

/* 3-Column Grid ensuring `< [Play] >` is strictly CENTERED in the dock! */
.dock-symmetric-row {
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.dock-side-left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
}

.dock-center-transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.dock-side-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.dock-select {
  width: 100%;
  max-width: 135px;
  min-height: 36px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  text-overflow: ellipsis;
}

.dock-speed-btn {
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--accent);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-family: inherit;
}

.btn-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

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

.btn-main-play {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: var(--shadow-sm);
}

.btn-main-play.playing {
  background: var(--text);
  color: var(--bg);
}

/* ==========================================================================
   8. Tab 3: Compact Voices List & Tab 4: Settings / Account
   ========================================================================== */
.voices-top-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-voice-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.voice-row-compact {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.voice-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.voice-radio-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.voice-row-compact.selected .voice-radio-dot {
  border-color: var(--accent);
}

.voice-row-compact.selected .voice-radio-dot::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

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

.voice-row-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.voice-row-desc {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-voice-mini {
  min-height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-voice-mini.primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  font-weight: 700;
}

.btn-voice-mini.danger {
  color: var(--danger);
}

/* Account & Settings */
.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 12px;
}

.panel-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 4px;
}

.panel-desc {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 10px;
}

.setting-block {
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

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

.setting-label-col {
  flex: 1;
  min-width: 0;
}

.setting-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.setting-sub {
  font-size: 11px;
  color: var(--muted);
}

.ios-switch {
  width: 42px;
  height: 22px;
  accent-color: var(--accent);
  cursor: pointer;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.tool-btn {
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.segmented-control.two-cols {
  grid-template-columns: repeat(2, 1fr);
}

.seg-btn {
  min-height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
}

.oauth-btn-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.btn-oauth {
  width: 100%;
  min-height: 40px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.btn-oauth.apple {
  background: var(--text);
  color: var(--bg);
  border: 1px solid var(--text);
}

.btn-oauth.google {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  margin: 10px 0;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.auth-divider span {
  padding: 0 10px;
}

.btn-primary {
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-secondary {
  min-height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-danger {
  min-height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.3);
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn {
  min-height: 34px;
  min-width: 34px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.form-group {
  margin-bottom: 10px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-input,
.form-textarea {
  width: 100%;
  min-height: 38px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 7px 11px;
  font-size: 13px;
  font-family: inherit;
}

.consent-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  margin-bottom: 10px;
}

.consent-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.recorder-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

.btn-record {
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.35);
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.status-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-secondary);
}

.status-badge.processing {
  background: var(--accent-soft);
  color: var(--accent);
}

.list-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  cursor: pointer;
}

.list-thumb {
  width: 36px;
  aspect-ratio: 3 / 4;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
}

.list-info {
  flex: 1;
  min-width: 0;
}

.list-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-meta {
  font-size: 11px;
  color: var(--muted);
}

/* ==========================================================================
   9. Bottom Tab Bar & Modals
   ========================================================================== */
.ios-tab-bar {
  flex-shrink: 0;
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding-top: 4px;
  padding-bottom: max(5px, var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 40;
}

.tab-btn {
  min-height: 44px;
  background: none;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 2px;
}

.tab-btn svg {
  width: 19px;
  height: 19px;
  stroke-width: 2;
}

.tab-btn.active {
  color: var(--accent);
  font-weight: 700;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 80;
}

.sheet-backdrop.open {
  display: flex;
}

.sheet-card {
  width: 100%;
  max-width: 640px;
  max-height: 86dvh;
  background: var(--surface);
  color: var(--text);
  border-top: 1px solid var(--border-strong);
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(20px + var(--safe-bottom));
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.sheet-book-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.sheet-cover {
  width: 72px;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
}

.fast-jump-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
}

.chap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.chap-btn {
  min-height: 34px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chap-btn:hover,
.chap-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}

.state-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 14px;
  text-align: center;
  margin: 10px 0;
}

.state-box-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  margin: 4px 0;
}

.state-box-desc {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 10px;
}
