:root {
  --bg: #0a0a0f;
  --bg2: #12121a;
  --card: #151527;
  --card2: #1c1c30;
  --border: #26263a;
  --text: #eceaf4;
  --text-dim: #a7a5bd;
  --text-muted: #6f6d8a;
  --purple: #8b5cf6;
  --purple-2: #6c2bd9;
  --accent: #22d3ee;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0,0,0,0.45);
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

#app { display: flex; flex-direction: column; min-height: 100vh; }
.site-main { flex: 1; }
.container { max-width: 1280px; margin: 0 auto; padding: 0 32px; }

/* ── Header / nav ─────────────────────────────── */
.nav { position: sticky; top: 0; z-index: 100; background: rgba(10,10,15,0.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.nav-inner { max-width: 1280px; margin: 0 auto; padding: 0 32px; height: 64px; display: flex; align-items: center; gap: 28px; }
.brand { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; background: linear-gradient(135deg, var(--purple), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav-links { display: flex; gap: 22px; flex: 1; }
.nav-links a { color: var(--text-dim); font-weight: 500; font-size: 0.95rem; padding: 6px 2px; border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s; }
.nav-links a:hover { color: var(--text); }
.nav-links a.active, .nav-links a:hover { border-color: var(--purple); }
.nav-auth { display: flex; align-items: center; gap: 12px; }

/* ── Buttons ──────────────────────────────────── */
.btn-primary, .btn-outline, .btn-ghost, .btn-google {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 10px; font-weight: 600; font-size: 0.92rem;
  border: 1px solid transparent; transition: opacity 0.15s, transform 0.1s, background 0.15s; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--purple), var(--purple-2)); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--purple); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); }
.btn-google { background: #fff; color: #1f2937; font-weight: 600; width: 100%; }
.btn-google:hover { opacity: 0.92; }
.btn-block { width: 100%; }
.btn-primary:active, .btn-outline:active, .btn-ghost:active { transform: scale(0.98); }

/* ── Hero ─────────────────────────────────────── */
.hero { min-height: 420px; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0a0a0f 100%); background-size: cover; background-position: center; display: flex; align-items: center; padding: 48px 32px; }
.hero-inner { max-width: 1280px; margin: 0 auto; width: 100%; }
.hero h1 { font-size: 3rem; font-weight: 800; margin: 0 0 16px; max-width: 720px; line-height: 1.1; }
.hero p { font-size: 1.1rem; color: var(--text-dim); max-width: 620px; margin: 0 0 28px; }
.hero-actions { display: flex; align-items: center; gap: 14px; }

/* ── Sections & grids ─────────────────────────── */
.section-header { display: flex; align-items: baseline; justify-content: space-between; margin: 36px 0 16px; }
.section-header h2 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.section-link { color: var(--purple); font-weight: 500; font-size: 0.9rem; }
.section-link:hover { text-decoration: underline; }
.anime-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 22px; }
.anime-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s; cursor: pointer; }
.anime-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--purple); }
.anime-card-img { position: relative; aspect-ratio: 2/3; background: var(--card2); overflow: hidden; }
.anime-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge-premium { position: absolute; top: 8px; left: 8px; background: rgba(139,92,246,0.9); color: #fff; font-size: 0.65rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.badge-rating { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,0.7); color: #ffd700; font-size: 0.72rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.badge-ep { position: absolute; top: 8px; right: 8px; background: rgba(34,211,238,0.9); color: #0a0a0f; font-size: 0.7rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.progress-bar { position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: rgba(255,255,255,0.2); }
.progress-bar div { height: 100%; background: var(--purple); }
.anime-card-title { padding: 10px 12px 2px; font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.anime-card-sub { padding: 0 12px 10px; color: var(--text-muted); font-size: 0.8rem; }

/* ── Page toolbar ─────────────────────────────── */
.page { padding: 36px 0 80px; }
.page h1 { font-size: 1.8rem; margin: 0; }
.page-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.toolbar-controls, .search-bar { display: flex; gap: 10px; align-items: center; }
.page-toolbar select, .toolbar-controls input, .search-bar input {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 10px 14px; font-size: 0.92rem; min-width: 220px;
}
.search-bar { flex: 1; max-width: 420px; }
.grid-loading { color: var(--text-muted); padding: 30px 0; text-align: center; }
.empty { color: var(--text-muted); text-align: center; padding: 40px 0; }
.watchlist-entry { min-width: 0; }
.watchlist-entry .btn-ghost { width: 100%; margin-top: 8px; }
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-entry { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; }

/* ── Auth ─────────────────────────────────────── */
.auth-page { display: flex; justify-content: center; align-items: flex-start; padding-top: 60px; }
.auth-card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 36px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.5rem; margin: 0 0 20px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; font-weight: 500; color: var(--text-dim); }
.auth-card input { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; color: var(--text); font-size: 0.95rem; }
.auth-card input:focus { outline: none; border-color: var(--purple); }
.form-error { color: var(--danger); font-size: 0.85rem; margin-bottom: 10px; min-height: 1.2em; }
.auth-alt { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--text-muted); font-size: 0.8rem; }
.auth-alt::before, .auth-alt::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-switch { margin-top: 18px; text-align: center; font-size: 0.88rem; color: var(--text-dim); }
.auth-switch a { color: var(--purple); font-weight: 600; }

/* ── Anime detail ─────────────────────────────── */
.anime-hero { margin: -36px -32px 0; padding: 48px 32px; background-size: cover; background-position: center; }
.anime-hero-inner { max-width: 1280px; margin: 0 auto; display: flex; gap: 32px; align-items: flex-end; }
.anime-poster { width: 240px; flex-shrink: 0; }
.anime-poster img { width: 100%; border-radius: 16px; box-shadow: var(--shadow); display: block; }
.anime-info h1 { font-size: 2.4rem; margin: 0 0 8px; }
.meta-line { color: var(--text-dim); margin-bottom: 10px; font-size: 0.95rem; }
.genres { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.genre-pill { background: rgba(139,92,246,0.15); border: 1px solid rgba(139,92,246,0.3); color: var(--purple); font-size: 0.78rem; font-weight: 600; padding: 4px 12px; border-radius: 20px; }
.desc { color: var(--text-dim); line-height: 1.6; max-width: 720px; margin-bottom: 24px; }
.episodes-section, .recommend-section { margin-top: 36px; }
.episodes-section h2, .recommend-section h2 { font-size: 1.3rem; }
.episode-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; max-height: 420px; overflow-y: auto; padding-right: 8px; }
.episode-item { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; color: var(--text); text-align: left; transition: border-color 0.15s, background 0.15s; }
.episode-item:hover { border-color: var(--purple); background: var(--card2); }
.episode-item.active { border-color: var(--purple); background: rgba(139,92,246,0.1); }
.ep-num { background: rgba(139,92,246,0.15); color: var(--purple); width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-weight: 700; flex-shrink: 0; }
.ep-title { flex: 1; font-weight: 500; }
.ep-lock { color: var(--text-muted); }

/* ── Watch page ───────────────────────────────── */
.watch-page { padding: 24px 0; }
.watch-container { max-width: 1100px; margin: 0 auto; padding: 0 32px; }
.player-stage { position: relative; background: #000; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.video-element { width: 100%; aspect-ratio: 16/9; display: block; background: #000; }
.player-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10,10,15,0.72); color: var(--text); text-align: center; padding: 24px; }
.player-error { position: absolute; inset: 0; background: rgba(10,10,15,0.9); display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 16px; color: var(--text); text-align: center; padding: 24px; }
.autoplay-next { position: absolute; right: 16px; bottom: 16px; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 10px; background: rgba(10,10,15,0.9); color: var(--text); }
.watch-nav, .season-nav { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.season-nav select { margin-left: 6px; }
.upgrade-banner { display: flex; align-items: center; justify-content: space-between; background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.3); border-radius: 12px; padding: 16px 20px; margin-top: 16px; }
.watch-meta { margin: 20px 0 0; }
.watch-meta h2 { margin: 0; font-size: 1.3rem; }
.episode-list { margin-top: 20px; }
.watch-back { margin-top: 20px; }

/* ── Profile ──────────────────────────────────── */
.profile-grid { display: grid; grid-template-columns: 300px 1fr; gap: 32px; }
.profile-card, .settings-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 28px; text-align: center; }
.profile-card h2 { margin: 12px 0 4px; }
.profile-card .muted { color: var(--text-muted); margin: 0 0 14px; }
.avatar-wrap { width: 120px; height: 120px; margin: 0 auto; border-radius: 50%; overflow: hidden; border: 3px solid var(--purple); }
.avatar { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-meta { margin-bottom: 18px; }
.profile-card .btn-block { margin-top: 10px; }
.settings-card { text-align: left; color: var(--text); }
.settings-card h3 { margin-top: 0; }
.settings-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 14px; }
.settings-card label.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.settings-card input[type="text"] { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; color: var(--text); }

/* ── Plans ────────────────────────────────────── */
.plans { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; max-width: 720px; margin-top: 24px; }
.plan { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 32px; text-align: center; }
.plan.featured { border-color: var(--purple); box-shadow: var(--shadow); }
.plan h3 { margin: 0 0 8px; }
.price { font-size: 2rem; font-weight: 800; margin-bottom: 18px; }
.price span { font-size: 0.85rem; color: var(--text-muted); font-weight: 400; }
.premium-card { max-width: 500px; text-align: center; padding: 48px; margin: 40px auto; }

/* ── Toast ────────────────────────────────────── */
.toast-root { position: fixed; bottom: 24px; right: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--card2); border: 1px solid var(--border); color: var(--text); padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: opacity 0.3s, transform 0.3s; max-width: 340px; font-size: 0.9rem; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: var(--danger); }
.toast.info { border-color: var(--accent); }

/* ── Footer ───────────────────────────────────── */
.site-footer { border-top: 1px solid var(--border); margin-top: auto; }
.footer-inner { max-width: 1280px; margin: 0 auto; padding: 24px 32px; display: flex; align-items: center; justify-content: space-between; color: var(--text-muted); font-size: 0.85rem; }
.footer-links { display: flex; gap: 20px; }
.footer-links a { color: var(--text-dim); }
.footer-links a:hover { color: var(--purple); }

/* ── Responsive (tablet/phone, still web-first) ── */
@media (max-width: 900px) {
  .profile-grid { grid-template-columns: 1fr; }
  .anime-hero-inner { flex-direction: column; align-items: flex-start; }
  .nav-links { gap: 12px; }
}
@media (max-width: 640px) {
  .nav-inner { padding: 0 16px; gap: 14px; }
  .container { padding: 0 16px; }
  .nav-links { display: none; }
  .anime-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .hero h1 { font-size: 2rem; }
  .plans { grid-template-columns: 1fr; }
  .anime-hero { margin: -36px -16px 0; padding: 32px 16px; }
  .watch-container { padding: 0 16px; }
  .page-toolbar { flex-direction: column; align-items: stretch; }
  .history-entry { align-items: flex-start; flex-direction: column; }
  .search-bar { max-width: 100%; }
}
