:root {
    color-scheme: dark;
    --bg: #0d1115;
    --panel: #151b21;
    --panel-2: #0f1419;
    --border: #2a333d;
    --text: #f5f7fa;
    --muted: #a8b3bf;
    --accent: #12b886;
    --danger: #fecaca;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

.tv-shell {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 18px;
}

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

.tv-topbar h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.1;
}

.tv-topbar p {
    margin: 6px 0 0;
    color: var(--muted);
}

.tv-topbar .tv-source-note {
    margin-top: 3px;
}

.tv-actions {
    display: flex;
    align-items: end;
    gap: 10px;
}

.tv-search {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
}

.tv-search input {
    width: min(320px, 48vw);
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel-2);
    color: var(--text);
    padding: 9px 12px;
}

.tv-proxy-toggle {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    background: var(--panel);
    padding: 8px 12px;
    text-decoration: none;
}

.tv-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
    gap: 16px;
    align-items: start;
}

.tv-player-panel,
.tv-channel-panel,
.tv-empty {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    overflow: hidden;
}

.tv-player {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #030405;
}

.tv-now,
.tv-status {
    padding: 11px 13px;
    border-top: 1px solid var(--border);
}

.tv-now {
    display: flex;
    gap: 8px;
    color: var(--muted);
}

.tv-now strong {
    color: var(--text);
}

.tv-status {
    min-height: 40px;
    color: var(--muted);
    background: var(--panel-2);
}

.tv-status:empty {
    display: none;
}

.tv-status.is-error {
    color: var(--danger);
}

.tv-status.is-loading {
    color: #ccfbf1;
}

.tv-channel-panel {
    max-height: calc(100vh - 118px);
    overflow: auto;
}

.tv-channel-list {
    display: grid;
    gap: 8px;
    padding: 10px;
}

.tv-channel {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 54px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--text);
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
}

.tv-channel:hover,
.tv-channel:focus,
.tv-channel.is-active {
    border-color: var(--accent);
    outline: none;
}

.tv-channel.is-active {
    box-shadow: 0 0 0 1px var(--accent) inset;
}

.tv-channel img,
.tv-avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 6px;
    object-fit: contain;
    background: #080b0e;
}

.tv-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-weight: 700;
}

.tv-channel span:last-child {
    overflow-wrap: anywhere;
}

.tv-empty {
    padding: 24px;
}

@media (max-width: 900px) {
    .tv-topbar,
    .tv-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .tv-search input {
        width: 100%;
    }

    .tv-layout {
        grid-template-columns: 1fr;
    }

    .tv-channel-panel {
        max-height: none;
    }
}
