/* ==========================================================================
   MiTV — APPLE TV / YOUTUBE TV DARK STUDIO DESIGN SYSTEM
   Minimalist, Sober, Zero-AI Clutter + GPU Sharpening Modes
   ========================================================================== */

:root {
  --bg-base: #070709;
  --bg-panel: #111115;
  --bg-card: #18181e;
  --bg-card-hover: #22222a;
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(255, 255, 255, 0.18);
  
  --accent-purple: #9333ea;
  --accent-purple-hover: #a855f7;
  --accent-purple-glow: rgba(147, 51, 234, 0.45);
  
  --live-red: #ef4444;
  --text-main: #f4f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

html, body {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: #262630;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3a3a48;
}

/* ==========================================================================
   Top Bar (46px Height)
   ========================================================================== */
.topbar {
  height: 46px;
  min-height: 46px;
  max-height: 46px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 12px;
  user-select: none;
  z-index: 100;
}

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

/* Brand */
.brand-item {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}
.brand-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-purple);
  box-shadow: 0 0 8px var(--accent-purple-glow);
}
.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}
.topbar-divider {
  width: 1px;
  height: 16px;
  background: var(--border-subtle);
}
.active-match-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Segmented Control */
.segmented-control {
  display: flex;
  background: #0b0b0e;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 2px;
  gap: 2px;
}
.segmented-control.full-width {
  width: 100%;
}
.seg-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.seg-btn:hover {
  color: var(--text-main);
}
.seg-btn.active {
  background: var(--accent-purple);
  color: #fff;
  font-weight: 600;
}

/* Topbar Buttons */
.topbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.topbar-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-active);
}

.enhance-btn strong {
  color: var(--accent-purple-hover);
  font-weight: 700;
}

.toggle-sidebar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.toggle-sidebar-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-purple);
}

/* ==========================================================================
   App Stage Layout (100dvh - 46px)
   ========================================================================== */
.app-stage {
  height: calc(100vh - 46px);
  height: calc(100dvh - 46px);
  display: flex;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
   Left Area: Video Stage (Flex: 1)
   ========================================================================== */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  background: #000;
  overflow: hidden;
}

/* Video Grid */
.video-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 3px;
  padding: 3px;
  background: #000;
  position: relative;
}

.video-grid.layout-1 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
.video-grid.layout-1 #slot-1,
.video-grid.layout-1 #slot-2,
.video-grid.layout-1 #slot-3 {
  display: none !important;
}

.video-grid.layout-2 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}
.video-grid.layout-2 #slot-2,
.video-grid.layout-2 #slot-3 {
  display: none !important;
}

.video-grid.layout-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

/* GPU Adaptive Sharpening Filters applied to media */
#videoGrid.enhance-sharp video,
#videoGrid.enhance-sharp iframe,
.video-grid.enhance-sharp video,
.video-grid.enhance-sharp iframe,
#videoGrid.filter-sharp video,
#videoGrid.filter-sharp iframe {
  filter: url(#sports-hd-enhance) contrast(1.06) saturate(1.1) !important;
  will-change: filter, transform;
  transform: translateZ(0);
}

#videoGrid.enhance-vivid video,
#videoGrid.enhance-vivid iframe,
.video-grid.enhance-vivid video,
.video-grid.enhance-vivid iframe,
#videoGrid.filter-vivid video,
#videoGrid.filter-vivid iframe {
  filter: url(#sports-hd-enhance) contrast(1.12) saturate(1.25) brightness(1.03) !important;
  will-change: filter, transform;
  transform: translateZ(0);
}

/* Ensure native fullscreen, picture-in-picture and controls remain unobstructed */
video::-webkit-media-controls {
  z-index: 2147483647;
  position: relative;
}
:fullscreen video {
  max-width: 100vw !important;
  max-height: 100vh !important;
}

/* Stream Slot Box */
.stream-slot {
  position: relative;
  background: #0c0d11;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Audio Focus: Purple Border & Glow */
.stream-slot.active-audio {
  border: 2px solid var(--accent-purple) !important;
  box-shadow: 0 0 18px var(--accent-purple-glow);
  z-index: 2;
}

/* Audio Badge */
.slot-audio-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
  background: var(--accent-purple);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  display: none;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}
.stream-slot.active-audio .slot-audio-badge {
  display: flex;
}

/* Floating Slot Bar on Hover */
.slot-floating-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: linear-gradient(to bottom, rgba(7, 7, 9, 0.85), transparent);
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 95px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.stream-slot:hover .slot-floating-bar {
  opacity: 1;
  pointer-events: auto;
}
.slot-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slot-actions {
  display: flex;
  gap: 4px;
}
.slot-mini-btn {
  background: rgba(17, 17, 21, 0.85);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
}
.slot-mini-btn:hover {
  background: var(--accent-purple);
  color: #fff;
}
.slot-mini-btn.slot-playpause {
  font-size: 10px;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
}
.playpause-chip {
  font-weight: 600;
  color: var(--text-main);
  background: var(--bg-card);
}
.playpause-chip:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
}

/* Media Box */
.slot-media-box {
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
  background: #000;
}
.slot-video, .slot-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
  object-fit: contain;
  display: block;
}
.slot-iframe {
  display: none;
}

/* Overlays (Loader, Error, Empty) */
.slot-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0c0d11;
  color: var(--text-secondary);
  z-index: 5;
  padding: 16px;
  text-align: center;
}
.loader-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(147, 51, 234, 0.2);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 8px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loader-text {
  font-size: 11.5px;
  color: var(--text-secondary);
}
.error-emoji {
  font-size: 22px;
  margin-bottom: 5px;
}
.error-text {
  font-size: 11.5px;
  color: var(--live-red);
  margin-bottom: 8px;
}
.slot-retry-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
}
.slot-retry-btn:hover {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
}
.empty-icon {
  font-size: 24px;
  font-weight: 800;
  color: #262632;
  margin-bottom: 4px;
}
.slot-empty p {
  font-size: 11.5px;
  color: var(--text-muted);
  max-width: 200px;
}

/* ==========================================================================
   Stage Footer (44px Height)
   ========================================================================== */
.stage-footer {
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  overflow-x: auto;
  user-select: none;
}
.focused-pill {
  background: rgba(147, 51, 234, 0.18);
  border: 1px solid var(--accent-purple);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.server-chips-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
}
.no-options-hint {
  font-size: 11px;
  color: var(--text-muted);
}
.server-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}
.server-chip:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-active);
}
.server-chip.active {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: #fff;
  font-weight: 600;
}
.latency-pill {
  font-size: 10px;
  opacity: 0.85;
}
.footer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Volume Control Box */
.volume-control-box {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 2px 7px 2px 4px;
  transition: border-color 0.15s ease;
  flex-shrink: 0;
}
.volume-control-box:hover {
  border-color: var(--border-active);
}
.volume-mute-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: transform 0.1s ease, color 0.15s ease;
}
.volume-mute-btn:hover {
  color: var(--accent-purple-hover);
  transform: scale(1.1);
}
.volume-mute-btn.muted {
  color: var(--live-red);
}
.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 65px;
  height: 4px;
  border-radius: 2px;
  background: #2a2a38;
  outline: none;
  cursor: pointer;
  transition: background 0.15s;
}
.volume-slider:hover {
  background: #38384a;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-purple);
  cursor: pointer;
  box-shadow: 0 0 6px var(--accent-purple-glow);
  transition: transform 0.1s ease, background 0.15s ease;
}
.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--accent-purple-hover);
}
.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-purple);
  border: none;
  cursor: pointer;
}
.volume-percent {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 26px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.tool-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.tool-chip:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}
.quality-chip {
  border-color: rgba(147, 51, 234, 0.35);
  color: var(--text-main);
  font-weight: 500;
}
.quality-chip.forced {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: #fff;
  font-weight: 600;
}
.auto-chip {
  border-color: rgba(147, 51, 234, 0.4);
}
.auto-chip:hover {
  border-color: var(--accent-purple);
  color: var(--accent-purple-hover);
}

/* ==========================================================================
   Right Area: Retractable Programming Sidebar (340px)
   ========================================================================== */
.sidebar {
  width: 340px;
  min-width: 340px;
  height: 100%;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-right 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

.sidebar.collapsed {
  margin-right: -340px;
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: #0e0e12;
}

.count-pill {
  font-size: 10px;
  background: #1e1e26;
  color: var(--text-secondary);
  padding: 1px 5px;
  border-radius: 10px;
}

/* Search Row */
.search-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.search-input-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.search-input-box svg {
  position: absolute;
  left: 8px;
  color: var(--text-muted);
}
.search-input-box input {
  width: 100%;
  background: #09090c;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 11.5px;
  padding: 5px 24px 5px 26px;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.15s;
}
.search-input-box input:focus {
  border-color: var(--accent-purple);
}
.search-clear {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
}
.search-reload-btn {
  width: 28px;
  height: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-reload-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

/* Filter Row */
.filter-row {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}
.filter-chips-scroll {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}
.filter-chip {
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 10.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.filter-chip:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}
.filter-chip.active {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: #fff;
  font-weight: 600;
}

/* Sidebar List */
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.list-loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 30px 10px;
}

/* Event Card */
.event-card {
  display: flex;
  align-items: center;
  padding: 7px 9px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}
.event-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
}
.event-card.active-in-slot {
  border-color: var(--accent-purple);
  background: rgba(147, 51, 234, 0.1);
}

.time-tag {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: #09090c;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
  min-width: 44px;
  text-align: center;
  flex-shrink: 0;
}
.time-tag.is-live {
  color: #fff;
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}
.red-dot {
  width: 5px;
  height: 5px;
  background: var(--live-red);
  border-radius: 50%;
  display: inline-block;
  margin-right: 3px;
}

.event-info {
  flex: 1;
  min-width: 0;
}
.event-league {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-purple);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.event-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.add-multistream-btn {
  width: 22px;
  height: 22px;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
  background: #111116;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.add-multistream-btn:hover {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: #fff;
}

/* ==========================================================================
   Mobile LAN Modal
   ========================================================================== */
.modal-layer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.modal-top {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-headline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-purple-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-purple);
}
.modal-headline h3 {
  font-size: 13.5px;
  font-weight: 600;
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}
.modal-content {
  padding: 16px;
  text-align: center;
}
.modal-guide {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.modal-qr-container {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
.modal-copy-row {
  display: flex;
  gap: 6px;
}
.modal-copy-row input {
  flex: 1;
  background: #09090c;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 4px;
  outline: none;
}
.copy-action-btn {
  background: var(--accent-purple);
  border: none;
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
}

/* ==========================================================================
   Responsive Adaptations (Mobile Portrait, Mobile Landscape, Tablets)
   ========================================================================== */

/* Mobile Portrait & Vertical Viewports (<= 860px) */
@media (max-width: 860px) {
  html, body {
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
  }

  .topbar {
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    padding: 0 8px;
    gap: 6px;
  }

  .topbar-left {
    flex-shrink: 0;
    gap: 6px;
  }
  .active-match-title {
    display: none !important;
  }
  .topbar-divider {
    display: none;
  }

  .topbar-center {
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 2px 0;
    gap: 5px;
    flex: 1;
    justify-content: flex-start;
  }
  .topbar-center::-webkit-scrollbar {
    display: none;
  }

  .seg-btn {
    padding: 3px 7px;
    font-size: 11px;
  }
  .topbar-btn {
    padding: 4px 7px;
    font-size: 11px;
  }
  #aspectFitBtn span, #fullscreenBtn span, #mobileBtn span {
    display: none;
  }
  #enhanceBtn span:not(.sparkle-icon) {
    display: none;
  }
  .toggle-sidebar-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
  .toggle-sidebar-btn span {
    display: none;
  }

  /* App Stage Container (100dvh - 44px) */
  .app-stage {
    flex-direction: column;
    height: calc(100vh - 44px);
    height: calc(100dvh - 44px);
    width: 100vw;
    overflow: hidden;
  }

  /* Video Stage: Top block */
  .stage {
    width: 100%;
    height: auto;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    background: #000;
    z-index: 10;
  }

  /* Fluid 16:9 Aspect Ratio on Mobile */
  .video-grid {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 48dvh;
    flex: 0 0 auto;
    padding: 0;
    gap: 2px;
    background: #000;
  }

  .video-grid.layout-1 .stream-slot {
    width: 100%;
    height: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .stage-footer {
    height: 38px;
    min-height: 38px;
    max-height: 38px;
    padding: 0 8px;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
  }
  .stage-footer::-webkit-scrollbar {
    display: none;
  }
  .focused-pill {
    font-size: 10px;
    padding: 2px 6px;
  }
  .tool-chip {
    font-size: 10.5px;
    padding: 3px 7px;
  }
  .volume-slider {
    width: 50px;
  }

  /* Programming Sidebar: Bottom section with independent scrolling */
  .sidebar {
    width: 100% !important;
    min-width: 100% !important;
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: auto !important;
    margin-right: 0 !important;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-panel);
  }

  .sidebar.collapsed {
    display: none !important;
  }

  /* If sidebar is collapsed by user on mobile, expand video stage to full screen */
  .app-stage:has(.sidebar.collapsed) .stage {
    flex: 1 1 100%;
    height: 100%;
  }
  .app-stage:has(.sidebar.collapsed) .video-grid {
    flex: 1 1 auto;
    max-height: none;
    aspect-ratio: auto;
  }

  .sidebar-header {
    padding: 6px 8px;
  }
  .search-row {
    padding: 6px 8px;
  }
  .filter-row {
    padding: 4px 8px;
  }

  .sidebar-list {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 6px 8px env(safe-area-inset-bottom, 8px);
  }
}

/* Mobile Landscape & Ultra-wide Low Height (<= 540px height) */
@media (max-height: 540px) and (orientation: landscape) {
  html, body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .topbar {
    height: 36px;
    min-height: 36px;
    max-height: 36px;
    padding: 0 8px;
  }

  .brand-title {
    font-size: 13px;
  }
  .active-match-title {
    display: none;
  }

  .app-stage {
    flex-direction: row;
    height: calc(100vh - 36px);
    height: calc(100dvh - 36px);
  }

  .stage {
    flex: 1 1 auto;
    height: 100%;
  }

  .video-grid {
    flex: 1;
    aspect-ratio: auto;
    max-height: none;
  }

  .stage-footer {
    height: 34px;
    min-height: 34px;
    max-height: 34px;
    padding: 0 6px;
  }

  .sidebar {
    width: 260px !important;
    min-width: 260px !important;
    height: 100% !important;
    flex: 0 0 260px !important;
    border-top: none;
    border-left: 1px solid var(--border-subtle);
    display: flex;
  }

  .sidebar.collapsed {
    margin-right: -260px !important;
    display: flex !important;
    opacity: 0;
  }
}
