/* ==========================================================================
   Lapatou Novel Read — Editorial Web Novel & Synchronized Audiobook UI
   Themes: dark (default) | oled | sepia | light
   ========================================================================== */

:root,
[data-theme="dark"] {
  --bg-canvas: #0d1117;
  --bg-surface: #151b24;
  --bg-elevated: #1c2431;
  --bg-hover: #232d3d;
  --bg-header: rgba(13, 17, 23, 0.88);
  --bg-dock: rgba(20, 26, 36, 0.96);
  --border-subtle: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.26);
  --text-primary: #e8edf5;
  --text-reading: #dfe6f0;
  --text-secondary: #98a6bd;
  --text-muted: #68778f;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-soft: rgba(245, 158, 11, 0.15);
  --audio-accent: #38bdf8;
  --audio-soft: rgba(56, 189, 248, 0.14);
  --success: #22c55e;
  --vtt-highlight-bg: rgba(245, 158, 11, 0.12);
  --vtt-highlight-border: #f59e0b;
  --litrpg-bg: rgba(56, 189, 248, 0.08);
  --litrpg-border: rgba(56, 189, 248, 0.35);
  --shadow-lg: 0 18px 42px rgba(0, 0, 0, 0.48);
  --shadow-card: 0 6px 20px rgba(0, 0, 0, 0.28);
}

[data-theme="oled"] {
  --bg-canvas: #000000;
  --bg-surface: #0a0c10;
  --bg-elevated: #12151c;
  --bg-hover: #1a1f29;
  --bg-header: rgba(0, 0, 0, 0.92);
  --bg-dock: rgba(8, 10, 14, 0.98);
  --border-subtle: rgba(255, 255, 255, 0.11);
  --border-strong: rgba(255, 255, 255, 0.22);
  --text-primary: #e6e8ec;
  --text-reading: #d8dce3;
  --text-secondary: #8d96a5;
  --text-muted: #5d6573;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-soft: rgba(245, 158, 11, 0.16);
  --audio-accent: #38bdf8;
  --audio-soft: rgba(56, 189, 248, 0.15);
  --success: #22c55e;
  --vtt-highlight-bg: rgba(245, 158, 11, 0.15);
  --vtt-highlight-border: #fbbf24;
  --litrpg-bg: rgba(56, 189, 248, 0.09);
  --litrpg-border: rgba(56, 189, 248, 0.38);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.85);
  --shadow-card: 0 6px 20px rgba(0, 0, 0, 0.65);
}

[data-theme="sepia"] {
  --bg-canvas: #f5ecd9;
  --bg-surface: #ede1c8;
  --bg-elevated: #e5d6b7;
  --bg-hover: #dccaa5;
  --bg-header: rgba(245, 236, 217, 0.92);
  --bg-dock: rgba(237, 225, 200, 0.97);
  --border-subtle: rgba(92, 68, 40, 0.16);
  --border-strong: rgba(92, 68, 40, 0.28);
  --text-primary: #2a2015;
  --text-reading: #2f2418;
  --text-secondary: #5e4b36;
  --text-muted: #826d54;
  --accent: #b45309;
  --accent-hover: #92400e;
  --accent-soft: rgba(180, 83, 9, 0.13);
  --audio-accent: #0369a1;
  --audio-soft: rgba(3, 105, 161, 0.12);
  --success: #15803d;
  --vtt-highlight-bg: rgba(180, 83, 9, 0.13);
  --vtt-highlight-border: #b45309;
  --litrpg-bg: rgba(3, 105, 161, 0.08);
  --litrpg-border: rgba(3, 105, 161, 0.34);
  --shadow-lg: 0 18px 38px rgba(58, 40, 18, 0.18);
  --shadow-card: 0 4px 14px rgba(58, 40, 18, 0.1);
}

[data-theme="light"] {
  --bg-canvas: #f8fafc;
  --bg-surface: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-hover: #e2e8f0;
  --bg-header: rgba(248, 250, 252, 0.9);
  --bg-dock: rgba(255, 255, 255, 0.97);
  --border-subtle: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.2);
  --text-primary: #0f172a;
  --text-reading: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent: #d97706;
  --accent-hover: #b45309;
  --accent-soft: rgba(217, 119, 6, 0.11);
  --audio-accent: #0284c7;
  --audio-soft: rgba(2, 132, 199, 0.11);
  --success: #16a34a;
  --vtt-highlight-bg: rgba(217, 119, 6, 0.12);
  --vtt-highlight-border: #d97706;
  --litrpg-bg: rgba(2, 132, 199, 0.07);
  --litrpg-border: rgba(2, 132, 199, 0.32);
  --shadow-lg: 0 18px 38px rgba(15, 23, 42, 0.12);
  --shadow-card: 0 4px 16px rgba(15, 23, 42, 0.06);
}

/* Reader Typography Variables (Controlled by Appearance Panel) */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --reader-font-family: var(--font-serif);
  --reader-font-size: 19px;
  --reader-line-height: 1.8;
  --reader-para-gap: 1.15em;
  --reader-max-width: 740px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
}

body.has-audio-dock {
  padding-bottom: 122px;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Top Scroll Progress Bar
   ========================================================================== */
.scroll-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 95;
  background: transparent;
  pointer-events: none;
}

.scroll-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--audio-accent));
  transition: width 0.1s linear;
}

/* ==========================================================================
   Site Header
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 80;
  background: var(--bg-header);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0.7rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.brand-logo {
  border-radius: 8px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  font-weight: 700;
  font-size: 1.04rem;
  letter-spacing: -0.015em;
}

.brand-subtitle {
  font-size: 0.71rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-search-wrap {
  flex: 1;
  max-width: 460px;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.8rem;
  color: var(--text-muted);
  pointer-events: none;
}

.header-search-input {
  width: 100%;
  padding: 0.52rem 2.1rem 0.52rem 2.35rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.header-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-clear-btn {
  position: absolute;
  right: 0.55rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.icon-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.46rem 0.82rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 0.84rem;
  font-weight: 600;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.icon-pill-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.icon-pill-btn.primary-subtle {
  border-color: rgba(245, 158, 11, 0.35);
  background: var(--accent-soft);
}

.count-pill {
  background: var(--accent);
  color: #0b0e14;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.05rem 0.42rem;
  border-radius: 999px;
}

/* ==========================================================================
   Main Container & Footer
   ========================================================================== */
.app-main {
  flex: 1;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.4rem 1.15rem 3rem;
}

.app-main:focus {
  outline: none;
}

.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 1.4rem 1.15rem;
  color: var(--text-muted);
  font-size: 0.83rem;
}

.footer-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.6rem;
}

/* ==========================================================================
   Home Catalog, Hero Banner & Continue Shelf
   ========================================================================== */
.catalog-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.5rem;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-elevated));
  border: 1px solid var(--border-subtle);
}

.catalog-hero-title {
  margin: 0 0 0.25rem;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.catalog-hero-sub {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.hero-stats-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.stat-chip {
  padding: 0.4rem 0.8rem;
  border-radius: 10px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.stat-chip strong {
  color: var(--text-primary);
  margin-right: 0.2rem;
}

.stat-chip.audio-chip strong {
  color: var(--audio-accent);
}

/* Continue Reading & Listening Shelf */
.continue-section {
  margin-bottom: 1.9rem;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

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

.continue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.9rem;
}

.continue-card {
  position: relative;
  display: flex;
  gap: 0.85rem;
  padding: 0.85rem;
  border-radius: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.continue-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.continue-cover-wrap {
  width: 60px;
  height: 86px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-elevated);
}

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

.continue-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.continue-novel-title {
  font-weight: 700;
  font-size: 0.93rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.continue-chap-label {
  font-size: 0.81rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.15rem;
}

.continue-bar-wrap {
  margin-top: 0.45rem;
  height: 5px;
  border-radius: 999px;
  background: var(--bg-elevated);
  overflow: hidden;
}

.continue-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.continue-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  gap: 0.5rem;
}

.resume-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #0b0e14;
  font-size: 0.78rem;
  font-weight: 700;
}

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

.continue-meta-tag {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.continue-remove-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.45rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
}

.continue-remove-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* Catalog Filter & Sort Controls */
.catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.filter-pill {
  padding: 0.44rem 0.88rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.filter-pill:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.filter-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0e14;
}

.toolbar-selects {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.styled-select {
  padding: 0.44rem 0.78rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 600;
}

/* Novel Cards Grid */
.novels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
  gap: 1.15rem;
}

.novel-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 15px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.novel-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
}

.novel-card-top {
  display: flex;
  gap: 0.9rem;
  padding: 0.95rem;
}

.cover-box {
  position: relative;
  width: 92px;
  height: 134px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

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

.fallback-cover {
  width: 100%;
  height: 100%;
  padding: 0.55rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(155deg, #1e293b 0%, #0f172a 60%, #291d0e 100%);
  color: #f8fafc;
  text-align: left;
}

.fallback-cover-tag {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fbbf24;
  font-weight: 700;
}

.fallback-cover-title {
  font-family: var(--font-serif);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.22;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.novel-card-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.status-pill {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.14rem 0.48rem;
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.status-pill.completed {
  color: var(--success);
}

.bookmark-icon-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0.18rem;
  font-size: 1.05rem;
  line-height: 1;
  transition: color 0.15s ease, transform 0.15s ease;
}

.bookmark-icon-btn:hover,
.bookmark-icon-btn.active {
  color: var(--accent);
  transform: scale(1.1);
}

.novel-card-title {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.28;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.novel-card-title a:hover {
  color: var(--accent);
}

.novel-card-author {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.48rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.novel-card-synopsis {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.42;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.novel-card-footer {
  margin-top: auto;
  padding: 0.65rem 0.95rem;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.badge-group {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  flex-wrap: wrap;
}

.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.52rem;
  border-radius: 7px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.meta-badge.audio-ready {
  color: var(--audio-accent);
  border-color: rgba(56, 189, 248, 0.3);
  background: var(--audio-soft);
}

/* ==========================================================================
   Novel Overview Page
   ========================================================================== */
.breadcrumb-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 1.1rem;
}

.breadcrumb-bar a:hover {
  color: var(--accent);
}

.novel-overview-card {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 1.75rem;
  padding: 1.6rem;
  border-radius: 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  margin-bottom: 1.75rem;
}

.overview-cover-wrap {
  width: 210px;
  height: 305px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-card);
}

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

.overview-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.overview-title {
  margin: 0.35rem 0 0.3rem;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.02em;
}

.overview-author {
  font-size: 0.96rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.overview-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.15rem;
}

.metric-box {
  padding: 0.68rem 0.85rem;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.metric-value {
  display: block;
  font-size: 1.12rem;
  font-weight: 800;
}

.metric-value.audio-highlight {
  color: var(--audio-accent);
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.synopsis-block {
  margin-bottom: 1.25rem;
}

.synopsis-text {
  margin: 0;
  color: var(--text-reading);
  font-size: 0.95rem;
  line-height: 1.65;
  white-space: pre-line;
}

.synopsis-text.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-link-btn {
  margin-top: 0.35rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 600;
}

.overview-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: auto;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.48rem;
  padding: 0.68rem 1.25rem;
  border-radius: 11px;
  border: none;
  background: var(--accent);
  color: #0b0e14;
  font-weight: 700;
  font-size: 0.92rem;
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.66rem 1.1rem;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.9rem;
}

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

.btn-secondary.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* Chapter Directory */
.chapter-dir-section {
  padding: 1.4rem;
  border-radius: 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.chapter-dir-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.chapter-dir-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.chapter-search-input {
  padding: 0.46rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-canvas);
  min-width: 220px;
  font-size: 0.86rem;
}

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

.range-tabs-scroller {
  display: flex;
  gap: 0.42rem;
  overflow-x: auto;
  padding-bottom: 0.65rem;
  margin-bottom: 0.95rem;
  border-bottom: 1px solid var(--border-subtle);
  scrollbar-width: thin;
}

.range-tab-btn {
  flex-shrink: 0;
  padding: 0.36rem 0.72rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
}

.range-tab-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.range-tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0e14;
}

.chapter-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 0.55rem;
}

.chapter-row-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.68rem 0.85rem;
  border-radius: 10px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.chapter-row-link:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.chapter-row-link.is-read {
  opacity: 0.72;
}

.chapter-row-link.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
  opacity: 1;
}

.chapter-row-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.chapter-rank-num {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 2.3rem;
}

.chapter-row-title {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-row-right {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  flex-shrink: 0;
}

.chap-audio-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.14rem 0.45rem;
  border-radius: 6px;
  background: var(--audio-soft);
  color: var(--audio-accent);
}

.chap-read-mark {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--success);
}

.pagination-bar {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
}

/* ==========================================================================
   Distraction-Free Reader View
   ========================================================================== */
.reader-shell {
  max-width: var(--reader-max-width);
  margin: 0 auto;
}

.reader-top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.65rem 0.9rem;
  margin-bottom: 1.5rem;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.reader-novel-back {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-toolbar-btns {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.reader-header {
  margin-bottom: 1.8rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.reader-chapter-title {
  margin: 0 0 0.65rem;
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.reader-submeta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.83rem;
  color: var(--text-muted);
}

.quiet-pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.26rem 0.72rem;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.79rem;
  font-weight: 600;
}

.quiet-pill-badge.audio-active {
  background: var(--audio-soft);
  border-color: rgba(56, 189, 248, 0.32);
  color: var(--audio-accent);
}

.reader-content {
  font-family: var(--reader-font-family);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--text-reading);
  word-wrap: break-word;
}

.reader-para {
  position: relative;
  margin: 0 0 var(--reader-para-gap);
  padding: 0.28rem 0.65rem;
  margin-left: -0.65rem;
  margin-right: -0.65rem;
  border-left: 3px solid transparent;
  border-radius: 0 8px 8px 0;
  transition: background-color 0.22s ease, border-color 0.22s ease;
}

.reader-para.litrpg-prompt {
  background: var(--litrpg-bg);
  border-left-color: var(--litrpg-border);
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.93em;
}

.reader-para.vtt-active {
  background: var(--vtt-highlight-bg);
  border-left-color: var(--vtt-highlight-border);
}

.para-seek-btn {
  position: absolute;
  left: -2.05rem;
  top: 0.38rem;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--audio-accent);
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.reader-para:hover .para-seek-btn,
.reader-para.vtt-active .para-seek-btn,
.para-seek-btn:focus {
  opacity: 1;
}

.para-seek-btn:hover {
  transform: scale(1.1);
  border-color: var(--audio-accent);
}

.reader-bottom-nav {
  margin-top: 2.6rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: center;
}

.nav-card-btn {
  display: flex;
  flex-direction: column;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: border-color 0.15s ease, background-color 0.15s ease;
  min-width: 0;
}

.nav-card-btn:hover:not(.disabled) {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.nav-card-btn.next {
  text-align: right;
}

.nav-card-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.nav-dir-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
}

.nav-chap-name {
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shortcut-hint {
  margin-top: 1.1rem;
  text-align: center;
  font-size: 0.77rem;
  color: var(--text-muted);
}

kbd {
  padding: 0.1rem 0.38rem;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  font-family: var(--font-mono);
  font-size: 0.73rem;
}

/* ==========================================================================
   Sticky Synchronized Audiobook Player Dock
   ========================================================================== */
.audio-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  background: var(--bg-dock);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  padding: 0.55rem 1.1rem 0.7rem;
}

.audio-scrub-row {
  max-width: 1280px;
  margin: 0 auto 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.audio-time {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  min-width: 44px;
  text-align: center;
}

.audio-progress-track {
  position: relative;
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: var(--bg-elevated);
  overflow: visible;
}

.audio-buffered-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.28);
  pointer-events: none;
}

.audio-played-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--audio-accent));
  pointer-events: none;
}

.audio-seek-slider {
  position: absolute;
  inset: -6px 0;
  width: 100%;
  height: 19px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.audio-controls-row {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}

.audio-track-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
}

.audio-cover-thumb {
  width: 38px;
  height: 50px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.audio-track-labels {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.audio-chapter-title {
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-chapter-title:hover {
  color: var(--accent);
}

.audio-novel-subtitle {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-transport-controls {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  flex-shrink: 0;
}

.audio-btn {
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  height: 36px;
  min-width: 36px;
  padding: 0 0.5rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.audio-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.audio-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.skip-label {
  font-size: 0.74rem;
  font-weight: 700;
}

.audio-play-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #0b0e14;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}

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

.audio-extra-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  flex: 1;
  flex-wrap: wrap;
}

.audio-pill-btn {
  padding: 0.32rem 0.62rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
}

.audio-pill-btn.active {
  border-color: rgba(56, 189, 248, 0.45);
  background: var(--audio-soft);
  color: var(--audio-accent);
}

.audio-close-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.3rem;
  line-height: 1;
  padding: 0.2rem 0.4rem;
}

.sleep-dropdown-wrap {
  position: relative;
}

.sleep-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 148px;
  padding: 0.35rem;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sleep-menu button {
  text-align: left;
  padding: 0.42rem 0.68rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 600;
}

.sleep-menu button:hover,
.sleep-menu button.selected {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ==========================================================================
   Slide-Over Drawer & Appearance Panel
   ========================================================================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}

.library-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(430px, 94vw);
  z-index: 110;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.drawer-header,
.appearance-header {
  padding: 1.05rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-title {
  margin: 0;
  font-size: 1.15rem;
}

.drawer-subtitle {
  margin: 0.1rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.icon-close-btn {
  border: none;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.25rem;
  line-height: 1;
}

.drawer-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 0.75rem;
}

.drawer-tab {
  padding: 0.72rem 0.4rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.83rem;
  font-weight: 700;
}

.drawer-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 1.2rem;
}

.drawer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 12px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  margin-bottom: 0.65rem;
}

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

.drawer-item-title {
  font-weight: 700;
  font-size: 0.9rem;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-item-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
  margin-top: 0.15rem;
}

.backup-card {
  padding: 1rem;
  border-radius: 12px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  margin-bottom: 1rem;
}

.backup-card h4 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}

.backup-card p {
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* Appearance Modal */
.appearance-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  z-index: 115;
  border-radius: 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
}

.appearance-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.appearance-body {
  padding: 1.1rem 1.25rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.setting-group-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.48rem;
}

.segmented-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(85px, 1fr));
  gap: 0.45rem;
}

.seg-btn {
  padding: 0.5rem 0.55rem;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-canvas);
  font-size: 0.82rem;
  font-weight: 600;
}

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

.slider-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

/* Loading, Empty & Toast States */
.loading-state,
.empty-state {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--text-secondary);
}

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 0.85rem;
  border-radius: 50%;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
}

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

.toast-container {
  position: fixed;
  bottom: 130px;
  right: 1.15rem;
  z-index: 130;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.62rem 1rem;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   Responsive Mobile Breakpoints
   ========================================================================== */
@media (max-width: 820px) {
  .header-inner {
    flex-wrap: wrap;
    padding: 0.6rem 0.85rem;
    gap: 0.6rem;
  }

  .header-search-wrap {
    order: 3;
    max-width: 100%;
    flex-basis: 100%;
  }

  .btn-label-desktop {
    display: none;
  }

  .novel-overview-card {
    grid-template-columns: 1fr;
    padding: 1.15rem;
    text-align: center;
  }

  .overview-cover-wrap {
    margin: 0 auto;
    width: 165px;
    height: 242px;
  }

  .overview-cta-row {
    justify-content: center;
  }

  .overview-details {
    text-align: left;
  }

  .overview-title,
  .overview-author {
    text-align: center;
  }

  .para-seek-btn {
    position: static;
    opacity: 0.85;
    width: 22px;
    height: 22px;
    margin-right: 0.45rem;
    vertical-align: middle;
  }

  .reader-bottom-nav {
    grid-template-columns: 1fr;
  }

  .nav-card-btn.next {
    text-align: left;
  }

  .audio-controls-row {
    flex-wrap: wrap;
    gap: 0.55rem;
  }

  .audio-track-meta {
    flex-basis: 100%;
  }

  .audio-transport-controls {
    margin: 0 auto;
  }

  .audio-extra-controls {
    flex-basis: 100%;
    justify-content: center;
  }

  body.has-audio-dock {
    padding-bottom: 185px;
  }
}
