:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface2: #22222e;
  --border: #2e2e3e;
  --accent: #7c5cfc;
  --accent2: #a07cff;
  --success: #22c55e;
  --danger: #ef4444;
  --text: #e8e8f0;
  --muted: #888899;
  --radius: 10px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', 'Noto Sans Thai', system-ui, sans-serif;
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { color: var(--text); }
img { max-width: 100%; display: block; }

/* ── Header ── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 62px;
  width: 100%;
  box-sizing: border-box;
}
.site-logo {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}
.site-nav { display: flex; gap: 4px; flex: 1; }
.site-nav a {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--muted);
  transition: color .2s, background .2s;
}
.site-nav a:hover, .site-nav a.current { color: var(--text); background: var(--surface2); }

.search-form-header {
  display: flex;
  gap: 6px;
}
.search-form-header input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 20px;
  font-size: .88rem;
  outline: none;
  width: 220px;
  transition: border-color .2s;
}
.search-form-header input:focus { border-color: var(--accent); }
.search-form-header button {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 7px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: .85rem;
}

/* ── Layout ── */
.site-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px;
}
.content-sidebar {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
}
@media (max-width: 900px) {
  .content-sidebar { grid-template-columns: 1fr; }
  .site-sidebar { display: none; }
}

/* ── Section Heading ── */
.section-heading {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Series Grid ── */
.series-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.series-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s, transform .15s, box-shadow .2s;
  cursor: pointer;
  position: relative;
}
.series-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(124,92,252,.2);
}
.series-card-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: var(--surface2);
}
.series-card-poster-ph {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--muted);
}
.series-card-body { padding: 10px; }
.series-card-title {
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text);
}
.series-card-meta { font-size: .72rem; color: var(--muted); margin-top: 4px; }
.series-card-rating { font-size: .7rem; color: #f59e0b; }

/* ── Hero Banner ── */
.hero-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0;
  margin-bottom: 36px;
}
.hero-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
}
.hero-body {
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}
.hero-title { font-size: 1.8rem; font-weight: 800; line-height: 1.2; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: .85rem; color: var(--muted); }
.meta-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .78rem;
}
.meta-badge-accent { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }
a.meta-badge-accent:hover { background: var(--accent2) !important; border-color: var(--accent2) !important; opacity: .9; }
.hero-desc { font-size: .9rem; color: var(--muted); line-height: 1.7; max-width: 700px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
@media (max-width: 640px) {
  .hero-banner { grid-template-columns: 1fr; }
  .hero-poster { aspect-ratio: 16/9; }
  .hero-body { padding: 20px; }
  .hero-title { font-size: 1.3rem; }
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  border-radius: var(--radius);
  border: none;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-success  { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: .82rem; }

/* ── Season / Episode Tabs ── */
.season-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 24px 0 16px;
}
.season-btn {
  padding: 6px 18px;
  border-radius: 20px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  transition: all .2s;
}
.season-btn.active, .season-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Episode List ── */
.episode-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.episode-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .2s, background .2s;
  text-decoration: none;
  color: var(--text);
}
.episode-item:hover { border-color: var(--accent); background: var(--surface2); }
.episode-item.active { border-color: var(--accent); background: rgba(124,92,252,.15); }
.episode-item.ep-watched .ep-num-badge { background: transparent; border: 1.5px solid var(--accent); color: var(--accent2); }
.episode-item.ep-watched .ep-title-text { color: var(--muted); }
.ep-num-badge {
  min-width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  color: #fff;
  flex-shrink: 0;
}
.ep-info { flex: 1; }
.ep-title-text { font-weight: 600; font-size: .88rem; }
.ep-sub-info { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.ep-play-icon { color: var(--muted); font-size: 1.2rem; }

/* ── Video Player ── */
.player-wrap {
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 24px;
  position: relative;
  aspect-ratio: 16/9;
}
.player-video {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Watch page layout ── */
.watch-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
}
.watch-main { min-width: 0; }
.watch-side {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.watch-side-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--accent2);
}
@media (max-width: 960px) {
  .watch-layout { grid-template-columns: 1fr; }
}

/* ── Pagination ── */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 32px;
}
.page-number, .page-numbers {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: .85rem;
  transition: all .15s;
}
.page-number:hover, .page-numbers:hover { border-color: var(--accent); color: var(--accent2); }
.page-number.current, .page-numbers.current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

/* ── Sidebar ── */
.site-sidebar { min-width: 0; }
.widget { margin-bottom: 24px; }
.widget-title {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--accent2);
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  align-items: center;
}
.filter-bar select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: .88rem;
  outline: none;
  cursor: pointer;
}
.filter-bar select:focus { border-color: var(--accent); }

/* ── Breadcrumb ── */
.breadcrumb {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 20px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent2); }
.breadcrumb .sep { color: var(--border); }

/* ── Footer ── */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  font-size: .82rem;
  color: var(--muted);
  margin-top: 60px;
}

/* ── Toast ── */
#nana-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.nana-toast-item {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: .88rem;
  max-width: 320px;
  animation: slideIn .3s ease;
  pointer-events: auto;
  border: 1px solid transparent;
}
.nana-toast-success { background: #14532d; border-color: var(--success); color: #86efac; }
.nana-toast-error   { background: #450a0a; border-color: var(--danger); color: #fca5a5; }
.nana-toast-info    { background: #1e1b4b; border-color: var(--accent); color: var(--accent2); }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }

/* ── Loading Spinner ── */
@keyframes spin { to { transform: rotate(360deg); } }
.loader { text-align: center; padding: 60px 24px; color: var(--muted); }
.spinner-lg {
  display: inline-block;
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-bottom: 12px;
}

/* ── Genre tag cloud ── */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: .78rem;
  padding: 4px 12px;
  border-radius: 99px;
  transition: all .2s;
}
.tag-item:hover { border-color: var(--accent); color: var(--accent2); background: rgba(124,92,252,.1); }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--muted);
}
.empty-state h2 { font-size: 1.2rem; margin-bottom: 8px; color: var(--text); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
