:root {
  --bg: #0a0d14;
  --bg-2: #0e131d;
  --card: #161c28;
  --card-2: #1d2533;
  --line: #232c3d;
  --text: #e8edf5;
  --muted: #8b98ad;
  --accent: #4f8cff;
  --accent-hover: #6aa0ff;
  --star: #f5c518;
  --radius: 8px;
  --radius-lg: 12px;
  --wrap: 1280px;
  --gap: 16px;
  --section: 80px;
  --fast: 150ms;
  --dur: 250ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --nav-h: 58px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input { font: inherit; }

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.wrap-wide { max-width: 1100px; }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 13, 20, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.header-inner { display: flex; align-items: center; gap: 20px; height: 64px; }

.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; letter-spacing: -0.02em; white-space: nowrap; }
.logo-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #7b5cff);
  color: #fff;
  font-size: 12px;
}

.searchbar { position: relative; display: flex; flex: 1; max-width: 420px; min-width: 0; }
.searchbar input {
  width: 100%;
  height: 40px;
  padding: 0 44px 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--text);
  font-size: 14px;
}
.searchbar input::placeholder { color: var(--muted); }
.searchbar input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18); }
.searchbar button {
  position: absolute;
  right: 4px;
  top: 4px;
  min-width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}
.searchbar button:hover { color: var(--text); background: var(--card-2); }

.main-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.main-nav > a, .nav-drop-btn {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.main-nav > a:hover, .nav-drop-btn:hover { color: var(--text); background: var(--card); }

.nav-drop { position: relative; }
.nav-drop-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  display: none;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 2px;
  min-width: 320px;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.nav-drop.open .nav-drop-menu { display: grid; }
.nav-drop-menu a { padding: 10px; border-radius: 6px; font-size: 13px; color: var(--muted); min-height: 40px; display: flex; align-items: center; }
.nav-drop-menu a:hover { background: var(--card-2); color: var(--text); }
.nav-drop-menu .nav-more { grid-column: 1 / -1; color: var(--accent); font-weight: 600; }

/* ---------- bottom nav (mobile) ---------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: none;
  background: rgba(12, 16, 24, 0.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--nav-h);
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  transition: color var(--fast) var(--ease);
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.is-active { color: var(--accent); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--card); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--card-2); border-color: #33405a; }
.btn.is-disabled, .page-btn.is-disabled { opacity: 0.4; pointer-events: none; }

/* ---------- hero ---------- */
.hero { position: relative; margin-bottom: var(--section); border-bottom: 1px solid var(--line); overflow: hidden; }
.hero-bg { position: absolute; inset: 0; z-index: 0; }
.hero-bg img { width: 100%; height: 100%; object-fit: cover; opacity: 0.28; }
.hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 13, 20, 0.35) 0%, var(--bg) 92%);
}
.hero-inner { position: relative; z-index: 1; display: flex; gap: 32px; align-items: center; padding-top: 56px; padding-bottom: 56px; }
.hero-poster { flex: 0 0 200px; }
.hero-poster img { width: 200px; border-radius: var(--radius-lg); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6); }
.hero-kicker { margin: 0 0 8px; color: var(--accent); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.hero-body h1 { font-size: clamp(26px, 4vw, 44px); }
.hero-meta { display: flex; flex-wrap: wrap; gap: 14px; margin: 14px 0; color: var(--muted); font-size: 14px; }
.hero-meta .rate { color: var(--star); }
.hero-overview { max-width: 620px; color: #c3ccdb; font-size: 15px; }
.hero-actions { display: flex; gap: 12px; margin-top: 24px; }

/* ---------- sections ---------- */
.section { margin-bottom: var(--section); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-title { font-size: 22px; }
.section-subtitle { margin: 24px 0 8px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.section-more { color: var(--accent); font-size: 14px; font-weight: 600; white-space: nowrap; }
.section-more:hover { color: var(--accent-hover); }

.page-head { padding: 40px 0 24px; }
.page-head h1 { font-size: 30px; }
.page-count { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- grid + cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--gap) 16px; }
.card { background: transparent; }
.card-link { display: block; }
.card-poster {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  aspect-ratio: 2 / 3;
  border: 1px solid var(--line);
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.card-poster img { width: 100%; height: 100%; object-fit: cover; }
.card-link:hover .card-poster { transform: translateY(-4px); border-color: var(--accent); }
.card-title {
  margin: 10px 0 2px;
  font-size: 14px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-link:hover .card-title { color: var(--accent); }
.card-meta { margin: 0; color: var(--muted); font-size: 12px; }

.badge {
  position: absolute;
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(6px);
}
.badge-type { top: 8px; left: 8px; background: rgba(10, 13, 20, 0.72); color: #cfd8e6; }
.badge-rate { bottom: 8px; right: 8px; background: rgba(10, 13, 20, 0.72); color: var(--star); }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: #c3ccdb;
  font-size: 13px;
  transition: border-color var(--fast) var(--ease), color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--text); background: var(--card-2); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-count { color: var(--muted); font-size: 11px; }
.chips-detail { margin: 16px 0; }
.chips-block { margin-top: 18px; }
.seasons { margin-bottom: 20px; }

/* ---------- pager ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 40px 0; }
.page-btn { display: inline-flex; align-items: center; min-height: 44px; padding: 9px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); font-size: 14px; }
.page-btn:hover { border-color: var(--accent); }
.page-info { color: var(--muted); font-size: 13px; }

/* ---------- detail ---------- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 24px 0; color: var(--muted); font-size: 13px; }
.crumbs a:hover { color: var(--accent); }
.crumbs-here { color: var(--text); }

.detail { display: grid; grid-template-columns: 300px 1fr; gap: 40px; margin-bottom: 56px; }
.detail-poster img { width: 100%; border-radius: var(--radius-lg); border: 1px solid var(--line); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5); }
.detail-body h1 { font-size: clamp(24px, 3.4vw, 38px); }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 14px 0; color: var(--muted); font-size: 14px; }
.detail-meta .rate { color: var(--star); font-weight: 600; }
.detail-meta a { color: var(--accent); }
.tag { padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; }
.tag-type { background: var(--accent); border-color: var(--accent); color: #fff; }
.detail-tagline { color: #b9c4d4; font-style: italic; }
.detail-overview { max-width: 760px; color: #c3ccdb; }
.detail-actions { display: flex; gap: 12px; margin: 22px 0; }
.detail-crew { margin-top: 20px; font-size: 14px; color: var(--muted); }
.detail-crew a { color: #c3ccdb; }
.detail-crew a:hover { color: var(--accent); }

/* ---------- episodes ---------- */
.ep-list { display: flex; flex-direction: column; gap: 8px; }
.ep-item {
  display: grid;
  grid-template-columns: 72px auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  min-height: 56px;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.ep-item:hover { border-color: var(--accent); background: var(--card-2); }
.ep-item.is-active { border-color: var(--accent); }
.ep-thumb { width: 72px; aspect-ratio: 16 / 10; border-radius: 6px; overflow: hidden; background: var(--bg-2); }
.ep-thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 0.85; }
.ep-num { font-size: 13px; font-weight: 700; color: var(--accent); min-width: 42px; }
.ep-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-date { color: var(--muted); font-size: 12px; }
.ep-list-compact .ep-item { grid-template-columns: auto 1fr; }
.ep-list-compact .ep-thumb { display: none; }

/* ---------- player ---------- */
.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 18px;
}
.player-frame, .player-video { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.player-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); }
.watch-inline { width: 100%; max-width: 880px; aspect-ratio: 16 / 9; background: #000; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }

.servers { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.servers-label { color: var(--muted); font-size: 13px; margin-right: 4px; }
.server-btn { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); font-size: 13px; font-weight: 600; }
.server-btn:hover { border-color: var(--accent); }
.server-btn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.server-btn.is-dead, .download-btn.is-dead { opacity: .45; cursor: not-allowed; border-style: dashed; }
.server-btn.is-dead em, .download-btn.is-dead em { font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; margin-left: 8px; padding: 1px 6px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--muted); }

.watch-head { margin-bottom: 20px; }
.watch-head h1 { font-size: 24px; }
.ep-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }

/* ---------- downloads ---------- */
.downloads { margin-bottom: var(--section); }
.download-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.download-btn { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); font-size: 13px; font-weight: 600; }
.download-btn:hover { border-color: var(--accent); background: var(--card-2); }

/* ---------- misc ---------- */
.empty { color: var(--muted); padding: 20px 0; }
.searchbar-inline { max-width: 480px; margin-top: 14px; }
.searchbar-inline button { position: static; min-width: auto; height: 40px; padding: 0 16px; margin-left: 8px; border-radius: var(--radius); background: var(--accent); color: #fff; font-weight: 600; }

.error-page { text-align: center; padding: 80px 0 120px; }
.error-code { font-size: 72px; font-weight: 800; color: var(--accent); margin: 0; }
.error-hint { color: var(--muted); margin-bottom: 24px; }

/* ---------- adult (18+) gate ---------- */
.badge-18 {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: #e5484d;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}
.adult-body { position: relative; }
.adult-veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: rgba(10, 13, 20, 0.55);
  border-radius: var(--radius-lg);
}
.adult-warn { margin: 0; max-width: 440px; color: #cfd8e6; font-size: 14px; }
html:not(.adult-ok) .adult-section .grid { filter: blur(16px); pointer-events: none; user-select: none; }
html.adult-ok .adult-veil { display: none; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 48px 0 32px; background: var(--bg-2); }
.footer-inner { display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; }
.footer-brand { font-weight: 700; }
.footer-brand p { margin: 8px 0 0; color: var(--muted); font-weight: 400; font-size: 14px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 20px; color: var(--muted); font-size: 14px; }
.footer-links a:hover { color: var(--accent); }
.footer-note { max-width: var(--wrap); margin: 32px auto 0; padding: 0 20px; color: #5c6779; font-size: 12px; }
.histats-counter { margin-top: 20px; text-align: center; opacity: .8; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .detail { grid-template-columns: 240px 1fr; gap: 28px; }
}

@media (max-width: 860px) {
  :root { --section: 48px; }

  /* nav: hide desktop nav, show bottom nav */
  .main-nav { display: none; }
  .bottom-nav { display: flex; }
  body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

  .header-inner { height: 60px; gap: 10px; }
  .logo { font-size: 17px; }
  .logo-mark { width: 24px; height: 24px; border-radius: 6px; font-size: 10px; }
  .searchbar { max-width: none; }
  .searchbar input { height: 38px; font-size: 16px; } /* 16px = no iOS zoom on focus */
  .searchbar button { top: 3px; height: 32px; }

  /* content */
  .wrap { padding: 0 14px; }
  .hero { margin-bottom: 32px; }
  .hero-inner { flex-direction: column; align-items: flex-start; gap: 16px; padding-top: 28px; padding-bottom: 28px; }
  .hero-poster { flex-basis: auto; }
  .hero-poster img { width: 140px; }
  .hero-overview { font-size: 14px; }
  .hero-actions { width: 100%; margin-top: 18px; }
  .hero-actions .btn { flex: 1; }

  .page-head { padding: 24px 0 18px; }
  .page-head h1 { font-size: 24px; }
  .section-title { font-size: 19px; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(114px, 1fr)); gap: 14px 10px; }
  .card-title { font-size: 13px; margin-top: 8px; }

  /* horizontal scrollers for chips / servers */
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; }
  .servers { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .servers::-webkit-scrollbar { display: none; }
  .server-btn { flex: 0 0 auto; }
  .download-grid { display: grid; grid-template-columns: repeat(2, 1fr); }

  /* detail */
  .crumbs { padding: 16px 0; }
  .detail { grid-template-columns: 1fr; gap: 18px; margin-bottom: 36px; }
  .detail-poster { max-width: 150px; }
  .detail-actions .btn { flex: 1; }

  /* episodes */
  .ep-item { grid-template-columns: auto 1fr; gap: 10px; padding: 10px 12px; }
  .ep-thumb, .ep-date { display: none; }

  /* player: edge to edge */
  .player-wrap {
    margin-left: -14px;
    margin-right: -14px;
    width: calc(100% + 28px);
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }
  .watch-inline { border-radius: var(--radius); }
  .watch-head h1 { font-size: 20px; }
  .ep-nav { gap: 8px; }
  .ep-nav .btn { flex: 1; padding: 0 10px; }

  .footer-links { gap: 14px; }
}

@media (max-width: 420px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .logo-text { font-size: 16px; }
}
