:root {
  --bg-base: #0b0d14;
  --bg-surface: #131622;
  --bg-elevated: #1b2032;
  --bg-hover: #242a42;
  --border-subtle: rgba(148, 163, 184, 0.12);
  --border-accent: rgba(139, 92, 246, 0.45);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --accent-light: #c4b5fd;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.65);
}

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

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: "Be Vietnam Pro", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

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

button,
input,
select {
  font-family: inherit;
}

/* ============================================================================
 * SPINNER & BOOT LOADER
 * ============================================================================ */
.boot-loader {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.rinnegan-spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid rgba(139, 92, 246, 0.2);
  border-top-color: var(--accent-light);
  box-shadow: inset 0 0 12px rgba(139, 92, 246, 0.35), 0 0 20px rgba(139, 92, 246, 0.25);
  animation: spin 0.9s linear infinite;
}

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

/* ============================================================================
 * LOGIN & ACCESS DENIED GATE
 * ============================================================================ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(circle at 50% 15%, rgba(124, 58, 237, 0.22), transparent 52%),
    radial-gradient(circle at 85% 85%, rgba(59, 130, 246, 0.1), transparent 45%),
    var(--bg-base);
}

.auth-card {
  width: 100%;
  max-width: 450px;
  background: rgba(19, 22, 34, 0.92);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(16px);
  text-align: center;
}

.brand-emblem {
  width: 96px;
  height: 96px;
  margin: 0 auto 18px;
  display: block;
  border-radius: 22px;
  object-fit: cover;
  border: 1.5px solid rgba(167, 139, 250, 0.45);
  box-shadow: 0 0 28px rgba(139, 92, 246, 0.42);
}

.auth-title {
  margin: 0 0 8px;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  margin: 0 0 26px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.55;
}

.google-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.auth-note {
  margin-top: 20px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.55;
  text-align: left;
}

.denied-box {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  text-align: left;
}

.denied-box h3 {
  margin: 0 0 6px;
  color: #fca5a5;
  font-size: 0.98rem;
}

.denied-box p {
  margin: 0;
  color: #e2e8f0;
  font-size: 0.87rem;
  line-height: 1.55;
}

.setup-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 18px;
  text-align: left;
  font-size: 0.85rem;
  color: #fde68a;
  line-height: 1.55;
}

/* ============================================================================
 * BUTTONS
 * ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  user-select: none;
}

.btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: rgba(148, 163, 184, 0.28);
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

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

.btn-soft:hover:not(:disabled) {
  background: rgba(139, 92, 246, 0.26);
}

.btn-block {
  width: 100%;
}

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

/* ============================================================================
 * TOP NAVBAR
 * ============================================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 13, 20, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: -0.01em;
}

.brand-link img,
.navbar-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid rgba(167, 139, 250, 0.35);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.3);
}

.brand-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-light);
  border: 1px solid var(--border-accent);
}

.search-box {
  flex: 1 1 280px;
  max-width: 480px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 9px 36px 9px 38px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.9rem;
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 1rem;
  line-height: 1;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  max-width: 220px;
}

.user-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
  object-fit: cover;
}

/* ============================================================================
 * MAIN CONTAINER & SHELVES
 * ============================================================================ */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 18px 64px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1.08rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Lịch sử đọc gần đây */
.history-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 290px);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 26px;
  scrollbar-width: thin;
}

.history-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: transform 0.15s, border-color 0.15s;
}

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

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

.history-meta {
  min-width: 0;
  flex: 1;
}

.history-meta h4 {
  margin: 0 0 4px;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--accent-light);
}

/* Filter Tabs */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

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

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

.tab-count {
  font-size: 0.74rem;
  opacity: 0.82;
  margin-left: 4px;
}

/* ============================================================================
 * COMIC GRID
 * ============================================================================ */
.comic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 18px;
}

@media (min-width: 768px) {
  .comic-grid {
    grid-template-columns: repeat(auto-fill, minmax(182px, 1fr));
    gap: 22px;
  }
}

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

.comic-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-accent);
  box-shadow: var(--shadow-card);
}

.cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 7;
  background: var(--bg-elevated);
  overflow: hidden;
}

.cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.comic-card:hover .cover-wrap img {
  transform: scale(1.04);
}

.status-pill {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.status-ongoing {
  background: rgba(16, 185, 129, 0.85);
  color: #fff;
}

.status-completed {
  background: rgba(100, 116, 139, 0.88);
  color: #f8fafc;
}

.fav-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(15, 23, 42, 0.78);
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.92rem;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.14s, color 0.14s, background 0.14s;
}

.fav-badge:hover {
  transform: scale(1.1);
  background: rgba(15, 23, 42, 0.94);
  color: #fde68a;
}

.fav-badge.is-fav {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.55);
}

.continue-ribbon {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 8px;
  background: linear-gradient(to top, rgba(11, 13, 20, 0.95), rgba(11, 13, 20, 0.65), transparent);
  color: var(--accent-light);
  font-size: 0.74rem;
  font-weight: 600;
}

.comic-info {
  padding: 11px 12px 13px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.comic-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
}

/* ============================================================================
 * COMIC DETAIL PAGE
 * ============================================================================ */
.comic-hero {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 24px;
  margin-bottom: 24px;
}

.comic-hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(28px) brightness(0.28);
  transform: scale(1.15);
  pointer-events: none;
}

.comic-hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

@media (max-width: 640px) {
  .comic-hero-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

.detail-cover {
  width: 175px;
  aspect-ratio: 5 / 7;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.detail-meta {
  flex: 1;
  min-width: 0;
}

.detail-meta h1 {
  margin: 6px 0 12px;
  font-size: clamp(1.3rem, 3vw, 1.9rem);
  line-height: 1.3;
}

.detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

@media (max-width: 640px) {
  .detail-stats {
    justify-content: center;
  }
}

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

@media (max-width: 640px) {
  .detail-actions {
    justify-content: center;
  }
}

.chapter-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}

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

.chapter-filter-input {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 0.86rem;
  width: 210px;
  outline: none;
}

.chapter-filter-input:focus {
  border-color: var(--accent);
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 10px;
  max-height: 620px;
  overflow-y: auto;
  padding-right: 4px;
}

.chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.87rem;
  font-weight: 600;
  transition: all 0.14s ease;
}

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

.chapter-item.is-read {
  opacity: 0.62;
  background: rgba(255, 255, 255, 0.025);
}

.chapter-item.is-last-read {
  opacity: 1;
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-light);
}

.chap-subtag {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ============================================================================
 * VERTICAL WEBTOON / MANGA READER
 * ============================================================================ */
.reader-shell {
  min-height: 100vh;
  background: #05060a;
  position: relative;
  user-select: none;
}

.reader-progress-track {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  z-index: 60;
}

.reader-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7c3aed, #c084fc);
  transition: width 0.1s linear;
}

.reader-hud-top {
  position: fixed;
  top: 3px;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(11, 13, 20, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: transform 0.24s ease, opacity 0.24s ease;
}

.reader-hud-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(11, 13, 20, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.24s ease, opacity 0.24s ease;
}

.reader-shell.hud-hidden .reader-hud-top {
  transform: translateY(-110%);
  opacity: 0;
  pointer-events: none;
}

.reader-shell.hud-hidden .reader-hud-bottom {
  transform: translateY(110%);
  opacity: 0;
  pointer-events: none;
}

.reader-title-group {
  min-width: 0;
  flex: 1;
}

.reader-comic-name {
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.reader-chap-label {
  font-size: 0.75rem;
  color: var(--accent-light);
}

.reader-select {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 175px;
  outline: none;
}

.reader-settings-drawer {
  position: fixed;
  top: 60px;
  right: 14px;
  z-index: 55;
  width: 280px;
  background: var(--bg-surface);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.8);
}

.setting-row {
  margin-bottom: 14px;
}

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

.setting-row label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.setting-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.reader-canvas {
  margin: 0 auto;
  padding-top: 56px;
  padding-bottom: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.reader-canvas.width-sm {
  max-width: 600px;
}

.reader-canvas.width-md {
  max-width: 780px;
}

.reader-canvas.width-lg {
  max-width: 980px;
}

.reader-canvas.width-full {
  max-width: 100%;
}

.reader-canvas.gap-spaced {
  gap: 14px;
}

.page-slot {
  width: 100%;
  position: relative;
  min-height: 220px;
  background: #0b0d14;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-slot.loaded {
  min-height: 0;
  background: transparent;
}

.page-slot img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}

.page-placeholder {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.reader-end-nav {
  max-width: 640px;
  margin: 28px auto 40px;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

/* Watermark chống leak kín đáo gắn theo email người đọc */
.reader-watermark {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 35;
  overflow: hidden;
  opacity: 0.045;
  display: flex;
  flex-wrap: wrap;
  align-content: space-around;
  justify-content: space-around;
  gap: 90px;
  padding: 40px;
}

.reader-watermark span {
  transform: rotate(-24deg);
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
}

/* ============================================================================
 * TOAST NOTIFICATION
 * ============================================================================ */
.toast-root {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-accent);
  color: var(--text-primary);
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  animation: fadeUp 0.2s ease;
}

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

/* ============================================================================
 * MODAL ĐỔI ẢNH BÌA (DÀNH CHO ADMIN)
 * ============================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(5, 6, 12, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.dropzone {
  border: 2px dashed var(--border-accent);
  border-radius: var(--radius-md);
  background: rgba(139, 92, 246, 0.06);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s;
}

.dropzone:hover,
.dropzone.dragover {
  background: rgba(139, 92, 246, 0.14);
  border-color: var(--accent-light);
}

.cover-search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.cover-candidate {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border-subtle);
  background: var(--bg-elevated);
  cursor: pointer;
  aspect-ratio: 5 / 7;
  padding: 0;
  transition: transform 0.14s, border-color 0.14s;
}

.cover-candidate:hover {
  transform: translateY(-2px);
  border-color: var(--accent-light);
}

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

.cover-candidate-src {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(11, 13, 20, 0.82);
  color: var(--accent-light);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}
