:root {
  --bg: #0b0e13;
  --bg-soft: #151a24;
  --panel: #1b2230;
  --panel-2: #222a3a;
  --text: #e8ecf3;
  --muted: #9aa4b8;
  --accent: #02a9ff;
  --accent-2: #3db4f2;
  --danger: #ed4245;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: var(--bg-soft);
  border-bottom: 1px solid #262f42;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; color: var(--accent-2); }

.nav { display: flex; gap: 16px; }
.nav a { color: var(--muted); font-weight: 600; }
.nav a:hover { color: var(--text); text-decoration: none; }

.user-chip { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; }
.username { font-weight: 600; }

.view {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.footer {
  padding: 16px 20px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  border-top: 1px solid #262f42;
}
.footer code { background: var(--panel); padding: 2px 6px; border-radius: 6px; }

.page-title { margin: 0 0 16px; font-size: 1.5rem; }

/* Boutons & champs */
.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #33405a;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #2b3650; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1cb5ff; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: rgba(237, 66, 69, 0.12); }
.btn.small { padding: 4px 10px; font-size: 0.8rem; }
.btn.smiley { font-size: 1rem; padding: 4px 10px; }
.btn.smiley.active { border-color: var(--accent); background: rgba(2, 169, 255, 0.15); }

.input {
  background: var(--panel);
  color: var(--text);
  border: 1px solid #33405a;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-family: inherit;
}
.input:focus { outline: none; border-color: var(--accent); }
.input.small { padding: 4px 8px; font-size: 0.8rem; }
.input.grow { flex: 1; min-width: 160px; }
textarea.input { resize: vertical; width: 100%; }

/* Barre de recherche */
.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

/* Grille de cartes */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}

.card { display: flex; flex-direction: column; gap: 6px; color: var(--text); }
.card:hover { text-decoration: none; }
.card:hover .card-title { color: var(--accent-2); }

.card-cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card:hover .card-cover { outline: 2px solid var(--ring, var(--accent)); }

.badge {
  position: absolute;
  top: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
}
.badge.score { left: 6px; color: #ffd76a; }
.badge.entry { right: 6px; background: rgba(2, 169, 255, 0.9); }

/* Action rapide « +1 » sur les cartes de recherche */
.card-quick {
  position: absolute;
  right: 6px;
  bottom: 10px;
  padding: 4px 9px;
  font-size: 0.78rem;
  line-height: 1.2;
  background: rgba(11, 14, 19, 0.85);
  border-color: rgba(2, 169, 255, 0.55);
}
.card:hover .card-quick { background: var(--accent); border-color: var(--accent); }
.card-quick:disabled { opacity: 0.5; }

.status-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
}

.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.card-sub {
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.center { display: flex; justify-content: center; margin-top: 20px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px 0; justify-content: center; }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--panel-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  background: rgba(237, 66, 69, 0.12);
  border: 1px solid var(--danger);
  color: #ffb3b5;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin: 16px 0;
  white-space: pre-line;
}

.empty { text-align: center; padding: 48px 0; }
.empty-grid { grid-column: 1 / -1; text-align: center; padding: 24px 0; }
.muted { color: var(--muted); }

/* Page détail */
.detail-banner {
  height: 220px;
  margin: -24px -20px 0;
  background-size: cover;
  background-position: center 30%;
  position: relative;
}
.detail-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(11, 14, 19, 0.25), var(--bg) 96%);
}

.detail-body { position: relative; z-index: 1; }

.detail-head {
  display: flex;
  gap: 24px;
  margin-top: -90px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.detail-cover {
  width: 200px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.detail-info { flex: 1; min-width: 260px; }
.detail-info h1 { margin: 0 0 4px; font-size: 1.7rem; }
.detail-sub { margin: 0; color: var(--muted); font-size: 1.05rem; }
.detail-native { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }
.detail-meta { color: var(--muted); font-size: 0.9rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip {
  background: var(--panel-2);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  color: var(--muted);
}

.detail-stats { display: flex; gap: 28px; margin: 12px 0; }
.stat-value { font-size: 1.15rem; font-weight: 700; }
.stat-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.airing { color: #7ee2a8; font-weight: 600; }
.adult-warning { color: #ffb3b5; font-weight: 600; }

.panel {
  background: var(--bg-soft);
  border: 1px solid #232c40;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-top: 20px;
}
.panel h2 { margin: 0 0 12px; font-size: 1.1rem; }
.synopsis { white-space: pre-line; line-height: 1.6; color: #cdd5e3; margin: 0; }

.rel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.rel-card {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--panel);
  border: 1px solid #2a3450;
  border-radius: 8px;
  padding: 8px;
  color: var(--text);
}
.rel-card:hover { text-decoration: none; border-color: var(--accent); }
.rel-card img { width: 42px; height: 60px; object-fit: cover; border-radius: 6px; }
.rel-type { display: block; font-size: 0.7rem; color: var(--accent-2); font-weight: 700; text-transform: uppercase; }
.rel-title { font-size: 0.85rem; font-weight: 600; }

/* Panneau d'édition de l'entrée de liste */
.entry-panel {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid #2a3450;
  border-radius: var(--radius);
  padding: 14px 16px;
}
.entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.progress-row { display: flex; align-items: center; gap: 8px; }
.prog { font-weight: 700; min-width: 64px; text-align: center; }
.score-row { display: flex; align-items: center; gap: 8px; }
.smiley-row { display: flex; gap: 6px; }
.entry-actions { margin-top: 12px; display: flex; justify-content: flex-end; }

/* Onglets */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tab {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid #2a3450;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Liste de suivi */
.list-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.list-stats { margin: 0; }
.list-section-title { display: flex; align-items: baseline; gap: 6px; }
.rows { display: flex; flex-direction: column; }

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 4px;
  border-bottom: 1px solid #232c40;
  flex-wrap: wrap;
}
.row:last-child { border-bottom: none; }
.row-cover img { width: 40px; height: 56px; object-fit: cover; border-radius: 6px; display: block; }
.row-main { flex: 1; min-width: 180px; }
.row-title { color: var(--text); font-weight: 600; font-size: 0.92rem; }
.row-title:hover { color: var(--accent-2); }
.row-meta { color: var(--muted); font-size: 0.78rem; }
.row-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.score-input { width: 72px; }
.score-cell .input { width: 64px; }

/* Édition en lot */
.row-check {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.row.selected { background: rgba(2, 169, 255, 0.07); }

.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px solid #232c40;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.bulk-count { font-weight: 600; min-width: 130px; }
.bulk-sep { width: 1px; height: 22px; background: #2a3450; }
.bulk-bar .input { max-width: 120px; }

/* Toasts */
#toast-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}
.toast {
  background: var(--panel-2);
  border: 1px solid #33405a;
  border-left: 4px solid var(--accent);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  max-width: 340px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { border-left-color: var(--danger); }

@media (max-width: 640px) {
  .detail-head { margin-top: -60px; }
  .detail-cover { width: 130px; }
  .topbar { flex-wrap: wrap; gap: 10px; }
}
