:root {
  --bg: #08090d;
  --surface: #121622;
  --surface-glass: rgba(18, 22, 34, 0.8);
  --surface-elevated: #1a2133;
  --surface-hover: #222c44;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #6366f1;
  --accent-2: #38bdf8;
  --live: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 20px 48px rgba(0, 0, 0, 0.52);
}

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

[hidden] {
  display: none !important;
}

/* Strong visible keyboard focus across every interactive element */
:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 12px;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.bg-backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-size: cover;
  background-position: center;
  opacity: 0.22;
  pointer-events: none;
}

.ambient-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.18;
}

.orb-1 {
  width: 480px;
  height: 480px;
  top: -120px;
  left: -90px;
  background: var(--accent);
}

.orb-2 {
  width: 520px;
  height: 520px;
  bottom: -160px;
  right: -110px;
  background: var(--accent-2);
}

/* Auth Shell (Frosted Glass inspired by reference players) */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface-glass);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-card.shake {
  animation: shake 0.35s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  50% { transform: translateX(7px); }
  75% { transform: translateX(-4px); }
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.brand-lockup h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  flex-shrink: 0;
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-mark.small {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 0.92rem;
}

.muted {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.small-note {
  font-size: 0.8rem;
}

/* Segmented Mode Switcher */
.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  margin-bottom: 18px;
}

.mode-tab {
  padding: 9px 8px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mode-tab:hover {
  color: var(--text);
}

.mode-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.field input,
.field select {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(8, 9, 13, 0.72);
  color: var(--text);
  font-size: 0.94rem;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent-2);
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 42px;
}

.eye-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.eye-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.auth-mode-switch {
  margin-top: 14px;
  text-align: center;
}

.btn-link {
  border: none;
  background: transparent;
  color: var(--accent-2);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.btn-link:hover {
  text-decoration: underline;
  color: #bae6fd;
}

.alert-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fecaca;
  font-size: 0.87rem;
}

.auth-footer {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.subtle-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.86rem;
}

.subtle-link:hover {
  color: var(--accent-2);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
}

.btn-sm {
  min-height: 34px;
  padding: 6px 11px;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
}

/* App Shell */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  background: rgba(8, 9, 13, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.nav-pills {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-pills::-webkit-scrollbar {
  display: none;
}

.nav-pill {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.16s ease;
}

.nav-pill:hover {
  color: var(--text);
}

.nav-pill.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 170px;
  max-width: 340px;
}

.search-wrap input {
  width: 100%;
  padding: 8px 34px 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
}

.icon-btn {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: var(--surface-hover);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.72rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.user-chip {
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main-container {
  flex: 1;
  width: 100%;
  max-width: 1580px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  align-content: start;
}

.player-stage,
.content-section,
.live-sidebar,
.controls-bar,
.now-playing {
  min-width: 0;
}

/* Player Stage */
.stage-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.stage-grid.with-sidebar {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.theater {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.video-frame {
  position: relative;
  width: 100%;
  max-width: min(100%, calc(58vh * 16 / 9));
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  background: #05070c;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.video-frame video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

.placeholder-overlay {
  background: radial-gradient(circle at center, rgba(99, 102, 241, 0.14), rgba(5, 7, 13, 0.94));
}

.placeholder-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 1.45rem;
  box-shadow: 0 10px 28px rgba(99, 102, 241, 0.35);
}

.video-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 13, 0.86);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
}

.overlay-box {
  max-width: 440px;
  display: grid;
  gap: 10px;
  justify-items: center;
}

.error-title {
  color: #fca5a5;
  font-size: 1.05rem;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.small-spinner {
  width: 22px;
  height: 22px;
  border-width: 2.5px;
  margin: 0 auto;
}

.cat-select {
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.84rem;
  max-width: 280px;
}

.catalog-head-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.loading-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-glass);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.88rem;
}

.loading-banner .small-spinner {
  margin: 0;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Custom Player Controls Bar */
.controls-bar {
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: grid;
  gap: 8px;
}

.seek-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.seek-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent-2);
  cursor: pointer;
}

.mono-time {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 48px;
  text-align: center;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.controls-left,
.controls-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ctrl-btn {
  min-width: 36px;
  min-height: 34px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.ctrl-btn:hover {
  background: var(--surface-hover);
}

.ctrl-btn.active {
  border-color: var(--accent-2);
  color: #bae6fd;
}

.volume-slider {
  width: 84px;
  accent-color: var(--accent-2);
  cursor: pointer;
}

.ctrl-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.ctrl-select-wrap select {
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
}

/* Now Playing */
.now-playing {
  background: var(--surface-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 18px;
}

.now-playing-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.now-playing h2 {
  margin: 6px 0 0;
  font-size: 1.18rem;
}

.now-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.status-pill,
.category-pill,
.type-pill,
.resume-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-idle { background: rgba(148, 163, 184, 0.16); color: var(--text-muted); }
.status-loading { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
.status-live { background: rgba(34, 197, 94, 0.18); color: #86efac; }
.status-error { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }
.category-pill { background: rgba(56, 189, 248, 0.15); color: #7dd3fc; }
.type-pill { background: rgba(99, 102, 241, 0.22); color: #c7d2fe; text-transform: uppercase; }
.resume-pill { background: rgba(34, 197, 94, 0.18); color: #86efac; }

.now-description {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 0.89rem;
}

.audio-warning-banner {
  margin-top: 10px;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.14);
  color: #fde68a;
  font-size: 0.86rem;
  line-height: 1.45;
}

/* Live Sidebar */
.live-sidebar {
  background: var(--surface-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  max-height: calc(100vh - 110px);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-head h3 {
  margin: 0;
  font-size: 1rem;
}

.count-pill {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.category-bar {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.cat-chip {
  flex-shrink: 0;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}

.cat-chip:hover {
  border-color: var(--accent-2);
  color: var(--text);
}

.cat-chip.active {
  background: rgba(99, 102, 241, 0.24);
  border-color: var(--accent-2);
  color: #e0f2fe;
}

.channel-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}

.channel-card {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.channel-card:hover {
  background: var(--surface-hover);
}

.channel-card.active {
  border-color: var(--accent-2);
  background: rgba(99, 102, 241, 0.18);
}

.channel-avatar {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent-2);
  overflow: hidden;
  flex-shrink: 0;
}

.channel-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.channel-meta {
  min-width: 0;
  flex: 1;
}

.channel-title {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-sub {
  margin-top: 2px;
  font-size: 0.76rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.playing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  flex-shrink: 0;
}

.fav-mini {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.fav-mini.is-fav {
  color: #facc15;
  border-color: rgba(250, 204, 21, 0.45);
}

/* Content Sections (Home, Movies, Series, Favorites, Recent) */
.content-section {
  display: grid;
  gap: 18px;
}

/* Compact Home Strip (replaces oversized hero banner) */
.home-section {
  gap: 20px;
}

.home-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 11px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(56, 189, 248, 0.06));
  border: 1px solid var(--border);
}

.home-strip-info {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  min-width: 0;
}

.home-greeting {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.home-sub-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.home-strip-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.shelf-title-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.home-shelves-stack {
  display: grid;
  gap: 22px;
  min-width: 0;
}

/* Live TV Category Shortcuts Rail */
.live-shortcuts-rail {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.live-shortcut-tile {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-glass);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.live-shortcut-tile:hover {
  border-color: var(--accent-2);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.shortcut-count {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
  font-size: 0.74rem;
  font-weight: 700;
}

/* Accessible Horizontal Poster Rails (Desktop buttons + Mobile touch scroll) */
.rail-wrapper {
  position: relative;
  min-width: 0;
}

.rail-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.rail-track .media-card {
  flex: 0 0 184px;
  scroll-snap-align: start;
}

.rail-track.rail-wide .media-card {
  flex: 0 0 230px;
}

.rail-track .media-card.poster-card .media-poster {
  aspect-ratio: 2 / 3;
}

.rail-nav-btn {
  position: absolute;
  top: 42%;
  transform: translateY(-50%);
  z-index: 5;
  width: 36px;
  height: 52px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(8, 9, 13, 0.86);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 1.35rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.rail-nav-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent-2);
}

.rail-nav-prev { left: 4px; }
.rail-nav-next { right: 4px; }

.poster-fallback-box {
  width: 100%;
  height: 100%;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  background: linear-gradient(145deg, rgba(99, 102, 241, 0.22), rgba(15, 23, 42, 0.96));
}

.poster-fallback-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rail-skeleton-chips {
  display: flex;
  gap: 10px;
  overflow: hidden;
}

.skeleton-chip {
  width: 145px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--surface), var(--surface-elevated), var(--surface));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  flex-shrink: 0;
}

.rail-skeleton-posters {
  display: flex;
  gap: 12px;
  overflow: hidden;
}

.skeleton-poster {
  width: 184px;
  height: 290px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface), var(--surface-elevated), var(--surface));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  flex-shrink: 0;
}

.section-head,
.shelf-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.section-head h2,
.shelf-head h3 {
  margin: 0;
}

.shelf-block {
  display: grid;
  gap: 12px;
}

/* Media Card Grid (Movies / Series / Favorites / Continue Watching) */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 14px;
}

.media-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.media-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-2);
}

.media-card-hit {
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.media-poster {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, #172038, #0c101b);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.media-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poster-fallback {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--accent-2);
  opacity: 0.9;
}

.card-type-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(8, 9, 13, 0.78);
  border: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #e2e8f0;
}

.card-fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(8, 9, 13, 0.78);
  color: #cbd5e1;
  cursor: pointer;
  font-size: 0.95rem;
}

.card-fav-btn.is-fav {
  color: #facc15;
  border-color: rgba(250, 204, 21, 0.5);
}

.progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.16);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.media-body {
  padding: 12px;
  display: grid;
  gap: 5px;
}

.media-title {
  font-weight: 600;
  font-size: 0.93rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.media-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

.loading-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 14px;
}

.skeleton-card {
  height: 190px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface), var(--surface-elevated), var(--surface));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.empty-card,
.empty-state {
  text-align: center;
  padding: 32px 18px;
  background: var(--surface-glass);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(2, 4, 10, 0.8);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-dialog {
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.modal-lg {
  max-width: 720px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.modal-head h3 {
  margin: 4px 0 0;
  font-size: 1.2rem;
}

.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-close {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.icon-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.episodes-list {
  display: grid;
  gap: 10px;
}

.episode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
}

.episode-info {
  min-width: 0;
  flex: 1;
}

.episode-title {
  font-weight: 600;
  font-size: 0.93rem;
}

.episode-progress-bar {
  margin-top: 6px;
  height: 4px;
  width: 100%;
  max-width: 240px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.compat-list {
  display: grid;
  gap: 8px;
}

.compat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  font-size: 0.86rem;
}

.compat-ok { color: #86efac; font-weight: 600; }
.compat-warn { color: #fcd34d; font-weight: 600; }
.compat-no { color: #fca5a5; font-weight: 600; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  padding: 11px 16px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent-2);
  color: #e0f2fe;
  font-size: 0.86rem;
  font-weight: 500;
  box-shadow: var(--shadow);
}

/* Mobile Responsive */
@media (max-width: 960px) {
  .topbar {
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 8px;
  }

  .nav-pills {
    order: 3;
    flex-basis: 100%;
    justify-content: flex-start;
  }

  .search-wrap {
    order: 4;
    flex-basis: 100%;
    max-width: none;
  }

  .user-chip {
    display: none;
  }

  .main-container {
    padding: 12px;
    gap: 14px;
  }

  .stage-grid.with-sidebar {
    grid-template-columns: minmax(0, 1fr);
  }

  .live-sidebar {
    max-height: none;
  }

  .video-frame {
    max-width: 100%;
  }

  .cat-select {
    max-width: 100%;
    width: 100%;
    min-width: 0;
  }

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

  .rail-track .media-card {
    flex: 0 0 144px;
  }

  .rail-track.rail-wide .media-card {
    flex: 0 0 196px;
  }

  .rail-nav-btn {
    display: none;
  }

  .volume-slider {
    width: 64px;
  }
}
