/* ========================================================
   MangaFreak Scraper App - Premium Dark Theme CSS
   ======================================================== */

:root {
  --bg-primary: #0d0d14;
  --bg-secondary: #13131f;
  --bg-card: #1a1a2e;
  --bg-card-hover: #22223b;
  --bg-sidebar: #0f0f1a;
  --accent: #e94560;
  --accent-2: #8b5cf6;
  --accent-3: #f59e0b;
  --text-primary: #f0f0ff;
  --text-secondary: #9898b8;
  --text-muted: #5a5a7a;
  --border: #2a2a45;
  --border-hover: #4a4a70;
  --gradient-1: linear-gradient(135deg, #e94560, #8b5cf6);
  --gradient-2: linear-gradient(135deg, #667eea, #764ba2);
  --gradient-3: linear-gradient(135deg, #f093fb, #f5576c);
  --sidebar-width: 240px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.4);
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-height);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  overflow: hidden;
}

.logo-icon { font-size: 1.6rem; flex-shrink: 0; }
.logo-text {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-footer { display: none; }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--text-primary); background: var(--border); }

.nav-links {
  list-style: none;
  padding: 12px 8px;
  flex: 1;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

.nav-icon { font-size: 1.1rem; flex-shrink: 0; }

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.nav-link.active {
  color: var(--text-primary);
  background: linear-gradient(135deg, rgba(233,69,96,0.2), rgba(139,92,246,0.2));
  border: 1px solid rgba(233,69,96,0.3);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--gradient-1);
  border-radius: 0 3px 3px 0;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* ============ MAIN WRAPPER ============ */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.main-wrapper.sidebar-collapsed { margin-left: var(--sidebar-collapsed); }

/* ============ TOPBAR ============ */
.topbar {
  position: sticky; top: 0;
  z-index: 50;
  height: var(--topbar-height);
  background: rgba(13,13,20,0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.menu-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: none;
}
.menu-btn:hover { color: var(--text-primary); background: var(--border); }

.topbar-search {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  gap: 8px;
  flex: 1;
  max-width: 400px;
  transition: border-color var(--transition);
}
.topbar-search:focus-within { border-color: var(--accent); }

.topbar-search input {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.9rem;
  width: 100%;
  padding: 10px 0;
  outline: none;
}
.topbar-search input::placeholder { color: var(--text-muted); }

.topbar-search button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  transition: color var(--transition);
  padding: 4px;
}
.topbar-search button:hover { color: var(--accent); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }

.bookmark-count {
  background: var(--accent);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  min-width: 24px;
  text-align: center;
}

/* ============ PAGES ============ */
.page { display: none; padding: 32px; animation: fadeIn 0.3s ease; }
.page.active { display: block; }

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

.page-header { margin-bottom: 32px; }
.page-header h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}
.page-header p { color: var(--text-secondary); font-size: 0.95rem; }

.section-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 32px 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============ MANGA GRID ============ */
.manga-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.manga-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  group: true;
}

.manga-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 12px 32px rgba(233,69,96,0.2);
}

.manga-card-img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
  background: var(--bg-secondary);
}

.manga-card-img-placeholder {
  width: 100%;
  aspect-ratio: 2/3;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.manga-card-info {
  padding: 10px;
}

.manga-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
  margin-bottom: 4px;
}

.manga-card-chapter {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 500;
}

.manga-card-status {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.manga-card-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.9) 100%);
  opacity: 0;
  transition: opacity var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px;
}

.manga-card:hover .manga-card-overlay { opacity: 1; }

.manga-card-overlay-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  margin-bottom: 4px;
}

.manga-card-actions {
  display: flex;
  gap: 6px;
}

.btn-bookmark {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background var(--transition);
  backdrop-filter: blur(8px);
}
.btn-bookmark:hover { background: var(--accent); }
.btn-bookmark.bookmarked { background: var(--accent); }

/* ============ RELEASES LIST ============ */
.releases-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.release-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all var(--transition);
}

.release-item:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  transform: translateX(4px);
}

.release-img {
  width: 44px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--bg-secondary);
}

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

.release-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.release-chapters { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

.release-chapter-tag {
  background: rgba(233,69,96,0.15);
  border: 1px solid rgba(233,69,96,0.3);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}
.release-chapter-tag:hover { background: var(--accent); color: white; }

.release-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: right;
}

.time-today { color: #22c55e; font-weight: 600; }
.time-yesterday { color: var(--accent-3); }

/* ============ GENRE TAGS ============ */
.genre-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.genre-tag {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.genre-tag:hover {
  border-color: var(--accent-2);
  color: var(--text-primary);
  background: rgba(139,92,246,0.1);
}

.genre-tag.active {
  background: var(--gradient-1);
  border-color: transparent;
  color: white;
  font-weight: 600;
}

/* ============ PAGINATION ============ */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.page-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 40px; height: 40px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}
.page-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: white; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ============ HISTORY & BOOKMARKS ============ */
.history-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.btn-danger {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.4);
  color: #ef4444;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}
.btn-danger:hover { background: #ef4444; color: white; }

.btn-primary {
  background: var(--gradient-1);
  border: none;
  color: white;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(233,69,96,0.3); }

.btn-large { padding: 16px 40px; font-size: 1rem; border-radius: 12px; }

/* ============ RANDOM PAGE ============ */
.random-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding: 40px 0;
}

#randomResult .manga-detail-card { max-width: 600px; }

/* ============ SEARCH PAGE ============ */
.search-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}

.search-input-wrapper {
  display: flex;
  gap: 12px;
}

.search-input-wrapper input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 1rem;
  padding: 14px 20px;
  outline: none;
  transition: border-color var(--transition);
  font-family: 'Inter', sans-serif;
}
.search-input-wrapper input:focus { border-color: var(--accent); }
.search-input-wrapper input::placeholder { color: var(--text-muted); }

.search-filters { display: flex; gap: 12px; flex-wrap: wrap; }

.search-filters select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}

/* ============ EMPTY STATE ============ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-state span { font-size: 4rem; }
.empty-state p { font-size: 1rem; text-align: center; }

/* ============ LOADING ============ */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(13,13,20,0.8);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.loading-overlay.active { opacity: 1; pointer-events: all; }
.loading-overlay p { color: var(--text-secondary); font-size: 0.9rem; }

.spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 300;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: #22c55e; color: #22c55e; }
.toast.error { border-color: var(--accent); color: var(--accent); }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  z-index: 150;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  animation: modalIn 0.3s cubic-bezier(0.4,0,0.2,1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--text-primary);
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
  z-index: 10;
}
.modal-close:hover { background: var(--accent); }

.modal-content { padding: 28px; }

/* Manga Detail in Modal */
.detail-header {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}

.detail-cover {
  width: 140px;
  height: 200px;
  object-fit: cover;
  border-radius: var(--radius);
  flex-shrink: 0;
  border: 2px solid var(--border);
}

.detail-cover-placeholder {
  width: 140px;
  height: 200px;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-primary));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

.detail-meta { flex: 1; }

.detail-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.2;
}

.detail-info { display: flex; flex-direction: column; gap: 6px; }
.detail-info-row { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.detail-info-label { color: var(--text-muted); font-weight: 500; min-width: 70px; }
.detail-info-value { color: var(--text-secondary); }

.detail-status-ongoing { color: #22c55e; font-weight: 600; }
.detail-status-completed { color: var(--accent-3); font-weight: 600; }

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

.detail-read-btn {
  background: var(--gradient-1);
  border: none;
  color: white;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}
.detail-read-btn:hover { opacity: 0.9; transform: translateY(-1px); }

.detail-bookmark-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}
.detail-bookmark-btn:hover { border-color: var(--accent-2); color: var(--accent-2); }
.detail-bookmark-btn.bookmarked { background: rgba(139,92,246,0.15); border-color: var(--accent-2); color: var(--accent-2); }

.detail-sections { border-top: 1px solid var(--border); padding-top: 20px; }
.detail-section-title { font-size: 0.85rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }

.detail-genres { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.detail-genre-tag {
  background: rgba(139,92,246,0.15);
  border: 1px solid rgba(139,92,246,0.3);
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition);
}
.detail-genre-tag:hover { background: var(--accent-2); color: white; }

.chapters-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  gap: 8px;
}
.chapter-item:hover { border-color: var(--accent); background: rgba(233,69,96,0.05); }
.chapter-name { font-size: 0.85rem; font-weight: 500; color: var(--text-primary); flex: 1; }
.chapter-read-btn {
  background: var(--gradient-1);
  border: none;
  color: white;
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
  flex-shrink: 0;
}
.chapter-read-btn:hover { opacity: 0.85; transform: scale(1.05); }

.detail-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
  padding: 0 4px;
}

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.skeleton-card { height: 260px; border-radius: var(--radius); }

/* ============ CHAPTER READER ============ */
.reader-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 500;
  background: #08080f;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.reader-overlay.open { display: flex; }

.reader-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.reader-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  height: 56px;
  background: rgba(10,10,18,0.98);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.reader-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.reader-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.reader-close-btn {
  background: rgba(233,69,96,0.15);
  border: 1px solid rgba(233,69,96,0.3);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
  flex-shrink: 0;
}
.reader-close-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }

.reader-title { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.reader-manga-title { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-chapter-label { font-size: 0.75rem; color: var(--accent); font-weight: 600; white-space: nowrap; }

.reader-chapter-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  cursor: pointer;
  max-width: 220px;
  font-family: 'Inter', sans-serif;
  outline: none;
}
.reader-chapter-select:focus { border-color: var(--accent); }

.reader-mode-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}
.reader-mode-btn:hover { border-color: var(--accent-2); color: var(--accent-2); }

.reader-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(13,13,20,0.95);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
}

.reader-nav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reader-nav-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--text-primary); background: rgba(233,69,96,0.1); }
.reader-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.reader-page-info { color: var(--text-secondary); font-size: 0.82rem; font-weight: 600; white-space: nowrap; }

.reader-pages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: #0a0a12;
  scroll-behavior: smooth;
}

/* Vertical (Scroll mode) */
.reader-pages.scroll {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 4px;
}

.reader-page-wrap {
  width: 100%;
  max-width: 900px;
  position: relative;
  background: #111120;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  flex-shrink: 0;
  transition: background 0.3s;
}
.reader-page-wrap.loaded { background: transparent; }

.reader-page-img {
  width: 100%;
  max-width: 900px;
  height: auto;
  display: block;
  object-fit: contain;
}

.page-error {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 40px;
  text-align: center;
}

/* Single-Page mode */
.reader-pages.page {
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  overflow: hidden;
}

.reader-singlepage {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
}

.reader-sp-btn {
  background: rgba(0,0,0,0.45);
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 2.5rem;
  width: 56px;
  height: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
  user-select: none;
}
.reader-sp-btn.reader-sp-prev { border-right: 1px solid rgba(255,255,255,0.07); }
.reader-sp-btn.reader-sp-next { border-left: 1px solid rgba(255,255,255,0.07); }
.reader-sp-btn:hover:not(:disabled) { background: rgba(233,69,96,0.22); color: white; }
.reader-sp-btn:disabled { opacity: 0.12; cursor: not-allowed; }

.reader-sp-imgwrap {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.reader-sp-imgwrap .reader-page-img {
  max-height: 100%;
  max-width: 100%;
  width: auto;
  object-fit: contain;
  animation: pageIn 0.22s ease;
}
@keyframes pageIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.reader-sp-counter {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.72);
  color: white;
  font-size: 0.83rem;
  font-weight: 700;
  padding: 5px 18px;
  border-radius: 20px;
  pointer-events: none;
  letter-spacing: 0.5px;
}

/* ============ SLIDESHOW MODE ============ */
.reader-pages.slideshow {
  overflow: hidden;
  position: relative;
  padding: 0;
}

.reader-slideshow {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reader-slide-track {
  position: relative;
  width: 100%;
  height: 100%;
}

.reader-slide {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.42s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.42s ease;
  opacity: 0;
  transform: translateX(100%);
  pointer-events: none;
}
.reader-slide.prev {
  transform: translateX(-100%);
  opacity: 0;
}
.reader-slide.active {
  transform: translateX(0);
  opacity: 1;
  pointer-events: all;
}
.reader-slide.next {
  transform: translateX(100%);
  opacity: 0;
}
.reader-slide .reader-page-img {
  max-height: 100%;
  max-width: 100%;
  width: auto;
  object-fit: contain;
}

.reader-slide-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.75);
  width: 52px; height: 80px;
  font-size: 2rem;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  z-index: 10;
  backdrop-filter: blur(6px);
}
.reader-slide-prev { left: 12px; }
.reader-slide-next { right: 12px; }
.reader-slide-nav:hover:not(:disabled) { background: var(--accent); color: white; border-color: var(--accent); }
.reader-slide-nav:disabled { opacity: 0.12; cursor: not-allowed; }

.reader-slide-counter {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 5px 18px;
  border-radius: 20px;
  z-index: 10;
  pointer-events: none;
  backdrop-filter: blur(6px);
  letter-spacing: 0.5px;
}

.reader-slide-dots {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
  background: rgba(0,0,0,0.55);
  padding: 6px 14px;
  border-radius: 20px;
  backdrop-filter: blur(6px);
}

.slide-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.slide-dot.active {
  background: var(--accent);
  transform: scale(1.4);
}
.slide-dot:hover { background: rgba(255,255,255,0.7); }
.slide-dot-more {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
  user-select: none;
}

/* ============ BULK SCRAPER ============ */
.scraper-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 900px;
}

.scraper-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.scraper-info-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--transition);
}
.scraper-info-card:hover { border-color: var(--accent-2); }
.scraper-info-icon { font-size: 1.8rem; }
.scraper-info-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.scraper-info-value {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.scraper-info-value code {
  background: rgba(139,92,246,0.2);
  color: var(--accent-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.scraper-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.scraper-btn {
  padding: 12px 28px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
}
.scraper-start {
  background: var(--gradient-1);
  color: white;
}
.scraper-start:hover:not(:disabled) { opacity: 0.9; transform: translateY(-2px); box-shadow: 0 8px 24px rgba(233,69,96,0.35); }
.scraper-start:disabled { opacity: 0.4; cursor: not-allowed; }
.scraper-stop {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.4);
  color: #ef4444;
}
.scraper-stop:hover:not(:disabled) { background: #ef4444; color: white; }
.scraper-stop:disabled { opacity: 0.3; cursor: not-allowed; }
.scraper-export {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
}
.scraper-export:hover { opacity: 0.9; transform: translateY(-1px); }

.scraper-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scraper-bar-wrap {
  height: 10px;
  background: var(--bg-card);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.scraper-bar-fill {
  height: 100%;
  background: var(--gradient-1);
  border-radius: 20px;
  transition: width 0.4s ease;
  position: relative;
  overflow: hidden;
}
.scraper-bar-fill::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: rgba(255,255,255,0.3);
  animation: barShine 1.5s infinite;
}
@keyframes barShine {
  to { left: 150%; }
}

.scraper-bar-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.scraper-log {
  background: #0a0a14;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
}

.scraper-log-item {
  padding: 3px 6px;
  border-radius: 4px;
  color: var(--text-secondary);
  line-height: 1.4;
  word-break: break-all;
}
.scraper-log-item.info { color: #60a5fa; }
.scraper-log-item.success { color: #4ade80; }
.scraper-log-item.error { color: var(--accent); }
.scraper-log-item.warn { color: var(--accent-3); }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 32px rgba(0,0,0,0.5); }
  .sidebar.collapsed { width: var(--sidebar-collapsed) !important; }

  .main-wrapper { margin-left: 0 !important; }
  .menu-btn { display: flex !important; }
  .page { padding: 20px 16px; }
  .manga-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
  .detail-header { flex-direction: column; }
  .topbar { padding: 0 16px; }
  .reader-topbar { height: auto; padding: 8px 12px; flex-wrap: wrap; min-height: 52px; }
  .reader-chapter-select { max-width: 150px; }
  .reader-nav-btn { max-width: 120px; font-size: 0.7rem; padding: 6px 10px; }
  .reader-sp-btn { width: 40px; font-size: 1.5rem; }
  .reader-slide-nav { width: 40px; height: 60px; font-size: 1.4rem; }
  .scraper-info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .manga-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-search { max-width: none; }
  .reader-mode-btn { display: none; }
  .reader-chapter-select { max-width: 120px; font-size: 0.72rem; }
  .reader-sp-btn { width: 32px; font-size: 1.2rem; }
}


/* Lucide Icon overrides */
.lucide { width: 1.2em; height: 1.2em; stroke-width: 2; }
.nav-icon .lucide { margin-right: 12px; }
