    :root {
      --bg: #0b1420;
      --accent: #29c8cc;
      --emerald: #10b981;
      --amber: #f59e0b;
      --red: #ef4444;
      --cols: 3;
      --rows: 3;
      --mono: "SF Mono", "JetBrains Mono", ui-monospace, monospace;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    html, body {
      width: 100vw; height: 100vh; overflow: hidden;
      background: var(--bg); color: #f8fafc;
      font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
    }

    body::before {
      content: ""; position: fixed; inset: -16%; z-index: 0; pointer-events: none;
      background:
        radial-gradient(circle at 22% 24%, rgba(41,200,204,0.18), transparent 52%),
        radial-gradient(circle at 78% 76%, rgba(16,185,129,0.16), transparent 52%);
      animation: none;
    }
    @keyframes tvBreath {
      0% { transform: scale(1) rotate(0deg); filter: hue-rotate(0deg); }
      100% { transform: scale(1.08) rotate(3deg); filter: hue-rotate(24deg); }
    }

    .tv-wall {
      position: relative; z-index: 1;
      width: 100vw; height: 100vh; padding: 5px;
      display: grid;
      grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
      grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
      gap: 5px;
    }
    /* The video wall geometry never changes when the toolbar hides. */

    .tv-tile {
      position: relative; border-radius: 9px; overflow: hidden;
      background: #0b1420;
      border: 1px solid rgba(56, 189, 248, 0.24);
      transition: border-color 0.2s, box-shadow 0.2s, border-radius 0.25s;
    }
    
    .tv-tile.tv-stage {position:absolute;left:0;top:0;opacity:0;pointer-events:none;z-index:-1;overflow:hidden;}
    .tv-playback-note {position:absolute;top:8px;left:8px;z-index:5;font-size:11px;padding:4px 7px;border-radius:5px;background:#071122df;color:#fde68a;pointer-events:none;}
    .tv-playback-note:empty {display:none;}
    #tvDiagnostics {position:fixed;z-index:100;inset:15% 5% auto;max-height:75vh;overflow:auto;background:#081525;border:1px solid #397c92;border-radius:10px;padding:15px;color:#e2e8f0;}
    #tvDiagnostics[hidden] {display:none!important;} #tvDiagnostics pre {white-space:pre-wrap;overflow-wrap:anywhere;font-size:12px;}
    .tv-tile.audio-live {
      border-color: var(--emerald) !important;
      box-shadow: 0 0 24px rgba(16, 185, 129, 0.55);
    }

    .tv-media, .tv-media video, .tv-media img {
      position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border: none;
    }
    /* Consistent balanced 16:9 framing across both Dashboard & TV Mode */
    .tv-media iframe {
      position: absolute; inset: 0; width: 100%; height: 100%;
      transform: none;
      border: none; pointer-events: auto; z-index: 2;
    }

    .tv-curtain {
      position: absolute; inset: 0; z-index: 4;
      background: radial-gradient(circle at 50% 45%, #0a1834 0%, #02050d 100%);
      display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
      pointer-events: none; transition: opacity 0.3s ease;
    }
    .tv-curtain.ready { opacity: 0; }
    @keyframes spin { to { transform: rotate(360deg); } }

    /* Slow-stream approval toast on individual persistent slow tile */
    .slow-prompt {
      position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 8;
      background: rgba(6, 13, 28, 0.95); backdrop-filter: blur(12px);
      border: 1px solid rgba(245, 158, 11, 0.65); border-radius: 10px;
      padding: 9px 13px; display: none; flex-direction: column; align-items: center; gap: 7px;
      box-shadow: 0 12px 32px rgba(0,0,0,0.85); text-align: center;
    }
    .slow-prompt.show { display: flex; }
    .slow-prompt span { font-size: 11px; font-weight: 700; color: #fde68a; white-space: nowrap; }
    .slow-actions { display: flex; gap: 6px; }
    .slow-btn {
      padding: 4px 10px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.25);
      background: rgba(16,185,129,0.25); color: #ecfdf5; font-size: 10.5px; font-weight: 800; cursor: pointer;
    }
    .slow-btn.wait { background: rgba(30,41,59,0.9); color: #94a3b8; }

    /* Naked Hover Whisper Pill + Open Individual Feed Action */
    .tv-hover-bar {
      position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 6;
      padding: 6px 10px; border-radius: 8px;
      background: rgba(3, 8, 20, 0.85); backdrop-filter: blur(10px);
      border: 1px solid rgba(41, 200, 204, 0.4);
      display: flex; align-items: center; justify-content: space-between; gap: 8px;
      opacity: 0; pointer-events: none; transition: opacity 0.18s ease;
    }
    .tv-tile:hover .tv-hover-bar { opacity: 1; pointer-events: auto; }
    body.idle-naked .tv-hover-bar { opacity: 0 !important; pointer-events: none !important; }
    .tv-hover-txt { font-size: 11.5px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .tv-open-single {
      padding: 3px 8px; border-radius: 6px; border: 1px solid rgba(41,200,204,0.55);
      background: rgba(41,200,204,0.2); color: #e0f2fe; font-size: 10px; font-weight: 800;
      text-decoration: none; white-space: nowrap; cursor: pointer;
    }
    .tv-open-single:hover { background: var(--accent); color: #020617; }

    /* Top HUD — Vanishes 100% after 2.2s of zero mouse movement */
    .tv-hud {
      position: fixed; top: 14px; left: 16px; right: 16px; z-index: 25;
      display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
      pointer-events: none; transition: opacity 0.35s ease, transform 0.35s ease;
    }
    body.idle-naked .tv-hud { opacity: 0; visibility:hidden; transform: translateY(-6px); }
    body.idle-naked:not(.phone-mode) .tv-wall { cursor: none; }

    .tv-bug, .tv-controls {
      pointer-events: auto;
      background: rgba(4, 10, 24, 0.9); backdrop-filter: blur(16px);
      border: 1px solid rgba(41, 200, 204, 0.44); border-radius: 11px;
      padding: 6px 12px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
      box-shadow: 0 12px 34px rgba(0,0,0,0.82), 0 0 22px -6px rgba(41,200,204,0.38);
    }
    body.idle-naked .tv-bug, body.idle-naked .tv-controls { pointer-events: none; }
    .tv-hud {display:grid;grid-template-columns:minmax(0,1fr);gap:6px;top:10px;left:10px;right:10px;max-height:calc(100dvh - 20px);overflow:auto;overscroll-behavior:contain;}
    .tv-bug {justify-self:start;max-width:100%;}
    .tv-controls {justify-content:flex-start;min-width:0;gap:6px;padding:8px;}
    .tv-options {display:flex;align-items:center;gap:6px;flex-wrap:wrap;min-width:0;flex-basis:100%;padding-top:7px;border-top:1px solid #294559;}
    .tv-options[hidden] {display:none!important;}
    .tv-btn {max-width:100%;min-height:32px;}
    .tv-hover-bar:focus-within {opacity:1!important;pointer-events:auto!important;}
    .slow-actions {flex-wrap:wrap;justify-content:center;}
    .tv-btn:focus-visible {outline:2px solid #8ce3e5;outline-offset:2px;}
    #tvPoolStatus {flex-basis:100%;font-size:12px;color:#bae6fd;line-height:1.4;overflow-wrap:anywhere;}
    #tvNotice {position:fixed;bottom:14px;left:50%;transform:translateX(-50%);z-index:30;max-width:min(92vw,720px);background:#102436;border:1px solid #5298ad;border-radius:8px;padding:10px 14px;color:#e2e8f0;font-size:13px;box-shadow:0 6px 20px #0008;}
    #tvNotice button {margin-left:8px;}
    .tv-empty {grid-column:1/-1;grid-row:1/-1;display:grid;place-content:center;text-align:center;gap:12px;padding:20px;color:#dbeafe;}
    .tv-empty button {justify-self:center;}
    @media(max-width:600px){body.phone-mode .tv-hud{max-height:none;overflow:visible;}body.phone-mode #tvNotice{position:relative;bottom:auto;left:auto;transform:none;margin:8px;max-width:none;}}

    .tv-controls select{max-width:100%;} .slow-prompt{max-width:90%;} .slow-prompt span{white-space:normal;}

    .tv-btn {
      height: 30px; padding: 0 10px; border-radius: 7px;
      border: 1px solid rgba(148,163,184,0.28); background: rgba(15,25,48,0.92);
      color: #e2e8f0; font-size: 11px; font-weight: 700; cursor: pointer; text-decoration: none;
      display: inline-flex; align-items: center; gap: 5px;
    }
    .tv-btn:hover, .tv-btn.active { border-color: #29c8cc; color: #fff; background: rgba(41,200,204,0.22); }
    .tv-btn.audio-pill.active { border-color: #10b981; background: rgba(16,185,129,0.24); color: #ecfdf5; }
    .tv-btn.shuffle {
      background:linear-gradient(135deg,#a0e4df,#29c8cc); border-color:#8defff; color:#062334; font-weight:850; gap:7px; box-shadow:0 3px 13px #00b8d427;
    }

    .tv-btn.shuffle:hover { background:linear-gradient(135deg,#bbfff3,#70e4ff); color:#062334; }
    .tv-btn.shuffle:focus-visible { outline:2px solid #fff; outline-offset:3px; }
    .tv-btn.shuffle .shuffle-icon { flex-shrink:0; }
    /* Non-Premium Broadcast Sponsor Corner Bug (Hidden when Pro Ad-Free is active!) */
    .tv-sponsor-bug {
      position: fixed; right: 16px; bottom: 16px; z-index: 22;
      width: 280px; border-radius: 11px; overflow: hidden;
      background: rgba(5, 11, 24, 0.92); backdrop-filter: blur(14px);
      border: 1px solid rgba(16, 185, 129, 0.45);
      box-shadow: 0 14px 36px rgba(0,0,0,0.85);
      transition: opacity 0.35s ease;
    }
    body.pro-adfree .tv-sponsor-bug { display: none !important; }
    .tv-sp-hdr {
      padding: 4px 9px; background: rgba(2, 6, 15, 0.88);
      display: flex; align-items: center; justify-content: space-between;
      font-family: var(--mono); font-size: 8.5px; color: #6ee7b7;
    }
    .tv-sp-pro {
      background: none; border: 1px solid rgba(250,204,21,0.5); color: #fde047;
      border-radius: 4px; padding: 1px 6px; font-size: 8.5px; font-weight: 800; cursor: pointer;
    }
    .tv-sp-body { display: flex; align-items: center; gap: 9px; padding: 8px 10px; text-decoration: none; color: #fff; }
    .tv-sp-body img { width: 52px; height: 42px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
    .tv-sp-title { font-size: 11px; font-weight: 800; line-height: 1.25; }
    .tv-sp-sub { font-size: 9.5px; color: #94a3b8; margin-top: 2px; line-height: 1.25; }
    body.phone-mode .tv-hud { position: relative; top: auto; left: auto; right: auto; padding: 8px; }
    body.phone-mode .tv-wall { position: relative; inset: auto; height: auto; aspect-ratio: 16 / 9; }
    body.phone-mode.hg-immersive .tv-hud {position:fixed;top:8px;left:8px;right:8px;max-height:calc(100dvh - 16px);overflow:auto;}
    body.phone-mode.hg-immersive .tv-wall {height:100dvh;aspect-ratio:auto;}
    body.phone-mode .tv-controls { flex-wrap: wrap; width: 100%; }
    body.phone-mode .tv-btn:disabled { display: none; }
    body.phone-mode .tv-hover-bar { opacity: 1; }
    body.phone-mode .tv-media iframe { pointer-events:auto; transform:none; }
    body.phone-mode {height:auto; min-height:100dvh; overflow:auto;}
    body.phone-mode .tv-sponsor-bug { display: none; }
  [hidden] { display:none !important; }

.hg-local-preview{color:#fde68a;font:600 11px system-ui;padding:6px 9px;border:1px solid #a16207;border-radius:6px;white-space:normal;max-width:100%;text-decoration:none}

/* R77: slightly smoother reveal for TV status curtains. */
.tv-curtain{transition:opacity .28s ease, transform .28s ease; transform:scale(1);}
.tv-curtain.ready{transform:scale(.985);}

.tv-geo-label{position:absolute;top:8px;left:8px;max-width:calc(100% - 16px);z-index:6;pointer-events:none;padding:4px 7px;border-radius:5px;background:rgba(3,8,20,.85);color:#fff;font-size:11px;font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} body.idle-naked .tv-geo-label{display:none}

/* Viewing theme: one native select instead of a toggle and conditional select. */
.tv-theme-control{display:flex;align-items:center;gap:6px;min-width:0;color:#dbeafe;font:600 12px system-ui;flex-wrap:wrap}
.tv-theme-control select{min-width:0;max-width:100%;font:600 13px system-ui;color-scheme:dark}
body.phone-mode .tv-theme-control{flex:1 1 100%;display:grid;grid-template-columns:minmax(0,1fr);gap:4px;order:-1}
body.phone-mode .tv-theme-control select{width:100%;min-height:44px;font-size:16px}
body.phone-mode #tvShuffleAllBtn,body.phone-mode #returnDeckLink,body.phone-mode #tvOptionsBtn{min-height:44px;justify-content:center;flex:1 1 auto;font-size:13px}
body.phone-mode #tvPoolStatus{text-align:center;margin:0}

/* TV-only remote hints and focus styling. */
.tv-remote-hint{display:none}.smart-tv .tv-remote-hint{display:block;margin:6px 0 0;color:#c5d6e3;font:500 13px/1.4 system-ui,sans-serif}.smart-tv .tv-hud :focus,.smart-tv dialog :focus{outline:3px solid #8ce3e5;outline-offset:2px}.smart-tv .tv-theme-control select{min-height:48px;font-size:16px}.smart-tv .tv-hud{max-height:95vh;overflow:auto}

/* TV remote targets remain accessible in normal viewing; fullscreen can hide the HUD. */
.smart-tv .tv-btn,.smart-tv .ip-site-menu summary{min-height:44px;font-size:15px}.smart-tv .tv-tile :focus{outline:3px solid #8ce3e5;outline-offset:-3px}.smart-tv .tv-controls [data-layout]{min-width:54px;justify-content:center}.smart-tv .tv-controls [data-layout].active{outline:2px solid #8ce3e5;outline-offset:-2px}

#tvPerformanceHint:not([hidden]){display:flex;flex-basis:100%;align-items:center;flex-wrap:wrap;gap:8px;padding:8px;border:1px solid #5298ad;border-radius:8px;background:#102436;color:#e2e8f0}#tvPerformanceHint[hidden]{display:none}#tvPerformanceHint span{flex:1 1 260px}

/* TV audio controls: visible when navigating a tile, without obscuring every stream. */
.smart-tv .tv-remote-audio{min-height:44px;min-width:68px;font-size:14px}.smart-tv .tv-remote-audio[aria-pressed="true"]{background:#8ce3e5;color:#10202c}.smart-tv .tv-remote-audio:disabled{display:none}.smart-tv .tv-tile:focus-within .tv-hover-bar{opacity:1;pointer-events:auto}.smart-tv .tv-hover-bar{max-width:100%;box-sizing:border-box}.smart-tv .tv-hover-bar .tv-hover-txt{min-width:0;overflow:hidden;text-overflow:ellipsis}

/* R163: simple TV toolbar and deterministic manual hiding. */
#tvShowControls{display:none}.smart-tv body.idle-naked #tvShowControls:not([hidden]){display:block;position:fixed;bottom:12px;right:12px;z-index:30;opacity:.65;background:#071525;color:#dcecf4;font-size:13px;min-height:36px}.smart-tv body.idle-naked #tvShowControls:focus{opacity:1;outline:3px solid #8ce3e5}.smart-tv body.idle-naked .tv-hud,.smart-tv body.idle-naked .tv-hover-bar{visibility:hidden!important;opacity:0!important;pointer-events:none!important}.smart-tv .tv-grid-picker{position:relative}.smart-tv .tv-grid-picker summary{cursor:pointer;display:flex;align-items:center}.smart-tv .tv-grid-choices{display:flex;gap:6px;flex-wrap:wrap;padding:8px}.smart-tv .tv-grid-picker[open]{flex-basis:100%}.smart-tv .tv-options #tvSecondary{display:flex;flex-wrap:wrap;gap:8px}.smart-tv .tv-controls{gap:8px}.smart-tv #tvModeSub{display:none}.smart-tv .tv-remote-hint{margin:0}.smart-tv body.idle-naked #tvNotice{display:none}
#tvHideControls[hidden],#tvShowControls[hidden]{display:none!important}

/* R198: explicit controls on touch and desktop, not just detected televisions. */
body.idle-naked #tvShowControls:not([hidden]){display:block;position:fixed;bottom:max(12px,env(safe-area-inset-bottom));right:max(12px,env(safe-area-inset-right));z-index:30;background:#101923e8;color:#f3f4f6;min-height:44px;padding:8px 14px;border:1px solid #67717a;border-radius:8px;}
body.idle-naked #tvShowControls:focus-visible{outline:3px solid #e1c38b;outline-offset:2px;}
body.phone-mode #tvHideControls{min-height:44px;}

body.phone-mode.idle-naked:not(.hg-immersive) #tvHud{display:none;}
