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

    /* ════════════════════════ DESIGN TOKENS ════════════════════════
       Control Room palette — slate surfaces, electric blue accent.
       Themes override ONLY --c-* palette values; everything else
       (spacing, radii, type, touch, z-scale, motion) is theme-invariant.
       Legacy aliases at the bottom serve not-yet-migrated rules:
       do not add new uses of them. */
    :root {
      /* palette */
      --c-bg-0: #0b0e14;            /* page behind tiles */
      --c-bg-1: #141a26;            /* base surface */
      --c-bg-2: #1b2333;            /* raised surface */
      --c-bg-3: #232d42;            /* interactive surface */
      --c-accent: #4d8dff;
      --c-accent-soft: #7faaff;
      --c-danger: #ff5c5c;          --c-danger-strong: #cc3a3a;
      --c-success: #2fd08c;         --c-success-strong: #1fa86c;
      --c-warning: #f5a623;         --c-warning-bright: #ffc53d;
      --c-info: #4d8dff;            --c-info-strong: #2f6fe0;
      --c-text: #e6eaf2;            --c-text-dim: #8b94a7;
      --c-border: #283349;
      --c-overlay: rgba(4, 6, 10, 0.65);
      --c-chrome: rgba(20, 26, 38, 0.97);      /* toolbar / status bars */
      --c-panel: #07090e;                       /* behind video */
      --c-panel-header: rgba(11, 14, 20, 0.92);
      /* spacing (4px base) */
      --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-6: 24px; --sp-8: 32px;
      /* radii */
      --r-sm: 4px; --r-md: 8px; --r-lg: 12px; --r-full: 999px;
      /* type scale */
      --fs-xs: 11px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 28px;
      /* touch targets */
      --touch-min: 44px; --touch-lg: 56px;
      /* z-scale — every global z-index must be one of these */
      --z-tile-ui: 10; --z-grid-handle: 30; --z-expanded: 40; --z-toolbar: 50;
      --z-chat: 55; --z-mixer: 60; --z-kiosk: 70; --z-dropdown: 80;
      --z-modal: 90; --z-toast: 100; --z-tour: 105; --z-boot: 110;
      /* motion */
      --dur-fast: 120ms; --dur-med: 200ms; --dur-slow: 350ms;
      --ease: cubic-bezier(0.2, 0, 0.2, 1);
    }
    body.theme-oled {
      --c-bg-0: #000000; --c-bg-1: #0a0c12; --c-bg-2: #10131c; --c-bg-3: #161b28;
      --c-border: #1a2030;
      --c-overlay: rgba(0, 0, 0, 0.7);
      --c-chrome: rgba(0, 0, 0, 0.97);
      --c-panel: #000000;
      --c-panel-header: rgba(0, 0, 0, 0.95);
    }
    body.theme-light {
      --c-bg-0: #f4f6fa; --c-bg-1: #ffffff; --c-bg-2: #edf0f6; --c-bg-3: #e2e7f0;
      --c-accent: #2f6fe0; --c-accent-soft: #5c8ee8;
      --c-danger: #d63838; --c-danger-strong: #a82424;
      --c-success: #1b9e66; --c-success-strong: #137a4e;
      --c-warning: #c07f0e; --c-warning-bright: #e8a21a;
      --c-info: #2f6fe0; --c-info-strong: #1f55b8;
      --c-text: #151923; --c-text-dim: #5c6474;
      --c-border: #c9d2e0;
      --c-overlay: rgba(20, 25, 35, 0.45);
      --c-chrome: rgba(255, 255, 255, 0.97);
      --c-panel: #e2e7f0;
      --c-panel-header: rgba(244, 246, 250, 0.95);
    }

    html, body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
      background: var(--c-bg-0); color: var(--c-text); height: 100%; overflow: hidden;
      -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
    }
    body { display: flex; flex-direction: column; }

    /* ── Toolbar — persistent compact top bar (in normal mode). In the
       auto-hide modes (kiosk / TV / cast / expanded tile) it disappears and
       chrome-hover brings it back as a fixed overlay. ── */
    .toolbar {
      display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3);
      background: var(--c-chrome); border-bottom: 1px solid var(--c-border);
      flex-wrap: wrap; position: relative; z-index: var(--z-toolbar);
    }
    .tb-group {
      display: flex; align-items: center; gap: var(--sp-1);
      padding-right: var(--sp-2); border-right: 1px solid var(--c-border);
    }
    .toolbar .btn, .toolbar select { min-height: 38px; }
    body.has-expanded .toolbar { display: none; }
    body.has-expanded.chrome-hover .toolbar {
      display: flex; position: fixed; top: 0; left: 0; right: 0;
    }

    .toolbar input[type="text"] {
      flex: 1 1 200px; min-width: 0; background: var(--c-bg-1); border: 1px solid var(--c-border);
      color: var(--c-text); padding: 10px 14px; border-radius: var(--r-md); font-size: 16px; outline: none;
    }
    .toolbar input:focus { border-color: var(--c-accent); }
    .toolbar input::placeholder { color: var(--c-text-dim); }

    .btn {
      background: var(--c-bg-3); color: var(--c-text); border: none; padding: 10px 16px;
      border-radius: var(--r-md); font-size: var(--fs-sm); cursor: pointer; white-space: nowrap;
      transition: background var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease);
      -webkit-appearance: none;
    }
    .btn:hover { filter: brightness(1.25); }
    .btn:active { filter: brightness(0.92); }
    .btn.sm { padding: 6px 10px; font-size: var(--fs-xs); }
    .btn.xs { padding: 3px 8px; font-size: var(--fs-xs); border-radius: var(--r-sm); }
    .btn.danger { color: var(--c-danger); }
    .btn.danger:hover { background: var(--c-danger-strong); color: #fff; filter: none; }
    .btn.primary { background: var(--c-accent); color: #fff; }
    .btn.green { background: var(--c-success); color: #fff; }
    .btn.green:hover { background: var(--c-success-strong); filter: none; }
    .btn:disabled { opacity: 0.4; cursor: default; }
    /* One consistent keyboard-focus treatment everywhere */
    .btn:focus-visible, select:focus-visible, input:focus-visible,
    .mixer-btn:focus-visible, .panel-menu-btn:focus-visible,
    .action-bar button:focus-visible {
      outline: 2px solid var(--c-accent); outline-offset: 2px;
    }
    ::selection { background: var(--c-accent); color: #fff; }
    * { scrollbar-width: thin; scrollbar-color: var(--c-bg-3) transparent; }
    *::-webkit-scrollbar { width: 8px; height: 8px; }
    *::-webkit-scrollbar-thumb { background: var(--c-bg-3); border-radius: var(--r-full); }
    *::-webkit-scrollbar-thumb:hover { background: var(--c-border); }
    *::-webkit-scrollbar-track { background: transparent; }

    .col-group { display: flex; align-items: center; gap: 4px; }
    .col-group label { color: var(--c-text-dim); font-size: 12px; }
    .col-group select, select.quality-sel {
      background: var(--c-bg-1); color: var(--c-text); border: 1px solid var(--c-border);
      padding: 8px; border-radius: var(--r-md); font-size: 13px;
    }

    .auth-section { display: flex; align-items: center; gap: 6px; margin-left: auto; }
    .auth-section .username { color: var(--c-success); font-size: 12px; font-weight: 600; }

    /* ── Grid ── */
    .grid {
      flex: 1; display: grid; grid-template-columns: 1fr;
      grid-auto-rows: 1fr;
      gap: 2px; padding: 0; overflow: hidden; min-height: 0; background: var(--c-bg-0);
      position: relative;
    }
    /* Auto-hide modes reclaim the toolbar's row */
    body.has-expanded .grid, body.kiosk-mode .grid, body.tv-mode .grid {
      height: 100dvh; height: 100vh;
    }
    /* Resizable gridline handles (custom layout). Absolutely positioned over the
       grid; only visible while Resize mode is on. */
    .grid-handle { position: absolute; z-index: var(--z-grid-handle); background: transparent; }
    .grid-handle::after { content: ''; position: absolute; background: var(--c-accent); opacity: 0; transition: opacity .15s; border-radius: 3px; }
    body.grid-resize .grid-handle::after { opacity: 0.5; }
    .grid-handle:hover::after, .grid-handle.dragging::after { opacity: 0.9 !important; }
    .grid-handle.col { top: 0; bottom: 0; width: 24px; margin-left: -12px; cursor: col-resize; }
    .grid-handle.col::after { left: 10px; width: 4px; top: 0; bottom: 0; }
    .grid-handle.row { left: 0; right: 0; height: 24px; margin-top: -12px; cursor: row-resize; }
    .grid-handle.row::after { top: 10px; height: 4px; left: 0; right: 0; }
    body:not(.grid-resize) .grid-handle { pointer-events: none; }
    /* In auto-hide modes, revealing the chrome pushes the grid down so the
       fixed toolbar doesn't cover tile tops */
    body.has-expanded.chrome-hover .grid, body.kiosk-mode.chrome-hover .grid {
      padding-top: var(--toolbar-h, 52px);
      height: calc(100vh - var(--toolbar-h, 52px));
      height: calc(100dvh - var(--toolbar-h, 52px));
    }

    .empty {
      grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center;
      justify-content: center; gap: 14px; color: var(--c-text-dim); padding: 40px 20px; text-align: center;
    }
    .empty h2 { color: var(--c-text); font-size: 28px; }
    .empty p { font-size: 14px; line-height: 1.6; max-width: 480px; }
    .badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
    .badge { background: var(--c-bg-3); padding: 6px 14px; border-radius: 20px; font-size: 12px; color: var(--c-text); }

    /* ── Panel ── */
    .panel {
      display: flex; flex-direction: column; border: 1px solid transparent; border-radius: 2px;
      overflow: hidden; background: var(--c-panel); min-height: 0; width: 100%; height: 100%; position: relative;
      /* z-index: 0 isolates a stacking context so tile-internal layers
         (loading, controls, badges) can never fight global chrome */
      z-index: 0;
      transition: border-color 0.3s;
    }
    .panel:hover { border-color: #333; }
    .panel.focused { border-color: var(--c-accent); }
    .panel.expanded {
      position: fixed; inset: 0; z-index: var(--z-expanded); min-height: 100dvh; min-height: 100vh;
      border: none; border-radius: 0;
      transition: top 0.35s ease, bottom 0.35s ease;
    }
    /* When the toolbar slides in, shrink the expanded panel from the top so the
       title/menu aren't covered. */
    .chrome-hover .panel.expanded {
      top: var(--toolbar-h, 52px);
      min-height: 0;
    }
    .panel.drag-over { border-color: var(--c-success); border-width: 2px; }

    .panel-header { display: none; }

    /* ── Panel Menu Button (top-right ⋮) — touch-first: always visible,
       full --touch-min hit area ── */
    .panel-menu-btn {
      position: absolute; top: 6px; right: 6px; z-index: 10;
      width: var(--touch-min); height: var(--touch-min); border-radius: 50%;
      background: rgba(0,0,0,0.7); border: 1px solid rgba(255,255,255,0.15);
      color: #ccc; font-size: 20px; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      opacity: 0.85; pointer-events: auto;
      line-height: 1; backdrop-filter: blur(4px); transition: opacity var(--dur-med);
    }
    .panel:hover .panel-menu-btn, .panel-menu-btn.open { opacity: 1; }
    .panel-menu-btn:hover { background: rgba(0,0,0,0.9); color: #fff; }

    /* ── Panel Dropdown Menu ── */
    .panel-dropdown {
      position: fixed; z-index: var(--z-dropdown);
      background: var(--c-bg-2); border: 1px solid var(--c-border); border-radius: var(--r-md);
      min-width: 160px; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
      display: none; flex-direction: column; overflow-y: auto; overflow-x: hidden;
      max-height: calc(100vh - 20px);
    }
    .panel-dropdown.open { display: flex; }
    .panel-dropdown button {
      background: none; border: none; color: var(--c-text); padding: 12px 16px;
      text-align: left; font-size: 14px; cursor: pointer; display: flex;
      align-items: center; gap: 8px; white-space: nowrap; min-height: 44px;
    }
    .panel-dropdown button:hover { background: var(--c-bg-3); }
    .panel-dropdown button.danger { color: var(--c-danger); }
    .panel-dropdown button.danger:hover { background: var(--c-danger-strong); color: #fff; }
    .panel-dropdown .sep { height: 1px; background: var(--c-border); margin: 2px 0; }
    .panel-menu-row {
      display: flex; align-items: center; justify-content: space-between;
      padding: 8px 16px; font-size: 14px; color: var(--c-text); gap: 8px;
      white-space: nowrap; min-height: 44px;
    }
    .panel-menu-row select {
      background: var(--c-bg-1); color: var(--c-text); border: 1px solid var(--c-border);
      border-radius: 4px; padding: 4px 6px; font-size: 13px; cursor: pointer;
    }
    .auto-refresh-badge {
      position: absolute; bottom: 38px; right: 8px; z-index: 5;
      background: rgba(76,175,80,0.85); color: #fff; font-size: 11px;
      padding: 2px 7px; border-radius: 10px; pointer-events: none;
      font-weight: 600; letter-spacing: 0.5px;
    }

    /* Panel label shown at top-left */
    .panel-drag-handle {
      position: absolute; top: 8px; left: 8px; z-index: 10;
      width: 28px; height: 28px; border-radius: 6px;
      background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.15);
      color: rgba(255,255,255,0.6); font-size: 14px; cursor: grab;
      display: flex; align-items: center; justify-content: center;
      opacity: 0; transition: opacity 0.25s; backdrop-filter: blur(4px);
    }
    .panel:hover .panel-drag-handle { opacity: 0.7; }
    .panel-drag-handle:hover { opacity: 1 !important; background: rgba(0,0,0,0.8); color: #fff; }
    .panel-drag-handle:active { cursor: grabbing; }
    @media (hover: none) and (pointer: coarse) {
      .panel-drag-handle { opacity: 0.7; width: 36px; height: 36px; font-size: 16px; }
    }
    body.dragging-stream iframe, body.dragging-stream video, body.dragging-stream .yt-container { pointer-events: none !important; }
    .panel-label {
      position: absolute; top: 8px; left: 42px; z-index: 4;
      font-size: var(--fs-xs); font-weight: 600; color: rgba(255,255,255,0.75);
      background: rgba(0,0,0,0.5); padding: 3px 8px; border-radius: var(--r-sm);
      opacity: 0.85; transition: opacity var(--dur-med); pointer-events: none;
      max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
      backdrop-filter: blur(4px);
    }
    .panel:hover .panel-label { opacity: 1; }

    /* Panel controls bar — collapsed (0 height) by default so it doesn't take
       space or overlap the video. Opens in-flow (pushing the video up) when
       the tile is TAPPED (.controls-open — works on every input type), on
       hover (desktop preview affordance), or while expanded. */
    .panel-controls {
      display: flex; align-items: center; gap: var(--sp-2);
      background: var(--c-panel-header); position: relative;
      flex-shrink: 0; z-index: 3;
      height: 0; padding: 0 10px; overflow: hidden;
      transition: height var(--dur-med) var(--ease), padding var(--dur-med) var(--ease);
    }
    .panel.controls-open .panel-controls,
    .panel:hover .panel-controls,
    .panel.expanded .panel-controls { height: var(--touch-min); padding: var(--sp-1) var(--sp-3); }

    .panel-controls .btn.xs {
      min-width: var(--touch-min); min-height: 36px; font-size: 14px;
      display: inline-flex; align-items: center; justify-content: center;
    }
    .panel-controls .btn.xs.listen-active { background: var(--c-accent); color: #fff; }

    .panel-controls input[type="range"] {
      flex: 1; max-width: 140px; height: 6px; accent-color: var(--c-accent); cursor: pointer;
      /* Pad the hit area to the full bar height without growing the track */
      padding: 14px 0; background: transparent; -webkit-appearance: none; appearance: none;
    }
    .panel-controls input[type="range"]::-webkit-slider-runnable-track {
      height: 6px; border-radius: 3px; background: rgba(255,255,255,0.22);
    }
    .panel-controls input[type="range"]::-webkit-slider-thumb {
      -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%;
      background: var(--c-accent); margin-top: -9px; border: none;
    }
    .panel-controls input[type="range"]::-moz-range-track {
      height: 6px; border-radius: 3px; background: rgba(255,255,255,0.22);
    }
    .panel-controls input[type="range"]::-moz-range-thumb {
      width: 24px; height: 24px; border-radius: 50%; background: var(--c-accent); border: none;
    }
    .panel-controls select {
      background: rgba(35, 45, 66, 0.9); color: #ccc; border: 1px solid #333;
      padding: 2px 4px; font-size: 10px; border-radius: 4px;
    }
    .stream-pos-select {
      background: rgba(35, 45, 66, 0.9); color: #ccc; border: 1px solid #555;
      padding: 2px 4px; font-size: 11px; border-radius: 4px; cursor: pointer;
      min-width: 32px; text-align: center;
    }
    .panel-controls .vol-label { font-size: 10px; color: #888; min-width: 24px; }
    .panel-controls .state-dot {
      width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    }
    .state-live { background: var(--c-danger); animation: pulse 1.5s infinite; }
    .state-playing { background: var(--c-success); }
    .state-buffering { background: var(--c-warning); animation: pulse 1s infinite; }
    .state-offline { background: #555; }
    @keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

    .panel iframe, .panel .yt-container, .panel video.hls-video { flex: 1; width: 100%; height: 100%; min-height: 0; border: none; background: #000; }
    /* Spotlight thumbnail click-catcher: lets you click an iframe (camera/YT)
       thumbnail to promote it to the main tile. Only present on thumbnails in
       spotlight mode; the main tile stays fully interactive. */
    .panel .spotlight-tap {
      position: absolute; inset: 0; z-index: 6; cursor: pointer;
      background: transparent;
    }
    .panel .spotlight-tap::after {
      content: "Click to make main";
      position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
      background: rgba(0,0,0,0.6); color: #fff; font-size: 11px;
      padding: 4px 10px; border-radius: 4px; opacity: 0; transition: opacity 0.15s;
      pointer-events: none; white-space: nowrap;
    }
    .panel .spotlight-tap:hover::after { opacity: 1; }
    .panel .yt-container { position: relative; flex: 1; min-height: 0; }
    .panel .yt-container iframe { position: absolute; inset: 0; width: 100%; height: 100%; }
    .panel video.hls-video { display: block; object-fit: contain; }
    /* Fit modes — toggle via .fit-cover (fill, crop edges) or .fit-stretch (distort to fit) */
    .panel.fit-cover video.hls-video { object-fit: cover; }
    .panel.fit-stretch video.hls-video { object-fit: fill; }
    .panel.fit-cover iframe { transform: scale(1.3); transform-origin: center; }
    .panel.fit-stretch iframe { transform: scaleX(1.3); transform-origin: center; }
    .mv-slot.fit-cover video { object-fit: cover; }
    .mv-slot.fit-stretch video { object-fit: fill; }
    .mv-slot.fit-cover iframe { transform: scale(1.3); transform-origin: center; }
    .mv-slot.fit-stretch iframe { transform: scaleX(1.3); transform-origin: center; }

    /* ─────── Multi-View Panel Styles ─────── */
    .multiview {
      display: flex; flex-direction: column;
      flex: 1; width: 100%; height: 100%; min-height: 0;
      background: #000; position: relative;
    }
    .mv-header {
      display: flex; align-items: center; gap: 4px;
      padding: 4px 8px; background: rgba(0,0,0,0.85);
      border-bottom: 1px solid rgba(255,255,255,0.08);
      min-height: 32px; flex-shrink: 0;
      z-index: 5;
    }
    .mv-mode-toggle { display: flex; gap: 2px; flex-shrink: 0; }
    .mv-mode-btn {
      background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
      color: #aaa; width: 28px; height: 24px; border-radius: 3px;
      font-size: 13px; cursor: pointer; line-height: 1;
      display: flex; align-items: center; justify-content: center;
      transition: all 0.15s;
    }
    .mv-mode-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
    .mv-mode-btn.active { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
    .mv-tab-strip {
      display: flex; gap: 2px; flex: 1; overflow-x: auto; overflow-y: hidden;
      scrollbar-width: thin; scrollbar-color: #444 transparent;
      min-width: 0;
    }
    .mv-tab-strip::-webkit-scrollbar { height: 4px; }
    .mv-tab-strip::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }
    .mv-tab {
      background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
      color: #bbb; padding: 4px 10px; border-radius: 4px;
      font-size: 12px; cursor: pointer; white-space: nowrap;
      max-width: 120px; overflow: hidden; text-overflow: ellipsis;
      transition: all 0.15s; flex-shrink: 0;
    }
    .mv-tab:hover { background: rgba(255,255,255,0.15); color: #fff; }
    .mv-tab.active { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
    .mv-tab .mv-tab-close {
      margin-left: 6px; opacity: 0.5; cursor: pointer;
      font-size: 11px; padding: 0 2px;
    }
    .mv-tab:hover .mv-tab-close { opacity: 1; }
    .mv-tab-close:hover { color: var(--c-danger); }
    .mv-add-btn {
      background: rgba(47, 208, 140, 0.2); border: 1px solid rgba(47, 208, 140, 0.4);
      color: var(--c-success); width: 24px; height: 24px; border-radius: 3px;
      font-size: 16px; cursor: pointer; line-height: 1; flex-shrink: 0;
      display: flex; align-items: center; justify-content: center;
    }
    .mv-add-btn:hover { background: rgba(47, 208, 140, 0.35); }
    .mv-body {
      position: relative; flex: 1; min-height: 0;
      background: #000; display: flex;
    }
    /* Tabs / Rotate modes: all slots mounted (kept playing in background), only active visible */
    .mv-body.mv-mode-tabs .mv-slot,
    .mv-body.mv-mode-rotate .mv-slot { position: absolute; inset: 0; }
    .mv-body.mv-mode-tabs .mv-slot:not(.mv-active),
    .mv-body.mv-mode-rotate .mv-slot:not(.mv-active) { visibility: hidden; pointer-events: none; }
    /* Grid / Stack / Row modes: CSS grid inside body */
    .mv-body.mv-mode-grid,
    .mv-body.mv-mode-stack,
    .mv-body.mv-mode-row {
      display: grid; gap: 2px; padding: 2px; background: #222;
    }
    .mv-body.mv-mode-grid .mv-slot,
    .mv-body.mv-mode-stack .mv-slot,
    .mv-body.mv-mode-row .mv-slot {
      position: relative; background: #000; overflow: hidden;
      min-width: 0; min-height: 0;
      border: 1px solid transparent; border-radius: 2px;
      cursor: pointer;
    }
    .mv-body.mv-mode-grid .mv-slot.mv-active,
    .mv-body.mv-mode-stack .mv-slot.mv-active,
    .mv-body.mv-mode-row .mv-slot.mv-active {
      border-color: var(--c-accent);
    }
    .mv-slot iframe, .mv-slot video, .mv-slot .yt-container {
      width: 100%; height: 100%; min-height: 0;
      border: none; background: #000; display: block;
      object-fit: contain;
    }
    .mv-slot .yt-container { position: relative; }
    .mv-slot .yt-container iframe { position: absolute; inset: 0; }
    .mv-slot-label {
      position: absolute; top: 4px; left: 4px; z-index: 3;
      background: rgba(0,0,0,0.7); color: #fff;
      font-size: 10px; font-weight: 500;
      padding: 2px 6px; border-radius: 3px;
      max-width: 80%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
      opacity: 0; transition: opacity 0.2s;
      pointer-events: none;
    }
    .mv-slot:hover .mv-slot-label { opacity: 1; }
    .mv-slot-audio {
      position: absolute; top: 4px; right: 4px; z-index: 3;
      background: rgba(77, 141, 255, 0.9); color: #fff;
      width: 20px; height: 20px; border-radius: 50%;
      font-size: 11px; display: none;
      align-items: center; justify-content: center;
    }
    .mv-body.mv-mode-grid .mv-slot.mv-active .mv-slot-audio,
    .mv-body.mv-mode-stack .mv-slot.mv-active .mv-slot-audio,
    .mv-body.mv-mode-row .mv-slot.mv-active .mv-slot-audio { display: flex; }
    .mv-slot-remove {
      position: absolute; top: 4px; right: 30px; z-index: 4;
      background: rgba(255,0,0,0.85); color: #fff;
      width: 20px; height: 20px; border-radius: 50%;
      font-size: 12px; border: none; cursor: pointer;
      display: none; align-items: center; justify-content: center;
      line-height: 1;
    }
    .mv-slot:hover .mv-slot-remove { display: flex; }
    /* Rotate progress bar */
    .mv-rotate-progress {
      position: absolute; bottom: 0; left: 0; right: 0;
      height: 2px; background: rgba(255,255,255,0.1);
      pointer-events: none; z-index: 4;
    }
    .mv-rotate-progress-bar {
      height: 100%; background: var(--c-accent);
      width: 0%; transition: width 0.1s linear;
    }
    .mv-rotate-controls {
      position: absolute; bottom: 4px; right: 4px; z-index: 4;
      background: rgba(0,0,0,0.7); border-radius: 4px;
      display: flex; align-items: center; gap: 4px;
      padding: 2px 4px;
    }
    .mv-rotate-controls button {
      background: none; border: none; color: #fff;
      cursor: pointer; padding: 2px 6px; font-size: 12px;
    }
    .mv-rotate-controls button:hover { color: var(--c-accent); }
    .mv-empty {
      display: flex; align-items: center; justify-content: center;
      height: 100%; color: #666; font-size: 13px; padding: 20px;
      text-align: center;
    }
    /* Combine modal specific */
    .combine-stream-list {
      max-height: 240px; overflow-y: auto;
      border: 1px solid var(--c-border); border-radius: var(--r-md);
      padding: 4px; margin: 8px 0;
    }
    .combine-stream-item {
      display: flex; align-items: center; gap: 8px;
      padding: 8px; cursor: pointer; border-radius: 4px;
      font-size: 14px;
    }
    .combine-stream-item:hover { background: var(--c-bg-3); }
    .combine-stream-item input { cursor: pointer; }
    .combine-mode-option {
      display: flex; align-items: flex-start; gap: 10px;
      padding: 10px; border: 1px solid var(--c-border);
      border-radius: var(--r-md); margin-bottom: 6px;
      cursor: pointer; transition: all 0.15s;
    }
    .combine-mode-option:hover { background: var(--c-bg-3); }
    .combine-mode-option.selected {
      border-color: var(--c-accent); background: rgba(77, 141, 255, 0.1);
    }
    .combine-mode-option-title {
      font-weight: 600; font-size: 14px; color: var(--c-text);
    }
    .combine-mode-option-desc {
      font-size: 12px; color: var(--c-text-dim); margin-top: 2px;
    }
    /* Mobile: narrow Multi-View collapses tab strip */
    @media (max-width: 500px) {
      .mv-header { padding: 3px 4px; gap: 3px; }
      .mv-tab { max-width: 80px; font-size: 11px; padding: 3px 6px; }
      .mv-mode-btn { width: 24px; height: 22px; font-size: 12px; }
    }

    /* Chat sidebar */
    .panel.with-chat { flex-direction: row; }
    .panel.with-chat iframe, .panel.with-chat .yt-container { flex: 1; min-width: 0; }
    .panel .chat-frame { width: 340px; border: none; border-left: 1px solid #222; flex-shrink: 0; }

    /* ── Favorite star in panel header ── */
    .panel-header .fav-btn { color: #555; cursor: pointer; font-size: 14px; transition: color 0.2s; background: none; border: none; padding: 2px 4px; }
    .panel-header .fav-btn:hover { color: var(--c-warning-bright); }
    .panel-header .fav-btn.favorited { color: var(--c-warning-bright); }

    /* ── Modals ── */
    .overlay {
      display: none; position: fixed; inset: 0; background: var(--c-overlay);
      backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
      z-index: var(--z-modal); align-items: center; justify-content: center;
    }
    .overlay.active { display: flex; }
    .modal {
      background: var(--c-bg-2); border: 1px solid var(--c-border); border-radius: var(--r-lg);
      padding: var(--sp-6); width: 540px; max-width: 92vw; max-height: 80vh; overflow-y: auto;
      box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
    }
    .modal h3 {
      margin-bottom: var(--sp-3); font-size: var(--fs-xl); font-weight: 600;
      letter-spacing: 0.2px;
    }
    .modal .hint { font-size: 12px; color: var(--c-text-dim); margin-bottom: 10px; }
    .modal textarea, .modal input[type="text"], .modal input[type="password"] {
      width: 100%; background: var(--c-bg-1); color: var(--c-text); border: 1px solid var(--c-border);
      border-radius: var(--r-md); padding: 10px; font-size: 16px; outline: none; margin-bottom: 8px;
    }
    .modal textarea { height: 180px; resize: vertical; font-family: monospace; }
    .modal textarea:focus, .modal input:focus { border-color: var(--c-accent); }
    .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
    .form-error { color: var(--c-accent); font-size: 12px; margin-bottom: 8px; min-height: 16px; }
    .form-row { margin-bottom: 4px; }
    .form-row label { font-size: 12px; color: var(--c-text-dim); display: block; margin-bottom: 2px; }

    .layout-list { list-style: none; margin: 10px 0; }
    .layout-list li {
      display: flex; align-items: center; gap: 6px; padding: 8px 12px;
      background: var(--c-bg-1); border-radius: var(--r-md); margin-bottom: 6px; cursor: pointer;
    }
    .layout-list li:hover { background: var(--c-bg-3); }
    .layout-list li .layout-name { flex: 1; font-size: 14px; }

    .share-box {
      display: flex; align-items: center; gap: 6px; background: var(--c-bg-1);
      padding: 8px; border-radius: var(--r-md); margin-top: 10px;
    }
    .share-box input { flex: 1; margin: 0 !important; font-size: 12px !important; }

    /* Gallery */
    .gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin: 10px 0; }
    .gallery-card {
      background: var(--c-bg-1); border-radius: var(--r-md); padding: 12px; cursor: pointer;
      border: 1px solid transparent; transition: border-color 0.2s;
    }
    .gallery-card:hover { border-color: var(--c-accent); }
    .gallery-card .card-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
    .gallery-card .card-info { font-size: 11px; color: var(--c-text-dim); }

    /* Search results */
    .search-results { margin: 10px 0; max-height: 300px; overflow-y: auto; }
    .search-item {
      display: flex; gap: 10px; padding: 8px; background: var(--c-bg-1); border-radius: var(--r-md);
      margin-bottom: 6px; cursor: pointer; align-items: center;
    }
    .search-item:hover { background: var(--c-bg-3); }
    .search-item img { width: 120px; height: 68px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
    .search-item .info { flex: 1; min-width: 0; }
    .search-item .info .s-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .search-item .info .s-channel { font-size: 11px; color: var(--c-text-dim); }

    .tab-row { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
    .tab-row .btn.active { background: var(--c-accent); color: #fff; }

    .setting-row {
      display: flex; align-items: center; justify-content: space-between;
      padding: 8px 12px; background: var(--c-bg-1); border-radius: var(--r-md); margin-bottom: 6px;
    }
    .setting-label { font-size: 13px; }
    .setting-row input[type="checkbox"] {
      width: 18px; height: 18px; accent-color: var(--c-accent); cursor: pointer;
    }

    /* ══════════════════════ MIXER PANEL ══════════════════════ */
    .mixer-panel {
      position: fixed; bottom: 0; left: 0; right: 0; z-index: var(--z-mixer);
      background: var(--c-bg-1);
      border-top: 1px solid var(--c-border);
      transform: translateY(100%); transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
      display: flex; flex-direction: column;
    }
    .mixer-panel.open { transform: translateY(0); }
    .mixer-panel.mixer-fade {
      opacity: 0; transition: transform 0.35s cubic-bezier(0.4,0,0.2,1), opacity 0.4s;
    }
    .mixer-panel.mixer-fade.mixer-visible { opacity: 1; }
    .mixer-panel.open.mixer-fade { opacity: 1; }

    .mixer-top-bar {
      display: flex; align-items: center; gap: 8px; padding: 0 12px;
      background: var(--c-bg-0); border-bottom: 1px solid var(--c-border); height: 26px; flex-shrink: 0;
    }
    .mixer-top-bar .mixer-title {
      font-size: 10px; font-weight: 700; color: var(--c-accent); letter-spacing: 2px; text-transform: uppercase;
    }
    .mixer-top-bar .mixer-stream-count {
      font-size: 9px; color: #666; margin-left: auto;
    }

    .mixer-drag-handle {
      width: 100%; height: 8px; cursor: ns-resize; display: flex; align-items: center; justify-content: center;
      background: var(--c-bg-2); flex-shrink: 0;
    }
    .mixer-drag-handle::after {
      content: ''; width: 40px; height: 4px; background: var(--c-border); border-radius: var(--r-full);
    }

    .mixer-body {
      display: flex; flex: 1; overflow-x: auto; overflow-y: hidden; min-height: 0;
      gap: 0; -webkit-overflow-scrolling: touch;
    }

    .mixer-channel {
      display: flex; flex-direction: column; align-items: center; min-width: 180px; width: 180px;
      padding: 8px 14px 10px; border-right: 1px solid var(--c-border); flex-shrink: 0;
      gap: 4px; background: var(--c-bg-2);
      box-shadow: inset 0 0 8px rgba(0,0,0,0.4);
    }
    @media (min-width: 1400px) {
      .mixer-channel { min-width: 200px; width: 200px; padding: 10px 16px 12px; }
    }

    .mixer-channel .ch-color-strip {
      width: 100%; height: 3px; border-radius: 1px; flex-shrink: 0;
    }
    .mixer-channel .ch-number {
      font-size: 9px; color: #666; font-weight: 700; letter-spacing: 1.5px; flex-shrink: 0;
    }
    .mixer-channel .ch-name {
      font-size: 11px; color: #ccc; text-align: center; width: 100%;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
      height: 14px; line-height: 14px;
    }

    /* Stereo VU Meters */
    .vu-meter-stereo {
      display: flex; gap: 3px; flex-shrink: 0; align-items: flex-end;
      padding: 4px 0;
    }
    .vu-meter {
      display: flex; flex-direction: column-reverse; gap: 1px; width: 12px; height: 80px; flex-shrink: 0;
      border-radius: 2px; overflow: hidden;
    }
    .vu-meter .vu-seg {
      flex: 1; width: 100%; border-radius: 1px; background: #1a1a1a;
      transition: none;
    }
    .vu-meter .vu-seg.lit-green { background: var(--c-success); box-shadow: 0 0 3px rgba(47, 208, 140, 0.3); }
    .vu-meter .vu-seg.lit-yellow { background: var(--c-warning-bright); box-shadow: 0 0 3px rgba(241,196,15,0.3); }
    .vu-meter .vu-seg.lit-red { background: var(--c-danger); box-shadow: 0 0 4px rgba(231,76,60,0.4); }
    .vu-meter .vu-seg.lit-peak { background: #fff; box-shadow: 0 0 4px rgba(255,255,255,0.5); }

    /* Gain / Pan Knobs */
    .mixer-knob-row {
      display: flex; gap: 16px; align-items: center; justify-content: center; flex-shrink: 0;
      padding: 4px 0;
    }
    .mixer-knob-wrap {
      display: flex; flex-direction: column; align-items: center; gap: 2px;
    }
    .mixer-knob-label {
      font-size: 8px; color: #666; text-transform: uppercase; letter-spacing: 1px; font-weight: 600;
    }
    .mixer-knob {
      width: 36px; height: 36px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #555, #222);
      border: 2px solid #444; cursor: pointer; position: relative;
      box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
    }
    .mixer-knob:hover { border-color: #666; }
    .mixer-knob::after {
      content: ''; position: absolute; width: 2px; height: 12px; background: #ddd;
      top: 3px; left: 50%; transform: translateX(-50%); border-radius: 1px;
    }
    .mixer-knob.pan-knob::after {
      transform-origin: bottom center; top: 3px;
    }

    /* Vertical Fader */
    .mixer-fader-wrap {
      display: flex; align-items: center; justify-content: center; flex: 1; min-height: 60px;
      position: relative;
    }
    .mixer-fader-ticks {
      position: absolute; right: 4px; top: 0; bottom: 0; display: flex; flex-direction: column;
      justify-content: space-between; pointer-events: none;
    }
    .mixer-fader-ticks span {
      font-size: 6px; color: #444; line-height: 1;
    }
    .mixer-fader {
      writing-mode: vertical-lr;
      direction: rtl;
      -webkit-appearance: none; appearance: none;
      width: 100px; height: var(--touch-min);
      background: transparent; cursor: pointer;
    }
    .mixer-fader::-webkit-slider-runnable-track {
      height: 4px; background: linear-gradient(to right, #333, #444); border-radius: 2px;
      box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
    }
    .mixer-fader::-webkit-slider-thumb {
      -webkit-appearance: none; width: 28px; height: 36px;
      background: linear-gradient(180deg, #e0e0e0 0%, #aaa 50%, #bbb 100%);
      border-radius: 4px; margin-top: -16px; cursor: pointer;
      box-shadow: 0 1px 4px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.3);
      border: 1px solid #666;
    }
    .mixer-fader::-moz-range-track {
      height: 4px; background: linear-gradient(to top, #333, #444); border-radius: 2px;
      box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
    }
    .mixer-fader::-moz-range-thumb {
      width: 28px; height: 36px;
      background: linear-gradient(180deg, #e0e0e0 0%, #aaa 50%, #bbb 100%);
      border-radius: 4px; cursor: pointer; border: 1px solid #666;
      box-shadow: 0 1px 4px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.3);
    }

    .mixer-db-label {
      font-size: 11px; color: #aaa; text-align: center; height: 16px; line-height: 16px; flex-shrink: 0;
      font-family: 'Courier New', monospace; font-weight: 600; padding: 2px 0;
    }

    .mixer-btn-row {
      display: flex; gap: 6px; justify-content: center; flex-shrink: 0; flex-wrap: wrap;
      padding: 4px 0;
    }
    .mixer-btn {
      width: var(--touch-min); height: 32px; border: none; border-radius: var(--r-sm);
      font-size: 12px; font-weight: 700;
      cursor: pointer; display: flex; align-items: center; justify-content: center;
      background: #2a2a2a; color: #888; transition: background 0.15s, color 0.15s;
      letter-spacing: 0.5px;
    }
    .mixer-btn:hover { background: #3a3a3a; }
    .mixer-btn.mute-active { background: var(--c-danger-strong); color: #fff; }
    .mixer-btn.solo-active { background: var(--c-warning-bright); color: #000; }
    .mixer-btn.listen-active { background: var(--c-accent); color: #fff; }
    .mixer-btn.pin-active { background: var(--c-info-strong); color: #fff; }
    .mixer-btn.rec-active { background: var(--c-danger); color: #fff; box-shadow: 0 0 6px rgba(231,76,60,0.5); }

    /* ── Recording Overlay ── */
    .rec-overlay {
      display: none; position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-toast);
      background: rgba(200,0,0,0.85); color: #fff; padding: 8px 16px;
      font-size: 14px; font-weight: 600; text-align: center;
      align-items: center; justify-content: center; gap: 10px;
      backdrop-filter: blur(4px); letter-spacing: 0.5px;
    }
    .rec-overlay.visible { display: flex; }
    .rec-dot {
      width: 12px; height: 12px; background: #fff; border-radius: 50%;
      animation: rec-pulse 1s ease-in-out infinite;
    }
    @keyframes rec-pulse {
      0%, 100% { opacity: 1; transform: scale(1); }
      50% { opacity: 0.3; transform: scale(0.8); }
    }
    .btn.rec-active-btn {
      background: #cc0000 !important; color: #fff !important;
      display: inline-flex !important; align-items: center; gap: 6px;
    }
    .rec-btn-dot {
      display: inline-block; width: 10px; height: 10px; border-radius: 50%;
      background: var(--c-danger); animation: rec-btn-pulse 1s ease-in-out infinite;
      flex-shrink: 0;
    }
    @keyframes rec-btn-pulse {
      0%, 100% { opacity: 1; box-shadow: 0 0 4px rgba(255,68,68,0.8); }
      50% { opacity: 0.3; box-shadow: 0 0 8px rgba(255,68,68,0.4); }
    }

    .mixer-vol-label {
      font-size: 9px; color: #666; text-align: center; height: 12px; line-height: 12px; flex-shrink: 0;
    }

    /* Master channel */
    .mixer-master {
      min-width: 200px; width: 200px; border-left: 1px solid var(--c-border); background: var(--c-bg-1);
      display: flex; flex-direction: column; align-items: center; padding: 8px 16px 10px;
      gap: 4px; flex-shrink: 0;
    }
    .mixer-master .ch-name {
      font-size: 11px; color: var(--c-accent); font-weight: 700; letter-spacing: 2px;
    }
    .mixer-solo-banner {
      width: 100%; padding: var(--sp-1) var(--sp-2); border-radius: var(--r-sm);
      background: var(--c-warning); color: #2a1d04; font-size: var(--fs-xs);
      font-weight: 700; letter-spacing: 1px; text-align: center; cursor: pointer;
    }
    /* Streams whose audio can't be controlled from the app (Twitch/Kick/
       generic iframes): make the dead controls visibly inert */
    .panel.audio-na .panel-controls input[type="range"],
    .panel.audio-na .panel-controls .vol-label,
    .panel.audio-na .panel-controls .btn.xs:first-child {
      opacity: 0.35; pointer-events: none;
    }
    .mixer-master .mixer-db-label { color: var(--c-accent); }
    .mixer-master-btns {
      display: flex; flex-direction: column; gap: 3px; width: 100%;
    }
    .mixer-master-btn {
      width: 100%; padding: 5px; border: none; border-radius: 3px; font-size: 9px; font-weight: 600;
      cursor: pointer; background: #2a2a2a; color: #aaa; transition: background 0.15s;
    }
    .mixer-master-btn:hover { background: #3a3a3a; color: #fff; }

    /* ── EQ Knobs (smaller than gain/pan) ── */
    .mixer-eq-row {
      display: flex; gap: 4px; align-items: center; justify-content: center; flex-shrink: 0;
      padding: 2px 0; border-bottom: 1px solid #1a1a1a; margin-bottom: 1px;
    }
    .mixer-eq-wrap {
      display: flex; flex-direction: column; align-items: center; gap: 0px;
    }
    .mixer-eq-label {
      font-size: 6px; color: #555; text-transform: uppercase; letter-spacing: 0.3px; line-height: 1;
    }
    .mixer-eq-knob {
      width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #3a3a3a, #1e1e1e);
      border: 1.5px solid #2a2a2a; cursor: pointer; position: relative;
      box-shadow: 0 1px 3px rgba(0,0,0,0.4);
    }
    .mixer-eq-knob::after {
      content: ''; position: absolute; width: 1.5px; height: 7px; background: #aaa;
      top: 2px; left: 50%; transform: translateX(-50%); border-radius: 1px;
    }
    .mixer-eq-value {
      font-size: 6px; color: #666; font-family: 'Courier New', monospace; line-height: 1; min-height: 8px; text-align: center;
    }

    /* ── Clip LED ── */
    .clip-led {
      width: 8px; height: 8px; border-radius: 50%; background: #2a1a1a; border: 1px solid #333;
      flex-shrink: 0; cursor: pointer; transition: background 0.05s;
    }
    .clip-led.clipped {
      background: #ff2222; border-color: var(--c-danger);
      box-shadow: 0 0 6px rgba(255,34,34,0.7), 0 0 12px rgba(255,34,34,0.3);
    }

    /* ── Fader Scale Markings ── */
    .fader-scale {
      position: absolute; left: 2px; top: 0; bottom: 0; display: flex; flex-direction: column;
      justify-content: space-between; pointer-events: none;
    }
    .fader-scale span {
      font-size: 5px; color: #333; line-height: 1; font-family: 'Courier New', monospace;
    }

    /* ── Channel Link Button ── */
    .mixer-link-btn {
      position: absolute; right: -9px; top: 50%; transform: translateY(-50%);
      width: 16px; height: 20px; border: 1px solid #333; border-radius: 3px;
      background: #1a1a1a; color: #555; font-size: 6px; font-weight: 700;
      cursor: pointer; z-index: 2; display: flex; align-items: center; justify-content: center;
      letter-spacing: -0.3px; transition: background 0.15s, color 0.15s;
    }
    .mixer-link-btn:hover { background: #2a2a2a; color: #aaa; }
    .mixer-link-btn.link-active { background: var(--c-info-strong); color: #fff; border-color: var(--c-info); }
    .mixer-channel { position: relative; }

    /* ── Solo Mode Toggle ── */
    .solo-mode-toggle {
      display: flex; border-radius: 3px; overflow: hidden; border: 1px solid #333; width: 100%;
    }
    .solo-mode-btn {
      flex: 1; padding: 3px 0; border: none; font-size: 7px; font-weight: 700;
      cursor: pointer; background: #1a1a1a; color: #555; transition: background 0.15s, color 0.15s;
      letter-spacing: 0.5px; text-align: center;
    }
    .solo-mode-btn:hover { background: #2a2a2a; }
    .solo-mode-btn.active { background: var(--c-warning); color: #000; }

    /* ── Mixer Preset Buttons ── */
    .mixer-preset-btns {
      display: flex; gap: 3px; width: 100%;
    }
    .mixer-preset-btn {
      flex: 1; padding: 4px; border: none; border-radius: 3px; font-size: 8px; font-weight: 600;
      cursor: pointer; background: #222; color: #888; transition: background 0.15s;
      letter-spacing: 0.5px;
    }
    .mixer-preset-btn:hover { background: #3a3a3a; color: #fff; }
    .mixer-preset-btn.save { color: var(--c-success); }
    .mixer-preset-btn.save:hover { background: #1a5c32; color: #fff; }
    .mixer-preset-btn.load { color: var(--c-info); }
    .mixer-preset-btn.load:hover { background: #1a3c5c; color: #fff; }

    /* ── Mute Groups ── */
    .mute-groups-section {
      width: 100%; margin-top: 6px; border-top: 1px solid #333; padding-top: 6px;
    }
    .mute-groups-title {
      font-size: 7px; color: #555; text-transform: uppercase; letter-spacing: 1px;
      text-align: center; margin-bottom: 4px; font-weight: 700;
    }
    .mute-group-btns {
      display: grid; grid-template-columns: 1fr 1fr; gap: 3px;
    }
    .mute-group-btn {
      padding: 4px 2px; border: 1px solid #333; border-radius: 3px; font-size: 8px; font-weight: 700;
      cursor: pointer; background: #1a1a1a; color: #666; transition: background 0.15s, color 0.15s;
      text-align: center; letter-spacing: 0.3px;
    }
    .mute-group-btn:hover { background: #2a2a2a; color: #aaa; }
    .mute-group-btn.mg-active { background: var(--c-danger-strong); color: #fff; border-color: var(--c-danger); }

    /* ── Channel Mute Group Indicator ── */
    .ch-mute-group-row {
      display: flex; gap: 3px; justify-content: center; flex-shrink: 0; margin-top: 2px;
    }
    .ch-mg-btn {
      width: 16px; height: 14px; border: 1px solid #333; border-radius: 2px; font-size: 7px;
      font-weight: 700; cursor: pointer; background: #1a1a1a; color: #555;
      display: flex; align-items: center; justify-content: center;
      transition: background 0.15s, color 0.15s;
    }
    .ch-mg-btn:hover { background: #2a2a2a; }
    .ch-mg-btn.mg-assigned { background: var(--c-info-strong); color: #fff; border-color: var(--c-info); }

    /* ── Enhanced Channel Color Strip ── */
    .ch-name-colored {
      font-size: 9px; color: #aaa; text-align: center; width: 100%;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
      height: 14px; line-height: 14px; border-radius: 2px; padding: 0 2px;
    }

    /* ══════════════════════ KIOSK MODE ══════════════════════ */
    body.kiosk-mode .toolbar,
    body.kiosk-mode .mixer-panel,
    body.kiosk-mode .restore-banner,
    body.kiosk-mode .pwa-banner { display: none !important; opacity: 0 !important; pointer-events: none !important; }
    /* In kiosk mode, allow toolbar to appear when chrome-hover is active (touch tap) */
    body.kiosk-mode.chrome-hover .toolbar { display: flex !important; transform: translateY(0) !important; pointer-events: auto !important; }
    body.kiosk-mode { background: #000; cursor: none; }
    body.kiosk-mode .grid { background: #000; gap: 1px; padding: 0; }
    body.kiosk-mode .panel { border-radius: 0; border: none; }
    body.kiosk-mode .panel:hover { border-color: transparent; }
    body.kiosk-mode .panel-header,
    body.kiosk-mode .panel-controls { opacity: 0; }
    body.kiosk-mode .panel:hover .panel-header,
    body.kiosk-mode .panel:hover .panel-controls { opacity: 1; }
    body.kiosk-mode.show-cursor { cursor: default; }

    /* TV Mode — optimized for casting / big screens / AirPlay */
    body.tv-mode { background: #000; }
    body.tv-mode .grid { gap: 2px; background: #000; width: 100vw; height: 100vh; aspect-ratio: 16/9; max-height: 100vh; }
    body.tv-mode .panel { min-height: 0; }
    body.tv-mode .panel-header .title { font-size: 14px; }
    body.tv-mode .panel-controls { padding: 6px 14px; }
    body.tv-mode .empty h2 { font-size: 36px; }
    body.tv-mode .empty p { font-size: 16px; }
    body.tv-mode .toolbar { display: none !important; }

    /* Cast/AirPlay mode — force 16:9 viewport behavior */
    body.cast-mode { background: #000; overflow: hidden; }
    body.cast-mode .grid {
      width: 100vw; height: 100vh; aspect-ratio: 16/9;
      max-width: 100vw; max-height: 100vh;
      margin: auto; gap: 2px; background: #000;
    }
    body.cast-mode .toolbar { display: none !important; }
    body.cast-mode .panel { min-height: 0; border: none; border-radius: 0; }
    body.cast-mode .panel-header,
    body.cast-mode .panel-controls { opacity: 0; }

    /* Fullscreen / standalone display mode — optimize for external displays */
    @media (display-mode: fullscreen) {
      .grid { width: 100vw; height: 100vh; }
      .panel { min-height: 0; }
    }

    .kiosk-bar {
      display: none; position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
      background: rgba(0,0,0,0.9); border: 1px solid #333; border-radius: 16px;
      padding: 12px 24px; z-index: var(--z-kiosk); gap: 12px; align-items: center;
      transition: opacity 0.4s, transform 0.4s; backdrop-filter: blur(10px);
      flex-wrap: wrap; justify-content: center;
    }
    body.kiosk-mode .kiosk-bar, body.tv-mode .kiosk-bar { display: flex; }
    .kiosk-bar.kiosk-hidden { opacity: 0; transform: translateX(-50%) translateY(20px); pointer-events: none; }
    .kiosk-bar .btn {
      min-height: 44px; min-width: 44px; padding: 10px 16px; font-size: 14px;
    }

    /* Always-visible labeled pull tab at bottom center to reveal the bar */
    .kiosk-pull-tab {
      display: none; position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
      width: 120px; height: 40px; z-index: calc(var(--z-kiosk) + 1); cursor: pointer;
      background: rgba(255,255,255,0.22); border-radius: 12px 12px 0 0;
      border: 1px solid rgba(255,255,255,0.35); border-bottom: none;
      transition: background 0.2s;
      font-size: 13px; font-weight: 700; color: #fff;
      text-align: center; line-height: 40px; letter-spacing: 0.5px;
      user-select: none;
    }
    .kiosk-pull-tab:hover, .kiosk-pull-tab:active { background: rgba(255,255,255,0.45); }
    body.kiosk-mode .kiosk-pull-tab, body.tv-mode .kiosk-pull-tab { display: block; }

    /* THE one exit affordance for kiosk/TV/cast mode: always present and
       always clickable. Dims while you're idle so it doesn't burn into the
       video; any touch/mouse activity (chrome-hover) brings it back. Esc and
       the pull-tab utility bar remain as secondary paths. */
    .kiosk-exit-fab {
      display: none; position: fixed; top: 16px; right: 16px; z-index: calc(var(--z-kiosk) + 1);
      min-width: var(--touch-min); min-height: var(--touch-min); padding: 12px 20px;
      background: rgba(77, 141, 255, 0.92); color: #fff; border: 2px solid #fff;
      border-radius: var(--r-full); font-size: 14px; font-weight: 700; cursor: pointer;
      box-shadow: 0 4px 16px rgba(0,0,0,0.5); backdrop-filter: blur(8px);
      letter-spacing: 0.5px;
      opacity: 0.35; pointer-events: auto;
      transition: opacity var(--dur-slow) var(--ease);
    }
    .kiosk-exit-fab:hover { background: rgba(77, 141, 255, 1); opacity: 1; }
    body.kiosk-mode .kiosk-exit-fab,
    body.tv-mode .kiosk-exit-fab,
    body.cast-mode .kiosk-exit-fab { display: block; }
    body.kiosk-mode.chrome-hover .kiosk-exit-fab,
    body.tv-mode.chrome-hover .kiosk-exit-fab,
    body.cast-mode.chrome-hover .kiosk-exit-fab { opacity: 1; }

    /* Entry-time hint banner teaching keyboard + touch exit */
    .kiosk-hint {
      position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
      background: rgba(0,0,0,0.88); color: #fff; padding: 14px 24px;
      border-radius: 12px; z-index: calc(var(--z-kiosk) + 1); font-size: 15px;
      border: 1px solid rgba(255,255,255,0.3); backdrop-filter: blur(10px);
      pointer-events: none; opacity: 0; transition: opacity 0.4s;
      display: none; max-width: 90vw; text-align: center;
    }
    .kiosk-hint.show { display: block; opacity: 1; }

    /* Cast instructions modal */
    .cast-steps { list-style: none; margin: 12px 0; }
    .cast-steps li {
      padding: 10px 12px; background: var(--c-bg-1); border-radius: var(--r-md);
      margin-bottom: 6px; font-size: 13px; line-height: 1.5;
      display: flex; align-items: flex-start; gap: 8px;
    }
    .cast-steps li .step-num {
      background: var(--c-accent); color: #fff; width: 22px; height: 22px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center; font-size: 11px;
      font-weight: 700; flex-shrink: 0;
    }
    .cast-platform { margin-bottom: 16px; }
    .cast-platform h4 { font-size: 14px; margin-bottom: 8px; color: var(--c-accent); }

    /* ══════════════════════ SHORTCUTS MODAL ══════════════════════ */
    .shortcuts-grid {
      display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 12px 0;
    }
    .shortcuts-grid .sc-key {
      background: var(--c-bg-1); padding: 4px 10px; border-radius: 4px; font-family: monospace;
      font-size: 13px; text-align: center; font-weight: 600; color: var(--c-accent);
      border: 1px solid var(--c-border);
    }
    .shortcuts-grid .sc-desc { font-size: 13px; color: var(--c-text); display: flex; align-items: center; }

    /* ══════════════════════ SHORTCUTS CATEGORIES ══════════════════════ */
    .sc-category {
      grid-column: 1 / -1; font-size: 12px; font-weight: 700; color: var(--c-accent);
      text-transform: uppercase; letter-spacing: 1.5px; margin-top: 10px; padding-bottom: 4px;
      border-bottom: 1px solid var(--c-border);
    }
    .sc-category:first-child { margin-top: 0; }

    /* ══════════════════════ SCHEDULE SECTION ══════════════════════ */
    .schedule-form { background: var(--c-bg-1); border-radius: var(--r-md); padding: 12px; margin: 10px 0; }
    .schedule-form label { font-size: 12px; color: var(--c-text-dim); display: block; margin-bottom: 4px; }
    .schedule-form select, .schedule-form input[type="datetime-local"] {
      width: 100%; background: var(--c-bg-2); color: var(--c-text); border: 1px solid var(--c-border);
      padding: 8px; border-radius: var(--r-md); font-size: 13px; margin-bottom: 8px;
    }
    .schedule-list { list-style: none; margin: 10px 0; }
    .schedule-list li {
      display: flex; align-items: center; gap: 8px; padding: 8px 12px;
      background: var(--c-bg-1); border-radius: var(--r-md); margin-bottom: 6px; font-size: 13px;
    }
    .schedule-list .sched-layout { flex: 1; font-weight: 600; color: var(--c-text); }
    .schedule-list .sched-time { font-size: 11px; color: var(--c-text-dim); }
    .schedule-list .sched-repeat { font-size: 10px; color: var(--c-accent); text-transform: uppercase; letter-spacing: 0.5px; }
    .schedule-list .sched-toggle { cursor: pointer; accent-color: var(--c-success); }

    /* ══════════════════════ USER PROFILE ══════════════════════ */
    .profile-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
    .profile-avatar {
      width: 64px; height: 64px; border-radius: 50%; background: var(--c-bg-3);
      display: flex; align-items: center; justify-content: center; font-size: 28px;
      font-weight: 700; color: var(--c-accent); border: 2px solid var(--c-accent);
      text-transform: uppercase;
    }
    .profile-info h2 { font-size: 20px; margin-bottom: 2px; }
    .profile-info .profile-meta { font-size: 12px; color: var(--c-text-dim); }
    .profile-stats {
      display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px;
    }
    .profile-stat {
      background: var(--c-bg-1); border-radius: var(--r-md); padding: 14px; text-align: center;
    }
    .profile-stat .stat-num { font-size: 24px; font-weight: 700; color: var(--c-accent); }
    .profile-stat .stat-label { font-size: 11px; color: var(--c-text-dim); margin-top: 2px; }
    .profile-link-box {
      background: var(--c-bg-1); border-radius: var(--r-md); padding: 10px 14px;
      display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
    }
    .profile-link-box input {
      flex: 1; margin: 0 !important; font-family: monospace; font-size: 12px !important;
      background: var(--c-bg-2) !important;
    }
    .profile-layouts-list { list-style: none; margin: 10px 0; max-height: 200px; overflow-y: auto; }
    .profile-layouts-list li {
      display: flex; align-items: center; gap: 8px; padding: 8px 12px;
      background: var(--c-bg-1); border-radius: var(--r-md); margin-bottom: 6px;
    }
    .profile-layouts-list .pl-name { flex: 1; font-size: 13px; font-weight: 600; }
    .profile-layouts-list .pl-badge {
      font-size: 10px; padding: 2px 8px; border-radius: 10px; background: var(--c-success); color: #fff;
    }

    /* ══════════════════════ BOOT SCREEN ══════════════════════ */
    #boot-screen {
      position: fixed; inset: 0; z-index: var(--z-boot); background: #000;
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      transition: opacity 0.8s ease-out; overflow: hidden;
    }
    #boot-screen.fade-out { opacity: 0; pointer-events: none; }
    .boot-content {
      position: relative; z-index: 2; display: flex; flex-direction: column;
      align-items: center; gap: 24px;
    }
    .boot-tv-grid {
      display: grid; gap: 6px; transition: all 0.6s cubic-bezier(0.4,0,0.2,1);
      grid-template-columns: 1fr;
    }
    .boot-tv {
      width: 100px; height: 62px; border-radius: 6px; position: relative; overflow: hidden;
      border: 2px solid #333; background: #0a0a0a;
      opacity: 0; transform: scale(0.3);
      transition: opacity 0.4s, transform 0.4s cubic-bezier(0.34,1.56,0.64,1), border-color 0.4s;
      box-shadow: 0 0 0 rgba(77, 141, 255, 0);
    }
    .boot-tv.visible { opacity: 1; transform: scale(1); }
    .boot-tv.glow { border-color: var(--c-accent); box-shadow: 0 0 20px rgba(77, 141, 255, 0.3); }
    .boot-tv canvas { width: 100%; height: 100%; display: block; }
    .boot-tv .scanlines {
      position: absolute; inset: 0; pointer-events: none;
      background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.15) 2px, rgba(0,0,0,0.15) 4px);
    }
    .boot-tv .tv-label {
      position: absolute; bottom: 2px; left: 4px; font-size: 7px; color: rgba(255,255,255,0.4);
      font-family: monospace; letter-spacing: 1px;
    }
    .boot-title {
      font-size: 32px; font-weight: 700; letter-spacing: 10px; color: #fff;
      text-shadow: 0 0 30px rgba(77, 141, 255, 0.5), 0 0 60px rgba(77, 141, 255, 0.2);
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
      min-height: 40px;
    }
    .boot-subtitle {
      font-size: 12px; letter-spacing: 4px; color: rgba(255,255,255,0.3);
      text-transform: uppercase; min-height: 16px;
    }
    .boot-progress {
      width: 240px; height: 2px; background: rgba(255,255,255,0.08); border-radius: 1px; overflow: hidden;
    }
    .boot-progress-bar {
      width: 0%; height: 100%; background: linear-gradient(90deg, var(--c-accent), var(--c-accent-soft));
      border-radius: 1px; transition: width 0.1s linear;
      box-shadow: 0 0 10px rgba(77, 141, 255, 0.6);
    }
    /* Ambient glow behind TV grid */
    .boot-ambient {
      position: absolute; width: 300px; height: 300px; border-radius: 50%;
      background: radial-gradient(circle, rgba(77, 141, 255, 0.08) 0%, transparent 70%);
      animation: ambient-pulse 3s ease-in-out infinite; pointer-events: none;
    }
    @keyframes ambient-pulse {
      0%, 100% { transform: scale(1); opacity: 0.5; }
      50% { transform: scale(1.3); opacity: 1; }
    }

    /* ══════════════════════ SESSION RESTORE BANNER ══════════════════════ */
    .restore-banner {
      position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-toast);
      background: var(--c-bg-2); border-bottom: 1px solid var(--c-border);
      padding: 10px 16px; display: flex; align-items: center; gap: 12px;
      font-size: 13px; animation: slide-down 0.3s ease-out;
    }
    @keyframes slide-down { from { transform: translateY(-100%); } to { transform: translateY(0); } }
    .restore-banner .restore-text { flex: 1; color: var(--c-text); }

    /* ══════════════════════ LOADING / SKELETON STATES ══════════════════════ */
    .panel-loading {
      position: absolute; inset: 0; display: flex; flex-direction: column;
      align-items: center; justify-content: center; gap: 12px;
      background: var(--c-panel); z-index: 1;
      animation: skeleton-pulse 1.5s ease-in-out infinite;
    }
    @keyframes skeleton-pulse {
      0%, 100% { background: var(--c-panel); }
      50% { background: #111; }
    }
    .panel-loading .loading-spinner {
      width: 32px; height: 32px; border: 3px solid #333; border-top-color: var(--c-accent);
      border-radius: 50%; animation: spin 0.8s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }
    .panel-loading .loading-text { font-size: 11px; color: var(--c-text-dim); }

    .panel-error {
      position: absolute; inset: 0; display: flex; flex-direction: column;
      align-items: center; justify-content: center; gap: 10px;
      background: var(--c-panel); z-index: 1;
    }
    .panel-error .error-msg { font-size: 13px; color: var(--c-text-dim); text-align: center; }
    .panel-error .btn { font-size: 12px; }

    /* ══════════════════════ CHANNEL GUIDE ══════════════════════ */
    .guide-categories { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
    .guide-categories .btn.active { background: var(--c-accent); color: #fff; }
    .guide-list { max-height: 400px; overflow-y: auto; }
    .guide-item {
      display: flex; align-items: center; gap: 10px; padding: 8px 12px;
      background: var(--c-bg-1); border-radius: var(--r-md); margin-bottom: 4px;
      cursor: pointer; transition: background 0.15s;
    }
    .guide-item:hover { background: var(--c-bg-3); }
    .guide-item .guide-icon { font-size: 18px; width: 28px; text-align: center; flex-shrink: 0; }
    .guide-item .guide-info { flex: 1; min-width: 0; }
    .guide-item .guide-name { font-size: 13px; font-weight: 600; }
    .guide-item .guide-desc { font-size: 11px; color: var(--c-text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .guide-item .guide-add-btn { font-size: 22px; color: var(--c-success); cursor: pointer; padding: 10px 12px; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; transition: transform 0.15s; }
    .guide-item .guide-add-btn:active { transform: scale(0.9); }
    .guide-item .guide-fav-btn { font-size: 20px; color: #555; cursor: pointer; padding: 10px 12px; background: none; border: none; transition: color 0.2s, transform 0.15s; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
    .guide-item .guide-fav-btn:hover { color: var(--c-warning-bright); transform: scale(1.2); }
    .guide-item .guide-fav-btn:active { transform: scale(0.9); }
    .guide-item .guide-fav-btn.favorited { color: var(--c-warning-bright); }

    /* ══════════════════════ ONBOARDING TOUR ══════════════════════ */
    .tour-overlay {
      position: fixed; inset: 0; z-index: var(--z-tour); background: rgba(0,0,0,0.7);
      display: flex; align-items: center; justify-content: center;
    }
    .tour-highlight {
      position: fixed; z-index: calc(var(--z-tour) + 1); border: 2px solid var(--c-accent);
      border-radius: var(--r-md); box-shadow: 0 0 0 9999px rgba(0,0,0,0.65);
      transition: all 0.4s ease;
    }
    .tour-tooltip {
      position: fixed; z-index: calc(var(--z-tour) + 2); background: var(--c-bg-2); border: 1px solid var(--c-border);
      border-radius: 12px; padding: 20px; max-width: 320px; min-width: 240px;
      box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    }
    .tour-tooltip h4 { font-size: 16px; margin-bottom: 8px; color: var(--c-text); }
    .tour-tooltip p { font-size: 13px; color: var(--c-text-dim); line-height: 1.5; margin-bottom: 14px; }
    .tour-tooltip .tour-actions { display: flex; align-items: center; gap: 8px; }
    .tour-tooltip .tour-dots { flex: 1; display: flex; gap: 6px; }
    .tour-tooltip .tour-dot {
      width: 8px; height: 8px; border-radius: 50%; background: #333;
    }
    .tour-tooltip .tour-dot.active { background: var(--c-accent); }
    .tour-step-indicator { font-size: 11px; color: var(--c-text-dim); text-align: center; margin-bottom: 8px; }

    /* ══════════════════════ PWA INSTALL ══════════════════════ */
    .pwa-install-btn {
      background: var(--c-success); color: #fff; border: none; padding: 6px 12px;
      border-radius: var(--r-md); font-size: 12px; cursor: pointer; white-space: nowrap;
      transition: background 0.15s; display: none;
    }
    .pwa-install-btn:hover { background: var(--c-success-strong); }
    .pwa-ios-modal-overlay {
      position: fixed; inset: 0; z-index: var(--z-modal); background: rgba(0,0,0,0.6);
      display: flex; align-items: center; justify-content: center;
    }
    .pwa-ios-modal {
      background: var(--c-bg-2); border: 1px solid var(--c-border); border-radius: 12px;
      padding: 24px; max-width: 340px; width: 90%; text-align: center;
      box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    }
    .pwa-ios-modal h4 { margin-bottom: 12px; color: var(--c-text); font-size: 16px; }
    .pwa-ios-modal p { font-size: 13px; color: var(--c-text-dim); line-height: 1.6; margin-bottom: 16px; }
    .pwa-ios-modal .ios-steps { text-align: left; margin: 12px 0; font-size: 13px; color: var(--c-text); }
    .pwa-ios-modal .ios-steps li { margin-bottom: 6px; }

    /* ══════════════════════ GALLERY CATEGORIES ══════════════════════ */
    .gallery-filter-tabs {
      display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px;
    }
    .gallery-filter-tabs .filter-tab {
      background: var(--c-bg-1); color: var(--c-text-dim); border: 1px solid var(--c-border);
      padding: 4px 10px; border-radius: 14px; font-size: 11px; cursor: pointer;
      transition: all 0.15s;
    }
    .gallery-filter-tabs .filter-tab:hover { border-color: var(--c-accent); color: var(--c-text); }
    .gallery-filter-tabs .filter-tab.active { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
    .gallery-card .card-category {
      display: inline-block; font-size: 10px; color: var(--c-accent-soft); background: rgba(77, 141, 255, 0.1);
      padding: 2px 6px; border-radius: 8px; margin-top: 4px;
    }
    .gallery-card .card-meta {
      display: flex; justify-content: space-between; align-items: center; margin-top: 6px;
    }
    .gallery-card .card-load-btn {
      background: var(--c-accent); color: #fff; border: none; padding: 4px 10px;
      border-radius: var(--r-md); font-size: 11px; cursor: pointer;
      transition: background 0.15s;
    }
    .gallery-card .card-load-btn:hover { background: var(--c-accent-soft); }

    /* ══════════════════════ SAVE LAYOUT CATEGORY ══════════════════════ */
    .layout-category-row {
      display: flex; gap: 6px; align-items: center; margin-bottom: 10px;
    }
    .layout-category-row label { font-size: 12px; color: var(--c-text-dim); white-space: nowrap; }
    .layout-category-row select {
      background: var(--c-bg-1); color: var(--c-text); border: 1px solid var(--c-border);
      padding: 6px 8px; border-radius: var(--r-md); font-size: 12px;
    }
    .layout-category-row .public-toggle {
      display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--c-text-dim); cursor: pointer;
    }
    .layout-category-row .public-toggle input { cursor: pointer; }
    .pwa-banner {
      position: fixed; bottom: 0; left: 0; right: 0; z-index: var(--z-kiosk);
      background: var(--c-bg-2); border-top: 1px solid var(--c-border);
      padding: 12px 16px; display: flex; align-items: center; gap: 12px;
      font-size: 13px; animation: slide-up 0.3s ease-out;
    }
    @keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
    .pwa-banner .pwa-text { flex: 1; color: var(--c-text); }

    /* ══════════════════════ RESPONSIVE ══════════════════════ */
    /* ── More panel (one organized overflow for ALL secondary actions) ── */
    .toolbar-more { position: relative; }
    .more-menu {
      display: none; position: absolute; top: 100%; right: 0; z-index: var(--z-dropdown);
      background: var(--c-bg-2); border: 1px solid var(--c-border); border-radius: var(--r-md);
      padding: var(--sp-2); min-width: 240px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
      flex-direction: column; gap: 2px; margin-top: 4px;
      max-height: calc(100vh - 80px); overflow-y: auto;
    }
    .more-menu.open { display: flex; }
    .more-menu .btn { width: 100%; text-align: left; min-height: var(--touch-min); }
    .more-section {
      font-size: var(--fs-xs); font-weight: 700; letter-spacing: 1.5px;
      text-transform: uppercase; color: var(--c-text-dim);
      padding: var(--sp-3) var(--sp-2) var(--sp-1);
    }
    .more-section:first-child { padding-top: var(--sp-1); }
    .more-row {
      display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
      padding: var(--sp-1) var(--sp-2); min-height: var(--touch-min);
    }
    .more-row label { color: var(--c-text-dim); font-size: var(--fs-sm); }
    .more-row select {
      background: var(--c-bg-1); color: var(--c-text); border: 1px solid var(--c-border);
      padding: var(--sp-2); border-radius: var(--r-sm); font-size: var(--fs-sm); min-height: 38px;
    }

    /* ── Mobile bottom action bar ── */
    .action-bar {
      display: none; position: fixed; left: 0; right: 0; bottom: 0;
      z-index: var(--z-toolbar);
      background: var(--c-chrome); border-top: 1px solid var(--c-border);
      padding-bottom: env(safe-area-inset-bottom, 0);
      height: calc(var(--touch-lg) + env(safe-area-inset-bottom, 0));
    }
    .action-bar button {
      flex: 1; background: none; border: none; color: var(--c-text-dim);
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      gap: 2px; cursor: pointer; min-height: var(--touch-lg); font-size: var(--fs-xs);
    }
    .action-bar button:active { color: var(--c-accent); }
    .action-bar .ab-ic { font-size: 22px; line-height: 1; }
    .action-bar .ab-lb { font-size: var(--fs-xs); }

    /* ── Phone layout (<768px): slim top bar (input + Add), bottom action
       bar carries the rest; the More panel becomes a bottom sheet ── */
    @media (max-width: 767px) {
      .tb-desktop { display: none !important; }
      .action-bar { display: flex; }
      body.kiosk-mode .action-bar, body.tv-mode .action-bar,
      body.cast-mode .action-bar, body.has-expanded .action-bar { display: none; }
      .grid { padding-bottom: calc(var(--touch-lg) + env(safe-area-inset-bottom, 0)); }
      body.kiosk-mode .grid, body.tv-mode .grid, body.has-expanded .grid { padding-bottom: 0; }
      .more-menu {
        position: fixed; left: 0; right: 0; top: auto;
        bottom: calc(var(--touch-lg) + env(safe-area-inset-bottom, 0));
        border-radius: var(--r-lg) var(--r-lg) 0 0; margin: 0;
        max-height: 65vh;
      }
    }

    /* ── Phone portrait (iPhone SE, Flip closed, small Android) ── */
    @media (max-width: 400px) {
      .toolbar { flex-wrap: wrap; gap: 4px; padding: 6px; }
      .toolbar input { flex: 1 1 100%; padding: 10px; font-size: 15px; }
      .btn { padding: 8px 10px; font-size: 12px; }
      .hide-mobile { display: none; }
      .hide-small { display: none; }
      .panel { min-height: 0; }
      .panel .chat-frame { display: none; }
      .modal { padding: 16px; max-width: 98vw; }
      .mixer-channel { min-width: 160px; width: 160px; padding: 8px 12px 10px; }
      .mixer-master { min-width: 140px; width: 140px; }
      .mixer-panel { max-height: 45vh; }
      .boot-tv { width: 60px; height: 38px; }
      .boot-title { font-size: 22px; letter-spacing: 6px; }
      .empty h2 { font-size: 22px; }
      .gallery-grid { grid-template-columns: 1fr; }
    }

    /* ── Phone landscape + large phones portrait (iPhone, Pixel, Galaxy S) ── */
    @media (min-width: 401px) and (max-width: 700px) {
      .toolbar { gap: 4px; padding: 6px; flex-wrap: wrap; }
      .toolbar input { padding: 8px 10px; font-size: 16px; flex: 1 1 150px; }
      .btn { padding: 8px 10px; font-size: 12px; }
      .hide-mobile { display: none; }
      .panel { min-height: 0; }
      .panel .chat-frame { width: 180px; }
      .mixer-channel { min-width: 180px; width: 180px; padding: 8px 14px 10px; }
      .mixer-master { min-width: 150px; width: 150px; }
      .mixer-panel { max-height: 45vh; }
      .boot-tv { width: 70px; height: 44px; }
    }

    /* ── Small tablets, Z Fold open, iPad mini (701-900px) ── */
    @media (min-width: 701px) and (max-width: 900px) {
      .toolbar input { padding: 9px 12px; font-size: 14px; }
      .panel .chat-frame { width: 240px; }
      .boot-tv { width: 85px; height: 53px; }
    }

    /* ── Tablets, iPad Air/Pro portrait (901-1100px) ── */
    @media (min-width: 901px) and (max-width: 1100px) {
      .toolbar input { padding: 10px 14px; font-size: 15px; }
      .panel .chat-frame { width: 280px; }
    }

    /* ── iPad Pro landscape, small laptops (1101-1399px) ── */
    @media (min-width: 1101px) and (max-width: 1399px) {
      .toolbar input { padding: 10px 14px; font-size: 15px; }
    }

    /* ── Desktop, large screens (1400px+) ── */
    @media (min-width: 1400px) and (min-height: 800px) {
      .btn { padding: 12px 20px; font-size: 15px; }
      .toolbar input { padding: 12px 16px; font-size: 17px; }
    }

    /* ── Ultra-wide / TV (2000px+) ── */
    @media (min-width: 2000px) {
      .btn { padding: 14px 24px; font-size: 16px; }
      .toolbar input { padding: 14px 18px; font-size: 18px; }
      .panel-header .title { font-size: 13px; }
      .boot-tv { width: 130px; height: 82px; }
      .boot-title { font-size: 40px; letter-spacing: 14px; }
    }

    /* ── Z Flip cover screen & very small screens ── */
    @media (max-width: 300px) {
      .toolbar { padding: 4px; }
      .btn { padding: 6px 8px; font-size: 11px; }
      .col-group, .auth-section { display: none; }
      .panel { min-height: 0; }
      .empty h2 { font-size: 18px; }
      .empty p { font-size: 11px; }
      .boot-tv { width: 45px; height: 28px; }
      .boot-title { font-size: 18px; letter-spacing: 4px; }
    }

    /* ── Tall narrow screens (phone portrait) — force 1 col, fill viewport ── */
    @media (max-width: 500px) and (orientation: portrait) {
      .grid { gap: 1px; grid-template-columns: 1fr !important; height: 100dvh; height: 100vh; }
      .panel { min-height: 0; height: 100%; }
    }

    /* ── iPad Mini / small tablets portrait — max 2 columns ── */
    @media (min-width: 501px) and (max-width: 850px) and (orientation: portrait) {
      .grid { height: 100dvh; height: 100vh; }
      .panel { min-height: 0; height: 100%; }
    }

    /* ── Phone landscape — optimize for width ── */
    @media (max-height: 500px) and (orientation: landscape) {
      .toolbar { padding: 4px 8px; }
      .toolbar input { padding: 6px 10px; font-size: 13px; }
      .btn { padding: 6px 10px; font-size: 11px; }
      .panel-header { padding: 3px 8px; }
      .panel-controls { padding: 2px 8px; }
      .mixer-panel { max-height: 50vh; }
      .modal { max-height: 90vh; }
    }

    /* ── Foldable open detection (Z Fold, Pixel Fold) ── */
    @media (min-width: 700px) and (max-width: 900px) and (min-height: 800px) {
      /* panels auto-size via grid 1fr rows */
    }

    /* ── Touch devices — larger tap targets ── */
    @media (hover: none) and (pointer: coarse) {
      .btn { min-height: 44px; min-width: 44px; font-size: 13px; }
      .btn.xs { min-height: 36px; min-width: 36px; padding: 8px 12px; font-size: 12px; }
      .btn.sm { min-height: 40px; font-size: 13px; }
      .panel-header .btn { min-height: 36px; min-width: 36px; padding: 6px 12px; }
      .mixer-btn { width: 44px; height: 36px; font-size: 12px; }
      .mixer-master-btn { min-height: 36px; font-size: 11px; }
      .mixer-preset-btn { min-height: 36px; font-size: 10px; }
      .mixer-knob { width: 44px; height: 44px; }
      .mixer-knob::after { height: 14px; top: 4px; }
      .clip-led { width: 16px; height: 16px; padding: 4px; }
      .col-group select, select.quality-sel { min-height: 44px; font-size: 16px; }
      .fav-btn { padding: 4px 8px; min-height: 36px; }
    }

    /* ── High DPI / Retina — sharper borders ── */
    @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
      .panel { border-width: 0.5px; }
    }

    /* ── Safe areas for notched phones (iPhone X+, Pixel) ── */
    @supports (padding: env(safe-area-inset-top)) {
      .toolbar { padding-top: max(8px, env(safe-area-inset-top)); padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
      .mixer-panel { padding-bottom: env(safe-area-inset-bottom); }
      .pwa-banner { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
      .kiosk-bar { bottom: max(20px, env(safe-area-inset-bottom)); }
    }

    /* ── External display / AirPlay / Chromecast ── */
    @media (display-mode: fullscreen), (display-mode: standalone) {
      html, body { width: 100vw; height: 100vh; overflow: hidden; }
      .grid { width: 100vw; height: 100vh; }
      .panel { min-height: 0; width: 100%; height: 100%; }
    }
    /* When mirroring, force fill — prevents letterboxing */
    html, body {
      min-height: 100dvh; min-height: 100vh;
      min-width: 100dvw; min-width: 100vw;
    }

    /* ── Error Tracking & Feedback ── */
    .btn-bug { position: relative; }
    .error-badge {
      position: absolute; top: -4px; right: -4px;
      background: var(--c-danger-strong); color: #fff; font-size: 9px; font-weight: 700;
      min-width: 16px; height: 16px; border-radius: 8px;
      display: none; align-items: center; justify-content: center;
      padding: 0 4px; line-height: 1; pointer-events: none;
    }
    .error-log-overlay .modal { width: 680px; max-height: 85vh; }
    .error-log-list { max-height: 45vh; overflow-y: auto; margin: 10px 0; }
    .error-log-entry {
      background: var(--c-bg-1); border: 1px solid var(--c-border); border-radius: 6px;
      padding: 10px 12px; margin-bottom: 6px; font-size: 12px; font-family: monospace;
      word-break: break-all; line-height: 1.5;
    }
    .error-log-entry .err-time { color: var(--c-text-dim); font-size: 10px; }
    .error-log-entry .err-msg { color: var(--c-danger); font-weight: 600; margin: 4px 0; }
    .error-log-entry .err-loc { color: var(--c-text-dim); font-size: 11px; }
    .error-log-entry .err-stack {
      color: var(--c-text-dim); font-size: 10px; margin-top: 4px;
      white-space: pre-wrap; max-height: 80px; overflow-y: auto;
      background: rgba(0,0,0,0.3); padding: 6px; border-radius: 4px;
    }
    .error-log-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
    .perf-monitor {
      display: flex; gap: 12px; align-items: center; padding: 8px 12px;
      background: var(--c-bg-1); border-radius: 6px; margin-top: 10px; font-size: 12px;
    }
    .perf-monitor .perf-item { display: flex; align-items: center; gap: 4px; }
    .perf-monitor .perf-warn { color: var(--c-warning); font-weight: 600; }
    .perf-monitor .perf-danger { color: var(--c-danger-strong); font-weight: 600; }
    .feedback-overlay .modal { width: 500px; }
    .feedback-overlay textarea { height: 120px; resize: vertical; font-family: sans-serif; }
    .toast-msg {
      position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%);
      background: var(--c-bg-3); color: var(--c-text); border: 1px solid var(--c-border); padding: 12px 20px; border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(0,0,0,0.4);
      font-size: 13px; font-weight: 600; z-index: var(--z-toast); opacity: 0;
      transition: opacity 0.3s; pointer-events: none;
    }
    .toast-msg.show { opacity: 1; }

    /* ── Inline Label Editing ── */
    .panel-header .title-edit {
      background: var(--c-bg-1); color: var(--c-text); border: 1px solid var(--c-accent);
      border-radius: 4px; padding: 2px 6px; font-size: 12px; font-weight: 600;
      width: 100%; min-width: 0; outline: none; font-family: inherit;
    }
    .panel-header .label-display {
      cursor: pointer; user-select: none;
    }
    .panel-header .label-display:hover { text-decoration: underline dotted; text-underline-offset: 2px; }

    /* ── Reconnecting Indicator ── */
    .panel-reconnecting {
      position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%);
      background: rgba(0,0,0,0.85); color: var(--c-warning); padding: 4px 12px;
      border-radius: 12px; font-size: 11px; font-weight: 600; z-index: 4;
      display: flex; align-items: center; gap: 6px; white-space: nowrap;
      animation: reconnect-pulse 1.5s ease-in-out infinite;
    }
    @keyframes reconnect-pulse {
      0%, 100% { opacity: 1; } 50% { opacity: 0.5; }
    }
    .panel-offline-msg {
      position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%);
      background: rgba(0,0,0,0.85); color: var(--c-danger-strong); padding: 4px 12px;
      border-radius: 12px; font-size: 11px; font-weight: 600; z-index: 4;
      white-space: nowrap;
    }

    /* ── YouTube Search Overlay ── */
    .yt-search-section {
      display: flex; gap: 8px; align-items: center; margin-bottom: 10px;
    }
    .yt-search-section input {
      flex: 1; margin: 0 !important;
    }
    .yt-search-hint {
      background: var(--c-bg-1); border-radius: var(--r-md); padding: 10px 14px;
      font-size: 12px; color: var(--c-text-dim); line-height: 1.6; margin-bottom: 10px;
    }
    .yt-search-hint strong { color: var(--c-text); }
    .yt-search-steps {
      list-style: none; counter-reset: step;
    }
    .yt-search-steps li {
      counter-increment: step; padding: 3px 0;
    }
    .yt-search-steps li::before {
      content: counter(step) ". "; color: var(--c-accent); font-weight: 700;
    }

    /* ── Import/Export Enhanced ── */
    .ie-format-toggle {
      display: flex; gap: 6px; margin-bottom: 8px;
    }
    .ie-format-toggle .btn.active { background: var(--c-accent); color: #fff; }

    /* ── Chat Sidebar ── */
    .chat-sidebar {
      position: fixed; top: 0; right: 0; bottom: 0; width: 340px; z-index: var(--z-chat);
      background: var(--c-bg-2); border-left: 1px solid var(--c-border);
      display: flex; flex-direction: column;
      transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    }
    .chat-sidebar.open { transform: translateX(0); }
    .chat-sidebar-header {
      display: flex; align-items: center; gap: 8px; padding: 10px 12px;
      background: var(--c-bg-3); border-bottom: 1px solid var(--c-border); flex-shrink: 0;
    }
    .chat-sidebar-header select {
      flex: 1; background: var(--c-bg-1); color: var(--c-text); border: 1px solid var(--c-border);
      padding: 6px 8px; border-radius: var(--r-md); font-size: 12px; min-width: 0;
    }
    .chat-sidebar-header .chat-close-btn {
      background: none; border: none; color: var(--c-danger); font-size: 18px; cursor: pointer;
      padding: 2px 6px; line-height: 1;
    }
    .chat-sidebar-header .chat-close-btn:hover { color: #fff; background: var(--c-danger-strong); border-radius: 4px; }
    .chat-sidebar-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
    .chat-sidebar-body iframe { flex: 1; width: 100%; border: none; min-height: 0; }
    .chat-sidebar-body .chat-unavailable {
      flex: 1; display: flex; align-items: center; justify-content: center;
      color: var(--c-text-dim); font-size: 13px; padding: 20px; text-align: center;
    }
    body.chat-sidebar-active .grid {
      margin-right: 340px; transition: margin-right 0.3s cubic-bezier(0.4,0,0.2,1);
    }
    body:not(.chat-sidebar-active) .grid {
      margin-right: 0; transition: margin-right 0.3s cubic-bezier(0.4,0,0.2,1);
    }
    @media (max-width: 767px) {
      .chat-sidebar { width: 100%; }
      body.chat-sidebar-active .grid { margin-right: 0; }
    }
