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

/* ── Design tokens — match radio/Player2 ─────────────────────────────── */
:root {
    color-scheme: dark;
    --bg: #000000;
    --surface: rgba(255,255,255,0.08);
    --surface-h: rgba(255,255,255,0.08);
    --border: rgba(255,255,255,0.10);
    --border-h: rgba(255,255,255,0.22);
    --accent: #000080;
    --accent-glow: rgba(0,0,128,0.5);
    --accent-line: rgba(255,255,255,0.40);
    --accent-edge: rgba(255,255,255,0.25);
    --accent-text: #aaccff;
    --btn-grad: linear-gradient(135deg, #00002a 0%, #000050 20%, #000066 40%, #000080 60%, #000066 80%, #00002a 100%);
    --btn-grad-hover: linear-gradient(135deg, #000050 0%, #000066 25%, #000090 50%, #000080 75%, #000050 100%);
    --text: #e0e0e0;
    --text-head: #ffffff;
    --muted: rgba(255,255,255,0.45);
    --fav: #e04444;
    --scrollbar: rgba(255,255,255,0.15);
    --header-h: 58px;
    --tabs-h: 40px;
}

html { background: #000; }
/* Light mode is the same day sky Player2 paints. This page is framed, so
   the parent canvas stops at the frame edge and the sky has to be repeated
   here -- the same reason dark mode repeats the starfield rather than
   relying on transparency. Keep in step with --sky-wash in player.css. */
html[data-theme="light"] {
    --sky-wash: linear-gradient(180deg, #d9e4ef 0%, #e6edf5 30%, #f5f7fa 58%, #eef0f3 80%, #e8eaee 100%);
    --cloud-far:
        radial-gradient(7.5% 9.5% at 31% 24%, rgba(255,255,255,0.90) 0%, rgba(255,255,255,0.60) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(6.5% 8.5% at 36% 22.5%, rgba(255,255,255,0.90) 0%, rgba(255,255,255,0.60) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(4% 5.5% at 39.5% 25.5%, rgba(255,255,255,0.88) 0%, rgba(255,255,255,0.58) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(10% 5.5% at 34.5% 27%, rgba(255,255,255,0.88) 0%, rgba(255,255,255,0.58) 45%, rgba(255,255,255,0) 80%),
        radial-gradient(6.5% 8.5% at 72% 57%, rgba(255,255,255,0.88) 0%, rgba(255,255,255,0.58) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(5.5% 7% at 76.5% 55.5%, rgba(255,255,255,0.88) 0%, rgba(255,255,255,0.58) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(9% 5% at 74.5% 59.5%, rgba(255,255,255,0.86) 0%, rgba(255,255,255,0.56) 45%, rgba(255,255,255,0) 80%),
        radial-gradient(5.5% 7.5% at 10% 76%, rgba(255,255,255,0.86) 0%, rgba(255,255,255,0.56) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(4.5% 6% at 14% 75%, rgba(255,255,255,0.86) 0%, rgba(255,255,255,0.56) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(8% 4.5% at 12% 78.5%, rgba(255,255,255,0.84) 0%, rgba(255,255,255,0.55) 45%, rgba(255,255,255,0) 80%),
        radial-gradient(11.5% 5.5% at 34.5% 28.5%, rgba(150,168,190,0.28) 0%, rgba(150,168,190,0.12) 50%, rgba(150,168,190,0) 82%),
        radial-gradient(10% 5% at 74.5% 61%, rgba(150,168,190,0.26) 0%, rgba(150,168,190,0.11) 50%, rgba(150,168,190,0) 82%),
        radial-gradient(9% 4.5% at 12% 80%, rgba(150,168,190,0.24) 0%, rgba(150,168,190,0.10) 50%, rgba(150,168,190,0) 82%);
    --cloud-near:
        radial-gradient(6.6% 9.1% at 14% 17%, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.66) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(7.3% 9.9% at 19.3% 15.5%, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.66) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(4.4% 6.1% at 23.7% 18.5%, rgba(255,255,255,0.93) 0%, rgba(255,255,255,0.64) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(11% 6.1% at 17.6% 20.2%, rgba(255,255,255,0.92) 0%, rgba(255,255,255,0.64) 45%, rgba(255,255,255,0) 80%),
        radial-gradient(5.9% 8.4% at 56% 47%, rgba(255,255,255,0.93) 0%, rgba(255,255,255,0.65) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(6.6% 9.1% at 61% 45.5%, rgba(255,255,255,0.93) 0%, rgba(255,255,255,0.65) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(3.7% 5.3% at 64.7% 48.4%, rgba(255,255,255,0.91) 0%, rgba(255,255,255,0.63) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(9.5% 5.3% at 59.5% 50%, rgba(255,255,255,0.90) 0%, rgba(255,255,255,0.63) 45%, rgba(255,255,255,0) 80%),
        radial-gradient(6.6% 9.1% at 83% 76%, rgba(255,255,255,0.94) 0%, rgba(255,255,255,0.66) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(7.3% 9.9% at 88.3% 74.5%, rgba(255,255,255,0.94) 0%, rgba(255,255,255,0.66) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(4.4% 6.1% at 92% 77.5%, rgba(255,255,255,0.92) 0%, rgba(255,255,255,0.64) 45%, rgba(255,255,255,0) 78%),
        radial-gradient(11% 6.1% at 86.6% 79.2%, rgba(255,255,255,0.91) 0%, rgba(255,255,255,0.64) 45%, rgba(255,255,255,0) 80%),
        radial-gradient(13.2% 6.1% at 17.6% 21.7%, rgba(150,168,190,0.40) 0%, rgba(150,168,190,0.18) 50%, rgba(150,168,190,0) 82%),
        radial-gradient(11.7% 5.3% at 59.5% 51.4%, rgba(150,168,190,0.35) 0%, rgba(150,168,190,0.15) 50%, rgba(150,168,190,0) 82%),
        radial-gradient(12% 6.1% at 85% 80.7%, rgba(150,168,190,0.38) 0%, rgba(150,168,190,0.17) 50%, rgba(150,168,190,0) 82%);
    background-color: #e8eaee;
    background-image: var(--sky-wash);
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: auto;
}
body { background: #000; }
html[data-theme="light"] body { background: transparent; }

/* ── Light mode tokens ──────────────────────────────────────────────── */
html[data-theme="light"] {
    color-scheme: light;
    --text:        #1a1a2e;
    --text-head:   #0d0d1a;
    --muted:       rgba(20,20,50,0.55);
    --surface:     rgba(255,255,255,0.55);
    --surface-h:   rgba(255,255,255,0.80);
    --border:      rgba(0,0,0,0.14);
    --border-h:    rgba(0,0,0,0.28);
    --accent-text: #0044bb;
    --scrollbar:   rgba(0,0,0,0.18);
    --fav:         #cc2222;
}

html, body {
    height: 100%;
    color: var(--text);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
}

/* ── Sky motion: two-speed parallax ──────────────────── */
/* Drift is driven by transform on an oversized strip, not by
   background-position, so the browser composites it instead of repainting a
   full-viewport layer every frame. Each strip is exactly one tile wider than
   the viewport and travels exactly one tile, which is what makes the loop
   seamless: change a background-size and you MUST change the matching
   keyframe and the matching negative inset by the same pixels.
   Two layers at very different speeds is the point. One sheet at a constant
   speed reads as a printed backdrop on rails. Same layers, tiles and timings
   as the block of the same name in Player2/css/player.css. Keep them in step. */
.ns-stars::before,
.ns-twinkling::before,
.ns-clouds::before,
.ns-clouds::after {
    content: '';
    position: absolute;
    background-repeat: repeat;
    pointer-events: none;
    will-change: transform;
}

.ns-stars,
.ns-twinkling,
.ns-sky,
.ns-clouds {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; /* clip the oversized strips */
    pointer-events: none;
}

/* Dark: the 0.34 black veil stays on the element so it covers the whole
   viewport; only the 2000px star tile moves, and barely. Far layer. */
.ns-stars {
    background: rgba(0,0,0,.34);
    z-index: -2;
}

.ns-stars::before {
    inset: 0 -2000px 0 0;
    background-image: url('../../images/nightsky/stars.png');
    background-size: 2000px 1375px;
    animation: ns-drift-stars 880s linear infinite;
}

@keyframes ns-drift-stars {
    from { transform: translate3d(0,0,0); }
    to   { transform: translate3d(-2000px,0,0); }
}

/* Near layer. Same diagonal and the same 50px/s as the old
   background-position keyframe (-10000px/5000px over 200s), restated as one
   100px tile every 2s so it can composite. */
.ns-twinkling {
    background: transparent;
    z-index: -1;
}

.ns-twinkling::before {
    inset: -100px -100px -100px -100px;
    background-image: url('../../images/nightsky/twinkling.png');
    background-size: 100px 100px;
    animation: ns-drift-twink 2s linear infinite;
}

@keyframes ns-drift-twink {
    from { transform: translate3d(0,0,0); }
    to   { transform: translate3d(-100px,50px,0); }
}

html[data-theme="light"] .ns-stars,
html[data-theme="light"] .ns-twinkling {
    display: none;
}

/* ── Day sky (light theme) ── */
/* .ns-sky is never used: the wash goes on the html canvas so transparent
   elements pick it up without a backdrop-filter. The clouds cannot live
   there too, because a canvas background is not composited and so could
   only ever hold still. */
.ns-sky {
    display: none;
}

.ns-clouds {
    display: none;
    z-index: -2;
}

html[data-theme="light"] .ns-clouds {
    display: block;
    background: transparent;
}

/* Far: small, faint, ~2.3px/s -- about the drift rate of the star field, so
   the two themes read as the same sky at different hours. */
html[data-theme="light"] .ns-clouds::before {
    inset: 0 -900px 0 0;
    background-image: var(--cloud-far);
    background-size: 900px 620px;
    opacity: 0.50;
    animation: ns-drift-far 400s linear infinite;
}

/* Near: large, bright, ~9px/s. Four times the far layer, which is about the
   most separation you can use before the near layer looks driven. */
html[data-theme="light"] .ns-clouds::after {
    inset: 0 -1500px 0 0;
    background-image: var(--cloud-near);
    background-size: 1500px 900px;
    opacity: 0.95;
    animation: ns-drift-near 167s linear infinite;
}

@keyframes ns-drift-far {
    from { transform: translate3d(0,0,0); }
    to   { transform: translate3d(-900px,0,0); }
}

@keyframes ns-drift-near {
    from { transform: translate3d(0,0,0); }
    to   { transform: translate3d(-1500px,0,0); }
}

@media (prefers-reduced-motion: reduce) {
    .ns-stars::before,
    .ns-twinkling::before,
    .ns-clouds::before,
    .ns-clouds::after {
        animation: none;
    }
}

/* ── View switching ──────────────────────────────────────────────────── */
.view {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
    z-index: 1;
}
.view.active {
    opacity: 1;
    pointer-events: auto;
}

/* Both views are transparent: the sky behind them (.ns-stars / .ns-twinkling in
   dark, .ns-clouds over the html wash in light) is the page background. A view
   that painted its own starfield would cover the drifting one and the page
   would read as a still picture. */
#browse-view {
    background: transparent;
}

/* ═══════════════════════════════════════════════════════════════════════
   BROWSE VIEW
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Header ──────────────────────────────────────────────────────────── */
/* The header, tabs, filter and tag rows are all transparent and borderless:
   the sky runs unbroken from the top of the page to the bottom. The only
   outlines left in the chrome are the search box and the country select,
   because a text field and a dropdown have to look like ones. */
#tv-header {
    flex-shrink: 0;
    height: var(--header-h);
    background: transparent;
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 0 14px;
}

#tv-logo {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 34px;
    font-weight: 700;
    letter-spacing: .4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.icon-btn {
    background: transparent;
    border: none;
    border-radius: 7px;
    color: var(--muted);
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: color .15s;
}
.icon-btn:hover { color: var(--text); }

#search-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
    transition: border-color .15s;
}
#search-input:focus { border-color: var(--accent-line); }
#search-input::placeholder { color: var(--muted); }

/* ── Tabs ────────────────────────────────────────────────────────────── */
#tabs {
    flex-shrink: 0;
    height: var(--tabs-h);
    display: flex;
    gap: 0;
    padding: 0 14px;
    background: transparent;
    align-items: flex-end;
}

.tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    padding: 0 16px 10px;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: color .15s;
}
.tab-btn.active {
    color: #fff;
    border-bottom-color: #fff;
    font-size: 16px;
    font-weight: 700;
}
.tab-btn:hover:not(.active) { color: var(--text); }

/* ── Filter row ──────────────────────────────────────────────────────── */
#filter-row {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: transparent;
}

.filter-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--muted);
    white-space: nowrap;
    flex-shrink: 0;
}

#country-select {
    flex: 1;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 7px 10px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: border-color .15s;
}
#country-select:focus { border-color: var(--accent-line); }
#country-select option { background: #16161f; color: #e0e0e0; }

#clear-btn {
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--muted);
    padding: 7px 12px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color .15s;
}
#clear-btn:hover { color: var(--text); }

/* ── Tag chips ───────────────────────────────────────────────────────── */
#tags-row-wrap {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    background: transparent;
}

#tags-row {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar) transparent;
}

.logo-only-label {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 14px 0 8px;
    font-size: 11px;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.logo-only-label input[type="checkbox"] {
    accent-color: var(--accent-text);
    cursor: pointer;
    width: 13px;
    height: 13px;
}

/* A resting chip is bare text. Only the picked one gets a pill, so the row
   reads as a list of words over the sky instead of a strip of outlined boxes,
   and the selection is the one thing that stands out. */
.tag-chip {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 20px;
    color: var(--muted);
    padding: 5px 13px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.tag-chip:hover {
    color: var(--text);
}
.tag-chip.active {
    background: var(--btn-grad);
    border-color: var(--accent-edge);
    color: #fff;
}

/* ── Content + grid ──────────────────────────────────────────────────── */
#content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 110px;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar) transparent;
}

.section-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin-bottom: 12px;
}

#channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 388px));
    gap: 14px;
    justify-content: center;
}

/* ── Channel card ────────────────────────────────────────────────────── */
.channel-card {
    --card-footer: 88px;
    height: 320px;
    width: 100%;
    border-radius: 18px;
    overflow: hidden;
    border: 3px solid #000;
    cursor: pointer;
    position: relative;
    transition: box-shadow .2s;
}
.channel-card:hover {
    box-shadow: 0 0 0 2px rgba(255,255,255,0.18), 0 6px 28px rgba(0,0,0,0.6);
}
.channel-card.playing {
    border-color: var(--accent-line);
    box-shadow: 0 0 0 1px var(--accent-line), 0 0 24px var(--accent-glow);
}

.channel-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
}

.channel-card-bg {
    position: absolute;
    top: 0; left: 0; right: 0;
    bottom: var(--card-footer);
    background: linear-gradient(135deg, #0a1628 0%, #1a3a5c 35%, #1e4470 65%, #0d1f38 100%);
}

.channel-art {
    position: absolute;
    top: 0; left: 0; right: 0;
    bottom: var(--card-footer);
    width: 100%;
    height: calc(100% - var(--card-footer));
    object-fit: contain;
    object-position: center;
    padding: 20px;
    z-index: 3;
}

/* Logo fallback (initials) when artwork is absent or fails */
.channel-art-fallback {
    position: absolute;
    top: 0; left: 0; right: 0;
    bottom: var(--card-footer);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    pointer-events: none;
}
.channel-art-fallback span {
    font-size: 64px;
    font-weight: 800;
    color: rgba(255,255,255,0.22);
    text-shadow: 0 2px 24px rgba(0,0,0,0.6);
    line-height: 1;
    user-select: none;
    letter-spacing: -2px;
}

/* LIVE badge */
.channel-live-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 6;
    background: rgba(160,20,20,0.85);
    border: 1px solid rgba(255,100,100,0.35);
    border-radius: 6px;
    padding: 3px 8px;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 5px;
    text-transform: uppercase;
    backdrop-filter: blur(4px);
}
.channel-live-badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #ff6060;
    animation: pulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

.channel-card-shimmer {
    position: absolute;
    top: 0; left: 0; right: 0;
    bottom: var(--card-footer);
    z-index: 2;
    animation: cardShimmer 8s ease-in-out infinite;
    pointer-events: none;
}
@keyframes cardShimmer {
    0%   { background: rgba(0,0,0,0.03); }
    33%  { background: rgba(255,255,255,0.07); }
    66%  { background: rgba(0,0,0,0.06); }
    100% { background: rgba(0,0,0,0.03); }
}

.channel-card-inner::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    bottom: var(--card-footer);
    background: rgba(0,0,0,0.22);
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
    z-index: 4;
}
.channel-card:hover .channel-card-inner::after { opacity: 1; }

.channel-card-play {
    position: absolute;
    top: calc((100% - var(--card-footer)) / 2);
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6));
}
.channel-card:hover .channel-card-play { opacity: 0.85; }
.channel-card.playing .channel-card-play { opacity: 1; }

.channel-card-bottom {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: var(--card-footer);
    background: linear-gradient(to bottom, #000000, #000080, #000000);
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    z-index: 4;
}

.channel-name {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    margin-right: 36px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.channel-genre {
    font-size: 13px;
    color: #bbb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 3px;
}

.btn-fav {
    position: absolute;
    bottom: calc(var(--card-footer) + 8px);
    right: 8px;
    z-index: 7;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: opacity .2s, color .15s, border-color .15s, background .15s;
    backdrop-filter: blur(4px);
    opacity: 0;
}
.channel-card:hover .btn-fav,
.btn-fav.saved { opacity: 1; }
.btn-fav.saved { color: var(--fav); border-color: rgba(224,68,68,0.6); background: rgba(224,68,68,0.15); }
.btn-fav:not(.saved):hover { color: #fff; border-color: rgba(255,255,255,0.4); }

.channel-card.playing::after {
    content: '';
    position: absolute;
    top: 10px; right: 10px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent-text);
    animation: pulse 1.5s ease-in-out infinite;
    z-index: 10;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .3; transform: scale(.65); }
}

/* ── Toast ───────────────────────────────────────────────────────────── */
.tv-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: rgba(18,18,42,0.96);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 10px;
    padding: 10px 22px;
    color: #e0e0e0;
    font-size: 14px;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s, transform .22s;
    white-space: nowrap;
}
.tv-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Mini now-playing bar ─────────────────────────────────────────────── */
#mini-bar {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 68px;
    background: linear-gradient(135deg, #111 0%, #1a1a1a 100%);
    border-top: 1px solid var(--accent-line);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    transform: translateY(100%);
    transition: transform .25s ease;
}
#mini-bar.visible { transform: translateY(0); }

#mini-art {
    width: 44px; height: 44px;
    border-radius: 6px;
    object-fit: contain;
    background: #1a1a1a;
    flex-shrink: 0;
}

#mini-pulse {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--fav);
    animation: pulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}
#mini-bar.buffering #mini-pulse { background: var(--muted); }
#mini-bar.error     #mini-pulse { background: var(--fav); animation: none; }

#mini-info { flex: 1; min-width: 0; }
#mini-name   { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mini-status { font-size: 13px; color: var(--muted); }
#mini-bar.error #mini-status { color: var(--fav); }

.mini-open-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    padding: 7px 12px;
    cursor: pointer;
    display: flex; align-items: center; gap: 5px;
    transition: border-color .15s;
    flex-shrink: 0;
}
.mini-open-btn:hover { border-color: var(--accent-line); }

/* ═══════════════════════════════════════════════════════════════════════
   NOW PLAYING VIEW
   ═══════════════════════════════════════════════════════════════════════ */

#now-playing-view {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar) transparent;
    z-index: 5;
    background: #000 url('../../images/nightsky/stars.png') repeat top center;
}
html[data-theme="light"] #now-playing-view { background: transparent; }

/* Top bar */
#np-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, #111 0%, #1a1a1a 100%);
    border-bottom: 1px solid var(--border);
    height: 72px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px 0 10px;
}

.np-back-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    width: 36px;
    height: 36px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
    flex-shrink: 0;
}
.np-back-btn:hover { color: var(--text); border-color: var(--border-h); background: rgba(255,255,255,.06); }

#np-topbar-channel {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
    max-width: 260px;
    min-width: 0;
    overflow: hidden;
}

#np-topbar-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

#np-topbar-text {
    flex: 1;
    min-width: 0;
}

#np-topbar-name {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-head);
}

#np-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

.tp-btn {
    background: rgba(255,255,255,.07);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    flex-shrink: 0;
}
.tp-btn:hover { background: rgba(255,255,255,.14); border-color: var(--border-h); }
.tp-btn.muted { color: var(--muted); }

.np-stop-btn {
    background: var(--btn-grad);
    border: 1px solid var(--accent-edge);
    border-radius: 8px;
    color: #fff;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex; align-items: center; gap: 6px;
    transition: background .15s;
    flex-shrink: 0;
}
.np-stop-btn:hover { background: var(--btn-grad-hover); border-color: var(--accent-line); }

/* Video */
#np-video-wrap {
    position: relative;
    width: 100%;
    background: #000;
    aspect-ratio: 16 / 9;
    max-height: calc(100vh - 72px);
    flex-shrink: 0;
}
#np-video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

#np-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    transition: opacity .2s;
}
#np-overlay.hidden { opacity: 0; pointer-events: none; }

.spinner-ring {
    width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,0.12);
    border-top-color: var(--accent-text);
    border-radius: 50%;
    animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#np-overlay-msg {
    color: rgba(255,255,255,0.7);
    font-size: 14px;
}

/* Info below video */
#np-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 24px 80px;
}

#np-header-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    max-width: 560px;
    margin-bottom: 6px;
}

#np-logo {
    width: 48px; height: 48px;
    border-radius: 10px;
    object-fit: contain;
    background: rgba(255,255,255,.04);
    border: 1px solid var(--border);
    display: block;
}

#np-logo-fallback {
    width: 48px; height: 48px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0a1628, #1e4470);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}
#np-logo-fallback span {
    font-size: 18px;
    font-weight: 800;
    color: rgba(255,255,255,0.6);
    user-select: none;
    letter-spacing: -1px;
}

/* Channel metadata tags (always shown when a channel is playing) */
#np-channel-info {
    width: 100%;
    max-width: 560px;
    margin-bottom: 16px;
}
#np-channel-info.hidden { display: none; }
#np-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.np-tag {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    text-transform: capitalize;
}

#np-text { flex: 1; min-width: 0; }

#np-name {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-head);
    line-height: 1.2;
    margin-bottom: 4px;
}

#np-meta {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#np-status {
    min-height: 20px;
    font-size: 15px;
    color: var(--muted);
    text-align: center;
    margin: 8px 0 24px;
    width: 100%;
    max-width: 560px;
}
#now-playing-view.error   #np-status { color: var(--fav); }
#now-playing-view.playing #np-status { color: rgba(255,255,255,.3); }

#np-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.ctrl-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text);
    cursor: pointer;
    transition: background .15s, border-color .15s;
    flex-shrink: 0;
}
.ctrl-btn:hover { background: var(--surface-h); border-color: var(--border-h); }
.ctrl-btn.muted { color: var(--muted); }

.np-fav-btn { color: var(--muted); }
.np-fav-btn.saved { color: var(--fav); border-color: rgba(224,68,68,.5); background: rgba(224,68,68,.1); }

#np-volume {
    width: 80px;
    accent-color: var(--accent-text);
    cursor: pointer;
    flex-shrink: 0;
}

/* Admin panel */
#np-admin {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    padding: 16px 20px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 12px;
    background: rgba(255,255,255,.02);
    min-width: 300px;
}
#np-admin.visible { display: flex; }

#np-admin-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--muted);
    font-weight: 700;
}

#np-admin-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.admin-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 7px 14px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    display: flex; align-items: center; gap: 6px;
    transition: background .15s, border-color .15s;
}
.admin-btn:hover { background: var(--surface-h); border-color: var(--border-h); }
.admin-btn.danger { border-color: rgba(224,68,68,.4); color: var(--fav); }
.admin-btn.danger:hover { background: rgba(224,68,68,.1); border-color: var(--fav); }

#np-admin-msg {
    font-size: 12px;
    color: var(--muted);
    min-height: 16px;
    text-align: center;
}

#np-raw-wrap {
    display: none;
    max-width: 560px;
    width: 100%;
    margin-bottom: 24px;
}
#np-raw-wrap.visible { display: block; }

#np-raw {
    background: rgba(255,255,255,.04);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    font-size: 11px;
    line-height: 1.6;
    color: var(--muted);
    white-space: pre-wrap;
    word-break: break-all;
    font-family: 'Consolas', 'Courier New', monospace;
    max-height: 320px;
    overflow-y: auto;
}

/* ── Related channels ────────────────────────────────────────────────── */
#np-related {
    width: 100%;
    max-width: 720px;
    margin-bottom: 20px;
}
#np-related.hidden { display: none; }

.np-related-head {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin-bottom: 10px;
}

#np-related-grid {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 6px;
}
#np-related-grid::-webkit-scrollbar { display: none; }

.np-rel-card {
    flex-shrink: 0;
    width: 150px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}
.np-rel-card:hover {
    border-color: var(--border-h);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.np-rel-art {
    width: 100%;
    height: 90px;
    background: linear-gradient(135deg, #0a1628, #1e4470);
    overflow: hidden;
}
.np-rel-art img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
    display: block;
}
.np-rel-art-init {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: 800;
    color: rgba(255,255,255,0.22);
    user-select: none;
    letter-spacing: -1px;
}
.np-rel-info {
    padding: 8px 10px;
}
.np-rel-name {
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-head);
    line-height: 1.3;
}
.np-rel-meta {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Shared: spinner & empty ─────────────────────────────────────────── */
.spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    justify-content: center;
    padding: 80px 24px;
    color: var(--muted);
    font-size: 15px;
    grid-column: 1 / -1;
}
.spinner::before {
    content: '';
    width: 52px; height: 52px;
    border: 3px solid rgba(255,255,255,.1);
    border-top-color: var(--accent-text);
    border-radius: 50%;
    animation: spin .75s linear infinite;
}

.empty-msg {
    text-align: center;
    color: var(--muted);
    padding: 60px 24px;
    font-size: 14px;
    grid-column: 1 / -1;
    line-height: 1.8;
}

/* ── Browse prompt (shown when Browse tab is active with no search/category) ── */
.browse-prompt {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 80px 24px;
    text-align: center;
}
.browse-prompt-icon {
    color: var(--muted);
    opacity: .45;
    margin-bottom: 6px;
}
.browse-prompt-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-head);
    letter-spacing: -.3px;
}
.browse-prompt-body {
    font-size: 15px;
    color: var(--muted);
    max-width: 360px;
    line-height: 1.75;
}

/* ── Scrollbar ───────────────────────────────────────────────────────── */
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.25); }

/* ── Light mode chrome ───────────────────────────────────────────────── */
html[data-theme="light"] #mini-bar,
html[data-theme="light"] #np-topbar {
    background: rgba(255,255,255,0.58);
}
html[data-theme="light"] .tp-btn { background: rgba(0,0,0,.05); border-color: rgba(0,0,0,.15); color: #1a1a2e; }
html[data-theme="light"] .tp-btn:hover { background: rgba(0,0,0,.1); }
html[data-theme="light"] .np-back-btn:hover { background: rgba(0,0,0,.05); }
/* #tabs, #filter-row and #tags-row-wrap have no light-mode wash of their own:
   they are transparent in both themes so the sky is continuous behind the
   chrome. */
html[data-theme="light"] .tab-btn { color: rgba(10,10,40,0.55); }
html[data-theme="light"] .tab-btn.active { color: #0d0d1a; border-bottom-color: #0d0d1a; }
html[data-theme="light"] .tab-btn:hover:not(.active) { color: #0d0d1a; }
html[data-theme="light"] #country-select { color: #1a1a2e; }
html[data-theme="light"] #country-select option { background: #ffffff; color: #1a1a2e; }

/* ── EPG (Electronic Programme Guide) ───────────────────────────────── */
#np-epg {
    width: 100%;
    max-width: 560px;
    background: rgba(255,255,255,.04);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#np-epg.hidden { display: none; }

.epg-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.epg-badge {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #fff;
    background: rgba(160,30,30,0.85);
    border-radius: 5px;
    padding: 3px 7px;
    margin-top: 1px;
    line-height: 1.5;
    white-space: nowrap;
}
.epg-badge-next {
    background: rgba(255,255,255,0.10);
    color: var(--muted);
}

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

.epg-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-head);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
    line-height: 1.3;
}
.epg-row:last-child .epg-title {
    color: var(--muted);
    font-weight: 400;
}

.epg-time {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}
.epg-row:last-child .epg-time { margin-bottom: 0; }

.epg-bar {
    height: 4px;
    background: rgba(255,255,255,0.10);
    border-radius: 2px;
    overflow: hidden;
}
.epg-fill {
    height: 100%;
    background: var(--accent-text);
    border-radius: 2px;
    transition: width 1s linear;
    min-width: 2px;
}

#epg-next-row.hidden { display: none; }

/* ── EPG topbar strip ─────────────────────────────────────────────── */
#np-topbar-epg {
    flex: 1;
    min-width: 0;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    overflow: hidden;
}
#np-topbar-epg.hidden { display: none; }

#tb-cur-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#tb-cur-time {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}
.tb-epg-bar {
    height: 3px;
    background: rgba(255,255,255,0.10);
    border-radius: 2px;
    overflow: hidden;
    margin: 2px 0;
}
.tb-epg-fill {
    height: 100%;
    background: var(--accent-text);
    border-radius: 2px;
    transition: width 0.5s linear;
}
#tb-next-row {
    display: flex;
    align-items: center;
    gap: 5px;
}
#tb-next-row.hidden { display: none; }
.tb-next-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: rgba(255,255,255,0.08);
    padding: 1px 4px;
    border-radius: 3px;
    flex-shrink: 0;
}
#tb-next-title {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    #channel-grid { grid-template-columns: 1fr; }
    .channel-card { height: 260px; --card-footer: 80px; }
    #np-main { padding: 16px 16px 60px; }
    #np-name { font-size: 18px; }
    #np-volume { width: 70px; }
    #np-admin { min-width: unset; width: 100%; }
    #tv-header { padding: 0 10px; gap: 7px; }
    #filter-row { padding: 6px 10px; gap: 8px; }
    #np-topbar { gap: 6px; padding: 0 8px 0 6px; }
    .tp-btn { width: 32px; height: 32px; }
    .np-stop-btn { padding: 6px 10px; }
}
@media (max-width: 480px) {
    #np-volume { display: none; }
    #np-topbar-name { font-size: 14px; }
    .np-stop-btn { font-size: 11px; padding: 6px 8px; }
}
@media (max-width: 400px) {
    #tv-logo span { display: none; }
    #np-controls { gap: 10px; }
    #np-fullscreen { display: none; }
}
