* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Segoe UI, Tahoma, sans-serif;
    background: linear-gradient(130deg, #0a1322 0%, #13243a 50%, #0a101a 100%);
    color: #f4f8ff;
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
    gap: 16px;
    height: 100vh;
    padding: 14px;
}

.topbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    padding: 12px 14px;
}

.topbar h1 {
    margin: 0 0 0 auto;
    font-size: 1.35rem;
    letter-spacing: 0.03em;
}

.navlink {
    text-decoration: none;
    color: #fff;
    background: rgba(255, 255, 255, 0.13);
    border-radius: 8px;
    padding: 10px 14px;
}

.player-zone,
.panel-zone {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    padding: 12px;
    min-height: 0;
}

#iptv-video {
    width: 100%;
    height: calc(100% - 112px);
    min-height: 320px;
    background: #000;
    border-radius: 10px;
}

.player-actions {
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1.35fr repeat(6, minmax(0, 1fr)) 1.25fr 1fr;
    gap: 8px;
}

.player-actions button {
    border: 0;
    border-radius: 10px;
    padding: 12px;
    background: #1d7df2;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.seek-step-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

#seek-back-10-btn {
    background: #c0392b;
}

#seek-forward-10-btn {
    background: #1f9d55;
}

#seek-minute-input {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(5, 15, 28, 0.75);
    color: #fff;
    padding: 12px;
    font-size: 0.95rem;
}

#quality-select {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(5, 15, 28, 0.75);
    color: #fff;
    padding: 10px;
    font-size: 0.95rem;
}

#seek-minute-btn {
    background: #0f9f7a;
}

#iptv-jsmpeg-canvas {
    width: 100%;
    height: calc(100% - 112px);
    min-height: 320px;
    background: #000;
    border-radius: 10px;
    display: none;
}

body.jsmpeg-mode #iptv-video {
    display: none;
}

body.jsmpeg-mode #iptv-jsmpeg-canvas {
    display: block;
}

body.jsmpeg-mode .seek-step-controls,
body.jsmpeg-mode #seek-minute-input,
body.jsmpeg-mode #seek-minute-btn {
    display: none;
}

@media (max-width: 1080px) {
    .player-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

}

#playback-status {
    margin: 10px 2px 0;
    color: #b7d6ff;
    font-size: 0.92rem;
}

.filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

#source-select,
#group-select,
#search-input,
.combo-trigger {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(5, 15, 28, 0.75);
    color: #fff;
    padding: 11px 12px;
    font-size: 1rem;
}

.combo-trigger {
    text-align: left;
    cursor: pointer;
    position: relative;
}

.combo-trigger::after {
    content: '▾';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9dd2ff;
}

.native-select-hidden {
    display: none;
}

.channels {
    overflow: auto;
    height: calc(100% - 94px);
    padding-right: 2px;
}

.channel-item {
    display: grid;
    grid-template-columns: 46px 1fr;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
}

.channel-item img {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    object-fit: cover;
    background: #0d2038;
}

.channel-item strong {
    display: block;
    line-height: 1.2;
}

.channel-item small {
    color: #8ec0ff;
}

.channel-item:hover {
    border-color: rgba(106, 198, 255, 0.9);
    transform: translateY(-1px);
}

.tesla-select-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: flex-end;
    justify-content: center;
    background: rgba(3, 8, 15, 0.66);
    z-index: 9999;
    padding: 14px;
}

.tesla-select-modal.open {
    display: flex;
}

.tesla-select-sheet {
    width: min(760px, 100%);
    max-height: 82vh;
    border-radius: 16px;
    background: linear-gradient(160deg, rgba(9, 20, 35, 0.98) 0%, rgba(12, 30, 49, 0.98) 100%);
    border: 1px solid rgba(149, 205, 255, 0.35);
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.42);
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
}

.tesla-select-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tesla-select-title {
    margin: 0;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
}

.tesla-select-close {
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    padding: 10px 14px;
    font-weight: 600;
}

.tesla-select-search {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 12px;
    background: rgba(5, 14, 26, 0.9);
    color: #fff;
    padding: 12px;
    font-size: 1rem;
}

.tesla-select-index {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tesla-select-index-btn {
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #e6f2ff;
    padding: 7px 10px;
    min-width: 36px;
    font-size: 0.86rem;
}

.tesla-select-index-btn.is-active {
    border-color: rgba(106, 198, 255, 0.95);
    background: rgba(34, 119, 177, 0.48);
    color: #ffffff;
}

.tesla-select-list {
    overflow: auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding-right: 2px;
}

.tesla-select-option {
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.06);
    color: #f4f8ff;
    text-align: left;
    padding: 12px;
    font-size: 0.98rem;
}

.tesla-select-option.is-active {
    border-color: rgba(121, 220, 168, 0.85);
    background: rgba(42, 130, 92, 0.36);
}

.tesla-select-empty {
    margin: 4px 2px;
    color: #b7d6ff;
}

@media (max-width: 1080px) {
    .layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .player-zone,
    .panel-zone {
        min-height: 45vh;
    }

    #iptv-video {
        height: 52vh;
    }
}
