@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* ══════════════════════════════════════════════════════════
   DESIGN TOKENS
══════════════════════════════════════════════════════════ */
:root {
  --bg-gradient: linear-gradient(135deg, #0b0f19 0%, #111827 50%, #1e1b4b 100%);
  --panel-bg: rgba(17, 24, 39, 0.7);
  --glass-bg: rgba(31, 41, 55, 0.4);
  --glass-border: rgba(255, 255, 255, 0.08);
  --accent-primary: #6366f1;
  --accent-primary-glow: rgba(99, 102, 241, 0.4);
  --accent-secondary: #a855f7;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --border-radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  /* Spacing scale */
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
}

/* ══════════════════════════════════════════════════════════
   RESET & BASE
══════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
}

/* ══════════════════════════════════════════════════════════
   HEADER & NAVIGATION
══════════════════════════════════════════════════════════ */
header {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(11, 15, 25, 0.85);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 200;
  padding: 0.85rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  min-height: 64px;
}

/* ── Logo ── */
.logo-container {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.logo-container:hover {
  transform: scale(1.03);
  opacity: 0.9;
}

.logo-icon {
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px var(--accent-primary-glow));
}

.logo-text {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.logo-text span {
  color: var(--accent-secondary);
}

/* ── Nav ── */
#main-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

#main-nav::-webkit-scrollbar { display: none; }

.nav-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: 10px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  color: var(--text-main);
  background: var(--glass-bg);
  border-color: var(--glass-border);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

/* ── Header user area ── */
.header-user-area {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════
   MAIN CONTAINER
══════════════════════════════════════════════════════════ */
.container {
  max-width: 1280px;
  margin: 1.75rem auto;
  padding: 0 1.25rem;
  min-height: 70vh;
}

/* ══════════════════════════════════════════════════════════
   SEARCH PANEL
══════════════════════════════════════════════════════════ */
.search-container {
  background: var(--panel-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  padding: 2.25rem 1.5rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  margin-bottom: 1.75rem;
  text-align: center;
}

.search-title {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 700;
  margin-bottom: 0.65rem;
  background: linear-gradient(to right, #ffffff, #c7d2fe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.search-desc {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: clamp(0.9rem, 2.5vw, 1.05rem);
  max-width: 550px;
  margin-left: auto;
  margin-right: auto;
}

.search-bar-wrapper {
  display: flex;
  max-width: 640px;
  margin: 0 auto;
  position: relative;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 4px;
  transition: var(--transition);
}

.search-bar-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 15px var(--accent-primary-glow);
}

.search-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: clamp(0.9rem, 2.5vw, 1.05rem);
  padding: 0.75rem 1rem;
}

.search-input::placeholder { color: #64748b; }

.search-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 0 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.search-clear-btn:hover { color: #ef4444; }

.search-btn {
  background: var(--accent-primary);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: clamp(0.85rem, 2vw, 1rem);
  padding: 0 1.25rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 40px;
}

.search-btn:hover:not(:disabled) {
  background: #4f46e5;
  box-shadow: 0 0 12px var(--accent-primary-glow);
}

.search-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  background: rgba(31, 41, 55, 0.4) !important;
  color: var(--text-muted) !important;
  box-shadow: none !important;
}

/* ── Suggestion tags ── */
.search-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 1.1rem;
}

.suggestion-tag {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  touch-action: manipulation;
}

.suggestion-tag:hover,
.suggestion-tag:active {
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
}

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

.batch-card {
  background: var(--panel-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  touch-action: manipulation;
}

.batch-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-primary);
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.18);
}

.batch-image-wrapper {
  aspect-ratio: 16 / 9;
  position: relative;
  overflow: hidden;
  background: #1e293b;
}

.batch-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition);
}

.batch-card:hover .batch-image { transform: scale(1.05); }

.batch-info {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.5rem;
}

.batch-name {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.batch-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ── Loaders & Empty states ── */
.batches-grid .loader-wrapper,
.batches-grid .empty-state {
  grid-column: 1 / -1;
  width: 100%;
  margin: 0 auto;
}

.loader-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1rem;
  gap: 1rem;
}

.spinner {
  width: 46px;
  height: 46px;
  border: 4px solid rgba(99, 102, 241, 0.1);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.loader-text {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
}

.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--text-muted);
  border: 1px dashed var(--glass-border);
  border-radius: var(--border-radius);
  background: rgba(255, 255, 255, 0.01);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.empty-icon {
  font-size: 2.25rem;
  color: #4b5563;
  margin-bottom: 0.25rem;
}

/* ══════════════════════════════════════════════════════════
   BROWSER HEADER (breadcrumb + back)
══════════════════════════════════════════════════════════ */
.browser-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}

.back-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

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

.browser-title-wrapper {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.browser-subtitle {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.browser-title {
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ══════════════════════════════════════════════════════════
   CHAPTERS / CONTENTS SPLIT VIEW
══════════════════════════════════════════════════════════ */
.details-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.sidebar-panel {
  background: var(--panel-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar-title {
  font-size: 1.05rem;
  font-weight: 700;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0.6rem;
  flex-shrink: 0;
}

.chapters-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

/* Custom scrollbar */
.chapters-list::-webkit-scrollbar { width: 4px; }
.chapters-list::-webkit-scrollbar-track { background: transparent; }
.chapters-list::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 2px;
}

.chapter-item {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  text-align: left;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.88rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  touch-action: manipulation;
}

.chapter-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.chapter-item.active {
  background: linear-gradient(90deg, rgba(99,102,241,0.15) 0%, rgba(168,85,247,0.05) 100%) !important;
  border-left: 3px solid var(--accent-primary) !important;
  border-color: var(--glass-border) !important;
  color: #c7d2fe !important;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.08);
}

.chapter-stats {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Filter inputs ── */
.filter-input-wrapper {
  position: relative;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  padding: 2px 10px;
  transition: var(--transition);
  flex-shrink: 0;
}

.filter-input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px var(--accent-primary-glow);
}

.filter-icon {
  color: #64748b;
  font-size: 0.8rem;
  margin-right: 0.25rem;
  flex-shrink: 0;
}

.filter-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 0.35rem;
}

.filter-input::placeholder { color: #475569; }

/* ── Contents panel ── */
.contents-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tabs-wrapper {
  display: flex;
  border-bottom: 1px solid var(--glass-border);
  gap: 1.25rem;
}

.content-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.75rem 0.35rem;
  position: relative;
  transition: var(--transition);
  white-space: nowrap;
}

.content-tab:hover { color: var(--text-main); }

.content-tab.active { color: var(--accent-primary); }

.content-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary);
  border-radius: 2px;
}

.content-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.content-card {
  background: var(--panel-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 0.85rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: var(--transition);
}

.content-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(31, 41, 55, 0.35);
}

.content-icon {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.content-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

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

.content-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Action buttons ── */
.action-buttons {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.action-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  touch-action: manipulation;
}

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

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

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  width: 100%;
  max-width: 960px;
  background: #0f172a;
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
  position: relative;
  transform: scale(0.96);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal-container { transform: scale(1); }

.modal-close-btn {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  z-index: 10;
  transition: var(--transition);
  font-weight: 600;
  font-size: 0.82rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

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

.video-player-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  background: #000;
}

.video-player-wrapper iframe,
.video-player-wrapper video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.85);
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

/* ══════════════════════════════════════════════════════════
   LINK CHANGER
══════════════════════════════════════════════════════════ */
.link-changer-container {
  max-width: 760px;
  margin: 0 auto;
}

.results-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1.75rem;
}

.link-result-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.quality-badge {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid var(--accent-secondary);
  color: #c084fc;
  padding: 0.25rem 0.7rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.link-text {
  flex: 1;
  min-width: 0;
  font-family: monospace;
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ══════════════════════════════════════════════════════════
   USER PANEL (Favorites / History)
══════════════════════════════════════════════════════════ */
.user-panel-header {
  text-align: center;
  padding: 2.5rem 1rem 1.75rem;
}

.user-panel-icon {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(168,85,247,0.2));
  border: 1px solid rgba(99,102,241,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: var(--accent-primary);
  margin: 0 auto 1.1rem;
}

.user-panel-title {
  font-size: clamp(1.3rem, 4vw, 1.6rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-main), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.35rem;
}

.user-panel-desc {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 1.1rem;
}

.btn-clear-history {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.22);
  color: #f87171;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  touch-action: manipulation;
}

.btn-clear-history:hover {
  background: rgba(239,68,68,0.2);
  border-color: rgba(239,68,68,0.35);
}

/* ── Watch History ── */
.history-list {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 0.8rem 0.9rem;
  transition: var(--transition);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.history-item:hover {
  background: rgba(99,102,241,0.07);
  border-color: rgba(99,102,241,0.2);
  transform: translateX(3px);
}

.history-thumb {
  width: 68px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255,255,255,0.05);
}

.history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.history-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.history-title {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.history-time {
  font-size: 0.73rem;
  color: var(--accent-primary);
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════
   HEADER USER AREA — SIGN IN BTN & AVATAR
══════════════════════════════════════════════════════════ */
.btn-signin {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  border: none;
  border-radius: 40px;
  padding: 0.5rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(99,102,241,0.35);
  touch-action: manipulation;
}

.btn-signin:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99,102,241,0.5);
}

/* ── User avatar / dropdown ── */
.user-menu { position: relative; display: flex; align-items: center; }

.user-avatar-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: 40px;
  padding: 0.3rem 0.6rem 0.3rem 0.3rem;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-main);
  touch-action: manipulation;
}

.user-avatar-btn:hover {
  background: rgba(255,255,255,0.11);
  border-color: var(--accent-primary);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: #fff;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  background: rgba(11,16,28,0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.97);
  transition: all 0.22s cubic-bezier(0.4,0,0.2,1);
  z-index: 500;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.user-dropdown.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem 0.7rem;
}

.user-dropdown-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}

.user-dropdown-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
}

.user-dropdown-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.user-dropdown-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 0.2rem 0;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.7rem 1rem;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 0.86rem;
  cursor: pointer;
  transition: background 0.18s;
  text-align: left;
  touch-action: manipulation;
}

.user-dropdown-item:hover { background: rgba(255,255,255,0.06); }
.user-dropdown-item.danger { color: #f87171; }
.user-dropdown-item.danger:hover { background: rgba(239,68,68,0.1); }

/* ══════════════════════════════════════════════════════════
   AUTH MODAL
══════════════════════════════════════════════════════════ */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  padding: 1rem;
}

.auth-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.auth-card {
  background: rgba(10,14,27,0.99);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 22px;
  padding: 2.25rem 1.75rem 1.75rem;
  width: 100%;
  max-width: 410px;
  position: relative;
  box-shadow: 0 30px 80px rgba(0,0,0,0.65), 0 0 0 1px rgba(99,102,241,0.1);
  animation: slideUp 0.3s cubic-bezier(0.4,0,0.2,1);
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes slideUp {
  from { opacity:0; transform: translateY(22px) scale(0.97); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

.auth-close-btn {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.auth-close-btn:hover { background: rgba(255,255,255,0.14); color: var(--text-main); }

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.auth-logo i {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 1.5rem;
}

.auth-logo em { font-style: normal; color: var(--accent-secondary); }

.auth-tabs {
  display: flex;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 1.5rem;
  gap: 3px;
}

.auth-tab {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.22s;
  touch-action: manipulation;
}

.auth-tab.active {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

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

.auth-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.auth-input-wrapper {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: 11px;
  padding: 0 0.85rem;
  gap: 0.55rem;
  transition: border-color 0.22s, box-shadow 0.22s;
}

.auth-input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.13);
}

.auth-input-wrapper > i:first-child {
  color: var(--text-muted);
  font-size: 0.82rem;
  flex-shrink: 0;
}

.auth-input-wrapper input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.92rem;
  padding: 0.7rem 0;
}

.auth-input-wrapper input::placeholder { color: rgba(156,163,175,0.55); }

.toggle-pw-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  font-size: 0.8rem;
  transition: color 0.18s;
  flex-shrink: 0;
}

.toggle-pw-btn:hover { color: var(--text-main); }

.auth-error {
  font-size: 0.8rem;
  color: #f87171;
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.2);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  display: none;
  line-height: 1.4;
}

.auth-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.82rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  border: none;
  border-radius: 11px;
  font-size: 0.97rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 0.4rem;
  box-shadow: 0 6px 18px rgba(99,102,241,0.3);
  touch-action: manipulation;
}

.auth-submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(99,102,241,0.45);
}

.auth-submit-btn:disabled { opacity: 0.7; cursor: not-allowed; }

.auth-switch-text {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.auth-switch-text a {
  color: var(--accent-primary);
  cursor: pointer;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-switch-text a:hover { color: var(--accent-secondary); }

/* ══════════════════════════════════════════════════════════
   FAVORITES HEART BUTTON
══════════════════════════════════════════════════════════ */
.fav-btn {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.4,0,0.2,1);
  font-size: 0.82rem;
  z-index: 5;
  opacity: 0;
  transform: scale(0.8);
  touch-action: manipulation;
}

/* On touch devices always show */
@media (hover: none) {
  .fav-btn { opacity: 1; transform: scale(1); }
}

.batch-card:hover .fav-btn { opacity: 1; transform: scale(1); }

.fav-btn.favorited {
  opacity: 1;
  transform: scale(1);
  color: #f43f5e;
  background: rgba(244,63,94,0.2);
  border-color: rgba(244,63,94,0.28);
}

.fav-btn:hover {
  transform: scale(1.15) !important;
  background: rgba(244,63,94,0.25);
  color: #f43f5e;
}

/* ══════════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════════ */
.subedu-toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: rgba(11,16,30,0.97);
  border: 1px solid rgba(99,102,241,0.28);
  color: var(--text-main);
  padding: 0.7rem 1.4rem;
  border-radius: 40px;
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  white-space: nowrap;
  max-width: calc(100vw - 2rem);
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.subedu-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Auth prompt inside panels */
.auth-prompt-icon {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  color: var(--accent-primary);
  margin: 0 auto;
}

/* ══════════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════════ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeInUp 0.3s cubic-bezier(0.4,0,0.2,1) forwards;
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — TABLET  ≤ 1024px
══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .details-grid {
    grid-template-columns: 260px 1fr;
    gap: 1.25rem;
  }

  .batches-grid {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — TABLET PORTRAIT  ≤ 768px
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  header {
    padding: 0.7rem 1rem;
    gap: 0.5rem;
  }

  .logo-text { font-size: 1.15rem; }
  .logo-icon  { font-size: 1.3rem; }

  .nav-tab {
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
  }

  .container {
    margin: 1.25rem auto;
    padding: 0 1rem;
  }

  .search-container {
    padding: 1.75rem 1.1rem;
  }

  .batches-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
  }

  .details-grid {
    grid-template-columns: 1fr;
  }

  .sidebar-panel {
    position: static;
    max-height: 280px;
  }

  .chapters-list {
    max-height: 200px;
  }

  .modal-container {
    width: 100%;
    max-width: 100%;
    border-radius: 12px;
  }

  .link-result-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .link-text { width: 100%; }

  .user-panel-header { padding: 2rem 1rem 1.5rem; }
  .history-list { padding: 0 0.5rem 2.5rem; }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE  ≤ 480px
══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  header {
    padding: 0.6rem 0.75rem;
  }

  /* Hide nav text labels on very small screens */
  .nav-tab span { display: none; }
  .nav-tab {
    padding: 0.5rem 0.6rem;
    gap: 0;
  }

  /* Keep sign in text hidden on small, show icon only */
  .btn-signin span { display: none; }
  .btn-signin { padding: 0.48rem 0.75rem; }

  .logo-text { font-size: 1.05rem; }
  .logo-icon  { font-size: 1.2rem; }

  .container {
    margin: 1rem auto;
    padding: 0 0.75rem;
  }

  .search-container {
    padding: 1.4rem 0.9rem;
    border-radius: 14px;
  }

  .search-title { font-size: 1.3rem; }
  .search-desc  { font-size: 0.85rem; margin-bottom: 1.1rem; }

  .search-bar-wrapper {
    border-radius: 10px;
  }

  .search-input {
    font-size: 0.9rem;
    padding: 0.65rem 0.75rem;
  }

  .search-btn {
    padding: 0 0.9rem;
    font-size: 0.85rem;
  }

  .search-btn span { display: none; }

  .batches-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .batch-name { font-size: 0.88rem; }
  .batch-info { padding: 0.75rem; }

  .browser-title { font-size: 1rem; }

  .content-card {
    padding: 0.75rem 0.85rem;
    gap: 0.65rem;
  }

  .content-title { font-size: 0.88rem; }

  .action-btn {
    padding: 0.45rem 0.7rem;
    font-size: 0.8rem;
  }

  .action-btn span { display: none; }

  .modal-overlay { padding: 0; align-items: flex-end; }

  .modal-container {
    border-radius: 20px 20px 0 0;
    max-height: 95dvh;
    width: 100%;
  }

  .auth-card {
    padding: 1.75rem 1.1rem 1.4rem;
    border-radius: 20px;
  }

  .user-dropdown {
    right: auto;
    left: 50%;
    transform: translateX(-50%) translateY(-8px) scale(0.97);
    min-width: 200px;
  }

  .user-dropdown.open {
    transform: translateX(-50%) translateY(0) scale(1);
  }

  .history-thumb { width: 56px; height: 40px; }

  .sidebar-panel { max-height: 240px; }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — VERY SMALL  ≤ 360px
══════════════════════════════════════════════════════════ */
@media (max-width: 360px) {
  .batches-grid {
    grid-template-columns: 1fr;
  }

  .logo-text { display: none; }
}

/* ══════════════════════════════════════════════════════════
   DESKTOP ENHANCEMENTS  ≥ 1280px
══════════════════════════════════════════════════════════ */
@media (min-width: 1280px) {
  header { padding: 0.9rem 2.5rem; }

  .container { padding: 0 2rem; }

  .search-container { padding: 3rem 2rem; }

  .batches-grid {
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1.5rem;
  }

  .details-grid {
    grid-template-columns: 320px 1fr;
    gap: 2rem;
  }

  .batch-name { font-size: 1.05rem; }
}

/* ══════════════════════════════════════════════════════════
   SCROLLBAR — GLOBAL (desktop only)
══════════════════════════════════════════════════════════ */
@media (min-width: 769px) {
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: rgba(99,102,241,0.4);
  }
}

/* ══════════════════════════════════════════════════════════
   TOUCH IMPROVEMENTS
══════════════════════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
  /* Increase tap targets */
  .chapter-item { padding: 0.85rem 1rem; }
  .nav-tab { min-height: 44px; }
  .back-btn { width: 44px; height: 44px; }
  .action-btn { min-height: 40px; }
  .suggestion-tag { min-height: 36px; }

  /* Remove hover effects that don't make sense on touch */
  .batch-card:hover { transform: none; }
  .batch-card:active { transform: scale(0.98); }
  .history-item:hover { transform: none; }
  .history-item:active { background: rgba(99,102,241,0.1); }
}

/* ══════════════════════════════════════════════════════════
   SAFE AREAS (iPhone notch / home bar)
══════════════════════════════════════════════════════════ */
@supports (padding: max(0px)) {
  header {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .container {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }

  .modal-container {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .subedu-toast {
    bottom: max(1.25rem, calc(env(safe-area-inset-bottom) + 0.75rem));
  }
}
