/* ==========================================================================
   Dabba TV - Apple TV Inspired Streaming Interface Stylesheet
   Design Philosophy: tvOS Materials, Frosted Glass, Capsule Controls, Squircles
   ========================================================================== */

:root {
  /* Apple tvOS Dark Palette */
  --bg-primary: #000000;
  --bg-secondary: #0a0a0d;
  --bg-surface: rgba(255, 255, 255, 0.05);
  --bg-surface-hover: rgba(255, 255, 255, 0.1);
  --bg-card: rgba(255, 255, 255, 0.035);
  --bg-card-hover: rgba(255, 255, 255, 0.09);
  --bg-glass: rgba(20, 20, 24, 0.72);
  --bg-glass-heavy: rgba(24, 24, 28, 0.88);

  /* Hairlines & Focus Rings */
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(255, 255, 255, 0.15);
  --border-focus: #0a84ff;

  /* Apple System Colors */
  --apple-blue: #0a84ff;
  --apple-cyan: #64d2ff;
  --apple-green: #30d158;
  --apple-purple: #bf5af2;
  --apple-red: #ff453a;
  --apple-amber: #ffd60a;
  --apple-gray: #8e8e93;

  /* Accent mappings */
  --accent-blue: var(--apple-blue);
  --accent-cyan: var(--apple-cyan);
  --accent-purple: var(--apple-purple);
  --accent-green: var(--apple-green);
  --accent-red: var(--apple-red);
  --accent-amber: var(--apple-amber);

  /* Typography Colors */
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.42);

  /* Apple Radii */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --radius-full: 9999px;

  /* Depth & Ambient Glow */
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 50px rgba(0, 0, 0, 0.75);
  --shadow-card-focus: 0 18px 40px -8px rgba(0, 0, 0, 0.8), 0 0 0 1.5px rgba(255, 255, 255, 0.28);
  --glow-apple: 0 0 24px rgba(10, 132, 255, 0.35);

  /* Apple Font Stack */
  --font-main: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Protocol Warning Banner (file:// referrer warning)
   ========================================================================== */

.protocol-warning-banner {
  background: rgba(255, 214, 10, 0.12);
  border-bottom: 1px solid rgba(255, 214, 10, 0.25);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #ffe680;
  padding: 8px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 500;
  gap: 12px;
  z-index: 101;
}

.warning-text {
  display: flex;
  align-items: center;
  gap: 8px;
}

.warning-text svg {
  width: 16px;
  height: 16px;
  color: var(--apple-amber);
  flex-shrink: 0;
}

.warning-text code {
  background: rgba(0, 0, 0, 0.5);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  color: #fff;
}

.server-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--apple-amber);
  color: #000;
  text-decoration: none;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.server-link-btn:hover {
  background: #ffdb4d;
  transform: scale(1.03);
}

/* ==========================================================================
   Top Header Navigation (Apple Translucent Bar)
   ========================================================================== */

.app-header {
  height: 64px;
  background: rgba(14, 14, 18, 0.72);
  backdrop-filter: blur(36px) saturate(190%);
  -webkit-backdrop-filter: blur(36px) saturate(190%);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 18px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  user-select: none;
  cursor: pointer;
}

.brand-icon.apple-squircle {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(145deg, #2c2c30, #16161a);
  border: 1px solid rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

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

.brand-text {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1;
  color: #ffffff;
}

.apple-tv-tag {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.2px;
  margin-left: 1px;
}

.live-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--apple-red);
  background: rgba(255, 69, 58, 0.14);
  border: 1px solid rgba(255, 69, 58, 0.28);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 5px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--apple-red);
  box-shadow: 0 0 8px var(--apple-red);
  animation: pulseAnim 1.8s infinite;
}

@keyframes pulseAnim {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Header Spotlight Search */
.header-center {
  flex: 1;
  max-width: 460px;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-box input {
  width: 100%;
  height: 38px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  padding: 0 38px 0 38px;
  color: var(--text-primary);
  font-size: 0.86rem;
  font-family: var(--font-main);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-box input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.search-box input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.32);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s;
}

.search-clear-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.15);
}

/* Apple Capsule Switch */
.toggle-control {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 0.15s;
}

.toggle-control input {
  display: none;
}

.toggle-slider {
  width: 38px;
  height: 22px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 22px;
  position: relative;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #ffffff;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.toggle-control input:checked + .toggle-slider {
  background: var(--apple-green);
}

.toggle-control input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

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

.toggle-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  vertical-align: middle;
}

/* Apple Capsule Pill Buttons */
.pill-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 15px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.pill-btn.secondary {
  color: var(--text-secondary);
}

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

.count-bubble {
  background: var(--apple-red);
  color: #fff;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(48, 209, 88, 0.12);
  border: 1px solid rgba(48, 209, 88, 0.28);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--apple-green);
  cursor: default;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--apple-green);
  box-shadow: 0 0 6px var(--apple-green);
}

/* ==========================================================================
   Main Player Layout (Apple TV 2-Column Grid)
   ========================================================================== */

.main-layout {
  display: grid;
  grid-template-columns: 1fr 450px;
  flex: 1;
  height: calc(100vh - 64px);
  overflow: hidden;
  background-color: var(--bg-primary);
}

/* Player Container with Cinema Ambient Light */
.player-container {
  display: flex;
  flex-direction: column;
  background: #000000;
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  position: relative;
}

/* Ambient glow layer behind video */
.ambient-glow {
  position: absolute;
  top: 10%;
  left: 10%;
  width: 80%;
  height: 55%;
  background: radial-gradient(circle, rgba(10, 132, 255, 0.16) 0%, rgba(191, 90, 242, 0.08) 45%, transparent 70%);
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.75;
  transition: opacity 0.8s ease;
}

.video-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 72vh;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 1;
}

#tvVideo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000000;
}

.embed-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  background: #000;
}

.embed-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Player Overlays */
.player-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(8, 8, 12, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  text-align: center;
  padding: 32px;
}

.placeholder-content {
  max-width: 480px;
}

.placeholder-icon {
  font-size: 3rem;
  color: var(--apple-blue);
  margin-bottom: 16px;
  display: inline-block;
  filter: drop-shadow(0 4px 18px rgba(10, 132, 255, 0.4));
}

.placeholder-icon svg {
  width: 60px;
  height: 60px;
}

.placeholder-content h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 10px;
  color: #fff;
}

.placeholder-content p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 24px;
}

.quick-hints {
  display: flex;
  justify-content: center;
  gap: 18px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.quick-hints span {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Apple Style Buffering Spinner */
.spinner-overlay {
  flex-direction: column;
  gap: 16px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.spinner.small {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

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

/* Error Overlay */
.error-box {
  max-width: 420px;
}

.error-icon {
  width: 48px;
  height: 48px;
  color: var(--apple-amber);
  margin-bottom: 14px;
}

.error-box h3 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
}

.error-box p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 22px;
}

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

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 18px;
  background: var(--apple-blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 14px rgba(10, 132, 255, 0.3);
}

.action-btn:hover {
  background: #258aff;
  transform: scale(1.03);
}

.action-btn.secondary {
  background: var(--apple-purple);
  box-shadow: 0 4px 14px rgba(191, 90, 242, 0.3);
}

.action-btn.secondary:hover {
  background: #cb74f5;
  transform: scale(1.03);
}

.action-btn.outline {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: none;
  color: var(--text-primary);
}

.action-btn.outline:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: scale(1.03);
}

/* ==========================================================================
   Apple TV Floating Controls Pod
   A floating frosted capsule dock centered over the player
   ========================================================================== */

.custom-controls {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  height: 52px;
  width: auto;
  min-width: 460px;
  max-width: 90%;
  background: rgba(20, 20, 25, 0.78);
  backdrop-filter: blur(40px) saturate(200%);
  -webkit-backdrop-filter: blur(40px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-full);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.video-viewport:hover .custom-controls,
.custom-controls:focus-within {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

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

.ctrl-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #fff;
  cursor: pointer;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.12);
}

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

.volume-slider-wrap {
  width: 80px;
  display: flex;
  align-items: center;
}

.volume-slider-wrap input[type=range] {
  width: 100%;
  accent-color: #ffffff;
  cursor: pointer;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.live-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.6px;
  background: rgba(255, 69, 58, 0.25);
  border: 1px solid rgba(255, 69, 58, 0.4);
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.red-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--apple-red);
}

.quality-badge, .proxy-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.proxy-badge {
  background: rgba(191, 90, 242, 0.25);
  border: 1px solid var(--apple-purple);
  color: #e3a9fc;
  margin-left: 6px;
}

/* Audio Equalizer Bars */
.equalizer-bars {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
  z-index: 12;
}

.equalizer-bars span {
  width: 3px;
  background: var(--apple-cyan);
  border-radius: 1.5px;
  animation: eqBounce 1.2s ease-in-out infinite alternate;
}

.equalizer-bars span:nth-child(1) { height: 60%; animation-delay: 0.1s; }
.equalizer-bars span:nth-child(2) { height: 100%; animation-delay: 0.3s; }
.equalizer-bars span:nth-child(3) { height: 40%; animation-delay: 0.2s; }
.equalizer-bars span:nth-child(4) { height: 80%; animation-delay: 0.4s; }

@keyframes eqBounce {
  0% { height: 20%; }
  100% { height: 100%; }
}

/* ==========================================================================
   Currently Playing Media Banner (Apple TV Aesthetic)
   ========================================================================== */

.now-playing-banner {
  padding: 18px 24px;
  background: rgba(14, 14, 18, 0.85);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 2;
}

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

.channel-logo-wrap {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.current-logo {
  max-width: 82%;
  max-height: 82%;
  object-fit: contain;
}

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

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

.title-row h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fav-icon-btn:hover, .fav-icon-btn.active {
  color: var(--apple-red);
}

.fav-icon-btn.active svg {
  fill: var(--apple-red);
}

.tags-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.tag svg {
  width: 12px;
  height: 12px;
}

.status-tag {
  color: var(--apple-green);
  background: rgba(48, 209, 88, 0.12);
  border-color: rgba(48, 209, 88, 0.25);
}

.ping-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--apple-green);
}

.ping-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.player-quick-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: var(--text-primary);
  transform: translateY(-1px);
}

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

/* ==========================================================================
   Channels Explorer Section (Right Column)
   ========================================================================== */

.explorer-container {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  height: 100%;
  overflow: hidden;
}

.explorer-toolbar {
  padding: 14px 18px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-color);
}

.select-wrapper {
  position: relative;
  flex: 1;
}

.select-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.select-wrapper select {
  width: 100%;
  height: 36px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  padding: 0 12px 0 32px;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-main);
  appearance: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.select-wrapper select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
}

.select-wrapper option {
  background: #1c1c1e;
  color: #fff;
}

.view-switch {
  display: flex;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  padding: 2px;
}

.view-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s;
}

.view-btn.active, .view-btn:hover {
  color: #000000;
  background: #ffffff;
}

.view-btn svg {
  width: 14px;
  height: 14px;
}

/* Apple TV Category Navigation Pills */
.category-chips {
  padding: 10px 18px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border-color);
}

.category-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  height: 32px;
  padding: 0 16px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.chip:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Active Apple TV Signature Pill: Solid white pill, black text */
.chip.active {
  background: #ffffff;
  border-color: #ffffff;
  color: #000000;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.25);
}

.chip.filter-direct {
  border-color: rgba(10, 132, 255, 0.35);
  color: var(--apple-blue);
}

.chip.filter-direct.active {
  background: var(--apple-blue);
  border-color: var(--apple-blue);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(10, 132, 255, 0.35);
}

/* Results Status Bar */
.results-bar {
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.results-count strong {
  color: var(--text-primary);
}

.link-btn {
  background: none;
  border: none;
  color: var(--apple-cyan);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.2s;
}

.link-btn:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.link-btn svg {
  width: 12px;
  height: 12px;
}

/* ==========================================================================
   Channels Grid & List Rendering (Apple tvOS Squircle Cards)
   ========================================================================== */

.channel-view {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

/* Grid View */
.grid-view {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.channel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

/* Apple TV Card Focus / Hover Physics */
.channel-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.25);
  transform: scale(1.03) translateY(-3px);
  box-shadow: 0 16px 36px -6px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.2);
  z-index: 2;
}

.channel-card.active-playing {
  border-color: var(--apple-blue);
  background: rgba(10, 132, 255, 0.1);
  box-shadow: 0 0 0 2px var(--apple-blue), 0 12px 28px rgba(10, 132, 255, 0.35);
}

.channel-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-logo-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-logo {
  max-width: 82%;
  max-height: 82%;
  object-fit: contain;
}

.card-fav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: all 0.2s;
}

.card-fav-btn:hover, .card-fav-btn.active {
  color: var(--apple-red);
}

.card-fav-btn.active svg {
  fill: var(--apple-red);
}

.card-fav-btn svg {
  width: 16px;
  height: 16px;
}

.card-name {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.25;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}

.card-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.card-badge-row {
  display: flex;
  gap: 4px;
}

.micro-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.micro-badge.verified {
  background: rgba(48, 209, 88, 0.15);
  color: var(--apple-green);
}

/* List View */
.list-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-view .channel-card {
  flex-direction: row;
  align-items: center;
  padding: 10px 16px;
  border-radius: 14px;
}

.list-view .channel-card-top {
  margin-bottom: 0;
  margin-right: 14px;
}

.list-view .card-info {
  flex: 1;
  min-width: 0;
}

.list-view .card-name {
  margin-bottom: 2px;
}

/* Load More & Spinner */
.load-more-wrap {
  padding: 18px;
  display: flex;
  justify-content: center;
}

.load-more-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 22px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.load-more-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.load-more-btn svg {
  width: 14px;
  height: 14px;
}

.more-spinner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Modals & Diagnostics (Apple macOS / tvOS Sheet Style)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  background: rgba(24, 24, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(48px) saturate(190%);
  -webkit-backdrop-filter: blur(48px) saturate(190%);
  border-radius: 24px;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  overflow: hidden;
  animation: modalIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.modal-title svg {
  width: 20px;
  height: 20px;
  color: var(--apple-cyan);
}

.modal-title h3 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.modal-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.2);
}

.modal-close svg {
  width: 16px;
  height: 16px;
}

.modal-body {
  padding: 24px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.6;
}

.input-copy-group {
  display: flex;
  gap: 10px;
  margin: 18px 0;
}

.input-copy-group input {
  flex: 1;
  height: 42px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  color: var(--apple-cyan);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.modal-subsections {
  margin-top: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px;
  border-radius: 14px;
  font-size: 0.82rem;
}

.modal-subsections h4 {
  color: var(--text-primary);
  margin-bottom: 8px;
  font-weight: 600;
}

.modal-subsections ol {
  padding-left: 18px;
  line-height: 1.7;
}

.modal-subsections code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 5px;
  font-family: var(--font-mono);
  color: #fff;
}

/* Diag Table */
.diag-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.diag-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  font-size: 0.82rem;
}

.diag-label {
  color: var(--text-muted);
  font-weight: 600;
}

.diag-val {
  color: var(--text-primary);
  font-weight: 500;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diag-val.mono {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ==========================================================================
   Apple Dynamic Island Style Toast Notifications
   ========================================================================== */

.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 300;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: rgba(28, 28, 32, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(36px) saturate(180%);
  -webkit-backdrop-filter: blur(36px) saturate(180%);
  padding: 10px 22px;
  border-radius: var(--radius-full);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: islandPop 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes islandPop {
  from { opacity: 0; transform: translateY(-16px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast.success { border-color: rgba(48, 209, 88, 0.4); }
.toast.error { border-color: rgba(255, 69, 58, 0.4); }
.toast.info { border-color: rgba(10, 132, 255, 0.4); }

/* Utility Classes */
.hidden {
  display: none !important;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .player-container {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .video-viewport {
    max-height: 55vh;
  }

  .custom-controls {
    min-width: 380px;
  }

  .explorer-container {
    height: auto;
  }
}

@media (max-width: 640px) {
  .app-header {
    padding: 0 14px;
    height: 58px;
  }

  .brand-text h1 {
    display: none;
  }

  .header-center {
    max-width: 190px;
  }

  .toggle-label {
    display: none;
  }

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

  .custom-controls {
    min-width: calc(100% - 24px);
    padding: 0 12px;
    height: 48px;
    bottom: 10px;
  }

  .volume-slider-wrap {
    display: none;
  }

  .now-playing-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .player-quick-tools {
    width: 100%;
    justify-content: flex-end;
  }
}
