:root {
  --bg-app: #0f141c;
  --bg-sidebar: #151c28;
  --bg-card: #1b2434;
  --bg-card-hover: #222e42;
  --bg-input: #121822;
  --border-color: #2a364d;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --accent-soft: rgba(245, 158, 11, 0.14);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --radius: 12px;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Crimson Pro', Georgia, serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-main);
  overflow-x: hidden;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ================= SIDEBAR ================= */
.sidebar {
  width: 290px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 18px;
}

.brand-icon {
  font-size: 28px;
  background: var(--accent-soft);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.brand-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

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

.nav-section {
  margin-bottom: 20px;
}

.nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 8px;
  padding: 0 8px;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  margin-bottom: 4px;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-badge {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 600;
}

.badge-green {
  background: var(--green-soft);
  color: #34d399;
}

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

.source-pills {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.source-pill {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.source-pill:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}

.source-pill.active {
  background: #232f46;
  color: #fff;
  border-color: #38496a;
  font-weight: 600;
}

.author-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 4px;
}

.chip {
  background: #1d2636;
  border: 1px solid #2b3850;
  color: #cbd5e1;
  font-size: 11.5px;
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.chip:hover, .chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0f141c;
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

.disk-stats {
  background: #111722;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 12.5px;
}

.disk-stat-row {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.disk-stat-row:last-child {
  margin-bottom: 0;
}

.disk-stat-row strong {
  color: #fff;
}

/* ================= MAIN CONTENT ================= */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 20, 28, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-bar-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s;
}

.search-bar-wrapper:focus-within {
  border-color: var(--accent);
}

.search-icon {
  margin-right: 10px;
  opacity: 0.7;
}

#search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
  padding: 8px 0;
}

.btn-clear-search {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 10px;
  font-size: 14px;
}

.btn-live-search {
  background: #233047;
  color: #e2e8f0;
  border: 1px solid #354768;
  padding: 8px 13px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-live-search:hover {
  background: var(--accent);
  color: #0f141c;
  border-color: var(--accent);
}

.select-control {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  outline: none;
}

/* Bannière Moissonneur */
.harvester-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.18), rgba(16, 185, 129, 0.15));
  border-bottom: 1px solid rgba(245, 158, 11, 0.35);
  padding: 10px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
}

.hb-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: #fde68a;
}

.hb-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.spinner-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.6; }
  50% { transform: scale(1.25); opacity: 1; }
}

.view-section {
  padding: 24px 28px 48px;
}

/* Continue Reading */
.continue-reading-box {
  background: linear-gradient(135deg, #1b2538, #161e2e);
  border: 1px solid #2d3d59;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 22px;
}

.section-header-inline h3 {
  font-size: 15px;
  margin-bottom: 12px;
  color: #fde68a;
}

.continue-reading-list {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.continue-item {
  background: rgba(15, 20, 28, 0.65);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 250px;
  max-width: 300px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.continue-item:hover {
  border-color: var(--accent);
}

.continue-info h4 {
  font-size: 13.5px;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

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

/* Barre des genres */
.genre-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-color);
}

.genre-tab {
  background: #182130;
  border: 1px solid #28354c;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: all 0.15s;
}

.genre-tab:hover {
  color: #fff;
  border-color: #3f5275;
}

.genre-tab.active {
  background: var(--accent);
  color: #0f141c;
  border-color: var(--accent);
  font-weight: 700;
}

.results-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.view-title {
  font-size: 22px;
  font-weight: 700;
}

.results-subtitle {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Boutons */
.btn-primary {
  background: var(--accent);
  color: #0f141c;
  border: none;
  padding: 10px 16px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

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

.btn-secondary {
  background: #222d42;
  color: #e2e8f0;
  border: 1px solid #334361;
  padding: 9px 14px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: #2c3a54;
  color: #fff;
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn-xs {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

/* ================= GRILLE DE LIVRES ================= */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
}

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

.book-card:hover {
  transform: translateY(-4px);
  border-color: #43567a;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
}

.book-cover-box {
  height: 255px;
  background: #121824;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}

.book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.book-card:hover .book-cover-img {
  transform: scale(1.03);
}

/* Couverture de collection générée quand pas d'image */
.generated-cover {
  width: 100%;
  height: 100%;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  background: linear-gradient(145deg, #2b1d16, #182338);
  border: 5px double rgba(245, 158, 11, 0.35);
}

.generated-cover .gc-ornament {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #fbbf24;
  opacity: 0.8;
}

.generated-cover .gc-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.generated-cover .gc-author {
  font-size: 12.5px;
  color: #cbd5e1;
  font-style: italic;
}

.card-badges-top {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.source-tag {
  background: rgba(15, 20, 28, 0.85);
  backdrop-filter: blur(4px);
  color: #e2e8f0;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  text-transform: uppercase;
}

.offline-tag {
  background: rgba(16, 185, 129, 0.92);
  color: #052e16;
  font-size: 10.5px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
}

.fav-btn-float {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(15, 20, 28, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #94a3b8;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.fav-btn-float.active, .fav-btn-float:hover {
  color: #fbbf24;
  transform: scale(1.1);
}

.book-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.book-title {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.35;
  color: #fff;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-author {
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}

.book-cat-pill {
  font-size: 10.5px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-actions {
  margin-top: auto;
  display: flex;
  gap: 6px;
}

.btn-read-card {
  flex: 1;
  background: var(--accent);
  color: #0f141c;
  border: none;
  padding: 8px 10px;
  border-radius: 7px;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

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

.btn-dl-card {
  background: #243147;
  color: #e2e8f0;
  border: 1px solid #354666;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-dl-card:hover {
  background: #30415e;
}

.btn-dl-card.done {
  background: var(--green-soft);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 32px;
}

/* ================= VUE MOISSONNEUR ================= */
.harvester-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 22px;
  margin-top: 20px;
}

.h-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.h-card-badge {
  align-self: flex-start;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  text-transform: uppercase;
}

.h-card h3 {
  font-size: 18px;
}

.h-card p {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

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

.sc-box {
  background: #121824;
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.sc-box strong {
  color: var(--accent);
  font-size: 15px;
}

.h-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.custom-harvest-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.custom-harvest-row input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 9px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
}

.preset-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-preset {
  background: #212c40;
  border: 1px solid #334463;
  color: #f1f5f9;
  padding: 12px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.btn-preset:hover {
  background: var(--accent);
  color: #0f141c;
  border-color: var(--accent);
}

.btn-preset-all {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fde68a;
}

.queue-status-box {
  background: #121824;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
}

.queue-stats-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 10px;
}

.progress-bar-track {
  height: 10px;
  background: #1e293b;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  transition: width 0.3s ease;
}

.q-current-book {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-controls {
  display: flex;
  gap: 8px;
}

.harvester-logs-card {
  margin-top: 22px;
  background: #111621;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

.logs-header {
  padding: 12px 18px;
  background: #171f2e;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.logs-path {
  color: var(--text-muted);
  font-family: monospace;
  font-size: 12px;
}

.logs-console {
  height: 240px;
  overflow-y: auto;
  padding: 12px 18px;
  font-family: 'Consolas', monospace;
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-line {
  display: flex;
  gap: 10px;
}

.log-time {
  color: #64748b;
  flex-shrink: 0;
}

.log-msg.success { color: #34d399; }
.log-msg.error { color: #f87171; }
.log-msg.info { color: #cbd5e1; }

/* ================= LISEUSE INTÉGRÉE ================= */
.reader-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.reader-modal.theme-light {
  --r-bg: #ffffff;
  --r-bar: #f8fafc;
  --r-text: #1e293b;
  --r-border: #e2e8f0;
  --r-muted: #64748b;
}

.reader-modal.theme-sepia {
  --r-bg: #f6efe2;
  --r-bar: #ece2d0;
  --r-text: #2c2218;
  --r-border: #d8cbb3;
  --r-muted: #6e5a44;
}

.reader-modal.theme-dark {
  --r-bg: #11151c;
  --r-bar: #171d26;
  --r-text: #e2e8f0;
  --r-border: #2a3446;
  --r-muted: #94a3b8;
}

.reader-topbar {
  background: var(--r-bar);
  border-bottom: 1px solid var(--r-border);
  color: var(--r-text);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.reader-left, .reader-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reader-title-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
}

.reader-title-box strong {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 440px;
}

.reader-title-box span {
  font-size: 12px;
  color: var(--r-muted);
}

.reader-btn, .reader-select {
  background: rgba(128, 128, 128, 0.12);
  border: 1px solid var(--r-border);
  color: var(--r-text);
  padding: 6px 12px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.reader-btn:hover {
  background: rgba(128, 128, 128, 0.22);
}

.theme-switcher {
  display: flex;
  gap: 4px;
}

.theme-dot {
  border: 1px solid var(--r-border);
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}

.theme-dot.active {
  outline: 2px solid var(--accent);
}

.font-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
}

.reader-body {
  flex: 1;
  display: flex;
  background: var(--r-bg);
  color: var(--r-text);
  overflow: hidden;
}

.reader-toc {
  width: 300px;
  background: var(--r-bar);
  border-right: 1px solid var(--r-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.reader-toc.hidden {
  display: none;
}

.toc-header {
  padding: 14px;
  border-bottom: 1px solid var(--r-border);
}

.toc-header h4 {
  font-size: 14px;
  margin-bottom: 8px;
}

.toc-header input {
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--r-border);
  background: var(--r-bg);
  color: var(--r-text);
  font-family: inherit;
  font-size: 12.5px;
}

.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.toc-item {
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border: none;
  background: transparent;
  color: var(--r-text);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  display: block;
  margin-bottom: 2px;
}

.toc-item:hover {
  background: rgba(128, 128, 128, 0.12);
}

.toc-item.active {
  background: var(--accent);
  color: #0f141c;
  font-weight: 700;
}

.reader-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 40px 28px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.reader-article {
  width: 100%;
  max-width: 740px;
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 1.78;
  color: var(--r-text);
}

.reader-article p {
  margin-bottom: 1.15em;
  text-align: justify;
}

.reader-article h1, .reader-article h2, .reader-article h3 {
  margin: 1.4em 0 0.7em;
  line-height: 1.3;
  text-align: center;
}

.reader-article img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 24px auto;
  border-radius: 6px;
}

.reader-iframe {
  width: 100%;
  height: 82vh;
  border: none;
  border-radius: 8px;
}

.reader-footer-nav {
  width: 100%;
  max-width: 740px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--r-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.reader-loading {
  margin: 80px auto;
  text-align: center;
}

.loader-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(245, 158, 11, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

/* Toast */
.toast-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #1e293b;
  color: #fff;
  border-left: 4px solid var(--accent);
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
  font-size: 13.5px;
  max-width: 360px;
}

/* ================= BOUTON & MODAL APPLI TÉLÉPHONE (QR CODE) ================= */
.btn-mobile-qr {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin-bottom: 18px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(16, 185, 129, 0.16));
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: transform 0.15s, border-color 0.15s;
}

.btn-mobile-qr:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.btn-mobile-qr span {
  font-size: 24px;
}

.btn-mobile-qr strong {
  display: block;
  font-size: 13.5px;
  color: #fde68a;
}

.btn-mobile-qr small {
  font-size: 11px;
  color: #cbd5e1;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(8, 12, 18, 0.82);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid #384968;
  border-radius: 16px;
  max-width: 620px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-body {
  padding: 20px 22px;
}

.modal-intro {
  font-size: 14px;
  color: #cbd5e1;
  line-height: 1.5;
  margin-bottom: 16px;
}

.qr-box {
  background: #111722;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

#mobile-qr-img {
  width: 210px;
  height: 210px;
  border-radius: 10px;
  background: #fff;
  padding: 8px;
}

.qr-url-pill {
  background: #1e293b;
  border: 1px solid var(--accent);
  color: #fde68a;
  font-family: monospace;
  font-size: 15px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 99px;
  user-select: all;
}

.install-steps-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.install-step-box {
  background: #131a27;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
}

.install-step-box h4 {
  font-size: 14px;
  margin-bottom: 8px;
  color: #fff;
}

.install-step-box ol {
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
}

.install-step-box li {
  margin-bottom: 6px;
}

/* ================= ANNUAIRE DES CATÉGORIES (Style Anna's Archive) ================= */
.categories-directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
}

.cat-group-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cat-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

.cat-group-icon {
  font-size: 22px;
}

.cat-group-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.cat-sub-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.cat-sub-btn {
  background: #131a28;
  border: 1px solid #293852;
  color: #e2e8f0;
  padding: 6px 11px;
  border-radius: 7px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.cat-sub-btn:hover {
  background: var(--accent);
  color: #0f141c;
  border-color: var(--accent);
  font-weight: 600;
}

/* ================= NAVIGATION MOBILE & RESPONSIVE (SMARTPHONE) ================= */
.mobile-menu-btn,
.mobile-close-drawer,
.mobile-bottom-nav,
.sidebar-backdrop {
  display: none;
}

@media (max-width: 900px) {
  .desktop-only {
    display: none !important;
  }

  .hide-on-sm {
    display: none !important;
  }

  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 90;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    width: 285px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.6);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-close-drawer {
    display: inline-flex;
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    padding: 4px 8px;
    cursor: pointer;
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1d2638;
    border: 1px solid var(--border-color);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 9px;
    font-size: 19px;
    cursor: pointer;
    flex-shrink: 0;
  }

  .topbar {
    padding: 10px 14px;
    gap: 8px;
  }

  .view-section {
    padding: 16px 14px 92px;
  }

  .books-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .book-cover-box {
    height: 205px;
  }

  .harvester-cards {
    grid-template-columns: 1fr;
  }

  .preset-buttons,
  .install-steps-grid {
    grid-template-columns: 1fr;
  }

  /* Barre d'onglets inférieure style application native iOS / Android */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 80;
    background: rgba(18, 24, 36, 0.96);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border-color);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }

  .mob-nav-item {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 2px;
    font-family: inherit;
    cursor: pointer;
  }

  .mob-nav-icon {
    font-size: 19px;
  }

  .mob-nav-label {
    font-size: 10.5px;
    font-weight: 600;
  }

  .mob-nav-item.active {
    color: var(--accent);
  }

  /* Liseuse adaptée aux écrans de téléphones */
  .reader-topbar {
    padding: 8px 10px;
    gap: 6px;
    flex-wrap: wrap;
  }

  .reader-title-box {
    order: 3;
    width: 100%;
    padding-top: 4px;
    border-top: 1px solid var(--r-border);
  }

  .reader-toc {
    position: fixed;
    top: 86px;
    bottom: 0;
    left: 0;
    z-index: 1010;
    width: 82%;
    max-width: 310px;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.45);
  }

  .reader-toc.hidden-on-mobile {
    display: none;
  }

  .reader-viewport {
    padding: 20px 16px 80px;
  }

  .reader-article {
    font-size: 18px;
    line-height: 1.68;
  }

  .toast-container {
    bottom: 74px;
    left: 14px;
    right: 14px;
  }
}

@media (max-width: 480px) {
  .hide-on-xs {
    display: none !important;
  }
}
