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

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;

    background: #111;
    color: #e0e0e0;
    font-family: sans-serif;
}

button,
input {
    font: inherit;
}


/* =====================================================
   Main music browser
   ===================================================== */

.music-browser {
    display: flex;
    flex-direction: column;

    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;

    padding: 10px;
    overflow: hidden;

    background: #111;
    color: #e0e0e0;
}

.music-browser-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 8px;
    color: #fff;
}

#musicBrowserTitle {
    margin: 0;
    color: #fff;
}

#musicBrowserClose {
    width: 30px;
    height: 28px;
    padding: 0;

    border: 1px solid #555;
    border-radius: 4px;

    background: #222;
    color: #fff;

    cursor: pointer;
    font-size: 18px;
}

#musicBrowserClose:hover {
    background: #333;
}


/* =====================================================
   Tabs
   ===================================================== */

.tabs {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;

    gap: 6px;
    margin-bottom: 8px;
}

.tabs button {
    padding: 7px 10px;

    border: 1px solid #444;
    border-radius: 4px;

    background: #333;
    color: #ccc;

    cursor: pointer;
}

.tabs button:hover {
    background: #444;
}

.tabs button.active {
    border-color: #4a90e2;
    background: #4a90e2;
    color: #fff;
}


/* =====================================================
   Breadcrumb, search and status
   ===================================================== */

.music-breadcrumb {
    flex: 0 0 auto;

    min-height: 24px;
    margin-bottom: 8px;

    color: #ccc;
    font-size: 14px;
}

.music-breadcrumb .back,
.music-breadcrumb .crumb {
    color: #7ab7ff;
    cursor: pointer;
}

.music-search {
    flex: 0 0 auto;

    width: 100%;
    margin-bottom: 8px;
    padding: 8px;

    border: 1px solid #555;

    background: #222;
    color: #fff;
}

.music-search:focus {
    border-color: #4a90e2;
    outline: none;
}

.music-status {
    flex: 0 0 auto;

    min-height: 20px;
    margin-bottom: 8px;

    color: #aaa;
    font-size: 13px;
}


/* =====================================================
   Three-column layout
   ===================================================== */

.music-browser-layout {
    display: grid;

    grid-template-columns:
        minmax(190px, 230px)
        minmax(0, 1fr)
        minmax(210px, 250px);

    flex: 1 1 0;

    width: 100%;
    height: 0;

    min-width: 0;
    min-height: 0;

    overflow: hidden;

    border-top:
        1px solid rgba(255, 255, 255, 0.06);

    background: #313338;
}


/* =====================================================
   Centre browser column
   ===================================================== */

.browser-main-column {
    display: flex;
    flex-direction: column;

    width: 100%;

    min-width: 0;
    min-height: 0;

    overflow: hidden;
    background: #313338;
}


/* Rows are inserted directly into #list by JavaScript. */
#list {
    display: grid;

    grid-template-columns:
        repeat(
            auto-fill,
            minmax(135px, 1fr)
        );

    grid-auto-rows: max-content;

    align-content: start;
    align-items: start;

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    margin: 0;
    padding: 12px;

    overflow-x: hidden;
    overflow-y: auto;

    gap: 12px;
}


/* =====================================================
   Artist, album, song and Invidious cards
   ===================================================== */

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

    width: 100%;
    height: auto;

    min-width: 0;
    min-height: 0;

    padding: 8px;
    overflow: visible;

    border: 1px solid #333;
    border-radius: 8px;

    background: #181818;
    color: #ddd;

    cursor: default;
}

.row:hover {
    border-color: #555;
    background: #202020;
}

.row.clickable {
    cursor: pointer;
}

.row.clickable:hover {
    border-color: #666;
    background: #252525;
}

.thumb {
    display: block;

    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;

    max-width: none;
    max-height: none;

    margin: 0 0 7px;

    object-fit: cover;

    border-radius: 6px;
    background: #222;
}

.info {
    flex: 0 0 auto;
    min-width: 0;
}

.title {
    display: -webkit-box;

    min-width: 0;
    overflow: hidden;

    color: #fff;

    font-size: 13px;
    line-height: 1.2;
    text-align: left;

    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.meta {
    display: -webkit-box;

    min-width: 0;
    margin-top: 4px;
    overflow: hidden;

    color: #aaa;

    font-size: 11px;
    line-height: 1.2;
    text-align: left;

    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}


/* Two-column action grid works for:
   Jellyfin: Play + Queue
   Invidious: Audio + Audio Queue + Video + Video Queue
*/
.action {
    display: grid !important;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    width: 100%;

    gap: 5px;
    margin-top: 8px;
    padding-top: 0;
}

.send-btn {
    display: block !important;

    width: 100%;
    min-width: 0;

    padding: 6px 3px;

    border: 1px solid #3b82f6;
    border-radius: 4px;

    background: #2b6cb0;
    color: #fff;

    cursor: pointer;

    overflow: hidden;

    font-size: 11px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.send-btn:hover:not(:disabled) {
    background: #3479c5;
}

.send-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.queue-btn {
    border-color: #686b74;
    background: #4e5058;
    color: #dbdee1;
}

.queue-btn:hover:not(:disabled) {
    background: #686b74;
}

.empty {
    grid-column: 1 / -1;

    width: 100%;
    padding: 36px 12px;

    color: #aaa;
    text-align: center;
}


/* =====================================================
   History and queue panels
   ===================================================== */

.media-side-panel {
    display: flex;
    flex-direction: column;

    width: 100%;

    min-width: 0;
    min-height: 0;

    overflow: hidden;

    background: #2b2d31;
}

.history-panel {
    border-right:
        1px solid rgba(0, 0, 0, 0.3);
}

.queue-panel {
    border-left:
        1px solid rgba(0, 0, 0, 0.3);
}

.side-panel-header {
    display: flex;
    flex: 0 0 auto;

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

    min-height: 46px;
    padding: 0 10px 0 13px;

    border-bottom:
        1px solid rgba(0, 0, 0, 0.3);

    background: #232428;
}

.side-panel-title {
    color: #f2f3f5;
    font-size: 13px;
    font-weight: 700;
}

.side-panel-count {
    display: inline-grid;
    place-items: center;

    min-width: 21px;
    height: 21px;

    margin-left: 5px;
    padding: 0 6px;

    border-radius: 20px;

    background: #1e1f22;
    color: #b5bac1;

    font-size: 11px;
    font-weight: 700;
}

.side-panel-clear {
    padding: 5px 8px;

    border: 0;
    border-radius: 4px;

    background: transparent;
    color: #b5bac1;

    cursor: pointer;
    font-size: 11px;
}

.side-panel-clear:hover {
    background: #3f4147;
    color: #f2f3f5;
}

.side-panel-list {
    flex: 1 1 auto;

    min-width: 0;
    min-height: 0;

    padding: 8px;

    overflow-x: hidden;
    overflow-y: auto;
}

.side-panel-empty {
    padding: 24px 10px;

    color: #949ba4;

    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}


/* =====================================================
   Queue controls
   ===================================================== */

.queue-play-next {
    flex: 0 0 auto;

    margin: 9px 9px 2px;
    padding: 9px 10px;

    border: 0;
    border-radius: 5px;

    background: #5865f2;
    color: #fff;

    cursor: pointer;

    font-size: 12px;
    font-weight: 700;
}

.queue-play-next:hover:not(:disabled) {
    background: #4752c4;
}

.queue-play-next:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}


/* =====================================================
   History and queue entries
   ===================================================== */

.side-media-item {
    display: grid;

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

    align-items: center;
    gap: 8px;

    margin-bottom: 7px;
    padding: 7px;

    overflow: hidden;

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

    background: #232428;
}

.side-media-item:hover {
    border-color:
        rgba(255, 255, 255, 0.06);

    background: #35373c;
}

.queue-item {
    grid-template-columns:
        18px
        38px
        minmax(0, 1fr);
}

.queue-position {
    color: #949ba4;

    font-family: monospace;
    font-size: 11px;
    text-align: center;
}

.side-media-thumb {
    width: 42px;
    height: 42px;

    object-fit: cover;

    border-radius: 5px;
    background: #1e1f22;
}

.queue-item .side-media-thumb {
    width: 38px;
    height: 38px;
}

.side-media-info {
    min-width: 0;
}

.side-media-title {
    overflow: hidden;

    color: #f2f3f5;

    font-size: 11px;
    font-weight: 650;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.side-media-meta {
    margin-top: 3px;
    overflow: hidden;

    color: #949ba4;

    font-size: 9px;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.side-media-actions {
    display: flex;

    grid-column: 1 / -1;

    justify-content: flex-end;

    gap: 4px;
    margin-top: 3px;
}

.queue-actions {
    grid-column: 2 / -1;
}

.side-action-button {
    display: grid;
    place-items: center;

    min-width: 26px;
    height: 25px;

    padding: 0 6px;

    border: 0;
    border-radius: 4px;

    background: #1e1f22;
    color: #b5bac1;

    cursor: pointer;
    font-size: 12px;
}

.side-action-button:hover:not(:disabled) {
    background: #5865f2;
    color: #fff;
}

.side-action-button:disabled {
    cursor: not-allowed;
    opacity: 0.25;
}


/* =====================================================
   Responsive layout
   ===================================================== */

@media (max-width: 1000px) {
    .music-browser-layout {
        grid-template-columns:
            180px
            minmax(0, 1fr)
            210px;
    }

    #list {
        grid-template-columns:
            repeat(
                auto-fill,
                minmax(125px, 1fr)
            );
    }
}

@media (max-width: 780px) {
    .music-browser-layout {
        grid-template-columns:
            minmax(0, 1fr)
            210px;
    }

    .history-panel {
        display: none;
    }
}

@media (max-width: 600px) {
    .music-browser {
        overflow-y: auto;
    }

    .music-browser-layout {
        display: flex;
        flex-direction: column;

        flex: 0 0 auto;
        height: auto;

        overflow: visible;
    }

    .browser-main-column {
        flex: 0 0 65vh;
    }

    .queue-panel {
        flex: 0 0 300px;

        border-top:
            1px solid rgba(0, 0, 0, 0.3);

        border-left: 0;
    }

    #list {
        grid-template-columns:
            repeat(
                auto-fill,
                minmax(120px, 1fr)
            );
    }
}
