:root {
    --bg: #0d1117;
    --bg-light: #161b22;
    --bg-hover: #1c2128;
    --border: #30363d;

    --text: #e6edf3;
    --muted: #8b949e;

    --accent: #58a6ff;
    --accent-hover: #79c0ff;
}


* {
    box-sizing: border-box;
}


html {
    background: var(--bg);
}


body {
    margin: 0;

    background: var(--bg);
    color: var(--text);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
}


/* Header */

.topbar {
    position: sticky;
    top: 0;

    z-index: 50;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 30px;

    padding: 18px 28px;

    background: rgba(13, 17, 23, 0.94);

    backdrop-filter: blur(12px);

    border-bottom: 1px solid var(--border);
}


.brand {
    display: flex;
    align-items: center;

    gap: 13px;

    min-width: 220px;
}


.brand-icon {
    width: 46px;
    height: 46px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 12px;

    background:
        linear-gradient(
            135deg,
            #238636,
            #58a6ff
        );

    color: white;

    font-size: 21px;
    font-weight: bold;

    box-shadow:
        0 5px 20px
        rgba(88, 166, 255, 0.15);
}


.brand h1 {
    margin: 0;

    font-size: 20px;
    line-height: 1.2;
}


.brand span {
    display: block;

    margin-top: 3px;

    color: var(--muted);

    font-size: 12px;
}


/* Search */

.search-wrap {
    position: relative;

    width: min(500px, 50vw);
}


#search {
    width: 100%;

    padding: 12px 42px 12px 16px;

    border: 1px solid var(--border);
    border-radius: 9px;

    background: var(--bg-light);
    color: var(--text);

    outline: none;

    font-size: 15px;
}


#search:focus {
    border-color: var(--accent);

    box-shadow:
        0 0 0 3px
        rgba(88, 166, 255, 0.12);
}


#search::placeholder {
    color: var(--muted);
}


.clear-search {
    position: absolute;

    right: 9px;
    top: 50%;

    transform: translateY(-50%);

    border: 0;

    background: transparent;

    color: var(--muted);

    font-size: 23px;

    cursor: pointer;

    display: none;
}


/* Main */

main {
    width: min(1200px, calc(100% - 32px));

    margin: 0 auto;
}


.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 22px 3px 12px;

    color: var(--muted);

    font-size: 13px;
}


#sortSelect {
    padding: 8px 30px 8px 10px;

    border: 1px solid var(--border);
    border-radius: 7px;

    background: var(--bg-light);
    color: var(--text);

    cursor: pointer;
}


/* Video list */

.library {
    display: flex;
    flex-direction: column;

    gap: 3px;
}


.video-row {
    display: grid;

    grid-template-columns:
        46px minmax(0, 1fr) auto;

    align-items: center;

    gap: 14px;

    padding: 10px 12px;

    border: 1px solid transparent;
    border-radius: 9px;

    cursor: pointer;

    transition:
        background 0.12s,
        border-color 0.12s;
}


.video-row:hover {
    background: var(--bg-hover);

    border-color: var(--border);
}


.video-row.playing {
    background:
        rgba(88, 166, 255, 0.08);

    border-color:
        rgba(88, 166, 255, 0.25);
}


.video-number {
    width: 40px;
    height: 40px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 8px;

    background: var(--bg-light);

    color: var(--muted);

    font-size: 14px;
}


.video-row.playing .video-number {
    background:
        rgba(88, 166, 255, 0.15);

    color: var(--accent);
}


.video-details {
    min-width: 0;
}


.video-title {
    color: var(--text);

    font-size: 15px;
    font-weight: 500;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


.video-filename {
    margin-top: 3px;

    color: var(--muted);

    font-size: 12px;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


.video-actions {
    display: flex;
    align-items: center;
}


.play-video {
    width: 38px;
    height: 38px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 8px;

    background: transparent;

    color: var(--muted);

    font-size: 17px;

    cursor: pointer;
}


.play-video:hover {
    background: var(--bg-light);

    color: var(--text);
}


/* Empty */

.empty {
    text-align: center;

    padding: 80px 20px;

    color: var(--muted);
}


.empty-icon {
    font-size: 50px;

    margin-bottom: 10px;
}


.empty h2 {
    color: var(--text);

    margin: 0 0 5px;
}


.empty p {
    margin: 0;
}


.hidden {
    display: none !important;
}


/* =========================
   VIDEO POPUP
   ========================= */

.video-modal {
    position: fixed;

    inset: 0;

    z-index: 200;

    display: flex;

    align-items: center;
    justify-content: center;

    padding: 30px;
}


.modal-backdrop {
    position: absolute;

    inset: 0;

    background:
        rgba(0, 0, 0, 0.78);

    backdrop-filter: blur(5px);
}


.video-window {
    position: relative;

    z-index: 1;

    width: 50vw;

    max-width: 1000px;

    min-width: 500px;

    background: var(--bg-light);

    border: 1px solid var(--border);

    border-radius: 12px;

    overflow: hidden;

    box-shadow:
        0 25px 80px
        rgba(0, 0, 0, 0.65);
}


/* Popup header */

.video-header {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 15px;

    padding: 13px 15px;

    border-bottom: 1px solid var(--border);
}


.video-info {
    min-width: 0;
}


#modalTitle {
    color: var(--text);

    font-size: 15px;
    font-weight: 600;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


#modalFilename {
    margin-top: 3px;

    color: var(--muted);

    font-size: 11px;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


.close-modal {
    flex: 0 0 auto;

    width: 36px;
    height: 36px;

    border: 0;

    border-radius: 8px;

    background: transparent;

    color: var(--muted);

    font-size: 27px;

    line-height: 1;

    cursor: pointer;
}


.close-modal:hover {
    background: var(--bg-hover);

    color: var(--text);
}


/* Video */

.video-container {
    background: #000;

    width: 100%;

    aspect-ratio: 16 / 9;
}


#video {
    display: block;

    width: 100%;
    height: 100%;

    background: #000;
}


/* Popup controls */

.video-controls {
    display: flex;

    align-items: center;
    justify-content: center;

    gap: 12px;

    padding: 10px;

    border-top: 1px solid var(--border);
}


.video-controls button {
    width: 38px;
    height: 38px;

    border: 0;

    border-radius: 50%;

    background: transparent;

    color: var(--text);

    font-size: 16px;

    cursor: pointer;
}


.video-controls button:hover {
    background: var(--bg-hover);
}


/* Mobile */

@media (max-width: 800px) {

    .topbar {
        flex-direction: column;

        align-items: stretch;

        gap: 14px;

        padding: 14px 16px;
    }


    .brand {
        min-width: 0;
    }


    .search-wrap {
        width: 100%;
    }


    main {
        width: calc(100% - 18px);
    }


    .video-row {
        grid-template-columns:
            40px minmax(0, 1fr) auto;

        gap: 10px;

        padding: 8px 6px;
    }


    .video-number {
        width: 36px;
        height: 36px;
    }


    .video-title {
        font-size: 14px;
    }


    .video-window {
        width: 95vw;

        min-width: 0;

        max-width: none;
    }


    .video-modal {
        padding: 10px;
    }

}
