:root {
  --bg-canvas: #080a0f;
  --bg-surface: #111520;
  --bg-surface-2: #171d2c;
  --bg-surface-3: #1e2638;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --accent-glow: rgba(56, 189, 248, 0.18);
  --indigo: #6366f1;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --topbar-h: 64px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter, Roboto, sans-serif;
}

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button svg {
  flex-shrink: 0;
  display: block;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(56, 189, 248, 0.08), transparent 60%),
    radial-gradient(ellipse 60% 45% at 85% 0%, rgba(99, 102, 241, 0.08), transparent 60%),
    var(--bg-canvas);
}

/* Top Navigation */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: rgba(17, 21, 32, 0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-home-btn {
  border: none;
  background: transparent;
  padding: 4px 8px 4px 4px;
  margin-left: -4px;
  border-radius: 11px;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.12s ease;
}

.brand-home-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.brand-home-btn:active {
  transform: scale(0.98);
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--indigo));
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 4px 18px rgba(56, 189, 248, 0.28);
  flex-shrink: 0;
}

.brand-icon svg {
  width: 20px;
  height: 20px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.playlist-pill {
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}

.type-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(8, 10, 15, 0.6);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.type-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.is-active {
  background: var(--bg-surface-3);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.3);
}

.tab-btn .count {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.tab-btn.is-active .count {
  background: var(--accent-glow);
  color: var(--accent);
}

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

.primary-btn,
.ghost-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 9px;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
  white-space: nowrap;
}

.primary-btn {
  border: none;
  background: linear-gradient(135deg, var(--accent-strong), var(--indigo));
  color: #fff;
  box-shadow: 0 2px 12px rgba(14, 165, 233, 0.25);
}

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

.primary-btn:active {
  transform: scale(0.98);
}

.ghost-btn,
.icon-btn {
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text-primary);
}

.ghost-btn:hover,
.icon-btn:hover {
  background: var(--bg-surface-3);
  border-color: var(--border-strong);
}

.primary-btn svg,
.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn.is-spinning svg {
  animation: spin 0.9s linear infinite;
}

.mobile-only {
  display: none;
}

/* --- Ambient 3-Card Home Hub (Limitsiz TV / Smarters Web Style) --- */
.app-shell.is-home-view .type-tabs {
  opacity: 0;
  pointer-events: none;
}

.home-hub {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: 32px 24px 40px;
  background:
    radial-gradient(ellipse 55% 45% at 18% 12%, rgba(29, 78, 216, 0.24), transparent 65%),
    radial-gradient(ellipse 45% 40% at 88% 92%, rgba(30, 64, 175, 0.22), transparent 65%),
    #04060b;
}

.home-hub-inner {
  width: min(1040px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
}

.hub-cards {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
}

.hub-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  min-height: 330px;
  padding: 36px 24px 32px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(13, 18, 30, 0.88) 0%, rgba(10, 14, 24, 0.96) 100%);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.24s ease, box-shadow 0.24s ease;
}

.hub-card-glow {
  position: absolute;
  left: -15%;
  right: -15%;
  bottom: -45%;
  height: 78%;
  border-radius: 50%;
  filter: blur(48px);
  opacity: 0.58;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.hub-card-live .hub-card-glow {
  background: radial-gradient(circle, #1e40af 0%, #1d4ed8 45%, transparent 75%);
}

.hub-card-movie .hub-card-glow {
  background: radial-gradient(circle, #2563eb 0%, #3b82f6 45%, transparent 75%);
}

.hub-card-series .hub-card-glow {
  background: radial-gradient(circle, #b91c1c 0%, #dc2626 45%, transparent 75%);
}

.hub-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.58);
}

.hub-card:hover .hub-card-glow {
  opacity: 0.88;
  transform: scale(1.08);
}

.hub-card-live:hover {
  border-color: rgba(59, 130, 246, 0.45);
}

.hub-card-movie:hover {
  border-color: rgba(56, 189, 248, 0.5);
}

.hub-card-series:hover {
  border-color: rgba(239, 68, 68, 0.48);
}

.hub-icon-circle {
  position: relative;
  z-index: 1;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  transition: transform 0.22s ease, background 0.22s ease;
}

.hub-card:hover .hub-icon-circle {
  transform: scale(1.07);
  background: rgba(255, 255, 255, 0.13);
}

.hub-icon-circle svg {
  width: 30px;
  height: 30px;
}

.hub-card-live .hub-icon-circle svg {
  color: #3b82f6;
}

.hub-card-movie .hub-icon-circle svg {
  color: #60a5fa;
}

.hub-card-series .hub-icon-circle svg {
  color: #ef4444;
}

.hub-card h2 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 1.45rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: #f8fafc;
}

.hub-card p {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 0.86rem;
  color: #94a3b8;
}

.hub-count {
  position: relative;
  z-index: 1;
  margin-top: 2px;
  font-size: 0.74rem;
  font-weight: 600;
  color: rgba(226, 232, 240, 0.72);
  font-variant-numeric: tabular-nums;
}

.hub-accent-line {
  position: relative;
  z-index: 1;
  width: 44px;
  height: 3px;
  border-radius: 999px;
  margin-top: 18px;
  transition: width 0.24s ease;
}

.hub-card:hover .hub-accent-line {
  width: 74px;
}

.hub-card-live .hub-accent-line {
  background: #3b82f6;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.75);
}

.hub-card-movie .hub-accent-line {
  background: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.75);
}

.hub-card-series .hub-accent-line {
  background: #ef4444;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.75);
}

.hub-quick-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.hub-quick-pill {
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(17, 21, 32, 0.72);
  color: #cbd5e1;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.hub-quick-pill:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: var(--accent);
  color: #fff;
}

.hub-continue-wrap {
  width: 100%;
  background: rgba(17, 21, 32, 0.65);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}

.hub-continue-wrap h3 {
  margin: 0 0 10px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.hub-footer {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 4px;
}

@media (max-width: 820px) {
  .hub-cards {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .hub-card {
    min-height: 175px;
    padding: 22px 20px;
  }

  .hub-icon-circle {
    width: 60px;
    height: 60px;
    margin-bottom: 4px;
  }

  .hub-card h2 {
    font-size: 1.25rem;
  }

  .hub-accent-line {
    margin-top: 8px;
  }
}

/* --- Limitsiz TV Theme Accents & 3-Mode Workspace --- */
.app-shell {
  --theme-accent: #2563eb;
  --theme-accent-soft: rgba(37, 99, 235, 0.2);
  --theme-accent-text: #60a5fa;
  --theme-accent-border: rgba(59, 130, 246, 0.55);
}

.app-shell.theme-series {
  --theme-accent: #dc2626;
  --theme-accent-soft: rgba(220, 38, 38, 0.22);
  --theme-accent-text: #f87171;
  --theme-accent-border: rgba(239, 68, 68, 0.55);
}

.tab-ico {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.tab-btn.is-active {
  background: var(--bg-surface-3);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--theme-accent-border);
}

.tab-btn.is-active .tab-ico {
  color: var(--theme-accent-text);
}

.tab-btn.is-active .count {
  background: var(--theme-accent-soft);
  color: var(--theme-accent-text);
}

/* Main Workspace — 3 Modes:
   1. .mode-live       : 235px Cat Rail | Sidebar Channels | 8px Resizer | 1fr Live Player
   2. .mode-catalog    : 235px Cat Rail | 1fr Full-Width 6-7 Col Poster Wall / Series Detail
   3. .mode-vod-player : 1fr Full-Width Cinema Player + Back to Catalog bar */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 235px var(--sidebar-w, 330px) 8px minmax(360px, 1fr);
  transition: grid-template-columns 0.22s ease;
}

.workspace.mode-catalog {
  grid-template-columns: 235px minmax(0, 1fr);
}

.workspace.mode-catalog .split-resizer,
.workspace.mode-catalog .player-column {
  display: none;
}

.workspace.mode-vod-player {
  grid-template-columns: minmax(0, 1fr);
}

.workspace.mode-vod-player .cat-rail,
.workspace.mode-vod-player .catalog-pane,
.workspace.mode-vod-player .split-resizer {
  display: none;
}

.workspace.mode-vod-player .player-column {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.app-shell.is-resizing .workspace {
  transition: none;
}

.app-shell.is-resizing {
  user-select: none;
  cursor: col-resize;
}

.app-shell.is-cinema .workspace.mode-live {
  grid-template-columns: 0px 0px 0px minmax(0, 1fr);
}

.app-shell.is-cinema .cat-rail,
.app-shell.is-cinema .split-resizer,
.app-shell.is-cinema .catalog-pane {
  opacity: 0;
  pointer-events: none;
  border-color: transparent;
  overflow: hidden;
}

/* Left Vertical Category Rail (Limitsiz TV Signature!) */
.cat-rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(9, 12, 20, 0.96);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.cat-rail-top {
  padding: 12px 10px 8px;
  flex-shrink: 0;
}

.cat-rail-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.22) transparent;
}

.cat-rail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.08);
  background: rgba(17, 21, 32, 0.72);
  color: #cbd5e1;
  font-size: 0.79rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.cat-rail-item:hover {
  background: rgba(30, 41, 59, 0.85);
  color: #fff;
  border-color: rgba(148, 163, 184, 0.2);
}

.cat-rail-item.is-active {
  background: var(--theme-accent);
  border-color: var(--theme-accent);
  color: #fff;
  font-weight: 650;
  box-shadow: 0 4px 16px var(--theme-accent-soft);
}

.cat-rail-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-rail-right {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.cat-rail-star {
  border: none;
  background: transparent;
  padding: 2px;
  color: rgba(148, 163, 184, 0.45);
  font-size: 0.78rem;
  cursor: pointer;
  line-height: 1;
}

.cat-rail-star:hover,
.cat-rail-star.is-pinned {
  color: #fbbf24;
}

.cat-rail-item.is-active .cat-rail-star {
  color: rgba(255, 255, 255, 0.75);
}

.cat-rail-item.is-active .cat-rail-star.is-pinned {
  color: #fde047;
}

.cat-rail-count {
  font-size: 0.69rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.28);
  color: rgba(226, 232, 240, 0.82);
  font-variant-numeric: tabular-nums;
}

.cat-rail-item.is-active .cat-rail-count {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.cat-rail-foot {
  padding: 8px 10px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.cat-rail-manage-btn {
  width: 100%;
  font-size: 0.75rem;
  padding: 7px 10px;
}

/* Middle / Full-Width Catalog Pane */
.catalog-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(10, 14, 23, 0.9);
  border-left: none;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.workspace.mode-catalog .catalog-pane {
  border-right: none;
  background: transparent;
}

.catalog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.catalog-head-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.catalog-head-left h2 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.catalog-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--theme-accent-soft);
  color: var(--theme-accent-text);
  border: 1px solid var(--theme-accent-border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.catalog-head-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* VOD Back Bar */
.vod-back-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.vod-back-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.split-resizer {
  position: relative;
  width: 8px;
  cursor: col-resize;
  background: rgba(12, 16, 26, 0.92);
  border-right: 1px solid var(--border);
  touch-action: none;
  user-select: none;
  z-index: 10;
  transition: background 0.15s ease;
}

.split-resizer::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 44px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
  transition: background 0.15s ease, height 0.15s ease;
}

.split-resizer:hover,
.app-shell.is-resizing .split-resizer {
  background: rgba(56, 189, 248, 0.14);
}

.split-resizer:hover::after,
.app-shell.is-resizing .split-resizer::after {
  background: var(--accent);
  height: 64px;
}

/* Player Column */
.player-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 18px 20px;
  gap: 14px;
  overflow-y: auto;
}

.player-card {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.video-stage {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 210px;
  aspect-ratio: 16 / 9;
  max-height: calc(100dvh - 230px);
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.workspace.mode-vod-player .video-stage:not(.has-custom-height):not(:fullscreen) {
  aspect-ratio: auto;
  height: min(54vw, calc(100dvh - 245px));
  min-height: 230px;
}

.video-stage.has-custom-height {
  aspect-ratio: auto;
  height: var(--player-h, 480px);
  max-height: none;
}

.video-stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

.video-stage:fullscreen,
.video-stage:-webkit-full-screen {
  max-height: none !important;
  height: 100vh !important;
  width: 100vw !important;
}

.player-h-resizer {
  position: relative;
  height: 9px;
  width: 100%;
  cursor: row-resize;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  touch-action: none;
  user-select: none;
  transition: background 0.15s ease;
}

.player-h-resizer::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 3px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
  transition: background 0.15s ease, width 0.15s ease;
}

.player-h-resizer:hover,
.app-shell.is-resizing-v .player-h-resizer {
  background: rgba(56, 189, 248, 0.14);
}

.player-h-resizer:hover::after,
.app-shell.is-resizing-v .player-h-resizer::after {
  background: var(--accent);
  width: 72px;
}

.app-shell.is-resizing-v {
  user-select: none;
  cursor: row-resize;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.72), rgba(5, 7, 12, 0.94));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 4;
}

.stage-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

#loadingOverlay.is-visible {
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.45), rgba(5, 7, 12, 0.65));
}

.empty-state,
.loader-box,
.error-box {
  text-align: center;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.empty-icon {
  width: 60px;
  height: 60px;
  color: var(--accent);
  opacity: 0.9;
}

.empty-state h2,
.error-box h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.empty-state p,
.error-box p,
.loader-box p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.45;
}

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

.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.error-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fca5a5;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  font-weight: 800;
}

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

/* Player Info & Controls Bar */
.player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.now-playing {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.np-avatar {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--bg-surface-3);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
  overflow: hidden;
  flex-shrink: 0;
}

.np-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
  background: rgba(255, 255, 255, 0.04);
}

.np-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

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

.np-title-row h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-badge {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
  flex-shrink: 0;
}

.engine-badge {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.32);
  flex-shrink: 0;
}

.np-sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-text {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.player-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.engine-switcher {
  display: inline-flex;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  margin-right: 4px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.seg-btn:hover {
  color: var(--text-primary);
}

.seg-btn.is-active {
  background: var(--bg-surface-3);
  color: var(--accent);
}

.tool-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.tool-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-3);
  border-color: var(--border-strong);
}

.tool-btn.is-active {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.12);
}

.tool-btn.is-active svg {
  fill: #fbbf24;
}

.tool-btn svg {
  width: 17px;
  height: 17px;
}

/* Bottom Panel */
.bottom-panel {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 12px;
}

.recent-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-head h3 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.text-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
}

.text-btn:hover {
  color: var(--text-primary);
}

.recent-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.recent-chip:hover {
  background: var(--bg-surface-3);
  border-color: var(--accent);
}

.recent-chip.is-playing {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.shortcuts-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  font-size: 0.76rem;
  color: var(--text-muted);
  padding: 0 4px;
}

.shortcuts-bar kbd {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-right: 4px;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(17, 21, 32, 0.92);
  border-left: 1px solid var(--border);
  overflow: hidden;
  transition: opacity 0.2s ease;
}

.sidebar-controls {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: 0.86rem;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
}

.category-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-row select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
}

.category-row select:focus {
  border-color: var(--accent);
}

.result-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.channel-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.25) transparent;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  min-height: 60px;
  transition: background 0.14s ease, border-color 0.14s ease;
}

/* Defer rendering only for below-the-fold items */
.channel-item.is-deferred {
  content-visibility: auto;
  contain-intrinsic-size: auto none auto 62px;
}

.channel-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
}

.channel-item.is-playing {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.15), rgba(99, 102, 241, 0.08));
  border-color: rgba(56, 189, 248, 0.45);
}

.ch-logo {
  width: 42px;
  height: 42px;
  border-radius: 9px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
}

.ch-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
}

.ch-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ch-name {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ch-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.73rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ch-type-tag {
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.ch-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.eq-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  margin-right: 4px;
}

.eq-bars span {
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  animation: eq 0.9s ease-in-out infinite alternate;
}

.eq-bars span:nth-child(2) {
  animation-delay: 0.25s;
}

.eq-bars span:nth-child(3) {
  animation-delay: 0.5s;
}

.fav-star-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.14s ease, background 0.14s ease;
}

.fav-star-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fbbf24;
}

.fav-star-btn.is-fav {
  color: #fbbf24;
}

.fav-star-btn.is-fav svg {
  fill: #fbbf24;
}

.fav-star-btn svg {
  width: 15px;
  height: 15px;
}

.list-status {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.load-more-sentinel {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* Native Modal Dialog */
dialog {
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  color: var(--text-primary);
  width: min(580px, calc(100vw - 28px));
  max-height: calc(100dvh - 40px);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.7);
}

dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(4, 6, 10, 0.75);
  backdrop-filter: blur(6px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.dialog-inner {
  padding: 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.dialog-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.dialog-sub {
  margin: 4px 0 0;
  font-size: 0.83rem;
  color: var(--text-secondary);
}

.icon-only-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.icon-only-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-3);
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-group input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: 0.86rem;
  outline: none;
}

.field-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.83rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-row code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-surface-3);
  color: var(--accent);
  font-size: 0.78rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.saved-playlists-wrap h3 {
  margin: 0 0 10px;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.saved-playlists {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.saved-item.is-active {
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(56, 189, 248, 0.08);
}

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

.saved-name {
  font-size: 0.88rem;
  font-weight: 600;
}

.saved-url {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.mini-btn {
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-surface-3);
  color: var(--text-primary);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.mini-btn:hover {
  border-color: var(--accent);
}

.mini-btn.danger:hover {
  border-color: var(--danger);
  color: #fca5a5;
}

.security-note {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.security-note code {
  color: var(--text-secondary);
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(23, 29, 44, 0.96);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 0.84rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  animation: fadeUp 0.2s ease;
}

.toast.is-error {
  border-color: rgba(239, 68, 68, 0.5);
  color: #fecaca;
}

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

@keyframes eq {
  0% {
    height: 4px;
  }
  100% {
    height: 14px;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Unified Custom Player Controls (Single Seek Bar, Auto-hide, Fullscreen-ready) --- */
.custom-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  padding: 28px 16px 12px;
  background: linear-gradient(to top, rgba(5, 7, 12, 0.92) 0%, rgba(5, 7, 12, 0.55) 60%, transparent 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.video-stage.controls-visible .custom-controls,
.video-stage:hover .custom-controls,
.custom-controls:focus-within {
  opacity: 1;
  pointer-events: auto;
}

.video-stage.is-idle-playing {
  cursor: none;
}

.video-stage.is-idle-playing .custom-controls {
  opacity: 0;
  pointer-events: none;
}

.cc-seek-row {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 22px;
}

.vod-seek-range {
  position: relative;
  z-index: 2;
  width: 100%;
  accent-color: var(--accent);
  height: 18px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

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

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

.cc-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.14s ease, transform 0.1s ease;
}

.cc-icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.cc-icon-btn svg {
  width: 18px;
  height: 18px;
}

.cc-step-btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.cc-step-btn:hover {
  background: rgba(56, 189, 248, 0.25);
  border-color: var(--accent);
}

.cc-volume {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cc-vol-range {
  width: 74px;
  accent-color: var(--accent);
  height: 4px;
  cursor: pointer;
}

.cc-time-display {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #e2e8f0;
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}

.cc-time-sep {
  color: var(--text-muted);
}

.cc-live-dot {
  color: #f87171;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

video::cue {
  background: var(--sub-bg, rgba(8, 10, 15, 0.82));
  color: var(--sub-color, #f8fafc);
  font-family: var(--font-sans);
  font-size: var(--sub-size, 1.08rem);
  line-height: 1.38;
}

/* Custom Subtitle Overlay (accurate height in normal & fullscreen + auto-lifts above control bar) */
.subtitle-overlay {
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: var(--sub-bottom, 10%);
  z-index: 12;
  display: flex;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  transition: bottom 0.18s ease;
}

.video-stage.controls-visible .subtitle-overlay {
  bottom: max(var(--sub-bottom, 10%), 94px);
}

.subtitle-cue {
  display: inline-block;
  max-width: 88%;
  padding: 6px 14px;
  border-radius: 8px;
  background: var(--sub-bg, rgba(8, 10, 15, 0.82));
  color: var(--sub-color, #f8fafc);
  font-family: var(--font-sans);
  font-size: var(--sub-size, 1.08rem);
  font-weight: 600;
  line-height: 1.42;
  white-space: pre-line;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.92), 0 0 2px rgba(0, 0, 0, 0.95);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.video-stage.is-fullscreen .subtitle-cue,
.video-stage:fullscreen .subtitle-cue,
.video-stage:-webkit-full-screen .subtitle-cue {
  font-size: calc(var(--sub-size, 1.08rem) * 1.5);
  padding: 8px 18px;
  border-radius: 10px;
}

.video-stage.is-fullscreen.controls-visible .subtitle-overlay,
.video-stage:fullscreen.controls-visible .subtitle-overlay,
.video-stage:-webkit-full-screen.controls-visible .subtitle-overlay {
  bottom: max(var(--sub-bottom, 10%), 110px);
}

.sub-pos-range {
  width: 100%;
  margin-top: 8px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* --- Feature 1: Translucent In-Player Fullscreen Overlay Drawer --- */
.fs-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(340px, 86%);
  z-index: 6;
  background: rgba(11, 15, 25, 0.9);
  backdrop-filter: blur(18px);
  border-left: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.65);
}

.fs-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.fs-drawer-tabs {
  display: flex;
  gap: 4px;
}

.fs-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 7px;
  cursor: pointer;
}

.fs-tab.is-active {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.4);
}

.fs-drawer-body,
.fs-drawer-settings {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fs-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  text-align: left;
  font-size: 0.8rem;
  cursor: pointer;
}

.fs-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.fs-item.is-playing {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}

.fs-set-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.fs-set-group:last-child {
  border-bottom: none;
}

.fs-set-group > label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.fs-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fs-pill {
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 7px;
  cursor: pointer;
}

.fs-pill.is-active {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.5);
}

/* --- Feature 2: Full-Width Netflix Poster Wall (6-7 Columns on Widescreen!) --- */
.channel-list.is-poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  grid-auto-rows: 275px;
  gap: 14px;
  align-content: start;
  padding: 16px;
}

.poster-year-pill {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(8, 10, 15, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f1f5f9;
  font-size: 0.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.channel-list.is-poster-grid .channel-item:hover {
  border-color: var(--theme-accent);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  transform: translateY(-3px);
}

.workspace.mode-catalog .series-poster {
  width: 96px;
  height: 138px;
}

.workspace.mode-catalog .episode-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  align-content: start;
  gap: 8px;
  padding: 14px;
}

.channel-list.is-poster-grid .load-more-sentinel,
.channel-list.is-poster-grid .list-status {
  grid-column: 1 / -1;
  align-self: center;
}

.channel-list.is-poster-grid .channel-item {
  position: relative;
  display: block;
  padding: 0;
  width: 100%;
  height: 100%;
  min-height: 230px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
}

.channel-list.is-poster-grid .channel-item.is-deferred {
  content-visibility: visible;
  contain-intrinsic-size: auto;
}

.channel-list.is-poster-grid .channel-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.channel-list.is-poster-grid .ch-logo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  font-size: 1.35rem;
}

.channel-list.is-poster-grid .ch-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  padding: 0;
  display: block;
}

.channel-list.is-poster-grid .ch-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 32px 9px 9px;
  background: linear-gradient(to top, rgba(5, 7, 12, 0.96) 0%, rgba(5, 7, 12, 0.72) 65%, transparent 100%);
  gap: 2px;
}

.channel-list.is-poster-grid .ch-name {
  font-size: 0.8rem;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.channel-list.is-poster-grid .ch-meta {
  font-size: 0.69rem;
  color: #cbd5e1;
}

.channel-list.is-poster-grid .ch-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
}

.channel-list.is-poster-grid .fav-star-btn {
  background: rgba(8, 10, 15, 0.68);
  backdrop-filter: blur(6px);
}

.channel-list.is-poster-grid .series-chevron {
  display: none;
}

/* --- Feature 5: VOD & Series Metadata Strip --- */
.vod-meta-bar {
  padding: 11px 16px;
  background: rgba(8, 10, 15, 0.55);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vod-meta-top,
.series-meta-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.meta-rating {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(251, 191, 36, 0.16);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.meta-chip {
  font-size: 0.73rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.meta-source {
  margin-left: auto;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.vod-meta-overview,
.series-meta-overview {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

/* --- Feature 4: Profiles & PIN Dialog --- */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 8px;
}

.profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  cursor: pointer;
}

.profile-card.is-active {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.profile-card-name {
  font-size: 0.86rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-form input {
  flex: 1;
  min-width: 150px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: 0.85rem;
}

.pin-section {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.pin-section h3 {
  margin: 0 0 4px;
  font-size: 0.92rem;
}

.pin-masked-input {
  -webkit-text-security: disc;
}

.cat-toggle-btn.is-locked {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.45);
}

/* --- Feature 7: Smart TV / Remote Control Mode --- */
.app-shell.is-tv-mode {
  font-size: 112%;
}

.app-shell.is-tv-mode .workspace.mode-live {
  grid-template-columns: 270px var(--sidebar-w, 400px) 8px minmax(360px, 1fr);
}

.app-shell.is-tv-mode .workspace.mode-catalog {
  grid-template-columns: 270px minmax(0, 1fr);
}

.app-shell.is-tv-mode .channel-item {
  min-height: 74px;
  padding: 11px 13px;
}

.app-shell.is-tv-mode .ch-name {
  font-size: 1rem;
}

.app-shell.is-tv-mode .tab-btn {
  padding: 8px 16px;
  font-size: 0.96rem;
}

.app-shell.is-tv-mode button:focus-visible,
.app-shell.is-tv-mode .channel-item:focus-visible,
.app-shell.is-tv-mode .continue-card:focus-visible,
.app-shell.is-tv-mode select:focus-visible,
.app-shell.is-tv-mode input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(56, 189, 248, 0.25);
}

.icon-btn.is-tv-on {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
}

.track-select {
  height: 34px;
  max-width: 150px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  font-size: 0.76rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.track-select:focus {
  border-color: var(--accent);
}

.mini-action-btn {
  height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.42);
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s ease, filter 0.14s ease;
}

.mini-action-btn:hover {
  background: rgba(56, 189, 248, 0.28);
}

/* Live EPG Bar */
.epg-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 16px;
  background: rgba(8, 10, 15, 0.55);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.epg-now-block {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.epg-top-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  flex-wrap: wrap;
}

.epg-tag {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(34, 197, 94, 0.16);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.epg-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.epg-progress-track {
  height: 4px;
  width: 100%;
  max-width: 420px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  overflow: hidden;
}

.epg-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--indigo));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.epg-desc {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.epg-next-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 11px;
  border-radius: 8px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  max-width: 280px;
}

.epg-next-label {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.epg-next-title {
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Continue Watching Strip */
.continue-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.continue-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 210px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  cursor: pointer;
  flex-shrink: 0;
  text-align: left;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.continue-card:hover {
  border-color: var(--accent);
  background: var(--bg-surface-3);
}

.continue-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 18px;
}

.continue-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.continue-progress {
  height: 3px;
  width: 100%;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.continue-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.continue-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.continue-remove:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

/* Channel Item EPG Subtitle & Progress Bar */
.ch-epg-line {
  font-size: 0.71rem;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.92;
}

.ch-progress-mini {
  height: 3px;
  width: 100%;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  margin-top: 3px;
  overflow: hidden;
}

.ch-progress-mini span {
  display: block;
  height: 100%;
  background: var(--accent);
}

/* Pinned Category Quick Chips */
.cat-manage-btn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.pinned-cats {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.pinned-cats::-webkit-scrollbar {
  display: none;
}

.pin-chip {
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-size: 0.73rem;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.pin-chip:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.pin-chip.is-active {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.5);
}

/* Category Manager Modal */
.cat-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-manage-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 50dvh;
  overflow-y: auto;
  padding-right: 4px;
}

.cat-manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
}

.cat-manage-row.is-hidden {
  opacity: 0.55;
}

.cat-manage-name {
  min-width: 0;
  flex: 1;
  font-size: 0.83rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-manage-count {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-left: 6px;
}

.cat-manage-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.cat-toggle-btn {
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-surface-3);
  color: var(--text-secondary);
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
}

.cat-toggle-btn.is-pinned {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.5);
}

.cat-toggle-btn.is-hidden {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

/* Series Detail View (Seasons & Episodes) */
.series-detail-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.series-detail-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.back-series-btn {
  align-self: flex-start;
  padding: 5px 10px;
  font-size: 0.78rem;
}

.series-hero {
  display: flex;
  align-items: center;
  gap: 11px;
}

.series-poster {
  width: 48px;
  height: 64px;
  border-radius: 8px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--accent);
  overflow: hidden;
  flex-shrink: 0;
}

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

.series-hero-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.series-hero-meta h3 {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.25;
}

.series-hero-meta span {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.season-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.season-tabs::-webkit-scrollbar {
  display: none;
}

.season-pill {
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.season-pill.is-active {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.5);
}

.episode-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ep-badge {
  min-width: 38px;
  height: 32px;
  border-radius: 7px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.series-chevron {
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0 4px;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .topbar {
    position: sticky;
    top: 0;
    padding: 0 12px;
    gap: 10px;
  }

  .brand-text h1 {
    font-size: 0.95rem;
  }

  .playlist-pill {
    display: none;
  }

  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: inline-flex;
  }

  .workspace,
  .workspace.mode-live,
  .workspace.mode-catalog,
  .workspace.mode-vod-player {
    display: flex;
    flex-direction: column;
    overflow: visible;
    flex: none;
  }

  .split-resizer {
    display: none;
  }

  .cat-rail {
    order: 2;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 220px;
  }

  .cat-rail-list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 10px 8px;
  }

  .cat-rail-item {
    width: auto;
    flex-shrink: 0;
    padding: 7px 10px;
  }

  .cat-rail-foot {
    display: none;
  }

  .player-column {
    order: 1;
    display: flex;
    flex-direction: column;
    padding: 10px;
  }

  .catalog-pane {
    order: 3;
    margin: 8px 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    min-height: 55dvh;
    max-height: 75dvh;
    overflow: hidden;
  }

  .workspace.mode-catalog .catalog-pane {
    max-height: none;
    min-height: 65dvh;
    margin: 8px 10px 24px;
    border: none;
  }

  .channel-list.is-poster-grid {
    grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
    grid-auto-rows: 210px;
    gap: 10px;
    padding: 10px;
  }

  .bottom-panel {
    padding: 0 0 18px;
  }

  .video-stage {
    max-height: 38dvh;
  }

  .shortcuts-bar {
    display: none;
  }

  .app-shell.is-mobile-sidebar-hidden .cat-rail {
    display: none;
  }
}

@media (max-width: 768px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
    gap: 8px;
  }

  .brand {
    order: 1;
    flex: 1;
    min-width: 0;
  }

  .topbar-actions {
    order: 2;
    gap: 6px;
  }

  .topbar-actions .icon-btn,
  .topbar-actions .primary-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 9px;
    flex-shrink: 0;
  }

  .topbar-actions .icon-btn span,
  .topbar-actions .primary-btn span {
    display: none;
  }

  .topbar-actions .icon-btn svg,
  .topbar-actions .primary-btn svg {
    width: 18px;
    height: 18px;
  }

  .type-tabs {
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }

  .app-shell.is-home-view .type-tabs,
  .app-shell.is-home-view #toggleSidebarMobileBtn,
  #tvModeBtn {
    display: none !important;
  }

  .home-hub {
    place-items: start center;
    padding: 14px 14px 28px;
  }

  .home-hub-inner {
    gap: 16px;
  }

  .hub-cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .hub-card {
    min-height: 138px;
    padding: 18px 16px 16px;
    border-radius: 16px;
    gap: 6px;
  }

  .hub-icon-ring {
    width: 48px;
    height: 48px;
    margin-bottom: 2px;
  }

  .hub-icon-ring svg {
    width: 24px;
    height: 24px;
  }

  .hub-card h2 {
    font-size: 1.15rem;
  }

  .hub-card p {
    font-size: 0.8rem;
  }

  .track-select {
    max-width: 132px;
    font-size: 0.74rem;
  }

  .tab-btn {
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  .player-bar {
    padding: 10px 12px;
    gap: 10px;
  }

  .player-tools {
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
  }

  .tool-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
  }

  .tool-btn svg {
    width: 18px;
    height: 18px;
  }

  .cc-vol-range {
    display: none;
  }

  .custom-controls {
    padding: 16px 10px 8px;
    gap: 5px;
  }

  .cc-btn-row {
    gap: 4px;
  }

  .cc-left,
  .cc-right {
    gap: 4px;
  }

  .cc-icon-btn {
    width: 30px;
    height: 30px;
  }

  .cc-icon-btn svg {
    width: 16px;
    height: 16px;
  }

  .cc-step-btn {
    height: 28px;
    padding: 0 7px;
    font-size: 0.72rem;
  }

  .cc-time-display {
    font-size: 0.72rem;
    white-space: nowrap;
  }

  #ccAspectBtn,
  #ccSleepBtn {
    display: none;
  }
}


/* ============================================================
   Cinema Upgrade Pack: OSD, Seek Preview, Next-Ep Countdown,
   Sort/Watchlist/Watched Badges, External Player & Dual Mode
   ============================================================ */

/* Animated Center OSD Flash */
.osd-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.84);
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 16px;
  background: rgba(6, 10, 18, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f8fafc;
  font-size: 1.05rem;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.osd-flash.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.osd-icon {
  font-size: 1.25rem;
  line-height: 1;
}

/* Seek Bar Hover Time Preview Tooltip + Buffered Fill */
.cc-seek-row {
  position: relative;
}

.seek-tooltip {
  position: absolute;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(6, 10, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f8fafc;
  font-size: 0.74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
}

.seek-buffered-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  z-index: 1;
  transform: translateY(-50%);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  pointer-events: none;
  overflow: hidden;
}

.seek-buffered-fill {
  height: 100%;
  width: 0%;
  background: rgba(255, 255, 255, 0.36);
  transition: width 0.25s linear;
}

/* Netflix Auto Next Episode Countdown Card */
.next-ep-overlay {
  position: absolute;
  right: 20px;
  bottom: 92px;
  z-index: 26;
  width: min(320px, calc(100% - 32px));
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(9, 13, 24, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(56, 189, 248, 0.38);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.next-ep-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #38bdf8;
  text-transform: uppercase;
}

.next-ep-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f8fafc;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.next-ep-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.next-ep-now-btn {
  flex: 1;
  padding: 7px 12px;
  font-size: 0.8rem;
}

/* Catalog Sort Select */
.catalog-sort-select {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  font-size: 0.76rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.catalog-sort-select:focus {
  border-color: var(--accent);
}

/* Watched Checkmark & Watchlist Badges */
.watched-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 4;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(22, 163, 74, 0.92);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.channel-item:not(.is-poster-card) .watched-badge {
  position: static;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 0.66rem;
}

.ep-watched-tag {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
  font-size: 0.66rem;
  font-weight: 700;
}

.tool-btn.is-active-tool {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
}

.tool-btn.is-watched-on {
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
}

/* External Player Modal */
.modal-sm {
  width: min(420px, calc(100vw - 28px));
}

.ext-player-grid {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.ext-link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  padding: 11px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 10px;
}

/* Dual-Screen Live TV Match Mode */
.stages-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  flex-shrink: 0;
  width: 100%;
  min-width: 0;
  background: #000;
}

.stages-grid.is-dual {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 3px;
}

.dual-stage {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 16 / 9;
  max-height: calc(100dvh - 210px);
  background: #04070e;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.stages-grid.is-dual .video-stage.is-audio-focus,
.stages-grid.is-dual .dual-stage.is-audio-focus {
  box-shadow: inset 0 0 0 2px #38bdf8;
}

.dual-stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.dual-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.82) 0%, transparent 100%);
}

.dual-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dual-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.dual-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.84rem;
  pointer-events: none;
}

@media (max-width: 1024px) {
  .stages-grid.is-dual {
    grid-template-columns: 1fr;
  }
}


/* ============================================================
   Frankfurt Power Pack: Global Search, TV Guide, DVR,
   Quality Selector, YouTube Trailer & Similar Strip
   ============================================================ */

.modal-lg {
  width: min(760px, calc(100vw - 24px));
  max-height: 86dvh;
}

.global-search-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: 0.94rem;
  outline: none;
  margin-bottom: 12px;
}

.global-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}

.global-search-results {
  max-height: 58dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.gs-group-title {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 6px;
}

.gs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}

.gs-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.gs-item:hover {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
}

.gs-thumb {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  background: var(--bg-canvas);
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.gs-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.gs-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gs-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Evening TV Guide (EPG Timeline) */
.epg-guide-list {
  max-height: 60dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.epg-guide-row {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.epg-guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.epg-guide-ch {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.epg-guide-ch strong {
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.epg-guide-now {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.22);
}

.epg-guide-upcoming {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.epg-up-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-canvas);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.epg-remind-btn {
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
}

.epg-remind-btn.is-set {
  background: #fbbf24;
  color: #0b0f19;
}

/* DVR Recording Button & Modal */
.dvr-rec-btn {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}

.dvr-rec-btn.is-recording {
  background: #dc2626;
  color: #fff;
  border-color: #ef4444;
  animation: pulseRec 1.3s ease-in-out infinite;
}

@keyframes pulseRec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.dvr-active-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: rgba(220, 38, 38, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fecaca;
  font-size: 0.84rem;
  font-weight: 600;
}

.dvr-list {
  max-height: 56dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

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

.dvr-row-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.dvr-row-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.dvr-row-actions {
  display: flex;
  gap: 6px;
}

/* Official YouTube Trailer Modal */
.trailer-frame-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  display: grid;
  place-items: center;
}

.trailer-frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Similar Movies / Series Poster Strip */
.similar-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.similar-card {
  width: 122px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  text-align: left;
  transition: transform 0.16s ease;
}

.similar-card:hover {
  transform: translateY(-3px);
}

.similar-poster {
  width: 122px;
  height: 176px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--text-muted);
}

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

.similar-title {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
