/* ====================================================
   TV / Webcam – style.css
   Dark glassmorphism theme matching RadioWave
   ==================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-dark: #0a0b0f;
  --bg-card: rgba(18, 20, 30, 0.85);
  --bg-card-hover: rgba(25, 28, 42, 0.9);
  --accent: #4f8cff;
  --accent-2: #9f6fff;
  --accent-glow: rgba(79, 140, 255, 0.25);
  --text-primary: #e8eaf0;
  --text-secondary: #8892a4;
  --border: rgba(255, 255, 255, 0.07);
  --danger: #ef4444;
  --success: #10b981;
  --sidebar-w: 280px;
  --nav-h: 52px;
  
  /* --- THE PRISM: HOLOGRAPHIC TOKENS (Phase 134) --- */
  --holo-gradient: linear-gradient(135deg, rgba(79, 140, 255, 0.1), rgba(159, 111, 255, 0.1));
  --holo-glow: 0 0 30px rgba(79, 140, 255, 0.3);
  --glass-refraction: blur(25px) saturate(1.8) contrast(1.1);
}

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

html,
body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
}

.hidden { display: none !important; }

/* ── Layout ──────────────────────────────────────── */
#app {
  display: grid;
  grid-template-rows: var(--nav-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

/* ── Top Nav ─────────────────────────────────────── */
#top-nav {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  background: rgba(10, 11, 18, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  z-index: 100;
}

#top-nav .app-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-right: 12px;
  text-transform: uppercase;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}

.nav-tab:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-tab.active {
  background: var(--accent);
  color: #fff;
}

/* ── Sidebar ─────────────────────────────────────── */
#sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header button {
  width: 26px;
  height: 26px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .2s;
}

.sidebar-header button:hover {
  opacity: .8;
}

/* Search unified below in container block */

#channel-search:focus {
  border-color: var(--accent);
}

.channel-category {
  padding: 8px 14px 2px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent-2);
}

#channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  position: relative; /* Base for virtualization */
}

/* Virtual List Components */
.v-list-spacer {
    pointer-events: none;
    width: 100%;
}

.v-list-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    will-change: transform;
}

#channel-list::-webkit-scrollbar {
  width: 4px;
}

#channel-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .15s;
  border-left: 3px solid transparent;
}

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

.channel-item.active {
  background: var(--bg-card-hover);
  border-left-color: var(--accent);
}

.channel-logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px;
  flex-shrink: 0;
}

.channel-logo-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

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

.channel-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-cat {
  font-size: 11px;
  color: var(--text-secondary);
}

.source-badge {
  font-size: 8px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 6px;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.1);
  vertical-align: middle;
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.status-dot.online {
  background: #00ff88;
  box-shadow: 0 0 5px #00ff88;
}

.status-dot.offline {
  background: #ff4444;
  box-shadow: 0 0 5px #ff4444;
}

.channel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto; /* Push to right */
}

.fav-btn {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  filter: grayscale(1) opacity(0.5);
  transition: all 0.2s;
}

.fav-btn:hover {
  transform: scale(1.2);
  filter: grayscale(0) opacity(1);
}

.fav-btn.active {
  filter: grayscale(0) opacity(1);
  color: gold;
}

.edit-btn {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  filter: grayscale(1) opacity(0.5);
  transition: all 0.2s;
}

.edit-btn:hover {
  transform: scale(1.2);
  filter: grayscale(0) opacity(1);
  color: #4f8cff;
}

.fav-section .continent-header {
  background: rgba(255, 215, 0, 0.05) !important;
  color: #ffd700 !important;
}

/* 3-Level Hierarchy */
.continent-group {
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.continent-header {
  font-size: 14px;
  font-weight: 900;
  color: var(--accent);
  padding: 15px 15px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(79, 140, 255, 0.05);
  cursor: pointer;
  transition: all 0.3s;
  user-select: none;
}

.continent-header:hover {
  background: rgba(79, 140, 255, 0.1);
}

.continent-header .toggle-icon {
  transition: transform 0.3s;
  color: var(--accent);
}

.continent-group.active .continent-header {
  background: var(--accent);
  color: white;
}

.continent-group.active .continent-header .toggle-icon {
  color: white;
}

.continent-content {
  display: none;
  background: rgba(0, 0, 0, 0.1);
}

.continent-group.active .continent-content {
  display: block;
}

.country-group {
  border-bottom: 1px solid var(--border);
}

.country-header {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  padding: 8px 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.01);
  cursor: pointer;
  transition: background 0.2s;
  user-select: none;
}

.country-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.country-header .name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.country-header .name-wrap::before {
  content: '📍';
  font-size: 12px;
  opacity: 0.5;
}

.country-header .toggle-icon {
  font-size: 12px;
  transition: transform 0.3s;
}

.country-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(0, 0, 0, 0.2);
}

.country-group.active .country-content {
  max-height: 5000px;
  padding-bottom: 5px;
}

.country-group.active .country-header .toggle-icon {
  transform: rotate(45deg);
}

.channel-category {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  padding: 10px 15px 5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.6;
}

.stream-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  background: #333;
  transition: all 0.3s;
}

.stream-status.online {
  background: #00ff85;
  box-shadow: 0 0 8px rgba(0, 255, 133, 0.5);
}

.stream-status.offline {
  background: #ff4d4d;
  box-shadow: 0 0 8px rgba(255, 77, 77, 0.5);
}

/* Program info */
.channel-program {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
}

.channel-program .now {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

.channel-program .next {
  font-size: 10px;
  color: var(--text-secondary);
  opacity: 0.7;
}

#channel-list.grid-view .channel-program {
  margin-top: 6px;
}

/* TV Dashboard */
#tv-dashboard {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-dark);
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 40px;
  overflow-y: auto;
  transition: opacity 0.5s;
}

#tv-dashboard.hidden {
  opacity: 0;
  pointer-events: none;
}

.dashboard-header {
  margin-bottom: 30px;
  text-align: center;
}

.dashboard-header h2 {
  font-size: 28px;
  margin-bottom: 10px;
  color: var(--accent);
}

#dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.dashboard-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.dashboard-card:hover {
  transform: translateY(-8px) scale(1.02) rotateX(2deg);
  background: var(--holo-gradient);
  border-color: var(--accent);
  box-shadow: var(--holo-glow);
}

/* --- THE PRISM: EFFECTS (Phase 134) --- */
.holographic {
    background: var(--holo-gradient) !important;
    backdrop-filter: var(--glass-refraction) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: var(--holo-glow) !important;
    animation: prism-float 4s ease-in-out infinite;
}

@keyframes prism-float {
    0%, 100% { transform: translateY(0) rotateZ(0deg); }
    50% { transform: translateY(-10px) rotateZ(0.5deg); }
}

.prism-glow {
    position: relative;
    overflow: hidden;
}

.prism-glow::after {
    content: '';
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.05), transparent);
    transform: rotate(45deg);
    animation: prism-shine 3s infinite;
}

@keyframes prism-shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

video, 
#yt-player, 
.player-video {
  width: 100%;
  height: 100%;
  object-fit: fill !important; /* Full stretch as requested */
  background: #000;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.dashboard-card .card-name {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 5px;
}

.dashboard-card .card-country {
  font-size: 12px;
  color: var(--accent);
  opacity: 0.8;
}

/* Loading Backdrop */
#player-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(20px);
  transition: opacity 0.3s;
}

#player-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  color: #fff;
}

#loading-logo {
  width: 120px;
  height: 120px;
  object-fit: contain;
  margin-bottom: 20px;
  animation: pulse 2s infinite;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
}

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

@keyframes pulse {

  0%,
  100% {
    opacity: 0.8;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

/* Fixes for status dots */
.channel-name {
  display: flex;
  align-items: center;
}

.channel-del {
  width: 22px;
  height: 22px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}

.channel-item:hover .channel-del {
  display: flex;
}

.channel-del:hover {
  background: var(--danger);
  color: #fff;
}

.channel-del:hover {
  background: var(--danger);
  color: #fff;
}

/* Grid View Toggle */
#channel-list.grid-view {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 10px;
}

#channel-list.grid-view .channel-category {
  grid-column: 1 / -1;
  margin-top: 10px;
}

#channel-list.grid-view .channel-item {
  flex-direction: column;
  text-align: center;
  padding: 15px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border-left: none;
  border-bottom: 3px solid transparent;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#channel-list.grid-view .channel-item.active {
  background: var(--bg-card-hover);
  border-bottom-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

#channel-list.grid-view .channel-logo {
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
}

#channel-list.grid-view .channel-logo-placeholder {
  width: 64px;
  height: 64px;
  font-size: 24px;
}

/* Theater Mode */
#app.theater-mode #sidebar,
#app.theater-mode #top-nav {
  display: none !important;
}

#app.theater-mode {
  grid-template-columns: 1fr !important;
  grid-template-rows: 1fr !important;
}

#app.theater-mode #news-ticker {
  opacity: 0.1;
  /* Fade out but keep slightly visible */
  transition: opacity 0.5s;
}

#app.theater-mode #news-ticker:hover {
  opacity: 1;
}

#app.theater-mode #player-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 1000;
}

#app.theater-mode #player-wrapper:hover~#player-controls,
#app.theater-mode #player-controls:hover {
  opacity: 1;
}

/* ── Main Area ───────────────────────────────────── */
#main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Tabs inside main */
#main-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 11, 18, 0.5);
}

.main-tab {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .2s;
}

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

.main-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── TV Panel ────────────────────────────────────── */
#tv-panel,
#cam-panel {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

#tv-panel.visible,
#cam-panel.visible {
  display: flex;
}

#player-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.player-video,
#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill; /* Stretched by user request */
  background: #000;
  transition: all 0.3s ease;
  z-index: 1;
}

#player-wrapper.is-fullscreen .player-video,
#player-wrapper.is-fullscreen #video {
  object-fit: fill;
}

/* Full surface stretch as requested */

/* Glassmorphic OSD */
#video-osd {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 15, 15, 0.4);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50px;
  padding: 10px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 100;
  transition: opacity 0.4s ease, transform 0.4s ease;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

#video-osd.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}

.osd-controls {
  display: flex;
  gap: 20px;
  align-items: center;
}

.osd-controls button {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  transition: transform 0.2s, color 0.2s, text-shadow 0.2s;
}

.osd-controls button:hover {
  transform: scale(1.2);
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent);
}

.osd-info {
  text-align: center;
}

#osd-channel-name {
  font-weight: 800;
  font-size: 14px;
  color: white;
  letter-spacing: 1px;
}

.osd-fav-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  filter: grayscale(1) opacity(0.5);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  user-select: none;
}

.osd-fav-btn:hover {
  transform: scale(1.3);
  filter: grayscale(0) opacity(0.8);
}

.osd-fav-btn.active {
  filter: grayscale(0) opacity(1);
  color: #ffd700;
  text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
  transform: scale(1.1);
}

.osd-edit-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  filter: grayscale(1) opacity(0.5);
  transition: all 0.3s ease;
  user-select: none;
}

.osd-edit-btn:hover {
  transform: scale(1.2);
  filter: grayscale(0) opacity(1);
  color: #4f8cff;
  text-shadow: 0 0 10px rgba(79, 140, 255, 0.4);
}

#osd-program-name {
  font-size: 11px;
  color: var(--text-secondary);
}

#loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--text-secondary);
  font-size: 15px;
  pointer-events: none;
  transition: opacity .3s;
}

.player-overlay.hidden {
  opacity: 0;
}

.player-overlay .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Controls bar */
#player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(10, 11, 18, 0.95);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 16px;
  transition: all .2s;
}

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

#channel-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#btn-exit-theater {
  display: none;
}

body.theater-active #btn-exit-theater {
  display: flex;
  background: var(--danger);
}

#volume-slider {
  width: 80px;
  accent-color: var(--accent);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: background .3s;
}

.status-dot.live {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-dot.error {
  background: var(--danger);
}

/* ── Webcam Panel ────────────────────────────────── */
#cam-panel {
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 16px;
  background: #000;
}

#webcam-video {
  max-width: 100%;
  max-height: calc(100% - 120px);
  border-radius: 12px;
  border: 2px solid var(--border);
  object-fit: cover;
}

#cam-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.cam-btn {
  padding: 7px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.cam-btn.active {
  background: var(--danger);
  border-color: var(--danger);
}

.cam-slider-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.cam-slider-group input[type=range] {
  width: 80px;
  accent-color: var(--accent);
}

/* ── Modal Common ───────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: block;
  /* Use block so absolute positioning of child works */
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

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

.modal-box {
  background: rgba(18, 20, 30, 0.98);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: 14px;
  width: 460px;
  min-width: 320px;
  min-height: 200px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  position: absolute;
  /* Changed from relative */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  overflow: hidden;
  resize: both;
}

.modal-header {
  padding: 20px 24px 15px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  cursor: move;
  /* Indicate draggable */
  user-select: none;
}

.modal-header h3 {
  font-size: 16px;
  font-family: 'Outfit';
  color: var(--accent);
  margin: 0;
}

.modal-body {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.modal-body::-webkit-scrollbar {
  width: 5px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

.modal-footer {
  padding: 15px 24px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 5px;
}

.btn-cancel {
  padding: 8px 18px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
}

.btn-save {
  padding: 8px 18px;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.btn-save:hover {
  opacity: .85;
}

/* ── Toast ───────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 18px;
  background: rgba(20, 22, 35, 0.96);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  transform: translateY(10px);
  opacity: 0;
  transition: all .3s;
  z-index: 2000;
  pointer-events: none;
}

#toast.show {
  transform: translateY(0);
  opacity: 1;
}

#toast.success {
  border-left: 3px solid var(--success);
}

#toast.error {
  border-left: 3px solid var(--danger);
}

/* ── Visual Effects ───────────────────────────────── */
@keyframes mesh {
  0% {
    background-position: 0% 0%;
  }

  50% {
    background-position: 100% 100%;
  }

  100% {
    background-position: 0% 0%;
  }
}

.mesh-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(at 0% 0%, #1a1b26 0, transparent 50%),
    radial-gradient(at 50% 0%, #24283b 0, transparent 50%),
    radial-gradient(at 100% 0%, #1a1b26 0, transparent 50%),
    radial-gradient(at 0% 50%, #24283b 0, transparent 50%),
    radial-gradient(at 100% 50%, #1a1b26 0, transparent 50%),
    radial-gradient(at 0% 100%, #1a1b26 0, transparent 50%),
    radial-gradient(at 50% 100%, #24283b 0, transparent 50%),
    radial-gradient(at 100% 100%, #1a1b26 0, transparent 50%);
  background-size: 200% 200%;
  animation: mesh 20s ease infinite;
  z-index: -2;
  opacity: 0;
  transition: opacity 1s;
}

.mesh-bg.active {
  opacity: 0.6;
}

#video-glow {
  position: absolute;
  inset: 0;
  filter: blur(100px);
  opacity: 0;
  transition: opacity 1s, background 0.8s ease;
  z-index: -1;
  pointer-events: none;
}

#video-glow.active {
  opacity: 0.5;
}

.crt-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.2) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
  background-size: 100% 3px, 3px 100%;
  opacity: 0;
  transition: opacity 0.5s;
}

.crt-overlay.active {
  opacity: 1;
}

#audio-visualizer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 80px;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s;
}

#audio-visualizer.active {
  opacity: 0.8;
}

.effects-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: rgba(15, 17, 26, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: none;
  flex-direction: column;
  gap: 12px;
  min-width: 200px;
  z-index: 2000;
  margin-top: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.effects-menu.active {
  display: flex;
}

.effects-menu label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-primary);
}

.effects-menu input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}
/* --- Heal Progress Modal styles --- */
.heal-content { max-width: 450px !important; background: rgba(15, 23, 42, 0.95) !important; border: 1px solid rgba(59, 130, 246, 0.3) !important; box-shadow: 0 0 30px rgba(59, 130, 246, 0.2) !important; }
.heal-list { margin: 15px 0; max-height: 250px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 5px; }
.heal-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 15px; background: rgba(255, 255, 255, 0.05); border-radius: 8px; font-size: 14px; transition: all 0.3s; border: 1px solid transparent; }
.heal-item.active { background: rgba(59, 130, 246, 0.15); border-color: rgba(59, 130, 246, 0.4); box-shadow: 0 0 10px rgba(59, 130, 246, 0.1); }
.heal-item.success { color: #4ade80; background: rgba(74, 222, 128, 0.1); border-color: rgba(74, 222, 128, 0.2); }
.heal-item.failed { opacity: 0.5; background: rgba(244, 63, 94, 0.05); }
.heal-status { text-align: center; font-size: 13px; color: #94a3b8; margin-bottom: 15px; font-style: italic; }
.heal-badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: rgba(255, 255, 255, 0.1); font-weight: 600; }
.heal-badge.testing { background: #3b82f6; color: white; animation: heal-pulse 1.5s infinite; }
.heal-badge.success { background: #10b981; color: white; }
.heal-badge.failed { background: #ef4444; color: white; }
@keyframes heal-pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

/* --- FOIL DECODING OVERLAY --- */
.heal-foil { position: absolute; inset: 0; z-index: 1500; background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(12px) saturate(150%); -webkit-backdrop-filter: blur(12px) saturate(150%); display: flex; align-items: center; justify-content: center; opacity: 1; transition: opacity 0.5s ease; }
.heal-foil.hidden { opacity: 0 !important; pointer-events: none !important; }
.heal-foil-content { width: 90%; max-width: 600px; padding: 40px; background: rgba(15, 23, 42, 0.6); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 24px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); color: white; }
.heal-foil-header { display: flex; align-items: center; gap: 20px; margin-bottom: 30px; }
.heal-foil-icon { font-size: 32px; filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.5)); }
.heal-foil-title-group h2 { margin: 0; font-size: 22px; font-weight: 800; font-family: 'Outfit'; }
.heal-foil-title-group p { margin: 4px 0 0; font-size: 11px; letter-spacing: 2px; color: #3b82f6; font-weight: 700; }
.heal-foil-list { display: flex; flex-direction: column; gap: 12px; max-height: 250px; overflow-y: auto; margin-bottom: 30px; padding-right: 10px; }
.heal-foil-list::-webkit-scrollbar { width: 4px; }
.heal-foil-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; }
.heal-status-msg { text-align: center; color: #94a3b8; font-size: 14px; margin-bottom: 20px; font-style: italic; }
.heal-cancel-btn { width: 100%; padding: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); color: #94a3b8; border-radius: 12px; cursor: pointer; font-weight: 600; letter-spacing: 1px; transition: all 0.3s; }
.heal-cancel-btn:hover { background: rgba(244, 63, 94, 0.1); color: #f43f5e; border-color: rgba(244, 63, 94, 0.2); }
.heal-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; background: rgba(255, 255, 255, 0.03); border-radius: 12px; font-size: 13px; transition: all 0.3s; border: 1px solid transparent; }
.heal-item.active { background: rgba(59, 130, 246, 0.15); border-color: rgba(59, 130, 246, 0.4); box-shadow: 0 0 15px rgba(59, 130, 246, 0.15); }
.heal-item.success { color: #4ade80; background: rgba(74, 222, 128, 0.1); border-color: rgba(74, 222, 128, 0.2); }
.heal-item.failed { opacity: 0.4; filter: grayscale(1); }
.heal-badge { font-size: 11px; padding: 3px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.1); font-weight: 700; }
.heal-badge.testing { background: #3b82f6; color: white; animation: heal-pulse 1.5s infinite; }
.heal-badge.success { background: #10b981; color: white; }
.heal-badge.failed { background: #ef4444; color: white; }

/* --- VISION PROGRESS UI --- */
.heal-progress-wrapper { margin-bottom: 25px; }
.heal-progress-container { width: 100%; height: 6px; background: rgba(255, 255, 255, 0.05); border-radius: 10px; overflow: hidden; margin-bottom: 8px; border: 1px solid rgba(255, 255, 255, 0.05); }
.heal-progress-bar { height: 100%; background: linear-gradient(90deg, #3b82f6, #60a5fa); box-shadow: 0 0 15px rgba(59, 130, 246, 0.5); width: 0%; transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.heal-step-counter { font-family: 'Inter'; font-size: 11px; font-weight: 800; color: #94a3b8; letter-spacing: 2px; text-transform: uppercase; text-align: right; }


/* --- ELITE TECHNICAL HUD --- */
.player-hud { position: absolute; top: 20px; right: 20px; z-index: 50; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; pointer-events: none; text-shadow: 0 2px 4px rgba(0,0,0,0.8); }
.hud-item { font-family: 'JetBrains Mono', 'Courier New', monospace; font-size: 13px; color: rgba(255, 255, 255, 0.8); background: rgba(0, 0, 0, 0.4); padding: 4px 10px; border-radius: 4px; backdrop-filter: blur(8px); border: 1px solid rgba(255, 255, 255, 0.1); letter-spacing: 0.5px; }
.hud-item.clock { font-size: 18px; font-weight: 800; color: var(--accent); border-color: rgba(96, 165, 250, 0.3); margin-bottom: 4px; }
.hud-item.station { font-weight: 600; color: #fff; }
.hud-item.strategy { font-size: 10px; font-weight: 700; color: #fbbf24; text-transform: uppercase; border-color: rgba(251, 191, 36, 0.3); }


.hud-item.graph-container { display: flex; align-items: center; gap: 10px; padding: 2px 8px; border-color: rgba(34, 197, 94, 0.3); }
#hud-bitrate-graph { width: 80px; height: 20px; opacity: 0.8; }
#hud-bitrate-text { font-size: 10px; font-weight: 800; color: #22c55e; min-width: 45px; text-align: right; text-shadow: 0 0 5px rgba(34, 197, 94, 0.5); }


/* --- MINI PLAYER (MULTI-VIEW) --- */
#mini-player-wrapper { position: fixed; bottom: 20px; right: 20px; width: 320px; aspect-ratio: 16/9; background: rgba(0,0,0,0.8); border: 2px solid var(--accent); border-radius: 12px; overflow: hidden; z-index: 1000; box-shadow: 0 20px 50px rgba(0,0,0,0.8); backdrop-filter: blur(10px); cursor: move; transition: transform 0.3s; }
#mini-player-wrapper:hover { transform: scale(1.02); }
#mini-video { width: 100%; height: 100%; object-fit: cover; }
#mini-player-osd { position: absolute; top: 0; left: 0; right: 0; padding: 8px 12px; background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent); display: flex; justify-content: space-between; align-items: center; opacity: 0; transition: opacity .2s; }
#mini-player-wrapper:hover #mini-player-osd { opacity: 1; }
#mini-title { font-family: 'Outfit'; font-size: 12px; color: #fff; font-weight: 600; text-shadow: 0 1px 2px #000; }
#mini-close { background: rgba(255,255,255,0.1); border: none; color: #fff; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px; transition: background .2s; }
#mini-close:hover { background: var(--error); }
.mini-btn { font-size: 14px; opacity: 0.6; transition: opacity .2s, color .2s; }
.mini-btn:hover { opacity: 1; color: var(--accent); }


.mini-select { background: rgba(0,0,0,0.6) !important; color: var(--accent) !important; border: 1px solid rgba(96, 165, 250, 0.2); font-size: 10px !important; font-weight: 700; cursor: pointer; height: auto !important; padding: 2px 4px !important; outline: none; }
.mini-select option { background: #1a1a1a; color: #fff; }


.sidebar-search-container { 
  display: flex; 
  gap: 6px; 
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
#channel-search { 
  flex: 1; 
  height: 32px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
#btn-voice-search { 
  width: 32px; 
  height: 32px;
  background: rgba(255,255,255,0.05); 
  border: 1px solid var(--border); 
  border-radius: 6px; 
  color: #fff; 
  cursor: pointer; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  transition: all .2s; 
}
#btn-voice-search:hover { background: rgba(96, 165, 250, 0.1); border-color: var(--accent); }
#btn-voice-search.active { background: var(--error); color: #fff; animation: pulse 1.5s infinite; }


/* --- PHASE 58: MINI-OVERLAY (IN-APP PiP) --- */
.mini-overlay {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 320px;
  height: 180px;
  z-index: 60;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 2px solid rgba(96, 165, 250, 0.5);
  box-shadow: 0 8px 32px rgba(0,0,0,0.7), 0 0 20px rgba(96,165,250,0.2);
  resize: both;
  cursor: move;
  transition: opacity 0.3s, transform 0.3s;
}
.mini-overlay.hidden { display: none; }
.mini-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  background: rgba(0,0,0,0.8);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  cursor: grab;
}
.mini-overlay-close {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
}
.mini-overlay-close:hover { color: #fff; }
#mini-video {
  width: 100%;
  height: calc(100% - 24px);
  object-fit: fill;
  background: #000;
}

/* --- PHASE 58: AUDIO TRACK SELECTOR --- */
.audio-track-menu {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 80;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: 14px;
  padding: 16px;
  min-width: 260px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.audio-track-menu.hidden { display: none; }
.audio-menu-header {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--accent);
  margin-bottom: 12px;
  text-align: center;
}
.audio-track-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  color: var(--text-primary);
  font-size: 13px;
}
.audio-track-item:hover { background: rgba(96,165,250,0.15); transform: scale(1.02); }
.audio-track-item.active { background: rgba(96,165,250,0.25); border: 1px solid var(--accent); }
.audio-track-item .track-lang { font-weight: 700; color: var(--accent); }

/* --- PHASE 58: HUD BITRATE GRAPH --- */
.hud-bitrate-canvas {
  border-radius: 4px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(96,165,250,0.2);
  display: block;
}
.hud-item.audio-track { font-size: 11px; color: #a78bfa; border-color: rgba(167,139,250,0.3); }
.hud-item.bitrate-label { font-size: 10px; color: #34d399; border-color: rgba(52,211,153,0.3); font-weight: 700; }

/* --- PHASE 58: TTFF LABEL --- */
.hud-item.ttff-label { font-size: 10px; color: #f59e0b; border-color: rgba(245,158,11,0.3); font-weight: 700; }

/* --- PHASE 59: KEYBOARD SHORTCUTS MODAL --- */
.shortcuts-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.7); backdrop-filter: blur(10px); }
.shortcuts-modal.hidden { display: none; }
.shortcuts-content { background: rgba(15, 23, 42, 0.95); border: 1px solid rgba(96,165,250,0.3); border-radius: 16px; padding: 24px 32px; max-width: 420px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
.shortcuts-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.shortcuts-header h2 { font-family: 'Outfit', sans-serif; font-size: 22px; color: var(--accent); margin: 0; }
.shortcuts-grid { display: flex; flex-direction: column; gap: 6px; }
.sc-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: rgba(255,255,255,0.04); border-radius: 8px; font-size: 13px; color: var(--text-primary); }
.sc-row kbd { background: rgba(96,165,250,0.2); border: 1px solid rgba(96,165,250,0.4); border-radius: 4px; padding: 3px 8px; font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; color: var(--accent); min-width: 32px; text-align: center; }
/* --- PHASE 64: ELITE EPG GRID --- */
.epg-grid-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(10, 11, 20, 0.85);
    backdrop-filter: blur(25px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.epg-grid-overlay.hidden { opacity: 0; pointer-events: none; transform: scale(1.05); }

.epg-grid-container {
    width: 95vw;
    height: 90vh;
    background: rgba(18, 20, 32, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 40px 100px rgba(0,0,0,0.8);
}

.epg-grid-header {
    padding: 25px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.epg-grid-close {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}
.epg-grid-close:hover { background: #f43f5e; color: #fff; transform: rotate(90deg); }

.epg-grid-toolbar {
    padding: 10px 30px;
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.epg-date-tabs { display: flex; gap: 10px; }
.epg-date-tab { padding: 8px 16px; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer; color: rgba(255,255,255,0.5); border: 1px solid transparent; }
.epg-date-tab.active { color: #fff; background: rgba(96, 165, 250, 0.2); border-color: rgba(96, 165, 250, 0.4); }

.epg-legend { display: flex; gap: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.legend-item.current { color: var(--accent); }
.legend-item.next { color: #fff; opacity: 0.6; }

.epg-grid-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

.epg-timeline-ruler {
    display: flex;
    height: 40px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(18, 20, 32, 0.95);
}

.epg-time-marker {
    flex-shrink: 0;
    width: 200px; /* 1 hour = 200px */
    border-left: 1px solid rgba(255,255,255,0.1);
    padding-left: 10px;
    display: flex;
    align-items: center;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255,255,255,0.4);
}

.epg-grid-row {
    display: flex;
    height: 80px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.epg-channel-cell {
    width: 250px;
    flex-shrink: 0;
    position: sticky;
    left: 0;
    z-index: 5;
    background: #121420;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 0 20px;
    border-right: 1px solid rgba(255,255,255,0.05);
}

.epg-channel-cell img { width: 45px; height: 45px; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5)); }
.epg-channel-cell .ch-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.epg-programs-scroll {
    display: flex;
    flex: 1;
    overflow-x: auto;
    position: relative;
    scrollbar-width: none;
}
.epg-programs-scroll::-webkit-scrollbar { display: none; }

.epg-program-block {
    position: absolute;
    height: 70%;
    top: 15%;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
}
.epg-program-block:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); transform: translateY(-2px); z-index: 2; }
.epg-program-block.active { background: rgba(96, 165, 250, 0.2); border-color: rgba(96, 165, 250, 0.4); box-shadow: 0 0 20px rgba(96, 165, 250, 0.2); }

.epg-program-block .p-title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.epg-program-block .p-time { font-size: 10px; opacity: 0.6; margin-top: 2px; }

.epg-now-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--accent);
    box-shadow: 0 0 15px var(--accent);
    z-index: 8;
    pointer-events: none;
}

/* --- PHASE 64: QUALITY BADGE --- */
.quality-badge {
    display: inline-block;
    padding: 1px 6px;
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    border-radius: 4px;
    margin-left: 6px;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
    vertical-align: middle;
}

/* --- PHASE 65: MULTI-VIEW (COMMAND CENTER) --- */
.multi-view-container {
    position: absolute;
    inset: 0;
    background: #000;
    z-index: 1000;
    display: grid;
    gap: 4px;
    padding: 4px;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.multi-view-container.hidden { 
    opacity: 0; 
    pointer-events: none; 
    transform: scale(0.95);
}

.mv-tile {
    position: relative;
    background: #0a0a0a;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    cursor: crosshair;
    transition: border-color 0.3s;
}
.mv-tile.active {
    border-color: var(--accent);
    box-shadow: inset 0 0 20px rgba(96, 165, 250, 0.3);
}
.mv-tile video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Layouts */
.mv-layout-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.mv-layout-2 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.mv-layout-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.mv-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px;
    padding: 8px 15px;
    display: flex;
    gap: 10px;
    z-index: 1100;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.3s;
}
.multi-view-container:hover .mv-controls { opacity: 1; }

.mv-controls button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 6px 14px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.mv-controls button:hover { background: var(--accent); border-color: var(--accent); }
.mv-btn-exit { background: rgba(244, 63, 94, 0.2) !important; color: #f43f5e !important; }
.mv-btn-exit:hover { background: #f43f5e; transform: scale(1.05); }

/* AI THEMATIC GRID (PHASE 65) */
.thematic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.theme-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.theme-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.theme-card .t-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.2));
}

.theme-card .t-label {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text);
    text-transform: uppercase;
}
/* Phase 66: EPG Reminders & Export */
#btn-export-m3u {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 8px;
    padding: 0 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-export-m3u:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.epg-reminder-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.4);
    border: none;
    color: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.epg-reminder-btn:hover {
    background: var(--accent);
    color: white;
    transform: scale(1.1);
}

.epg-reminder-btn.active {
    color: #ffcc00;
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
}

.epg-program-block {
    position: relative; /* Ensure button positioning works */
}

/* Phase 68: DVR & Pulse */
#btn-record.active {
    animation: pulse-red 1.5s infinite;
    background: rgba(255, 77, 77, 0.2);
}

@keyframes pulse-red {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(255, 77, 77, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); }
}

.recording-hud {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
    pointer-events: none;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.2);
}
.recording-hud::before {
    content: '';
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: fade 1s infinite alternate;
}
/* Phase 69: System Stats & Intelligence */
.stats-box {
    background: rgba(20, 20, 25, 0.7) !important;
    backdrop-filter: blur(25px) saturate(180%) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 20px;
    padding: 20px;
}

.stats-card {
    padding: 20px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stats-card.full-width { grid-column: 1 / -1; }

.big-stat {
    font-size: 48px;
    font-weight: 800;
    font-family: 'Outfit';
    color: var(--accent);
    margin: 10px 0;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
    font-size: 14px;
    opacity: 0.8;
}

.storage-bar {
    height: 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 5px;
    margin-top: 15px;
    overflow: hidden;
}

#stat-storage-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #4facfe);
    transition: width 1s ease;
}

.health-chart {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    height: 100px;
    margin-top: 20px;
}

.health-bar {
    flex: 1;
    background: var(--accent);
    border-radius: 4px 4px 0 0;
    position: relative;
    min-width: 40px;
}

.health-bar::after {
    content: attr(data-label);
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    white-space: nowrap;
}

.roadmap-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
}

.roadmap-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    border-left: 4px solid var(--accent);
}

.roadmap-item.status-proposed { border-left-color: #888; }
.roadmap-item.status-planned { border-left-color: #00e5ff; }

.roadmap-info { flex: 1; }
.roadmap-info h5 { margin: 0; font-size: 15px; }
.roadmap-info p { margin: 0; font-size: 12px; opacity: 0.6; }

.roadmap-priority {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    text-transform: uppercase;
}

/* Phase 73: Background Sync UI */
.sync-badge {
    font-size: 11px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.5);
}
.sync-badge.syncing {
    color: #00e676;
    border-color: rgba(0, 230, 118, 0.3);
}
.pulse-dot {
    width: 6px;
    height: 6px;
    background: #00e676;
    border-radius: 50%;
    animation: pulseSync 1.5s infinite;
}
@keyframes pulseSync {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

/* Phase 74: Sync Progress Bar */
.sync-progress-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    margin: 15px 0;
    overflow: hidden;
    transition: all 0.3s ease;
}
.sync-progress-track.hidden {
    height: 0;
    margin: 0;
    opacity: 0;
}
.sync-progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #00e676, #00b0ff, #00e676);
    background-size: 200% 100%;
    animation: flowGreen 2s linear infinite;
    box-shadow: 0 0 10px rgba(0, 230, 118, 0.5);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes flowGreen {
    0% { background-position: 0% 0%; }
    100% { background-position: -200% 0%; }
}

/* Phase 75: Sync Strategy UI */
.sync-options-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sync-opt-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    width: 100%;
}
.sync-opt-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #00e676;
    transform: translateY(-2px);
}
.opt-icon {
    font-size: 24px;
}
.opt-text b {
    display: block;
    font-size: 14px;
}
.opt-text span {
    font-size: 11px;
    opacity: 0.6;
}

/* Phase 78: HLS Quality & Audio Menus */
.osd-menu {
    position: absolute;
    bottom: 45px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 11, 25, 0.9);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    min-width: 140px;
    padding: 8px;
    z-index: 1000;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.osd-menu.hidden { display: none; }
.osd-menu-item {
    padding: 10px 15px;
    font-size: 13px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
    text-align: left;
    white-space: nowrap;
}
.osd-menu-item:hover { background: rgba(255,255,255,0.1); }
.osd-menu-item.active { background: var(--accent); color: white; font-weight: 700; }
.osd-menu-header {
    padding: 5px 15px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    font-weight: 800;
}
