/* =====================================================
  * Norva - Dark Theme Design System
   ===================================================== */

/* CSS Variables */
:root {
  /* iOS Safari toolbar compensation (set dynamically by JS) */
  --ios-ui-bottom: 0px;


  /* Colors */
  --color-bg-primary: #080B12;
  --color-bg-secondary: #12121a;
  --color-bg-tertiary: #1a1a25;
  --color-bg-hover: #22222f;
  --color-bg-active: #2a2a3a;

  --color-accent: #3B82F6;
  --color-accent-hover: #60A5FA;
  --color-accent-dim: rgba(59, 130, 246, 0.2);
  --color-accent-secondary: #8B5CF6;

  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;

  --color-text-primary: #F8FAFC;
  --color-text-secondary: #94A3B8;
  --color-text-muted: #71717a;

  --color-border: #27272a;
  --color-border-light: #3f3f46;

  /* Glass effect */
  --glass-bg: rgba(18, 18, 26, 0.8);
  --glass-border: rgba(255, 255, 255, 0.1);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;

  /* Layout */
  --navbar-height: 60px;
  --sidebar-width: 320px;
  --epg-sidebar-width: 250px;

  /* Safe area insets for notched devices */
  --safe-area-inset-top: env(safe-area-inset-top, 0px);
  --safe-area-inset-right: env(safe-area-inset-right, 0px);
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-inset-left: env(safe-area-inset-left, 0px);
}

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text-primary);
  background: var(--color-bg-primary);
  overflow: hidden;
  /* Prevent pull-to-refresh and overscroll bounce on mobile */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

/* Prevent text selection on touch devices (improves UX) */
@media (hover: none) {
  * {
    -webkit-user-select: none;
    user-select: none;
  }

  /* Allow text selection in inputs and content areas */
  input,
  textarea,
  .modal-body,
  .series-info,
  .movie-info,
  .epg-program-desc {
    -webkit-user-select: text;
    user-select: text;
  }
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  /* fallback */
  height: 100dvh;
  /* dynamic viewport height for modern browsers */
  height: -webkit-fill-available;
  /* iOS Safari fallback */
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  line-height: 1.3;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
}

h4 {
  font-size: 1rem;
}

.hint {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.hidden {
  display: none !important;
}

/* =====================================================
   Navbar
   ===================================================== */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--navbar-height);
  padding: 0 var(--space-lg);
  padding-left: max(var(--space-lg), var(--safe-area-inset-left));
  padding-right: max(var(--space-lg), var(--safe-area-inset-right));
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
}

.logo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  border-radius: 10px;
}

.brand-text {
  font-family: 'Century Gothic', sans-serif;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  color: #fff;
  /* Visual correction: shift text slightly down to align optically with icon center */
  padding-top: 2px;
}

.brand-accent {
  color: var(--color-accent);
}

.navbar-menu {
  display: flex;
  gap: var(--space-xs);
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 110;
}

.mobile-menu-toggle span {
  width: 100%;
  height: 2px;
  background: var(--color-text-primary);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.mobile-menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(7px, 7px);
}

.mobile-menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -7px);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.nav-link:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-hover);
}

.nav-link.active {
  color: var(--color-accent);
  background: var(--color-accent-dim);
}

.nav-icon {
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* =====================================================
   Main Content & Pages
   ===================================================== */
.main-content {
  flex: 1;
  overflow: hidden;
}

.page {
  display: none;
  height: 100%;
  overflow: hidden;
}

.page.active {
  display: block;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: var(--space-xl);
  text-align: center;
  color: var(--color-text-muted);
}

/* =====================================================
   Home Page Layout
   ===================================================== */
.home-layout {
  display: flex;
  height: 100%;
  position: relative;
}

/* Fix scroll sidebar on desktop (Safari / flex bug) */
.main-content,
.page,
.home-layout,
.channel-sidebar,
.channel-list {
  min-height: 0;
}

/* Floating Channel Toggle Button (Mobile) */
.channel-toggle-btn {
  display: none;
  position: absolute;
  top: var(--space-md);
  left: var(--space-md);
  z-index: 60;
  padding: var(--space-sm) var(--space-md);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-primary);
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-fast);
  align-items: center;
  gap: var(--space-sm);
}

.channel-toggle-btn:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  box-shadow: var(--shadow-glow);
}

.channel-toggle-btn .icon {
  width: 1.25em;
  height: 1.25em;
}

/* Channel Sidebar Overlay */
.channel-sidebar-overlay {
  display: none;
}

/* Sidebar */
.channel-sidebar {
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
}

.sidebar-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-header-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-header-row .search-wrapper {
  flex: 1;
}

.sidebar-collapse-btn {
  display: none;
  /* Hidden on mobile */
  flex-shrink: 0;
  padding: var(--space-xs);
}

.sidebar-collapse-btn .icon {
  transition: transform 0.2s ease;
}

/* Desktop collapse button visibility */
@media (min-width: 769px) {
  .sidebar-collapse-btn {
    display: flex;
  }
}

/* Collapsed sidebar state (desktop only) */
.channel-sidebar.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
  border-right: none;
}

.channel-sidebar.collapsed .sidebar-header,
.channel-sidebar.collapsed .channel-list {
  opacity: 0;
  visibility: hidden;
}

/* Expand button when sidebar is collapsed */
.sidebar-expand-btn {
  display: none;
  position: fixed;
  left: 0;
  top: calc(var(--navbar-height) + var(--space-md));
  z-index: 95;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-sm);
  cursor: pointer;
  color: var(--color-text-primary);
  transition: opacity 0.3s ease, background var(--transition-fast);
  opacity: 0;
  pointer-events: none;
}

.sidebar-expand-btn:hover {
  background: var(--color-bg-hover);
}

.sidebar-expand-btn .icon {
  width: 20px;
  height: 20px;
}

/* Show expand button when sidebar is collapsed */
.home-layout.sidebar-collapsed .sidebar-expand-btn {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

/* Fade in expand button with player controls */
.home-layout.sidebar-collapsed .sidebar-expand-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Hide expand button on mobile - mobile uses the floating toggle instead */
@media (max-width: 768px) {
  .sidebar-expand-btn {
    display: none !important;
  }
}

/* Smooth transitions */
.channel-sidebar {
  transition: width 0.2s ease, min-width 0.2s ease;
}

.search-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: 0.875rem;
  transition: border-color var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.search-input::placeholder {
  color: var(--color-text-muted);
}

/* Search wrapper for clear button */
.search-wrapper {
  position: relative;
  width: 100%;
  min-width: 150px;
}

.search-wrapper .search-input {
  padding-right: 30px;
  /* Room for clear button */
}

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.search-wrapper:hover .search-clear,
.search-input:focus~.search-clear {
  opacity: 0.6;
}

.search-clear:hover {
  opacity: 1;
  color: var(--color-text-primary);
}

.sidebar-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  flex-wrap: wrap;
}

.source-select {
  flex: 1;
  min-width: 140px;
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-size: 0.75rem;
}

.playback-scan-btn {
  width: 34px;
  min-width: 34px;
  height: 30px;
  padding: 0;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.playback-scan-btn.scanning .scan-icon {
  display: inline-block;
  animation: live-scan-spin 0.8s linear infinite;
}

.live-scan-status {
  flex-basis: 100%;
  min-height: 16px;
  color: var(--color-text-muted);
  font-size: 0.68rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes live-scan-spin {
  to {
    transform: rotate(360deg);
  }
}

.toggle-hidden {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  cursor: pointer;
}

.toggle-hidden input {
  accent-color: var(--color-accent);
}

/* Channel List */
.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.channel-group {
  margin-bottom: var(--space-sm);
}

.group-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}

.group-header:hover {
  background: var(--color-bg-hover);
}

.group-toggle {
  transition: transform var(--transition-fast);
}

.group-header.collapsed .group-toggle {
  transform: rotate(-90deg);
}

.group-name {
  flex: 1;
  font-weight: 500;
  font-size: 0.875rem;
}

.group-count {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.group-channels {
  margin-top: var(--space-xs);
}

.group-header.collapsed+.group-channels {
  display: none;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.channel-item.logical-channel {
  min-height: 58px;
}

.channel-lcn {
  flex: 0 0 24px;
  color: #9fb1ff;
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.channel-item.logical-primary .channel-name {
  font-weight: 700;
}

.channel-item.logical-multiplex {
  opacity: 0.92;
}

.channel-item:hover {
  background: var(--color-bg-hover);
}

.channel-item.active {
  background: var(--color-accent-dim);
  border-left: 3px solid var(--color-accent);
}

.channel-item.hidden {
  opacity: 0.5;
}

.channel-item.playback-broken .channel-name::after,
.channel-item.playback-direct-hls .channel-name::after {
  content: "HS";
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(239, 68, 68, 0.18);
  color: var(--color-error);
  border: 1px solid rgba(239, 68, 68, 0.35);
  font-size: 0.62rem;
  font-weight: 700;
  vertical-align: middle;
}

.channel-item.playback-ok:not(.playback-broken):not(.playback-direct-hls) .channel-name::after {
  content: "OK";
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.35);
  font-size: 0.62rem;
  font-weight: 700;
  vertical-align: middle;
}

.channel-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-tertiary);
  object-fit: contain;
}

.channel-info {
  flex: 1;
  min-width: 0;
}

.channel-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-program {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =====================================================
   Video Player Section
   ===================================================== */
.player-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-primary);
  min-width: 0;
}

.video-container {
  flex: 1 1 58%;
  position: relative;
  background: #000;
  overflow: hidden;
  min-height: 240px;
  /* Allow flex child to shrink */
}

.live-guide-fusion {
  flex: 0 0 42%;
  min-height: 260px;
  max-height: 46%;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(18, 24, 38, 0.92), rgba(7, 10, 18, 0.98)),
    var(--color-bg-primary);
  overflow: hidden;
}

.live-guide-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.live-guide-shell.groups-hidden {
  grid-template-columns: minmax(0, 1fr);
}

.live-guide-shell.groups-hidden .live-guide-groups {
  display: none;
}

.live-guide-fusion.live-guide-groups-hidden .live-guide-shell {
  grid-template-columns: minmax(0, 1fr);
}

.live-guide-fusion.live-guide-groups-hidden .live-guide-groups {
  display: none;
}

.live-guide-groups {
  overflow-y: auto;
  padding: 18px 10px 18px 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.live-guide-group {
  display: flex;
  width: 100%;
  min-height: 36px;
  align-items: center;
  margin-bottom: 6px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-secondary);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.live-guide-group:hover,
.live-guide-group:focus-visible,
.live-guide-group.active {
  outline: none;
  color: #fff;
  background: rgba(83, 118, 255, 0.78);
}

.live-guide-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.live-guide-preview {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 22px;
  min-height: 132px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.live-guide-preview-art {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  background: rgba(0, 0, 0, 0.34);
}

.live-guide-preview-art img {
  max-width: 78%;
  max-height: 82px;
  object-fit: contain;
}

.live-guide-preview-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.live-guide-preview-title {
  color: #eaf0ff;
  font-size: 1.15rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-guide-preview-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
  color: #aeb9ff;
  font-size: 0.85rem;
}

.live-guide-progress {
  width: 74px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.live-guide-progress span {
  display: block;
  height: 100%;
  background: #7d8cff;
}

.live-guide-preview-channel {
  margin-top: 12px;
  color: #fff;
  font-weight: 800;
}

.live-guide-preview-channel span {
  margin-left: 10px;
  color: #a6b1d6;
  font-size: 0.78rem;
}

.live-guide-table {
  display: grid;
  grid-template-rows: 32px minmax(0, 1fr);
  min-height: 0;
}

.live-guide-time-head,
.live-guide-row {
  display: grid;
  grid-template-columns: 270px repeat(3, minmax(160px, 1fr));
}

.live-guide-time-head {
  align-items: center;
  padding-right: 12px;
  color: #adbbff;
  font-weight: 800;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.live-guide-time-head span {
  padding: 0 10px;
}

.live-guide-rows {
  min-height: 0;
  overflow-y: auto;
  padding-right: 12px;
}

.live-guide-row {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  background: rgba(16, 20, 34, 0.66);
  color: var(--color-text-primary);
  cursor: pointer;
  text-align: left;
}

.live-guide-row:nth-child(even) {
  background: rgba(11, 15, 27, 0.72);
}

.live-guide-row:hover,
.live-guide-row:focus-visible,
.live-guide-row.active {
  outline: none;
  background: rgba(91, 116, 255, 0.86);
}

.live-guide-row.pending-refresh {
  background: rgba(91, 116, 255, 0.74);
}

.live-guide-channel-cell {
  display: grid;
  grid-template-columns: 34px 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  min-width: 0;
}

.live-guide-num {
  color: #9fb1ff;
  font-weight: 800;
  text-align: right;
}

.live-guide-channel-cell img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.live-guide-channel-name {
  grid-column: 3;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f8fbff;
  font-weight: 800;
}

.live-guide-variant-count {
  grid-column: 3;
  min-width: 0;
  margin-top: 2px;
  color: #99a7d4;
  font-size: 0.66rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-guide-mode {
  grid-column: 3;
  justify-self: start;
  margin-top: 2px;
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.58rem;
  font-weight: 800;
}

.live-guide-mode.ok {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

.live-guide-mode.problem {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

.live-guide-mode.pending {
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
}

.live-guide-program {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 12px;
  color: #c5cff8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-left: 1px solid rgba(255, 255, 255, 0.065);
}

.live-guide-row.active .live-guide-program,
.live-guide-row:hover .live-guide-program,
.live-guide-row:focus-visible .live-guide-program {
  color: #fff;
}

.live-guide-empty {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}

@media (max-width: 1100px) {
  .live-guide-shell {
    grid-template-columns: 170px minmax(0, 1fr);
  }

  .live-guide-preview {
    grid-template-columns: 150px minmax(0, 1fr);
    min-height: 112px;
    padding: 14px 16px;
  }

  .live-guide-time-head,
  .live-guide-row {
    grid-template-columns: 220px repeat(3, minmax(130px, 1fr));
  }
}

@media (max-width: 768px) {
  .player-section {
    overflow-y: auto;
  }

  .video-container {
    flex: 0 0 44vh;
  }

  .live-guide-fusion {
    flex: 0 0 56vh;
    max-height: none;
  }

  .live-guide-shell {
    grid-template-columns: 1fr;
  }

  .live-guide-shell.groups-hidden .live-guide-groups,
  .live-guide-fusion.live-guide-groups-hidden .live-guide-groups {
    display: none;
  }

  .live-guide-groups {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .live-guide-group {
    width: auto;
    min-width: 130px;
    margin-bottom: 0;
    justify-content: center;
    text-align: center;
  }

  .live-guide-preview {
    grid-template-columns: 92px minmax(0, 1fr);
    min-height: 96px;
  }

  .live-guide-preview-title {
    font-size: 1rem;
  }

  .live-guide-time-head,
  .live-guide-row {
    grid-template-columns: 210px repeat(3, 150px);
    min-width: 660px;
  }

  .live-guide-table {
    overflow-x: auto;
  }
}

/* Live TV player controls overlay - iOS Safari safe positioning */
#player-controls-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--ios-ui-bottom, 0px));
  box-sizing: border-box;
}

/* Favorites */
.group-header.favorites-group {
  background: linear-gradient(to right, rgba(239, 68, 68, 0.1), transparent);
  border-left: 3px solid var(--color-error);
}

.group-header.favorites-group .group-name {
  color: var(--color-error);
  font-weight: 600;
}

.favorite-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.25rem;
  padding: 0 var(--space-xs);
  cursor: pointer;
  opacity: 0;
  transition: all var(--transition-fast);
}

.channel-item:hover .favorite-btn,
.epg-channel-row:hover .favorite-btn,
.favorite-btn.active {
  opacity: 1;
}

.favorite-btn:hover,
.favorite-btn.active {
  color: var(--color-error);
  transform: scale(1.1);
}

#video-player {
  width: 100%;
  height: 100%;
  max-height: 100%;
  background: #000;
  object-fit: contain;
  /* Maintain aspect ratio without overflow */
}

/* Make video controls more touch-friendly on mobile */
@media (max-width: 768px) {
  #video-player::-webkit-media-controls-panel {
    padding: 8px;
  }

  #video-player::-webkit-media-controls-play-button,
  #video-player::-webkit-media-controls-fullscreen-button,
  #video-player::-webkit-media-controls-volume-slider {
    transform: scale(1.2);
  }
}

/* Custom Video Controls */
.video-controls {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  display: none;
  flex-direction: column;
  gap: var(--space-sm);
  z-index: 50;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.video-controls.show {
  pointer-events: auto;
}

.video-container:hover .video-controls,
.video-controls.show {
  opacity: 1;
}

.video-control-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-md);
}

.video-control-btn:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  transform: scale(1.05);
}

.video-control-btn:active {
  transform: scale(0.95);
}

.video-control-btn .icon {
  width: 24px;
  height: 24px;
}

.video-control-btn.muted .icon {
  color: var(--color-error);
}

/* Show custom controls on mobile as supplementary */
@media (max-width: 768px) {
  .video-controls {
    display: flex;
  }

  /* Make control buttons larger on mobile */
  .video-control-btn {
    width: 56px;
    height: 56px;
  }

  .video-control-btn .icon {
    width: 28px;
    height: 28px;
  }
}

/* Touch devices */
@media (hover: none) and (pointer: coarse) {
  .video-controls {
    display: flex;
  }
}

/* Closed Caption styling */
video::cue {
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 1.2em;
  font-family: inherit;
  padding: 0.2em 0.5em;
}

.player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.player-overlay.hidden {
  display: none;
}

.overlay-content {
  text-align: center;
  color: var(--color-text-muted);
}

/* Now Playing Overlay */
.now-playing-overlay {
  position: absolute;
  bottom: 60px;
  left: var(--space-lg);
  right: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.now-playing-overlay.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

/* iOS safe area for now playing overlay */
@supports (bottom: env(safe-area-inset-bottom)) {
  .now-playing-overlay {
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }
}

/* Fullscreen mode for video container */
.video-container:fullscreen {
  width: 100%;
  height: 100%;
  background: #000;
}

.video-container:fullscreen #video-player {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-container:fullscreen .now-playing-overlay {
  bottom: 80px;
}

/* Safari fullscreen support (required for iOS) */
.video-container:-webkit-full-screen {
  width: 100%;
  height: 100%;
  background: #000;
}

.video-container:-webkit-full-screen #video-player {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-container:-webkit-full-screen .now-playing-overlay {
  bottom: 80px;
}

/* Fullscreen safe area for controls - especially for iOS */
.video-container:fullscreen .watch-bottom-bar,
.video-container:-webkit-full-screen .watch-bottom-bar {
  padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
}

.video-container:fullscreen .watch-top-bar,
.video-container:-webkit-full-screen .watch-top-bar {
  padding-top: calc(var(--space-lg) + env(safe-area-inset-top, 0px));
}

.channel-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.channel-nav .btn-icon {
  width: 36px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
}

.now-playing-info {
  flex: 1;
}

.now-playing-info .channel-name {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.program-title {
  font-size: 1.25rem;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

.program-time {
  font-size: 1rem;
  color: var(--color-text-muted);
}

.up-next {
  width: 250px;
}

.up-next h4 {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  margin-bottom: var(--space-sm);
}

#up-next-list {
  list-style: none;
}

#up-next-list li {
  font-size: 0.875rem;
  padding: var(--space-xs) 0;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
}

/* =====================================================
   EPG Guide
   ===================================================== */

.epg-limit-warning {
  background: var(--color-warning);
  color: var(--color-bg);
  padding: var(--space-sm) var(--space-md);
  text-align: center;
  font-weight: 500;
  margin-bottom: var(--space-sm);
  border-radius: var(--radius-sm);
}

.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

.guide-controls {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.guide-controls {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.guide-date {
  font-weight: 600;
}

.epg-grid {
  height: calc(100vh - var(--navbar-height) - 60px);
  overflow: hidden;
  overflow-y: auto;
  padding: var(--space-md);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.epg-time-header {
  display: flex;
  position: sticky;
  top: 0;
  background: var(--color-bg-secondary);
  z-index: 10;
}

.epg-header-corner {
  width: var(--epg-sidebar-width);
  flex-shrink: 0;
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
}

.epg-time-slots {
  display: flex;
  flex: 1;
}

.epg-time-slot {
  padding: var(--space-sm) var(--space-md);
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  border-right: 1px solid var(--color-border);
  flex-shrink: 0;
}

.epg-channel-row {
  display: flex;
  border-bottom: 1px solid var(--color-border);
}

.epg-channel-info {
  width: var(--epg-sidebar-width);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--color-bg-secondary);
  position: sticky;
  left: 0;
  z-index: 5;
  border-right: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.epg-channel-info:hover {
  background: var(--color-bg-hover);
}

.resize-handle {
  position: absolute;
  right: -8px;
  top: 0;
  bottom: 0;
  width: 16px;
  cursor: col-resize;
  background: transparent;
  z-index: 10;
  transition: background var(--transition-fast);
}

.resize-handle:hover,
.resize-handle.active {
  background: var(--color-accent);
}

.epg-channel-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.epg-channel-name {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.epg-programs {
  display: flex;
  flex: 1;
}

.epg-program {
  padding: var(--space-sm);
  background: var(--color-bg-tertiary);
  border-right: 1px solid var(--color-border);
  cursor: pointer;
  overflow: hidden;
  transition: background var(--transition-fast);
}

.epg-program:hover {
  background: var(--color-bg-hover);
}

.epg-program.current {
  background: var(--color-accent-dim);
  border-left: 3px solid var(--color-accent);
}

.epg-program-title {
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.epg-program-time {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Current time indicator */
.epg-now-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--color-error);
  z-index: 2;
}

/* =====================================================
   Settings Page
   ===================================================== */
.settings-container {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-lg);
  height: calc(100vh - var(--navbar-height));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.settings-container h2 {
  margin-bottom: var(--space-lg);
}

/* Tabs */
.tabs {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.tab {
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}

.tab:hover {
  color: var(--color-text-primary);
}

.tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.account-settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-md);
  align-items: stretch;
}

.account-summary-card,
.account-actions-card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.account-summary-card strong {
  display: block;
  margin-top: var(--space-xs);
  word-break: break-word;
}

.account-actions-card {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
  justify-content: flex-end;
}

.service-health-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
  padding: var(--space-lg);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.service-health-card.service-health-prominent {
  min-height: 220px;
  align-items: flex-end;
  padding: clamp(24px, 4vw, 48px);
  background:
    linear-gradient(120deg, rgba(59, 130, 246, 0.22), rgba(139, 92, 246, 0.14)),
    var(--color-bg-secondary);
}

.service-health-prominent .service-health-copy h3 {
  max-width: 760px;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
}

.service-health-prominent .service-health-copy p {
  max-width: 680px;
  font-size: 1.05rem;
}

.service-health-prominent .service-health-actions .btn {
  min-width: 220px;
}

.service-health-card.hidden {
  display: none;
}

.service-health-card.setup-suppressed,
#home-service-health.setup-suppressed,
.setup-suppressed .service-health-card {
  display: none;
}

.service-health-not_configured,
.service-health-auth_failed,
.service-health-expired {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(127, 29, 29, 0.16);
}

.service-health-unreachable,
.service-health-degraded {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(120, 53, 15, 0.14);
}

.service-health-syncing {
  border-color: rgba(96, 165, 250, 0.35);
  background: rgba(30, 64, 175, 0.14);
}

.service-health-copy h3 {
  margin: var(--space-xs) 0;
}

.service-health-copy p {
  margin: 0;
  color: var(--color-text-secondary);
}

.service-health-copy small,
.service-health-label {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

.service-health-label {
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 700;
}

.service-health-actions {
  flex: 0 0 auto;
}

.norva-setup-gate {
  min-height: calc(100dvh - 180px);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: clamp(24px, 4vw, 56px);
  align-items: center;
  padding: clamp(28px, 6vw, 76px) clamp(18px, 5vw, 64px);
  background:
    linear-gradient(120deg, rgba(79, 123, 255, 0.18), rgba(169, 78, 255, 0.1)),
    var(--color-bg-primary);
}

.norva-setup-card {
  max-width: 820px;
}

.norva-setup-kicker {
  color: var(--color-primary);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: var(--space-md);
  text-transform: uppercase;
}

.norva-setup-card h1 {
  max-width: 860px;
  margin: 0 0 var(--space-md);
  font-family: var(--font-display, inherit);
  font-size: clamp(2.4rem, 6vw, 5.5rem);
  line-height: 0.95;
}

.norva-setup-card p {
  max-width: 680px;
  color: var(--color-text-secondary);
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  line-height: 1.55;
  margin: 0 0 var(--space-xl);
}

.norva-setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.norva-setup-actions .btn {
  min-width: 180px;
}

.norva-setup-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.norva-setup-step {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: var(--space-md);
  align-items: center;
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: rgba(18, 24, 38, 0.72);
}

.norva-setup-step-index {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.12);
  color: var(--color-text-muted);
  font-weight: 800;
}

.norva-setup-step strong {
  display: block;
  margin-bottom: 2px;
}

.norva-setup-step span:not(.norva-setup-step-index) {
  color: var(--color-text-muted);
  font-size: 0.92rem;
}

.norva-setup-step.active {
  border-color: rgba(96, 165, 250, 0.62);
  background: rgba(37, 99, 235, 0.18);
}

.norva-setup-step.complete {
  border-color: rgba(52, 211, 153, 0.5);
  background: rgba(6, 95, 70, 0.16);
}

.norva-setup-step.attention {
  border-color: rgba(248, 113, 113, 0.52);
  background: rgba(127, 29, 29, 0.18);
}

.norva-setup-step.active .norva-setup-step-index {
  background: var(--color-primary);
  color: #fff;
}

.norva-setup-step.complete .norva-setup-step-index {
  background: rgba(16, 185, 129, 0.22);
  color: #86efac;
}

.norva-setup-step.attention .norva-setup-step-index {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

/* Source Sections */
.source-section {
  margin-bottom: var(--space-xl);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.source-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.source-advanced-login {
  margin-top: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.48);
  overflow: hidden;
}

.source-advanced-login summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-md);
  cursor: pointer;
  color: var(--color-text-secondary);
  font-weight: 700;
  list-style: none;
}

.source-advanced-login summary::-webkit-details-marker {
  display: none;
}

.source-advanced-login summary::after {
  content: '+';
  margin-left: auto;
  color: var(--color-primary);
  font-size: 1.2rem;
}

.source-advanced-login[open] summary {
  border-bottom: 1px solid var(--color-border);
}

.source-advanced-login[open] summary::after {
  content: '-';
}

.source-advanced-login .form-group {
  padding: var(--space-md);
  margin: 0;
}

.source-advanced-login .form-group + .form-group {
  padding-top: 0;
}

.source-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.source-item.disabled {
  opacity: 0.5;
}

.source-icon {
  font-size: 1.5rem;
}

.source-info {
  flex: 1;
  min-width: 0;
}

.source-name {
  font-weight: 500;
}

.source-name-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.source-url {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  word-break: break-all;
}

.source-health-message {
  margin-top: var(--space-xs);
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.source-health-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: 0.6875rem;
  font-weight: 800;
}

.source-health-ready {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(22, 101, 52, 0.22);
}

.source-health-syncing {
  color: #93c5fd;
  border-color: rgba(96, 165, 250, 0.35);
  background: rgba(30, 64, 175, 0.2);
}

.source-health-auth_failed,
.source-health-expired,
.source-health-not_configured {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(127, 29, 29, 0.24);
}

.source-health-unreachable,
.source-health-degraded {
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(120, 53, 15, 0.22);
}

.source-item.needs-attention {
  border-color: rgba(245, 158, 11, 0.45);
}

.source-actions {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.source-actions .btn-warning-outline {
  color: var(--color-warning, #f59e0b);
  border-color: rgba(245, 158, 11, 0.45);
}

.source-actions .btn-warning-outline:hover {
  background: rgba(245, 158, 11, 0.12);
  border-color: var(--color-warning, #f59e0b);
}

.source-actions .btn-repair {
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.55);
}

.source-form-intro {
  margin: 0 0 var(--space-md);
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.label-optional {
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Hidden Items */
.hidden-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.hidden-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
}

.hidden-item-info {
  flex: 1;
}

.hidden-item-type {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

/* Settings Sections */
.settings-section {
  margin-bottom: var(--space-xl);
}

.settings-section h3 {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.setting-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
}

.setting-info {
  flex: 1;
}

.setting-label {
  display: block;
  font-weight: 500;
}

.setting-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.setting-number {
  width: 80px;
  text-align: center;
}

/* Toggle Switch */
.setting-toggle {
  position: relative;
  width: 48px;
  height: 26px;
}

.setting-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.setting-toggle input:checked+.toggle-slider {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.setting-toggle input:checked+.toggle-slider::before {
  transform: translateX(22px);
}

/* Volume Slider */
.volume-slider-container {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex: 1;
}

.volume-slider {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--color-bg-tertiary);
  appearance: none;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.volume-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  border: none;
}

#volume-value {
  min-width: 40px;
  text-align: right;
  font-weight: 500;
  color: var(--color-text-secondary);
}

/* Keyboard Shortcuts */
.shortcuts-grid {
  display: grid;
  gap: var(--space-sm);
}

.shortcut {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.75rem;
}

/* =====================================================
   Buttons
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--color-accent);
  color: white;
}

.btn-primary:hover {
  background: var(--color-accent-hover);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-bg-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.btn-danger {
  background: var(--color-error);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-icon {
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
}

/* =====================================================
   Modal
   ===================================================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal.active {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--color-text-primary);
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
}

/* EPG Info Modal */
.epg-info-modal .channel-details {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.epg-info-modal .channel-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
}

.epg-info-modal .channel-meta p {
  margin: var(--space-xs) 0;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.epg-info-modal h4 {
  margin: var(--space-md) 0 var(--space-sm);
  font-size: 1rem;
  color: var(--color-text-primary);
}

.epg-program-list {
  max-height: 300px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.epg-program {
  padding: var(--space-sm);
  margin-bottom: var(--space-xs);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
}

.epg-program.current {
  background: var(--color-accent-dim);
  border-left: 3px solid var(--color-accent);
}

.epg-program-time {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.epg-program-title {
  font-weight: 500;
  color: var(--color-text-primary);
}

.epg-program-desc {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: var(--space-xs);
}

.no-programs {
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--space-lg);
}

/* Form Elements */
.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.form-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: 0.875rem;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-accent);
}

/* =====================================================
   Context Menu
   ===================================================== */
.context-menu {
  display: none;
  position: fixed;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 150px;
  overflow: hidden;
}

.context-menu.active {
  display: block;
}

.context-item {
  display: block;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  color: var(--color-text-primary);
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.context-item:hover {
  background: var(--color-bg-hover);
}

/* =====================================================
   Content Browser (Manage Content Tab)
   ===================================================== */
.content-browser {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--navbar-height) - 200px);
}

.content-browser-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.content-type-toggle {
  display: flex;
  gap: var(--space-xs);
}

.content-type-toggle .btn {
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
}

.content-type-toggle .btn.active {
  background: var(--color-accent);
  color: white;
}

.content-browser-header .source-select {
  flex: 1;
  max-width: 300px;
}

.content-actions {
  display: flex;
  gap: var(--space-sm);
  margin-left: auto;
}

.content-tree {
  flex: 1;
  overflow-y: auto;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.content-group {
  margin-bottom: var(--space-xs);
}

.content-group-header {
  display: flex;
  align-items: center;
  padding: var(--space-xs);
  background: var(--color-surface-hover);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
}

.content-group-header:hover {
  background: var(--color-surface-active);
}

.group-expander {
  margin-right: var(--space-sm);
  font-size: 0.8em;
  width: 20px;
  text-align: center;
  transition: transform 0.2s;
}

.content-group.collapsed .group-expander {
  transform: rotate(-90deg);
}

.content-channels {
  margin-left: 28px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.content-group.collapsed .content-channels {
  display: none;
}

.checkbox-label.channel-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-bg-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  transition: background var(--transition-fast);
}

.checkbox-label.channel-item:hover {
  background: var(--color-bg-hover);
}

.content-categories {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.checkbox-label.category-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background var(--transition-fast);
}

.checkbox-label.category-item:hover {
  background: var(--color-bg-hover);
}

.checkbox-label.channel-item.is-hidden {
  opacity: 0.6;
  text-decoration: line-through;
  background: rgba(251, 191, 36, 0.1);
}

.checkbox-label.channel-item .channel-name {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Checkbox styling */
.content-tree input[type="checkbox"] {
  accent-color: var(--color-accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* =====================================================
   Scrollbar
   ===================================================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border-light);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* =====================================================
   Loading States
   ===================================================== */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-xl);
  color: var(--color-text-muted);
  width: 100%;
}

.horizontal-scroll .empty-state {
  padding: var(--space-xl);
  min-height: 150px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =====================================================
   Responsive
   ===================================================== */

/* Mobile-first responsive breakpoints */
@media (max-width: 1024px) {

  /* Tablet adjustments */
  :root {
    --sidebar-width: 280px;
    --epg-sidebar-width: 200px;
  }

  .movies-grid,
  .series-grid {
    gap: var(--space-sm);
    padding: var(--space-md);
  }
}

@media (max-width: 768px) {

  /* Tablet/Mobile landscape */
  :root {
    --navbar-height: 56px;
    --sidebar-width: 320px;
    --space-lg: 16px;
    --space-xl: 24px;
    --epg-sidebar-width: 180px;
  }

  /* Navigation - Hide text labels, show only icons */
  .navbar {
    padding: 0 var(--space-md);
  }

  .navbar-menu {
    flex: 1;
    justify-content: space-around;
    gap: 0;
  }

  /* Hide nav link text on mobile, but keep Now Playing visible */
  .navbar-menu .nav-link span:not(.nav-icon) {
    display: none;
  }

  .nav-link {
    padding: var(--space-sm);
    flex-direction: column;
    gap: 2px;
  }

  .nav-icon {
    font-size: 1.4rem;
  }

  /* Brand - Simplify on tablet */
  .brand-text {
    font-size: 1.25rem;
  }

  /* Home Layout - Full screen video with drawer */
  .home-layout {
    flex-direction: row;
  }

  /* Show floating channel toggle button */
  .channel-toggle-btn {
    display: flex;
  }

  /* Channel sidebar becomes a slide-out drawer */
  .channel-sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    height: auto;
    border-right: 1px solid var(--color-border);
    border-bottom: none;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 90;
    box-shadow: var(--shadow-lg);
    visibility: hidden;
  }

  .channel-sidebar.active {
    transform: translateX(0);
    visibility: visible;
  }

  /* Overlay behind drawer */
  .channel-sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 80;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .channel-sidebar-overlay.active {
    display: block;
    opacity: 1;
  }

  /* Video player takes full width */
  .player-section {
    width: 100%;
  }

  .sidebar-header {
    padding: var(--space-sm) var(--space-md);
  }

  .sidebar-controls {
    flex-wrap: wrap;
  }

  /* Video Player */
  .player-section {
    flex: 1;
    min-height: 0;
  }

  /* Now Playing Overlay - Stack vertically */
  .now-playing-overlay {
    flex-direction: column;
    bottom: 40px;
    left: var(--space-md);
    right: var(--space-md);
    padding: var(--space-md);
    gap: var(--space-md);
  }

  .now-playing-info .channel-name {
    font-size: 1.25rem;
  }

  .program-title {
    font-size: 1rem;
  }

  .up-next {
    width: 100%;
  }

  .channel-nav {
    flex-direction: row;
    justify-content: center;
    width: 100%;
  }

  .channel-nav .btn-icon {
    width: 48px;
    height: 36px;
  }

  /* EPG Guide */
  .guide-header {
    flex-direction: column;
    gap: var(--space-md);
    align-items: stretch;
  }

  .guide-controls {
    flex-wrap: wrap;
    justify-content: center;
  }

  .epg-grid {
    height: calc(100vh - var(--navbar-height) - 120px);
  }

  .epg-channel-info {
    width: var(--epg-sidebar-width);
  }

  /* Movies & Series */
  .movies-header,
  .series-header {
    flex-direction: column;
    gap: var(--space-md);
    align-items: stretch;
    padding: var(--space-md);
  }

  .movies-controls,
  .series-controls {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .movies-controls .source-select,
  .series-controls .source-select,
  .movies-controls .search-wrapper,
  .series-controls .search-wrapper {
    flex: 1;
    min-width: 140px;
  }

  .movies-grid,
  .series-grid {
    padding: var(--space-md);
    gap: var(--space-md);
    height: calc(100vh - var(--navbar-height) - 140px);
  }

  .movie-card,
  .series-card {
    flex: 0 0 140px;
    width: 140px;
  }

  .movie-poster,
  .series-poster,
  .series-card .series-poster {
    width: 140px;
    height: 210px;
  }

  /* Settings */
  .settings-container {
    padding: var(--space-md);
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .account-settings-grid {
    grid-template-columns: 1fr;
  }

  .account-actions-card {
    justify-content: stretch;
  }

  .account-actions-card .btn,
  #settings-manage-service-btn {
    flex: 1 1 160px;
  }

  .service-health-card {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-md);
  }

  .service-health-card.service-health-prominent {
    min-height: 260px;
    justify-content: flex-end;
  }

  .service-health-actions .btn {
    width: 100%;
  }

  .norva-setup-gate {
    min-height: calc(100dvh - 96px);
    grid-template-columns: 1fr;
    align-items: start;
    padding: 28px 16px 40px;
  }

  .norva-setup-card h1 {
    font-size: clamp(2.2rem, 12vw, 3.6rem);
  }

  .norva-setup-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .norva-setup-actions .btn {
    width: 100%;
  }

  .norva-setup-step {
    grid-template-columns: 38px minmax(0, 1fr);
    padding: 14px;
  }

  .norva-setup-step-index {
    width: 38px;
    height: 38px;
  }

  .source-item {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
  }

  .source-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    justify-content: stretch;
  }

  .source-actions .btn {
    flex: 1;
    min-width: 44px;
    justify-content: center;
  }

  /* Modal */
  .modal-content {
    max-width: 90%;
    margin: var(--space-md);
  }

  /* Series Details */
  .series-details-header {
    flex-direction: column;
    align-items: center;
  }

  .series-details-header .series-poster {
    width: 180px;
    height: 270px;
  }
}

@media (max-width: 640px) {

  /* Mobile portrait - phones */
  :root {
    --navbar-height: 52px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
  }

  body {
    font-size: 13px;
  }

  /* Navigation - Compact with hamburger menu */
  .navbar {
    padding: 0 var(--space-sm);
    height: 52px;
  }

  .logo {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .brand-text {
    font-size: 1.1rem;
  }

  /* Show mobile menu toggle */
  .mobile-menu-toggle {
    display: flex;
  }

  /* Mobile dropdown menu */
  .navbar-menu {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    padding: 0;
    gap: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    z-index: 100;
    visibility: hidden;
  }

  .navbar-menu.active {
    max-height: 400px;
    padding: var(--space-sm) 0;
    box-shadow: var(--shadow-lg);
    visibility: visible;
  }

  .nav-link {
    padding: var(--space-md) var(--space-lg);
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--space-md);
    border-radius: 0;
  }

  .nav-link span:not(.nav-icon) {
    display: inline !important;
  }

  .nav-icon {
    font-size: 1.3rem;
  }

  /* Hide "TV" from brand on very small screens */
  .brand-accent {
    display: none;
  }

  /* Channel Sidebar - Drawer on mobile */
  .channel-sidebar {
    width: 85%;
    max-width: 320px;
  }

  .channel-toggle-btn {
    top: var(--space-sm);
    left: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.875rem;
  }

  .channel-toggle-btn .icon {
    width: 1.1em;
    height: 1.1em;
  }

  .sidebar-header {
    padding: var(--space-sm);
  }

  .channel-item {
    padding: var(--space-xs) var(--space-sm);
  }

  .channel-logo {
    width: 32px;
    height: 32px;
  }

  .channel-name {
    font-size: 0.875rem;
  }

  .group-header {
    padding: var(--space-xs) var(--space-sm);
  }

  /* Now Playing Overlay - Compact */
  .now-playing-overlay {
    padding: var(--space-sm);
    bottom: 20px;
    left: var(--space-sm);
    right: var(--space-sm);
  }

  .now-playing-info .channel-name {
    font-size: 1.1rem;
    margin-bottom: 4px;
  }

  .program-title {
    font-size: 0.875rem;
  }

  .program-time {
    font-size: 0.75rem;
  }

  .up-next {
    display: none;
    /* Hide "Up Next" on very small screens */
  }

  /* EPG Guide - Mobile optimized */
  .guide-header {
    padding: var(--space-sm);
  }

  .guide-header h2 {
    font-size: 1.25rem;
  }

  .guide-controls {
    gap: var(--space-xs);
  }

  .guide-controls .btn {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.75rem;
  }

  .epg-channel-info {
    width: 140px;
    padding: var(--space-xs);
  }

  .epg-channel-logo {
    width: 24px;
    height: 24px;
  }

  .epg-channel-name {
    font-size: 0.75rem;
  }

  .epg-time-slot {
    min-width: 140px;
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.75rem;
  }

  .epg-program {
    padding: var(--space-xs);
  }

  .epg-program-title {
    font-size: 0.75rem;
  }

  .epg-program-time {
    font-size: 0.65rem;
  }

  /* Movies & Series Grid - Smaller cards */
  .movies-header h2,
  .series-header h2 {
    font-size: 1.25rem;
  }

  .movies-controls .btn,
  .series-controls .btn {
    font-size: 0.75rem;
    padding: var(--space-xs) var(--space-sm);
  }

  .movies-grid,
  .series-grid {
    padding: var(--space-sm);
    gap: var(--space-sm);
    justify-content: space-around;
  }

  .movie-card,
  .series-card {
    flex: 0 0 calc(50% - 8px);
    width: calc(50% - 8px);
    max-width: 160px;
  }

  .movie-poster,
  .series-poster,
  .series-card .series-poster {
    width: 100%;
    height: auto;
    aspect-ratio: 2/3;
  }

  .movie-title,
  .series-title {
    font-size: 0.8rem;
  }

  .movie-meta,
  .series-meta {
    font-size: 0.7rem;
  }

  /* Favorite button - always visible on mobile */
  .movie-poster .favorite-btn,
  .series-poster .favorite-btn {
    width: 28px;
    height: 28px;
    top: 6px;
    right: 6px;
  }

  .fav-icon {
    font-size: 1rem;
  }

  /* Settings Page - Mobile optimized */
  .settings-container {
    padding: var(--space-sm);
    height: calc(100vh - var(--navbar-height));
  }

  .settings-container h2 {
    font-size: 1.25rem;
    margin-bottom: var(--space-md);
  }

  .settings-section h3 {
    font-size: 1rem;
  }

  .tabs {
    gap: 2px;
    margin-bottom: var(--space-md);
  }

  .tab {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .setting-item {
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-sm);
    gap: var(--space-sm);
  }

  .setting-info {
    order: -1;
    /* Move label to top */
  }

  .setting-label {
    font-size: 0.875rem;
  }

  .setting-hint {
    font-size: 0.7rem;
  }

  .source-item {
    padding: var(--space-sm);
  }

  .source-name {
    font-size: 0.875rem;
  }

  .source-url {
    font-size: 0.7rem;
  }

  .btn {
    font-size: 0.8rem;
    padding: var(--space-xs) var(--space-sm);
  }

  .btn-sm {
    font-size: 0.7rem;
    padding: 4px var(--space-xs);
  }

  /* Content Browser */
  .content-browser-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
  }

  .content-type-toggle {
    justify-content: center;
  }

  .content-actions {
    margin-left: 0;
    justify-content: space-between;
  }

  /* Series Details */
  .series-details {
    padding: var(--space-sm);
  }

  .series-back-btn {
    padding: var(--space-xs) var(--space-sm);
    margin-bottom: var(--space-md);
    font-size: 0.875rem;
  }

  .series-details-header .series-poster {
    width: 160px;
    height: 240px;
  }

  .series-info h3 {
    font-size: 1.25rem;
  }

  .series-info p {
    font-size: 0.875rem;
  }

  .season-header {
    padding: var(--space-sm);
  }

  .season-name {
    font-size: 0.875rem;
  }

  .episode-item {
    padding: var(--space-xs) var(--space-sm);
  }

  .episode-number {
    width: 32px;
    font-size: 0.875rem;
  }

  .episode-title {
    font-size: 0.875rem;
  }

  .episode-duration {
    font-size: 0.75rem;
  }

  /* Modal - Full screen on mobile */
  .modal-content {
    max-width: 95%;
    max-height: 95vh;
  }

  .modal-header h3 {
    font-size: 1.1rem;
  }

  .modal-body {
    padding: var(--space-md);
  }

  /* Forms */
  .form-input {
    font-size: 0.875rem;
    padding: var(--space-xs) var(--space-sm);
  }

  /* Keyboard shortcuts - Hide on mobile since they're not relevant */
  .shortcuts-grid {
    display: none;
  }
}

@media (max-width: 480px) {

  /* Extra small phones */
  :root {
    --navbar-height: 48px;
  }

  .navbar {
    height: 48px;
  }

  .brand-text {
    font-size: 1rem;
  }

  .channel-sidebar {
    width: 90%;
    max-width: 300px;
  }

  /* Single column for very small screens */
  .movie-card,
  .series-card {
    flex: 0 0 calc(50% - 6px);
    width: calc(50% - 6px);
  }

  .now-playing-overlay {
    padding: var(--space-xs);
  }

  .now-playing-info .channel-name {
    font-size: 1rem;
  }

  .epg-channel-info {
    width: 120px;
  }

  .epg-time-slot {
    min-width: 120px;
  }
}

/* Landscape orientation adjustments for phones */
@media (max-width: 896px) and (orientation: landscape) {
  .channel-sidebar {
    width: 280px;
  }

  .navbar-menu {
    gap: 4px;
  }

  .now-playing-overlay {
    bottom: 10px;
    padding: var(--space-xs) var(--space-sm);
  }

  .now-playing-info .channel-name {
    font-size: 1rem;
    margin-bottom: 2px;
  }

  .program-title {
    font-size: 0.8rem;
  }

  .channel-nav {
    display: none;
    /* Hide channel nav in landscape to save space */
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {

  /* Increase touch target sizes */
  .btn,
  .nav-link,
  .channel-item,
  .movie-card,
  .series-card,
  .tab {
    min-height: 44px;
    /* iOS recommended touch target */
  }

  .channel-item {
    padding: var(--space-sm);
  }

  /* Always show favorite buttons on touch devices */
  .favorite-btn {
    opacity: 1 !important;
  }

  /* Remove hover effects */
  .channel-item:hover,
  .movie-card:hover,
  .series-card:hover {
    transform: none;
  }

  /* Show play overlay by default on touch */
  .movie-play-overlay,
  .series-play-overlay {
    opacity: 0.3;
  }
}

/* =====================================================
   Movies Page
   ===================================================== */

.movies-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

.movies-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.movies-controls {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}



/* Favorites Button */
/* Favorites Button Base */
.favorite-btn {
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 5;
  padding: 0;
}

/* Poster Favorites (Movies/Series) */
.movie-poster .favorite-btn,
.series-poster .favorite-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.9);
  opacity: 1;
}

/* Channel List Favorites */
.channel-item .favorite-btn {
  position: relative;
  width: 24px;
  height: 24px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  opacity: 0;
  /* Hide by default in list until hover or active */
  margin-left: var(--space-xs);
}

.channel-item:hover .favorite-btn,
.channel-item .favorite-btn.active {
  opacity: 1;
}

.favorite-btn:hover {
  transform: scale(1.1);
}

.movie-poster .favorite-btn:hover,
.series-poster .favorite-btn:hover {
  background: rgba(0, 0, 0, 0.8);
  color: white;
}

.favorite-btn.active {
  color: #ef4444;
}

.movie-poster .favorite-btn.active,
.series-poster .favorite-btn.active {
  background: rgba(255, 255, 255, 0.9);
}

.movie-poster .favorite-btn.active:hover,
.series-poster .favorite-btn.active:hover {
  background: white;
}

.fav-icon {
  font-size: 1.2rem;
  line-height: 1;
}

/* Filter Button Active State */
.btn-ghost.active {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

.movies-controls .search-input {
  min-width: 150px;
}

.movies-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  padding: var(--space-lg);
  overflow-y: auto;
  height: calc(100vh - 120px);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  justify-content: center;
  align-content: flex-start;
}

.movie-card {
  flex: 0 0 160px;
  width: 160px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.movie-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.movie-poster {
  position: relative;
  width: 160px;
  height: 240px;
  /* 2:3 ratio (160 * 1.5 = 240) */
  background: var(--color-bg-primary);
  overflow: hidden;
}

.movie-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.movie-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.movie-card:hover .movie-play-overlay {
  opacity: 1;
}

.play-icon {
  font-size: 3rem;
  color: white;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.movie-info {
  padding: var(--space-sm);
}

.movie-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movie-meta {
  display: flex;
  gap: var(--space-sm);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.movies-loader {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: var(--space-lg);
}

#page-movies.active {
  display: flex;
  flex-direction: column;
}

#page-movies.movie-detail-open {
  overflow: hidden;
}

#page-movies.movie-detail-open .movies-header,
#page-movies.movie-detail-open #movies-filter-bar,
#page-movies.movie-detail-open #movies-continue,
#page-movies.movie-detail-open #movies-grid {
  display: none;
}

.movie-details {
  --movie-hero-bg: none;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #05070d;
}

.movie-detail-hero {
  position: relative;
  min-height: min(70vh, 680px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(18px, 3vw, 36px) clamp(18px, 5vw, 72px) clamp(30px, 5vw, 64px);
  isolation: isolate;
  overflow: hidden;
}

.movie-detail-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background-image: var(--movie-hero-bg);
  background-size: cover;
  background-position: center;
  opacity: 0.44;
  transform: scale(1.04);
}

.movie-detail-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(5, 7, 13, 0.98) 0%, rgba(5, 7, 13, 0.76) 34%, rgba(5, 7, 13, 0.22) 70%),
    linear-gradient(180deg, rgba(5, 7, 13, 0.16) 0%, rgba(5, 7, 13, 0.92) 100%);
}

.movie-back-btn {
  position: absolute;
  top: clamp(14px, 2vw, 26px);
  left: clamp(14px, 4vw, 42px);
  z-index: 2;
  margin: 0;
  padding: 0 18px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(12, 15, 23, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--color-text-primary);
  font-weight: 800;
  backdrop-filter: blur(14px);
  cursor: pointer;
}

.movie-detail-hero-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(132px, 220px) minmax(0, 780px);
  gap: clamp(18px, 4vw, 40px);
  align-items: end;
  width: min(1120px, 100%);
}

.movie-detail-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: var(--color-bg-secondary);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.42);
}

.movie-detail-info h3 {
  margin: 0 0 var(--space-sm);
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.movie-detail-info p {
  max-width: 760px;
  margin: 0;
  color: rgba(236, 241, 255, 0.86);
  font-size: clamp(0.98rem, 1.3vw, 1.12rem);
  line-height: 1.58;
}

.movie-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--space-sm);
}

.movie-meta-pills span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.11);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(242, 245, 255, 0.92);
  font-size: 0.82rem;
  font-weight: 700;
  backdrop-filter: blur(12px);
}

.movie-detail-progress {
  width: min(420px, 100%);
  height: 4px;
  margin-top: var(--space-md);
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}

.movie-detail-progress > div {
  height: 100%;
  border-radius: inherit;
  background: var(--color-accent);
}

.movie-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.movie-primary-action,
.movie-secondary-action {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.movie-primary-action {
  color: #070911;
  background: #fff;
}

.movie-primary-action:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.9);
}

.movie-primary-action .play-icon svg {
  width: 18px;
  height: 18px;
}

.movie-secondary-action {
  color: var(--color-text-primary);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
}

.movie-secondary-action:hover,
.movie-secondary-action.active {
  background: rgba(98, 135, 255, 0.18);
  border-color: rgba(98, 135, 255, 0.48);
}

.movie-secondary-action .fav-icon svg {
  width: 20px;
  height: 20px;
}

.movie-versions-section {
  width: min(1120px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(22px, 4vw, 44px) 0 clamp(40px, 6vw, 80px);
}

.movie-versions-section.single-version {
  display: none;
}

.movie-versions-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.movie-versions-toolbar h3 {
  margin: 0;
  font-size: clamp(1.4rem, 2vw, 2rem);
}

.movie-versions-toolbar .hint {
  margin: 0;
}

.movie-versions-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-sm);
}

.movie-version-item {
  min-width: 0;
  min-height: 86px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text-primary);
  cursor: pointer;
  text-align: left;
}

.movie-version-item:hover,
.movie-version-item.active {
  border-color: rgba(98, 135, 255, 0.58);
  background: rgba(98, 135, 255, 0.16);
}

.movie-version-main {
  font-weight: 900;
}

.movie-version-sub {
  max-width: 100%;
  color: var(--color-text-secondary);
  font-size: 0.86rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.movie-version-progress {
  margin-top: auto;
  color: var(--color-accent);
  font-size: 0.78rem;
  font-weight: 800;
}

@media (max-width: 720px) {
  .movie-detail-hero {
    min-height: auto;
    padding: 74px 14px 26px;
  }

  .movie-detail-hero::after {
    background:
      linear-gradient(180deg, rgba(5, 7, 13, 0.4) 0%, rgba(5, 7, 13, 0.94) 72%),
      linear-gradient(90deg, rgba(5, 7, 13, 0.96), rgba(5, 7, 13, 0.4));
  }

  .movie-back-btn {
    height: 42px;
    padding: 0 14px;
  }

  .movie-detail-hero-content {
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 14px;
    align-items: end;
  }

  .movie-detail-info h3 {
    font-size: clamp(1.55rem, 8vw, 2.35rem);
  }

  .movie-meta-pills {
    gap: 6px;
  }

  .movie-meta-pills span {
    min-height: 24px;
    padding: 0 8px;
    font-size: 0.72rem;
  }

  .movie-detail-info p {
    display: -webkit-box;
    margin-top: var(--space-xs);
    font-size: 0.92rem;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .movie-detail-actions {
    margin-top: var(--space-md);
  }

  .movie-primary-action,
  .movie-secondary-action {
    flex: 1 1 150px;
    min-height: 46px;
  }

  .movie-versions-section {
    width: calc(100% - 28px);
    padding-top: 18px;
  }

  .movie-versions-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .movie-versions-list {
    grid-template-columns: 1fr;
  }
}

/* =====================================================
   Series Page
   ===================================================== */
#page-series.active {
  display: flex;
  flex-direction: column;
}

.series-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

.series-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.series-controls {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

/* Unified Control Sizing */
.guide-controls .source-select,
.movies-controls .source-select,
.series-controls .source-select {
  min-width: 150px;
}

.guide-controls .search-wrapper,
.movies-controls .search-wrapper,
.series-controls .search-wrapper {
  width: 220px;
}

.series-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.series-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  padding: var(--space-lg);
  overflow-y: auto;
  height: calc(100vh - 120px);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  justify-content: center;
  align-content: flex-start;
}

.series-card {
  flex: 0 0 160px;
  width: 160px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.series-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.series-poster,
.series-card .series-poster {
  position: relative;
  width: 160px;
  height: 240px;
  background: var(--color-bg-primary);
  overflow: hidden;
}

.series-poster img,
.series-card .series-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.series-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.series-card:hover .series-play-overlay {
  opacity: 1;
}

.series-card-info {
  padding: var(--space-sm);
}

.series-title {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.series-meta {
  display: flex;
  gap: var(--space-sm);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.series-loader {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: var(--space-lg);
}

/* Series Details Panel */
.series-details {
  position: absolute;
  inset: 0;
  background: var(--color-bg-primary);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  overflow-y: auto;
  padding: var(--space-lg);
}

.series-details.hidden {
  display: none;
}

.series-back-btn {
  background: var(--color-bg-tertiary);
  border: none;
  color: var(--color-text-primary);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-bottom: var(--space-lg);
  transition: background var(--transition-fast);
}

.series-back-btn:hover {
  background: var(--color-bg-hover);
}

.series-details-header {
  display: flex;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.series-details-header .series-poster {
  flex-shrink: 0;
  width: 200px;
  height: 300px;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.series-details-header .series-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.series-info h3 {
  font-size: 1.5rem;
  margin: 0 0 var(--space-md) 0;
}

.series-info p {
  color: var(--color-text-secondary);
  line-height: 1.6;
  max-height: 200px;
  overflow-y: auto;
}

/* Seasons and Episodes */
.series-seasons {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.season-group {
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.season-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  cursor: pointer;
  background: var(--color-bg-tertiary);
  transition: background var(--transition-fast);
}

.season-header:hover {
  background: var(--color-bg-hover);
}

.season-expander {
  width: 20px;
  text-align: center;
  transition: transform 0.2s;
}

.season-group.collapsed .season-expander {
  transform: rotate(-90deg);
}

.season-name {
  font-weight: 500;
}

.episode-list {
  display: flex;
  flex-direction: column;
}

.season-group.collapsed .episode-list {
  display: none;
}

.episode-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--color-border);
}

.episode-item:last-child {
  border-bottom: none;
}

.episode-item:hover {
  background: var(--color-bg-hover);
}

.episode-number {
  flex-shrink: 0;
  width: 40px;
  font-weight: 500;
  color: var(--color-accent);
}

.episode-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.episode-duration {
  flex-shrink: 0;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Premium Series Detail */
#page-series.series-detail-open {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#page-series.series-detail-open .series-header,
#page-series.series-detail-open #series-filter-bar,
#page-series.series-detail-open #series-continue {
  display: none;
}

#page-series.series-detail-open .series-content {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#page-series.series-detail-open .series-details {
  position: relative;
  inset: auto;
  width: 100%;
  min-height: calc(100vh - var(--navbar-height));
  padding: 0;
  overflow-x: hidden;
  overflow-y: visible;
  background: #05070d;
}

.series-detail-hero {
  --series-hero-bg: none;
  position: relative;
  min-height: min(68vh, 660px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(18px, 3vw, 36px) clamp(18px, 5vw, 72px) clamp(30px, 5vw, 64px);
  isolation: isolate;
  overflow: hidden;
}

.series-detail-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background-image: var(--series-hero-bg);
  background-size: cover;
  background-position: center;
  opacity: 0.42;
  transform: scale(1.04);
}

.series-detail-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(5, 7, 13, 0.98) 0%, rgba(5, 7, 13, 0.76) 34%, rgba(5, 7, 13, 0.22) 70%),
    linear-gradient(180deg, rgba(5, 7, 13, 0.2) 0%, rgba(5, 7, 13, 0.92) 100%);
}

.series-detail-hero .series-back-btn {
  position: absolute;
  top: clamp(14px, 2vw, 26px);
  left: clamp(14px, 4vw, 42px);
  z-index: 2;
  margin: 0;
  padding: 0;
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(12, 15, 23, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--color-text-primary);
  font-size: 1.45rem;
  backdrop-filter: blur(14px);
}

.series-detail-hero-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(132px, 220px) minmax(0, 780px);
  gap: clamp(18px, 4vw, 40px);
  align-items: end;
  width: min(1120px, 100%);
}

.series-detail-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: var(--color-bg-secondary);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.42);
}

.series-detail-hero .series-info h3 {
  margin: 0 0 var(--space-sm);
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.series-detail-hero .series-info p {
  max-width: 760px;
  max-height: none;
  margin: 0;
  overflow: visible;
  color: rgba(236, 241, 255, 0.86);
  font-size: clamp(0.98rem, 1.3vw, 1.12rem);
  line-height: 1.58;
}

.series-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--space-sm);
}

.series-meta-pills span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.11);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(242, 245, 255, 0.92);
  font-size: 0.82rem;
  font-weight: 700;
  backdrop-filter: blur(12px);
}

.series-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.series-primary-action,
.series-secondary-action {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.series-primary-action {
  color: #070911;
  background: #fff;
}

.series-primary-action:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.9);
}

.series-primary-action:disabled {
  cursor: default;
  opacity: 0.55;
  transform: none;
}

.series-primary-action .play-icon svg {
  width: 18px;
  height: 18px;
}

.series-secondary-action {
  color: var(--color-text-primary);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
}

.series-secondary-action:hover,
.series-secondary-action.active {
  background: rgba(98, 135, 255, 0.18);
  border-color: rgba(98, 135, 255, 0.48);
}

.series-secondary-action .fav-icon svg {
  width: 20px;
  height: 20px;
}

.series-episodes-section {
  width: min(1120px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(22px, 4vw, 44px) 0 clamp(40px, 6vw, 80px);
}

.series-episodes-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.series-episodes-toolbar h3 {
  margin: 0;
  font-size: clamp(1.4rem, 2vw, 2rem);
}

#series-season-select {
  width: auto;
  min-width: 160px;
}

.series-details .series-seasons {
  gap: 0;
}

.series-details .season-group {
  background: transparent;
  border-radius: 0;
  overflow: visible;
}

.season-group.hidden-by-select {
  display: none;
}

.series-details .episode-list {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.series-details .episode-item {
  display: grid;
  grid-template-columns: 42px minmax(120px, 190px) minmax(0, 1fr) auto;
  gap: var(--space-md);
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.series-details .episode-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.series-details .episode-number {
  width: auto;
  justify-self: center;
  color: rgba(224, 231, 255, 0.72);
  font-weight: 800;
}

.episode-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 6px;
  background: var(--color-bg-secondary);
}

.episode-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.episode-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.episode-item:hover .episode-play {
  opacity: 1;
}

.episode-play svg {
  width: 26px;
  height: 26px;
}

.episode-copy {
  min-width: 0;
}

.episode-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.series-details .episode-title {
  flex: initial;
  min-width: 0;
  color: var(--color-text-primary);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.episode-description {
  margin: 5px 0 0;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.episode-progress {
  width: min(280px, 100%);
  height: 3px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.episode-progress > div {
  height: 100%;
  border-radius: inherit;
  background: var(--color-accent);
}

.episode-watched {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  color: #07100c;
  background: var(--color-success);
  font-size: 0.78rem;
  font-weight: 900;
}

.episode-watched.inprogress {
  color: var(--color-accent);
  background: rgba(93, 126, 255, 0.18);
}

.series-details .episode-duration {
  justify-self: end;
  color: var(--color-text-secondary);
}

@media (max-width: 720px) {
  .series-detail-hero {
    min-height: auto;
    padding: 74px 14px 26px;
  }

  .series-detail-hero::after {
    background:
      linear-gradient(180deg, rgba(5, 7, 13, 0.4) 0%, rgba(5, 7, 13, 0.94) 72%),
      linear-gradient(90deg, rgba(5, 7, 13, 0.96), rgba(5, 7, 13, 0.4));
  }

  .series-detail-hero .series-back-btn {
    width: 46px;
    height: 46px;
    font-size: 1.25rem;
  }

  .series-detail-hero-content {
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 14px;
    align-items: end;
  }

  .series-detail-hero .series-info h3 {
    font-size: clamp(1.55rem, 8vw, 2.35rem);
  }

  .series-meta-pills {
    gap: 6px;
  }

  .series-meta-pills span {
    min-height: 24px;
    padding: 0 8px;
    font-size: 0.72rem;
  }

  .series-detail-hero .series-info p {
    display: -webkit-box;
    margin-top: var(--space-xs);
    font-size: 0.92rem;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .series-detail-actions {
    margin-top: var(--space-md);
  }

  .series-primary-action,
  .series-secondary-action {
    flex: 1 1 150px;
    min-height: 46px;
  }

  .series-episodes-section {
    width: calc(100% - 28px);
    padding-top: 18px;
  }

  .series-episodes-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  #series-season-select {
    width: 100%;
  }

  .series-details .episode-item {
    grid-template-columns: 28px 92px minmax(0, 1fr);
    gap: 10px;
    padding: 12px 0;
  }

  .episode-description {
    display: none;
  }

  .series-details .episode-duration {
    grid-column: 3;
    justify-self: start;
    font-size: 0.78rem;
  }
}

/* Icons */
.icon {
  width: 1.25em;
  height: 1.25em;
  display: inline-block;
  vertical-align: middle;
  fill: currentColor;
  object-fit: contain;
  flex-shrink: 0;
}

.nav-link .icon {
  width: 1.5em;
  height: 1.5em;
}

.norva-ui-icon {
  filter: drop-shadow(0 0 8px rgba(94, 142, 255, 0.22));
}

.nav-link .norva-ui-icon {
  width: 1.65em;
  height: 1.65em;
  opacity: 0.78;
  transition: opacity var(--transition-fast), filter var(--transition-fast), transform var(--transition-fast);
}

.nav-link:hover .norva-ui-icon,
.nav-link.active .norva-ui-icon {
  opacity: 1;
  filter: drop-shadow(0 0 12px rgba(91, 147, 255, 0.52)) drop-shadow(0 0 18px rgba(203, 91, 255, 0.28));
  transform: translateY(-1px);
}

.btn .norva-ui-icon {
  width: 1.35em;
  height: 1.35em;
}

.favorite-btn .norva-ui-icon {
  width: 1.45em;
  height: 1.45em;
}

.icon.text-warning {
  color: var(--color-warning);
}

/* Animation Utilities */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.spin {
  animation: spin 1s linear infinite;
}

/* User Management Styles */
.user-list-container {
  margin: var(--space-lg) 0;
  overflow-x: auto;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.user-table thead {
  background: var(--color-bg-tertiary);
}

.user-table th {
  padding: var(--space-md);
  text-align: left;
  font-weight: 600;
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border);
}

.user-table td {
  padding: var(--space-md);
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
}

.user-table tbody tr:last-child td {
  border-bottom: none;
}

.user-table tbody tr:hover {
  background: var(--color-bg-hover);
}

.user-table .btn {
  padding: var(--space-xs) var(--space-sm);
  margin: 0 var(--space-xs);
  font-size: 14px;
}

.add-user-section {
  margin-top: var(--space-2xl);
  padding: var(--space-lg);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
}

.user-form {
  display: grid;
  gap: var(--space-md);
  max-width: 500px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  margin-bottom: var(--space-xs);
  color: var(--color-text-primary);
  font-weight: 500;
}

/* =====================================================
   Watch Page (VOD Player)
   ===================================================== */

/* Page Container - scrollable */
.watch-page {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  background: var(--color-bg-primary);
}

.watch-page.active {
  display: block;
}

/* Video Section - full viewport height minus navbar */
.watch-video-section {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--navbar-height));
  /* fallback */
  height: calc(100dvh - var(--navbar-height));
  /* dynamic viewport for modern browsers */
  min-height: 400px;
  background: #000;
}

#watch-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* Player Overlay */
.watch-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(to bottom,
      rgba(0, 0, 0, 0.7) 0%,
      transparent 20%,
      transparent 75%,
      rgba(0, 0, 0, 0.8) 100%);
  opacity: 1;
  transition: opacity 0.3s ease;
  pointer-events: auto;
  z-index: 10;
}

.watch-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* iOS safe area support for landscape mode (notched devices) */
@supports (padding: env(safe-area-inset-left)) {
  .watch-overlay {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
}

/* Top Bar */
.watch-top-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  padding-top: calc(var(--space-lg) + var(--safe-area-inset-top));
  pointer-events: none;
  z-index: 20;
  width: 100%;
  box-sizing: border-box;
}

.watch-top-bar>* {
  pointer-events: auto;
}

/* Live TV Header: Left Title & Right Status */
.watch-top-bar.live-header {
  justify-content: space-between;
}

/* VOD Header: Spaced (Back Btn - Title - Status) */
.watch-top-bar.vod-header {
  justify-content: space-between;
}

.watch-back-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: var(--radius-full);
  color: #fff;
  cursor: pointer;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.watch-back-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.watch-back-btn .icon {
  width: 24px;
  height: 24px;
}

.watch-title-info {
  flex: 1;
  min-width: 0;
}

.watch-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.watch-subtitle {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Center Play Button */
.watch-center-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-full);
  color: #fff;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.watch-center-play:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%) scale(1.1);
}

.watch-center-play.show {
  display: flex;
}

.watch-center-play .icon {
  width: 40px;
  height: 40px;
}

/* Loading Spinner */
.watch-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  z-index: 15;
}

.watch-loading.show {
  display: block;
}

.watch-loading .loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Bottom Bar */
.watch-bottom-bar {
  padding: var(--space-md) var(--space-lg);
  padding-bottom: calc(var(--space-lg) + var(--safe-area-inset-bottom));
}

/* Progress Container */
.watch-progress-container {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.watch-time {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.8);
  min-width: 50px;
  font-variant-numeric: tabular-nums;
}

.watch-time:last-child {
  text-align: right;
}

.watch-progress {
  --progress: 0%;
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(to right,
      var(--color-accent) 0%,
      var(--color-accent) var(--progress),
      rgba(255, 255, 255, 0.3) var(--progress),
      rgba(255, 255, 255, 0.3) 100%);
  border-radius: 3px;
  cursor: pointer;
}

.watch-progress::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: transparent;
}

.watch-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--color-accent);
  border-radius: 50%;
  cursor: pointer;
  margin-top: -5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform var(--transition-fast);
}

.watch-progress:hover::-webkit-slider-thumb {
  transform: scale(1.2);
}

.watch-progress::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.3);
}

.watch-progress::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--color-accent);
}

.watch-progress::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--color-accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.watch-progress-container.duration-unknown .watch-progress,
.watch-progress-container.duration-unknown .watch-time-total {
  display: none;
}

.watch-progress-container.duration-readonly .watch-progress {
  cursor: default;
  opacity: 0.65;
}

.watch-progress-container.duration-readonly .watch-progress::-webkit-slider-thumb {
  cursor: default;
}

.watch-progress-container.duration-readonly .watch-progress::-moz-range-thumb {
  cursor: default;
}

/* Control Buttons */
.watch-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.watch-btn {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.watch-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.watch-btn .icon {
  width: 24px;
  height: 24px;
}

/* Captions Menu */
.watch-captions-wrapper,
.watch-audio-wrapper {
  position: relative;
}

.watch-captions-menu,
.watch-audio-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: var(--space-sm);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  min-width: 180px;
  max-width: 280px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  z-index: 30;
}

.watch-captions-menu.hidden,
.watch-audio-menu.hidden {
  display: none;
}

.captions-menu-title {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--glass-border);
}

.captions-menu-list {
  max-height: 200px;
  overflow-y: auto;
}

.captions-option,
.audio-option {
  display: block;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  color: var(--color-text-primary);
  text-align: left;
  font-size: 0.875rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.captions-option:hover,
.audio-option:hover {
  background: rgba(255, 255, 255, 0.1);
}

.captions-option.active,
.audio-option.active {
  color: var(--color-accent);
}

.captions-option.active::before {
  content: "\2713 ";
}

.audio-option.active::before {
  content: "\2713 ";
}

.captions-empty {
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text-muted);
  font-size: 0.8rem;
  line-height: 1.35;
  border-top: 1px solid var(--glass-border);
}

.captions-offset {
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--glass-border);
}

.captions-offset-label {
  margin-bottom: var(--space-xs);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.captions-offset-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xs);
}

.captions-offset-btn {
  min-height: 32px;
  padding: 0 var(--space-sm);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text-primary);
  font-size: 0.8rem;
  cursor: pointer;
}

.captions-offset-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.watch-btn-lg {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
}

.watch-btn-lg:hover {
  background: rgba(255, 255, 255, 0.2);
}

.watch-btn-lg .icon {
  width: 32px;
  height: 32px;
}

.skip-label {
  position: absolute;
  bottom: 2px;
  font-size: 0.625rem;
  font-weight: 600;
}

.watch-spacer {
  flex: 1;
}

/* Volume Slider */
.watch-volume {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  cursor: pointer;
}

.watch-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
}

/* Scroll Hint */
.watch-scroll-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.75rem;
  animation: bounce 2s infinite ease-in-out;
  pointer-events: none;
}

.watch-scroll-hint .icon {
  width: 20px;
  height: 20px;
}

@keyframes bounce {

  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }

  50% {
    transform: translateX(-50%) translateY(8px);
  }
}

/* Next Episode Panel */
.watch-next-episode {
  position: absolute;
  bottom: 160px;
  right: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: slideInRight 0.3s ease;
  z-index: 50;
  pointer-events: auto;
}

.watch-next-episode.hidden {
  display: none;
}

@keyframes slideInRight {
  from {
    transform: translateX(100px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.next-info {
  min-width: 0;
}

.next-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-xs) 0;
}

.next-info h4 {
  color: #fff;
  margin: 0;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.next-countdown {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-accent);
  min-width: 30px;
  text-align: center;
}

/* ===== Details Section ===== */
.watch-details-section {
  padding: var(--space-xl) var(--space-lg);
  padding-bottom: var(--space-2xl);
  max-width: 1200px;
  margin: 0 auto;
}

.watch-content-info {
  display: flex;
  gap: var(--space-xl);
  margin-bottom: var(--space-2xl);
}

.watch-poster {
  width: 200px;
  height: 300px;
  object-fit: cover;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  background: var(--color-bg-tertiary);
}

.watch-meta {
  flex: 1;
  min-width: 0;
}

.watch-meta h2 {
  font-size: 2rem;
  margin-bottom: var(--space-sm);
  color: var(--color-text-primary);
}

.watch-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
  font-size: 0.875rem;
}

.watch-rating {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--color-warning);
}

.watch-description {
  color: var(--color-text-secondary);
  line-height: 1.7;
  margin-bottom: var(--space-lg);
  max-width: 700px;
}

.watch-actions {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.watch-actions .btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.watch-actions .btn .icon {
  width: 18px;
  height: 18px;
}

.watch-actions .btn .icon-fav-filled {
  color: var(--color-error);
}

/* Recommended Movies Grid */
.watch-recommended h3,
.watch-episodes h3 {
  margin-bottom: var(--space-lg);
  font-size: 1.25rem;
  color: var(--color-text-primary);
}

.watch-recommended-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-md);
}

.watch-recommended-card {
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.watch-recommended-card:hover {
  transform: scale(1.05);
}

.watch-recommended-card img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--color-bg-tertiary);
}

.watch-recommended-card p {
  margin-top: var(--space-xs);
  font-size: 0.813rem;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Series Episodes */
.watch-season-group {
  margin-bottom: var(--space-sm);
}

.watch-season-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}

.watch-season-header:hover {
  background: var(--color-bg-hover);
}

.watch-season-header .icon {
  width: 20px;
  height: 20px;
  color: var(--color-text-muted);
  transition: transform var(--transition-fast);
}

.watch-season-header.collapsed .icon {
  transform: rotate(-90deg);
}

.watch-season-header.collapsed+.watch-episode-list {
  display: none;
}

.watch-season-name {
  flex: 1;
  font-weight: 500;
}

.watch-season-count {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.watch-episode-list {
  padding: var(--space-xs) 0 var(--space-xs) var(--space-lg);
}

.watch-episode-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.watch-episode-item:hover {
  background: var(--color-bg-hover);
}

.watch-episode-item.active {
  background: var(--color-accent-dim);
  border-left: 3px solid var(--color-accent);
}

.watch-episode-num {
  width: 32px;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.watch-episode-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.watch-episode-duration {
  color: var(--color-text-muted);
  font-size: 0.813rem;
  flex-shrink: 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .watch-content-info {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .watch-poster {
    width: 150px;
    height: 225px;
  }

  .watch-meta h2 {
    font-size: 1.5rem;
  }

  .watch-meta-row {
    justify-content: center;
  }

  .watch-description {
    text-align: left;
  }

  .watch-actions {
    justify-content: center;
  }

  .watch-scroll-hint {
    display: none;
  }

  .watch-volume {
    display: none;
  }

  .watch-next-episode {
    left: var(--space-md);
    right: var(--space-md);
    bottom: calc(120px + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
  }

  .next-info {
    flex: 1;
  }

  .next-info h4 {
    max-width: none;
  }

  .watch-bottom-bar {
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
  }
}

/* Player Overflow Menu */
.player-overflow-wrapper {
  position: relative;
}

.player-overflow-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: var(--space-sm);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  min-width: 180px;
  overflow: hidden;
  z-index: 100;
}

.overflow-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: none;
  color: var(--color-text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.overflow-menu-item:hover {
  background: var(--color-bg-hover);
}

.overflow-menu-item .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Hardware Info Grid (Transcoding Tab) */
.hw-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-sm);
}

.hw-info-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
}

.hw-info-item.hw-available {
  border-color: var(--color-success);
  background: rgba(16, 185, 129, 0.1);
}

.hw-info-item.hw-unavailable {
  opacity: 0.6;
}

.hw-badge {
  font-weight: 600;
  font-size: 0.875rem;
}

.hw-info-item.hw-available .hw-badge {
  color: var(--color-success);
}

.hw-info-item.hw-unavailable .hw-badge {
  color: var(--color-text-muted);
}

.hw-name {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Transcode Status Indicator */
.transcode-status {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  display: inline-flex;
  align-items: center;
  backdrop-filter: blur(4px);
  transition: opacity 0.3s ease;
}

.transcode-status.transcoding {
  background: rgba(255, 68, 68, 0.8);
  /* Red for Transcoding */
  box-shadow: 0 0 10px rgba(255, 68, 68, 0.3);
}

.transcode-status.remuxing {
  background: rgba(255, 153, 0, 0.8);
  /* Orange for Remux */
}

.transcode-status.direct {
  background: rgba(76, 175, 80, 0.8);
  /* Green for Direct */
}

.transcode-status.upscaling {
  background: rgba(156, 39, 176, 0.8);
  /* Purple for Upscaling */
  box-shadow: 0 0 10px rgba(156, 39, 176, 0.4);
}

.transcode-status.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Badge Container for right alignment */
.player-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  /* Fallback for cases without flex-grow middle element */
}

/* Quality Badge */
.quality-badge {
  display: inline-block;
  background: rgba(158, 158, 158, 0.8);
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.quality-badge.hidden {
  display: none;
}

/* Watch Header Bar (Title + Transcode Status) */
/* Moved to original definition around line 3311 */

.watch-title-overlay {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

/* =====================================================
   Edit User Modal
   ===================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-overlay .modal {
  display: block;
  position: relative;
  inset: auto;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-overlay .modal-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-overlay .modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
}

.modal-overlay .modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}

.modal-overlay .modal-close:hover {
  color: var(--color-text-primary);
}

.modal-overlay .modal-body {
  padding: var(--space-lg);
}

.modal-overlay .modal-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  background: var(--color-bg-tertiary);
}

/* Modal Form Styles */
.modal-overlay .modal-form-group {
  margin-bottom: var(--space-md);
}

.modal-overlay .modal-form-group label {
  display: block;
  margin-bottom: var(--space-xs);
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

.modal-overlay .modal-form-group .form-input {
  width: 100%;
  padding: var(--space-sm);
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
}

.modal-overlay .modal-form-group .form-input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.modal-overlay .modal-form-group .form-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--color-bg-tertiary);
}

/* =====================================================
   User Management Badges
   ===================================================== */
.user-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 12px;
  white-space: nowrap;
}

.user-badge-sso {
  background: linear-gradient(135deg, #3B82F6 0%, #8b5cf6 100%);
  color: #fff;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.user-badge-local {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.user-badge-admin {
  background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  color: #000;
  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
}

.user-badge-viewer {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* =====================================================
   Now Playing Indicator (Header)
   ===================================================== */

.now-playing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  margin-right: var(--space-md);
  background: linear-gradient(135deg, var(--color-accent) 0%, #8b5cf6 100%);
  border-radius: var(--radius-full);
  color: white;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  animation: now-playing-pulse 2s ease-in-out infinite;
}

.now-playing-indicator:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.5);
}

.now-playing-indicator.hidden {
  display: none;
}

.now-playing-icon {
  font-size: 10px;
}

.now-playing-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes now-playing-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.85;
  }
}

/* Mobile responsive - show in dropdown menu */
@media (max-width: 768px) {
  .now-playing-indicator {
    width: calc(100% - 32px);
    max-width: none;
    margin: 0 16px var(--space-sm) 16px;
    padding: 10px 16px;
    font-size: 13px;
    border-radius: var(--radius-md);
    justify-content: center;
  }
}

/* =====================================================
   Home Dashboard Styles
   ===================================================== */

#page-home {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.dashboard-content {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.dashboard-section {
  margin-bottom: 40px;
}

.dashboard-section.hidden {
  display: none;
}

.home-hero-section {
  position: relative;
  min-height: clamp(320px, 42vw, 520px);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 36px;
  background: #080b12;
  isolation: isolate;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.home-hero-section.hidden {
  display: none;
}

.home-hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: saturate(1.08);
  transform: scale(1.02);
}

.home-hero-section::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(5, 7, 12, 0.96) 0%, rgba(5, 7, 12, 0.72) 42%, rgba(5, 7, 12, 0.14) 100%),
    linear-gradient(0deg, rgba(5, 7, 12, 0.78) 0%, rgba(5, 7, 12, 0.02) 46%);
}

.home-hero-content {
  position: relative;
  z-index: 2;
  width: min(620px, 68%);
  min-height: inherit;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 5vw, 64px);
}

.home-hero-kicker {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--color-accent-hover);
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 12px;
}

.home-hero-content h1 {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(2rem, 4.8vw, 4.6rem);
  line-height: 0.96;
  color: var(--color-text-bright);
  margin-bottom: 18px;
  max-width: 11ch;
}

.home-hero-content p {
  color: var(--color-text-secondary);
  font-size: clamp(0.96rem, 1.3vw, 1.1rem);
  line-height: 1.55;
  max-width: 56ch;
  margin-bottom: 24px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.home-hero-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.home-hero-play,
.home-hero-more {
  min-width: 120px;
  justify-content: center;
}

.home-rail-header {
  margin-bottom: 16px;
}

.home-rail-subtitle {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  color: var(--color-text-bright);
}

/* Scroll Wrapper with Navigation Arrows */
.scroll-wrapper {
  position: relative;
}

.scroll-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  backdrop-filter: blur(8px);
}

.scroll-arrow:hover {
  background: rgba(0, 0, 0, 0.9);
  border-color: var(--color-accent);
  transform: translateY(-50%) scale(1.1);
}

.scroll-arrow svg {
  width: 24px;
  height: 24px;
}

.scroll-arrow.scroll-left {
  left: -8px;
}

.scroll-arrow.scroll-right {
  right: -8px;
}

.scroll-arrow.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Hide arrows on touch devices (they can swipe) */
@media (hover: none) {
  .scroll-arrow {
    display: none;
  }
}

.horizontal-scroll {

  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding-bottom: 12px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar by default, show on hover */
.horizontal-scroll::-webkit-scrollbar {
  height: 6px;
}

.horizontal-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.horizontal-scroll:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

.dashboard-card {
  flex: 0 0 calc(50% - 10px);
  /* 2 per view on small screens */
  max-width: 240px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  scroll-snap-align: start;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* 4 per view on medium screens */
@media (min-width: 768px) {
  .dashboard-card {
    flex: 0 0 calc(25% - 15px);
  }
}

/* 6 per view on large screens */
@media (min-width: 1200px) {
  .dashboard-card {
    flex: 0 0 calc(16.66% - 17px);
  }
}

.dashboard-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-accent-dim);
}

.card-image {
  position: relative;
  aspect-ratio: 2/3;
  overflow: hidden;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.dashboard-card:hover .card-image img {
  transform: scale(1.05);
}

.progress-bar-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(0, 0, 0, 0.5);
}

.progress-bar {
  height: 100%;
  background: var(--color-accent);
  box-shadow: 0 0 10px var(--color-accent);
}

.play-icon-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.play-icon-overlay svg {
  width: 48px;
  height: 48px;
  color: white;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.dashboard-card:hover .play-icon-overlay {
  opacity: 1;
}

.card-info {
  padding: 12px;
}

.card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-card-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: rgba(8, 12, 22, 0.82);
  color: var(--color-text-bright);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.72rem;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

.home-card-language-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  max-width: calc(100% - 20px);
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: rgba(20, 36, 73, 0.82);
  color: #d8e6ff;
  border: 1px solid rgba(95, 130, 255, 0.42);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(10px);
}

.home-card-badge + .home-card-language-badge {
  bottom: 38px;
}

.loading-state,
.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--color-text-muted);
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-lg);
  border: 1px dashed rgba(255, 255, 255, 0.1);
}

/* =====================================================
   Channel Tile Styles (Favorite Channels)
   ===================================================== */

.channel-tiles {
  gap: 16px;
}

.channel-tile {
  flex: 0 0 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 12px 8px;
  border-radius: var(--radius-md);
  transition: transform var(--transition-fast), background var(--transition-fast);
  scroll-snap-align: start;
}

.channel-tile:hover {
  transform: translateY(-4px);
  background: rgba(255, 255, 255, 0.05);
}

.tile-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--color-surface);
  border: 2px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.channel-tile:hover .tile-logo {
  border-color: var(--color-accent);
  box-shadow: 0 0 16px rgba(var(--color-accent-rgb), 0.3);
}

.tile-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-align: center;
  max-width: 90px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-tile:hover .tile-name {
  color: var(--color-text-bright);
}

/* Responsive: smaller tiles on mobile */
@media (max-width: 480px) {
  .channel-tile {
    flex: 0 0 80px;
    padding: 8px 4px;
  }

  .tile-logo {
    width: 52px;
    height: 52px;
  }

  .tile-name {
    font-size: 0.7rem;
    max-width: 70px;
  }
}

/* ============================================================
   Filter bar (Movies / Series)
   ============================================================ */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

.filter-select {
  max-width: 170px;
  font-size: 0.85rem;
}

.filter-toggle {
  white-space: nowrap;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-size: 0.82rem;
  color: var(--color-text-secondary);
}

.filter-toggle.active {
  background: var(--color-accent-dim);
  border-color: var(--color-accent);
  color: var(--color-accent-hover);
}

.playback-filter-toggle.active {
  border-color: var(--color-success);
  color: var(--color-success);
  background: rgba(16, 185, 129, 0.12);
}

.filter-count {
  margin-left: auto;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.filter-reset {
  color: var(--color-warning);
  white-space: nowrap;
}

/* ============================================================
   Multi-select dropdown (categories)
   ============================================================ */

.multi-select {
  position: relative;
}

.multi-select-btn {
  cursor: pointer;
  text-align: left;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select-btn.has-selection {
  border-color: var(--color-accent);
  color: var(--color-accent-hover);
}

.multi-select-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 300;
  width: 300px;
  max-width: 85vw;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  padding: var(--space-sm);
}

.multi-select-search {
  width: 100%;
  margin-bottom: var(--space-xs);
}

.multi-select-actions {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-xs);
}

.multi-select-list {
  max-height: 280px;
  overflow-y: auto;
}

.multi-select-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.multi-select-item:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.multi-select-item input {
  accent-color: var(--color-accent);
  flex-shrink: 0;
}

.multi-select-empty {
  padding: var(--space-sm);
}

/* ============================================================
   Card badges: versions, watched state, progress
   ============================================================ */

.version-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 2;
  background: rgba(10, 10, 15, 0.85);
  border: 1px solid var(--color-accent);
  color: var(--color-accent-hover);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.version-badge:hover {
  background: var(--color-accent);
  color: #fff;
}

.version-language-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  max-width: calc(100% - 16px);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(20, 36, 73, 0.86);
  color: #d8e6ff;
  border: 1px solid rgba(95, 130, 255, 0.42);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(8px);
}

.version-language-badge.with-version-badge {
  bottom: 34px;
}

.watched-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-success);
  color: #fff;
  font-size: 0.75rem;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.watched-badge.inprogress-badge {
  background: var(--color-accent);
  font-size: 0.6rem;
}

.playback-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 7px;
  border-radius: var(--radius-full);
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.card-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  z-index: 2;
}

.card-progress-fill {
  height: 100%;
  background: var(--color-accent);
}

/* ============================================================
   Version picker modal
   ============================================================ */

.version-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  max-height: 50vh;
  overflow-y: auto;
}

.version-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  color: var(--color-text-primary);
}

.version-item:hover {
  border-color: var(--color-accent);
  background: var(--color-bg-hover);
}

.version-item-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-accent-hover);
}

.version-item-name {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  word-break: break-word;
}

/* ============================================================
   Continue Watching row
   ============================================================ */

.continue-row {
  padding: var(--space-md) var(--space-md) 0;
}

.continue-row h3 {
  font-size: 1rem;
  margin-bottom: var(--space-sm);
  color: var(--color-text-secondary);
}

.continue-scroller {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding-bottom: var(--space-sm);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.continue-scroller::-webkit-scrollbar {
  display: none;
}

.continue-card {
  position: relative;
  flex: 0 0 220px;
  display: flex;
  gap: var(--space-sm);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.continue-card:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

.continue-card img {
  width: 60px;
  height: 90px;
  object-fit: cover;
  flex-shrink: 0;
}

.continue-card-info {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: var(--space-sm) var(--space-sm) var(--space-sm) 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.continue-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.continue-card-subtitle {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.continue-card .card-progress {
  position: static;
  margin-top: 4px;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.mobile-filter-button,
.mobile-filter-sheet-header,
.mobile-filter-body,
.mobile-filter-backdrop {
  display: none;
}

/* Episode watched markers in series details */
.episode-watched {
  color: var(--color-success);
  font-size: 0.8rem;
  margin-left: var(--space-xs);
  flex-shrink: 0;
}

.episode-watched.inprogress {
  color: var(--color-accent);
}

/* Responsive: filter bar on small screens */
@media (max-width: 768px) {
  .filter-bar {
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
  }

  .filter-select {
    max-width: 130px;
    font-size: 0.78rem;
  }

  .filter-count {
    width: 100%;
    margin-left: 0;
    order: 99;
  }

  .continue-card {
    flex: 0 0 180px;
  }
}

/* Compact touch controls for dense catalog pages on phones and tablets. */
@media (max-width: 1024px) {

  body.catalog-filter-open {
    overflow: hidden;
  }

  #page-movies .movies-header,
  #page-series .series-header {
    gap: 8px;
    padding: 8px 10px;
  }

  #page-movies .movies-header h2,
  #page-series .series-header h2 {
    line-height: 1.1;
  }

  #page-movies .movies-controls,
  #page-series .series-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px;
    align-items: center;
    gap: 8px;
    width: 100%;
    overflow: visible;
  }

  #page-movies .filter-bar,
  #page-series .filter-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 450;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    max-height: min(82dvh, 680px);
    overflow: hidden;
    padding: 0;
    border: 1px solid var(--color-border-light);
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    background: var(--color-bg-secondary);
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.55);
    transform: translateY(110%);
    visibility: hidden;
    transition: transform 0.22s ease, visibility 0.22s ease;
  }

  #page-movies .filter-bar.mobile-open,
  #page-series .filter-bar.mobile-open {
    transform: translateY(0);
    visibility: visible;
  }

  .mobile-filter-backdrop {
    position: fixed;
    inset: 0;
    z-index: 440;
    display: block;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }

  .mobile-filter-backdrop.mobile-open {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-filter-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--color-border);
  }

  .mobile-filter-sheet-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text-bright);
  }

  .mobile-filter-close {
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 1.25rem;
    justify-content: center;
  }

  .mobile-filter-body {
    display: grid;
    gap: 14px;
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
  }

  .mobile-filter-section {
    display: grid;
    gap: 10px;
    width: 100%;
    min-width: 0;
  }

  .mobile-filter-section-title {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
  }

  .mobile-filter-field {
    display: grid;
    gap: 6px;
    width: 100%;
    min-width: 0;
  }

  .mobile-filter-field.hidden {
    display: none;
  }

  .mobile-filter-label {
    font-size: 0.78rem;
    font-weight: 650;
    color: var(--color-text-secondary);
  }

  .mobile-filter-field .source-select,
  .mobile-filter-field .filter-select,
  .mobile-filter-field select,
  .mobile-filter-field .multi-select,
  .mobile-filter-field .multi-select-btn,
  .mobile-filter-field .btn {
    width: 100%;
    max-width: none;
    justify-content: center;
  }

  #page-movies .movies-controls > *,
  #page-series .series-controls > *,
  #page-movies .filter-bar > *,
  #page-series .filter-bar > * {
    min-width: 0;
  }

  #page-movies .movies-controls .source-select,
  #page-series .series-controls .source-select,
  #page-movies .movies-controls .multi-select-btn,
  #page-series .series-controls .multi-select-btn,
  #page-movies .filter-select,
  #page-series .filter-select {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: 38px;
    font-size: 0.82rem;
  }

  #page-movies .movies-controls .multi-select,
  #page-series .series-controls .multi-select {
    min-width: 0;
  }

  #page-movies .movies-controls .search-wrapper,
  #page-series .series-controls .search-wrapper {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
    min-width: 0;
  }

  #movies-mobile-filters-btn,
  #series-mobile-filters-btn {
    grid-column: 1;
    grid-row: 2;
  }

  #movies-sort,
  #series-sort {
    grid-column: 2;
    grid-row: 2;
  }

  #page-movies .movies-controls .search-input,
  #page-series .series-controls .search-input {
    min-width: 0;
    height: 36px;
    padding-top: 0;
    padding-bottom: 0;
  }

  #page-movies .movies-controls .btn,
  #page-series .series-controls .btn,
  #page-movies .filter-toggle,
  #page-series .filter-toggle,
  #page-movies .filter-reset,
  #page-series .filter-reset {
    min-height: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 6px;
    padding-right: 6px;
    font-size: 0.82rem;
  }

  .mobile-filter-button {
    display: inline-flex;
    position: relative;
    border: 1px solid var(--color-border);
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    border-radius: var(--radius-md);
  }

  .mobile-filter-badge {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    background: var(--color-accent);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
  }

  .mobile-filter-badge.active {
    display: inline-flex;
  }

  #movies-random,
  #series-random {
    grid-column: 3;
    grid-row: 2;
    width: 44px;
    max-width: 44px;
    min-width: 44px;
    flex: 0 0 44px;
    gap: 0;
    padding: 0;
    overflow: hidden;
    color: transparent;
    font-size: 0 !important;
  }

  #movies-random::before,
  #series-random::before {
    content: "\1F3B2";
    color: var(--color-text-primary);
    font-size: 1rem;
    line-height: 1;
  }

  #movies-favorites-btn,
  #series-favorites-btn {
    width: 44px;
    max-width: 44px;
    min-width: 44px;
    flex: 0 0 44px;
    gap: 0;
    padding: 0;
    overflow: hidden;
    color: transparent;
    font-size: 0 !important;
  }

  #movies-favorites-btn .icon,
  #series-favorites-btn .icon {
    width: 22px;
    height: 22px;
    margin: 0;
    flex: 0 0 22px;
    color: var(--color-text-secondary);
  }

  #movies-favorites-btn.active .icon,
  #series-favorites-btn.active .icon {
    color: var(--color-accent);
  }

  #page-movies .filter-count,
  #page-series .filter-count {
    display: none;
  }

  #page-movies .continue-row,
  #page-series .continue-row {
    padding: 8px 10px 0;
  }

  #page-movies .continue-row h3,
  #page-series .continue-row h3 {
    margin-bottom: 6px;
    font-size: 0.92rem;
  }

  #page-movies .continue-card,
  #page-series .continue-card {
    flex-basis: 160px;
  }

  #page-movies .continue-card img,
  #page-series .continue-card img {
    width: 52px;
    height: 78px;
  }

  #page-movies .movies-grid,
  #page-series .series-grid {
    padding: 10px;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  #page-movies .movies-header,
  #page-series .series-header {
    gap: 10px;
    padding: 12px 16px;
  }

  #page-movies .movies-controls,
  #page-series .series-controls {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 52px;
    max-width: 760px;
    margin: 0 auto;
  }

  #movies-random,
  #series-random {
    width: 52px;
    max-width: 52px;
    min-width: 52px;
    flex-basis: 52px;
  }

  #page-movies .filter-bar,
  #page-series .filter-bar {
    left: 24px;
    right: 24px;
    bottom: 16px;
    max-height: min(76dvh, 720px);
    border-bottom: 1px solid var(--color-border-light);
    border-radius: 18px;
  }

  .mobile-filter-body {
    padding: 14px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-filter-section-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

@media (min-width: 900px) and (max-width: 1024px) {
  #page-movies .movies-controls,
  #page-series .series-controls {
    max-width: 880px;
  }

  .mobile-filter-section-body {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .dashboard-content {
    padding: 16px 12px 20px;
  }

  .home-hero-section {
    min-height: 420px;
    margin: -4px -12px 28px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .home-hero-section::before {
    background:
      linear-gradient(0deg, rgba(5, 7, 12, 0.98) 0%, rgba(5, 7, 12, 0.78) 44%, rgba(5, 7, 12, 0.08) 100%),
      linear-gradient(90deg, rgba(5, 7, 12, 0.52) 0%, rgba(5, 7, 12, 0.08) 100%);
  }

  .home-hero-bg {
    background-position: center top;
  }

  .home-hero-content {
    width: 100%;
    justify-content: flex-end;
    padding: 28px 18px;
  }

  .home-hero-content h1 {
    max-width: 13ch;
    font-size: 2.25rem;
  }

  .home-hero-content p {
    -webkit-line-clamp: 2;
    margin-bottom: 18px;
  }

  .home-hero-actions .btn {
    flex: 1 1 0;
  }

  .dashboard-section {
    margin-bottom: 28px;
  }

  .section-header {
    margin-bottom: 12px;
  }

  .section-header h2 {
    font-size: 1.25rem;
  }

  .horizontal-scroll {
    gap: 12px;
    padding-bottom: 8px;
  }

  .dashboard-card {
    flex-basis: calc(50% - 8px);
    max-width: 170px;
  }

  .card-info {
    padding: 10px;
  }
}

/* Playback error banner (shown when all stream versions fail) */
.watch-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  background: rgba(10, 10, 15, 0.85);
  padding: var(--space-lg);
}

.watch-error.hidden {
  display: none;
}

.watch-error-box {
  max-width: 480px;
  text-align: center;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-error);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.watch-error-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-error);
  margin-bottom: var(--space-sm);
}

.watch-error-msg {
  color: var(--color-text-primary);
  font-size: 0.92rem;
  margin-bottom: var(--space-sm);
}

.watch-error-detail {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-family: monospace;
  word-break: break-word;
}

/* ============================================================
   Live TV — flat search results mode
   ============================================================ */

.search-results {
  padding: 4px 8px 8px;
}

.search-results-header {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  padding: 6px 8px 2px;
}

.search-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin: 10px 8px 4px;
}

.channel-item.search-result {
  border-radius: var(--radius-md);
}

.channel-item.search-result .search-subtitle {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result.kb-selected {
  background: var(--color-bg-hover);
  outline: 1px solid var(--color-accent);
  outline-offset: -1px;
}

mark.search-highlight {
  background: transparent;
  color: var(--color-accent-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.search-epg-tag {
  font-size: 0.62rem;
  color: var(--color-accent-hover);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-full);
  padding: 0 6px;
  margin-left: 4px;
  vertical-align: 1px;
}

.search-group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 8px 6px;
}

.search-group-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  cursor: pointer;
  max-width: 100%;
}

.search-group-chip:hover {
  border-color: var(--color-accent);
  color: var(--color-text-primary);
}

.search-group-chip span {
  color: var(--color-text-muted);
  font-size: 0.7rem;
}

.search-kbd-footer {
  display: flex;
  gap: 14px;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  margin-top: 10px;
  padding: 8px 8px 0;
}

.search-empty {
  padding: var(--space-md);
}

.search-empty .search-suggest {
  margin-top: var(--space-xs);
  color: var(--color-accent-hover);
}

/* ============================================================
   Subtitle cue rendering (native <track> over the VOD player)
   ============================================================ */

#watch-video::cue {
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 1.05em;
  line-height: 1.3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  white-space: pre-line;
}

/* ============================================================
   TV mode (Android TV WebView client) — D-pad focus ring
   ============================================================ */

.tv-mode *:focus {
  outline: 3px solid var(--color-accent) !important;
  outline-offset: 2px;
  border-radius: var(--radius-sm);
  scroll-margin: 120px;
}

.tv-mode .movie-card:focus,
.tv-mode .series-card:focus,
.tv-mode .continue-card:focus {
  transform: scale(1.04);
  transition: transform 0.12s ease;
  z-index: 3;
}

/* TV viewports sit far away: slightly larger base text */
.tv-mode body {
  font-size: 17px;
}
