:root {
  --bg: #060606;
  --bg-card: #0e0e0e;
  --bg-elevated: #141414;
  --bg-hover: #1a1a1a;
  --bg-input: #0c0c0c;
  --border: #1a1a1a;
  --border-focus: #00ff88;
  --accent: #00ff88;
  --accent-dim: #00cc6a;
  --accent-glow: rgba(0, 255, 136, 0.15);
  --accent-glow-strong: rgba(0, 255, 136, 0.3);
  --text: #e8e8e8;
  --text-secondary: #777;
  --text-dim: #444;
  --danger: #ff4444;
  --gold: #ffd700;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 50px;
  --sidebar-w: 260px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scrollbar-width: thin;
  scrollbar-color: #1a1a1a transparent;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #222; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #333; }

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

/* ===== BANNER ===== */
.banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.6rem 1.5rem;
  background: var(--accent-glow-strong);
  border-bottom: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  position: relative;
  z-index: 50;
}

.banner-close {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.3rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.banner-close:hover {
  opacity: 1;
}

/* ===== APP LAYOUT ===== */
.app {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 1.5rem;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: #000;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.1rem;
  box-shadow: 0 0 20px var(--accent-glow-strong);
}

.logo span {
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: 3px;
  color: var(--text);
}

/* Nav Items */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-family: inherit;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active svg {
  filter: drop-shadow(0 0 6px var(--accent-glow-strong));
}

/* Sidebar Sections */
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar-section h4 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-dim);
  font-weight: 600;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-group label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Custom Select */
.custom-select {
  position: relative;
}

.select-display {
  padding: 0.55rem 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.select-display:hover {
  border-color: #333;
}

.custom-select.open .select-display {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 240px;
  overflow-y: auto;
  z-index: 30;
  display: none;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}

.custom-select.open .select-dropdown {
  display: block;
}

.select-option {
  padding: 0.5rem 0.9rem;
  font-size: 0.83rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.select-option:hover {
  background: var(--accent-glow);
  color: var(--accent);
}

.select-option.selected {
  color: var(--accent);
  font-weight: 600;
}

/* Bubble Buttons */
.bubble-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bubble {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.bubble:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.bubble.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
  box-shadow: 0 0 14px var(--accent-glow-strong);
}

/* Toggle Pill / Custom Checkbox */
.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toggle-pill {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  cursor: pointer;
  font-size: 0.83rem;
  color: var(--text-secondary);
  user-select: none;
}

.toggle-pill input {
  display: none;
}

.pill-track {
  width: 38px;
  height: 22px;
  background: #222;
  border-radius: 11px;
  position: relative;
  transition: all var(--transition);
  border: 1px solid #333;
}

.pill-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #555;
  border-radius: 50%;
  transition: all var(--transition);
}

.toggle-pill input:checked + .pill-track {
  background: var(--accent-glow-strong);
  border-color: var(--accent);
}

.toggle-pill input:checked + .pill-track .pill-knob {
  left: 18px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow-strong);
}

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

/* Header / Search */
header {
  padding: 1.2rem 2rem;
  position: sticky;
  top: 0;
  z-index: 15;
  background: rgba(6, 6, 6, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.search-container {
  position: relative;
  max-width: 600px;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
  transition: color var(--transition);
}

#search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition);
}

#search-input::placeholder {
  color: var(--text-dim);
}

#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), 0 0 30px var(--accent-glow);
}

#search-input:focus ~ .search-icon,
.search-container:focus-within .search-icon {
  color: var(--accent);
}

/* Live Search Results Dropdown */
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 420px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
}

.search-results.hidden {
  display: none;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  cursor: pointer;
  transition: all 0.15s;
  border-bottom: 1px solid var(--border);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--accent-glow);
}

.search-result-item img {
  width: 45px;
  height: 65px;
  object-fit: cover;
  border-radius: 6px;
  background: #1a1a1a;
}

.search-result-info h4 {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.search-result-info span {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.search-result-info .type-badge {
  display: inline-block;
  padding: 1px 8px;
  background: var(--accent-glow);
  color: var(--accent);
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 6px;
}

/* Hero Banner */
.hero {
  position: relative;
  height: 380px;
  margin: 0 2rem 1.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
}

.hero.hidden { display: none; }

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

.hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(6,6,6,0.95) 0%, rgba(6,6,6,0.4) 50%, transparent 100%),
              linear-gradient(0deg, rgba(6,6,6,0.9) 0%, transparent 50%);
}

.hero-content {
  position: relative;
  z-index: 2;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
}

.hero-content h2 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 20px rgba(0,0,0,0.5);
}

.hero-content p {
  font-size: 0.9rem;
  color: #bbb;
  max-width: 500px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.hero-meta .score-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.3rem 0.7rem;
  background: var(--accent-glow-strong);
  color: var(--accent);
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 700;
}

.hero-meta span {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ===== GRID ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 1.2rem;
  padding: 0 2rem 2rem;
  flex: 1;
}

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

.card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: var(--accent);
  box-shadow: 0 12px 40px rgba(0, 255, 136, 0.1), 0 0 0 1px var(--accent);
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.8) 100%);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}

.card:hover::after {
  opacity: 1;
}

.card img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
}

.card-info {
  padding: 0.75rem 0.85rem;
}

.card-info h3 {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-info .meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-info .score {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.78rem;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.8rem;
  padding: 1.5rem 2rem 3rem;
}

.page-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  transition: all var(--transition);
}

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

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

.page-pills {
  display: flex;
  gap: 4px;
}

.page-pill {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.page-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.page-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 700;
  box-shadow: 0 0 14px var(--accent-glow-strong);
}

/* ===== WATCH VIEW ===== */
.hidden { display: none !important; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  margin: 1.5rem 2rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  transition: all var(--transition);
}

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

/* Player */
.watch-player {
  padding: 0 2rem;
  margin-bottom: 1.5rem;
}

/* Server Picker */
.server-picker {
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.server-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.server-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.server-btn {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.server-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.server-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 700;
  box-shadow: 0 0 12px var(--accent-glow-strong);
}

.watch-player iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius);
  background: #000;
  border: 1px solid var(--border);
  display: block;
}

/* Watch Details */
.watch-details {
  padding: 0 2rem 3rem;
}

.watch-info-row {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.watch-poster {
  width: 160px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.watch-info {
  flex: 1;
}

.watch-info h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.6rem;
}

.watch-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 0.8rem;
}

.watch-genres span {
  padding: 0.25rem 0.75rem;
  background: var(--accent-glow);
  color: var(--accent);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(0,255,136,0.15);
}

.watch-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.8rem;
}

.watch-stats .score {
  color: var(--accent);
  font-weight: 700;
}

.watch-desc {
  color: #999;
  font-size: 0.88rem;
  line-height: 1.65;
}

/* Episodes Section */
.watch-episodes {
  margin-bottom: 2rem;
}

.watch-episodes h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.season-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 1rem;
}

.season-tab {
  padding: 0.4rem 1rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.season-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.season-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 700;
  box-shadow: 0 0 14px var(--accent-glow-strong);
}

.episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}

.ep-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  font-family: inherit;
  color: var(--text-secondary);
}

.ep-card:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--text);
}

.ep-card.active {
  border-color: var(--accent);
  background: var(--accent-glow-strong);
  color: var(--accent);
}

.ep-num {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.ep-label {
  font-size: 0.7rem;
}

/* Cast */
.watch-cast {
  margin-bottom: 2rem;
}

.watch-cast h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.cast-list {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.cast-item {
  text-align: center;
  min-width: 80px;
}

.cast-item img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 50%;
  margin-bottom: 0.4rem;
  border: 2px solid var(--border);
  transition: border-color var(--transition);
}

.cast-item:hover img {
  border-color: var(--accent);
}

.cast-name {
  display: block;
  font-size: 0.72rem;
  color: var(--text);
  font-weight: 500;
}

.cast-char {
  display: block;
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* Similar */
.watch-similar {
  margin-bottom: 2rem;
}

.watch-similar h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.similar-row {
  display: flex;
  gap: 0.8rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.similar-card {
  min-width: 120px;
  cursor: pointer;
  transition: transform var(--transition);
}

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

.similar-card img {
  width: 120px;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.similar-card p {
  font-size: 0.72rem;
  margin-top: 0.3rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

/* Hero Watch Button */
.hero-watch-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.65rem 1.8rem;
  background: var(--accent);
  border: none;
  color: #000;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  box-shadow: 0 0 20px var(--accent-glow-strong);
  width: fit-content;
}

.hero-watch-btn:hover {
  box-shadow: 0 0 30px var(--accent-glow-strong), 0 0 60px var(--accent-glow);
  transform: scale(1.03);
}

/* States */
.loading {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-dim);
  font-size: 0.95rem;
  grid-column: 1 / -1;
}

.loading::after {
  content: "";
  display: block;
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 1rem auto 0;
  animation: spin 0.8s linear infinite;
}

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

.error {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--danger);
  grid-column: 1 / -1;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  :root { --sidebar-w: 60px; }

  .sidebar {
    padding: 1rem 0.5rem;
    align-items: center;
  }

  .logo span,
  .sidebar-section,
  .nav-item span { display: none; }

  .nav-item {
    justify-content: center;
    padding: 0.7rem;
  }

  .nav-item svg { margin: 0; }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    padding: 0 1rem 1rem;
    gap: 0.8rem;
  }

  .hero {
    margin: 0 1rem 1rem;
    height: 240px;
  }

  .hero-content h2 { font-size: 1.3rem; }
  .hero-content p { font-size: 0.8rem; }

  header { padding: 0.8rem 1rem; }

  .watch-player { padding: 0 1rem; }
  .watch-details { padding: 0 1rem 2rem; }
  .back-btn { margin: 1rem 1rem 0.5rem; }

  .watch-info-row {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .watch-poster { width: 120px; }
  .watch-genres { justify-content: center; }
  .watch-stats { justify-content: center; }

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