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

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

:root {
  --bg:        #0d0d1a;
  --bg2:       #13132b;
  --bg3:       #1a1a38;
  --card:      #16162e;
  --border:    #2a2a50;
  --purple:    #c084fc;
  --pink:      #f472b6;
  --purple-d:  #a855f7;
  --text:      #e2e8f0;
  --text-muted:#94a3b8;
  --radius:    12px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
}

html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--purple); text-decoration: none; }
a:hover { color: var(--pink); }

h1,h2,h3,h4,h5 { font-family: 'Nunito', sans-serif; font-weight: 800; }

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

/* ===== NAVBAR ===== */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(13,13,26,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
}
.nav-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 1.5rem;
  height: 60px;
}
.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-family: 'Nunito', sans-serif; font-weight: 900;
  font-size: 1.25rem; color: var(--text);
  white-space: nowrap;
}
.nav-brand img { width: 32px; height: 32px; object-fit: contain; border-radius: 8px; }
.nav-brand span { background: linear-gradient(135deg, var(--purple), var(--pink)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.nav-links { display: flex; gap: 0.25rem; margin-left: auto; }
.nav-links a {
  padding: 6px 14px; border-radius: 8px;
  color: var(--text-muted); font-weight: 500; font-size: 0.9rem;
  transition: all .2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--bg3); }

/* ===== HERO ===== */
.hero {
  text-align: center;
  padding: 5rem 1.5rem 4rem;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(168,85,247,.15), transparent);
}
.hero-logo { width: 120px; height: 120px; object-fit: contain; margin: 0 auto 1.5rem; border-radius: 20px; filter: drop-shadow(0 0 32px rgba(192,132,252,.4)); }
.hero h1 { font-size: clamp(1.8rem, 5vw, 3rem); margin-bottom: .75rem; background: linear-gradient(135deg, #fff 30%, var(--purple)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero p { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 2rem; }

/* Search bar */
.search-bar {
  max-width: 560px; margin: 0 auto;
  display: flex; gap: 0; border-radius: var(--radius);
  overflow: hidden; border: 1.5px solid var(--border);
  background: var(--bg2);
  transition: border-color .2s;
}
.search-bar:focus-within { border-color: var(--purple); }
.search-bar input {
  flex: 1; background: transparent; border: none; outline: none;
  padding: 14px 18px; color: var(--text); font-size: 1rem; font-family: 'Inter', sans-serif;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar button {
  padding: 0 22px; background: linear-gradient(135deg, var(--purple-d), var(--pink));
  border: none; cursor: pointer; color: #fff; font-weight: 600; font-size: 0.95rem;
  transition: opacity .2s;
}
.search-bar button:hover { opacity: .85; }

/* ===== GENRE PILLS ===== */
.genre-section { max-width: 1200px; margin: 0 auto; padding: 2.5rem 1.5rem 1.5rem; }
.genre-section h2 { font-size: 1.1rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 1rem; }
.pill-list { display: flex; flex-wrap: wrap; gap: .6rem; }
.pill {
  padding: 7px 18px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--bg2);
  color: var(--text); font-size: .875rem; font-weight: 500;
  cursor: pointer; transition: all .2s;
}
.pill:hover { border-color: var(--purple); color: var(--purple); background: rgba(192,132,252,.08); }
.pill.active { border-color: var(--purple); background: rgba(192,132,252,.15); color: var(--purple); }

/* ===== SECTIONS ===== */
.section { max-width: 1200px; margin: 0 auto; padding: 2.5rem 1.5rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.section-header h2 { font-size: 1.5rem; }
.section-header a { font-size: .875rem; color: var(--text-muted); }
.section-header a:hover { color: var(--purple); }

/* ===== ANIME CARD GRID ===== */
.anime-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 1.25rem;
}
.anime-card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
  transition: transform .2s, border-color .2s, box-shadow .2s;
  cursor: pointer;
}
.anime-card:hover { transform: translateY(-4px); border-color: var(--purple); box-shadow: 0 8px 32px rgba(168,85,247,.2); }
.card-cover { position: relative; aspect-ratio: 2/3; overflow: hidden; }
.card-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.anime-card:hover .card-cover img { transform: scale(1.05); }
.card-score {
  position: absolute; top: 8px; right: 8px;
  background: rgba(13,13,26,.85); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 8px; font-size: .75rem; font-weight: 700;
  color: var(--purple);
}
.card-body { padding: 10px 12px 12px; }
.card-title { font-family: 'Nunito', sans-serif; font-weight: 700; font-size: .9rem; line-height: 1.3; margin-bottom: 4px; }
.card-meta { font-size: .78rem; color: var(--text-muted); }

/* ===== BROWSE LAYOUT ===== */
.browse-layout { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; display: flex; gap: 2rem; align-items: flex-start; }
.sidebar { width: 220px; flex-shrink: 0; }
.sidebar-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.sidebar-box h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: .85rem; }
.filter-list { list-style: none; display: flex; flex-direction: column; gap: .35rem; }
.filter-list label { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .875rem; }
.filter-list input[type=checkbox] { accent-color: var(--purple); }
.browse-main { flex: 1; min-width: 0; }
.browse-controls { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; gap: 1rem; }
.browse-controls select {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font-size: .875rem; outline: none; cursor: pointer;
}
.browse-controls select:focus { border-color: var(--purple); }
#results-count { font-size: .875rem; color: var(--text-muted); }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: .5rem; margin-top: 2.5rem; flex-wrap: wrap; }
.pagination button {
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text); cursor: pointer; font-size: .875rem;
  transition: all .2s;
}
.pagination button:hover { border-color: var(--purple); color: var(--purple); }
.pagination button.active { background: var(--purple-d); border-color: var(--purple-d); color: #fff; }
.pagination button:disabled { opacity: .35; cursor: default; }

/* ===== SEARCH PAGE ===== */
.search-page { max-width: 900px; margin: 0 auto; padding: 2.5rem 1.5rem; }
.search-page .search-bar { max-width: 100%; margin-bottom: 2rem; }
#search-results-grid { margin-top: 1.5rem; }

/* ===== ANIME DETAIL ===== */
.anime-banner { width: 100%; height: 280px; object-fit: cover; filter: brightness(.45); position: absolute; inset: 0; }
.anime-hero { position: relative; height: 280px; overflow: hidden; margin-bottom: 0; }
.anime-hero-overlay { position: absolute; inset: 0; background: linear-gradient(to top, var(--bg) 0%, transparent 60%); }

.anime-detail { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem 3rem; }
.anime-meta-row { display: flex; gap: 2rem; margin-top: -80px; position: relative; z-index: 2; align-items: flex-end; flex-wrap: wrap; }
.anime-cover { width: 150px; height: 215px; object-fit: cover; border-radius: var(--radius); border: 3px solid var(--border); flex-shrink: 0; box-shadow: var(--shadow); }
.anime-info { flex: 1; padding-bottom: .5rem; }
.anime-info h1 { font-size: clamp(1.4rem, 4vw, 2rem); margin-bottom: .25rem; }
.anime-info .ja-title { color: var(--text-muted); font-size: 1rem; margin-bottom: .75rem; }
.anime-badges { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.badge { padding: 4px 12px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--bg3); border: 1px solid var(--border); }
.badge.score { background: rgba(192,132,252,.15); border-color: var(--purple); color: var(--purple); }
.badge.genre { color: var(--text-muted); }

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: 10px 22px; border-radius: 10px; font-weight: 600; font-size: .9rem;
  border: none; cursor: pointer; transition: all .2s;
}
.btn-primary { background: linear-gradient(135deg, var(--purple-d), var(--pink)); color: #fff; }
.btn-primary:hover { opacity: .88; color: #fff; }
.btn-amazon { background: #ff9900; color: #111; }
.btn-amazon:hover { background: #e68a00; color: #111; }

.anime-body { margin-top: 2.5rem; display: grid; grid-template-columns: 1fr 320px; gap: 2rem; align-items: start; }
.synopsis { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; }
.synopsis h2 { font-size: 1.1rem; margin-bottom: .75rem; }
.synopsis p { color: var(--text-muted); line-height: 1.75; }

/* Theme sections */
.themes-section { margin-bottom: 2rem; }
.themes-section h2 { font-size: 1.3rem; margin-bottom: 1rem; }
.season-tabs { display: flex; gap: .5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.tab-btn { padding: 6px 16px; border-radius: 8px; border: 1.5px solid var(--border); background: transparent; color: var(--text-muted); cursor: pointer; font-size: .85rem; transition: all .2s; }
.tab-btn.active { border-color: var(--purple); color: var(--purple); background: rgba(192,132,252,.1); }
.theme-list { display: flex; flex-direction: column; gap: 1.25rem; }
.theme-item { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.theme-label { padding: .75rem 1rem; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--purple); background: rgba(192,132,252,.07); display: flex; justify-content: space-between; align-items: center; }
.theme-title { padding: .6rem 1rem; font-weight: 600; font-size: .9rem; border-bottom: 1px solid var(--border); }
.theme-embed { aspect-ratio: 16/9; }
.theme-embed iframe { width: 100%; height: 100%; border: none; }
.no-video { aspect-ratio: 16/9; background: var(--bg3); display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: .875rem; }

/* Sidebar panel */
.anime-sidebar-panel .sidebar-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.anime-sidebar-panel h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: .85rem; }
.meta-list { list-style: none; display: flex; flex-direction: column; gap: .6rem; font-size: .875rem; }
.meta-list li { display: flex; justify-content: space-between; gap: .5rem; }
.meta-list .key { color: var(--text-muted); }
.meta-list .val { font-weight: 500; text-align: right; }

/* ===== FOOTER ===== */
footer {
  border-top: 1px solid var(--border);
  background: var(--bg2);
  padding: 2.5rem 1.5rem;
  margin-top: 4rem;
}
.footer-inner { max-width: 1200px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 2rem; justify-content: space-between; align-items: flex-start; }
.footer-brand img { width: 40px; border-radius: 10px; margin-bottom: .5rem; }
.footer-brand .site-name { font-family: 'Nunito', sans-serif; font-weight: 900; font-size: 1.1rem; background: linear-gradient(135deg, var(--purple), var(--pink)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.footer-brand p { color: var(--text-muted); font-size: .8rem; margin-top: .25rem; }
.footer-links { display: flex; gap: 3rem; flex-wrap: wrap; }
.footer-links ul { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.footer-links h4 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: .5rem; }
.footer-links a { font-size: .875rem; color: var(--text-muted); transition: color .2s; }
.footer-links a:hover { color: var(--purple); }
.footer-bottom { max-width: 1200px; margin: 1.5rem auto 0; padding-top: 1rem; border-top: 1px solid var(--border); font-size: .8rem; color: var(--text-muted); text-align: center; }

/* ===== UTILITY ===== */
.page-header { padding: 2.5rem 1.5rem 1rem; max-width: 1200px; margin: 0 auto; }
.page-header h1 { font-size: 2rem; }
.page-header p { color: var(--text-muted); margin-top: .25rem; }

.empty-state { text-align: center; padding: 4rem 1rem; color: var(--text-muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .browse-layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .anime-body { grid-template-columns: 1fr; }
  .anime-meta-row { margin-top: -60px; }
  .anime-cover { width: 110px; height: 158px; }
  .footer-links { gap: 1.5rem; }
}
@media (max-width: 480px) {
  .anime-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .nav-links a { padding: 6px 10px; font-size: .82rem; }
}

/* ── External Link Badges ── */
.ext-link {
  display: inline-flex; align-items: center;
  padding: .3rem .7rem; border-radius: 20px;
  font-size: .75rem; font-weight: 600;
  text-decoration: none; transition: opacity .2s;
}
.ext-link:hover { opacity: .8; text-decoration: none; }
.ext-link.mal     { background: #2e51a2; color: #fff; }
.ext-link.anidb   { background: #c2184a; color: #fff; }
.ext-link.ap      { background: #e85d75; color: #fff; }
.ext-link.tmdb    { background: #01b4e4; color: #fff; }
