/* ════════════════════════════════════════════════════════
   MangaShelf — style.css
   Dark navy aesthetic · Outfit + JetBrains Mono
   ════════════════════════════════════════════════════════ */

:root {
  --bg:        #0f1729;
  --bg2:       #131d35;
  --bg3:       #192240;
  --surface:   #1e2d4d;
  --surface2:  #243459;
  --border:    rgba(255,255,255,0.08);
  --border2:   rgba(255,255,255,0.14);
  --accent:    #3b82f6;
  --accent-h:  #2563eb;
  --accent2:   #f59e0b;
  --success:   #22c55e;
  --danger:    #ef4444;
  --text:      #e8edf8;
  --text-mid:  #8da0c4;
  --text-muted:#4f6490;
  --nav-h:     68px;
  --radius:    10px;
  --radius-sm: 6px;
  --font:      'Outfit', sans-serif;
  --mono:      'JetBrains Mono', monospace;
  --shadow:    0 8px 32px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.6);
  /* Status colours — shared by badges and card borders */
  --status-reading:   #22c55e;
  --status-planned:   #6b7280;
  --status-completed: #3b82f6;
  --status-dropped:   #ef4444;
  --status-paused:    #eab308;
  --status-hiatus:    #f97316;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  overflow-x: hidden;
  /* subtle grid texture */
  background-image:
    radial-gradient(circle at 20% 80%, rgba(59,130,246,0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(99,102,241,0.04) 0%, transparent 50%);
}

/* ══════════════ SCROLLBAR ══════════════ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ══════════════ NAVBAR ══════════════ */
.navbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-h);
  background: rgba(15,23,41,0.92);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 200px 1fr auto;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  z-index: 800;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}

.nav-brand {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* URL BAR */
.url-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 0.4rem 0.5rem 0.4rem 1rem;
  transition: border-color 0.2s;
}
.url-bar-wrap:focus-within { border-color: var(--accent); }

.url-bar {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  outline: none;
  min-width: 0;
}
.url-bar::placeholder { color: var(--text-muted); }

.url-help {
  background: var(--surface2);
  border: none;
  color: var(--text-mid);
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.url-help:hover { background: var(--accent); color: white; }

.url-confirm {
  background: var(--accent);
  border: none;
  color: white;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}
.url-confirm:hover { background: var(--accent-h); }
.url-confirm:active { transform: scale(0.97); }

.url-add-btn {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-mid);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}
.url-add-btn:hover { border-color: var(--accent); color: var(--accent); }

.nav-right { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; }

.nav-updates-btn {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-mid);
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.nav-updates-btn:hover { border-color: var(--accent); color: var(--accent); }

.updates-badge {
  position: absolute;
  top: -6px; right: -6px;
  background: var(--danger);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}

/* Profile button in navbar */
.nav-profile-btn {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-mid);
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  transition: all 0.2s;
  padding: 0;
  font-size: 1.1rem;
}
.nav-profile-btn:hover { border-color: var(--accent); }
.nav-profile-btn img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: calc(var(--radius-sm) - 1px);
}

/* ══════════════ MAIN ══════════════ */
.main {
  padding: calc(var(--nav-h) + 1.5rem) 1.5rem 3rem;
  max-width: 1600px;
  margin: 0 auto;
}

/* ══════════════ TOOLBAR ══════════════ */
.toolbar {
  margin-bottom: 1rem;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-field {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  width: 240px;
  outline: none;
  transition: border-color 0.2s;
}
.search-field:focus { border-color: var(--accent); }
.search-field::placeholder { color: var(--text-muted); }

.toolbar-select {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
}

.discord-btn {
  background: #5865F2;
  border: none;
  color: white;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; gap: 0.4rem;
  transition: opacity 0.2s;
}
.discord-btn:hover { opacity: 0.85; }

.total-count {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}

.btn-random {
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text);
  font-size: 1.1rem;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.btn-random:hover { border-color: var(--accent); transform: rotate(20deg) scale(1.1); }

/* ══════════════ FILTERS ══════════════ */
.filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-group { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.filter-divider {
  width: 1px; height: 24px;
  background: var(--border2);
  flex-shrink: 0;
}

.filter-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-mid);
  padding: 0.3rem 1rem;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
}
.filter-chip:hover { border-color: var(--accent); color: var(--text); }
.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}

/* ══════════════ GRID ══════════════ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 1.25rem;
}

/* ══════════════ CARD ══════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.22s, box-shadow 0.22s, border-color 0.22s;
  animation: fadeUp 0.3s ease both;
  position: relative;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 36px rgba(0,0,0,0.5);
  border-color: var(--border2);
}

.card.has-update { border-top: 2px solid var(--accent2); }

/* Cover */
.card-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2/3;
  overflow: hidden;
  background: var(--bg3);
}

.card-cover {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s;
}
.card:hover .card-cover { transform: scale(1.04); }

.card-cover-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.8rem;
  background: linear-gradient(135deg, var(--bg3), var(--surface2));
}

/* Badges on cover */
.card-site-badge {
  position: absolute;
  top: 0.4rem; left: 0.4rem;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  color: #ccc;
  font-family: var(--mono);
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: 4px;
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-type-badge {
  position: absolute;
  top: 0.4rem; right: 0.4rem;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.card-share-btn {
  position: absolute;
  top: 2rem; right: 0.4rem;
  background: rgba(0,0,0,0.6);
  border: none;
  color: #ccc;
  width: 24px; height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.7rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.card:hover .card-share-btn { opacity: 1; }

.card-status-badge {
  position: absolute;
  bottom: 0.4rem; left: 0.4rem;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
}

.badge-manga   { background: rgba(59,130,246,0.85); color: white; }
.badge-manhwa  { background: rgba(34,197,94,0.85); color: white; }
.badge-manhua  { background: rgba(239,68,68,0.85); color: white; }
.badge-autre   { background: rgba(168,85,247,0.85); color: white; }

.badge-reading   { background: color-mix(in srgb, var(--status-reading)   85%, transparent); color: white; }
.badge-planned   { background: color-mix(in srgb, var(--status-planned)   85%, transparent); color: white; }
.badge-completed { background: color-mix(in srgb, var(--status-completed) 85%, transparent); color: white; }
.badge-dropped   { background: color-mix(in srgb, var(--status-dropped)   85%, transparent); color: white; }
.badge-paused    { background: color-mix(in srgb, var(--status-paused)    85%, transparent); color: white; }
.badge-hiatus    { background: color-mix(in srgb, var(--status-hiatus)    85%, transparent); color: white; }

.card-fav {
  position: absolute;
  bottom: 0.4rem; right: 0.4rem;
  color: var(--accent2);
  font-size: 1rem;
}

/* Card body */
.card-body {
  padding: 0.75rem 0.75rem 0.85rem;
  border-left: 3px solid transparent;
  border-bottom-left-radius: var(--radius);
}
.card-body.status-reading   { border-left-color: var(--status-reading); }
.card-body.status-planned   { border-left-color: var(--status-planned); }
.card-body.status-completed { border-left-color: var(--status-completed); }
.card-body.status-dropped   { border-left-color: var(--status-dropped); }
.card-body.status-paused    { border-left-color: var(--status-paused); }
.card-body.status-hiatus    { border-left-color: var(--status-hiatus); }

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.card-chapter {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-mid);
  margin-bottom: 0.25rem;
}

.card-time {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.card-continue {
  display: block;
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-mid);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem;
  text-align: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin-top: 0.75rem;
  transition: all 0.2s;
  text-decoration: none;
}
.card-continue:hover { background: var(--accent); border-color: var(--accent); color: white; }

/* ══════════════ EMPTY ══════════════ */
.empty-state {
  text-align: center;
  padding: 6rem 2rem;
  animation: fadeUp 0.4s ease;
}
.empty-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.empty-state h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-muted); font-size: 0.9rem; }

/* ══════════════ SIDE PANEL ══════════════ */
.side-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(420px, 100vw);
  height: 100vh;
  background: var(--bg2);
  border-left: 1px solid var(--border2);
  z-index: 900;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(0,0,0,0.4);
}
.side-panel.open { transform: translateX(0); }

.side-panel-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 899;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.side-panel-overlay.open { opacity: 1; pointer-events: all; }

.side-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.side-panel-header h2 { font-size: 1.1rem; font-weight: 700; }

.panel-close {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}
.panel-close:hover { border-color: var(--danger); color: var(--danger); }

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

.panel-actions {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}

.btn-refresh {
  background: var(--accent);
  border: none;
  color: white;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-refresh:hover { opacity: 0.85; }

.last-check-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.checking-wrap {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem; color: var(--text-muted);
  font-size: 0.875rem;
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.updates-feed { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.5rem; }

.panel-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* Update item */
.update-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  transition: border-color 0.2s;
}
.update-item.has-new { border-left: 3px solid var(--accent2); }
.update-item:hover { border-color: var(--border2); }

.update-thumb {
  width: 40px; height: 54px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg3);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  overflow: hidden;
}
.update-thumb img { width: 100%; height: 100%; object-fit: cover; }

.update-info { flex: 1; min-width: 0; }
.update-title {
  font-size: 0.85rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 0.2rem;
}
.update-sub { font-family: var(--mono); font-size: 0.7rem; color: var(--text-muted); margin-bottom: 0.3rem; }
.update-new { font-family: var(--mono); font-size: 0.72rem; color: var(--accent2); font-weight: 600; }

.update-btns { display: flex; flex-direction: column; gap: 0.3rem; flex-shrink: 0; }

.btn-read {
  background: var(--accent2);
  border: none;
  color: #000;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: block; text-align: center;
  transition: opacity 0.2s;
}
.btn-read:hover { opacity: 0.85; }

.btn-mark-read {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-muted);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-family: var(--font);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-mark-read:hover { border-color: var(--success); color: var(--success); }

/* Manual item */
.manual-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.manual-item-info { min-width: 0; }
.manual-item-title { font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.manual-item-chap  { font-family: var(--mono); font-size: 0.68rem; color: var(--text-muted); }
.manual-item-actions { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.chap-mini-input {
  width: 58px;
  background: var(--bg);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  text-align: center;
  outline: none;
}
.btn-upd {
  background: var(--success);
  border: none; color: #000;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-upd:hover { opacity: 0.85; }

/* ══════════════ MODAL ══════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  z-index: 850;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 14px;
  width: 100%; max-width: 560px;
  max-height: 90vh;
  overflow: hidden;
  position: relative;
  transform: translateY(24px) scale(0.97);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  box-shadow: var(--shadow-lg);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal--sm { max-width: 440px; }

/* Modal background (cover blur) */
.modal-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  filter: blur(40px) brightness(0.15) saturate(1.5);
  opacity: 0.8;
  z-index: 0;
}

.modal-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  max-height: 90vh;
  overflow-y: auto;
}

/* Modal header */
.modal-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.5rem 1.5rem 1rem;
  background: rgba(15,23,41,0.6);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: relative;
}

.modal-cover {
  width: 72px; height: 96px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--bg3);
  flex-shrink: 0;
}

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

.modal-label-small {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.35rem;
}

.modal-title-input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s;
}
.modal-title-input:focus { border-color: var(--accent); }

.modal-header-actions {
  display: flex; gap: 0.4rem;
  margin-top: 0.5rem;
}

.modal-icon-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  color: var(--text-mid);
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.modal-icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.modal-icon-btn.active { color: var(--accent2); border-color: var(--accent2); }

.modal-close-btn {
  position: absolute;
  top: 1rem; right: 1rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.modal-close-btn:hover { border-color: var(--danger); color: var(--danger); }

/* Modal fields */
.modal-fields {
  padding: 1.25rem 1.5rem;
  display: flex; flex-direction: column;
  gap: 1rem;
}

.field-row { display: flex; gap: 1rem; }

.field-group { display: flex; flex-direction: column; gap: 0.35rem; }

.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-mid);
  letter-spacing: 0.02em;
}

.field-input {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
.field-input:focus { border-color: var(--accent); }
.field-input::placeholder { color: var(--text-muted); }

.field-select {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  width: 100%;
}

.field-hint {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.field-details {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.field-summary {
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  list-style: none;
  display: flex; justify-content: space-between;
  user-select: none;
}
.field-summary::-webkit-details-marker { display: none; }
details[open] .field-summary .arrow { transform: rotate(90deg); }
.arrow { display: inline-block; transition: transform 0.2s; font-size: 0.7rem; }
details[open] .field-details > *:not(summary) { padding: 0 0.85rem; }

.field-textarea {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  outline: none;
  width: 100%;
  resize: vertical;
  transition: border-color 0.2s;
}
.field-textarea:focus { border-color: var(--accent); }

.type-toggle {
  background: var(--accent);
  border: none;
  color: white;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s;
}

/* Modal footer */
.modal-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1px solid var(--border);
  background: rgba(15,23,41,0.4);
}

.btn-delete {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger);
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.btn-delete:hover { background: rgba(239,68,68,0.25); }

.btn-cancel {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-mid);
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  margin-left: auto;
  transition: all 0.2s;
}
.btn-cancel:hover { border-color: var(--text-mid); color: var(--text); }

.btn-save {
  background: var(--accent);
  border: none;
  color: white;
  padding: 0.55rem 1.4rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn-save:hover { background: var(--accent-h); }
.btn-save:active { transform: scale(0.97); }

/* ══════════════ HELP TOOLTIP ══════════════ */
.help-tooltip {
  position: fixed;
  top: calc(var(--nav-h) + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  max-width: 360px;
  width: 90%;
  z-index: 820;
  box-shadow: var(--shadow);
  animation: fadeUp 0.2s ease;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-mid);
}
.help-tooltip h4 { color: var(--text); font-size: 0.9rem; margin-bottom: 0.5rem; }

/* ══════════════ TOASTS ══════════════ */
.toast-stack {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  z-index: 9999;
}
.toast {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 500;
  min-width: 220px;
  animation: slideIn 0.3s ease;
  display: flex; align-items: center; gap: 0.5rem;
  box-shadow: var(--shadow);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ══════════════ RESPONSIVE ══════════════ */
@media (max-width: 900px) {
  .navbar { grid-template-columns: auto 1fr auto; }
}

/* ── Tablette (600-900px) ── */
@media (max-width: 900px) and (min-width: 601px) {
  .nav-brand { display: none; }
}

/* ── Mobile (≤600px) ── */
@media (max-width: 600px) {

  /* Navbar : logo | cloche sur une ligne, URL bar dessous */
  .navbar {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    height: auto;
    padding: 0.6rem 0.75rem;
    gap: 0.4rem 0.6rem;
  }

  /* Logo reste sur la première ligne à gauche */
  .nav-left { grid-column: 1; grid-row: 1; }

  /* Cloche reste sur la première ligne à droite */
  .nav-right { grid-column: 3; grid-row: 1; }

  /* URL bar prend toute la largeur sur la 2e ligne */
  .nav-center {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  /* URL bar : masquer le bouton "? Aide" et "Confirmer" texte, garder icônes */
  .url-help { display: none; }
  .url-confirm { padding: 0.4rem 0.65rem; font-size: 0.75rem; }
  .url-add-btn { padding: 0.4rem 0.65rem; font-size: 0.75rem; }

  /* Padding main ajusté à la nouvelle hauteur navbar (~110px) */
  .main {
    padding-top: 115px;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    padding-bottom: 5rem; /* espace pour le widget auth en bas */
  }

  /* Grille : 2 colonnes fixes sur mobile */
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }

  /* Toolbar : colonne */
  .toolbar-left {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .search-field { width: 100%; }
  .toolbar-select { width: 100%; }
  .total-count { margin-left: 0; }

  /* Filtres : scroll horizontal pour ne pas wrapper trop */
  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filters::-webkit-scrollbar { display: none; }
  .filter-group { flex-wrap: nowrap; }
  .filter-divider { flex-shrink: 0; }

  /* Cards : texte plus compact */
  .card-title { font-size: 0.8rem; }
  .card-chapter { font-size: 0.72rem; }
  .card-time { font-size: 0.65rem; }
  .card-continue { font-size: 0.72rem; padding: 0.3rem 0.5rem; }

  /* Toasts : pleine largeur en bas */
  .toast-stack {
    bottom: 4.5rem;
    right: 0.75rem;
    left: 0.75rem;
  }
  .toast { min-width: 0; width: 100%; }

  /* Modal : plein écran sur mobile */
  .modal-overlay { align-items: flex-end; }
  .modal {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 92dvh;
  }
  .modal--sm { border-radius: var(--radius) var(--radius) 0 0; }
}

/* ══════════════ META INFO (genres, score) ══════════════ */
.meta-info {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: .25rem 0 .5rem;
}

.genre-chip {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text-mid);
  font-size: .7rem;
  padding: .2rem .55rem;
  border-radius: 20px;
  white-space: nowrap;
}

.score-badge {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  padding: .2rem .6rem;
  border-radius: 20px;
}
.score-badge small { font-size: .65rem; font-weight: 400; opacity: .85; }

.pub-status-chip {
  background: var(--surface2);
  color: var(--text-mid);
  font-size: .7rem;
  padding: .2rem .55rem;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ══════════════ ALT NAMES ══════════════ */
.modal-alt-names-section {
  margin: .25rem 0 .5rem;
}
.modal-alt-names-section .field-label {
  margin-bottom: .4rem;
}
.alt-names-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.alt-name-chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .7rem;
  padding: .18rem .5rem;
  border-radius: 20px;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* ══════════════ ADD MODAL — SEARCH ══════════════ */
.add-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.add-search-wrap .field-input { flex: 1; }

.add-search-spinner {
  position: absolute;
  right: .75rem;
  width: 14px; height: 14px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  opacity: 0;
  transition: opacity .2s;
}
.add-search-spinner.active {
  opacity: 1;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.add-search-results {
  margin-top: .4rem;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}

.add-result-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .8rem;
  cursor: pointer;
  transition: background .15s;
  border-bottom: 1px solid var(--border);
}
.add-result-item:last-child { border-bottom: none; }
.add-result-item:hover { background: var(--surface); }

.add-result-cover {
  width: 40px; height: 56px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg3);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.add-result-cover img { width: 100%; height: 100%; object-fit: cover; }

.add-result-info { flex: 1; min-width: 0; }
.add-result-title {
  font-size: .875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.add-result-sub {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: .2rem;
  text-transform: capitalize;
}
.add-result-source {
  color: var(--accent);
  font-weight: 500;
}

/* Selected preview */
.add-selected-preview {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--bg3);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: .6rem .8rem;
  margin-bottom: .25rem;
}
.add-selected-cover {
  width: 40px; height: 56px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}
.add-selected-info { flex: 1; min-width: 0; }
.add-selected-title {
  font-size: .9rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.add-selected-meta {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: .15rem;
  text-transform: capitalize;
}
.add-selected-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: .25rem;
  font-size: .9rem;
  flex-shrink: 0;
}
.add-selected-clear:hover { color: var(--danger); }

/* ══════════════ NSFW BLUR ══════════════ */
.cover-nsfw {
  filter: blur(12px);
  transition: filter .3s;
}
.card-cover-wrap:hover .cover-nsfw {
  filter: blur(0);
}
.cover-nsfw-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(0,0,0,0.35);
  pointer-events: none;
  transition: opacity .3s;
}
.card-cover-wrap:hover .cover-nsfw-overlay {
  opacity: 0;
}

/* ══════════════ PROFILE PANEL ══════════════ */
.profile-user-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}
.profile-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}
.profile-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.profile-user-info { flex: 1; min-width: 0; }
.profile-user-name { font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-user-email { font-size: .75rem; color: var(--text-muted); margin-top: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.profile-signin-wrap {
  text-align: center;
  padding: 1.5rem 0;
}
.profile-signin-wrap p { font-size: .875rem; color: var(--text-muted); margin-bottom: 1rem; }
.btn-google-signin {
  display: inline-flex; align-items: center; gap: .6rem;
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: .6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-google-signin:hover { border-color: var(--accent); }

.btn-signout {
  width: 100%;
  background: none;
  border: 1px solid var(--border2);
  color: var(--danger);
  padding: .55rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .8rem;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: .75rem;
}
.btn-signout:hover { background: rgba(239,68,68,.1); border-color: var(--danger); }

.btn-export {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  display: flex; align-items: center; gap: .5rem;
}
.btn-export:hover { border-color: var(--accent); color: var(--accent); }

/* Theme swatches */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .5rem;
  margin-top: .6rem;
  margin-bottom: 1.5rem;
}
.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  cursor: pointer;
}
.theme-swatch-color {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.theme-swatch-color::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: calc(var(--radius-sm) - 2px);
}
.theme-swatch.active .theme-swatch-color { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-swatch-label { font-size: .65rem; color: var(--text-muted); text-align: center; }
.theme-swatch.active .theme-swatch-label { color: var(--accent); font-weight: 600; }
