:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #182234;
  --bg-hover: #334155;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 8px;
  --ch-col-width: 130px;
  --epg-row-height: 64px;
  --hour-width: 240px; /* 4px per minute */
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Custom Dark Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Header */
.app-header {
  height: 56px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 30;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.logo-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.logo-text .highlight {
  color: var(--accent);
}

.tuner-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-weight: 600;
  letter-spacing: 0.025em;
}

.badge-idle {
  background-color: rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.badge-active {
  background-color: rgba(16, 185, 129, 0.2);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-recording {
  background-color: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.5);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.header-nav {
  display: flex;
  gap: 0.5rem;
}

.nav-btn {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-block;
}

.nav-btn:hover {
  color: var(--text-main);
  background-color: var(--bg-hover);
}

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

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lang-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.lang-select, .form-select, .form-input {
  background-color: var(--bg-primary);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  outline: none;
}

/* App Main Content */
.app-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
}

.tab-pane {
  display: none;
  height: 100%;
  width: 100%;
}

.tab-pane.active {
  display: flex;
}

/* Tab 1: Live TV Layout */
.tv-layout {
  display: flex;
  width: 100%;
  height: 100%;
}

.video-container {
  flex: 1;
  background-color: #000;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  height: 100%;
  container-type: size;
}

.video-screen {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: #000;
  flex: 1;
  container-type: size;
}

.video-container.cursor-hidden,
.video-container.cursor-hidden * {
  cursor: none !important;
}

.tv-video-stage,
#tv-video,
#tv-video-next {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: opacity 0.22s ease-in-out;
}

.tv-video-stage.active-stage {
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
}

.tv-video-stage.video-stage-next {
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

.tv-video-stage.ar-auto,
#tv-video.ar-auto,
#tv-video-next.ar-auto {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tv-video-stage.ar-16-9,
#tv-video.ar-16-9,
#tv-video-next.ar-16-9 {
  aspect-ratio: 16 / 9;
  width: min(100cqw, calc(100cqh * 16 / 9)) !important;
  height: min(100cqh, calc(100cqw * 9 / 16)) !important;
  max-width: 100%;
  max-height: 100%;
  object-fit: fill;
}

.tv-video-stage.ar-4-3,
#tv-video.ar-4-3,
#tv-video-next.ar-4-3 {
  aspect-ratio: 4 / 3;
  width: min(100cqw, calc(100cqh * 4 / 3)) !important;
  height: min(100cqh, calc(100cqw * 3 / 4)) !important;
  max-width: 100%;
  max-height: 100%;
  object-fit: fill;
}

.tv-video-stage.ar-fill,
#tv-video.ar-fill,
#tv-video-next.ar-fill {
  width: 100% !important;
  height: 100% !important;
  object-fit: fill;
}

.tv-video-stage.ar-cover,
#tv-video.ar-cover,
#tv-video-next.ar-cover {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

.aspect-btn {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.aspect-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
}

#aspect-ratio-menu {
  min-width: 195px;
}

/* Standby Overlay */
.standby-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.standby-card {
  text-align: center;
  max-width: 400px;
  padding: 2rem;
}

.standby-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}

.standby-card h3 {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.standby-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Radio Broadcast Overlay Card */
.radio-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}

.radio-card {
  text-align: center;
  padding: 2rem;
  max-width: 480px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.radio-icon-pulse {
  font-size: 3.5rem;
  animation: pulse-radio 2s infinite ease-in-out;
  margin-bottom: 0.25rem;
}

@keyframes pulse-radio {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.4)); }
  50% { transform: scale(1.08); filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.8)); }
}

.radio-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  margin: 0;
  letter-spacing: -0.02em;
}

.radio-badge-tag {
  display: inline-block;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #93c5fd;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.6rem;
  border-radius: 9999px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.radio-now-show {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.radio-equalizer {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  height: 36px;
  margin-top: 1.25rem;
}

.eq-bar {
  width: 5px;
  background: var(--accent);
  border-radius: 3px;
  animation: eq-bounce 1.2s infinite ease-in-out;
}

.bar-1 { height: 40%; animation-delay: 0.1s; }
.bar-2 { height: 80%; animation-delay: 0.3s; }
.bar-3 { height: 60%; animation-delay: 0.5s; }
.bar-4 { height: 95%; animation-delay: 0.2s; }
.bar-5 { height: 50%; animation-delay: 0.4s; }
.bar-6 { height: 85%; animation-delay: 0.6s; }
.bar-7 { height: 65%; animation-delay: 0.15s; }
.bar-8 { height: 45%; animation-delay: 0.35s; }

@keyframes eq-bounce {
  0%, 100% { transform: scaleY(0.3); opacity: 0.5; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* Floating Stream Alert Banner */
.stream-alert {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(220, 38, 38, 0.95);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 20;
  max-width: 90%;
  opacity: 0;
  transition: all 0.3s ease;
  font-size: 0.95rem;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  pointer-events: auto;
}

.stream-alert.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.stream-alert-icon {
  font-size: 1.25rem;
}

.stream-alert-msg {
  flex: 1;
  font-weight: 500;
}

.btn-close-alert {
  background: none;
  border: none;
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.25rem;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.btn-close-alert:hover {
  opacity: 1;
}

/* Video OSD (Discreet Top-Left Smart-TV Banner, dynamically scaled with window size) */
.video-osd {
  position: absolute;
  top: clamp(0.5rem, 2vmin, 1.5rem);
  left: clamp(0.5rem, 2vmin, 1.5rem);
  width: clamp(230px, 32vmin + 80px, 600px);
  max-width: calc(100% - clamp(1rem, 4vmin, 3rem));
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: clamp(6px, 1vmin, 12px);
  padding: clamp(0.35rem, 1vmin, 0.95rem) clamp(0.55rem, 1.4vmin, 1.35rem);
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.35s ease, visibility 0.35s ease, transform 0.35s ease, border-color 0.2s ease, background 0.2s ease;
  transform: translateY(0);
}

.video-osd:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(15, 23, 42, 0.92);
}

.osd-show-title.clickable:hover {
  color: #93c5fd;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.video-osd.controls-autohidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateY(-8px);
}

.osd-channel {
  display: flex;
  align-items: center;
}

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

.osd-number-name {
  display: flex;
  align-items: center;
  gap: clamp(0.35rem, 0.7vmin, 0.75rem);
  font-weight: 700;
  font-size: clamp(0.85rem, 1.8vmin, 1.35rem);
  line-height: 1.2;
}

.osd-show-title {
  font-size: clamp(0.75rem, 1.5vmin, 1.15rem);
  font-weight: 500;
  color: #fff;
  margin: clamp(0.18rem, 0.4vmin, 0.4rem) 0 clamp(0.22rem, 0.5vmin, 0.5rem) 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.95;
}

.osd-time-bar-wrapper {
  display: flex;
  align-items: center;
  gap: clamp(0.35rem, 0.7vmin, 0.75rem);
  font-size: clamp(0.65rem, 1.2vmin, 0.95rem);
  color: var(--text-muted);
}

.osd-progress-bg {
  flex: 1;
  height: clamp(3px, 0.45vmin, 6px);
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
  overflow: hidden;
}

.osd-progress-fill {
  height: 100%;
  width: 0%;
  background-color: var(--accent);
  transition: width 0.3s ease;
}

.osd-signal-badge {
  font-size: clamp(0.65rem, 1.2vmin, 0.95rem);
  font-weight: 600;
  padding: clamp(0.1rem, 0.2vmin, 0.25rem) clamp(0.35rem, 0.6vmin, 0.65rem);
  border-radius: 4px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  margin-left: auto;
  white-space: nowrap;
}

/* OSD Next Program Banner */
.osd-next-wrapper {
  display: flex;
  align-items: center;
  gap: clamp(0.35rem, 0.6vmin, 0.65rem);
  margin-top: clamp(0.28rem, 0.5vmin, 0.55rem);
  padding-top: clamp(0.28rem, 0.5vmin, 0.45rem);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: clamp(0.68rem, 1.25vmin, 0.92rem);
  color: var(--text-muted, #94a3b8);
  transition: color 0.15s ease, background-color 0.15s ease;
  cursor: pointer;
}

.osd-next-wrapper.clickable:hover {
  color: #e2e8f0;
}

.osd-next-wrapper.clickable:hover .osd-next-title {
  color: #93c5fd;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.osd-next-badge {
  font-size: clamp(0.55rem, 1vmin, 0.72rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 3px;
  padding: 0.08rem 0.35rem;
  flex-shrink: 0;
}

.osd-next-time {
  font-weight: 600;
  color: #cbd5e1;
  flex-shrink: 0;
}

.osd-next-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Stream Tuning / Buffering Loader */
.stream-loader {
  position: absolute;
  inset: 0;
  background-color: rgba(10, 15, 30, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 8;
  transition: opacity 0.25s ease;
}

.loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 2rem;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.loader-card .spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(59, 130, 246, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin-loader 0.8s linear infinite;
}

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

.loader-info h4 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
}

.loader-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

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

/* Quick Zap Number Indicator */
.zap-indicator {
  position: absolute;
  top: 30px;
  right: 30px;
  background-color: rgba(15, 23, 42, 0.85);
  border: 2px solid var(--accent);
  color: #fff;
  font-size: 2.5rem;
  font-weight: 800;
  padding: 0.5rem 1.5rem;
  border-radius: var(--radius);
  z-index: 10;
}

/* Unified Player Bottom Bar (Timeshift + Controls Group) */
.player-bottom-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  z-index: 10;
  background: linear-gradient(to top, rgba(10, 15, 29, 0.95) 0%, rgba(10, 15, 29, 0.75) 60%, rgba(10, 15, 29, 0.2) 90%, transparent 100%);
  transition: opacity 0.35s ease, visibility 0.35s ease;
  pointer-events: none;
}

.player-bottom-bar > * {
  pointer-events: auto;
}

.player-bottom-bar.controls-autohidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* Player Controls Bar */
.player-controls {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 48px;
  background: transparent;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.35rem 0.85rem;
  gap: clamp(0.3rem, 1vw, 0.65rem);
  z-index: 10;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.player-controls.controls-autohidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.player-controls > * {
  flex-shrink: 0;
}

.player-spacer {
  flex: 1;
  min-width: 8px;
}

.ctrl-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.88rem;
  cursor: pointer;
  padding: 0.28rem 0.55rem;
  border-radius: 6px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  line-height: 1.2;
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.ctrl-btn:active {
  transform: translateY(0);
}

.vol-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.12rem 0.45rem 0.12rem 0.25rem;
  border-radius: 6px;
}

.vol-group .ctrl-btn {
  background: transparent;
  border: none;
  padding: 0.15rem 0.25rem;
  font-size: 0.95rem;
}

.vol-group .ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: none;
}

.vol-slider {
  width: 70px;
  height: 5px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.28);
  border-radius: 9999px;
  outline: none;
  cursor: pointer;
  accent-color: var(--accent);
  transition: background 0.15s ease, opacity 0.15s ease, width 0.2s ease;
}

.vol-slider:hover {
  background: rgba(255, 255, 255, 0.45);
}

.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.vol-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

.vol-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: none;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.vol-slider::-moz-range-track {
  height: 5px;
  background: rgba(255, 255, 255, 0.28);
  border-radius: 9999px;
}

.vol-group.is-muted .vol-slider {
  opacity: 0.45;
}

.rec-btn {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  font-weight: 600;
  font-size: 0.78rem;
}

.rec-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.6);
  color: #fff;
}

.rec-btn.is-recording {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

.track-select-btn,
.teletext-ctrl-btn,
.hbbtv-ctrl-btn,
.aspect-btn {
  font-size: 0.78rem;
  font-weight: 600;
}

.aspect-btn {
  font-family: monospace;
  font-weight: 700;
}

.signal-quality-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  color: var(--text-main);
  backdrop-filter: blur(4px);
}

.signal-quality-badge strong {
  font-size: 0.85rem;
}

.signal-quality-badge.sig-good strong, .osd-signal-badge.sig-good {
  color: var(--success);
}
.signal-quality-badge.sig-med strong, .osd-signal-badge.sig-med {
  color: var(--warning);
}
.signal-quality-badge.sig-poor strong, .osd-signal-badge.sig-poor {
  color: var(--danger);
}

.osd-signal-badge {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border);
  margin-left: 0.5rem;
}

.tuner-signal-meter {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.tuner-signal-meter strong {
  color: var(--accent);
}

.latency-tag {
  font-size: 0.75rem;
  color: var(--success);
  font-weight: 600;
}

/* Channel Sidebar */
.channel-sidebar {
  width: 340px;
  background-color: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.channel-search-input {
  width: 100%;
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  outline: none;
}

.channel-type-filters {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.ch-type-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.ch-type-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
}

.ch-type-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.badge-radio {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: 0.3rem;
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.channel-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background-color: var(--bg-card);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.channel-card.active {
  border-color: var(--accent);
  background-color: rgba(59, 130, 246, 0.15);
}

.channel-card.has-conflict {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.08) 0%, var(--bg-card) 100%);
}

.channel-card.has-conflict:hover {
  border-color: rgba(245, 158, 11, 0.7);
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.15) 0%, var(--bg-hover) 100%);
}

.channel-card.is-recording {
  border-color: rgba(239, 68, 68, 0.5);
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.12) 0%, var(--bg-card) 100%);
}

.channel-card.is-recording:hover {
  border-color: rgba(239, 68, 68, 0.8);
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.18) 0%, var(--bg-hover) 100%);
}

.channel-card.can-switch {
  border-left: 3px solid #22c55e;
}

.ch-status-wrap {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.badge-rec {
  background: rgba(239, 68, 68, 0.22);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.55);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.45rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
  animation: pulse-rec 2s infinite ease-in-out;
}

@keyframes pulse-rec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.badge-watchable {
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.45);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

.badge-conflict {
  background-color: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
  font-size: 0.68rem;
  padding: 0.12rem 0.4rem;
  border-radius: 9999px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  white-space: nowrap;
}

.epg-conflict-icon {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  margin-left: 0.3rem;
  filter: drop-shadow(0 0 2px rgba(245, 158, 11, 0.5));
}

.epg-channel-cell.has-conflict {
  border-left: 3px solid #f59e0b;
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.15) 0%, var(--bg-secondary) 100%);
}

.epg-channel-cell.has-conflict:hover {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.25) 0%, var(--bg-hover) 100%);
}

.epg-channel-cell.is-playing {
  border-left: 4px solid var(--accent);
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.22) 0%, var(--bg-secondary) 100%);
}

.epg-channel-cell.is-playing:hover {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.3) 0%, var(--bg-hover) 100%);
}

.epg-channel-cell.is-playing .epg-ch-cell-name {
  color: #60a5fa;
  font-weight: 700;
}

.epg-playing-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.6rem;
  font-weight: 700;
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.5);
  padding: 0.06rem 0.28rem;
  border-radius: 3px;
  margin-left: 0.25rem;
  flex-shrink: 0;
  white-space: nowrap;
  vertical-align: middle;
  animation: pulse-playing 2s infinite ease-in-out;
}

@keyframes pulse-playing {
  0%, 100% {
    opacity: 1;
    border-color: rgba(59, 130, 246, 0.6);
  }
  50% {
    opacity: 0.7;
    border-color: rgba(59, 130, 246, 0.25);
  }
}

.ch-logo-mini {
  width: 36px;
  height: 36px;
  background-color: var(--bg-secondary);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-weight: bold;
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

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

.ch-top-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.ch-now-show {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.15rem;
}

/* ========================================================== */
/* TAB 2: MODERN TV-STYLE EPG TIMELINE GRID                   */
/* ========================================================== */
.epg-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
}

.epg-toolbar {
  min-height: 52px;
  padding: 0.4rem 1.25rem;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 0.75rem;
  position: relative;
  z-index: 20;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 0 1 auto;
}

.epg-search-container {
  position: relative;
  width: 260px;
}

.epg-search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.epg-search-icon {
  position: absolute;
  left: 0.65rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  pointer-events: none;
  user-select: none;
}

.epg-search-input {
  width: 100%;
  padding: 0.32rem 1.8rem 0.32rem 1.95rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-main);
  font-size: 0.8rem;
  transition: all 0.15s ease;
  outline: none;
}

.epg-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
  background-color: rgba(24, 34, 52, 0.95);
}

.epg-search-clear {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.05rem 0.25rem;
  line-height: 1;
  border-radius: 4px;
}

.epg-search-clear:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

.epg-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 460px;
  max-width: 90vw;
  max-height: 480px;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.epg-search-dropdown-header {
  padding: 0.45rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.epg-search-dropdown-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.epg-search-result-item {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  gap: 0.75rem;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.epg-search-result-item:hover {
  background-color: var(--bg-hover);
}

.epg-search-result-item:last-child {
  border-bottom: none;
}

.epg-search-ch-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  max-width: 58px;
  flex-shrink: 0;
  text-align: center;
}

.epg-search-ch-num {
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--bg-card);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.epg-search-ch-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  margin-top: 0.15rem;
}

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

.epg-search-prog-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.epg-search-live-tag {
  font-size: 0.62rem;
  font-weight: 700;
  color: #10b981;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.epg-search-prog-time {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 0.12rem;
}

.epg-search-actions {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.epg-search-actions .btn {
  padding: 0.22rem 0.45rem;
  font-size: 0.72rem;
}

/* In-grid highlight when search query is active */
.epg-event-block.search-matched {
  border: 2px solid var(--accent) !important;
  background-color: rgba(59, 130, 246, 0.35) !important;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.6) !important;
  z-index: 10 !important;
  opacity: 1 !important;
}

.epg-event-block.search-dimmed {
  opacity: 0.25 !important;
  filter: grayscale(60%);
}

.epg-event-block.pulse-highlight {
  animation: pulseBlock 1.5s 3 ease-in-out;
}

@keyframes pulseBlock {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.8);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 20px 4px rgba(59, 130, 246, 0.9);
    transform: scale(1.02);
  }
}

.epg-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.epg-title {
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
  margin: 0;
}

.epg-live-clock {
  font-size: 0.85rem;
  background: var(--bg-card);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius);
  font-family: monospace;
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.05em;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.epg-day-selector {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.25rem;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.15rem 0;
}

.epg-day-selector::-webkit-scrollbar {
  height: 4px;
}

.epg-day-selector::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.epg-day-selector::-webkit-scrollbar-track {
  background: transparent;
}

.day-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
  user-select: none;
}

.day-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.day-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 1px 4px rgba(59, 130, 246, 0.4);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.epg-nav-btn {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0.25rem 0.55rem;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: 6px;
  line-height: 1.25;
}

.toolbar-right #btn-epg-now {
  padding: 0.25rem 0.65rem;
}

.toolbar-right #btn-epg-refresh {
  padding: 0.25rem 0.45rem;
  font-size: 0.8rem;
  line-height: 1.15;
}

.epg-timeline-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

/* Sticky Timeline Header */
.epg-timeline-header {
  height: 42px;
  display: flex;
  background-color: var(--bg-secondary);
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

.epg-header-corner {
  width: var(--ch-col-width);
  min-width: var(--ch-col-width);
  border-right: 2px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 0.65rem;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-muted);
  background-color: var(--bg-secondary);
  z-index: 10;
}

.epg-time-ruler-scroll {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.epg-time-ruler {
  display: flex;
  height: 100%;
  position: relative;
}

.ruler-slot {
  width: var(--hour-width);
  min-width: var(--hour-width);
  height: 100%;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  padding-left: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.ruler-slot .ruler-date-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  margin-right: 0.4rem;
  font-weight: 800;
  letter-spacing: 0.025em;
}

/* Grid Scroll Area (Channels on Left, Events on Right) */
.epg-grid-scroll {
  flex: 1;
  display: flex;
  overflow: auto;
  position: relative;
  width: 100%;
  cursor: grab;
  will-change: scroll-position;
}

.epg-grid-scroll.is-dragging {
  cursor: grabbing !important;
  user-select: none !important;
}

.epg-grid-scroll.is-dragging * {
  pointer-events: none !important;
  user-select: none !important;
}

.epg-events-canvas {
  flex: 1;
  min-width: calc(100% - var(--ch-col-width));
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  height: max-content;
}

.epg-channels-column {
  width: var(--ch-col-width);
  min-width: var(--ch-col-width);
  background-color: var(--bg-secondary);
  border-right: 2px solid var(--border);
  position: sticky;
  left: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  height: max-content;
}

.epg-channel-cell {
  height: var(--epg-row-height);
  min-height: var(--epg-row-height);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 0.45rem;
  cursor: pointer;
  background-color: var(--bg-secondary);
  transition: background-color 0.15s ease;
  contain: layout;
  content-visibility: auto;
  contain-intrinsic-size: auto var(--epg-row-height);
}

.epg-channel-cell:hover {
  background-color: var(--bg-hover);
}

.epg-ch-cell-info {
  overflow: hidden;
  min-width: 0;
  width: 100%;
}

.epg-ch-cell-name {
  font-weight: 600;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.epg-ch-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.epg-events-canvas {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
}

.epg-rows-container {
  display: flex;
  flex-direction: column;
}

.epg-channel-row-track {
  height: var(--epg-row-height);
  min-height: var(--epg-row-height);
  border-bottom: 1px solid var(--border);
  position: relative;
  display: flex;
  contain: layout;
  content-visibility: auto;
  contain-intrinsic-size: auto var(--epg-row-height);
}

.epg-channel-row-track.is-playing {
  background: rgba(59, 130, 246, 0.05);
  border-bottom: 1px solid rgba(59, 130, 246, 0.3);
}

.epg-channel-row-track.is-playing .epg-event-block.active-now {
  border: 1px solid var(--accent);
  border-left: 4px solid var(--accent);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.22) 0%, var(--bg-card) 100%);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.25);
}

.epg-event-block {
  position: absolute;
  top: 4px;
  bottom: 4px;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  overflow: hidden;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.epg-event-block:hover {
  background-color: var(--bg-hover);
  border-color: var(--accent);
  z-index: 3;
}

.epg-event-block.active-now {
  border-left: 3px solid var(--accent);
  background-color: rgba(59, 130, 246, 0.12);
}

.epg-event-block.epg-block-recording {
  border-left: 3px solid #ef4444;
  background-color: rgba(239, 68, 68, 0.15);
}

.epg-event-block.epg-block-scheduled {
  border-left: 3px solid #f59e0b;
  background-color: rgba(245, 158, 11, 0.1);
}

.epg-block-rec-badge {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  margin-right: 0.35rem;
  display: inline-flex;
  align-items: center;
}

.epg-block-sched-badge {
  margin-right: 0.3rem;
  font-size: 0.72rem;
}

.epg-block-title {
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.epg-block-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Red Live NOW Indicator Line */
.epg-now-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: var(--danger);
  z-index: 4;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}

.now-marker-badge {
  position: sticky;
  top: 4px;
  left: -18px;
  background-color: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

/* ========================================================== */
/* TAB 3: SETTINGS                                            */
/* ========================================================== */
.settings-container {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.settings-col {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-col.full-width {
  grid-column: 1 / -1;
}

.channel-manager-card .channel-admin-table {
  max-height: 540px;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.settings-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-primary {
  background-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-secondary {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.btn-danger {
  background-color: var(--danger);
  color: #fff;
}

/* Tuner Item Card */
.tuner-item {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 0.6rem;
}

.tuner-item.tuner-recording-active {
  border-color: rgba(239, 68, 68, 0.45);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.05), var(--bg-secondary));
}

.tuner-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tuner-left-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tuner-name {
  font-weight: 600;
}

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

.tuner-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--bg-hover);
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.viewers-box {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.viewer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.viewer-ip {
  color: var(--warning);
  font-weight: 600;
}

/* Channel Admin Table */
.channel-admin-table {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.drag-handle {
  cursor: grab;
  font-size: 1.2rem;
  color: var(--text-muted);
  user-select: none;
  padding: 0 0.4rem 0 0.1rem;
  transition: color 0.15s ease;
  line-height: 1;
}

.drag-handle:hover {
  color: var(--accent);
}

.admin-channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-secondary);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  user-select: none;
}

.admin-channel-row.dragging {
  opacity: 0.35;
  background-color: var(--bg-card);
  border: 1px dashed var(--accent);
}

.admin-channel-row.drag-over-above {
  border-top: 2px solid var(--accent);
}

.admin-channel-row.drag-over-below {
  border-bottom: 2px solid var(--accent);
}

.admin-ch-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-ch-info {
  display: flex;
  flex-direction: column;
}

.admin-ch-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.admin-ch-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* External Players & Media Servers Integration */
.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.integration-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.integration-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.integration-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.copy-input-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.copy-input-group .form-input {
  flex: 1;
  min-width: 240px;
}

.code-font {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  color: #38bdf8 !important;
}

.btn-copy {
  white-space: nowrap;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-row label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.readonly {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  overflow-y: auto;
}

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 540px;
  width: 100%;
  max-height: calc(100vh - 2.5rem);
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  position: relative;
}

.modal-confirm-card {
  max-width: 440px;
}

.confirm-modal-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-main);
  margin: 0;
  padding: 0.5rem 0;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background-color: var(--bg-card);
  z-index: 2;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  padding-right: 0.75rem;
  line-height: 1.3;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.modal-close-btn:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.1);
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
  overscroll-behavior: contain;
}

.modal-desc {
  line-height: 1.6;
  white-space: pre-line;
  color: var(--text-main);
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.conflict-details {
  background-color: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin: 1rem 0;
  font-size: 0.85rem;
}

/* ========================================================== */
/* CHANNEL SCANNER MODERN STYLES                              */
/* ========================================================== */
.card-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.badge-system {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.scanner-controls-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0 0.5rem 0;
  flex-wrap: wrap;
}

.btn-scan {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  padding: 0.65rem 1.4rem;
  font-size: 0.95rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
  cursor: pointer;
}

.btn-scan:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}

.btn-scan:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.scan-mode-tabs {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  flex-wrap: wrap;
}

.scan-mode-tab {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.scan-mode-tab:hover {
  color: var(--text-main);
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

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

.scan-mode-panel {
  margin-bottom: 1.25rem;
  background: rgba(255, 255, 255, 0.02);
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.scan-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.scan-form-grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

@media (max-width: 640px) {
  .scan-form-grid, .scan-form-grid-3 {
    grid-template-columns: 1fr;
  }
}

.scan-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.scan-form-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.scan-panel-info {
  margin-top: 0.65rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.scan-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: scanSpin 0.8s linear infinite;
  display: inline-block;
}

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

.scan-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  font-size: 0.85rem;
  color: var(--accent);
}

.scan-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: scanPulse 1.5s infinite;
}

@keyframes scanPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}

.scan-progress-box {
  margin-top: 1.25rem;
  padding: 1.25rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.scan-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.scan-info-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

.scan-info-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.scan-found-pill {
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--success);
  font-weight: 600;
  font-size: 0.8rem;
}

.scan-pct-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  min-width: 40px;
  text-align: right;
}

.scan-progress-track {
  width: 100%;
  height: 10px;
  background: var(--bg-primary);
  border-radius: 9999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.scan-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa, #34d399);
  border-radius: 9999px;
  transition: width 0.3s ease-out;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.5);
}

.scan-live-ticker-wrap {
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.scan-ticker-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lock-pill {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.4);
  font-weight: 700;
}

.scan-live-ticker {
  min-height: 52px;
  max-height: 120px;
  overflow-y: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-content: flex-start;
}

.ticker-placeholder {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
  display: flex;
  align-items: center;
  height: 100%;
}

.ticker-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.82rem;
  font-weight: 500;
  animation: slideInUp 0.3s ease-out;
}

.ticker-badge .t-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.scan-results-box {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.scan-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.scan-results-title h4 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.2rem;
}

.scan-summary-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.scan-stats-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.stat-pill {
  font-size: 0.82rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent;
}

.stat-pill:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.stat-pill.active {
  box-shadow: 0 0 0 2px var(--accent);
  filter: brightness(1.25);
  font-weight: 700;
  transform: translateY(-1px);
}

.stat-discovered {
  background-color: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.35);
}

.stat-new {
  background-color: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.35);
}

.stat-updated {
  background-color: rgba(147, 51, 234, 0.18);
  color: #c084fc;
  border-color: rgba(147, 51, 234, 0.35);
}

.stat-missing {
  background-color: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
}

.scan-filter-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.scan-search-wrap {
  width: 100%;
  max-width: 320px;
}

.scan-search-input {
  width: 100%;
  padding: 0.42rem 0.85rem;
  font-size: 0.85rem;
  border-radius: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-main);
  transition: border-color 0.15s ease;
}

.scan-search-input:focus {
  border-color: var(--accent);
  outline: none;
}

.epg-search-hl {
  background: rgba(245, 158, 11, 0.35);
  color: #fef08a;
  border-radius: 2px;
  padding: 0 2px;
}

.scan-channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.scan-channel-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  transition: all 0.2s ease;
}

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

.scan-channel-card.is-new {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.06);
}

.scan-channel-card.is-new:hover {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.12);
}

.scan-ch-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.scan-ch-num {
  min-width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-main);
  flex-shrink: 0;
}

.scan-ch-details {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

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

.scan-ch-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.scan-ch-badges {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.badge-new {
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.5);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  animation: pulseGreen 2s infinite;
}

.badge-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.missing-channels-alert {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.missing-alert-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.missing-alert-title {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.missing-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.missing-alert-title strong {
  color: #f87171;
  font-size: 0.95rem;
  display: block;
}

.missing-alert-title p {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 0.2rem;
}

.missing-cards-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.missing-ch-tag {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 0.82rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-weight: 500;
}

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

@keyframes pulseGreen {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0); }
}

.hidden {
  display: none !important;
}

/* ========================================================== */
/* RESPONSIVE BREAKPOINTS: EPG TOOLBAR & SMALL SCREENS        */
/* ========================================================== */
@media (max-width: 1080px) {
  .epg-toolbar {
    flex-wrap: wrap;
    height: auto;
    min-height: unset;
    padding: 0.45rem 1rem;
    gap: 0.4rem 0.75rem;
  }

  .epg-search-container {
    width: 220px;
  }

  .toolbar-left {
    order: 1;
    flex: 0 1 auto;
  }

  .toolbar-right {
    order: 2;
    flex: 0 1 auto;
    margin-left: auto;
  }

  .epg-day-selector {
    order: 3;
    width: 100%;
    flex: 1 0 100%;
    margin-left: 0;
    padding: 0.25rem 0 0.1rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }
}

@media (max-width: 768px) {
  .epg-toolbar {
    padding: 0.4rem 0.6rem;
    gap: 0.35rem;
  }

  .toolbar-left {
    order: 1;
    width: 100%;
    flex: 1 0 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }

  .epg-title-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .epg-search-container {
    width: 100%;
    margin-top: 0;
    position: relative;
  }

  .epg-search-dropdown {
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    max-height: 52vh;
  }

  .toolbar-right {
    order: 2;
    width: 100%;
    flex: 1 0 100%;
    display: flex;
    justify-content: space-between;
    margin-left: 0;
    gap: 0.3rem;
  }

  .toolbar-right .epg-nav-btn {
    flex: 1;
    text-align: center;
    justify-content: center;
    padding: 0.28rem 0.35rem;
    font-size: 0.74rem;
  }

  .epg-day-selector {
    order: 3;
    width: 100%;
    flex: 1 0 100%;
    margin-left: 0;
    padding: 0.2rem 0 0.05rem 0;
  }
}

@media (max-width: 860px) {
  :root {
    --ch-col-width: 90px;
    --epg-row-height: 56px;
  }

  /* Header */
  .app-header {
    height: auto;
    padding: 0.5rem 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .header-left {
    gap: 0.5rem;
  }

  .logo h1 {
    font-size: 1rem;
  }

  .header-nav {
    order: 3;
    width: 100%;
    display: flex;
    justify-content: space-around;
    padding-top: 0.35rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .nav-btn {
    flex: 1;
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    justify-content: center;
  }

  /* Live TV Tab: Channel list moves below video */
  .tv-layout {
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
  }

  .video-container {
    flex: none;
    width: 100%;
    height: var(--mobile-video-height, min(56.25vw, 68vh));
    min-height: 180px;
    max-height: 82vh;
    transition: height 0.25s ease;
    position: relative;
  }

  .video-screen {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  .video-container:has(.active-stage.ar-4-3) {
    height: var(--mobile-video-height, min(75vw, 75vh));
  }

  .video-container:fullscreen,
  #video-wrapper:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-height: none !important;
    position: fixed !important;
    inset: 0 !important;
    display: block !important;
  }

  .video-container:fullscreen .video-screen,
  #video-wrapper:fullscreen .video-screen {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
  }

  .video-container:fullscreen .stream-alert,
  #video-wrapper:fullscreen .stream-alert {
    position: absolute !important;
    top: 1rem !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    max-width: 90% !important;
    border-radius: var(--radius) !important;
  }

  .video-container:fullscreen .video-osd,
  #video-wrapper:fullscreen .video-osd {
    position: absolute !important;
    top: clamp(0.5rem, 2vmin, 1.5rem) !important;
    left: clamp(0.5rem, 2vmin, 1.5rem) !important;
    width: clamp(230px, 32vmin + 80px, 600px) !important;
    max-width: calc(100% - clamp(1rem, 4vmin, 3rem)) !important;
    border-radius: clamp(6px, 1vmin, 12px) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
  }

  .video-container:fullscreen .player-bottom-bar,
  #video-wrapper:fullscreen .player-bottom-bar {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
  }

  .video-osd {
    top: clamp(0.35rem, 1.5vmin, 0.75rem);
    left: clamp(0.35rem, 1.5vmin, 0.75rem);
    width: clamp(200px, 70vmin, calc(100% - 1rem));
    max-width: calc(100% - 1rem);
    padding: clamp(0.35rem, 1vmin, 0.6rem) clamp(0.5rem, 1.5vmin, 0.8rem);
  }

  .osd-number-name {
    font-size: clamp(0.8rem, 2vmin, 0.95rem);
  }

  .osd-show-title {
    font-size: clamp(0.72rem, 1.7vmin, 0.85rem);
  }

  .channel-sidebar {
    width: 100%;
    flex: 1;
    border-left: none;
    border-top: 1px solid var(--border);
    min-height: 280px;
    overflow-y: visible;
  }

  .channel-list {
    overflow-y: visible;
  }

  /* Compact & wrapping controls on mobile */
  .player-controls {
    height: auto;
    min-height: 44px;
    padding: 0.35rem 0.6rem;
    gap: 0.35rem 0.5rem;
    flex-wrap: wrap;
  }

  .ctrl-btn {
    font-size: 1rem;
    padding: 0.2rem 0.35rem;
  }

  .vol-slider {
    width: 50px;
  }

  #latency-tag {
    display: none !important;
  }

  /* TV Guide Tab */
  .epg-toolbar {
    padding: 0.4rem 0.75rem;
    gap: 0.35rem 0.5rem;
  }

  .epg-title {
    font-size: 1.05rem;
  }

  .epg-live-clock {
    font-size: 0.8rem;
    padding: 0.18rem 0.5rem;
  }


  .toolbar-right {
    gap: 0.35rem;
  }

  .toolbar-right .btn {
    padding: 0.28rem 0.55rem;
    font-size: 0.76rem;
  }

  .day-btn {
    font-size: 0.72rem;
    padding: 0.22rem 0.55rem;
  }

  .epg-channel-cell {
    padding: 0 0.4rem;
  }

  .epg-ch-cell-name {
    font-size: 0.75rem;
  }

  /* Settings Tab */
  .settings-container {
    grid-template-columns: 1fr;
    padding: 0.75rem;
    gap: 1rem;
  }

  .settings-col.full-width {
    grid-column: 1;
  }

  .form-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .form-row label {
    width: 100%;
  }

  .form-input, .form-select {
    width: 100%;
  }
}

@media (max-width: 600px) {
  :root {
    --ch-col-width: 62px;
    --epg-row-height: 50px;
  }

  .epg-timeline-header {
    height: 36px;
  }

  .epg-header-corner {
    padding: 0 0.15rem;
    font-size: 0.7rem;
    font-weight: 700;
    justify-content: center;
    text-align: center;
    letter-spacing: -0.02em;
  }

  .ruler-slot {
    font-size: 0.72rem;
    padding-left: 0.3rem;
  }

  .ruler-slot .ruler-date-badge {
    font-size: 0.6rem;
    padding: 0.1rem 0.3rem;
    margin-right: 0.25rem;
  }

  /* Compact Channel Column */
  .epg-channel-cell {
    padding: 0.2rem 0.15rem;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 0.1rem;
  }

  .epg-ch-cell-info {
    width: 100%;
    overflow: hidden;
    display: flex;
    justify-content: center;
  }

  .epg-ch-cell-name {
    font-size: 0.68rem;
    font-weight: 600;
    max-width: 58px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    line-height: 1.15;
  }

  .epg-ch-cell-name .badge {
    margin-right: 0 !important;
    font-size: 0.62rem !important;
    padding: 0.05rem 0.25rem !important;
  }

  .epg-playing-badge {
    display: none !important;
  }

  .epg-channel-cell.is-playing {
    border-left: 3px solid var(--accent);
    background: rgba(59, 130, 246, 0.18);
  }

  /* Compact Event Blocks */
  .epg-event-block {
    top: 2px;
    bottom: 2px;
    padding: 0.2rem 0.35rem;
    border-radius: 4px;
  }

  .epg-block-title {
    font-size: 0.72rem;
    line-height: 1.15;
  }

  .epg-block-time {
    font-size: 0.62rem;
    margin-top: 0.05rem;
  }

  /* Compact Search Dropdown Results on Mobile */
  .epg-search-dropdown {
    max-height: 50vh;
  }

  .epg-search-dropdown-header {
    padding: 0.35rem 0.55rem;
    font-size: 0.68rem;
  }

  .epg-search-result-item {
    padding: 0.45rem 0.55rem;
    gap: 0.4rem;
  }

  .epg-search-ch-badge {
    min-width: 38px;
    max-width: 38px;
  }

  .epg-search-ch-num {
    font-size: 0.64rem;
    padding: 0.05rem 0.2rem;
  }

  .epg-search-ch-name {
    font-size: 0.64rem;
  }

  .epg-search-prog-title {
    font-size: 0.78rem;
    gap: 0.25rem;
  }

  .epg-search-live-tag {
    font-size: 0.55rem;
    padding: 0.03rem 0.2rem;
  }

  .epg-search-prog-time {
    font-size: 0.64rem;
  }

  .epg-search-actions {
    gap: 0.2rem;
  }

  .epg-search-actions .btn {
    padding: 0.18rem 0.35rem;
    font-size: 0.66rem;
  }
}

@media (max-width: 520px) {
  .epg-toolbar {
    padding: 0.35rem 0.5rem;
    gap: 0.35rem;
  }

  .toolbar-left {
    order: 1;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .epg-title-group {
    width: 100%;
    justify-content: space-between;
  }

  .epg-title {
    font-size: 0.95rem;
  }

  .epg-live-clock {
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
  }

  .toolbar-right {
    order: 2;
    width: 100%;
    margin-left: 0;
    display: flex;
    gap: 0.35rem;
  }

  .toolbar-right .epg-nav-btn {
    flex: 1;
    justify-content: center;
    text-align: center;
    padding: 0.32rem 0.35rem;
    font-size: 0.74rem;
  }

  .epg-day-selector {
    order: 3;
    width: 100%;
    padding: 0.2rem 0 0.05rem 0;
  }

  .day-btn {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }
}

/* ==========================================================================
   Mobile Stacked Layout (Sufficient Height Available)
   Moves OSD & Alerts ABOVE the video, and Timeshift & Controls BELOW the video,
   leaving the broadcast video 100% clean and unobstructed.
   ========================================================================== */
@media (max-width: 860px) and (min-height: 520px) {
  .video-container:not(:fullscreen) {
    flex: none;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark, #0b0f19);
    container-type: normal;
  }

  /* Above the video: Stream Alert Banner */
  .video-container:not(:fullscreen) .stream-alert {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    box-sizing: border-box;
    margin: 0;
    order: 1;
  }

  /* Above the video: Video OSD (Channel & Program Header) */
  .video-container:not(:fullscreen) .video-osd {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
    border-left: none;
    border-right: none;
    border-top: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.95);
    padding: 0.5rem 0.8rem;
    box-sizing: border-box;
    order: 2;
    z-index: 5;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .video-container:not(:fullscreen) .video-osd.controls-autohidden {
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    pointer-events: auto !important;
  }

  /* Video Screen Surface: perfectly clean & unobstructed */
  .video-container:not(:fullscreen) .video-screen {
    position: relative;
    width: 100%;
    height: var(--mobile-video-height, min(56.25vw, 48vh));
    min-height: 180px;
    max-height: 52vh;
    background: #000;
    flex: none;
    order: 3;
  }

  .video-container:not(:fullscreen):has(.active-stage.ar-4-3) .video-screen {
    height: var(--mobile-video-height, min(75vw, 55vh));
  }

  /* Below the video: Unified Player Bottom Bar */
  .video-container:not(:fullscreen) .player-bottom-bar {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    width: 100%;
    order: 4;
    background: rgba(15, 23, 42, 0.96);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .video-container:not(:fullscreen) .player-bottom-bar.controls-autohidden {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .video-container:not(:fullscreen) .timeshift-bar {
    position: relative;
    width: 100%;
    background: transparent;
    border-top: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  }

  .video-container:not(:fullscreen) .player-controls {
    position: relative;
    width: 100%;
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 0.35rem 0.6rem;
  }

  .channel-sidebar {
    border-top: none;
  }
}

/* Responsive Controls Width Adaptability */
@media (max-width: 1050px) {
  .vol-slider {
    width: 50px;
  }
  .rec-btn .rec-text {
    display: none;
  }
  .ts-btn-label {
    display: none;
  }
}

@media (max-width: 680px) {
  .player-controls {
    padding: 0.3rem 0.5rem;
    gap: 0.3rem 0.4rem;
  }

  .vol-slider {
    width: 45px;
  }

  .rec-btn {
    padding: 0.22rem 0.4rem;
  }

  .rec-btn .rec-text {
    display: none;
  }

  .ctrl-btn {
    padding: 0.22rem 0.35rem;
    font-size: 0.85rem;
  }

  .track-select-btn {
    padding: 0.22rem 0.4rem;
    font-size: 0.76rem;
  }

  .aspect-btn,
  .teletext-ctrl-btn,
  .hbbtv-ctrl-btn {
    padding: 0.22rem 0.4rem;
    font-size: 0.76rem;
  }

  .timeshift-bar {
    padding: 0 0.5rem;
    gap: 0.35rem;
  }

  .timeshift-btn {
    padding: 0.18rem 0.35rem;
    font-size: 0.74rem;
  }
}

@media (max-width: 480px) {
  .player-spacer {
    display: none;
  }

  .vol-slider {
    width: 42px;
  }

  .player-controls {
    padding: 0.3rem 0.4rem;
    gap: 0.25rem 0.35rem;
  }

  .ctrl-btn {
    font-size: 0.92rem;
    padding: 0.2rem 0.28rem;
  }

  .ts-btn-label {
    display: none;
  }

  .timeshift-live-pill {
    padding: 0.15rem 0.35rem;
    font-size: 0.7rem;
  }

  .track-menu {
    max-width: 90vw;
  }
}

/* ==========================================================================
   Player Track Selectors & Instant Recording
   ========================================================================== */
.track-dropdown-wrap {
  position: relative;
}

.track-select-btn {
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  color: var(--text-main);
  transition: all 0.2s ease;
}

.track-select-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
}

.track-select-btn.has-active {
  border-color: var(--accent);
  color: #fff;
  background: rgba(59, 130, 246, 0.2);
}

.track-select-btn.track-switching {
  opacity: 0.85;
  pointer-events: none;
  border-color: var(--accent);
  animation: trackBtnPulse 0.7s infinite alternate ease-in-out;
}

@keyframes trackBtnPulse {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(0.96); opacity: 1; filter: brightness(1.2); }
}

.track-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 170px;
  max-width: min(320px, 92vw);
  max-height: 60vh;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.track-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.track-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.track-item.active {
  background-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.track-item.disabled {
  cursor: default;
  opacity: 0.55;
  background: transparent;
  pointer-events: none;
}

.track-item.disabled:hover {
  background: transparent;
}

.track-item-tag {
  font-size: 0.7rem;
  opacity: 0.75;
  margin-left: 0.5rem;
}

/* Instant Record Button */
.rec-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: var(--radius);
  color: #fca5a5;
  transition: all 0.2s ease;
}

.rec-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: var(--danger);
  color: #fff;
}

.rec-btn .rec-dot {
  color: var(--danger);
  font-size: 1rem;
  line-height: 1;
}

.rec-btn.rec-active {
  background: var(--danger);
  border-color: #dc2626;
  color: #fff;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
  animation: rec-glow 2s infinite;
}

.rec-btn.rec-active .rec-dot {
  color: #fff;
  animation: rec-pulse 1s infinite alternate;
}

@keyframes rec-pulse {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

@keyframes rec-glow {
  0% { box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 16px rgba(239, 68, 68, 0.8); }
  100% { box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }
}

/* ==========================================================================
   DVR & Recordings Screen
   ========================================================================== */
.recordings-screen {
  padding: 1.5rem 2rem;
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  overflow-y: auto;
  height: calc(100vh - 60px);
}

.recordings-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.recordings-title-group h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 0.25rem 0;
  color: var(--text-main);
}

.recordings-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.recordings-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* DVR Overview & Storage Statistics Bar */
.dvr-stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

@media (max-width: 900px) {
  .dvr-stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .dvr-stats-bar {
    grid-template-columns: 1fr;
  }
}

.dvr-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.dvr-stat-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.dvr-stat-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.dvr-stat-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.dvr-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.dvr-stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sections & Two-Column Split Layout */
.recordings-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.recordings-top-split {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .recordings-top-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: start;
  }

  .recordings-top-split .recordings-grid {
    grid-template-columns: 1fr;
  }
}

.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.rec-filter-count {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.section-badge-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.section-badge-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.section-badge-header .badge {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  display: inline-block;
}

.live-dot.pulse {
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  animation: dot-pulse 1.5s infinite;
}

@keyframes dot-pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Filter and Search Bar */
.recordings-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
}

.rec-search-box {
  flex: 1;
  min-width: 220px;
  position: relative;
  display: flex;
  align-items: center;
}

.rec-search-input {
  width: 100%;
  padding: 0.45rem 2rem 0.45rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.rec-search-input:focus {
  border-color: var(--accent);
}

.btn-clear-search {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  font-size: 0.8rem;
}

.rec-filter-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.rec-filter-select {
  padding: 0.45rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
}

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

/* Recordings Grid: Strictly Two Columns on Bigger Screens */
.recordings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.empty-grid {
  display: block;
}

.empty-state {
  padding: 1.5rem 1.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
}

/* Rich Recording Cards */
.recording-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.recording-card:hover {
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.recording-card.card-active {
  border-color: var(--danger);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), var(--bg-card));
}

.rec-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.rec-card-title-wrap {
  flex: 1;
  min-width: 0;
}

.rec-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 0.35rem 0;
  line-height: 1.35;
  color: var(--text-main);
  word-break: break-word;
}

.rec-card-channel-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.rec-status-tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.rec-status-tag.active {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.rec-status-tag.scheduled {
  background: rgba(234, 179, 8, 0.15);
  color: #fde047;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.rec-status-tag.completed {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.rec-status-tag.failed {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.rec-card-desc {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rec-card-body {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.rec-meta-grid {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.85rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.rec-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Active Recording Progress Bar */
.rec-progress-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 0.25rem;
}

.rec-progress-bar {
  height: 100%;
  background: linear-gradient(to right, #ef4444, #f87171);
  border-radius: 9999px;
  transition: width 1s linear;
}

.rec-card-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
}

.btn-rec-action {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-rec-action:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-rec-action.play-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-rec-action.play-btn:hover {
  background: #2563eb;
}

.btn-rec-action.stop-btn, .btn-rec-action.del-btn {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-rec-action.stop-btn:hover, .btn-rec-action.del-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
}

/* Modal Player */
.modal-player-card {
  max-width: 900px;
  width: 95%;
}

.player-modal-body {
  padding: 0;
  background: #000;
  display: flex;
  justify-content: center;
}

.recording-video-element {
  width: 100%;
  max-height: 70vh;
  outline: none;
  background: #000;
}

@media (max-width: 768px) {
  .recordings-screen {
    padding: 1rem;
    gap: 1.25rem;
  }

  .recordings-grid {
    grid-template-columns: 1fr;
  }

  .track-select-btn {
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
  }
}

/* ========================================================== */
/* TIMESHIFT, RF ANALYZER, TELETEXT, HBBTV & SHORTCUTS HELP  */
/* ========================================================== */

/* Timeshift Scrubber & Live Controls Bar */
.timeshift-bar {
  position: relative;
  width: 100%;
  height: 38px;
  display: flex;
  align-items: center;
  padding: 0 0.85rem;
  gap: 0.55rem;
  background: transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 10;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.timeshift-bar.controls-autohidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.timeshift-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 6px;
  padding: 0.22rem 0.45rem;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.timeshift-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

#btn-timeshift-playpause {
  width: 28px;
  height: 28px;
  padding: 0;
  justify-content: center;
  font-size: 0.85rem;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
  color: #93c5fd;
}

#btn-timeshift-playpause:hover {
  background: rgba(59, 130, 246, 0.35);
  border-color: var(--accent);
}

.timeshift-track-wrap {
  flex: 1;
  min-width: 70px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.timeshift-slider {
  width: 100%;
  height: 5px;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 9999px;
  outline: none;
  cursor: pointer;
  transition: height 0.15s ease;
}

.timeshift-slider:hover {
  height: 7px;
}

.timeshift-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(0,0,0,0.7), 0 0 0 2px rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.timeshift-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

.timeshift-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(0,0,0,0.7), 0 0 0 2px rgba(255, 255, 255, 0.3);
  cursor: pointer;
}

.timeshift-time-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.75);
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.timeshift-live-pill {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  border-radius: 12px;
  padding: 0.18rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  letter-spacing: 0.04em;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.timeshift-live-pill.is-live {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

.live-dot {
  font-size: 0.65rem;
  animation: pulse-dot 1.5s infinite;
}

/* Real-Time RF Signal Analyzer HUD Overlay */
.rf-analyzer-overlay {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: min(380px, calc(100% - 2rem));
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  z-index: 25;
  color: var(--text-main);
  animation: fadeIn 0.2s ease;
}

.rf-analyzer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.rf-analyzer-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.rf-chip {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.rf-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}
.rf-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.rf-analyzer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.rf-metric-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
}

.rf-metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.rf-metric-val {
  font-size: 0.9rem;
  font-weight: 700;
  font-family: monospace;
}

.rf-subval {
  font-size: 0.75rem;
  font-weight: 400;
  color: #93c5fd;
}

.rf-bar-bg {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.25rem;
}

.rf-bar-fill {
  height: 100%;
  background: linear-gradient(to right, #eab308, #22c55e);
  transition: width 0.3s ease;
}

.rf-lock-flags {
  display: flex;
  gap: 0.35rem;
  justify-content: space-between;
  margin-bottom: 0.65rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.35rem;
  border-radius: 6px;
}

.rf-flag {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  flex: 1;
  text-align: center;
  transition: all 0.2s ease;
}

.rf-flag.locked,
.rf-flag.active {
  background: rgba(34, 197, 94, 0.25);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.5);
  text-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

.rf-multiplex-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Retro Teletext CRT Screen Overlay */
.teletext-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.teletext-window {
  width: min(720px, 100%);
  height: min(540px, 95%);
  background: #000;
  border: 3px solid #333;
  box-shadow: 0 0 28px rgba(0, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  font-family: 'Courier New', Courier, monospace;
}

.teletext-header {
  background: #000;
  border-bottom: 2px solid #333;
  color: #00ffff;
  font-weight: bold;
  padding: 0.5rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  letter-spacing: 0.1em;
}

.teletext-title {
  color: #ffff00;
}

.teletext-close-btn {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 1.1rem;
}

.teletext-screen {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  color: #ffffff;
  background: #000;
  line-height: 1.45;
  white-space: pre-wrap;
  font-size: 0.95rem;
  text-shadow: 0 0 2px rgba(255,255,255,0.4);
}

.teletext-controls {
  background: #111;
  padding: 0.5rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #333;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.teletext-nav-row {
  display: flex;
  gap: 0.4rem;
}

.txt-btn-color {
  border: none;
  padding: 0.25rem 0.6rem;
  font-family: inherit;
  font-weight: bold;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 2px;
}
.txt-red { background: #ef4444; color: #fff; }
.txt-green { background: #22c55e; color: #000; }
.txt-yellow { background: #eab308; color: #000; }
.txt-blue { background: #3b82f6; color: #fff; }

.teletext-input-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #ccc;
  font-size: 0.8rem;
}

.teletext-page-input {
  width: 60px;
  background: #222;
  border: 1px solid #444;
  color: #ffff00;
  font-family: inherit;
  font-weight: bold;
  padding: 0.2rem 0.4rem;
  text-align: center;
}

/* Shortcuts Modal */
.shortcuts-modal-card {
  max-width: 620px;
  width: 90%;
}

.shortcuts-modal-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  padding: 1.25rem;
}

@media (max-width: 640px) {
  .shortcuts-modal-body {
    grid-template-columns: 1fr;
  }
}

.shortcuts-section h4 {
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.25rem;
}

.shortcut-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
  gap: 0.5rem;
}

.shortcut-keys kbd {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 0.15rem 0.35rem;
  font-size: 0.75rem;
  font-family: monospace;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.shortcut-desc {
  color: var(--text-muted);
  text-align: right;
}

/* HbbTV Modal */
.hbbtv-modal-card {
  max-width: min(96vw, 1480px);
  width: min(96vw, 1480px);
  height: min(94vh, calc(96vw * 9 / 16 + 64px));
  max-height: 920px;
  display: flex;
  flex-direction: column;
}

.hbbtv-modal-body {
  flex: 1;
  padding: 0;
  position: relative;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hbbtv-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.hbbtv-remote-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  margin-right: 12px;
}

.btn-color-pill {
  border: none;
  border-radius: 9999px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  user-select: none;
}

.btn-color-pill:hover {
  transform: translateY(-1px);
  filter: brightness(1.15);
}

.btn-color-pill:active {
  transform: translateY(1px);
  filter: brightness(0.9);
}

.btn-red {
  background: #e50914;
  color: #fff;
}

.btn-green {
  background: #22c55e;
  color: #052e16;
}

.btn-yellow {
  background: #eab308;
  color: #422006;
}

.btn-blue {
  background: #3b82f6;
  color: #fff;
}

.btn-back {
  background: #475569;
  color: #f8fafc;
}

.hbbtv-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.padding-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.padding-col {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* Control Bar Buttons for Teletext, HbbTV, and Shortcuts Help */
.teletext-ctrl-btn,
.hbbtv-ctrl-btn {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.28rem 0.6rem;
  border-radius: var(--radius);
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.teletext-ctrl-btn {
  background: rgba(59, 130, 246, 0.22);
  border: 1px solid rgba(59, 130, 246, 0.55);
  color: #93c5fd;
}

.teletext-ctrl-btn:hover {
  background: rgba(59, 130, 246, 0.4);
  border-color: #60a5fa;
  color: #fff;
}

.hbbtv-ctrl-btn {
  background: rgba(239, 68, 68, 0.22);
  border: 1px solid rgba(239, 68, 68, 0.55);
  color: #fca5a5;
}

.hbbtv-ctrl-btn:hover {
  background: rgba(239, 68, 68, 0.4);
  border-color: #f87171;
  color: #fff;
}

.hbbtv-ctrl-btn .red-dot {
  width: 7px;
  height: 7px;
  background: #ef4444;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px #ef4444;
}

/* Fullscreen compatibility for Modals & Toasts mounted inside video container */
.video-container .modal {
  position: absolute;
  inset: 0;
  z-index: 1000;
  cursor: default !important;
}

.video-container .modal * {
  cursor: auto;
}

.video-container #app-toast {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
}

/* Subtitle Sync Controls */
.track-menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  margin: 6px 0;
}

.track-menu-section-title {
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted, #94a3b8);
  letter-spacing: 0.05em;
}

.sub-sync-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  margin: 2px 4px 6px 4px;
}

.btn-sync-adj {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-sync-adj:hover {
  background: #3b82f6;
  color: #fff;
  border-color: #60a5fa;
}

.btn-sync-adj:active {
  transform: scale(0.96);
}

.sub-sync-label {
  font-family: monospace;
  font-size: 0.82rem;
  font-weight: 700;
  color: #38bdf8;
  min-width: 44px;
  text-align: center;
}
