:root {
  --bg0: #040610;
  --bg1: #080d1a;
  --panel: rgba(13, 20, 36, 0.78);
  --panel-solid: #0b1220;
  --line: #1e293b;
  --line-soft: rgba(56, 189, 248, 0.14);
  --text: #e2e8f0;
  --muted: #64748b;
  --muted-2: #8394ad;
  --cyan: #0bb8d6;
  --sky: #38bdf8;
  --blue: #3b82f6;
  --indigo: #6366f1;
  --violet: #8b8cf5;
  --teal: #00d1c1;
  --grad: linear-gradient(135deg, #0bb8d6 0%, #3b82f6 55%, #6366f1 100%);
  --grad-teal: linear-gradient(135deg, #8b8cf5 0%, #00a8e0 50%, #00d1c1 100%);
  --glow: 0 0 22px rgba(56, 189, 248, 0.35);
  --radius: 16px;
  --font: "Segoe UI", "Helvetica Neue", Inter, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(1200px 700px at 78% -10%, rgba(59, 130, 246, 0.14), transparent 60%),
    radial-gradient(900px 600px at 5% 10%, rgba(11, 184, 214, 0.1), transparent 60%),
    linear-gradient(160deg, var(--bg1), var(--bg0));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 96px 96px;
  mask-image: radial-gradient(ellipse at 50% 30%, #000 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 30%, #000 0%, transparent 72%);
  opacity: 0.5;
}
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ------------------------------------------------------------ brand */
.brand {
  font-weight: 700; letter-spacing: 0.32em; font-size: 0.78rem;
  color: var(--muted-2); text-transform: uppercase; white-space: nowrap;
}
.brand .dot {
  display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--sky); margin: 0 0.5em; vertical-align: middle;
  box-shadow: 0 0 8px var(--sky);
}

/* ------------------------------------------------------------ login */
.login {
  position: relative; z-index: 1; min-height: 100vh;
  display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: min(420px, 100%); text-align: center; padding: 40px 34px 34px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 28px;
  backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(56, 189, 248, 0.05);
}
.logo-wrap { width: 132px; height: 132px; margin: 0 auto 18px; }
.logo-big { width: 100%; height: 100%; animation: float 7s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-4px); } }
.login-card .sub { color: var(--muted); margin: 10px 0 26px; font-size: 0.95rem; }
form { text-align: left; display: grid; gap: 16px; }
label { display: grid; gap: 7px; }
label span { font-size: 0.68rem; letter-spacing: 0.26em; color: var(--muted); font-weight: 700; }
input[type="text"], input[type="password"], input[type="search"] {
  width: 100%; padding: 13px 15px; border-radius: 12px;
  background: rgba(4, 6, 16, 0.75); border: 1px solid var(--line); color: var(--text);
  font: inherit; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18), var(--glow); }
.error { color: #fca5a5; font-size: 0.9rem; margin: 0; }

/* ----------------------------------------------------------- buttons */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  border-radius: 12px; padding: 12px 20px; color: #fff; transition: transform .12s, box-shadow .2s, filter .2s;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn.primary { background: var(--grad); box-shadow: var(--glow); }
.btn.primary:hover { box-shadow: 0 0 30px rgba(99, 102, 241, 0.55); }
.btn.teal { background: var(--grad-teal); box-shadow: 0 0 22px rgba(0, 209, 193, 0.28); }
.btn.ghost { background: rgba(15, 23, 42, 0.6); border-color: var(--line); color: var(--muted-2); }
.btn.ghost:hover { border-color: var(--sky); color: var(--text); }
.btn.small { padding: 8px 14px; font-size: 0.85rem; }

/* ------------------------------------------------------------ topbar */
#app { position: relative; z-index: 1; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 28px;
  padding: 14px clamp(16px, 4vw, 44px);
  background: rgba(4, 6, 16, 0.72); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand-link { display: flex; align-items: center; gap: 12px; }
.logo-small { width: 34px; height: 34px; }
.topbar nav { display: flex; gap: 6px; margin-left: 8px; flex: 1; }
.topbar nav a {
  padding: 8px 16px; border-radius: 10px; color: var(--muted-2); font-weight: 600; font-size: 0.92rem;
  transition: color .15s, background .15s;
}
.topbar nav a:hover { color: var(--text); }
.topbar nav a.active { color: #fff; background: rgba(59, 130, 246, 0.16); box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.35); }
.user { display: flex; align-items: center; gap: 12px; color: var(--muted-2); font-size: 0.9rem; }

.view { padding: 28px clamp(16px, 4vw, 44px) 80px; max-width: 1700px; margin: 0 auto; }
h2.section {
  font-size: 0.78rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted-2);
  font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; gap: 12px;
}
h2.section::before { content: ""; width: 26px; height: 2px; background: var(--grad); border-radius: 2px; box-shadow: var(--glow); }

/* -------------------------------------------------------------- rows */
.row-block { margin-bottom: 34px; }
.row { display: flex; gap: 16px; overflow-x: auto; padding: 6px 4px 14px; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: #1e3a5f transparent; }
.row .card { flex: 0 0 172px; scroll-snap-align: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 18px; }

/* -------------------------------------------------------------- card */
.card {
  position: relative; cursor: pointer; border-radius: var(--radius);
  background: var(--panel-solid); border: 1px solid var(--line); overflow: hidden;
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.card:hover { transform: translateY(-4px); border-color: rgba(56, 189, 248, 0.7); box-shadow: var(--glow), 0 14px 30px rgba(0, 0, 0, 0.5); }
.poster { aspect-ratio: 2 / 3; background: linear-gradient(160deg, #0d1628, #060a14); position: relative; }
.poster img { width: 100%; height: 100%; object-fit: cover; }
.poster .ph {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 14px; text-align: center;
  color: var(--muted); font-size: 0.85rem; letter-spacing: 0.04em;
}
.card .meta { padding: 10px 12px 12px; }
.card .t { font-weight: 600; font-size: 0.9rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .s { color: var(--muted); font-size: 0.78rem; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badge {
  position: absolute; top: 9px; left: 9px; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.14em;
  padding: 4px 8px; border-radius: 999px; background: rgba(4, 6, 16, 0.82); border: 1px solid var(--line); color: var(--muted-2);
  text-transform: uppercase; backdrop-filter: blur(6px);
}
.badge.avail { color: #5eead4; border-color: rgba(0, 209, 193, 0.5); box-shadow: 0 0 12px rgba(0, 209, 193, 0.25); }
.badge.pend { color: #a5b4fc; border-color: rgba(99, 102, 241, 0.55); }
.score { position: absolute; top: 9px; right: 9px; font-size: 0.72rem; font-weight: 700; padding: 4px 8px; border-radius: 999px; background: rgba(4, 6, 16, 0.82); border: 1px solid var(--line); color: var(--sky); }

/* ------------------------------------------------------------ search */
.searchbar { position: relative; max-width: 720px; margin: 4px 0 26px; }
.searchbar input { padding: 16px 18px 16px 50px; font-size: 1.05rem; border-radius: 16px; }
.searchbar svg { position: absolute; left: 17px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; stroke: var(--sky); fill: none; stroke-width: 2; }

.tabs { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; align-items: center; }
.tab { padding: 9px 18px; border-radius: 999px; background: rgba(15, 23, 42, 0.6); border: 1px solid var(--line); color: var(--muted-2); font-weight: 600; cursor: pointer; font-size: 0.9rem; }
.tab.active { color: #fff; border-color: rgba(56, 189, 248, 0.6); background: rgba(59, 130, 246, 0.18); box-shadow: var(--glow); }
select {
  font: inherit; color: var(--text); background: rgba(4, 6, 16, 0.75); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; outline: none;
}

.empty { color: var(--muted); padding: 40px 0; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty strong { color: var(--muted-2); }
.note { color: var(--muted); font-size: 0.85rem; max-width: 760px; line-height: 1.55; }
.note code { background: rgba(15, 23, 42, 0.9); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--sky); }
.loading { color: var(--muted); padding: 24px 0; letter-spacing: 0.2em; font-size: 0.75rem; text-transform: uppercase; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

/* ------------------------------------------------------------- modal */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(2, 3, 9, 0.8); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 20px; overflow-y: auto; }
.modal-card {
  width: min(980px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; border-radius: 26px;
  background: var(--panel-solid); border: 1px solid rgba(56, 189, 248, 0.28);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7), var(--glow); position: relative;
}
.detail-hero { position: relative; min-height: 220px; background-size: cover; background-position: center 20%; }
.detail-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11, 18, 32, 0.2) 0%, var(--panel-solid) 96%); }
.close { position: absolute; top: 14px; right: 14px; z-index: 3; width: 38px; height: 38px; border-radius: 50%; background: rgba(4, 6, 16, 0.8); border: 1px solid var(--line); color: var(--text); font-size: 1.2rem; cursor: pointer; }
.close:hover { border-color: var(--sky); }
.detail-body { display: grid; grid-template-columns: 220px 1fr; gap: 28px; padding: 0 32px 32px; margin-top: -110px; position: relative; z-index: 2; }
.detail-body .poster { border-radius: 16px; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6); }
.detail-body h3 { margin: 70px 0 6px; font-size: clamp(1.4rem, 3vw, 2rem); letter-spacing: 0.01em; }
.tagline { color: var(--muted-2); font-style: italic; margin: 0 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }
.chip { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted-2); font-size: 0.78rem; background: rgba(15, 23, 42, 0.6); }
.chip.fsk { color: #fff; background: var(--grad); border-color: transparent; font-weight: 700; }
.chip.ok { color: #5eead4; border-color: rgba(0, 209, 193, 0.5); }
.overview { line-height: 1.65; color: #cbd5e1; margin: 0 0 18px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 18px 0 6px; }
.seasons { margin-top: 14px; display: grid; gap: 8px; }
.season { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(15, 23, 42, 0.5); }
.season small { color: var(--muted); }
.season a.btn { padding: 7px 13px; font-size: 0.82rem; }
.cast { color: var(--muted); font-size: 0.85rem; margin-top: 8px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 80; padding: 12px 20px; border-radius: 12px; background: var(--panel-solid); border: 1px solid var(--sky); box-shadow: var(--glow); }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 10px 14px; }
  .topbar .brand { display: none; }
  .topbar nav { order: 3; width: 100%; margin: 0; }
  .user span { display: none; }
  .detail-body { grid-template-columns: 1fr; padding: 0 18px 24px; margin-top: -70px; }
  .detail-body .poster { width: 150px; }
  .detail-body h3 { margin-top: 8px; }
  .row .card { flex-basis: 140px; }
}
