/* ============================================================
   DESIGN TOKENS
   ============================================================ */

:root {
    color-scheme: dark;

    --bg-main: #0b0b10;
    --bg-secondary: #13131a;
    --bg-elevated: #1b1b24;
    --bg-card: rgba(22, 22, 30, 0.72);
    --bg-bar: rgba(16, 16, 22, 0.92);

    --surface-1: rgba(255, 255, 255, 0.04);
    --surface-2: rgba(255, 255, 255, 0.07);
    --surface-3: rgba(255, 255, 255, 0.12);

    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.17);

    --text-primary: #f4f4f6;
    --text-secondary: #cfcfd6;
    --text-muted: #9a9aa6;
    --text-faint: #6f6f7b;

    --accent: #8b5cf6;
    --accent-strong: #7c3aed;
    --accent-light: #b9a5fc;
    --accent-bg: rgba(139, 92, 246, 0.16);
    --accent-border: rgba(139, 92, 246, 0.42);

    --danger-text: #fca5a5;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --success: #6ee7a0;
    --like: #f472b6;

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-pill: 999px;

    --shadow-card: 0 12px 40px rgba(0, 0, 0, 0.28);
    --shadow-pop: 0 24px 70px rgba(0, 0, 0, 0.55);

    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

    --page-width: 1240px;
    --gutter: 16px;

    /* Phone layout: the tab bar and the small player sit above each other. */
    --nav-height: 58px;
    --mini-height: 64px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* Wide layout: one player bar. */
    --bar-height: 88px;

    /* Icons, as masks (see ICONS below). Shapes after Feather / Lucide. */
    --icon-music: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18V5l12-2v13'/%3E%3Ccircle cx='6' cy='18' r='3'/%3E%3Ccircle cx='18' cy='16' r='3'/%3E%3C/svg%3E");
    --icon-heart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z'/%3E%3C/svg%3E");
    --icon-heart-filled: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z'/%3E%3C/svg%3E");
    --icon-clock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpolyline points='12 6 12 12 16 14'/%3E%3C/svg%3E");
    --icon-list: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='8' y1='6' x2='21' y2='6'/%3E%3Cline x1='8' y1='12' x2='21' y2='12'/%3E%3Cline x1='8' y1='18' x2='21' y2='18'/%3E%3Cline x1='3' y1='6' x2='3.01' y2='6'/%3E%3Cline x1='3' y1='12' x2='3.01' y2='12'/%3E%3Cline x1='3' y1='18' x2='3.01' y2='18'/%3E%3C/svg%3E");
    --icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    --icon-folder: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z'/%3E%3C/svg%3E");
    --icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    --icon-close: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E");
    --icon-refresh: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='23 4 23 10 17 10'/%3E%3Cpolyline points='1 20 1 14 7 14'/%3E%3Cpath d='M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15'/%3E%3C/svg%3E");
    --icon-trash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 6 5 6 21 6'/%3E%3Cpath d='M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6'/%3E%3Cpath d='M10 11v6'/%3E%3Cpath d='M14 11v6'/%3E%3Cpath d='M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2'/%3E%3C/svg%3E");
    --icon-volume: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='11 5 6 9 2 9 2 15 6 15 11 19 11 5'/%3E%3Cpath d='M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07'/%3E%3C/svg%3E");
    --icon-more: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='5' r='1'/%3E%3Ccircle cx='12' cy='12' r='1'/%3E%3Ccircle cx='12' cy='19' r='1'/%3E%3C/svg%3E");
    --icon-bars: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='6' y1='20' x2='6' y2='13'/%3E%3Cline x1='12' y1='20' x2='12' y2='5'/%3E%3Cline x1='18' y1='20' x2='18' y2='10'/%3E%3C/svg%3E");
    --icon-play: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='7 4 20 12 7 20 7 4'/%3E%3C/svg%3E");
    --icon-pause: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='6' y='4' width='3.5' height='16' rx='1'/%3E%3Crect x='14.5' y='4' width='3.5' height='16' rx='1'/%3E%3C/svg%3E");
    --icon-previous: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='19 20 9 12 19 4 19 20'/%3E%3Cline x1='5' y1='19' x2='5' y2='5'/%3E%3C/svg%3E");
    --icon-next: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='5 4 15 12 5 20 5 4'/%3E%3Cline x1='19' y1='5' x2='19' y2='19'/%3E%3C/svg%3E");
    --icon-shuffle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='16 3 21 3 21 8'/%3E%3Cline x1='4' y1='20' x2='21' y2='3'/%3E%3Cpolyline points='21 16 21 21 16 21'/%3E%3Cline x1='15' y1='15' x2='21' y2='21'/%3E%3Cline x1='4' y1='4' x2='9' y2='9'/%3E%3C/svg%3E");
    --icon-repeat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m17 2 4 4-4 4'/%3E%3Cpath d='M3 11v-1a4 4 0 0 1 4-4h14'/%3E%3Cpath d='m7 22-4-4 4-4'/%3E%3Cpath d='M21 13v1a4 4 0 0 1-4 4H3'/%3E%3C/svg%3E");
    --icon-repeat-one: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m17 2 4 4-4 4'/%3E%3Cpath d='M3 11v-1a4 4 0 0 1 4-4h14'/%3E%3Cpath d='m7 22-4-4 4-4'/%3E%3Cpath d='M21 13v1a4 4 0 0 1-4 4H3'/%3E%3Cpath d='M11 10h1v4'/%3E%3C/svg%3E");
}


/* ============================================================
   RESET & BASE
   ============================================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    width: 100%;
    min-height: 100%;
    background: var(--bg-main);
    -webkit-text-size-adjust: 100%;
}

body {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
    font-size: 15px;
    line-height: 1.5;

    color: var(--text-primary);
    background:
        radial-gradient(900px 480px at 10% -10%, rgba(139, 92, 246, 0.16), transparent 60%),
        var(--bg-main);
    background-attachment: fixed;

    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
}

input {
    outline: none;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 2px solid var(--accent-light);
    outline-offset: 2px;
}

::selection {
    background: rgba(139, 92, 246, 0.35);
}

audio {
    display: none;
}

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


/* ============================================================
   ICONS
   Drawn as a mask so they take the colour of the text around them.
   ============================================================ */

.icon,
.player-button::before,
.like-button::before,
.track-action[data-action="menu"]::before,
.library-delete-button::before,
.search-result::after {
    content: "";
    display: block;
    flex: 0 0 auto;
    width: 20px;
    height: 20px;

    background: currentColor;
    -webkit-mask: var(--icon) center / contain no-repeat;
    mask: var(--icon) center / contain no-repeat;
}

.icon-music { --icon: var(--icon-music); }
.icon-heart { --icon: var(--icon-heart); }
.icon-clock { --icon: var(--icon-clock); }
.icon-list { --icon: var(--icon-list); }
.icon-search { --icon: var(--icon-search); }
.icon-folder { --icon: var(--icon-folder); }
.icon-chevron { --icon: var(--icon-chevron); }
.icon-close { --icon: var(--icon-close); }
.icon-refresh { --icon: var(--icon-refresh); }
.icon-volume { --icon: var(--icon-volume); }


/* ============================================================
   LAYOUT
   ============================================================ */

.app {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
}

.main {
    min-width: 0;
}

.main > [role="alert"] {
    margin-bottom: 12px;
    padding: 12px 16px;

    font-size: 13px;
    color: var(--danger-text);

    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-md);
}

/* Blurred cover behind the whole page, like other music apps. */
.backdrop {
    position: fixed;
    inset: -60px;
    z-index: -1;

    background-position: center;
    background-size: cover;
    filter: blur(70px) saturate(1.5);
    opacity: 0;
    transition: opacity 0.8s ease;
    pointer-events: none;
}

.backdrop.visible {
    opacity: 0.32;
}


/* ============================================================
   TOP BAR
   ============================================================ */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    padding: calc(12px + var(--safe-top)) var(--gutter) 10px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-logo {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 10px;
}

.topbar h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 19px;
    line-height: 1.2;
    font-weight: 750;
    letter-spacing: -0.3px;
}

.topbar-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.account-menu {
    position: relative;
}

.avatar {
    position: relative;
    width: 40px;
    height: 40px;

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

    font-size: 15px;
    font-weight: 700;
    color: #fff;
    list-style: none;
    cursor: pointer;

    background: linear-gradient(135deg, #a78bfa, #6d28d9);
    border-radius: 50%;
}

.avatar::-webkit-details-marker {
    display: none;
}

/* A dot on the avatar tells whether Google Drive is connected. */
.avatar::after {
    content: "";
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 12px;
    height: 12px;

    background: var(--text-faint);
    border: 2px solid var(--bg-main);
    border-radius: 50%;
}

.account-menu:has(.connection-status.connected) .avatar::after {
    background: var(--success);
}

.menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 200;

    width: max-content;
    min-width: 230px;
    max-width: min(320px, calc(100vw - 2 * var(--gutter)));
    padding: 8px;

    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-pop);
}

.menu-user {
    padding: 8px 12px 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

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

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;

    padding: 0 12px 10px;
    margin-bottom: 6px;

    font-size: 12.5px;
    line-height: 1.4;
    color: var(--text-muted);
    overflow-wrap: anywhere;

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

.connection-status::before {
    content: "";
    flex: 0 0 auto;
    width: 7px;
    height: 7px;

    border-radius: 50%;
    background: var(--text-faint);
}

.connection-status.connected {
    color: var(--success);
}

.connection-status.connected::before {
    background: var(--success);
}

.menu form {
    display: flex;
}

.menu-item {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;

    font-size: 14px;
    text-align: left;
    color: var(--text-primary);

    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
}

.menu-item:hover {
    background: var(--surface-2);
}


/* ============================================================
   FORM CONTROLS
   ============================================================ */

/* 16px keeps iOS from zooming the page when a field gets focus. */
input[type="text"],
input[type="url"],
input[type="search"],
.login-form input,
.folder-filter {
    width: 100%;
    min-width: 0;
    height: 46px;
    padding: 0 14px;

    font-size: 16px;
    color: var(--text-primary);

    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);

    transition:
        border-color 0.2s var(--ease),
        background 0.2s var(--ease),
        box-shadow 0.2s var(--ease);
}

input[type="text"]:hover,
input[type="url"]:hover,
.login-form input:hover,
.folder-filter:hover {
    border-color: var(--border-hover);
}

input::placeholder {
    color: var(--text-faint);
}

input[type="text"]:focus,
input[type="url"]:focus,
.login-form input:focus,
.search-field:focus-within {
    background: var(--surface-2);
    border-color: var(--accent-border);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.14);
}

input[type="search"]::-webkit-search-cancel-button {
    filter: invert(0.8);
    cursor: pointer;
}

.folder-filter {
    cursor: pointer;
    text-overflow: ellipsis;
}

.folder-filter option,
.speed-control option {
    background: var(--bg-elevated);
}

.primary-button,
.secondary-button {
    height: 46px;
    padding: 0 18px;

    font-size: 14px;
    font-weight: 650;
    white-space: nowrap;

    border-radius: var(--radius-md);

    transition:
        transform 0.18s var(--ease),
        background 0.18s var(--ease),
        border-color 0.18s var(--ease),
        opacity 0.18s var(--ease);
}

.primary-button {
    color: #fff;
    background: var(--accent);
    border: 1px solid transparent;
}

.primary-button:hover {
    background: var(--accent-strong);
}

.secondary-button {
    color: var(--text-primary);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.secondary-button:hover {
    background: var(--surface-3);
    border-color: var(--border-hover);
}

.primary-button:active,
.secondary-button:active {
    transform: scale(0.98);
}

.primary-button:disabled,
.secondary-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.primary-button.compact {
    height: 38px;
    padding: 0 14px;
    font-size: 13px;
    border-radius: var(--radius-pill);
}

.icon-button {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;

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

    color: var(--text-secondary);
    background: transparent;
    border: 0;
    border-radius: 50%;

    transition:
        background 0.18s var(--ease),
        color 0.18s var(--ease);
}

.icon-button:hover {
    color: var(--text-primary);
    background: var(--surface-2);
}


/* ============================================================
   LOGIN
   ============================================================ */

.login-page {
    width: min(420px, calc(100% - 32px));
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;

    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 28px;
    padding: 40px 0;
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

.login-brand .brand-logo {
    width: 64px;
    height: 64px;
    border-radius: 18px;
}

.login-page h1 {
    font-size: 24px;
    font-weight: 750;
    letter-spacing: -0.4px;
}

.login-brand p {
    margin-top: -8px;
    font-size: 14px;
    color: var(--text-muted);
}

.login-form {
    display: grid;
    gap: 8px;

    padding: 24px;

    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);

    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.login-form h2 {
    margin-bottom: 8px;
    font-size: 18px;
    font-weight: 700;
}

.login-form label {
    margin-top: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.login-form .primary-button {
    width: 100%;
    margin-top: 14px;
}

.login-form [role="alert"],
.folder-status[data-kind="error"] {
    color: var(--danger-text);
}

.login-form [role="alert"] {
    padding: 10px 12px;
    font-size: 13px;
    background: var(--danger-bg);
    border-radius: var(--radius-sm);
}


/* ============================================================
   LIBRARIES PANEL
   ============================================================ */

.sources-header {
    display: flex;
    align-items: center;
    gap: 4px;

    margin-bottom: 10px;
}

.section-title {
    flex: 1;
    min-width: 0;

    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.section-subtitle {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.library-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.library-empty {
    padding: 22px 16px;

    font-size: 13px;
    text-align: center;
    color: var(--text-muted);

    border: 1px dashed var(--border-hover);
    border-radius: var(--radius-md);
}

.library-item {
    display: flex;
    align-items: center;
    gap: 2px;

    border-radius: var(--radius-md);
    transition: background 0.18s var(--ease);
}

.library-item:hover,
.library-item.active {
    background: var(--surface-2);
}

.library-load-button {
    flex: 1;
    min-width: 0;
    min-height: 60px;

    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 4px 8px 8px;

    text-align: left;
    color: var(--text-primary);

    background: transparent;
    border: 0;
    border-radius: var(--radius-md);
}

.library-icon {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;

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

    color: #fff;
    background: linear-gradient(135deg, #a78bfa, #6d28d9);
    border-radius: 12px;
}

.library-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.library-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 15px;
    font-weight: 650;
}

.library-item.active .library-name {
    color: var(--accent-light);
}

.library-meta {
    font-size: 12.5px;
    color: var(--text-muted);
}

.library-delete-button {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;

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

    color: var(--text-faint);
    background: transparent;
    border: 0;
    border-radius: 50%;

    --icon: var(--icon-trash);
}

.library-delete-button::before {
    width: 18px;
    height: 18px;
}

.library-delete-button:hover {
    color: var(--danger-text);
    background: var(--danger-bg);
}

.add-folder {
    display: grid;
    gap: 10px;

    margin-top: 18px;
    padding-top: 18px;

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

.button-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}


/* ============================================================
   TABS
   ============================================================ */

.tab {
    display: flex;
    align-items: center;
    justify-content: center;

    font-weight: 650;
    color: var(--text-muted);

    background: transparent;
    border: 0;

    transition:
        background 0.2s var(--ease),
        color 0.2s var(--ease);
}

.tab:hover {
    color: var(--text-primary);
}


/* ============================================================
   LIBRARY BAR (which folder is on screen, and what is happening to it)
   ============================================================ */

/* Only the Library tab shows a folder. */
body:not([data-view="library"]) .library-bar {
    display: none;
}

.source-button {
    width: 100%;
    min-height: 52px;

    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px;

    text-align: left;
    color: var(--text-primary);

    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.source-button .icon-folder {
    color: var(--accent-light);
}

.source-button .icon-chevron {
    color: var(--text-muted);
}

.source-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.folder-status,
.search-status {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-muted);
}

.folder-status {
    margin-top: 8px;
    padding: 0 2px;
}

.add-folder .folder-status {
    margin-top: 0;
}

.folder-status:empty,
.search-status:empty {
    display: none;
}


/* ============================================================
   VIEW HEADER (an open playlist)
   ============================================================ */

.view-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.view-title {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.view-title strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 20px;
    letter-spacing: -0.3px;
}

.view-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.view-actions .primary-button,
.view-actions .secondary-button {
    height: 38px;
    padding: 0 14px;
    font-size: 13px;
    border-radius: var(--radius-pill);
}


/* ============================================================
   SEARCH
   ============================================================ */

/* Stays at the top while the list scrolls under it. */
.search-bar {
    position: sticky;
    top: 0;
    z-index: 50;

    display: flex;
    gap: 8px;

    margin: 0 calc(var(--gutter) * -1);
    padding: calc(8px + var(--safe-top)) var(--gutter) 8px;

    background: rgba(11, 11, 16, 0.86);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.search-field {
    flex: 1 1 auto;
    min-width: 0;
    height: 46px;

    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 6px 0 14px;

    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: var(--radius-pill);

    transition:
        border-color 0.2s var(--ease),
        background 0.2s var(--ease),
        box-shadow 0.2s var(--ease);
}

.search-field input {
    flex: 1;
    height: 100%;
    padding: 0;

    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

/* The pill around it shows the focus. */
.search-field input:focus-visible {
    outline: none;
}

.search-bar .folder-filter {
    flex: 0 1 38%;
    max-width: 220px;
    padding: 0 10px;

    font-size: 14px;
    background-color: var(--surface-2);
    border-color: transparent;
    border-radius: var(--radius-pill);
}

.search-status {
    padding: 2px 2px 6px;
}


/* ============================================================
   TRACK LIST
   ============================================================ */

.search-results {
    display: flex;
    flex-direction: column;

    /* Rows are padded, their text lines up with the rest of the page. */
    margin: 0 -8px;
}

.search-result {
    position: relative;
    display: flex;
    align-items: center;

    min-height: 62px;
    padding: 0 0 0 8px;

    border-radius: var(--radius-md);

    transition: background 0.18s var(--ease);
}

/* The square in front of a song, with a note on it. */
.search-result::before {
    content: "";
    flex: 0 0 42px;
    width: 42px;
    height: 42px;

    background: var(--surface-2);
    border-radius: 10px;
}

.search-result::after {
    position: absolute;
    left: 19px;
    top: 50%;
    transform: translateY(-50%);

    color: var(--text-faint);
    --icon: var(--icon-music);
}

.search-result:hover {
    background: var(--surface-1);
}

.search-result.active {
    background: var(--accent-bg);
}

.search-result.active::before {
    background: rgba(139, 92, 246, 0.3);
}

.search-result.active::after {
    color: var(--accent-light);
    --icon: var(--icon-bars);
}

.search-result.active .search-result-title {
    color: var(--accent-light);
}

.track-main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 62px;

    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;

    padding: 8px 4px 8px 12px;

    color: inherit;
    text-align: left;
    background: transparent;
    border: 0;
}

.search-result-title,
.search-result-meta {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
}

.search-result-meta {
    font-size: 12.5px;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.track-action {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;

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

    color: var(--text-muted);
    background: transparent;
    border: 0;
    border-radius: 50%;

    transition:
        background 0.18s var(--ease),
        color 0.18s var(--ease),
        opacity 0.18s var(--ease),
        transform 0.18s var(--ease);
}

.track-action:hover {
    color: var(--text-primary);
    background: var(--surface-3);
}

.track-action[data-action="menu"] {
    --icon: var(--icon-more);
}

.like-button {
    --icon: var(--icon-heart);
}

.like-button.liked {
    color: var(--like);
    --icon: var(--icon-heart-filled);
}

.like-button:active {
    transform: scale(1.2);
}

/* With a mouse, the row buttons appear when the row is pointed at. */
@media (hover: hover) {
    .search-result .track-action:not(.liked) {
        opacity: 0;
    }

    .search-result:hover .track-action,
    .search-result:focus-within .track-action,
    .search-result.active .track-action {
        opacity: 1;
    }
}

/* Scrolling near this marker renders the next rows of a long list. */
.more-rows {
    flex: 0 0 1px;
}

.empty-results {
    padding: 56px 24px;

    font-size: 14px;
    text-align: center;
    color: var(--text-muted);
}


/* ============================================================
   PLAYLISTS
   ============================================================ */

.playlist-create {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.playlist-list {
    display: flex;
    flex-direction: column;
    gap: 6px;

    margin-top: 14px;
}

.playlist-item {
    width: 100%;
    min-height: 60px;

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

    padding: 12px 16px;

    color: var(--text-primary);
    text-align: left;

    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);

    transition:
        background 0.18s var(--ease),
        border-color 0.18s var(--ease);
}

.playlist-item:hover {
    background: var(--surface-2);
    border-color: var(--border-hover);
}

.playlist-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 15px;
    font-weight: 650;
}

.playlist-item .search-result-meta {
    flex: 0 0 auto;
}


/* ============================================================
   PLAYER (shared parts)
   ============================================================ */

.player {
    position: fixed;
    z-index: 120;
}

.player-art {
    position: relative;
    flex: 0 0 auto;
    overflow: hidden;

    background: var(--surface-2);
    border-radius: 10px;
}

.cover-art {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.cover-placeholder {
    position: absolute;
    inset: 0;

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

    color: var(--text-faint);
}

.cover-art:not([hidden]) + .cover-placeholder {
    display: none;
}

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

.now-playing,
.now-playing-sub {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.now-playing {
    font-size: 14.5px;
    font-weight: 650;
    line-height: 1.35;
}

.now-playing-sub {
    font-size: 12.5px;
    line-height: 1.35;
    color: var(--text-muted);
}

.now-playing-sub:empty {
    display: none;
}

.player-button {
    position: relative;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;

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

    color: var(--text-secondary);
    background: transparent;
    border: 0;
    border-radius: 50%;

    transition:
        background 0.18s var(--ease),
        color 0.18s var(--ease),
        transform 0.18s var(--ease);
}

.player-button:hover {
    color: var(--text-primary);
}

.player-button:active {
    transform: scale(0.92);
}

#shuffle-button { --icon: var(--icon-shuffle); }
#previous-button { --icon: var(--icon-previous); }
#next-button { --icon: var(--icon-next); }
#repeat-button { --icon: var(--icon-repeat); }
#repeat-button[data-mode="one"] { --icon: var(--icon-repeat-one); }
#queue-button { --icon: var(--icon-list); }
#play-button { --icon: var(--icon-play); }
#play-button.playing { --icon: var(--icon-pause); }

#previous-button::before,
#next-button::before {
    width: 24px;
    height: 24px;
}

.toggle-button.active {
    color: var(--accent-light);
}

/* A dot under Shuffle / Repeat while they are on. */
.toggle-button.active::after {
    content: "";
    position: absolute;
    bottom: 5px;
    left: 50%;
    width: 4px;
    height: 4px;
    margin-left: -2px;

    background: currentColor;
    border-radius: 50%;
}

.player-button.play-button {
    color: #111;
    background: #fff;
}

.player-button.play-button:hover {
    color: #111;
    transform: scale(1.05);
}

/* Number of songs waiting in the queue. */
#queue-button[data-count]:not([data-count=""])::after {
    content: attr(data-count);
    position: absolute;
    top: 3px;
    right: 1px;

    min-width: 17px;
    height: 17px;
    padding: 0 4px;

    font-size: 10.5px;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    color: #fff;

    background: var(--accent);
    border-radius: var(--radius-pill);
}

.time-label {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.speed-control {
    height: 36px;
    padding: 0 8px;

    font-size: 13px;
    color: var(--text-primary);

    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    cursor: pointer;
}

.player-volume {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

#volume-control {
    width: 100px;
    height: 20px;
    margin: 0;

    accent-color: var(--accent-light);
    cursor: pointer;
}

/* The position slider: a thin line that fills up, with a thumb to drag.
   --progress is set by the script as the song plays. */
#progress-bar {
    -webkit-appearance: none;
    appearance: none;

    width: 100%;
    height: 24px;
    margin: 0;

    background: transparent;
    cursor: pointer;
}

#progress-bar::-webkit-slider-runnable-track {
    height: 4px;
    background:
        linear-gradient(
            to right,
            var(--text-primary) var(--progress, 0%),
            var(--surface-3) var(--progress, 0%)
        );
    border-radius: var(--radius-pill);
}

#progress-bar::-moz-range-track {
    height: 4px;
    background:
        linear-gradient(
            to right,
            var(--text-primary) var(--progress, 0%),
            var(--surface-3) var(--progress, 0%)
        );
    border-radius: var(--radius-pill);
}

#progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    margin-top: -5px;

    background: #fff;
    border: 0;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

#progress-bar::-moz-range-thumb {
    width: 14px;
    height: 14px;

    background: #fff;
    border: 0;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}


/* ============================================================
   DIALOGS
   ============================================================ */

.dialog {
    width: min(440px, calc(100% - 32px));
    max-height: 80vh;
    margin: auto;
    padding: 20px;

    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    border-radius: 20px;
    box-shadow: var(--shadow-pop);

    overflow-y: auto;
}

.dialog[open] {
    animation: dialog-in 0.22s var(--ease);
}

.dialog::backdrop {
    background: rgba(5, 5, 9, 0.65);
    backdrop-filter: blur(4px);
}

@keyframes dialog-in {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
}

.dialog-title {
    margin-bottom: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.dialog-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dialog-body .playlist-create {
    margin-top: 10px;
}

.dialog-option {
    min-height: 50px;
    padding: 0 14px;

    font-size: 15px;
    text-align: left;
    color: var(--text-primary);

    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);

    transition: background 0.15s var(--ease);
}

.dialog-option:hover {
    background: var(--surface-2);
}

.dialog-option.danger {
    color: var(--danger-text);
}

.dialog-close {
    width: 100%;
    margin-top: 14px;
}

.dialog-footer {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.dialog-footer .secondary-button {
    flex: 1;
    margin-top: 0;
}

.queue-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;

    min-height: 50px;
    padding: 0 4px 0 14px;

    background: var(--surface-1);
    border-radius: var(--radius-sm);
}

.queue-row .search-result-title {
    flex: 1;
    min-width: 0;
}

.queue-row .track-action {
    width: auto;
    padding: 0 12px;
    font-size: 13px;
    border-radius: var(--radius-pill);
}


/* ============================================================
   TOAST
   ============================================================ */

.toast {
    position: fixed;
    left: 50%;
    z-index: 500;

    max-width: calc(100% - 32px);
    padding: 11px 18px;

    font-size: 13.5px;
    font-weight: 550;
    color: var(--text-primary);

    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-pop);

    opacity: 0;
    transform: translate(-50%, 8px);
    pointer-events: none;

    transition:
        opacity 0.22s var(--ease),
        transform 0.22s var(--ease);
}

.toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}


/* ============================================================
   SCROLLBAR
   ============================================================ */

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border-radius: var(--radius-pill);
}

*::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.28);
}


/* ============================================================
   PHONE & TABLET
   Tabs become a bar at the bottom, the player a small bar above it that
   opens to full screen, and the libraries panel a sheet.
   ============================================================ */

@media (max-width: 899.98px) {

    .app {
        padding-bottom:
            calc(var(--nav-height) + var(--mini-height) + var(--safe-bottom) + 32px);
    }

    .main {
        padding: 0 var(--gutter);
    }

    .library-bar,
    .view-header,
    .playlist-panel {
        margin-bottom: 6px;
    }

    .library-list {
        margin: 0 -8px;
    }

    .view-header {
        gap: 10px;
    }

    .view-actions {
        width: calc(100% + var(--gutter) * 2);
        margin: 0 calc(var(--gutter) * -1);
        padding: 0 var(--gutter);

        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .view-actions::-webkit-scrollbar {
        display: none;
    }

    .view-actions .primary-button,
    .view-actions .secondary-button {
        flex: 0 0 auto;
        height: 40px;
    }

    /* ---- tab bar ---- */

    .tabs {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 110;

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

        height: calc(var(--nav-height) + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);

        background: var(--bg-bar);
        border-top: 1px solid var(--border);

        backdrop-filter: blur(22px);
        -webkit-backdrop-filter: blur(22px);
    }

    .tab {
        flex-direction: column;
        gap: 3px;
        min-width: 0;
        font-size: 11px;
    }

    .tab .icon {
        width: 22px;
        height: 22px;
    }

    .tab.active {
        color: var(--accent-light);
    }

    /* ---- libraries sheet ---- */

    .sources {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 310;

        max-height: 88vh;
        max-height: 88dvh;
        padding: 22px var(--gutter) calc(20px + var(--safe-bottom));
        overflow-y: auto;
        overscroll-behavior: contain;

        background: var(--bg-elevated);
        border-top: 1px solid var(--border-hover);
        border-radius: 22px 22px 0 0;
        box-shadow: var(--shadow-pop);

        visibility: hidden;
        transform: translateY(104%);
        transition:
            transform 0.28s var(--ease),
            visibility 0s 0.28s;
    }

    /* The little handle sheets have at the top. */
    .sources::before {
        content: "";
        position: absolute;
        top: 8px;
        left: 50%;
        width: 40px;
        height: 4px;
        margin-left: -20px;

        background: var(--surface-3);
        border-radius: var(--radius-pill);
    }

    body.sources-open .sources {
        visibility: visible;
        transform: none;
        transition: transform 0.28s var(--ease);
    }

    .scrim {
        position: fixed;
        inset: 0;
        z-index: 300;

        background: rgba(4, 4, 8, 0.62);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.28s var(--ease);
    }

    body.sources-open .scrim {
        opacity: 1;
        pointer-events: auto;
    }

    body.sources-open,
    body.player-open {
        overflow: hidden;
    }

    /* ---- small player ---- */

    .player {
        left: 8px;
        right: 8px;
        bottom: calc(var(--nav-height) + var(--safe-bottom) + 8px);

        height: var(--mini-height);

        display: grid;
        grid-template-columns: 46px minmax(0, 1fr) 44px 44px 44px;
        align-items: center;
        column-gap: 2px;
        padding: 0 6px 0 9px;
        overflow: hidden;

        background: #25222f;
        border: 1px solid var(--border);
        border-radius: 16px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    }

    /* The groups dissolve: their children sit on the one row. */
    .player-left,
    .player-center,
    .player-controls {
        display: contents;
    }

    .player-art {
        width: 46px;
        height: 46px;
    }

    .player-info {
        padding: 0 4px 0 10px;
        cursor: pointer;
    }

    .player-right,
    .player-collapse,
    #shuffle-button,
    #previous-button,
    #repeat-button,
    .time-label {
        display: none;
    }

    .player-button.play-button {
        width: 40px;
        height: 40px;
        justify-self: center;
    }

    /* The position becomes a line along the bottom edge. */
    .player-progress {
        position: absolute;
        left: 12px;
        right: 12px;
        bottom: 0;
        height: 2px;
        pointer-events: none;
    }

    .player-progress #progress-bar {
        display: block;
        height: 2px;
    }

    .player-progress #progress-bar::-webkit-slider-runnable-track {
        height: 2px;
    }

    .player-progress #progress-bar::-moz-range-track {
        height: 2px;
    }

    .player-progress #progress-bar::-webkit-slider-thumb {
        width: 0;
        height: 0;
        box-shadow: none;
    }

    .player-progress #progress-bar::-moz-range-thumb {
        width: 0;
        height: 0;
        box-shadow: none;
    }

    /* ---- full-screen player ---- */

    body.player-open .player {
        inset: 0;
        z-index: 400;

        height: auto;

        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 22px;
        padding:
            calc(8px + var(--safe-top))
            24px
            calc(24px + var(--safe-bottom));
        overflow-y: auto;

        background:
            linear-gradient(180deg, rgba(88, 60, 170, 0.5), rgba(11, 11, 16, 0) 62%),
            var(--bg-main);
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    body.player-open .player-left {
        flex: 1 1 auto;
        min-height: 0;

        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-rows: auto minmax(0, 1fr) auto;
        align-items: center;
        row-gap: 18px;
    }

    body.player-open .player-collapse {
        display: inline-flex;
        grid-column: 1 / -1;
        margin-left: -12px;
    }

    body.player-open .player-art {
        grid-column: 1 / -1;
        justify-self: center;
        align-self: center;

        /* As large as fits above the title and the controls. */
        width: min(100%, 38vh, 380px);
        height: auto;
        aspect-ratio: 1;

        border-radius: 18px;
        box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    }

    body.player-open .cover-placeholder .icon {
        width: 72px;
        height: 72px;
    }

    body.player-open .player-info {
        padding: 0;
        cursor: default;
    }

    body.player-open .now-playing {
        font-size: 21px;
        font-weight: 750;
        letter-spacing: -0.3px;
    }

    body.player-open .now-playing-sub {
        font-size: 15px;
    }

    body.player-open .like-button::before {
        width: 26px;
        height: 26px;
    }

    /* The position slider first, the buttons under it. */
    body.player-open .player-center {
        display: flex;
        flex-direction: column-reverse;
        gap: 14px;
    }

    body.player-open .player-progress {
        position: static;
        height: auto;
        pointer-events: auto;

        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    body.player-open .player-progress #progress-bar {
        grid-column: 1 / -1;
        grid-row: 1;
        height: 28px;
    }

    body.player-open .player-progress #progress-bar::-webkit-slider-runnable-track {
        height: 4px;
    }

    body.player-open .player-progress #progress-bar::-moz-range-track {
        height: 4px;
    }

    body.player-open .player-progress #progress-bar::-webkit-slider-thumb {
        width: 16px;
        height: 16px;
        margin-top: -6px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    }

    body.player-open .player-progress #progress-bar::-moz-range-thumb {
        width: 16px;
        height: 16px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    }

    body.player-open .time-label {
        display: block;
    }

    body.player-open .time-label:last-child {
        text-align: right;
    }

    body.player-open .player-controls {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    body.player-open #shuffle-button,
    body.player-open #previous-button,
    body.player-open #repeat-button {
        display: flex;
    }

    body.player-open .player-button {
        width: 52px;
        height: 52px;
    }

    body.player-open #previous-button::before,
    body.player-open #next-button::before {
        width: 30px;
        height: 30px;
    }

    body.player-open .player-button.play-button {
        width: 72px;
        height: 72px;
    }

    body.player-open .play-button::before {
        width: 30px;
        height: 30px;
    }

    body.player-open .player-right {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    /* The phone's own buttons set the volume. */
    .player-volume {
        display: none;
    }

    /* ---- dialogs slide up from the bottom ---- */

    .dialog {
        width: 100%;
        max-width: 100%;
        max-height: 82vh;
        max-height: 82dvh;
        margin: auto 0 0;
        padding: 20px var(--gutter) calc(16px + var(--safe-bottom));

        border-width: 1px 0 0;
        border-radius: 22px 22px 0 0;
    }

    @keyframes dialog-in {
        from {
            transform: translateY(100%);
        }
    }

    .toast {
        bottom: calc(var(--nav-height) + var(--mini-height) + var(--safe-bottom) + 20px);
    }
}

@media (max-width: 420px) {

    /* The Connect button needs the room the title takes. */
    .topbar:has(#connect-drive:not([hidden])) h1 {
        display: none;
    }
}

@media (max-width: 380px) {

    .tab {
        font-size: 10.5px;
    }

    body.player-open .player {
        padding-left: 18px;
        padding-right: 18px;
    }
}


/* ============================================================
   WIDE SCREENS
   Libraries in a side panel, tabs above the list, one player bar.
   ============================================================ */

@media (min-width: 900px) {

    :root {
        --gutter: 28px;
    }

    .app {
        padding-bottom: calc(var(--bar-height) + 40px);
    }

    .topbar,
    .layout {
        width: min(var(--page-width), calc(100% - var(--gutter) * 2));
        margin: 0 auto;
    }

    .topbar {
        padding: 22px 0 18px;
    }

    .brand-logo {
        width: 42px;
        height: 42px;
        border-radius: 12px;
    }

    .topbar h1 {
        font-size: 22px;
    }

    .layout {
        display: grid;
        grid-template-columns: 320px minmax(0, 1fr);
        gap: 28px;
        align-items: start;
    }

    .sources {
        position: sticky;
        top: 20px;

        max-height: calc(100vh - var(--bar-height) - 40px);
        padding: 18px 14px 18px;
        overflow-y: auto;

        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);

        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
    }

    .sources-header {
        padding-left: 6px;
    }

    .add-folder {
        padding-left: 4px;
        padding-right: 4px;
    }

    /* The same message is under the folder name, right next to the panel. */
    .sources-close,
    .scrim,
    .player-collapse,
    #sources-status {
        display: none;
    }

    input[type="text"],
    input[type="url"],
    .folder-filter,
    .primary-button,
    .secondary-button,
    .search-field {
        height: 42px;
    }

    input[type="text"],
    input[type="url"],
    input[type="search"],
    .folder-filter {
        font-size: 14px;
    }

    /* ---- tabs ---- */

    .tabs {
        display: flex;
        gap: 4px;
        width: fit-content;
        margin-bottom: 18px;
        padding: 4px;

        background: var(--surface-1);
        border: 1px solid var(--border);
        border-radius: var(--radius-pill);
    }

    .tab {
        gap: 8px;
        height: 38px;
        padding: 0 16px;

        font-size: 13.5px;
        border-radius: var(--radius-pill);
    }

    .tab .icon {
        width: 16px;
        height: 16px;
    }

    .tab.active {
        color: #fff;
        background: var(--accent);
    }

    /* The folder name is a heading here: the panel is always on screen. */
    .library-bar,
    .view-header,
    .playlist-panel {
        margin-bottom: 10px;
    }

    .source-button {
        min-height: 0;
        padding: 0;
        gap: 10px;

        background: transparent;
        border: 0;
        cursor: default;
    }

    .source-button .icon-chevron {
        display: none;
    }

    .source-name {
        font-size: 22px;
        letter-spacing: -0.4px;
    }

    .folder-status {
        margin-top: 4px;
        padding: 0;
    }

    .search-bar {
        margin: 0;
        padding: 10px 0;
        background: rgba(11, 11, 16, 0.8);
    }

    .search-bar .folder-filter {
        flex-basis: 240px;
        max-width: 280px;
    }

    .search-result,
    .track-main {
        min-height: 58px;
    }

    .track-action {
        width: 40px;
        height: 40px;
    }

    /* ---- player bar ---- */

    .player {
        left: 0;
        right: 0;
        bottom: 0;

        min-height: var(--bar-height);

        display: grid;
        grid-template-columns:
            minmax(0, 1fr)
            minmax(0, 560px)
            minmax(0, 1fr);
        align-items: center;
        column-gap: 24px;

        padding:
            10px
            max(var(--gutter), calc((100vw - var(--page-width)) / 2))
            10px;

        background: var(--bg-bar);
        border-top: 1px solid var(--border);

        backdrop-filter: blur(26px) saturate(1.4);
        -webkit-backdrop-filter: blur(26px) saturate(1.4);
    }

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

    .player-art {
        width: 56px;
        height: 56px;
    }

    .player-info {
        flex: 0 1 auto;
    }

    .player-center {
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .player-controls {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
    }

    .player-button {
        width: 38px;
        height: 38px;
    }

    .player-button:hover {
        background: var(--surface-2);
    }

    .player-button.play-button {
        width: 42px;
        height: 42px;
    }

    .player-button.play-button:hover {
        background: #fff;
    }

    .toggle-button.active::after {
        bottom: 3px;
    }

    .player-progress {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .time-label {
        flex: 0 0 40px;
    }

    .time-label:first-child {
        text-align: right;
    }

    .player-right {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 12px;
    }

    .toast {
        bottom: calc(var(--bar-height) + 18px);
    }
}
