:root {
    color-scheme: dark;
    --bg: #080b12;
    --bg-raised: #0d121c;
    --panel: rgba(16, 22, 34, 0.92);
    --panel-solid: #101622;
    --panel-soft: #151d2b;
    --panel-hover: #1a2434;
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #f5f7fb;
    --muted: #929cad;
    --muted-strong: #b9c0cc;
    --accent: #6ce5bd;
    --accent-strong: #2bd49c;
    --accent-deep: #103d34;
    --violet: #9a8cff;
    --danger: #ff6b7a;
    --warning: #ffcc66;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 13px;
    --radius-sm: 9px;
    --topbar-height: 76px;
    --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html {
    min-width: 320px;
    min-height: 100%;
    background: var(--bg);
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 78% 8%, rgba(80, 67, 167, 0.17), transparent 30rem),
        radial-gradient(circle at 12% 86%, rgba(24, 142, 111, 0.11), transparent 30rem),
        var(--bg);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select {
    font: inherit;
}

button,
a,
input,
select {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
}

button:not(:disabled),
a {
    cursor: pointer;
}

button:disabled {
    cursor: wait;
    opacity: 0.72;
}

a {
    color: inherit;
    text-decoration: none;
}

svg {
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

:focus-visible {
    outline: 3px solid rgba(108, 229, 189, 0.9);
    outline-offset: 3px;
}

.skip-link {
    position: fixed;
    z-index: 1000;
    top: 12px;
    left: 12px;
    padding: 10px 16px;
    border-radius: 10px;
    color: #07130f;
    background: var(--accent);
    font-weight: 800;
    transform: translateY(-160%);
    transition: transform 160ms ease;
}

.skip-link:focus {
    transform: translateY(0);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.15em;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    min-width: max-content;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    padding: 8px;
    border: 1px solid rgba(108, 229, 189, 0.25);
    border-radius: 12px;
    background: linear-gradient(145deg, rgba(108, 229, 189, 0.2), rgba(154, 140, 255, 0.12));
    grid-template-columns: repeat(3, 1fr);
    align-items: end;
    gap: 3px;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 9px 24px rgba(43, 212, 156, 0.08);
}

.brand-mark span {
    display: block;
    border-radius: 99px;
    background: var(--accent);
}

.brand-mark span:nth-child(1) { height: 42%; opacity: 0.72; }
.brand-mark span:nth-child(2) { height: 100%; }
.brand-mark span:nth-child(3) { height: 68%; opacity: 0.84; }

.brand-copy {
    display: grid;
    line-height: 1;
}

.brand-copy strong {
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.brand-copy small {
    margin-top: 5px;
    color: var(--muted);
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.18em;
}

.brand-large .brand-mark {
    width: 48px;
    height: 48px;
    padding: 10px;
    border-radius: 15px;
}

.brand-large .brand-copy strong {
    font-size: 25px;
}

.topbar {
    position: sticky;
    z-index: 50;
    top: 0;
    display: grid;
    min-height: var(--topbar-height);
    padding: 14px clamp(18px, 3vw, 42px);
    border-bottom: 1px solid var(--line);
    background: rgba(8, 11, 18, 0.82);
    backdrop-filter: blur(22px) saturate(145%);
    grid-template-columns: auto minmax(240px, 560px) 1fr;
    align-items: center;
    gap: clamp(22px, 4vw, 56px);
}

.topbar-search {
    width: 100%;
}

.search-box {
    display: flex;
    width: 100%;
    min-height: 44px;
    padding: 0 12px 0 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.045);
    align-items: center;
    gap: 10px;
    transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.search-box:focus-within {
    border-color: rgba(108, 229, 189, 0.55);
    background: rgba(255, 255, 255, 0.065);
    box-shadow: 0 0 0 4px rgba(108, 229, 189, 0.08);
}

.search-box input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
}

.search-box input::placeholder {
    color: #707a89;
}

.search-box input::-webkit-search-cancel-button {
    filter: invert(0.8);
}

.search-box kbd {
    display: inline-grid;
    min-width: 24px;
    height: 24px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--muted);
    background: rgba(0, 0, 0, 0.18);
    font: 700 12px/1 var(--font);
    place-items: center;
}

.topbar-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 18px;
}

.connection-state {
    display: inline-flex;
    color: var(--muted-strong);
    font-size: 13px;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    box-shadow: 0 0 0 4px rgba(255, 204, 102, 0.1);
}

.status-dot.is-online {
    background: var(--accent-strong);
    box-shadow: 0 0 0 4px rgba(43, 212, 156, 0.12), 0 0 12px rgba(43, 212, 156, 0.36);
}

.status-dot.is-error {
    background: var(--danger);
    box-shadow: 0 0 0 4px rgba(255, 107, 122, 0.12);
}

.icon-button,
.quiet-button,
.secondary-button,
.primary-button {
    display: inline-flex;
    border: 0;
    align-items: center;
    justify-content: center;
}

.icon-button {
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--muted-strong);
    background: rgba(255, 255, 255, 0.045);
    gap: 8px;
    transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-button:hover {
    border-color: rgba(255, 107, 122, 0.35);
    color: #ffd7dc;
    background: rgba(255, 107, 122, 0.09);
}

.proxy-button:hover {
    border-color: rgba(108, 229, 189, 0.38);
    color: #dffcf2;
    background: rgba(43, 212, 156, 0.09);
}

.proxy-button svg {
    color: var(--accent);
}

.proxy-button [data-proxy-label] {
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
}

.workspace {
    display: grid;
    width: min(1760px, 100%);
    min-height: calc(100vh - var(--topbar-height));
    margin: 0 auto;
    padding: clamp(18px, 2.5vw, 38px);
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
    align-items: start;
    gap: clamp(20px, 2.5vw, 38px);
}

.browse-panel,
.player-card,
.schedule-card {
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.browse-panel {
    position: sticky;
    top: calc(var(--topbar-height) + 24px);
    display: flex;
    max-height: calc(100vh - var(--topbar-height) - 48px);
    min-height: 540px;
    padding: 20px 12px 12px;
    border-radius: var(--radius-xl);
    flex-direction: column;
    overflow: hidden;
}

.panel-heading,
.player-heading,
.schedule-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-heading {
    padding: 0 8px 14px;
}

.panel-heading h1,
.player-heading h2,
.schedule-heading h2 {
    margin: 0;
    font-size: 21px;
    line-height: 1.2;
}

.count-badge {
    min-width: 40px;
    padding: 4px 9px;
    border: 1px solid var(--line);
    border-radius: 99px;
    color: var(--muted-strong);
    background: rgba(255, 255, 255, 0.045);
    font-size: 12px;
    font-weight: 750;
    text-align: center;
}

.category-strip {
    display: flex;
    min-height: 41px;
    padding: 1px 8px 13px;
    gap: 7px;
    overflow-x: auto;
    scrollbar-width: none;
}

.category-strip::-webkit-scrollbar {
    display: none;
}

.category-chip {
    min-width: max-content;
    height: 31px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 99px;
    color: var(--muted-strong);
    background: rgba(255, 255, 255, 0.035);
    font-size: 12px;
    font-weight: 720;
    transition: color 150ms ease, background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.category-chip:hover {
    border-color: var(--line-strong);
    color: var(--text);
    transform: translateY(-1px);
}

.category-chip[aria-pressed="true"] {
    border-color: rgba(108, 229, 189, 0.45);
    color: #dffcf2;
    background: rgba(43, 212, 156, 0.14);
}

.chip-skeleton {
    width: 76px;
    height: 31px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.07);
    animation: shimmer 1.35s ease-in-out infinite alternate;
    flex: 0 0 auto;
}

.chip-skeleton-short {
    width: 51px;
}

.channel-grid {
    display: grid;
    padding: 0 4px 4px;
    gap: 7px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
    scrollbar-width: thin;
}

.channel-grid::-webkit-scrollbar {
    width: 6px;
}

.channel-grid::-webkit-scrollbar-thumb {
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.14);
}

.channel-card {
    position: relative;
    display: grid;
    width: 100%;
    min-height: 66px;
    padding: 9px 34px 9px 9px;
    border: 1px solid transparent;
    border-radius: 14px;
    color: var(--text);
    background: transparent;
    grid-template-columns: 48px minmax(0, 1fr);
    align-items: center;
    gap: 11px;
    text-align: left;
    transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.channel-card::after {
    position: absolute;
    top: 50%;
    right: 13px;
    width: 7px;
    height: 7px;
    border-top: 1.5px solid currentColor;
    border-right: 1.5px solid currentColor;
    color: #626d7c;
    content: "";
    transform: translateY(-50%) rotate(45deg);
}

.channel-card:hover {
    border-color: var(--line);
    background: var(--panel-hover);
    transform: translateX(2px);
}

.channel-card.is-active {
    border-color: rgba(108, 229, 189, 0.33);
    background: linear-gradient(100deg, rgba(43, 212, 156, 0.15), rgba(154, 140, 255, 0.07));
}

.channel-card.is-active::before {
    position: absolute;
    top: 15px;
    bottom: 15px;
    left: -4px;
    width: 3px;
    border-radius: 99px;
    background: var(--accent);
    box-shadow: 0 0 12px rgba(108, 229, 189, 0.46);
    content: "";
}

.channel-card.is-active::after {
    color: var(--accent);
}

.channel-logo,
.selected-channel-logo {
    display: grid;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #dce4ee;
    background: linear-gradient(145deg, #222d3d, #151c29);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.04em;
    place-items: center;
}

.channel-logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
}

.channel-logo img,
.selected-channel-logo img {
    width: 100%;
    height: 100%;
    padding: 5px;
    object-fit: contain;
}

.channel-copy {
    display: grid;
    min-width: 0;
    gap: 3px;
}

.channel-copy strong {
    overflow: hidden;
    font-size: 14px;
    font-weight: 730;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-copy span {
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-number {
    color: var(--accent) !important;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}

.channel-skeleton {
    display: grid;
    min-height: 66px;
    padding: 9px;
    grid-template-columns: 48px 1fr;
    gap: 11px;
}

.channel-skeleton span {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.075);
    grid-row: span 2;
}

.channel-skeleton i {
    align-self: end;
    width: 72%;
    height: 9px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.075);
}

.channel-skeleton i:last-child {
    width: 48%;
    align-self: start;
}

.channel-skeleton span,
.channel-skeleton i {
    animation: shimmer 1.35s ease-in-out infinite alternate;
}

.empty-state {
    display: grid;
    min-height: 220px;
    padding: 28px;
    color: var(--muted);
    text-align: center;
    place-items: center;
    align-content: center;
    gap: 7px;
}

.empty-state strong {
    color: var(--muted-strong);
}

.empty-state span {
    max-width: 230px;
    font-size: 13px;
}

.watch-panel {
    display: grid;
    min-width: 0;
    gap: 20px;
}

.player-card,
.schedule-card {
    overflow: hidden;
    border-radius: var(--radius-xl);
}

.player-heading {
    min-height: 78px;
    padding: 14px 20px;
}

.selected-channel {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
}

.selected-channel > div {
    min-width: 0;
}

.selected-channel h2 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selected-channel-logo {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    flex: 0 0 auto;
}

.live-pill {
    display: inline-flex;
    height: 28px;
    padding: 0 10px;
    border: 1px solid rgba(255, 107, 122, 0.28);
    border-radius: 99px;
    color: #ffc7ce;
    background: rgba(255, 107, 122, 0.1);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.09em;
    align-items: center;
    gap: 7px;
}

.live-pill span,
.program-live-mark span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 4px rgba(255, 107, 122, 0.12), 0 0 11px rgba(255, 107, 122, 0.54);
    animation: pulse 1.8s ease-in-out infinite;
}

.player-stage {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    color: var(--muted);
    background:
        radial-gradient(circle at 50% 44%, rgba(87, 75, 181, 0.19), transparent 35%),
        linear-gradient(145deg, #070a10, #0b1019);
    isolation: isolate;
}

.player-stage::before {
    position: absolute;
    z-index: -1;
    inset: 0;
    opacity: 0.25;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px);
    background-size: 36px 36px;
    content: "";
    mask-image: linear-gradient(to bottom, black, transparent 85%);
}

.player-stage video {
    position: absolute;
    z-index: 1;
    width: 100%;
    height: 100%;
    inset: 0;
    background: #000;
    object-fit: contain;
}

.player-stage video:not([data-ready="true"]) {
    visibility: hidden;
}

.quality-control {
    position: absolute;
    z-index: 5;
    top: 12px;
    right: 12px;
    display: flex;
    min-height: 36px;
    padding: 4px 5px 4px 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    color: #eef6f4;
    background: rgba(7, 11, 18, 0.86);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(10px);
    align-items: center;
    gap: 8px;
}

.quality-control-label {
    color: var(--muted-strong);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.quality-active {
    min-width: 48px;
    padding: 3px 7px;
    border: 1px solid rgba(108, 229, 189, 0.2);
    border-radius: 8px;
    color: var(--accent);
    background: rgba(43, 212, 156, 0.08);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    text-align: center;
}

.quality-control label {
    display: flex;
}

.quality-control select {
    min-width: 88px;
    height: 28px;
    padding: 0 26px 0 9px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    color: var(--text);
    background-color: #121924;
    font-size: 11px;
    font-weight: 750;
}

.quality-control select:hover:not(:disabled) {
    border-color: rgba(108, 229, 189, 0.46);
}

.quality-control select:disabled {
    opacity: 0.65;
}

.player-placeholder,
.player-loading,
.player-error {
    position: absolute;
    z-index: 3;
    display: grid;
    padding: 28px;
    text-align: center;
    inset: 0;
    place-items: center;
    align-content: center;
    gap: 8px;
}

.player-placeholder strong,
.player-loading strong,
.player-error strong {
    color: var(--text);
    font-size: 17px;
}

.player-placeholder > span:last-child,
.player-loading > span:last-child,
.player-error > span {
    font-size: 13px;
}

.broadcast-glyph {
    display: grid;
    width: 84px;
    height: 84px;
    margin-bottom: 8px;
    border: 1px solid rgba(108, 229, 189, 0.2);
    border-radius: 50%;
    color: var(--accent);
    background: rgba(108, 229, 189, 0.055);
    place-items: center;
}

.broadcast-glyph svg circle {
    opacity: 0.42;
}

.broadcast-glyph svg path {
    fill: currentColor;
    stroke: none;
}

.loader,
.button-spinner {
    border-radius: 50%;
    animation: spin 750ms linear infinite;
}

.loader {
    width: 38px;
    height: 38px;
    margin-bottom: 8px;
    border: 3px solid rgba(108, 229, 189, 0.16);
    border-top-color: var(--accent);
}

.player-error {
    color: #ffb6bf;
    background: rgba(19, 7, 11, 0.88);
    backdrop-filter: blur(12px);
}

.secondary-button {
    min-height: 38px;
    margin-top: 9px;
    padding: 0 15px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    font-size: 13px;
    font-weight: 750;
}

.secondary-button:hover {
    background: rgba(255, 255, 255, 0.13);
}

.now-strip {
    display: grid;
    min-height: 76px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.018);
    grid-template-columns: 24px minmax(0, 1fr) minmax(110px, 24%);
    align-items: center;
    gap: 12px;
}

.program-live-mark {
    display: grid;
    place-items: center;
}

.now-summary {
    display: grid;
    min-width: 0;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 9px;
}

.now-summary strong {
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.now-summary > span:last-child {
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.now-label,
.schedule-state {
    color: var(--accent);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.12em;
}

.program-progress {
    height: 4px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.1);
}

.program-progress span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-strong), var(--violet));
    transition: width 500ms ease;
}

.playback-debug {
    border-top: 1px solid var(--line);
    background: rgba(4, 8, 14, 0.34);
}

.playback-debug summary {
    display: flex;
    min-height: 44px;
    padding: 10px 20px;
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 750;
    list-style: none;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    user-select: none;
}

.playback-debug summary::-webkit-details-marker {
    display: none;
}

.playback-debug summary:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.025);
}

.debug-summary-icon {
    color: var(--accent);
}

.debug-chevron {
    margin-left: auto;
    color: var(--muted);
    transition: transform 160ms ease;
}

.playback-debug[open] .debug-chevron {
    transform: rotate(180deg);
}

.debug-values {
    display: grid;
    margin: 0;
    padding: 0 20px 16px;
    gap: 8px;
}

.debug-values > div {
    display: grid;
    min-width: 0;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
    grid-template-columns: 126px minmax(0, 1fr);
    align-items: start;
    gap: 12px;
}

.debug-values dt {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.045em;
    text-transform: uppercase;
}

.debug-values dd {
    min-width: 0;
    margin: 0;
}

.debug-values code {
    display: block;
    overflow-wrap: anywhere;
    color: #cfe9e1;
    font: 500 11px/1.55 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    user-select: text;
    white-space: pre-wrap;
}

.schedule-card {
    padding: 20px;
}

.schedule-heading {
    margin-bottom: 15px;
}

.quiet-button {
    min-height: 38px;
    padding: 0 11px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--muted);
    background: transparent;
    font-size: 12px;
    gap: 7px;
}

.quiet-button:hover {
    border-color: var(--line);
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.quiet-button.is-loading svg {
    animation: spin 750ms linear infinite;
}

.schedule-list {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.11);
    grid-template-columns: 1fr 1fr;
}

.schedule-item {
    display: grid;
    min-width: 0;
    min-height: 118px;
    padding: 17px;
    grid-template-columns: 55px minmax(0, 1fr);
    gap: 13px;
}

.schedule-item + .schedule-item {
    border-left: 1px solid var(--line);
}

.schedule-item.is-now {
    background: linear-gradient(110deg, rgba(43, 212, 156, 0.07), transparent 60%);
}

.schedule-time {
    color: var(--muted-strong);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    font-weight: 750;
}

.schedule-item > div {
    min-width: 0;
}

.schedule-item strong {
    display: block;
    overflow: hidden;
    margin-top: 4px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schedule-item p {
    display: -webkit-box;
    overflow: hidden;
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.toast-region {
    position: fixed;
    z-index: 100;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    display: grid;
    width: min(380px, calc(100vw - 36px));
    gap: 9px;
    pointer-events: none;
}

/* Proxy settings */
.toggle-row {
    position: relative;
    display: flex;
    min-height: 62px;
    padding: 12px 13px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.028);
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease;
}

.toggle-row:hover {
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.045);
}

.toggle-copy {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.toggle-copy strong {
    color: var(--text);
    font-size: 13px;
}

.toggle-copy small,
.proxy-help {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.45;
}

.toggle-row > input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.toggle-control {
    position: relative;
    display: block;
    width: 46px;
    height: 26px;
    padding: 3px;
    border: 1px solid var(--line-strong);
    border-radius: 99px;
    background: #202837;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.22);
    flex: 0 0 auto;
    transition: border-color 170ms ease, background 170ms ease, box-shadow 170ms ease;
}

.toggle-control span {
    display: block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #a7b0be;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.35);
    transition: background 170ms ease, transform 170ms ease;
}

.toggle-row > input:focus-visible + .toggle-control {
    outline: 3px solid rgba(108, 229, 189, 0.9);
    outline-offset: 3px;
}

.toggle-row > input:checked + .toggle-control {
    border-color: rgba(108, 229, 189, 0.55);
    background: rgba(43, 212, 156, 0.25);
    box-shadow: inset 0 2px 5px rgba(8, 38, 29, 0.3), 0 0 0 3px rgba(43, 212, 156, 0.06);
}

.toggle-row > input:checked + .toggle-control span {
    background: var(--accent);
    transform: translateX(20px);
}

.toggle-row:has(> input:disabled) {
    cursor: not-allowed;
    opacity: 0.62;
}

.proxy-login-settings {
    display: grid;
    gap: 0;
}

.proxy-field-area,
.proxy-settings-fields {
    padding-top: 13px;
}

.proxy-help {
    display: block;
    margin-top: 7px;
}

.proxy-parts {
    min-width: 0;
}

.proxy-primary-instruction {
    margin: 0 0 12px;
    color: var(--muted-strong);
    font-size: 12px;
    line-height: 1.5;
}

.proxy-preserve-note {
    display: block;
    margin: -7px 0 12px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.45;
}

.proxy-host-port-grid,
.proxy-credentials-grid {
    display: grid;
    min-width: 0;
    gap: 10px;
}

.proxy-host-port-grid {
    grid-template-columns: minmax(0, 1fr) minmax(82px, 0.34fr);
}

.proxy-credentials-grid {
    margin-top: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.proxy-scheme-compact {
    max-width: 154px;
    margin-top: 10px;
}

.compact-input-shell {
    min-height: 44px;
    padding-inline: 10px;
}

.input-shell select {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
    cursor: pointer;
}

.input-shell select option {
    color: var(--text);
    background: var(--panel-solid);
}

.proxy-parts .field > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.proxy-parts .field > span:first-child small {
    color: var(--muted);
    font-size: 9px;
    font-weight: 600;
}

.proxy-url-details {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.proxy-url-details summary {
    width: max-content;
    max-width: 100%;
    color: var(--accent);
    font-size: 11px;
    font-weight: 750;
    cursor: pointer;
}

.proxy-url-details summary::marker {
    color: var(--muted);
}

.proxy-url-details summary:hover {
    color: #cffff0;
}

.proxy-url-details[open] summary {
    margin-bottom: 11px;
}

.proxy-url-details-body {
    padding-left: 14px;
    border-left: 1px solid rgba(108, 229, 189, 0.18);
}

.proxy-dialog {
    width: min(520px, calc(100% - 32px));
    max-width: none;
    max-height: calc(100dvh - 32px);
    margin: auto;
    padding: 0;
    overflow: visible;
    border: 0;
    color: var(--text);
    background: transparent;
}

.proxy-dialog::backdrop {
    background: rgba(2, 5, 10, 0.76);
    backdrop-filter: blur(8px);
}

.proxy-dialog[open] {
    animation: proxy-dialog-in 180ms ease both;
}

.proxy-dialog-card {
    display: grid;
    max-height: calc(100dvh - 32px);
    padding: clamp(22px, 4vw, 30px);
    overflow-y: auto;
    border: 1px solid var(--line-strong);
    border-radius: 22px;
    background:
        radial-gradient(circle at 100% 0, rgba(154, 140, 255, 0.12), transparent 18rem),
        #101622;
    box-shadow: 0 32px 100px rgba(0, 0, 0, 0.62);
    gap: 18px;
}

.proxy-dialog-head {
    display: flex;
    align-items: center;
    gap: 13px;
}

.proxy-dialog-head h2 {
    margin: 0;
    font-size: 22px;
    letter-spacing: -0.025em;
}

.proxy-dialog-icon {
    display: grid;
    width: 46px;
    height: 46px;
    border: 1px solid rgba(108, 229, 189, 0.24);
    border-radius: 13px;
    color: var(--accent);
    background: rgba(108, 229, 189, 0.07);
    place-items: center;
    flex: 0 0 auto;
}

.proxy-dialog-description {
    margin: -3px 0 0;
    color: var(--muted-strong);
    font-size: 13px;
}

.proxy-dialog-toggle {
    background: rgba(108, 229, 189, 0.035);
}

.proxy-form-error {
    margin-top: -3px;
}

.proxy-dialog-actions {
    display: flex;
    padding-top: 2px;
    justify-content: flex-end;
    gap: 10px;
}

.proxy-dialog-actions .secondary-button,
.proxy-save-button {
    min-height: 44px;
    margin-top: 0;
    padding: 0 18px;
}

.proxy-save-button {
    min-width: 126px;
}

.proxy-save-button[aria-busy="true"] .button-spinner {
    display: block;
}

.proxy-save-button[aria-busy="true"] > span:first-child {
    opacity: 0.72;
}

.toast {
    display: flex;
    padding: 12px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 13px;
    color: var(--muted-strong);
    background: rgba(20, 27, 40, 0.96);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(14px);
    align-items: center;
    gap: 10px;
    animation: toast-in 220ms ease both;
}

.toast::before {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    content: "";
    flex: 0 0 auto;
}

.toast.is-error::before {
    background: var(--danger);
}

.noscript-banner {
    position: fixed;
    z-index: 200;
    right: 16px;
    bottom: 16px;
    left: 16px;
    padding: 12px 16px;
    border: 1px solid rgba(255, 107, 122, 0.35);
    border-radius: 12px;
    color: #ffd5da;
    background: #34161d;
    text-align: center;
}

/* Login */
.login-page {
    display: grid;
    min-height: 100vh;
    padding: clamp(22px, 5vw, 64px);
    overflow-x: hidden;
    place-items: center;
}

.login-page::before,
.login-page::after {
    position: fixed;
    z-index: -1;
    width: 460px;
    height: 460px;
    border-radius: 50%;
    content: "";
    filter: blur(110px);
    opacity: 0.14;
}

.login-page::before {
    top: -170px;
    right: -100px;
    background: var(--violet);
}

.login-page::after {
    bottom: -220px;
    left: -100px;
    background: var(--accent-strong);
}

.login-layout {
    display: grid;
    width: min(1100px, 100%);
    min-height: 620px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 30px;
    background: rgba(13, 18, 28, 0.88);
    box-shadow: 0 36px 100px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(20px);
    grid-template-columns: minmax(0, 1.16fr) minmax(390px, 0.84fr);
}

.login-intro {
    position: relative;
    display: flex;
    min-width: 0;
    padding: clamp(34px, 6vw, 72px);
    background:
        linear-gradient(140deg, rgba(108, 229, 189, 0.075), transparent 45%),
        radial-gradient(circle at 80% 85%, rgba(154, 140, 255, 0.13), transparent 55%);
    flex-direction: column;
    justify-content: space-between;
}

.login-intro::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 44%;
    opacity: 0.3;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 38px 38px;
    content: "";
    mask-image: linear-gradient(to top, black, transparent);
    pointer-events: none;
}

.intro-copy {
    position: relative;
    z-index: 1;
    max-width: 560px;
    margin: 72px 0 54px;
}

.intro-copy h1 {
    max-width: 650px;
    margin: 12px 0 18px;
    font-size: clamp(39px, 5vw, 68px);
    line-height: 0.98;
    letter-spacing: -0.055em;
}

.intro-copy > p:last-child {
    max-width: 520px;
    margin: 0;
    color: var(--muted-strong);
    font-size: clamp(15px, 1.6vw, 18px);
}

.feature-row {
    position: relative;
    z-index: 1;
    display: flex;
    color: var(--muted-strong);
    font-size: 12px;
    flex-wrap: wrap;
    gap: 16px;
}

.feature-row span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.feature-row svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.login-card {
    display: flex;
    padding: clamp(30px, 4.5vw, 58px);
    border-left: 1px solid var(--line);
    background: rgba(8, 11, 18, 0.5);
    flex-direction: column;
    justify-content: center;
}

.login-card-head {
    margin-bottom: 27px;
}

.secure-badge {
    display: inline-flex;
    height: 28px;
    padding: 0 10px;
    border: 1px solid rgba(108, 229, 189, 0.22);
    border-radius: 99px;
    color: var(--accent);
    background: rgba(108, 229, 189, 0.06);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.07em;
    align-items: center;
    gap: 6px;
}

.login-card-head h2 {
    margin: 20px 0 6px;
    font-size: 28px;
    letter-spacing: -0.025em;
}

.login-card-head p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.login-form {
    display: grid;
    gap: 18px;
}

.field {
    display: grid;
    gap: 7px;
}

.field > span:first-child {
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 700;
}

.input-shell {
    position: relative;
    display: flex;
    min-height: 50px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 13px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.035);
    align-items: center;
    gap: 10px;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.input-shell:focus-within {
    border-color: rgba(108, 229, 189, 0.56);
    background: rgba(255, 255, 255, 0.052);
    box-shadow: 0 0 0 4px rgba(108, 229, 189, 0.075);
}

.input-shell input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
}

.input-shell input::placeholder {
    color: #646e7c;
}

.input-shell input:-webkit-autofill,
.input-shell input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    box-shadow: 0 0 0 1000px #121925 inset;
}

.password-toggle {
    display: grid;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    color: var(--muted);
    background: transparent;
    place-items: center;
    flex: 0 0 auto;
}

.password-toggle:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.password-toggle .eye-closed,
.password-toggle[aria-pressed="true"] .eye-open {
    display: none;
}

.password-toggle[aria-pressed="true"] .eye-closed {
    display: block;
}

.form-error {
    display: flex;
    padding: 11px 12px;
    border: 1px solid rgba(255, 107, 122, 0.24);
    border-radius: 11px;
    color: #ffc7ce;
    background: rgba(255, 107, 122, 0.075);
    font-size: 12px;
    align-items: flex-start;
    gap: 9px;
}

.form-error svg {
    margin-top: 1px;
    flex: 0 0 auto;
}

.primary-button {
    position: relative;
    min-height: 52px;
    margin-top: 2px;
    padding: 0 18px;
    border-radius: 13px;
    color: #06130f;
    background: linear-gradient(115deg, var(--accent), #84efd0);
    box-shadow: 0 14px 34px rgba(43, 212, 156, 0.16);
    font-size: 14px;
    font-weight: 850;
    gap: 9px;
    transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.primary-button:hover:not(:disabled) {
    box-shadow: 0 18px 42px rgba(43, 212, 156, 0.24);
    filter: brightness(1.04);
    transform: translateY(-1px);
}

.primary-button:active:not(:disabled) {
    transform: translateY(0);
}

.button-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(4, 26, 18, 0.2);
    border-top-color: #06130f;
}

.primary-button[aria-busy="true"] .button-spinner {
    display: block;
}

.primary-button[aria-busy="true"] > svg {
    display: none;
}

.privacy-note {
    display: flex;
    margin: 18px 0 0;
    color: #798494;
    font-size: 11px;
    line-height: 1.45;
    align-items: flex-start;
    gap: 8px;
}

.privacy-note svg {
    margin-top: 1px;
    color: var(--accent);
    flex: 0 0 auto;
}

.login-footer {
    position: fixed;
    right: 0;
    bottom: 15px;
    left: 0;
    display: flex;
    color: #667080;
    font-size: 10px;
    justify-content: center;
    gap: 9px;
}

@keyframes shimmer {
    from { opacity: 0.45; }
    to { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 0.68; transform: scale(0.92); }
    50% { opacity: 1; transform: scale(1.08); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes proxy-dialog-in {
    from { opacity: 0; transform: translateY(8px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1080px) {
    .topbar {
        grid-template-columns: auto minmax(220px, 1fr) auto;
        gap: 20px;
    }

    .connection-state span:last-child,
    .logout-button span {
        display: none;
    }

    .logout-button {
        width: 42px;
        padding: 0;
    }

    .workspace {
        grid-template-columns: minmax(270px, 320px) minmax(0, 1fr);
        gap: 20px;
    }

    .schedule-list {
        grid-template-columns: 1fr;
    }

    .schedule-item + .schedule-item {
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .login-layout {
        grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr);
    }
}

@media (max-width: 820px) {
    :root {
        --topbar-height: 126px;
    }

    .topbar {
        position: relative;
        padding: 13px 18px;
        grid-template-columns: 1fr auto;
        gap: 12px;
    }

    .topbar-search {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .workspace {
        padding: 18px;
        grid-template-columns: 1fr;
    }

    .browse-panel {
        position: static;
        max-height: none;
        min-height: 0;
        order: 2;
    }

    .watch-panel {
        order: 1;
    }

    .channel-grid {
        max-height: 450px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .login-page {
        display: block;
        padding: 18px 18px 56px;
    }

    .login-layout {
        min-height: 0;
        border-radius: 24px;
        grid-template-columns: 1fr;
    }

    .login-intro {
        min-height: 380px;
        padding: 32px;
    }

    .intro-copy {
        margin: 55px 0 38px;
    }

    .intro-copy h1 {
        font-size: clamp(38px, 11vw, 60px);
    }

    .login-card {
        padding: 34px 32px;
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .login-footer {
        position: static;
        margin-top: 22px;
        flex-wrap: wrap;
    }
}

@media (max-width: 560px) {
    .topbar-actions {
        gap: 8px;
    }

    .connection-state {
        width: 26px;
        justify-content: center;
    }

    .proxy-button {
        width: 42px;
        padding: 0;
    }

    .proxy-button [data-proxy-label] {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .search-box kbd {
        display: none;
    }

    .workspace {
        padding: 12px;
        gap: 12px;
    }

    .player-card,
    .schedule-card,
    .browse-panel {
        border-radius: 18px;
    }

    .player-heading {
        min-height: 68px;
        padding: 11px 13px;
    }

    .selected-channel-logo {
        width: 42px;
        height: 42px;
    }

    .player-heading h2,
    .schedule-heading h2 {
        font-size: 18px;
    }

    .player-placeholder,
    .player-loading,
    .player-error {
        padding: 15px;
    }

    .broadcast-glyph {
        width: 58px;
        height: 58px;
    }

    .broadcast-glyph svg {
        width: 44px;
        height: 44px;
    }

    .quality-control {
        top: 7px;
        right: 7px;
        min-height: 32px;
        padding: 3px;
        gap: 4px;
    }

    .quality-control-label {
        display: none;
    }

    .quality-active {
        min-width: 42px;
        padding-inline: 5px;
    }

    .quality-control select {
        min-width: 76px;
        height: 26px;
        padding-left: 7px;
    }

    .now-strip {
        min-height: 70px;
        padding: 11px 13px;
        grid-template-columns: 18px minmax(0, 1fr);
    }

    .now-summary {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .now-summary > span:last-child {
        grid-column: 2;
    }

    .program-progress {
        display: none;
    }

    .playback-debug summary {
        padding-inline: 13px;
    }

    .debug-values {
        padding: 0 13px 13px;
    }

    .debug-values > div {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .schedule-card {
        padding: 15px;
    }

    .quiet-button span {
        display: none;
    }

    .schedule-item {
        min-height: 108px;
        padding: 14px;
        grid-template-columns: 48px minmax(0, 1fr);
        gap: 10px;
    }

    .channel-grid {
        max-height: 500px;
        grid-template-columns: 1fr;
    }

    .login-intro,
    .login-card {
        padding: 27px 22px;
    }

    .login-intro {
        min-height: 340px;
    }

    .intro-copy {
        margin: 45px 0 30px;
    }

    .feature-row {
        gap: 9px 14px;
    }

    .login-footer span:nth-child(2) {
        display: none;
    }

    .proxy-host-port-grid {
        grid-template-columns: minmax(0, 1fr) 88px;
    }

    .proxy-credentials-grid {
        grid-template-columns: 1fr;
    }

    .proxy-scheme-compact {
        max-width: 100%;
    }

    .proxy-parts .field > span:first-child {
        white-space: normal;
    }

    .proxy-url-details-body {
        padding-left: 10px;
    }

    .proxy-dialog {
        width: calc(100% - 20px);
        max-height: calc(100dvh - 20px);
    }

    .proxy-dialog-card {
        max-height: calc(100dvh - 20px);
        padding: 20px 17px;
        border-radius: 18px;
    }

    .proxy-dialog-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .proxy-dialog-actions .secondary-button,
    .proxy-save-button {
        width: 100%;
        padding: 0 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (forced-colors: active) {
    .status-dot,
    .live-pill span,
    .program-live-mark span {
        forced-color-adjust: none;
    }

    .channel-card.is-active,
    .category-chip[aria-pressed="true"] {
        outline: 2px solid Highlight;
    }

    .toggle-row > input:checked + .toggle-control span {
        background: Highlight;
        forced-color-adjust: none;
    }
}
