/* ════════════════════════════════════════════════════════════════════
   ACTIVECODES IPTV — "Aurora" premium design system
   ════════════════════════════════════════════════════════════════════ */

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

:root {
  /* Surfaces — near-black with cool depth */
  --bg:       #060711;
  --bg-soft:  #0b0d1a;
  --surface:  #12152a;
  --surface2: #181b33;
  --elevated: #1e2240;
  --border:   #262a47;
  --border-soft: #1c1f38;

  /* Brand gradient (logo blue → purple → pink) */
  --c1: #5b8cff;
  --c2: #9d6bff;
  --c3: #e15fd0;
  --grad:   linear-gradient(135deg, #5b8cff 0%, #9d6bff 48%, #e15fd0 100%);
  --grad-h: linear-gradient(135deg, #74a0ff 0%, #b184ff 48%, #f078e0 100%);
  --glow:   0 8px 30px rgba(123, 116, 255, .35);

  /* Text */
  --text:  #f0f1fb;
  --text2: #b9bce0;
  --muted: #7e82ad;
  --faint: #565a82;

  /* States */
  --ok:   #34d99a;
  --warn: #f5b13d;
  --bad:  #ff6b9d;

  --r:    10px;
  --r-lg: 16px;
  --r-xl: 22px;
  --nav-h: 64px;
  --sidebar-w: 232px;

  --ease: cubic-bezier(.22, 1, .36, 1);
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

button, input, select { font-family: inherit; }
button { cursor: pointer; }

/* ════════════════════════════════════════════════════════════════════
   LOGIN
   ════════════════════════════════════════════════════════════════════ */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(60% 50% at 18% 12%, rgba(91,140,255,.20), transparent 70%),
    radial-gradient(55% 50% at 85% 88%, rgba(225,95,208,.18), transparent 70%),
    var(--bg);
}

/* Static soft glows (no animated mega-blur — that re-composites every frame) */
.login-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
}
.login-glow-left {
  width: 480px; height: 480px;
  background: radial-gradient(circle, rgba(91,140,255,.26), transparent 70%);
  left: -160px; bottom: -120px;
}
.login-glow-right {
  width: 420px; height: 420px;
  background: radial-gradient(circle, rgba(225,95,208,.22), transparent 70%);
  right: -140px; top: -120px;
}

.login-box {
  position: relative;
  z-index: 1;
  width: 380px;
  max-width: calc(100vw - 40px);
  padding: 48px 40px 40px;
  background: linear-gradient(180deg, rgba(24,27,51,.92), rgba(11,13,26,.95));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--r-xl);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.06),
    0 30px 90px rgba(0,0,0,.6),
    0 0 70px rgba(91,140,255,.10);
}

.login-logo { text-align: center; margin-bottom: 34px; }
.login-logo-img { width: 168px; height: auto; filter: drop-shadow(0 6px 18px rgba(123,116,255,.35)); }

.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.form-group input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.form-group input::placeholder { color: var(--faint); }
.form-group input:focus {
  border-color: var(--c1);
  background: rgba(255,255,255,.06);
  box-shadow: 0 0 0 4px rgba(91,140,255,.16);
}

.btn-login {
  width: 100%;
  margin-top: 10px;
  padding: 15px;
  background: var(--grad);
  background-size: 160% 160%;
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  box-shadow: var(--glow);
  transition: transform .15s var(--ease), box-shadow .2s, background-position .5s;
}
.btn-login:hover { background-position: 100% 0; box-shadow: 0 10px 38px rgba(123,116,255,.55); }
.btn-login:active { transform: scale(.97); }
.btn-login:disabled { opacity: .5; cursor: not-allowed; }
.btn-login-icon { font-size: 12px; }

.login-error {
  display: none;
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: var(--r);
  background: rgba(255,107,157,.10);
  border: 1px solid rgba(255,107,157,.3);
  color: var(--bad);
  font-size: 13px;
  text-align: center;
}

/* ════════════════════════════════════════════════════════════════════
   APP SHELL
   ════════════════════════════════════════════════════════════════════ */
#app { display: none; flex-direction: column; height: 100vh; }

/* ── Navbar ───────────────────────────────────────── */
.navbar {
  height: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  gap: 16px;
  padding-left: 22px;
  padding-right: 22px;
  flex-shrink: 0;
  z-index: 20;
  background: #0a0b16;
  border-bottom: 1px solid var(--border-soft);
}

.nav-logo { display: flex; align-items: center; flex-shrink: 0; }
.nav-logo-img { height: 38px; width: auto; object-fit: contain; }

.nav-tabs { display: flex; gap: 4px; padding: 4px; background: rgba(255,255,255,.03); border-radius: 99px; border: 1px solid var(--border-soft); }
.nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  border-radius: 99px;
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.nav-tab svg { flex-shrink: 0; opacity: .65; transition: opacity .15s; }
.nav-tab:hover { color: var(--text); }
.nav-tab.active {
  color: #fff;
  background: var(--grad);
  box-shadow: 0 4px 18px rgba(123,116,255,.4);
}
.nav-tab.active svg { opacity: 1; }

.nav-search {
  flex: 1;
  max-width: 340px;
  margin-left: auto;
  position: relative;
}
.search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.nav-search input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.nav-search input::placeholder { color: var(--faint); }
.nav-search input:focus {
  border-color: rgba(91,140,255,.55);
  background: rgba(255,255,255,.06);
  box-shadow: 0 0 0 4px rgba(91,140,255,.12);
}

.nav-user { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.nav-username { color: var(--text2); font-size: 13px; font-weight: 500; white-space: nowrap; }

.btn-logout, .btn-admin {
  padding: 8px 16px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: all .15s;
}
.btn-logout {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn-logout:hover { color: var(--text); border-color: var(--faint); background: rgba(255,255,255,.07); }
.btn-admin {
  background: rgba(91,140,255,.12);
  border: 1px solid rgba(91,140,255,.32);
  color: var(--c1);
}
.btn-admin:hover { background: rgba(91,140,255,.2); border-color: rgba(91,140,255,.5); }

.server-switcher { display: flex; align-items: center; gap: 8px; }
.server-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.server-select {
  padding: 7px 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-size: 12px;
  outline: none;
}
.server-select:focus { border-color: var(--c1); }

.account-expiry {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 99px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.account-expiry:empty { display: none; }
.exp-unlimited { color: var(--ok);   border-color: rgba(52,217,154,.3);  background: rgba(52,217,154,.08); }
.exp-ok        { color: var(--ok);   border-color: rgba(52,217,154,.3);  background: rgba(52,217,154,.08); }
.exp-warn      { color: var(--warn); border-color: rgba(245,177,61,.3);  background: rgba(245,177,61,.08); }
.exp-soon      { color: #ff9b6b;     border-color: rgba(255,155,107,.3); background: rgba(255,155,107,.08); }
.exp-expired   { color: var(--bad);  border-color: rgba(255,107,157,.4); background: rgba(255,107,157,.12); }

.btn-menu { display: none; }

/* ── Content layout ───────────────────────────────── */
.content-area { display: flex; flex: 1; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  overflow-y: auto;
  padding: 14px 10px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border-soft);
}
.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--faint);
  padding: 6px 14px 12px;
}
.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 3px;
  border-radius: var(--r);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  transition: color .15s, background .15s;
}
.category-item::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  width: 3px; height: 0;
  background: var(--grad);
  border-radius: 99px;
  transform: translateY(-50%);
  transition: height .2s var(--ease);
}
.category-item:hover { color: var(--text); background: rgba(255,255,255,.04); }
.category-item.active {
  color: #fff;
  font-weight: 600;
  background: linear-gradient(90deg, rgba(91,140,255,.14), rgba(157,107,255,.05));
}
.category-item.active::before { height: 60%; }
.cat-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--faint);
  background: rgba(255,255,255,.05);
  padding: 2px 8px;
  border-radius: 99px;
  flex-shrink: 0;
}
.category-item.active .cat-count { color: var(--c1); background: rgba(91,140,255,.18); }

.main-panel {
  flex: 1;
  overflow-y: auto;
  padding: 26px 28px;
  scroll-behavior: smooth;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
}
.section-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.4px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.section-count { font-size: 13px; color: var(--muted); font-weight: 500; }

/* ── Card grid ────────────────────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 20px;
}
.live-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.card {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  transition: transform .28s var(--ease), box-shadow .28s, border-color .28s;
  /* Skip layout/paint for offscreen cards — huge win with 1000s of channels */
  content-visibility: auto;
  contain-intrinsic-size: auto 280px;
}
.card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
  pointer-events: none;
}
.card:hover {
  transform: translateY(-8px);
  border-color: rgba(123,116,255,.4);
  box-shadow: 0 22px 50px rgba(0,0,0,.55), 0 0 0 1px rgba(123,116,255,.25), var(--glow);
  z-index: 2;
}
.card:hover .card-poster { transform: scale(1.06); }
.card:hover .card-play { opacity: 1; transform: translate(-50%,-50%) scale(1); }

.card-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
  background: var(--surface2);
  transition: transform .5s var(--ease);
}
.live-card .card-poster { aspect-ratio: 16/9; object-fit: contain; padding: 14px; background: radial-gradient(circle at 50% 40%, var(--surface2), var(--surface)); }
.card-poster.no-img {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--faint);
  background: linear-gradient(135deg, var(--surface2), var(--surface));
}

.card-play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%) scale(.8);
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  color: #fff;
  opacity: 0;
  box-shadow: 0 8px 28px rgba(123,116,255,.6);
  transition: opacity .25s, transform .25s var(--ease);
}

.card-info {
  padding: 12px 14px 14px;
  position: relative;
}
.card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.card-badge {
  position: absolute;
  top: 10px; right: 10px;
  padding: 3px 9px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
  color: #fff;
  background: var(--grad);
  border-radius: 99px;
  box-shadow: 0 4px 14px rgba(123,116,255,.5);
}

/* ── Loader / Empty ───────────────────────────────── */
.loader, .empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  gap: 16px;
  color: var(--muted);
}
.spinner {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--c1);
  border-right-color: var(--c2);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state .empty-icon { font-size: 54px; opacity: .45; }

/* ════════════════════════════════════════════════════════════════════
   PLAYER
   ════════════════════════════════════════════════════════════════════ */
.player-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  flex-direction: column;
  background: #000;
}
.player-overlay.visible { display: flex; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.player-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: linear-gradient(to bottom, rgba(0,0,0,.85), transparent);
  pointer-events: none;
}
.player-topbar > * { pointer-events: auto; }
.player-meta { flex: 1; min-width: 0; }
.player-title { font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
.player-subtitle { font-size: 12.5px; color: var(--text2); margin-top: 3px; }

/* ── EPG (now / next) ─────────────────────────────── */
.player-epg {
  margin-top: 10px;
  max-width: 560px;
}
.player-epg[hidden] { display: none; }
.epg-now, .epg-next {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  min-width: 0;
}
.epg-next { margin-top: 5px; opacity: .72; font-size: 11.5px; }
.epg-tag {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .7px;
  padding: 2px 7px;
  border-radius: 99px;
  color: #fff;
  background: var(--grad);
}
.epg-tag-next { background: rgba(255,255,255,.12); color: var(--text2); }
.epg-prog {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.epg-next .epg-prog { font-weight: 500; color: var(--text2); }
.epg-time { flex-shrink: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.epg-bar {
  height: 3px;
  margin: 7px 0;
  border-radius: 99px;
  background: rgba(255,255,255,.14);
  overflow: hidden;
}
.epg-bar > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--grad);
  transition: width .8s linear;
}

.btn-close-player {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .15s;
}
.btn-close-player:hover { background: rgba(255,255,255,.22); transform: rotate(90deg); }

.player-body { display: flex; flex: 1; overflow: hidden; }
.player-main { flex: 1; position: relative; background: #000; display: flex; min-width: 0; }

#video-player, .video-js { width: 100% !important; height: 100% !important; outline: none; font-family: inherit; }
#ts-player {
  width: 100%; height: 100%;
  display: none;
  object-fit: contain;
  background: #000;
}

.video-js .vjs-play-progress,
.video-js .vjs-volume-level { background-color: var(--c1) !important; }
.video-js .vjs-big-play-button {
  background: var(--grad) !important;
  border: none !important;
  border-radius: 50% !important;
  width: 72px !important; height: 72px !important;
  line-height: 72px !important;
  margin: -36px 0 0 -36px !important;
  box-shadow: var(--glow) !important;
}
.video-js .vjs-big-play-button:hover { background: var(--grad-h) !important; }
.video-js .vjs-control-bar { background: linear-gradient(transparent, rgba(0,0,0,.85)) !important; }
.video-js .vjs-loading-spinner { border-top-color: var(--c1) !important; border-right-color: var(--c2) !important; }

.player-error {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  color: var(--text2);
  padding: 24px;
}
.player-error .err-icon { font-size: 52px; }
.player-error .err-msg { max-width: 420px; font-size: 14px; }

/* ── Series panel ─────────────────────────────────── */
.series-panel {
  width: 330px;
  flex-shrink: 0;
  overflow-y: auto;
  display: none;
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
}
.series-panel.visible { display: block; }

.season-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 18px;
  border-bottom: 1px solid var(--border-soft);
}
.season-tab {
  padding: 6px 16px;
  border-radius: 99px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  transition: all .15s;
}
.season-tab:hover { color: var(--text); border-color: var(--faint); }
.season-tab.active {
  background: var(--grad);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(123,116,255,.4);
}

.episode-list { padding: 10px; }
.episode-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r);
  transition: background .15s;
}
.episode-item:hover { background: rgba(255,255,255,.05); }
.episode-item.active { background: linear-gradient(90deg, rgba(91,140,255,.16), rgba(157,107,255,.06)); }
.ep-num {
  width: 30px;
  flex-shrink: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--faint);
}
.episode-item.active .ep-num { color: var(--c1); }
.ep-info { flex: 1; overflow: hidden; }
.ep-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ep-play { flex-shrink: 0; font-size: 15px; color: var(--faint); transition: color .15s; }
.episode-item:hover .ep-play { color: var(--c1); }
.episode-item.active .ep-play { color: var(--c2); }

/* ── Toast ────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 26px; right: 26px;
  z-index: 2000;
  max-width: 340px;
  padding: 14px 20px;
  border-radius: var(--r);
  background: var(--elevated);
  border: 1px solid var(--border);
  font-size: 13px;
  box-shadow: 0 14px 40px rgba(0,0,0,.55);
  transform: translateY(120px);
  opacity: 0;
  transition: transform .35s var(--ease), opacity .35s;
}
.toast.show { transform: none; opacity: 1; }
.toast.error { border-color: rgba(255,107,157,.35); background: rgba(255,107,157,.10); color: var(--bad); }

.sidebar-overlay { display: none; }

/* ════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════════ */
@media (hover: none) {
  .card:hover { transform: none; box-shadow: none; border-color: var(--border-soft); }
  .card:hover .card-poster { transform: none; }
  .card:hover .card-play { opacity: 0; }
  .card:active { transform: scale(.97); }
}

/* ── Large tablet (≤ 1100px) ─────────────────────── */
@media (max-width: 1100px) {
  :root { --sidebar-w: 200px; }
  .nav-search { max-width: 240px; }
  .content-grid { grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 16px; }
  .live-grid { grid-template-columns: repeat(auto-fill, minmax(210px,1fr)); }
}

/* ── Tablet (≤ 860px) ────────────────────────────── */
@media (max-width: 860px) {
  :root { --sidebar-w: 175px; }
  .nav-username { display: none; }
  .server-label { display: none; }
  .nav-logo-img { height: 32px; }
  .nav-search { max-width: 200px; }
  .main-panel { padding: 20px; }
  .section-title { font-size: 19px; }
  .series-panel { width: 260px; }
}

/* ── Mobile (≤ 600px) ────────────────────────────── */
@media (max-width: 600px) {
  #login-screen { min-height: 100svh; }
  .login-box { padding: 38px 26px 30px; }
  .login-logo-img { width: 140px; }

  #app {
    height: 100svh; height: 100dvh;
    padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  }

  /* Top bar: single slim row (clears the Dynamic Island / notch) */
  .navbar {
    height: calc(56px + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: 12px;
    padding-right: 12px;
    gap: 8px;
    border-bottom: 1px solid var(--border-soft);
  }
  .nav-logo-img { height: 30px; }
  .nav-search { flex: 1; max-width: none; margin-left: 0; }
  .nav-search input { padding: 9px 14px 9px 38px; }
  .nav-user { gap: 6px; }
  .nav-username, .server-label, .account-expiry { display: none !important; }
  .server-select { font-size: 11px; padding: 5px 8px; max-width: 90px; }
  .btn-admin { padding: 6px 10px; font-size: 11px; }

  .btn-logout {
    width: 36px; height: 36px;
    padding: 0; border-radius: 50%;
    font-size: 0;
    display: flex; align-items: center; justify-content: center;
  }
  .btn-logout::before { content: '⏻'; font-size: 15px; color: var(--muted); }

  .btn-menu {
    display: flex;
    align-items: center; justify-content: center;
    width: 36px; height: 36px;
    flex-shrink: 0;
    border-radius: var(--r);
    background: rgba(255,255,255,.05);
    border: 1px solid var(--border);
    color: var(--muted);
    transition: all .15s;
  }
  .btn-menu:hover { color: var(--text); }
  .btn-menu.active { color: #fff; background: var(--grad); border-color: transparent; box-shadow: 0 4px 14px rgba(123,116,255,.4); }

  /* Tabs → fixed bottom bar */
  .nav-tabs {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 200;
    display: flex;
    gap: 4px;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--border);
    background: #0a0b16;
  }
  .nav-tab {
    flex: 1;
    flex-direction: column;
    gap: 4px;
    padding: 6px 4px 5px;
    font-size: 10px;
    border-radius: var(--r);
  }
  .nav-tab svg { width: 20px; height: 20px; opacity: .55; }
  .nav-tab.active { box-shadow: 0 4px 16px rgba(123,116,255,.45); }
  .nav-tab.active svg { opacity: 1; }

  /* Sidebar → slide-in drawer */
  .content-area { position: relative; }
  .sidebar {
    position: fixed;
    top: calc(56px + env(safe-area-inset-top, 0px)); left: 0;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    width: 76vw; max-width: 300px;
    z-index: 300;
    padding: 0 10px 10px;
    border-right: 1px solid var(--border);
    transform: translateX(-101%);
    transition: transform .28s var(--ease);
    box-shadow: 12px 0 40px rgba(0,0,0,.5);
  }
  .sidebar.mobile-open { transform: none; }
  .sidebar-title {
    position: sticky;
    top: 0;
    margin: 0 -10px 8px;
    padding: 16px 16px 12px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border-soft);
  }
  .category-item { padding: 11px 14px; font-size: 13px; }

  .sidebar-overlay {
    position: fixed;
    inset: calc(56px + env(safe-area-inset-top,0px)) 0 0 0;
    z-index: 250;
    background: rgba(0,0,0,.62);
    opacity: 0;
    animation: fadeIn .25s ease forwards;
  }
  .sidebar-overlay.visible { display: block; }

  .main-panel { padding: 14px; }
  .section-header { margin-bottom: 14px; }
  .section-title { font-size: 17px; }

  .content-grid { grid-template-columns: repeat(auto-fill, minmax(104px,1fr)); gap: 10px; }

  /* Live TV → comfortable list rows */
  .live-grid { grid-template-columns: 1fr; gap: 6px; }
  .live-card {
    display: flex;
    align-items: center;
    height: 64px;
    border-radius: 12px;
  }
  .live-card .card-poster {
    width: 88px; height: 64px;
    aspect-ratio: unset;
    padding: 8px;
    border-radius: 12px 0 0 12px;
    flex-shrink: 0;
  }
  .live-card .card-poster.no-img { font-size: 24px; }
  .live-card .card-info { flex: 1; min-width: 0; padding: 0 14px; }
  .live-card .card-title { font-size: 14px; }
  .live-card .card-meta { font-size: 11px; }
  .live-card .card-play {
    position: static;
    transform: none;
    opacity: 1;
    width: 40px; height: 40px;
    font-size: 14px;
    background: none;
    box-shadow: none;
    color: var(--faint);
    flex-shrink: 0;
    margin-right: 10px;
  }
  .live-card:active { background: var(--surface2); }
  .live-card:active .card-play { color: var(--c1); }

  /* Player */
  .player-topbar { padding: 14px 14px; padding-top: calc(14px + env(safe-area-inset-top,0px)); }
  .player-title { font-size: 15px; }
  .player-subtitle { font-size: 11px; }
  .player-epg { margin-top: 7px; }
  .epg-now { font-size: 11.5px; }
  .epg-next { display: none; }   /* keep topbar compact on phones */
  .epg-bar { margin: 5px 0; }
  .player-body { flex-direction: column; }
  .player-main { flex: 1; min-height: 0; }
  .series-panel {
    width: 100%;
    max-height: 44vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .season-tabs { position: sticky; top: 0; z-index: 2; background: var(--bg-soft); padding: 12px; }
  .episode-item { padding: 12px 10px; }

  .toast {
    bottom: calc(70px + env(safe-area-inset-bottom,0px));
    left: 12px; right: 12px;
    max-width: none;
    text-align: center;
  }
}

/* ── Phone landscape: immersive player ───────────── */
@media (max-width: 920px) and (orientation: landscape) and (pointer: coarse) {
  .player-topbar { padding: 8px 14px; background: linear-gradient(to bottom, rgba(0,0,0,.7), transparent); }
  .player-subtitle, .player-epg { display: none; }   /* immersive */
  .player-title { font-size: 14px; }
  .player-body { flex-direction: row; }
  .series-panel { width: 260px; max-height: none; height: 100%; border-top: none; border-left: 1px solid var(--border); }
}

/* ── Very small (≤ 380px) ────────────────────────── */
@media (max-width: 380px) {
  .nav-tab { font-size: 9px; }
  .nav-tab svg { width: 18px; height: 18px; }
  .btn-admin { font-size: 10px; padding: 5px 8px; }
  .content-grid { grid-template-columns: repeat(auto-fill, minmax(92px,1fr)); gap: 7px; }
}
