:root {
    --bg-base: #050505;
    --bg-surface: #0a0a0a;
    --bg-soft: rgba(255, 255, 255, 0.04);
    --accent: #d91627;
    --accent-hover: #f01e31;
    --text-muted: rgba(255, 255, 255, 0.55);
    --border: rgba(255, 255, 255, 0.08);
    --radius: 4px;
}

* {
    box-sizing: border-box;
}

html {
    background-color: var(--bg-base);
    color-scheme: dark;
}

body {
    margin: 0;
    font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--bg-base);
    color: #fff;
}

h1, h2, h3, .font-heading {
    font-family: "Outfit", sans-serif;
}

.app-shell {
    min-height: 100vh;
}

.upload-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.upload-screen::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("https://images.pexels.com/photos/9966703/pexels-photo-9966703.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
    background-size: cover;
    background-position: center;
    opacity: 0.6;
}

.upload-screen::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.86);
}

.upload-card-wrap {
    width: 100%;
    max-width: 700px;
    position: relative;
    z-index: 1;
}

.brand-top {
    text-align: center;
    margin-bottom: 32px;
}

.brand-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo .site-logo {
    width: 56px;
    height: 56px;
}

.site-logo {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: contain;
    flex-shrink: 0;
    display: block;
}

.brand-title {
    margin: 0;
    font-size: 3rem;
    font-weight: 300;
    letter-spacing: -0.03em;
}

.brand-title span {
    font-weight: 700;
}

.brand-subtitle {
    margin: 12px auto 0;
    color: var(--text-muted);
    max-width: 560px;
}

.upload-card {
    background: rgba(0, 0, 0, 0.58);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(16px);
    padding: 24px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 11px 10px;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.dropzone {
    border: 2px dashed rgba(255, 255, 255, 0.16);
    border-radius: 4px;
    padding: 42px 24px;
    text-align: center;
    cursor: pointer;
    transition: all .2s ease;
}

.dropzone.active {
    border-color: var(--accent);
    background: rgba(217, 22, 39, 0.08);
}

.dropzone p {
    margin: 8px 0 0;
    color: rgba(255, 255, 255, 0.72);
}

.input {
    width: 100%;
    height: 44px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.4);
    color: white;
    padding: 0 12px;
}

.btn {
    border: none;
    border-radius: 4px;
    height: 44px;
    padding: 0 16px;
    font-weight: 600;
    cursor: pointer;
}

.btn-accent {
    width: 100%;
    margin-top: 10px;
    background: var(--accent);
    color: #fff;
}

.btn-accent:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    width: 100%;
    margin-top: 18px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.separator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0 4px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .2em;
    color: rgba(255, 255, 255, 0.3);
}

.separator::before, .separator::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.62);
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, .2);
    border-top-color: var(--accent);
    animation: spin 1s linear infinite;
}

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

.player-layout {
    min-height: 100vh;
    background: var(--bg-base);
}

.sidebar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    font-family: "Outfit", sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
}

.sidebar-sub {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.45);
    margin: 4px 0;
}

.main-content {
    padding: 24px 26px;
    max-width: 1380px;
    margin: 0 auto;
}

.top-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.back-to-list-btn {
    font-size: 18px;
}

.video-wrap {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    background: #000;
    position: relative;
    aspect-ratio: 16 / 9;
}

.video-el {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.kaltura-player-host {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #000;
}

.kaltura-player-host .playkit-player {
    width: 100% !important;
    height: 100% !important;
    padding-top: 0 !important;
}

.kaltura-player-host .playkit-player video {
    object-fit: contain;
}

.video-state {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.75);
}

.video-state.visible {
    display: flex;
}

.player-controls {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 18px;
    background: rgba(12, 12, 12, 0.72);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
    z-index: 2;
}

.controls-spacer {
    flex: 1;
}

.video-wrap.kaltura-mode .player-controls,
.player-controls[hidden] {
    display: none !important;
}

.control-btn {
    border: none;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
}

.modern-icon-btn {
    width: 46px;
    height: 46px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    transition: transform .16s ease, background .16s ease, border-color .16s ease;
}

.modern-icon-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.28);
    transform: translateY(-1px);
}

.player-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: #000;
    padding: calc(10px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
    display: flex;
    flex-direction: column;
    gap: 10px;
}

html.player-open,
body.player-open,
html.playback-fullscreen,
body.playback-fullscreen {
    background-color: #000;
}

html.player-open::before,
html.playback-fullscreen::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: max(env(safe-area-inset-top), 8px);
    background: #000;
    z-index: 2147483646;
    pointer-events: none;
}

body.player-open .player-overlay,
body.playback-fullscreen .player-overlay {
    padding: 0;
    background: #000;
}

.video-wrap:fullscreen,
.video-wrap:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    aspect-ratio: auto;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: #000;
}

.video-wrap:fullscreen::backdrop,
.video-wrap:-webkit-full-screen::backdrop {
    background: #000;
}

.player-overlay:fullscreen,
.player-overlay:-webkit-full-screen {
    padding: 0;
    background: #000;
}

.player-overlay:fullscreen .player-overlay-links,
.player-overlay:-webkit-full-screen .player-overlay-links {
    display: none;
}

.video-wrap:fullscreen .player-overlay-top,
.video-wrap:-webkit-full-screen .player-overlay-top {
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
}

.video-wrap:fullscreen .player-controls,
.video-wrap:-webkit-full-screen .player-controls {
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
}

.video-wrap:fullscreen .video-el,
.video-wrap:-webkit-full-screen .video-el {
    object-fit: contain;
}

.player-channel-title {
    flex: 1;
    font-family: "Outfit", sans-serif;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-overlay .video-wrap {
    flex: 1;
    aspect-ratio: auto;
    min-height: 0;
    border-radius: 14px;
}

.player-overlay-links {
    display: flex;
    justify-content: center;
}

.modern-controls {
    backdrop-filter: blur(8px);
    pointer-events: auto;
}

.player-chrome {
    position: absolute;
    inset: 0;
    z-index: 4;
    opacity: 0;
    transition: opacity .2s ease;
    pointer-events: none;
}

.player-chrome.visible {
    opacity: 1;
}

.player-overlay-top {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 18px;
    background: rgba(12, 12, 12, 0.58);
    backdrop-filter: blur(14px);
}

.player-mini-list {
    position: absolute;
    top: 78px;
    right: 16px;
    width: min(320px, 85vw);
    max-height: 55vh;
    overflow: auto;
    padding: 8px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(6, 6, 6, 0.9);
    backdrop-filter: blur(10px);
    display: none;
    pointer-events: auto;
}

.player-mini-list.open {
    display: block;
}

.mini-channel-item {
    width: 100%;
    text-align: left;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #fff;
    padding: 8px 10px;
    cursor: pointer;
}

.mini-channel-item:hover,
.mini-channel-item.active {
    background: rgba(217, 22, 39, 0.18);
    border-color: rgba(217, 22, 39, 0.45);
}

.volume-slider {
    width: 120px;
    accent-color: var(--accent);
    cursor: pointer;
}

.volume-value {
    min-width: 42px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    text-align: right;
}

.playing-now {
    margin: 16px 0 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.playing-now img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    background: rgba(0, 0, 0, .5);
    border-radius: 4px;
    padding: 3px;
}

.label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .2em;
    color: rgba(255, 255, 255, 0.4);
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 20px 0 12px;
}

.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
}

.load-more-wrap {
    display: flex;
    justify-content: center;
    margin: 20px 0 28px;
}

.load-more-btn {
    min-width: 220px;
}

.official-link {
    display: inline-block;
    margin-top: 14px;
    padding: 10px 16px;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.official-link:hover {
    opacity: 0.9;
}

.official-link-inline {
    margin-top: 10px;
    font-size: 13px;
    padding: 8px 12px;
}

.channel-card {
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: var(--bg-surface);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
}

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

.channel-thumb {
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .4);
    position: relative;
    padding: 10px;
}

.channel-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.fav-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    cursor: pointer;
}

.fav-btn.active {
    color: var(--accent);
}

.channel-meta {
    padding: 10px;
}

.channel-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-group {
    margin-top: 3px;
    font-size: 12px;
    color: rgba(255, 255, 255, .45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toast-wrap {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-left: 4px solid var(--accent);
    padding: 10px 14px;
    border-radius: 4px;
}

@media (max-width: 1024px) {
    .main-content {
        padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
        max-width: 100%;
    }

    .top-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .volume-slider,
    .volume-value {
        display: none;
    }

    .modern-controls {
        justify-content: flex-start;
        gap: 8px;
        padding: 10px;
    }

    .modern-icon-btn {
        width: 40px;
        height: 40px;
    }

    .player-overlay-top {
        top: calc(10px + env(safe-area-inset-top));
        left: 10px;
        right: 10px;
    }

    .player-controls {
        left: 10px;
        right: 10px;
        bottom: calc(10px + env(safe-area-inset-bottom));
    }

    .controls-spacer {
        flex: 1;
        min-width: 12px;
    }
}

@media (max-width: 720px) {
    .player-overlay .video-wrap {
        border-radius: 10px;
    }

    .channel-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
    }

    .channel-thumb {
        aspect-ratio: 16 / 8;
        padding: 6px;
    }

    .channel-meta {
        padding: 8px;
    }

    .channel-name {
        font-size: 13px;
    }

    .channel-group {
        font-size: 11px;
    }
}
