:root {
    --bg: #070b14;
    --bg-soft: #0b1220;
    --panel: rgba(14, 20, 32, 0.94);
    --panel-strong: #111827;
    --card: rgba(255, 255, 255, 0.055);
    --card-hover: rgba(255, 255, 255, 0.105);
    --text: #f8fafc;
    --muted: #98a4b8;
    --line: rgba(255, 255, 255, 0.105);
    --brand: #ef4444;
    --brand-2: #f97316;
    --success: #5eead4;
    --danger: #fb7185;
    --radius: 22px;
    --shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 8% 0%, rgba(239, 68, 68, 0.16), transparent 31rem),
        radial-gradient(circle at 96% 4%, rgba(249, 115, 22, 0.11), transparent 26rem),
        linear-gradient(180deg, #060914 0%, #0b1020 42%, #080c16 100%);
}

button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
    width: min(1480px, 100%);
    margin: 0 auto;
    padding: 18px 22px 28px;
}

.topbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
}

.eyebrow {
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--brand);
    font-size: 11px;
    font-weight: 900;
}

h1, h2, p { margin-top: 0; }

h1 {
    margin-bottom: 0;
    font-size: clamp(25px, 3.2vw, 42px);
    line-height: 1;
}

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.stats span, .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.055);
    color: var(--muted);
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 12px;
}

.stats b { color: var(--text); }

.layout {
    display: block;
}

.content {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.player-card, .channel-section {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    border-radius: var(--radius);
    overflow: hidden;
}

.player-card {
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
}

.video-wrap {
    position: relative;
    background: #020617;
    aspect-ratio: 16 / 9;
}

video {
    display: block;
    width: 100%;
    height: 100%;
    background: #020617;
}

.player-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    text-align: center;
    padding: 30px;
    background:
        linear-gradient(120deg, rgba(5, 9, 18, 0.95), rgba(5, 9, 18, 0.66)),
        radial-gradient(circle, rgba(239, 68, 68, 0.16), transparent 26rem);
}

.player-overlay.hidden { display: none; }

.logo-placeholder {
    width: 72px;
    height: 72px;
    border-radius: 24px;
    display: grid;
    place-items: center;
    margin: 0 auto 15px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
    font-size: 27px;
    font-weight: 950;
    box-shadow: 0 18px 40px rgba(239, 68, 68, 0.25);
}

.player-overlay h2 { margin-bottom: 8px; }
.player-overlay p { max-width: 640px; color: var(--muted); line-height: 1.55; }

.now-playing {
    display: grid;
    grid-template-columns: 76px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    background: rgba(2, 6, 23, 0.28);
}

#nowLogo {
    width: 76px;
    height: 56px;
    object-fit: contain;
    border-radius: 14px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.92);
}

.now-meta { min-width: 0; }
#nowGroup { margin: 0 0 4px; color: var(--success); font-weight: 800; font-size: 13px; }
#nowTitle { margin: 0 0 8px; font-size: clamp(19px, 2.4vw, 30px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { padding: 5px 8px; font-size: 11px; }
.badge.drm { border-color: rgba(251, 113, 133, 0.6); color: #fecdd3; }

.player-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.action-btn {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 9px 11px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    text-decoration: none;
    transition: 0.18s ease;
}

.action-btn:hover:not(:disabled) {
    border-color: rgba(239, 68, 68, 0.72);
    background: rgba(239, 68, 68, 0.12);
}

.action-btn:disabled, .action-btn.disabled {
    opacity: 0.45;
    pointer-events: none;
}

.player-message {
    display: none;
    padding: 12px 16px 16px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    line-height: 1.55;
}

.player-message.show { display: block; }
.player-message.error { color: #fecdd3; }

.channel-section {
    padding: 0;
    max-width: 1480px;
    width: 100%;
    margin: 0 auto;
}

.channel-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 16px 18px 12px;
    background:
        linear-gradient(180deg, rgba(14, 20, 32, 0.98), rgba(14, 20, 32, 0.91)),
        var(--panel);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

.toolbar-row {
    display: grid;
    grid-template-columns: minmax(190px, auto) minmax(240px, 420px);
    gap: 16px;
    align-items: end;
    margin-bottom: 13px;
}

.toolbar-row h2 {
    margin-bottom: 0;
    font-size: clamp(22px, 2.7vw, 34px);
}

.search-box input {
    width: 100%;
    border: 1px solid var(--line);
    background: rgba(2, 6, 23, 0.55);
    color: var(--text);
    border-radius: 999px;
    padding: 12px 15px;
    outline: none;
}

.search-box input:focus {
    border-color: rgba(239, 68, 68, 0.78);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
}

.category-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0 12px;
    margin: 0 -2px;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
}

.category-list::-webkit-scrollbar { height: 8px; }
.category-list::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.04); border-radius: 999px; }
.category-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.18); border-radius: 999px; }

.category-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 999px;
    padding: 11px 16px;
    background: rgba(255, 255, 255, 0.055);
    color: rgba(248, 250, 252, 0.9);
    transition: 0.18s ease;
    scroll-snap-align: start;
    white-space: nowrap;
    min-height: 44px;
}

.category-btn span:first-child {
    font-weight: 800;
}

.category-btn span:last-child {
    display: inline-flex;
    min-width: 24px;
    height: 22px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0 7px;
    background: rgba(0, 0, 0, 0.24);
    color: var(--muted);
    font-size: 11px;
}

.category-btn:hover {
    border-color: rgba(239, 68, 68, 0.62);
    background: rgba(239, 68, 68, 0.10);
}

.category-btn.active {
    border-color: rgba(239, 68, 68, 0.94);
    color: #fff;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.95), rgba(249, 115, 22, 0.72));
    box-shadow: 0 12px 28px rgba(239, 68, 68, 0.18);
}

.category-btn.active span:last-child {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}

.chip {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--muted);
    font-size: 12px;
    transition: 0.18s ease;
}

.chip:hover, .chip.active {
    border-color: rgba(94, 234, 212, 0.58);
    background: rgba(94, 234, 212, 0.10);
    color: var(--text);
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 16px;
    padding: 18px 18px 10px;
}

.section-head h2 { margin-bottom: 0; }
.result-count { color: var(--muted); font-size: 14px; text-align: right; }

.build-note {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
    text-align: right;
}

.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
    gap: 12px;
    padding: 8px 18px 20px;
}

.channel-card {
    position: relative;
    border: 1px solid var(--line);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.035)),
        var(--card);
    border-radius: 18px;
    padding: 12px;
    min-height: 148px;
    color: var(--text);
    text-align: left;
    transition: transform 0.18s ease, border 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
    overflow: hidden;
}

.channel-card:hover {
    transform: translateY(-2px);
    border-color: rgba(239, 68, 68, 0.55);
    background: var(--card-hover);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.20);
}

.channel-card.active {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.20) inset;
}

.card-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: flex-start;
}

.card-logo {
    width: 86px;
    height: 58px;
    object-fit: contain;
    padding: 7px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
}

.favorite-star {
    color: #fde68a;
    font-size: 18px;
    line-height: 1;
}

.channel-name {
    margin: 13px 0 2px;
    line-height: 1.25;
    font-weight: 850;
    min-height: 36px;
}

.channel-sub {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    color: var(--muted);
    font-size: 10px;
    opacity: 0.62;
}

.pill {
    border-radius: 999px;
    padding: 3px 6px;
    background: rgba(0, 0, 0, 0.22);
}

.empty {
    grid-column: 1 / -1;
    padding: 40px 20px;
    text-align: center;
    border: 1px dashed var(--line);
    border-radius: 18px;
    color: var(--muted);
}

/* TV360 event cards: white logos need a darker stage and less text clutter. */
.channel-card.is-tv360 {
    min-height: 146px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background:
        linear-gradient(145deg, rgba(31, 41, 55, 0.96), rgba(15, 23, 42, 0.98)),
        var(--card);
    border-color: rgba(148, 163, 184, 0.22);
}

.channel-card.is-tv360:hover {
    background:
        linear-gradient(145deg, rgba(39, 51, 68, 0.98), rgba(17, 24, 39, 1)),
        var(--card-hover);
    border-color: rgba(148, 163, 184, 0.46);
}

.channel-card.is-tv360.active {
    border-color: rgba(239, 68, 68, 0.78);
    box-shadow:
        0 0 0 2px rgba(239, 68, 68, 0.16) inset,
        0 16px 42px rgba(0, 0, 0, 0.28);
}

.channel-card.is-tv360 .card-top {
    min-height: 90px;
    align-items: flex-start;
}

.channel-card.is-tv360 .card-logo {
    width: 116px;
    height: 66px;
    padding: 6px 9px;
    border-radius: 14px;
    background:
        linear-gradient(145deg, rgba(107, 114, 128, 0.42), rgba(31, 41, 55, 0.92));
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.08),
        0 14px 28px rgba(0, 0, 0, 0.24);
}

.channel-card.is-tv360 .channel-name { display: none; }

.channel-card.is-tv360 .channel-sub {
    gap: 4px;
    margin-top: 8px;
    font-size: 9px;
    line-height: 1;
    opacity: 0.68;
}

.channel-card.is-tv360 .pill {
    padding: 3px 6px;
    font-size: 9px;
    letter-spacing: 0.01em;
    background: rgba(2, 6, 23, 0.38);
    color: rgba(203, 213, 225, 0.86);
}

@media (max-width: 980px) {
    .app-shell { padding: 14px; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .stats { justify-content: flex-start; }
    .toolbar-row { grid-template-columns: 1fr; align-items: start; }
    .now-playing { grid-template-columns: 62px 1fr; }
    #nowLogo { width: 62px; height: 48px; }
    .player-actions { grid-column: 1 / -1; justify-content: stretch; }
    .action-btn { flex: 1; text-align: center; }
    .channel-toolbar { top: 0; }
}

@media (max-width: 560px) {
    .topbar { margin-bottom: 12px; }
    .stats span { font-size: 11px; padding: 6px 8px; }
    .player-card { border-radius: 18px; }
    .now-playing { padding: 12px; }
    .badges { display: none; }
    .channel-section { border-radius: 18px; }
    .channel-toolbar { padding: 13px 12px 10px; }
    .category-list { gap: 8px; padding-bottom: 10px; }
    .category-btn { padding: 9px 12px; min-height: 40px; }
    .quick-actions { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
    .chip { flex: 0 0 auto; }
    .section-head { align-items: flex-start; flex-direction: column; padding: 14px 12px 8px; }
    .result-count, .build-note { text-align: left; }
    .channel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 6px 12px 16px; }
    .channel-card { min-height: 136px; padding: 10px; }
    .card-logo { width: 74px; height: 50px; }
    .channel-name { font-size: 14px; min-height: 34px; }
    .channel-card.is-tv360 { min-height: 128px; padding: 10px; }
    .channel-card.is-tv360 .card-top { min-height: 72px; }
    .channel-card.is-tv360 .card-logo { width: 98px; height: 56px; }
}
