/*
Theme Name: AnimeVault
Theme URI: https://ai.apijav.com
Author: AnimeVault
Description: A full-featured anime streaming WordPress theme powered by the AnimeVault API. Includes home page, anime detail pages, episode player, search, browse, and genre pages.
Version: 1.0.0
License: GNU General Public License v2 or later
Text Domain: animevault
Tags: anime, streaming, dark, video, entertainment
*/

/* ============================================================
   CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
  --bg-primary:    #0a0a0f;
  --bg-secondary:  #111118;
  --bg-card:       #16161f;
  --bg-elevated:   #1d1d28;
  --accent:        #e63946;
  --accent-dim:    rgba(230, 57, 70, 0.15);
  --accent-glow:   rgba(230, 57, 70, 0.4);
  --gold:          #f4a261;
  --text-primary:  #f0f0f5;
  --text-secondary:#a0a0b8;
  --text-muted:    #5a5a7a;
  --border:        rgba(255,255,255,0.07);
  --border-hover:  rgba(255,255,255,0.15);
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;
  --shadow-card:   0 4px 24px rgba(0,0,0,0.5);
  --shadow-glow:   0 0 30px rgba(230,57,70,0.25);
  --font-display:  'Cinzel', serif;
  --font-ui:       'DM Sans', sans-serif;
  --font-mono:     'JetBrains Mono', monospace;
  --transition:    0.2s cubic-bezier(0.4,0,0.2,1);
  --header-h:      64px;
  --api-base:      'https://ai.apijav.com';
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-ui);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(230,57,70,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(244,162,97,0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
ul, ol { list-style: none; }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.section-title {
  font-size: clamp(1.1rem, 2.5vw, 1.4rem);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.section-title::before {
  content: '';
  display: block;
  width: 4px;
  height: 1.2em;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

.page-wrap {
  position: relative;
  z-index: 1;
  padding-top: var(--header-h);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
  align-items: start;
}
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ============================================================
   HEADER / NAV
   ============================================================ */
#site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(10,10,15,0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  align-items: center;
}
#site-header .container {
  display: flex;
  align-items: center;
  gap: 32px;
  width: 100%;
}

.site-logo {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text-primary);
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.site-logo span { color: var(--accent); }

/* Search bar in header */
.header-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.header-search input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 9px 48px 9px 18px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.header-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.header-search input::placeholder { color: var(--text-muted); }
.header-search button {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  transition: color var(--transition);
  display: flex;
}
.header-search button:hover { color: var(--accent); }

/* Search autocomplete */
.search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: none;
  z-index: 200;
}
.search-suggestions.active { display: block; }
.suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition);
}
.suggestion-item:hover { background: var(--border); }
.suggestion-item img { width: 36px; height: 50px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.suggestion-item .s-info .s-name { font-size: 0.85rem; font-weight: 600; }
.suggestion-item .s-info .s-meta { font-size: 0.75rem; color: var(--text-muted); }

/* Main nav */
.main-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.main-nav a {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition);
}
.main-nav a:hover, .main-nav a.active { color: var(--text-primary); background: var(--border); }

.nav-dropdown { position: relative; }
.nav-dropdown > a::after { content: ' ▾'; font-size: 0.7rem; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-width: 200px;
  padding: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity var(--transition), transform var(--transition);
  z-index: 100;
}
.nav-dropdown:hover .dropdown-menu { opacity: 1; pointer-events: all; transform: none; }
.dropdown-menu a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.dropdown-menu a:hover { color: var(--text-primary); background: var(--border); }

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  margin-left: auto;
}
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text-primary); border-radius: 2px; transition: var(--transition); }

/* Mobile nav */
.mobile-nav {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 999;
  padding: 80px 24px 24px;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  border: 1px solid var(--border);
}
.mobile-nav .close-mobile {
  position: absolute;
  top: 18px;
  right: 18px;
  font-size: 1.5rem;
  color: var(--text-secondary);
  background: none;
  border: none;
}

@media (max-width: 768px) {
  .main-nav { display: none; }
  .hamburger { display: flex; }
  .header-search { max-width: 200px; }
}

/* ============================================================
   PROVIDER SWITCHER
   ============================================================ */
.provider-bar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 6px 0;
}
.provider-bar .container { display: flex; align-items: center; gap: 12px; }
.provider-bar span { font-size: 0.75rem; color: var(--text-muted); }
.provider-btn {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all var(--transition);
}
.provider-btn.active, .provider-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ============================================================
   ANIME CARD
   ============================================================ */
.anime-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 16px;
}

.anime-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  cursor: pointer;
}
.anime-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

.card-poster {
  position: relative;
  aspect-ratio: 2/3;
  overflow: hidden;
  background: var(--bg-elevated);
}
.card-poster img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.anime-card:hover .card-poster img { transform: scale(1.05); }

.card-poster .ep-badge {
  position: absolute;
  bottom: 8px; left: 8px;
  display: flex;
  gap: 4px;
}
.badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}
.badge-sub { background: rgba(0,200,120,0.9); color: #fff; }
.badge-dub { background: rgba(80,120,255,0.9); color: #fff; }
.badge-type { background: rgba(0,0,0,0.75); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-filler { background: rgba(100,100,100,0.8); color: #ccc; }
.badge-new { background: var(--accent); color: #fff; }

.card-poster .overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.8) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--transition);
}
.anime-card:hover .overlay { opacity: 1; }

.card-body { padding: 10px 12px 12px; }
.card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
  font-family: var(--font-ui);
}
.card-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ============================================================
   SPOTLIGHT / HERO
   ============================================================ */
.spotlight-section {
  position: relative;
  height: clamp(400px, 55vh, 680px);
  overflow: hidden;
  margin-bottom: 40px;
}
.spotlight-slides { position: relative; width: 100%; height: 100%; }
.spotlight-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.8s ease;
}
.spotlight-slide.active { opacity: 1; }

.spotlight-bg {
  position: absolute;
  inset: 0;
}
.spotlight-bg img {
  width: 100%; height: 100%;
  object-fit: cover;
  filter: blur(2px) brightness(0.4);
}
.spotlight-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(10,10,15,0.95) 0%, rgba(10,10,15,0.6) 50%, transparent 100%),
              linear-gradient(0deg, var(--bg-primary) 0%, transparent 30%);
}

.spotlight-content {
  position: absolute;
  bottom: 60px;
  left: 0; right: 0;
}
.spotlight-content .container { max-width: 680px; margin: 0; padding-left: 40px; }
.spotlight-rank {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.spotlight-title {
  font-size: clamp(1.6rem, 4vw, 3rem);
  font-family: var(--font-display);
  margin-bottom: 10px;
  text-shadow: 0 2px 20px rgba(0,0,0,0.5);
}
.spotlight-meta {
  display: flex;
  gap: 14px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.spotlight-meta span {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.spotlight-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 520px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 20px;
}
.spotlight-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-watch {
  background: var(--accent);
  color: #fff;
  padding: 11px 24px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition), box-shadow var(--transition);
}
.btn-watch:hover { background: #c82333; box-shadow: var(--shadow-glow); }
.btn-info {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
  padding: 11px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-hover);
  transition: background var(--transition);
}
.btn-info:hover { background: rgba(255,255,255,0.18); }

/* Spotlight dots */
.spotlight-dots {
  position: absolute;
  bottom: 20px;
  left: 40px;
  display: flex;
  gap: 6px;
}
.spotlight-dot {
  width: 24px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.3);
  transition: all var(--transition);
  cursor: pointer;
}
.spotlight-dot.active { background: var(--accent); width: 40px; }

/* Spotlight thumbstrip */
.spotlight-strip {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.strip-thumb {
  width: 72px;
  aspect-ratio: 2/3;
  border-radius: 6px;
  overflow: hidden;
  opacity: 0.4;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
}
.strip-thumb.active { opacity: 1; border-color: var(--accent); }
.strip-thumb img { width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 768px) {
  .spotlight-strip { display: none; }
  .spotlight-content .container { padding-left: 20px; }
}

/* ============================================================
   TOP 10 SECTION
   ============================================================ */
.top10-section { margin-bottom: 40px; }
.top10-tabs { display: flex; gap: 4px; margin-bottom: 20px; }
.top10-tab {
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.top10-tab.active, .top10-tab:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.top10-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.top10-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}
.top10-item:hover { border-color: var(--accent); transform: translateX(4px); }
.top10-rank {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  color: var(--border);
  width: 40px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}
.top10-item:nth-child(1) .top10-rank { color: var(--gold); }
.top10-item:nth-child(2) .top10-rank { color: #c0c0c0; }
.top10-item:nth-child(3) .top10-rank { color: #cd7f32; }
.top10-poster { width: 44px; height: 60px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.top10-info { flex: 1; overflow: hidden; }
.top10-name { font-size: 0.83rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.top10-eps { font-size: 0.72rem; color: var(--text-muted); }

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

.skeleton-card { aspect-ratio: 2/3; border-radius: var(--radius-md); }
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-line.short { width: 60%; }

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.section-loader { text-align: center; padding: 48px; color: var(--text-muted); }

/* ============================================================
   ANIME DETAIL PAGE
   ============================================================ */
.anime-hero {
  position: relative;
  padding: 40px 0 32px;
  overflow: hidden;
}
.anime-hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
  filter: blur(40px) brightness(0.25);
  transform: scale(1.1);
}
.anime-hero .container { position: relative; z-index: 1; }

.anime-detail-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  align-items: start;
}
@media (max-width: 640px) { .anime-detail-grid { grid-template-columns: 1fr; } }

.detail-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

.detail-info { flex: 1; }
.detail-title {
  font-size: clamp(1.4rem, 3.5vw, 2.4rem);
  margin-bottom: 6px;
}
.detail-jname {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  font-family: var(--font-ui);
}
.detail-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.detail-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.detail-badge.highlight { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.stat-item { text-align: center; }
.stat-value { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.stat-label { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }

.detail-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 16px;
}
.detail-desc.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.btn-expand {
  font-size: 0.8rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  margin-bottom: 20px;
  padding: 0;
}

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.tag {
  padding: 4px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.tag:hover { border-color: var(--accent); color: var(--accent); }

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

/* ============================================================
   EPISODE LIST
   ============================================================ */
.episode-section { margin-top: 32px; }
.ep-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.ep-search-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  width: 180px;
  transition: border-color var(--transition);
}
.ep-search-input:focus { border-color: var(--accent); }
.ep-page-size {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
}

.ep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(55px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.ep-btn {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.ep-btn:hover { border-color: var(--accent); color: var(--accent); }
.ep-btn.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.ep-btn.filler { opacity: 0.5; }
.ep-btn .ep-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.7rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ep-btn:hover .ep-tooltip { opacity: 1; }

.ep-pagination { display: flex; gap: 8px; flex-wrap: wrap; }
.ep-page-btn {
  padding: 6px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.ep-page-btn.active, .ep-page-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ============================================================
   VIDEO PLAYER PAGE
   ============================================================ */
.player-page { background: #000; min-height: 100vh; }
.player-wrap {
  position: relative;
  width: 100%;
  background: #000;
  max-height: 80vh;
}
.player-wrap iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  display: block;
}
.player-sidebar { position: relative; z-index: 1; }

.source-selector {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}
.source-selector span { font-size: 0.8rem; color: var(--text-muted); margin-right: 4px; }
.source-btn {
  padding: 6px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.source-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.source-btn:hover:not(.active) { border-color: var(--border-hover); color: var(--text-primary); }

.ep-nav-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.ep-nav-btn {
  padding: 8px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}
.ep-nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.ep-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.ep-title-display {
  flex: 1;
  font-size: 0.88rem;
  color: var(--text-primary);
  text-align: center;
  font-weight: 600;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar { display: flex; flex-direction: column; gap: 24px; }

.sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.sidebar-card .section-title { font-size: 0.95rem; }

.sidebar-list .anime-card {
  display: flex;
  flex-direction: row;
  gap: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.sidebar-list .card-poster {
  width: 60px;
  height: 80px;
  flex-shrink: 0;
  border-radius: 6px;
}
.sidebar-list .card-body { padding: 4px 0; }

/* Genre cloud */
.genre-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.genre-pill {
  padding: 5px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.genre-pill:hover, .genre-pill.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================================================
   BROWSE / SEARCH PAGE
   ============================================================ */
.browse-filters {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 28px;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
  align-items: flex-start;
}
.filter-row:last-child { margin-bottom: 0; }
.filter-group { display: flex; flex-direction: column; gap: 6px; min-width: 140px; }
.filter-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em; }
.filter-options { display: flex; flex-wrap: wrap; gap: 4px; }
.filter-opt {
  padding: 4px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.filter-opt:hover, .filter-opt.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.filter-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
  min-width: 160px;
}
.filter-apply {
  padding: 10px 24px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  transition: background var(--transition);
  border: none;
  cursor: pointer;
}
.filter-apply:hover { background: #c82333; }
.filter-reset {
  padding: 10px 18px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  border: 1px solid var(--border);
  transition: all var(--transition);
  cursor: pointer;
}
.filter-reset:hover { border-color: var(--border-hover); color: var(--text-primary); }

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.results-count { font-size: 0.85rem; color: var(--text-muted); }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 36px;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  padding: 0 10px;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ============================================================
   AZ LIST
   ============================================================ */
.az-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.az-btn {
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.az-btn:hover, .az-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ============================================================
   ERROR / EMPTY STATES
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin: 0 auto 16px; opacity: 0.4; }
.empty-state h3 { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.88rem; }

.error-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 0.85rem;
  color: var(--text-primary);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 340px;
}
.error-toast.show { transform: translateY(0); opacity: 1; }

/* ============================================================
   FOOTER
   ============================================================ */
#site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 40px 0 24px;
  margin-top: 64px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}
@media (max-width: 768px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-col h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 14px;
  font-family: var(--font-display);
}
.footer-col a {
  display: block;
  font-size: 0.83rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  transition: color var(--transition);
}
.footer-col a:hover { color: var(--accent); }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: gap;
  gap: 12px;
}
.footer-bottom p { font-size: 0.78rem; color: var(--text-muted); }

/* ============================================================
   UTILITY
   ============================================================ */
.mt-1 { margin-top: 8px; }  .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; } .mt-5 { margin-top: 48px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; } .mb-4 { margin-bottom: 32px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.fw-bold { font-weight: 700; }
.text-center { text-align: center; }

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

/* ============================================================
   SMOOTH SECTION REVEAL
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.visible { opacity: 1; transform: none; }

/* ── Player loading overlay ── */
.av-player-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 2;
  aspect-ratio: 16/9;
}
.av-player-loading .av-spin {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255,255,255,.1);
  border-top-color: #6c63ff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
