:root {
  --bg: #0b0b0f;
  --bg-2: #14141c;
  --bg-3: #1d1d28;
  --card: #191922;
  --border: #262633;
  --text: #f2f2f5;
  --muted: #9a9aa8;
  --primary: #e50914;
  --primary-2: #ff3b47;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 10px;
}

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

html, body {
  height: 100%;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.view { min-height: 100vh; }

.btn {
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: var(--bg-3);
  transition: opacity .15s, transform .05s;
  font-family: inherit;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-2); }
.btn-outline { background: transparent; border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--muted); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.icon-btn {
  border: none; background: transparent; color: var(--text);
  font-size: 20px; cursor: pointer; padding: 8px;
}

/* ============ LOGIN ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  padding: 20px;
}
.login-brand { text-align: center; }
.login-brand h1 { font-size: 40px; letter-spacing: -1px; }
.login-brand h1 b { color: var(--primary); }
.login-brand p { color: var(--muted); margin-top: 6px; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 30px;
}
.login-card h2 { margin-bottom: 18px; font-size: 22px; }
.login-card label { display: block; color: var(--muted); font-size: 13px; margin: 14px 0 6px; }
.login-card input {
  width: 100%; padding: 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 15px;
}
.login-card input:focus { outline: none; border-color: var(--primary); }
.msg { padding: 10px 12px; border-radius: 6px; font-size: 14px; margin-bottom: 12px; }
.msg.error { background: rgba(239,68,68,.15); color: var(--danger); }
.msg.success { background: rgba(34,197,94,.15); color: var(--success); }

/* ============ TOPBAR ============ */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 26px;
  background: rgba(11,11,15,.92);
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { font-size: 24px; font-weight: 700; letter-spacing: -1px; }
.brand b { color: var(--primary); }
.nav-tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav-tab {
  border: none; background: transparent; color: var(--muted);
  font-size: 15px; padding: 8px 14px; border-radius: 6px; cursor: pointer; font-family: inherit;
  white-space: nowrap;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--text); background: var(--bg-3); font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ============ SEARCH ============ */
.search-bar { display: flex; gap: 10px; padding: 12px 26px; background: var(--bg-2); align-items: center; }
.search-bar input {
  flex: 1; padding: 11px 14px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 15px;
}
.search-bar input:focus { outline: none; border-color: var(--primary); }

/* ============ CONTENT / GRID ============ */
.content { padding: 24px 26px 60px; }
.section-title { font-size: 22px; font-weight: 700; margin: 6px 0 14px; }
.row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; scroll-snap-type: x mandatory; }
.row::-webkit-scrollbar { height: 8px; }
.row::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

.tile {
  min-width: 168px; max-width: 168px; background: var(--card);
  border-radius: var(--radius); overflow: hidden; cursor: pointer; scroll-snap-align: start;
  transition: transform .15s;
}
.tile:hover { transform: translateY(-4px); }
.tile-poster {
  width: 100%; aspect-ratio: 16 / 10; background: var(--bg-3);
  object-fit: cover; display: block;
}
.tile-poster.placeholder { display: flex; align-items: center; justify-content: center; font-size: 34px; color: var(--muted); }
.tile-info { padding: 9px 11px; }
.tile-name {
  font-size: 13px; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ============ GROUPS CHIPS ============ */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 18px; }
.chips::-webkit-scrollbar { height: 6px; }
.chips::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--bg-2); color: var(--muted);
  border-radius: 20px; padding: 7px 15px; font-size: 13px; cursor: pointer; white-space: nowrap; font-family: inherit;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.chip:hover:not(.active) { color: var(--text); }

/* ============ DETAIL ============ */
.detail-hero {
  position: relative; border-radius: 14px; overflow: hidden; margin-bottom: 24px;
  min-height: 320px; display: flex; align-items: flex-end;
  background: var(--bg-3);
}
.detail-bg {
  position: absolute; inset: 0; object-fit: cover; opacity: .45; width: 100%; height: 100%;
}
.detail-body { position: relative; padding: 26px; width: 100%; background: linear-gradient(transparent, rgba(11,11,15,.92)); }
.detail-title { font-size: 30px; font-weight: 800; }
.detail-meta { color: var(--muted); margin: 8px 0 14px; display: flex; flex-wrap: wrap; gap: 10px; }
.detail-desc { color: #d9d9e0; max-width: 720px; line-height: 1.5; }
.detail-actions { margin-top: 16px; display: flex; gap: 10px; }

.seasons { margin-top: 26px; }
.seasons h3 { margin-bottom: 12px; }
.season-block { margin-bottom: 20px; }
.season-title { font-weight: 600; color: var(--muted); font-size: 14px; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .5px; }
.episode {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 8px;
  background: var(--bg-2); margin-bottom: 8px; cursor: pointer; border: 1px solid transparent;
}
.episode:hover { border-color: var(--primary); }
.episode-num { min-width: 26px; height: 26px; border-radius: 50%; background: var(--bg-3); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.episode-name { flex: 1; font-size: 14px; }
.episode-dur { color: var(--muted); font-size: 12px; }

/* ============ EMPTY / LOADING ============ */
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .big { font-size: 46px; margin-bottom: 12px; }
.spinner {
  width: 40px; height: 40px; border: 4px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; margin: 60px auto; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ PLAYER ============ */
.player-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.95); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.player-shell { width: 100%; max-width: 960px; }
.player-box {
  width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 10px; overflow: hidden;
}
.player-box video { width: 100%; height: 100%; background: #000; }
.player-bar { display: flex; align-items: center; gap: 14px; padding: 12px 4px; }
.player-title { flex: 1; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-msg {
  margin-top: 10px; padding: 12px 14px; border-radius: 8px; background: var(--bg-2);
  border: 1px solid var(--border); font-size: 13px; line-height: 1.5;
}
.player-msg .tiny { color: var(--muted); font-size: 12px; margin-top: 6px; word-break: break-all; }

@media (max-width: 640px) {
  .topbar { gap: 12px; padding: 12px 14px; }
  .content { padding: 18px 14px 50px; }
  .tile { min-width: 140px; max-width: 140px; }
  .detail-title { font-size: 24px; }
}
