/* ── Liseuse — thème sombre moderne ── */

:root {
  --bg: #0d0f12;
  --bg-elevated: #141820;
  --surface: #1a1f28;
  --surface-hover: #222833;
  --surface-raised: #252b36;
  --border: #2e3644;
  --border-subtle: #232933;
  --text: #e8ecf1;
  --text-muted: #8b95a5;
  --text-dim: #5c6573;
  --accent: #5b8def;
  --accent-hover: #7aa3f5;
  --accent-soft: rgba(91, 141, 239, 0.14);
  --accent-glow: rgba(91, 141, 239, 0.25);
  --success: #34d399;
  --danger: #f87171;
  --fav: #d4a72c;
  --fav-soft: rgba(212, 167, 44, 0.14);
  --sidebar-w: 248px;
  --reader-bar-h: 52px;
  --reader-footer-h: 56px;
  --reader-chrome-top: calc(var(--reader-bar-h) + env(safe-area-inset-top, 0px));
  --reader-chrome-bottom: calc(var(--reader-footer-h) + env(safe-area-inset-bottom, 0px));
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.45);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

html.reader-mobile-lock,
html.reader-mobile-lock body {
  overflow: hidden;
  height: 100%;
  overscroll-behavior: none;
}

#app {
  display: flex;
  width: 100%;
  max-width: 100vw;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

#app.reader-mode .sidebar {
  display: none;
}

#app.reader-mode .main-shell {
  width: 100%;
}

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  position: sticky;
  top: 0;
  height: 100dvh;
  max-height: 100dvh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.brand-icon {
  font-size: 1.75rem;
}

.brand-name {
  display: block;
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.brand-tagline {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.5rem 0.75rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
  box-shadow: inset 0 0 0 1px rgba(91, 141, 239, 0.2);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.online-status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

/* ── Main shell ──────────────────────────────────────────── */

.main-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
}

.main-shell.hide-bottom-nav .bottom-nav {
  display: none;
}

.views-container {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.view {
  display: none;
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.view.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

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

/* ── Top bar ─────────────────────────────────────────────── */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 0.75rem;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-bar h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.top-bar.simple {
  padding-bottom: 0;
}

.library-top-bar {
  gap: 0.5rem;
}

.library-top-bar h1 {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-menu-btn {
  flex-shrink: 0;
  margin-left: -0.25rem;
}

/* ── Library drawer ──────────────────────────────────────── */

.library-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(5, 7, 10, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.28s ease;
}

.library-drawer-backdrop.visible {
  opacity: 1;
}

.library-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 45;
  width: min(300px, 88vw);
  display: flex;
  flex-direction: column;
  background: rgba(16, 20, 28, 0.92);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    1px 0 0 rgba(91, 141, 239, 0.08),
    16px 0 48px rgba(0, 0, 0, 0.45);
  transform: translateX(-105%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.library-drawer.open {
  transform: translateX(0);
}

.library-drawer.open .library-drawer-item {
  animation: drawer-item-in 0.38s cubic-bezier(0.32, 0.72, 0, 1) backwards;
}

.library-drawer.open .library-drawer-item:nth-child(1) { animation-delay: 0.04s; }
.library-drawer.open .library-drawer-item:nth-child(2) { animation-delay: 0.08s; }
.library-drawer.open .library-drawer-item:nth-child(3) { animation-delay: 0.12s; }
.library-drawer.open .library-drawer-item:nth-child(4) { animation-delay: 0.16s; }

@keyframes drawer-item-in {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.library-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.35rem 1.1rem 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.library-drawer-brand {
  min-width: 0;
}

.library-drawer-kicker {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.library-drawer-head h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.library-drawer-close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.library-drawer-close svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

.library-drawer-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.library-drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 0.85rem 1.25rem;
}

.library-drawer-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.7rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s, transform 0.12s;
}

.library-drawer-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.library-drawer-item:active {
  transform: scale(0.98);
}

.library-drawer-item.active {
  background: linear-gradient(135deg, rgba(91, 141, 239, 0.18), rgba(91, 141, 239, 0.08));
  border-color: rgba(91, 141, 239, 0.28);
  color: var(--text);
  box-shadow: 0 4px 20px rgba(91, 141, 239, 0.12);
}

.library-drawer-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  transition: background 0.18s, color 0.18s;
}

.library-drawer-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.library-drawer-item.active .library-drawer-icon {
  background: rgba(91, 141, 239, 0.22);
  color: var(--accent);
}

.library-drawer-item.active[data-reading-filter="read"] .library-drawer-icon svg {
  stroke: var(--success);
}

.library-drawer-item.active[data-reading-filter="read"] .library-drawer-icon {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.library-drawer-label {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.library-drawer-item.active .library-drawer-label {
  color: var(--accent);
}

.library-drawer-item.active[data-reading-filter="read"] .library-drawer-label {
  color: var(--success);
}

.library-drawer-count {
  flex-shrink: 0;
  min-width: 1.6rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.library-drawer-item.active .library-drawer-count {
  background: rgba(91, 141, 239, 0.2);
  color: var(--accent);
}

.library-drawer-item.active[data-reading-filter="read"] .library-drawer-count {
  background: rgba(52, 211, 153, 0.18);
  color: var(--success);
}

/* ── Library ─────────────────────────────────────────────── */

.library-filters {
  display: flex;
  gap: 0.5rem;
  margin: 0 1.5rem 0.75rem;
  padding: 0;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.library-filters::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex-shrink: 0;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-chip:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

.filter-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.library-status {
  padding: 0 1.5rem 0.5rem;
  font-size: 0.85rem;
}

.library-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0 1.5rem 0.75rem;
  min-width: 0;
  max-width: 100%;
}

.library-search-icon {
  position: absolute;
  left: 0.85rem;
  font-size: 0.9rem;
  opacity: 0.5;
  pointer-events: none;
}

.library-search {
  width: 100%;
  padding: 0.65rem 2.25rem 0.65rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.library-search::placeholder {
  color: var(--text-dim);
}

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

.library-search-clear {
  position: absolute;
  right: 0.5rem;
  border: none;
  background: var(--surface-hover);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
}

.library-search-clear:hover {
  color: var(--text);
  background: var(--border);
}

.library-content {
  padding: 0 1.5rem 2rem;
  min-width: 0;
  max-width: 100%;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 0.75rem;
}

.lib-group {
  margin-bottom: 1.5rem;
}

.group-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.75rem;
  padding: 0 0.25rem;
}

.group-books {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.book-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0.85rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
  color: var(--text);
  font: inherit;
  outline: none;
  box-sizing: border-box;
}

.book-row:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.book-row:hover {
  transform: translateY(-2px);
  border-color: var(--border);
  box-shadow: var(--shadow-lg);
  background: var(--surface-hover);
}

.book-cover {
  width: 52px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--surface-raised);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.book-cover.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--surface-raised);
}

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

.book-info h3 {
  margin: 0 0 0.15rem;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-info p {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-storage-badges {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

.book-storage-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
}

.book-storage-server {
  color: var(--accent);
  border-color: rgba(91, 141, 239, 0.28);
  background: var(--accent-soft);
}

.book-storage-local {
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.28);
  background: rgba(52, 211, 153, 0.1);
}

.progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.25rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 2px;
}

.book-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.book-format-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  line-height: 1.2;
}

.book-reading-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.25rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
}

.book-reading-icons {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
}

.book-reading-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, transform 0.12s;
}

.book-reading-icon svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.book-reading-icon:hover {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
}

.book-reading-icon:active {
  transform: scale(0.92);
}

.book-reading-toread.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.book-reading-read.active {
  color: var(--success);
  background: rgba(52, 211, 153, 0.12);
}

.book-reading-icons.is-reading .book-reading-icon {
  opacity: 0.55;
}

.book-reading-icons.is-reading .book-reading-icon:hover {
  opacity: 1;
}

.book-favorite-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.25rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
}

.book-favorite-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.book-favorite-icon svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.book-favorite-icon:hover {
  color: var(--fav);
  background: var(--fav-soft);
}

.book-favorite-icon:active {
  opacity: 0.85;
}

.book-favorite-icon.active {
  color: var(--fav);
  background: var(--fav-soft);
}

.book-favorite-icon.active svg {
  fill: currentColor;
  stroke: currentColor;
}

.book-favorite-icon.active:hover {
  color: var(--fav);
  background: rgba(212, 167, 44, 0.2);
}

.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--text-muted);
}

/* ── Fiche livre ─────────────────────────────────────────── */

#view-book.active {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.book-detail-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100%;
  background: #080a0e;
  position: relative;
}

.book-detail-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  padding-top: calc(0.85rem + env(safe-area-inset-top, 0px));
  background: transparent;
  border-bottom: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
}

.detail-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  background: rgba(8, 10, 14, 0.52);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 4px 16px rgba(0, 0, 0, 0.28);
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.15s ease,
    box-shadow 0.2s ease;
}

.detail-back-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: translateX(-1px);
}

.detail-back-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.1) inset,
    0 6px 20px rgba(0, 0, 0, 0.32);
}

.detail-back-btn:active {
  transform: scale(0.94);
}

.detail-back-btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(8, 10, 14, 0.9),
    0 0 0 4px rgba(91, 141, 239, 0.45);
}

.book-detail-scroll {
  flex: 1;
  padding: 0 0 2.5rem;
  padding-bottom: calc(2.5rem + env(safe-area-inset-bottom, 0px));
}

.book-detail-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.detail-main-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  z-index: 4;
  background: #080a0e;
}

.detail-hero-stage {
  position: relative;
  min-height: clamp(280px, 42vh, 340px);
  overflow: hidden;
}

.detail-hero-bg {
  position: absolute;
  inset: -30px;
  background-size: cover;
  background-position: center top;
  filter: blur(32px) saturate(1.15) brightness(0.55);
  transform: scale(1.12);
}

.detail-hero-fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(8, 10, 14, 0.15) 0%,
    rgba(8, 10, 14, 0.55) 55%,
    #080a0e 100%
  );
  pointer-events: none;
}

.detail-hero-cover {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  padding-top: calc(3.25rem + env(safe-area-inset-top, 0px));
  padding-bottom: 1.25rem;
}

.detail-hero-info {
  position: relative;
  z-index: 3;
  margin-top: 0;
  padding: 1.25rem clamp(1rem, 4vw, 1.75rem) 1.25rem;
  text-align: center;
}

.detail-hero-cover .book-detail-cover-wrap {
  margin-bottom: 0;
}

.detail-hero-cover .book-detail-cover,
.detail-hero-cover .book-detail-cover.placeholder {
  width: 148px;
  height: 220px;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.detail-cover-edit-btn {
  position: absolute;
  right: 0.35rem;
  bottom: 0.35rem;
  z-index: 2;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(8, 10, 14, 0.75);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.book-detail-cover-wrap:hover .detail-cover-edit-btn,
.detail-cover-edit-btn:focus-visible {
  opacity: 1;
}

.detail-title {
  margin: 0 0 0.35rem;
  font-size: clamp(1.05rem, 3.8vw, 1.45rem);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.03em;
  color: var(--text);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.detail-author {
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.detail-stats-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  margin: 0 0 1.15rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.detail-stat {
  color: var(--text-muted);
}

.detail-stat-fav {
  color: var(--fav);
  font-weight: 600;
}

.detail-stat-rating {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-weight: 600;
  color: var(--text);
}

.detail-stat-star {
  color: var(--fav);
  font-size: 0.85em;
}

.detail-meta-badge {
  display: inline-flex;
  align-items: center;
  max-width: min(100%, 280px);
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.detail-genre-badge {
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.1);
  color: #6ee7b7;
}

.detail-genre-badge:hover {
  background: rgba(52, 211, 153, 0.18);
  border-color: rgba(52, 211, 153, 0.5);
}

.detail-serie-badge {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.1);
  color: #93c5fd;
}

.detail-serie-badge:hover {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.5);
}

.detail-meta-badge-empty {
  opacity: 0.55;
  font-style: italic;
  text-transform: none;
  letter-spacing: 0.02em;
  font-weight: 600;
}

.detail-stat-sep {
  opacity: 0.35;
  user-select: none;
}

.detail-stat-btn {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: inherit;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: color 0.15s, text-decoration-color 0.15s;
}

.detail-stat-btn:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.detail-stat-muted {
  opacity: 0.65;
  font-style: italic;
}

.detail-hero-manage {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 1.25rem;
  width: 100%;
  max-width: min(100%, 420px);
  margin: 0 auto 0.85rem;
}

.detail-hero-manage.hidden {
  display: none;
}

.detail-hero-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
  max-width: min(100%, 420px);
  margin: 0 auto;
}

.detail-btn-primary {
  width: 100%;
  min-height: 50px;
  padding: 0.9rem 1.25rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(37, 99, 235, 0.45);
  transition: filter 0.15s, transform 0.12s;
}

.detail-btn-primary:hover {
  filter: brightness(1.06);
}

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

.detail-btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  min-height: 48px;
  padding: 0.85rem 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.detail-btn-outline:hover {
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.04);
}

.detail-btn-outline.is-active {
  border-color: rgba(212, 167, 44, 0.45);
  color: var(--fav);
}

.detail-sections {
  padding: 0.5rem clamp(1rem, 4vw, 1.75rem) 0;
  width: 100%;
  max-width: none;
  margin: 0;
}

.detail-section {
  padding: 1.35rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.detail-section.hidden {
  display: none;
}

.detail-section-title {
  margin: 0 0 0.85rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

#detail-panel-summary .detail-section-title {
  color: var(--text-muted);
}

.detail-summary-text,
.detail-author-bio-text,
.detail-expandable-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.72;
  color: var(--text-muted);
}

.detail-author-bio-wrap {
  flex: 1;
  min-width: 0;
}

.detail-author-bio-wrap .detail-read-more {
  margin-top: 0.5rem;
}

.detail-read-more {
  margin-top: 0.65rem;
  padding: 0;
  border: none;
  background: none;
  color: #3b82f6;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.detail-read-more:hover {
  text-decoration: underline;
}

.detail-author-layout {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.detail-author-avatar {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.25), rgba(37, 99, 235, 0.12));
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #93c5fd;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.detail-author-avatar-photo {
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.12);
}

.detail-author-avatar-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-section-empty,
.detail-section-loading {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-dim);
  font-style: italic;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.book-detail-footer {
  display: none;
}

.book-detail-header-spacer {
  flex: 1;
  min-width: 0;
}

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

.detail-header-fav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  background: rgba(8, 10, 14, 0.52);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  color: var(--text-dim);
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 4px 16px rgba(0, 0, 0, 0.28);
  transition:
    color 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease;
}

.detail-header-fav svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.detail-header-fav:hover {
  color: var(--fav);
  background: rgba(212, 167, 44, 0.14);
  border-color: rgba(212, 167, 44, 0.28);
}

.detail-header-fav.active {
  color: var(--fav);
  background: rgba(212, 167, 44, 0.16);
  border-color: rgba(212, 167, 44, 0.32);
}

.detail-header-fav.active svg {
  fill: currentColor;
  stroke: currentColor;
}

.detail-header-fav.active:hover {
  color: var(--fav);
  background: rgba(212, 167, 44, 0.22);
}

.detail-header-fav:active {
  transform: scale(0.94);
}

.detail-edit-btn-header {
  margin-top: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.detail-view-mode,
.detail-hero-meta {
  width: 100%;
  max-width: 420px;
}

.detail-meta-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
}

.detail-meta-row .detail-title,
.detail-meta-row .detail-author {
  margin: 0;
  flex: 0 1 auto;
  min-width: 0;
}

#detail-author-row {
  margin-top: 0.35rem;
  margin-bottom: 0.35rem;
}

.detail-genre-row {
  margin-top: 0.15rem;
  margin-bottom: 0.5rem;
  justify-content: center;
}

.detail-chip-trigger {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  max-width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.detail-chip-trigger:hover .detail-genre-chip:not(.detail-meta-add) {
  border-color: rgba(91, 141, 239, 0.5);
  background: rgba(91, 141, 239, 0.18);
}

.detail-chip-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 999px;
}

.detail-chip-btn {
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
}

.detail-chip-btn:hover {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.16);
}

.detail-chip-btn:focus-visible {
  outline: 2px solid var(--success);
  outline-offset: 2px;
}

.detail-meta-add {
  opacity: 0.7;
  border-style: dashed !important;
}

.detail-meta-add:hover {
  opacity: 1;
}

.detail-serie-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.38rem 0.8rem;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.28);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--success);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-inline-edit-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-top: 0.15rem;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

#detail-author-row .detail-inline-edit-btn {
  margin-top: 0.05rem;
}

.detail-inline-edit-btn:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.detail-cover-edit-btn {
  position: absolute;
  right: 0.35rem;
  bottom: 0.35rem;
  z-index: 2;
  margin-top: 0;
  background: rgba(13, 15, 18, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.detail-cover-edit-btn:hover {
  background: rgba(13, 15, 18, 0.92);
  border-color: rgba(91, 141, 239, 0.35);
}

.detail-meta-edit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  max-width: 360px;
  margin: 0 auto 0.85rem;
}

#detail-title-edit {
  margin-bottom: 0.35rem;
}

.detail-inline-input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  text-align: center;
}

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

.detail-inline-edit-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.detail-inline-save,
.detail-inline-cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.detail-inline-save {
  color: var(--accent);
  border-color: rgba(91, 141, 239, 0.35);
  background: var(--accent-soft);
}

.detail-inline-save:hover {
  filter: brightness(1.08);
}

.detail-inline-cancel:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.book-detail-cover-wrap {
  position: relative;
}

.book-detail-cover-shadow {
  position: absolute;
  inset: 12% -8% -12%;
  background: radial-gradient(ellipse at 50% 80%, rgba(91, 141, 239, 0.22), transparent 70%);
  filter: blur(16px);
  z-index: 0;
  pointer-events: none;
}

.book-detail-cover {
  position: relative;
  z-index: 1;
  width: 148px;
  height: 222px;
  object-fit: cover;
  border-radius: 10px;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.35),
    0 20px 48px rgba(0, 0, 0, 0.25);
}

.book-detail-cover.placeholder {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 148px;
  height: 222px;
  font-size: 2.75rem;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--surface-raised), var(--surface));
  border: 1px solid var(--border-subtle);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.detail-chip-trigger .detail-genres {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
}

.detail-genre-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.38rem 0.8rem;
  border-radius: 999px;
  background: rgba(91, 141, 239, 0.12);
  border: 1px solid rgba(91, 141, 239, 0.28);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.detail-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.detail-badge-status {
  color: var(--accent);
  border-color: rgba(91, 141, 239, 0.25);
  background: var(--accent-soft);
}

.detail-badge-status.on-device {
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.25);
  background: rgba(52, 211, 153, 0.1);
}

.detail-badge-meta {
  color: var(--text-muted);
  border-color: var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-field {
  display: block;
  margin-bottom: 0.75rem;
  text-align: left;
}

.detail-field span {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-field input {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  background: var(--bg-elevated);
  color: var(--text);
}

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

.detail-edit-actions {
  display: flex;
  gap: 0.5rem;
}

.detail-edit-actions .btn-primary,
.detail-edit-actions .btn-secondary {
  flex: 1;
}

.detail-edit-btn {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.05rem;
  padding: 0.2rem 0.45rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.detail-edit-btn:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.detail-manage-block {
  width: 100%;
  max-width: 360px;
  margin: 0 auto 1rem;
  padding: 0 0.25rem;
}

.book-detail-manage {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 1.25rem;
}

.detail-manage-item {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  padding: 0.25rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, opacity 0.15s;
}

.detail-manage-item:hover {
  color: var(--text);
}

.detail-manage-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}

.detail-manage-icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.detail-manage-label {
  font-size: 0.62rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  word-break: break-word;
}

.detail-manage-danger .detail-manage-icon {
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
}

.detail-manage-danger:hover {
  color: var(--danger);
}

.detail-progress-block {
  width: 100%;
  max-width: none;
  margin: 0.75rem 0 0;
  padding: 0;
}

.detail-progress-bar {
  height: 6px;
  margin-bottom: 0.4rem;
  border-radius: 999px;
  overflow: hidden;
}

.detail-progress-text {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

@media (min-width: 640px) {
  .book-detail-scroll {
    max-width: min(100%, 560px);
    margin: 0 auto;
    width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .detail-hero-cover .book-detail-cover,
  .detail-hero-cover .book-detail-cover.placeholder {
    width: 168px;
    height: 252px;
  }
}

@media (min-width: 900px) {
  .book-detail-scroll {
    max-width: min(100%, 1040px);
    padding: 1.5rem 2rem 2.5rem;
  }

  .book-detail-layout {
    display: grid;
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
    gap: 0 2.5rem;
    align-items: start;
  }

  .detail-hero-stage {
    grid-column: 1;
    position: sticky;
    top: 0.75rem;
    height: auto;
    min-height: 420px;
    border-radius: 18px;
    margin-top: 0.5rem;
  }

  .detail-hero-cover {
    padding-top: 2.5rem;
  }

  .detail-hero-cover .book-detail-cover,
  .detail-hero-cover .book-detail-cover.placeholder {
    width: 100%;
    max-width: 220px;
    height: auto;
    aspect-ratio: 2 / 3;
  }

  .detail-main-panel {
    grid-column: 2;
    min-width: 0;
  }

  .detail-hero-info {
    margin-top: 0;
    padding-top: 0.75rem;
    padding-left: 0;
    padding-right: 0;
    text-align: left;
  }

  .detail-stats-line {
    justify-content: flex-start;
  }

  .detail-hero-actions {
    margin: 0;
    max-width: 380px;
  }

  .detail-hero-manage {
    margin-left: 0;
    margin-right: 0;
    justify-content: flex-start;
  }

  .detail-sections {
    padding-left: 0;
    padding-right: 0;
  }

  .book-detail-manage {
    justify-content: flex-start;
  }

  .detail-meta-edit {
    margin-left: 0;
    margin-right: auto;
  }

  .detail-author-layout {
    gap: 1rem;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .detail-hero-stage {
    min-height: clamp(200px, 45vh, 240px);
  }

  .detail-hero-cover {
    padding-top: calc(2rem + env(safe-area-inset-top, 0px));
  }
}

@media (min-width: 1200px) {
  .book-detail-scroll {
    max-width: min(100%, 1120px);
  }

  .book-detail-layout {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    gap: 0 3rem;
  }

  .detail-hero-stage {
    min-height: 480px;
  }

  .detail-hero-cover .book-detail-cover,
  .detail-hero-cover .book-detail-cover.placeholder {
    max-width: 260px;
  }

  .detail-title {
    font-size: 1.55rem;
  }

  .detail-summary-text,
  .detail-author-bio-text {
    font-size: 0.95rem;
  }
}

@media (max-width: 380px) {
  .detail-stat-sep {
    display: none;
  }

  .detail-stats-line {
    gap: 0.45rem;
  }

  .detail-meta-badge {
    max-width: 100%;
  }

  .detail-hero-cover .book-detail-cover,
  .detail-hero-cover .book-detail-cover.placeholder {
    width: 132px;
    height: 198px;
  }
}

.btn-secondary {
  padding: 0.85rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--text-dim);
}

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

/* ── Reader ──────────────────────────────────────────────── */

#view-reader {
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

#view-reader.active {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 30;
  height: 100dvh;
  max-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  box-sizing: border-box;
}

.reader-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--reader-bar-h);
  padding: 0 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

#view-reader.reader-immersive .reader-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

#view-reader.reader-immersive .reader-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

#view-reader.reader-immersive .reader-page {
  flex: 1;
}

#view-reader.reader-immersive .reader-panel {
  top: 0;
  bottom: 0;
}

#view-reader.reader-immersive .reader-panel-bottom {
  max-height: 70vh;
}

.reader-bar-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

#reader-book-title {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#reader-book-author {
  font-size: 0.75rem;
}

.reader-btn {
  border: none;
  background: transparent;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.reader-btn-icon {
  border-radius: 12px;
  transition: background 0.15s, color 0.15s, transform 0.12s;
}

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

.reader-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reader-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

.reader-bar-actions-mobile {
  margin-left: auto;
}

.reader-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.reader-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1rem 1.25rem;
  transition: background 0.2s, color 0.2s;
  background: #e0d2be;
  color: #3d3229;
}

.reader-viewport {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
  position: relative;
  min-height: 0;
  perspective: 1800px;
  perspective-origin: 50% 38%;
}

.reader-viewport.reader-swiping,
.reader-page.reader-touch-pan {
  touch-action: none;
}

@media (pointer: coarse) {
  .reader-page {
    touch-action: pan-y;
  }

  .reader-page.reader-touch-pan,
  .reader-viewport.reader-swiping {
    touch-action: none;
  }

  .reader-zone-prev,
  .reader-zone-next {
    pointer-events: none;
  }
}

.reader-flip-wrapper {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  display: flex;
  align-self: stretch;
  overflow: hidden;
  transform-style: preserve-3d;
}

.reader-flip-under {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.reader-flip-under.hidden {
  opacity: 0;
  visibility: hidden;
}

.reader-viewport.reader-swiping .reader-flip-under:not(.hidden) {
  box-shadow:
    inset 0 0 calc(20px + var(--flip-progress, 0) * 36px)
    rgba(0, 0, 0, calc(0.05 + var(--flip-progress, 0) * 0.14));
}

.reader-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 28%;
  z-index: 5;
  cursor: pointer;
  border: none;
  background: transparent;
}

.reader-zone-prev {
  left: 0;
}

.reader-zone-next {
  right: 0;
}

.reader-zone-center {
  left: 28%;
  right: 28%;
  width: auto;
  z-index: 4;
  cursor: default;
  pointer-events: none;
}

.reader-zone-prev:hover {
  background: linear-gradient(to right, rgba(0, 0, 0, 0.04), transparent);
}

.reader-zone-next:hover {
  background: linear-gradient(to left, rgba(0, 0, 0, 0.04), transparent);
}

.reader-spread {
  display: flex;
  width: min(920px, 100%);
  height: 100%;
  max-height: 100%;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.06),
    0 12px 40px rgba(0, 0, 0, 0.14);
  border-radius: 2px;
  z-index: 1;
}

.reader-sheet {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: #f4ecd8;
  color: #3d3229;
  padding: 2.5rem 2.25rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.reader-sheet-left {
  border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.reader-sheet-right {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  align-self: stretch;
  padding: 0;
  transform-style: preserve-3d;
  --flip-progress: 0;
  --flip-edge: right;
  --flip-shadow-x: -12;
}

.reader-page-flip {
  position: absolute;
  inset: 0;
  z-index: 2;
  transform-style: preserve-3d;
  will-change: transform;
}

.reader-page-face {
  position: absolute;
  inset: 0;
  padding: 2.5rem 2.25rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.reader-page-front {
  z-index: 2;
  background: inherit;
}

.reader-page-back {
  z-index: 1;
  transform: rotateY(180deg);
  background: #ebe3d0;
}

.theme-day .reader-page-back {
  background: #f0eee6;
}

.theme-sepia .reader-page-back {
  background: #e8dcc4;
}

.theme-night .reader-page-back {
  background: #161616;
}

.theme-console .reader-page-back {
  background: #0a0e14;
}

.reader-sheet-right.page-turn-next .reader-page-flip {
  animation: pageFlipInNext 0.42s cubic-bezier(0.33, 1, 0.48, 1);
}

.reader-sheet-right.page-turn-prev .reader-page-flip {
  animation: pageFlipInPrev 0.42s cubic-bezier(0.33, 1, 0.48, 1);
}

.reader-sheet-right.swipe-drag:not(.swipe-commit-next):not(.swipe-commit-prev) .reader-page-flip {
  transition: none !important;
}

.reader-sheet-right.swipe-drag .reader-page-flip {
  filter: drop-shadow(
    calc(var(--flip-progress, 0) * var(--flip-shadow-x, -12) * 1px)
    calc(6px + var(--flip-progress, 0) * 14px)
    calc(10px + var(--flip-progress, 0) * 28px)
    rgba(0, 0, 0, calc(0.1 + var(--flip-progress, 0) * 0.28))
  );
}

.reader-sheet-right.swipe-drag .reader-page-front::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: calc(0.12 + var(--flip-progress, 0) * 0.58);
}

.reader-sheet-right.swipe-drag.swipe-next .reader-page-front::before {
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.45) 0%,
    rgba(0, 0, 0, 0.18) 16%,
    rgba(0, 0, 0, 0.05) 30%,
    transparent 48%
  );
}

.reader-sheet-right.swipe-drag.swipe-prev .reader-page-front::before {
  background: linear-gradient(
    to left,
    rgba(0, 0, 0, 0.45) 0%,
    rgba(0, 0, 0, 0.18) 16%,
    rgba(0, 0, 0, 0.05) 30%,
    transparent 48%
  );
}

.reader-sheet-right.swipe-drag {
  z-index: 3;
}

@keyframes pageFlipInNext {
  from {
    transform: rotateY(-22deg);
    opacity: 0.9;
  }
  to {
    transform: rotateY(0);
    opacity: 1;
  }
}

@keyframes pageFlipInPrev {
  from {
    transform: rotateY(22deg);
    opacity: 0.9;
  }
  to {
    transform: rotateY(0);
    opacity: 1;
  }
}

.reader-text {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  font-family: "Merriweather", Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.75;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  letter-spacing: 0.01em;
  user-select: text;
  -webkit-user-select: text;
  position: relative;
  z-index: 2;
  cursor: text;
}

.reader-text p {
  margin: 0 0 0.85em;
  text-indent: 1.5em;
}

.reader-text p:first-of-type,
.page-chapter + p {
  text-indent: 0;
}

.page-chapter {
  margin: 0 0 1em;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: inherit;
  opacity: 0.55;
  text-indent: 0;
}

.reader-text p.current {
  background: rgba(91, 141, 239, 0.18);
  border-radius: 4px;
  padding: 0.1em 0.25em;
  margin-left: -0.25em;
  margin-right: -0.25em;
}

/* Reader themes */
.theme-day {
  background: #e8e4df;
  color: #1a1a1a;
}

.theme-day .reader-sheet {
  background: #fffef9;
  color: #1a1a1a;
}

.theme-sepia {
  background: #e0d2be;
  color: #3d3229;
}

.theme-sepia .reader-sheet {
  background: #f4ecd8;
  color: #3d3229;
}

.theme-sepia .reader-sheet-left {
  border-right-color: rgba(61, 50, 41, 0.12);
}

.theme-sepia .reader-spread {
  box-shadow:
    0 2px 4px rgba(61, 50, 41, 0.08),
    0 12px 36px rgba(61, 50, 41, 0.14);
}

.theme-sepia .reader-zone-prev:hover {
  background: linear-gradient(to right, rgba(61, 50, 41, 0.06), transparent);
}

.theme-sepia .reader-zone-next:hover {
  background: linear-gradient(to left, rgba(61, 50, 41, 0.06), transparent);
}

.theme-sepia .reader-text p.current {
  background: rgba(91, 70, 54, 0.12);
}

.theme-night {
  background: #121212;
  color: #d4d4d4;
}

.theme-night .reader-sheet {
  background: #1e1e1e;
  color: #d4d4d4;
}

.theme-night .reader-text p.current {
  background: rgba(255, 255, 255, 0.08);
}

.theme-console {
  background: #0a0e14;
  color: #58a6ff;
}

.theme-console .reader-sheet {
  background: #0d1117;
}

.theme-console .reader-text {
  font-family: "Consolas", "Courier New", monospace;
}

.theme-console .reader-text p.current {
  background: rgba(88, 166, 255, 0.15);
}

/* PDF plein écran — page blanche bord à bord */
#view-reader.reader-pdf {
  background: #fff;
}

#view-reader.reader-pdf .reader-page {
  padding: 0;
  background: #fff;
}

#view-reader.reader-pdf .reader-viewport {
  width: 100%;
  height: 100%;
}

#view-reader.reader-pdf .reader-spread {
  width: 100%;
  height: 100%;
  max-width: none;
  box-shadow: none;
  border-radius: 0;
}

#view-reader.reader-pdf .reader-sheet-left {
  display: none;
}

#view-reader.reader-pdf .reader-sheet {
  padding: 0;
  background: #fff;
  border: none;
}

#view-reader.reader-pdf .reader-page-face {
  padding: 0;
}

#view-reader.reader-pdf .reader-sheet-right {
  flex: 1;
  width: 100%;
}

#view-reader.reader-pdf .reader-pdf-view {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #fff;
}

#view-reader.reader-pdf .pdf-page-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  box-shadow: none;
}

#view-reader.reader-pdf.theme-night,
#view-reader.reader-pdf.theme-night .reader-page,
#view-reader.reader-pdf.theme-night .reader-sheet {
  background: #fff;
  color: #1a1a1a;
}

#view-reader.reader-pdf.theme-sepia .reader-sheet {
  background: #fff;
}

.reader-page-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 64px;
  text-align: center;
}

.reader-pdf-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.pdf-page-canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

.pdf-loading {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 2rem;
}

.toc-pdf-hint {
  padding: 0.5rem 0.75rem 0.75rem;
  font-size: 0.85rem;
}


.reader-footer {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: var(--reader-footer-h);
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

.reader-footer-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.reader-footer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.reader-progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.reader-nav-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.12s;
}

.reader-nav-btn:active {
  transform: scale(0.94);
}

.reader-sheet-handle {
  width: 36px;
  height: 4px;
  margin: 0.55rem auto 0.15rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  flex-shrink: 0;
}

.reader-menu-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

.reader-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 88px;
  padding: 0.85rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-hover);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.reader-menu-item:active {
  transform: scale(0.97);
}

.reader-menu-item:hover {
  background: var(--surface-raised);
  border-color: rgba(91, 141, 239, 0.35);
}

.reader-menu-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 600;
}

.reader-menu-label {
  text-align: center;
  line-height: 1.2;
}

.reader-menu-head {
  border-bottom: none;
  padding-bottom: 0.35rem;
}

.reader-chapter-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
  min-width: 0;
}

.reader-chapter-info.is-empty {
  display: none;
}

.reader-progress {
  flex: 1;
  accent-color: var(--accent);
}

.reader-pct {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
}

/* Reader panels */
.reader-panel {
  position: fixed;
  top: var(--reader-chrome-top);
  right: 0;
  width: min(320px, 90vw);
  bottom: var(--reader-chrome-bottom);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
}

.reader-panel-bottom {
  top: auto;
  left: 0;
  right: 0;
  width: 100%;
  bottom: 0;
  border-left: none;
  border-top: 1px solid var(--border);
  max-height: min(55dvh, calc(100dvh - var(--reader-chrome-top) - 2rem));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

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

.panel-head h3 {
  margin: 0;
  font-size: 1rem;
}

.panel-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
}

.panel-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

#view-reader.reader-pdf .reader-text {
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

.reader-dict-toolbar {
  position: fixed;
  z-index: 120;
  display: flex;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgba(14, 17, 23, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.reader-dict-toolbar.hidden {
  display: none;
}

.reader-dict-btn {
  margin: 0;
  padding: 0.45rem 0.85rem;
  border: none;
  border-radius: 999px;
  background: rgba(91, 141, 239, 0.22);
  color: #e8ecf1;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.12s;
}

.reader-dict-btn:hover {
  background: rgba(91, 141, 239, 0.35);
}

.reader-dict-btn:active {
  transform: scale(0.96);
}

.dict-panel-body {
  max-height: min(42vh, 320px);
}

.dict-term {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.dict-note {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.dict-definition {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.dict-definition p {
  margin: 0 0 0.65rem;
}

.dict-definition p:last-child {
  margin-bottom: 0;
}

.dict-loading {
  margin: 0;
  color: var(--text-dim);
}

.dict-error {
  margin: 0;
  color: var(--danger);
}

.dict-source {
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
}

.theme-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.theme-chip {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-hover);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.theme-chip:hover {
  background: var(--surface-raised);
  border-color: var(--accent);
  color: var(--text);
}

.theme-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.toc-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.5rem;
}

.toc-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text);
}

.toc-item:hover {
  background: var(--bg);
}

.toc-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.reader-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 40;
}

/* Audio panel */
.audio-panel-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.audio-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.play-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), #4a7ae0);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.speed-row {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.chip {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
}

.chip.active,
.speed-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.slider-row,
.voice-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.slider-row input,
.voice-row select {
  flex: 1;
}

/* ── Forms & sync ────────────────────────────────────────── */

.form-panel {
  max-width: 480px;
  padding: 1rem 1.5rem 2rem;
}

.form-panel label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.form-panel input[type="text"],
.form-panel input[type="url"],
.form-panel select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--bg-elevated);
  color: var(--text);
}

.form-panel input:focus,
.form-panel select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.file-label {
  display: inline-block;
  padding: 0.65rem 1rem;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(91, 141, 239, 0.25);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s;
}

.file-label:hover {
  background: rgba(91, 141, 239, 0.22);
}

/* ── Upload ──────────────────────────────────────────────── */

.upload-top-bar {
  gap: 0.5rem;
}

.upload-top-bar h1 {
  flex: 1;
  margin: 0;
}

.upload-panel {
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.file-input-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}

.upload-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 220px;
  padding: 2rem 1.5rem;
  border: 1.5px dashed rgba(91, 141, 239, 0.35);
  border-radius: 16px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(91, 141, 239, 0.12), transparent 55%),
    var(--surface);
  cursor: pointer;
  text-align: center;
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.upload-dropzone-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(91, 141, 239, 0.08), transparent 70%);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: rgba(91, 141, 239, 0.65);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(91, 141, 239, 0.18), transparent 55%),
    var(--surface-hover);
}

.upload-dropzone:hover .upload-dropzone-glow,
.upload-dropzone.dragover .upload-dropzone-glow {
  opacity: 1;
}

.upload-dropzone:active {
  transform: scale(0.99);
}

.upload-dropzone.hidden {
  display: none;
}

.upload-dropzone-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: 0.25rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 4px 24px rgba(91, 141, 239, 0.2);
}

.upload-dropzone-icon svg {
  width: 26px;
  height: 26px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.upload-dropzone-title {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.upload-dropzone-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.upload-formats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.upload-formats span {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.upload-queue {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: upload-fade-in 0.28s ease;
}

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

.upload-queue-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.upload-queue-kicker {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.upload-queue-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.upload-clear-btn {
  flex-shrink: 0;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.upload-clear-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.upload-single-card {
  display: flex;
  gap: 1.15rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.upload-cover-wrap {
  flex-shrink: 0;
  position: relative;
  width: 88px;
  height: 124px;
}

.upload-cover-preview {
  width: 88px;
  height: 124px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.upload-cover-preview.hidden + .upload-cover-placeholder,
.upload-cover-wrap:has(.upload-cover-preview:not(.hidden)) .upload-cover-placeholder {
  display: none;
}

.upload-cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 124px;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--surface-raised), var(--surface));
  border: 1px solid var(--border-subtle);
  font-size: 2rem;
}

.upload-meta-fields {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.upload-field {
  display: block;
}

.upload-field span {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.upload-field input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--bg-elevated);
  color: var(--text);
}

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

.upload-batch-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.upload-batch-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

.upload-batch-ext {
  flex-shrink: 0;
  min-width: 2.5rem;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
}

.upload-batch-name {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.upload-progress-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border-subtle);
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #7aa3f5);
  transition: width 0.25s ease;
}

.upload-status {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.upload-submit-btn {
  width: 100%;
  padding: 0.9rem 1.25rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #4a7ae0);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 24px var(--accent-glow);
  transition: filter 0.15s, transform 0.12s, opacity 0.15s;
}

.upload-submit-btn:hover:not(:disabled) {
  filter: brightness(1.06);
}

.upload-submit-btn:active:not(:disabled) {
  transform: scale(0.99);
}

.upload-submit-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary {
  padding: 0.7rem 1.25rem;
  background: linear-gradient(135deg, var(--accent), #4a7ae0);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 12px var(--accent-glow);
  transition: filter 0.15s, box-shadow 0.15s;
}

.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 4px 20px var(--accent-glow);
}

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

.btn-text {
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
}

.sync-panel {
  padding-bottom: 2rem;
}

.settings-url-block {
  margin-bottom: 0.5rem;
}

.settings-field-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.settings-url-row {
  display: flex;
  align-items: flex-start;
  gap: 0.25rem;
}

.settings-url-display {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding-top: 0.15rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  word-break: break-all;
  line-height: 1.4;
}

.settings-url-row .detail-edit-btn {
  margin-top: 0;
}

.sync-last {
  margin-bottom: 0.5rem;
  padding: 0 0 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sync-last-line {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  margin: 0;
  line-height: 1.35;
}

.sync-last-label {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-dim);
}

.sync-last-label::after {
  content: "·";
  margin-left: 0.35rem;
  opacity: 0.5;
}

.sync-last-time {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

.sync-last-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.sync-refresh-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.sync-refresh-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sync-refresh-btn:hover:not(:disabled) {
  color: var(--accent);
  background: var(--accent-soft);
}

.sync-refresh-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.sync-refresh-btn:disabled {
  opacity: 0.45;
  cursor: wait;
}

.sync-refresh-btn.syncing svg {
  animation: sync-spin 0.85s linear infinite;
}

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

.sync-status {
  margin: 0.25rem 0 0;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.sync-categories {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  margin-top: 0;
}

.sync-category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.sync-category-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.sync-category-count {
  flex-shrink: 0;
  min-width: 1.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

.sync-empty {
  margin: 0;
  padding: 1rem;
  text-align: center;
  font-size: 0.88rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.sync-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sync-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.sync-item:hover {
  background: var(--surface-hover);
  border-color: var(--border);
}

.sync-item:active {
  transform: scale(0.99);
}

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

.sync-item-info h4 {
  margin: 0 0 0.15rem;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-item-info p {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sync-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ── Utilities ───────────────────────────────────────────── */

.muted {
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

.icon-btn {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--text);
  border-radius: var(--radius-sm);
}

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

.fab {
  position: fixed;
  right: 1rem;
  bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  height: 48px;
  padding: 0 1.15rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--accent), #4a7ae0);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 24px var(--accent-glow);
  white-space: nowrap;
}

.fab-plus {
  font-size: 1.2rem;
  line-height: 1;
  font-weight: 400;
}

.fab-text {
  line-height: 1;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  z-index: 100;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
}

.toast.error {
  background: rgba(248, 113, 113, 0.15);
  border-color: var(--danger);
  color: var(--danger);
}

body.confirm-open {
  overflow: hidden;
}

body.reading-mode-open {
  overflow: hidden;
}

.reading-mode-sheet {
  position: fixed;
  inset: 0;
  z-index: 190;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.reading-mode-sheet.hidden {
  display: none;
}

.reading-mode-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: readingModeFadeIn 0.25s ease;
}

.reading-mode-panel {
  position: relative;
  width: min(100%, 420px);
  padding: 0.85rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  border-radius: 22px 22px 0 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: none;
  background: rgba(22, 26, 34, 0.96);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.45);
  animation: readingModeSlideUp 0.28s ease;
}

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

@keyframes readingModeSlideUp {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.reading-mode-handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 0.85rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.reading-mode-title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  color: var(--text);
}

.reading-mode-subtitle {
  margin: 0 0 1.1rem;
  font-size: 0.82rem;
  text-align: center;
  color: var(--text-muted);
}

.reading-mode-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.reading-mode-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.1rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.reading-mode-option:hover {
  transform: translateY(-2px);
  border-color: rgba(91, 141, 239, 0.35);
  background: rgba(91, 141, 239, 0.08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.reading-mode-option:active {
  transform: translateY(0);
}

.reading-mode-option-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
}

.reading-mode-option-icon svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reading-mode-icon-read {
  color: var(--accent);
  background: linear-gradient(145deg, rgba(91, 141, 239, 0.28), rgba(91, 141, 239, 0.1));
  border: 1px solid rgba(91, 141, 239, 0.25);
}

.reading-mode-icon-audio {
  color: #a78bfa;
  background: linear-gradient(145deg, rgba(167, 139, 250, 0.28), rgba(167, 139, 250, 0.1));
  border: 1px solid rgba(167, 139, 250, 0.25);
}

.reading-mode-option-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  text-align: center;
}

.reading-mode-option-text strong {
  font-size: 0.95rem;
  font-weight: 600;
}

.reading-mode-option-text span {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.reading-mode-cancel {
  width: 100%;
  min-height: 44px;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.reading-mode-cancel:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.confirm-dialog.hidden {
  display: none;
}

.confirm-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.confirm-dialog-panel {
  position: relative;
  width: min(100%, 380px);
  padding: 1.35rem 1.25rem 1.15rem;
  border-radius: 16px;
  border: 1px solid rgba(248, 113, 113, 0.25);
  background: var(--surface);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

.confirm-dialog-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 0.85rem;
  border-radius: 50%;
  font-size: 1.35rem;
  font-weight: 700;
}

.confirm-dialog-icon-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

.confirm-dialog-icon-warning {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.confirm-dialog-panel-danger {
  border-color: rgba(248, 113, 113, 0.25);
}

.confirm-dialog-panel-warning {
  border-color: rgba(251, 191, 36, 0.28);
}

.confirm-dialog-title {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  color: var(--text);
}

.confirm-dialog-message {
  margin: 0 0 1.15rem;
  font-size: 0.88rem;
  line-height: 1.55;
  text-align: center;
  color: var(--text-muted);
}

.confirm-dialog-actions {
  display: flex;
  gap: 0.65rem;
}

.confirm-dialog-actions .btn-secondary,
.confirm-dialog-actions .btn-danger,
.confirm-dialog-actions .btn-primary {
  flex: 1;
  min-height: 44px;
}

.btn-danger {
  padding: 0.85rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--danger);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
}

.btn-danger:hover {
  filter: brightness(1.08);
}

.btn-danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Bottom nav (mobile) ─────────────────────────────────── */

.bottom-nav {
  display: none;
  align-items: stretch;
  justify-content: space-around;
  gap: 0.2rem;
  padding: 0.45rem 0.65rem 0;
  padding-bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
  background: rgba(14, 17, 23, 0.78);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow:
    0 -1px 0 rgba(91, 141, 239, 0.08),
    0 -12px 40px rgba(0, 0, 0, 0.45);
}

.bottom-nav .nav-item {
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-width: 0;
  min-height: 58px;
  padding: 0.35rem 0.25rem;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text-dim);
  font-size: inherit;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease, transform 0.15s ease;
  box-shadow: none;
}

.bottom-nav .nav-item::before {
  content: "";
  position: absolute;
  inset: 0.2rem 0.15rem;
  border-radius: 10px;
  background: transparent;
  transition: background 0.22s ease, box-shadow 0.22s ease;
}

.bottom-nav .nav-item:hover {
  color: var(--text-muted);
  background: transparent;
}

.bottom-nav .nav-item:active {
  transform: scale(0.94);
}

.bottom-nav .nav-item.active {
  color: var(--accent);
  background: transparent;
  box-shadow: none;
}

.bottom-nav .nav-item.active::before {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(91, 141, 239, 0.22);
}

.bottom-nav-icon {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
}

.bottom-nav-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s ease, stroke-width 0.2s ease;
}

.bottom-nav .nav-item.active .bottom-nav-icon svg {
  stroke-width: 2.1;
  transform: scale(1.06);
}

.bottom-nav .nav-item.active[data-filter="favorites"] {
  color: var(--fav);
}

.bottom-nav .nav-item.active[data-filter="favorites"] .bottom-nav-icon svg {
  fill: var(--fav);
  stroke: var(--fav);
}

.bottom-nav-label {
  position: relative;
  z-index: 1;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1;
  text-transform: uppercase;
  opacity: 0.92;
}

.bottom-nav .nav-item.active .bottom-nav-label {
  opacity: 1;
}

.bottom-nav .nav-item span:not(.bottom-nav-icon):not(.bottom-nav-label) {
  display: none;
}

/* ── Responsive ──────────────────────────────────────────── */

.desktop-only {
  display: block;
}

.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: flex;
  }

  .fab.mobile-only {
    display: inline-flex;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
  }

  .main-shell:not(.hide-bottom-nav) .views-container {
    padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
  }

  .views-container:has(#view-library.active) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 0;
  }

  #view-library.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  #view-library .library-top-bar {
    flex-shrink: 0;
  }

  #view-library .library-search-wrap,
  #view-library .library-filters,
  #view-library .library-status {
    flex-shrink: 0;
  }

  #view-library .library-content:not(.hidden) {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: calc(6.5rem + env(safe-area-inset-bottom, 0px));
  }

  #view-library #library-empty:not(.hidden) {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem 1rem calc(6rem + env(safe-area-inset-bottom, 0px));
  }

  .top-bar {
    padding-top: calc(0.85rem + env(safe-area-inset-top, 0px));
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .top-bar h1 {
    font-size: 1.25rem;
  }

  .library-status,
  .library-search-wrap,
  .library-filters {
    margin-left: 1rem;
    margin-right: 1rem;
  }

  .library-status {
    padding-left: 0;
    padding-right: 0;
  }

  .library-content {
    padding: 0 1rem 1.5rem;
  }

  .library-search {
    font-size: 16px;
  }

  .library-grid {
    grid-template-columns: 1fr;
  }

  .toast {
    bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
    left: 1rem;
    right: 1rem;
    max-width: none;
  }

  #view-reader.active {
    padding: 0;
    z-index: 50;
  }

  .reader-page {
    padding: 0;
    flex: 1;
    min-height: 0;
  }

  .theme-day .reader-page {
    background: #fffef9;
    color: #1a1a1a;
  }

  .theme-sepia .reader-page {
    background: #f4ecd8;
    color: #3d3229;
  }

  .theme-night .reader-page {
    background: #1e1e1e;
    color: #d4d4d4;
  }

  .theme-console .reader-page {
    background: #0d1117;
    color: #58a6ff;
  }

  .reader-spread {
    width: 100%;
    max-width: 100%;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
    filter: none;
  }

  .reader-sheet {
    padding: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .reader-sheet-right {
    padding: 0;
    box-shadow: none;
  }

  .reader-page-face {
    padding:
      calc(1.35rem + env(safe-area-inset-top, 0px))
      calc(1.15rem + env(safe-area-inset-right, 0px))
      calc(1.35rem + env(safe-area-inset-bottom, 0px))
      calc(1.15rem + env(safe-area-inset-left, 0px));
    border-radius: 0;
  }

  .reader-sheet-right.swipe-drag .reader-page-front,
  .reader-sheet-right.swipe-drag .reader-page-back {
    border-radius: 0;
    box-shadow:
      0 2px 8px rgba(0, 0, 0, 0.08),
      0 12px 36px rgba(0, 0, 0, 0.18);
  }

  .reader-nav-btn.mobile-only {
    display: inline-flex;
  }

  #view-reader:not(.reader-immersive) .reader-bar {
    position: absolute;
    top: calc(0.45rem + env(safe-area-inset-top, 0px));
    left: 0.65rem;
    right: 0.65rem;
    z-index: 25;
    min-height: 48px;
    padding: 0.3rem 0.45rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    background: rgba(12, 15, 20, 0.88);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.38);
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }

  #view-reader:not(.reader-immersive) .reader-footer {
    position: absolute;
    left: 0.65rem;
    right: 0.65rem;
    bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
    z-index: 25;
    min-height: auto;
    padding: 0.65rem 0.55rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    background: rgba(12, 15, 20, 0.9);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.38);
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }

  #view-reader.reader-immersive .reader-bar,
  #view-reader.reader-immersive .reader-footer {
    position: absolute;
    transform: translateY(-120%);
    opacity: 0;
    pointer-events: none;
  }

  #view-reader.reader-immersive .reader-footer {
    transform: translateY(120%);
  }

  .reader-chapter-info {
    display: block;
    flex: 1;
    min-width: 0;
    max-width: none;
    font-size: 0.72rem;
    color: var(--text-muted);
  }

  .reader-page-info {
    flex-shrink: 0;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
  }

  .reader-footer-meta {
    gap: 0.65rem;
  }

  .reader-progress {
    flex: 1;
    min-width: 0;
    height: 4px;
  }

  .reader-pct {
    font-size: 0.75rem;
    min-width: 2.5rem;
  }

  .reader-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: min(88dvh, calc(100dvh - 0.5rem));
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.45);
  }

  .reader-panel-bottom {
    max-height: min(72dvh, calc(100dvh - 1rem));
  }

  .reader-menu-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-body input[type="range"] {
    width: 100%;
    min-height: 28px;
  }

  .theme-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .theme-chip {
    text-align: center;
    padding: 0.65rem 0.5rem;
  }

  .reader-sheet-left {
    display: none;
  }

  .reader-zone {
    width: 22%;
  }

  .reader-sheet-right.page-turn-next .reader-page-flip {
    animation: pageFlipInNext 0.42s cubic-bezier(0.33, 1, 0.48, 1);
  }

  .reader-sheet-right.page-turn-prev .reader-page-flip {
    animation: pageFlipInPrev 0.42s cubic-bezier(0.33, 1, 0.48, 1);
  }

  #view-reader.reader-pdf .reader-page,
  #view-reader.reader-pdf .reader-sheet {
    padding: 0;
  }

  #view-reader.reader-pdf .reader-pdf-view {
    padding:
      env(safe-area-inset-top, 0px)
      env(safe-area-inset-right, 0px)
      env(safe-area-inset-bottom, 0px)
      env(safe-area-inset-left, 0px);
    box-sizing: border-box;
  }

  #view-reader.reader-immersive .reader-panel {
    top: 0;
    bottom: 0;
    max-height: 100dvh;
    border-radius: 0;
  }

  #view-reader.reader-immersive .reader-panel-bottom {
    max-height: min(70dvh, calc(100dvh - 2rem));
    border-radius: 20px 20px 0 0;
  }

  .upload-panel,
  .sync-panel {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .confirm-dialog-panel {
    width: min(100%, calc(100vw - 2rem));
    margin: 1rem;
  }
}

@media (max-width: 480px) {
  .library-top-bar {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .library-status,
  .library-search-wrap,
  .library-filters {
    margin-left: 0.85rem;
    margin-right: 0.85rem;
  }

  .library-content {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .book-row {
    gap: 0.75rem;
    padding: 0.7rem;
  }

  .book-cover {
    width: 46px;
    height: 64px;
  }

  .book-info h3 {
    font-size: 0.9rem;
  }

  .book-meta {
    gap: 0.28rem;
  }

  .fab {
    right: 0.85rem;
    height: 44px;
    padding: 0 1rem;
    font-size: 0.88rem;
  }

  .reader-bar {
    gap: 0.25rem;
    padding: 0 0.35rem;
  }

  .reader-btn {
    width: 36px;
    height: 36px;
    font-size: 0.92rem;
  }

  #reader-book-author {
    display: none;
  }

  .reader-chapter-info {
    font-size: 0.7rem;
  }

  .reader-footer {
    gap: 0.5rem;
    padding: 0 0.65rem;
  }

  .reader-sheet {
    padding: 0;
  }

  .reader-page-face {
    padding:
      calc(1rem + env(safe-area-inset-top, 0px))
      calc(0.85rem + env(safe-area-inset-right, 0px))
      calc(1rem + env(safe-area-inset-bottom, 0px))
      calc(0.85rem + env(safe-area-inset-left, 0px));
  }

  .reader-text {
    font-size: 16px;
    line-height: 1.65;
  }

  .detail-hero-stage {
    min-height: clamp(300px, 46vh, 360px);
  }

  .library-filters {
    margin-bottom: 0.65rem;
  }

  .filter-chip {
    font-size: 0.8rem;
    padding: 0.35rem 0.7rem;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .reader-page {
    padding: 0;
  }

  .reader-sheet {
    padding: 0;
  }

  .reader-page-face {
    padding:
      calc(0.65rem + env(safe-area-inset-top, 0px))
      calc(0.85rem + env(safe-area-inset-right, 0px))
      calc(0.65rem + env(safe-area-inset-bottom, 0px))
      calc(0.85rem + env(safe-area-inset-left, 0px));
  }

  #reader-book-author {
    display: none;
  }

  .reader-panel-bottom {
    max-height: min(85dvh, calc(100dvh - 1rem));
  }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .library-content {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .library-search-wrap,
  .library-status,
  .library-filters {
    margin-left: 1.25rem;
    margin-right: 1.25rem;
  }
}

@media (min-width: 769px) {
  #view-reader.active {
    left: var(--sidebar-w);
  }

  #app.reader-mode #view-reader.active {
    left: 0;
  }

  .reader-footer-main {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
  }

  .reader-footer-meta {
    flex: 0 1 auto;
    max-width: 42%;
  }

  .reader-progress-wrap {
    flex: 1;
  }
}

/* ── Fiche livre — enrichissement & similaires ── */

.detail-shimmer {
  background: linear-gradient(
    90deg,
    rgba(139, 149, 165, 0.45) 0%,
    rgba(232, 236, 241, 0.85) 50%,
    rgba(139, 149, 165, 0.45) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: detail-shimmer 1.5s ease-in-out infinite;
}

@keyframes detail-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.detail-similar-track {
  display: flex;
  gap: 0.85rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.detail-similar-card {
  flex: 0 0 auto;
  scroll-snap-align: start;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.detail-similar-cover {
  width: clamp(84px, 22vw, 108px);
  height: auto;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s ease;
}

.detail-similar-card:hover .detail-similar-cover {
  transform: translateY(-4px) scale(1.02);
}

.detail-similar-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (min-width: 900px) {
  .detail-similar-cover {
    width: 108px;
  }
}

/* ── Fiche livre — commentaires ── */

.detail-comments-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.detail-comments-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
}

.detail-comments {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.detail-comments-compose {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.detail-comments-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, rgba(91, 141, 239, 0.35), rgba(59, 130, 246, 0.15));
  border: 1px solid rgba(91, 141, 239, 0.35);
  color: #bfdbfe;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.detail-comments-input-wrap {
  flex: 1;
  min-width: 0;
}

.detail-comments-input {
  width: 100%;
  margin: 0;
  padding: 0.62rem 1rem;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.35;
  transition: background 0.15s, box-shadow 0.15s;
}

.detail-comments-input::placeholder {
  color: var(--text-dim);
}

.detail-comments-input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 0 0 1px rgba(91, 141, 239, 0.35);
}

.detail-comments-stars.detail-rating-input {
  display: flex;
  align-items: center;
  gap: 0;
}

.detail-rating-input {
  display: inline-flex;
  align-items: center;
  gap: 0;
}

.detail-star-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.22);
  line-height: 0;
  cursor: pointer;
  transition: color 0.15s ease, transform 0.12s ease, filter 0.15s ease;
}

.detail-star-icon {
  width: 15px;
  height: 15px;
  display: block;
  fill: currentColor;
  stroke: none;
}

.detail-star-btn:not(.active) .detail-star-icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linejoin: round;
}

.detail-star-btn:hover {
  color: rgba(232, 185, 35, 0.75);
  transform: scale(1.08);
}

.detail-star-btn.active {
  color: #e8b923;
  filter: drop-shadow(0 0 4px rgba(232, 185, 35, 0.35));
}

.detail-star-btn.active:hover {
  color: #f0c832;
  filter: drop-shadow(0 0 6px rgba(232, 185, 35, 0.5));
}

.detail-star-btn:active {
  transform: scale(0.94);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.detail-review-status {
  margin: 0;
  font-size: 0.78rem;
  color: var(--success);
}

.detail-review-status.hidden {
  display: none;
}

.detail-review-status-error {
  color: var(--danger);
}

.detail-stat-user-rating .detail-stat-star {
  color: var(--fav);
}
