/* =========================================================================
   DESIGN TOKENS
   ========================================================================= */
:root {
    --bg: #07070a;
    --surface: #121218;
    --surface-2: #1a1a22;
    --surface-3: #22222c;
    --border: #262632;
    --text: #f2f2f7;
    --text-2: #a8a8b3;
    --text-3: #6b6b78;
    --accent: #14b8a6;
    --accent-2: #0d9488;
    --accent-glow: rgba(20, 184, 166, 0.35);
    --ok: #34d399;
    --warn: #fbbf24;
    --err: #f87171;

    /* Dynamic player theming (overridden by JS) */
    --player-tint: 30, 110, 110;
    --player-grad: linear-gradient(160deg,
        rgba(var(--player-tint), 1) 0%,
        rgba(var(--player-tint), 0.92) 40%,
        #07070a 100%);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow: 0 4px 16px rgba(0,0,0,0.35);
    --shadow-lg: 0 16px 48px rgba(0,0,0,0.5);

    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);

    --header-h: 52px;
    --nav-h: calc(60px + env(safe-area-inset-bottom));
    --mini-h: 64px;
}

/* =========================================================================
   LIGHT THEME OVERRIDES
   Activated via <html data-theme="light">. Accent stays the same — teal
   #14b8a6 passes WCAG AA on white. The full-screen player overlay and
   vinyl record visuals stay dark in both themes (intentional).
   ========================================================================= */
[data-theme="light"] {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface-2: #f0f0f3;
    --surface-3: #e5e5ea;
    --border: #d2d2d7;
    --text: #1d1d1f;
    --text-2: #6e6e73;
    --text-3: #a1a1a6;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
    --shadow:    0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 16px 40px rgba(0,0,0,0.12);
}

/* Header / nav backdrops — translucent light replacements for the dark
   rgba(7,7,10,0.82) / rgba(10,10,14,0.88) values used in dark mode. */
[data-theme="light"] #app-header { background: rgba(245, 245, 247, 0.82); border-bottom-color: rgba(0,0,0,0.06); }
[data-theme="light"] #bottom-nav { background: rgba(245, 245, 247, 0.88); border-top-color: rgba(0,0,0,0.08); }

/* Faint white-on-dark borders/hovers vanish on white surfaces — flip to
   subtle dark equivalents. */
[data-theme="light"] .icon-btn:hover { background: rgba(0,0,0,0.06); }
[data-theme="light"] .song-list-row { border-bottom-color: rgba(0,0,0,0.06); }
[data-theme="light"] .more-item { border-bottom-color: rgba(0,0,0,0.06); }
[data-theme="light"] .song-section-header { background: rgba(245,245,247,0.85); }

/* Mini-player sits on the regular shell (not the full overlay) — it should
   adapt to light theme. The full #player-overlay stays dark intentionally. */
[data-theme="light"] #mini-player {
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(0,0,0,0.08);
    box-shadow: 0 12px 32px rgba(0,0,0,0.12);
}
[data-theme="light"] .mini-btn:hover { background: rgba(0,0,0,0.06); }

/* Search-screen mesh background — replace dark base gradient with a light
   one, keep the teal/cyan radials at lower opacity for subtlety. */
[data-theme="light"] .mesh-bg {
    background:
        radial-gradient(40% 50% at 20% 30%, rgba(20,184,166,0.35) 0%, transparent 50%),
        radial-gradient(45% 55% at 80% 40%, rgba(14,165,233,0.30) 0%, transparent 55%),
        radial-gradient(50% 60% at 50% 80%, rgba(13,148,136,0.30) 0%, transparent 55%),
        linear-gradient(135deg, #e6fffb 0%, #e0f2fe 100%);
    background-size: 200% 200%;
    animation: mesh-drift 16s ease-in-out infinite;
}

/* Smooth color crossfade on theme toggle. Scoped to color tokens only to
   avoid janking layout/album-art animations. */
html, body, #app-header, #bottom-nav, #mini-player, .more-list, .more-item,
.song-list-row, .region, .icon-btn, .toggle-switch, .toggle-thumb {
    transition: background-color 200ms var(--ease-out),
                color 200ms var(--ease-out),
                border-color 200ms var(--ease-out);
}

/* =========================================================================
   RESET + BASE
   ========================================================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    /* Baseline full-height shell. In installed iOS PWAs, JS innerHeight can
       report the short splash viewport on cold start, so standalone mode is
       handled below with lvh/vh instead of --vh. */
    height: -webkit-fill-available;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
}

html.uses-js-vh,
html.uses-js-vh body {
    height: var(--vh);
}

/* Body sizes itself via `position: fixed; inset: 0` (set below), which pins
   every edge to the viewport. Applying an explicit height here over-constrains
   the box and CSS drops `bottom`, so if iOS ever reports a short `100lvh` on
   cold start the bottom-nav strands a strip of body bg above the home
   indicator. Pin the height to <html> only. */
html.is-standalone {
    height: 100vh;
    height: 100lvh;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "SF Pro Text", sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    font-size: 15px;
    line-height: 1.4;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    position: fixed;
    inset: 0;
    width: 100%;
}

input, textarea, [contenteditable="true"], .selectable, .error-modal-body {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

button {
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

a { color: inherit; }

.hidden { display: none !important; }
.muted { color: var(--text-3); padding: 32px 16px; text-align: center; font-size: 0.9rem; }
.muted-small { color: var(--text-3); font-size: 0.75rem; text-align: center; }

/* =========================================================================
   APP SHELL
   ========================================================================= */

/* Top header */
#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    height: calc(var(--header-h) + env(safe-area-inset-top));
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(7, 7, 10, 0.82);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    z-index: 40;
}

#app-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    flex: 1;
}

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

/* Status bar (inline at top of main content) */
#status-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    font-size: 0.72rem;
    padding: 4px 8px 10px;
    margin-top: -4px;
}

#status-bar:empty { display: none; }

.status-warn { color: var(--warn); }
.status-ok { color: var(--ok); }
.status-err { color: var(--err); }

/* Pull-to-refresh indicator */
#pull-indicator {
    position: fixed;
    top: calc(var(--header-h) + env(safe-area-inset-top) + 8px);
    left: 50%;
    transform: translate(-50%, -40px);
    width: 36px;
    height: 36px;
    background: var(--surface-2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
    z-index: 30;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    box-shadow: var(--shadow);
}

#pull-indicator.visible { opacity: 1; }
#pull-indicator.refreshing svg { animation: spin 0.9s linear infinite; }

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

/* Main scroll area */
#app-main {
    position: fixed;
    top: calc(var(--header-h) + env(safe-area-inset-top));
    left: 0;
    right: 0;
    bottom: var(--nav-h);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding: 12px;
    transition: bottom 0.3s var(--ease-out);
}

body.has-mini-player #app-main {
    bottom: calc(var(--nav-h) + var(--mini-h));
}

/* Screens */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.25s var(--ease-out); }

/* =========================================================================
   BUTTONS + INPUTS
   ========================================================================= */
button {
    padding: 11px 18px;
    min-height: 44px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

button:hover { background: var(--accent-2); }
button:active { transform: scale(0.97); }
button:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; transform: none; }
button.secondary { background: var(--surface-2); color: var(--text); }
button.secondary:hover { background: var(--surface-3); }
button.danger { background: #dc2626; }
button.danger:hover { background: #b91c1c; }

button.sm {
    padding: 8px 14px;
    min-height: 36px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.icon-btn {
    background: transparent;
    color: var(--text-2);
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    touch-action: manipulation;
}

.icon-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.icon-btn.active { color: var(--accent); }

input[type="text"] {
    padding: 12px 16px;
    min-height: 44px;
    font-size: 0.95rem;
    background: var(--surface);
    border: 1px solid transparent;
    color: var(--text);
    border-radius: var(--radius);
    width: 100%;
    transition: border-color 0.15s, background 0.15s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface-2);
}

/* Search field with icon */
.search-field {
    position: relative;
    width: 100%;
}

.search-field .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
}

.search-field input[type="text"] {
    padding-left: 40px;
    padding-right: 40px;
}

.search-field .clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface-3);
    color: var(--text-2);
    width: 26px;
    height: 26px;
    min-height: 26px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.1rem;
    line-height: 1;
}

/* Checkboxes */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
    transition: all 0.2s var(--ease-out);
}

input[type="checkbox"]:hover {
    border-color: var(--accent);
    background: rgba(20, 184, 166, 0.1);
}

input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    animation: checkPop 0.2s var(--ease-spring);
}

@keyframes checkPop {
    0% { opacity: 0; transform: rotate(45deg) scale(0.5); }
    100% { opacity: 1; transform: rotate(45deg) scale(1); }
}

/* =========================================================================
   TOOLBAR
   ========================================================================= */
.toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.toolbar button,
.toolbar > input { width: 100%; }

/* =========================================================================
   BOTTOM NAV
   ========================================================================= */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(10, 10, 14, 0.88);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    z-index: 45;
}

.bn-tab {
    flex: 1;
    background: transparent;
    color: var(--text-3);
    padding: 8px 4px;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 0;
    font-size: 0.68rem;
    font-weight: 600;
    transition: color 0.15s;
}

.bn-tab span {
    font-size: 0.68rem;
    letter-spacing: -0.01em;
}

.bn-tab:hover { background: transparent; color: var(--text-2); }
.bn-tab.active { color: var(--accent); }
.bn-tab.active svg { filter: drop-shadow(0 0 8px var(--accent-glow)); }
.bn-tab:active svg { transform: scale(0.88); transition: transform 0.1s; }

/* =========================================================================
   CHIPS (Recently Played / Added)
   ========================================================================= */
#chips-container {
    margin-bottom: 12px;
}

#chips-container:empty { display: none; }

.chip-section {
    margin-bottom: 14px;
}

.chip-section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
    padding: 0 2px;
}

.see-all-link {
    background: none;
    border: 0;
    padding: 2px 4px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    transition: color 0.15s;
}
.see-all-link:hover { color: var(--accent); }
.see-all-link:active { color: var(--accent); }

.chip-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0;
    margin: 0 -12px;
    scroll-padding-inline: 12px;
    scrollbar-width: none;
}
.chip-scroll::-webkit-scrollbar { display: none; }

.chip-scroll::before,
.chip-scroll::after {
    content: "";
    flex: 0 0 12px;
    align-self: stretch;
}

.chip {
    flex-shrink: 0;
    width: 132px;
    scroll-snap-align: start;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.chip:active { transform: scale(0.97); background: var(--surface-2); }

.chip-art {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    object-fit: cover;
    margin-bottom: 6px;
}

.chip-art.placeholder {
    background: linear-gradient(135deg, #134e4a, #0c3a4a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.4);
}

.chip-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================================================================
   SONG LIST
   ========================================================================= */
.song-list-wrap {
    position: relative;
}

#song-list-content {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}

.song-list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
    min-height: 60px;
    transition: background 0.12s;
    touch-action: manipulation;
}

.song-list-row:active { background: var(--surface-2); }
.song-list-row:last-child { border-bottom: none; }

.song-list-row.now-playing {
    background: linear-gradient(90deg, rgba(20,184,166,0.16), transparent);
    border-left: 3px solid var(--accent);
    padding-left: 11px;
}

.song-list-thumb {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--surface-2);
}

.song-list-thumb.thumb-hidden { display: none; }

.song-list-thumb-placeholder {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    background: linear-gradient(135deg, #134e4a, #0c3a4a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.3);
}

.song-list-info {
    flex: 1;
    min-width: 0;
}

.song-list-title {
    font-weight: 500;
    font-size: 0.92rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 8px;
}

.song-list-row.now-playing .song-list-title { color: var(--accent); }

.song-list-meta {
    font-size: 0.72rem;
    color: var(--text-3);
    margin-top: 3px;
}

/* Alphabet section headers */
.song-section { border-bottom: none; }

.song-section-header {
    padding: 10px 16px 6px;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--accent);
    background: rgba(7,7,10,0.85);
    backdrop-filter: blur(12px);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Now-playing equalizer icon */
.eq-icon {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
    width: 14px;
    flex-shrink: 0;
}

.eq-icon span {
    display: block;
    width: 3px;
    background: var(--accent);
    border-radius: 1px;
    animation: eq-bounce 0.9s infinite var(--ease-in-out);
    transform-origin: bottom;
}

.eq-icon span:nth-child(1) { animation-delay: -0.5s; }
.eq-icon span:nth-child(2) { animation-delay: -0.2s; }
.eq-icon span:nth-child(3) { animation-delay: -0.7s; }

.eq-icon.paused span { animation-play-state: paused; height: 30%; }

@keyframes eq-bounce {
    0%, 100% { height: 25%; }
    50% { height: 100%; }
}

/* Inline icon-only action button used in song rows (download, add-to-my-songs) */
.song-icon-btn {
    background: transparent;
    color: var(--accent);
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}
.song-icon-btn:hover { color: var(--accent-2); }
.song-icon-btn:active { background: var(--accent-glow); color: var(--accent-2); }

/* Offline indicator on song rows */
.offline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ok);
    flex-shrink: 0;
    margin-right: 4px;
    display: none;
    box-shadow: 0 0 6px rgba(52, 199, 142, 0.6);
}
.song-list-row.is-offline .offline-dot { display: block; }

/* Downloads screen */
.storage-meter {
    padding: 14px 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.storage-meter-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.85rem;
}
#storage-fill {
    height: 6px;
    background: var(--accent);
    border-radius: 3px;
    width: 0%;
    transition: width 200ms ease;
}
.download-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.download-row:last-child { border-bottom: none; }
.download-info {
    flex: 1;
    min-width: 0;
}
.download-title {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.download-meta {
    font-size: 0.78rem;
    color: var(--text-3);
    margin-top: 2px;
}
#downloads-progress {
    padding: 8px 16px;
}
#downloads-progress-info {
    font-size: 0.82rem;
    color: var(--text-3);
    margin-bottom: 4px;
}
#downloads-progress-fill {
    height: 4px;
    background: var(--accent);
    border-radius: 2px;
    width: 0%;
    transition: width 150ms linear;
}

/* My Songs / All Songs toggle */
.song-list-toggle {
    display: flex;
    gap: 2px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 3px;
}

.toggle-btn {
    flex: 1;
    padding: 8px 12px;
    min-height: 36px;
    background: transparent;
    color: var(--text-3);
    border-radius: 9px;
    font-size: 0.82rem;
    font-weight: 600;
}

.toggle-btn:hover { background: transparent; color: var(--text-2); }
.toggle-btn.active {
    background: var(--surface-3);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* =========================================================================
   EMPTY STATES + SKELETONS
   ========================================================================= */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 8px;
    color: var(--text-3);
}

.empty-state svg { color: var(--text-3); opacity: 0.5; margin-bottom: 4px; }
.empty-state p { font-size: 1.05rem; color: var(--text-2); font-weight: 600; }
.empty-state span { font-size: 0.85rem; color: var(--text-3); text-align: center; max-width: 280px; }

/* Skeleton */
#song-list-skeleton, #search-skeleton { padding: 4px; }

.skeleton-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    min-height: 60px;
}

.skeleton-thumb {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    flex-shrink: 0;
    animation: shimmer 1.6s infinite linear;
    background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 40%, var(--surface-2) 80%);
    background-size: 200% 100%;
}

.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.skeleton-line {
    height: 11px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 40%, var(--surface-2) 80%);
    background-size: 200% 100%;
    animation: shimmer 1.6s infinite linear;
}
.skeleton-line.w70 { width: 70%; } .skeleton-line.w50 { width: 50%; }
.skeleton-line.w80 { width: 80%; } .skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; } .skeleton-line.w30 { width: 30%; }
.skeleton-line.w75 { width: 75%; } .skeleton-line.w45 { width: 45%; }
.skeleton-line.w35 { width: 35%; }

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* =========================================================================
   MINI PLAYER (glassmorphism)
   ========================================================================= */
#mini-player {
    position: fixed;
    bottom: var(--nav-h);
    margin-bottom: 12px;
    left: 8px;
    right: 8px;
    background: rgba(22, 22, 30, 0.75);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 50px;
    overflow: hidden;
    z-index: 42;
    box-shadow: 0 12px 32px rgba(0,0,0,0.5);
    animation: mini-rise 0.35s var(--ease-spring);
}

@keyframes mini-rise {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

#mini-progress-bar {
    height: 2px;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s linear;
}

#mini-player-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    min-height: 56px;
}

#mini-artwork-wrap {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
}

.mini-artwork {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mini-artwork-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #134e4a, #0c3a4a);
    display: flex;
    align-items: center;
    justify-content: center;
}

#mini-song-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    padding: 4px 0;
}

#mini-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#mini-artist {
    font-size: 0.7rem;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#mini-controls {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.mini-btn {
    width: 38px;
    height: 38px;
    min-height: 38px;
    min-width: 38px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-btn:hover { background: rgba(255,255,255,0.08); }
.mini-btn:active { transform: scale(0.9); }

/* =========================================================================
   FULL-SCREEN PLAYER OVERLAY
   ========================================================================= */
#player-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    transform: translateY(0);
    transition: transform 0.35s var(--ease-out);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg);
}

#player-overlay.hidden {
    display: flex !important;
    transform: translateY(100%);
    pointer-events: none;
}

#player-bg {
    position: absolute;
    inset: 0;
    background: var(--player-grad);
    z-index: -1;
    transition: background 0.6s var(--ease-out);
    overflow: hidden;
}

#player-bg::before,
#player-bg::after {
    content: "";
    position: absolute;
    inset: -40%;
    pointer-events: none;
    filter: blur(80px);
    will-change: transform;
}

#player-bg::before {
    background:
        radial-gradient(42% 42% at 30% 30%, rgba(var(--player-tint), 1), transparent 60%),
        radial-gradient(36% 36% at 75% 65%, rgba(255,255,255,0.22), transparent 65%),
        radial-gradient(30% 30% at 15% 85%, rgba(var(--player-tint), 0.9), transparent 60%);
    animation: player-bg-drift-a 14s var(--ease-in-out) infinite alternate;
}

#player-bg::after {
    background:
        radial-gradient(48% 48% at 70% 20%, rgba(var(--player-tint), 0.95), transparent 60%),
        radial-gradient(34% 34% at 25% 75%, rgba(255,255,255,0.18), transparent 65%),
        radial-gradient(32% 32% at 85% 85%, rgba(var(--player-tint), 0.8), transparent 60%);
    animation: player-bg-drift-b 18s var(--ease-in-out) infinite alternate;
    mix-blend-mode: screen;
}

@keyframes player-bg-drift-a {
    0%   { transform: translate(-8%, -6%) scale(1) rotate(0deg); }
    50%  { transform: translate(10%, 4%) scale(1.25) rotate(15deg); }
    100% { transform: translate(6%, 12%) scale(1.15) rotate(-10deg); }
}

@keyframes player-bg-drift-b {
    0%   { transform: translate(8%, 6%) scale(1.2) rotate(0deg); }
    50%  { transform: translate(-10%, -8%) scale(1) rotate(-18deg); }
    100% { transform: translate(-4%, 10%) scale(1.3) rotate(12deg); }
}

@media (prefers-reduced-motion: reduce) {
    #player-bg::before,
    #player-bg::after { animation: none; }
}

#player-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px 24px 24px;
    overflow: hidden;
}

#player-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0 12px;
}

#player-header .icon-btn {
    color: var(--text);
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
#player-header .icon-btn:hover { background: rgba(255,255,255,0.15); }

#player-source {
    flex: 1;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255,255,255,0.7);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Artwork */
#player-artwork-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
    min-height: 0;
    touch-action: pan-y;
}

#vinyl-stage {
    position: relative;
    width: 85vw;
    max-width: 380px;
    aspect-ratio: 1;
}

#vinyl-disc {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #1f1f1f 0%, #0a0a0a 55%, #050505 100%);
    box-shadow:
        0 24px 60px rgba(0,0,0,0.6),
        inset 0 0 0 2px rgba(255,255,255,0.04),
        inset 0 -4px 20px rgba(0,0,0,0.5);
    cursor: pointer;
    animation: vinyl-spin 8s linear infinite;
    animation-play-state: paused;
    will-change: transform;
}
#vinyl-disc.spinning { animation-play-state: running; }

.vinyl-grooves {
    position: absolute;
    inset: 6%;
    border-radius: 50%;
    pointer-events: none;
    background: repeating-radial-gradient(
        circle at center,
        rgba(255,255,255,0.04) 0 1px,
        transparent 1px 4px
    );
    -webkit-mask-image: radial-gradient(circle, transparent 38%, #000 41%);
    mask-image: radial-gradient(circle, transparent 38%, #000 41%);
}

.vinyl-shine {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    background: conic-gradient(
        from 0deg,
        rgba(255,255,255,0.08), transparent 30%, transparent 70%, rgba(255,255,255,0.06)
    );
    mix-blend-mode: screen;
}

.vinyl-spindle {
    position: absolute;
    width: 8px;
    height: 8px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, #d4d4d4, #6a6a6a);
    z-index: 2;
    pointer-events: none;
}

#player-artwork {
    position: absolute;
    width: 38%;
    height: 38%;
    top: 31%;
    left: 31%;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.08), 0 4px 12px rgba(0,0,0,0.4);
    z-index: 1;
    transition: opacity 0.2s;
    pointer-events: none;
}

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

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

/* Tonearm */
#tonearm {
    position: absolute;
    top: -15%;
    right: -5%;
    width: 65%;
    height: 80%;
    pointer-events: none;
    z-index: 3;
}

.tonearm-base {
    position: absolute;
    top: 4%;
    right: 6%;
    width: 18%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #d4d4d4, #4a4a4a);
    box-shadow: 0 3px 8px rgba(0,0,0,0.5), inset 0 0 0 2px rgba(255,255,255,0.08);
    z-index: 2;
}
.tonearm-base::after {
    content: "";
    position: absolute;
    inset: 30%;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #6a6a6a, #2a2a2a);
}

.tonearm-arm {
    position: absolute;
    top: 11%;
    right: 13%;
    width: 70%;
    height: 6px;
    background: linear-gradient(90deg, #d4d4d4, #8a8a8a 60%, #5a5a5a);
    border-radius: 3px;
    transform-origin: 100% 50%;
    transform: rotate(-45deg);
    transition: transform 600ms cubic-bezier(.25,.8,.4,1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.tonearm-head {
    position: absolute;
    left: -2px;
    top: -14px;
    width: 18px;
    height: 28px;
    background: linear-gradient(180deg, #2a2a2a, #1a1a1a);
    border-radius: 3px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.tonearm-head::after {
    content: "";
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 6px;
    background: #888;
    border-radius: 0 0 2px 2px;
}

#vinyl-stage.paused .tonearm-arm {
    transform: rotate(-3deg);
}

@media (prefers-reduced-motion: reduce) {
    #vinyl-disc { animation: none; }
    .tonearm-arm { transition: none; }
}

.album-art-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.4);
}

.mesh-bg {
    background:
        radial-gradient(40% 50% at 20% 30%, #14b8a6 0%, transparent 50%),
        radial-gradient(45% 55% at 80% 40%, #0ea5e9 0%, transparent 55%),
        radial-gradient(50% 60% at 50% 80%, #0d9488 0%, transparent 55%),
        linear-gradient(135deg, #0a1f1e 0%, #0e1f2a 100%);
    background-size: 200% 200%;
    animation: mesh-drift 16s ease-in-out infinite;
}

@keyframes mesh-drift {
    0%, 100% { background-position: 0% 0%, 100% 0%, 50% 100%, 0 0; }
    50% { background-position: 100% 50%, 0% 50%, 50% 0%, 0 0; }
}

/* Song info + marquee */
#player-song-info {
    text-align: center;
    margin-bottom: 20px;
    padding: 0 8px;
}

.marquee-wrap {
    overflow: hidden;
    white-space: nowrap;
    position: relative;
}

#player-title {
    font-size: clamp(1.05rem, 4.2vw, 1.4rem);
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
    white-space: nowrap;
    display: inline-block;
    padding-right: 2em;
}

#player-title.marquee {
    animation: marquee-scroll 14s linear infinite;
}

@keyframes marquee-scroll {
    0%, 10% { transform: translateX(0); }
    90%, 100% { transform: translateX(var(--marquee-distance, -50%)); }
}

#player-artist {
    font-size: clamp(0.82rem, 2.8vw, 0.95rem);
    color: rgba(255,255,255,0.75);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Waveform */
#player-progress {
    margin: 8px 0 12px;
    padding: 0 4px;
}

.waveform-wrap {
    position: relative;
    height: 56px;
    width: 100%;
    cursor: pointer;
    touch-action: pan-y;
}

#waveform-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.time-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.7);
    margin-top: 4px;
    padding: 0 2px;
    font-variant-numeric: tabular-nums;
}

/* Player controls */
#player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.ctrl-btn {
    width: 52px;
    height: 52px;
    min-height: 52px;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, transform 0.1s;
}

.ctrl-btn:hover { background: rgba(255,255,255,0.1); }
.ctrl-btn:active { transform: scale(0.92); }
.ctrl-btn.active { color: var(--accent); }
.ctrl-btn.active svg { filter: drop-shadow(0 0 8px var(--accent-glow)); }

.ctrl-btn.primary {
    width: 72px;
    height: 72px;
    min-height: 72px;
    background: #fff;
    color: #000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.ctrl-btn.primary:hover { background: rgba(255,255,255,0.9); transform: scale(1.03); }
.ctrl-btn.primary:active { transform: scale(0.95); }

/* Extra controls (±10s + queue) */
#player-extra-controls {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 16px;
    margin-top: 4px;
}

#player-extra-controls .icon-btn {
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    width: 44px;
    height: 44px;
    border-radius: 14px;
    transition: background 0.2s ease, color 0.2s ease;
}
#player-extra-controls .icon-btn:hover { background: rgba(255,255,255,0.15); }
#player-extra-controls .icon-btn.active {
    background: rgba(255,255,255,0.22);
    color: #fff;
}

/* =========================================================================
   LYRICS PANEL (full player)
   - Occupies the artwork slot when `#player-content.showing-lyrics` is set.
   - Header, song info, progress, and controls stay visible unchanged.
   ========================================================================= */
#lyrics-panel {
    display: none;
    flex: 1;
    min-height: 0;
    position: relative;
    padding: 8px 0 12px;
    overflow: hidden;
    touch-action: pan-y;
}

#player-content.showing-lyrics #player-artwork-wrap {
    display: none;
}

#player-content.showing-lyrics #lyrics-panel {
    display: flex;
    flex-direction: column;
}

#lyrics-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0 8px;
    scroll-behavior: smooth;
    mask-image: linear-gradient(
        to bottom,
        transparent 0%, #000 18%, #000 82%, transparent 100%
    );
    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0%, #000 18%, #000 82%, transparent 100%
    );
}

#lyrics-list::-webkit-scrollbar { width: 0; height: 0; }

#lyrics-list .lyrics-spacer {
    height: 40%;
    min-height: 80px;
    flex-shrink: 0;
}

#lyrics-list.plain-only {
    mask-image: none;
    -webkit-mask-image: none;
}

.lyrics-line {
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    color: rgba(255,255,255,0.35);
    padding: 10px 14px;
    border-radius: 12px;
    transition: color 0.25s ease, transform 0.25s ease, background 0.2s ease, opacity 0.25s ease;
    cursor: pointer;
    letter-spacing: -0.01em;
    text-shadow: 0 1px 6px rgba(0,0,0,0.25);
    word-break: break-word;
    hyphens: auto;
}

.lyrics-line.past { color: rgba(255,255,255,0.3); }
.lyrics-line.upcoming { color: rgba(255,255,255,0.5); }
.lyrics-line.active {
    color: #fff;
    transform: scale(1.04);
    text-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.lyrics-line:hover { background: rgba(255,255,255,0.06); }
.lyrics-line:active { background: rgba(255,255,255,0.12); }

.lyrics-line.plain {
    font-size: 1.1rem;
    font-weight: 500;
    color: rgba(255,255,255,0.82);
    cursor: default;
    text-align: center;
    padding: 4px 14px;
    transform: none;
}
.lyrics-line.plain:hover { background: transparent; }

#lyrics-status {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: rgba(255,255,255,0.7);
    font-size: 0.98rem;
    text-align: center;
}

.lyrics-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lyrics-empty-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: rgba(255,255,255,0.95);
}
.lyrics-empty-sub {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.65);
    max-width: 280px;
    line-height: 1.4;
}

.lyrics-retry {
    margin-top: 4px;
    padding: 8px 18px;
    border-radius: 999px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-weight: 600;
    border: none;
    cursor: pointer;
}
.lyrics-retry:hover { background: rgba(255,255,255,0.25); }

@media (prefers-reduced-motion: reduce) {
    #lyrics-list { scroll-behavior: auto; }
    .lyrics-line { transition: none; }
}

/* =========================================================================
   QUEUE PANEL
   ========================================================================= */
#queue-overlay,
#modal-overlay,
#error-modal-overlay,
#action-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: overlay-fade 0.22s var(--ease-out);
}

@keyframes overlay-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

#queue-panel, #action-sheet, .modal {
    background: var(--surface);
    width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
    animation: slideUp 0.28s var(--ease-spring);
    padding-bottom: env(safe-area-inset-bottom);
}

#queue-panel {
    max-height: 75vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 10px auto 4px;
}

.queue-header {
    padding: 4px 18px 14px;
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 2;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.queue-header-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.queue-header-top h3 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    flex: 1;
}

.queue-header-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-3);
    margin-top: 2px;
    min-height: 1.1em;
}

.queue-header-meta > span + span:not([hidden])::before {
    content: "·";
    margin-right: 8px;
    opacity: 0.6;
}

.queue-header-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.queue-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface-2);
    color: var(--text-2);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    min-height: 32px;
    transition: background 0.15s var(--ease-out), color 0.15s var(--ease-out), opacity 0.15s;
}
.queue-action-btn:hover:not(:disabled) {
    background: var(--surface-3);
    color: var(--text);
}
.queue-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.queue-action-btn.active {
    background: rgba(20,184,166,0.18);
    color: var(--accent);
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    margin: 2px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.12s;
    position: relative;
}

.queue-item:hover { background: rgba(255,255,255,0.04); }

.queue-item.now-playing {
    background: linear-gradient(90deg, rgba(20,184,166,0.18), rgba(20,184,166,0.04));
}

.queue-item.dragging { opacity: 0.45; }
.queue-item.drag-over-top { box-shadow: inset 0 2px 0 0 var(--accent); }
.queue-item.drag-over-bottom { box-shadow: inset 0 -2px 0 0 var(--accent); }

.queue-drag-handle {
    cursor: grab;
    color: var(--text-3);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 2px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.queue-item:hover .queue-drag-handle { opacity: 0.8; }
.queue-drag-handle:hover { color: var(--text); }
.queue-drag-handle:active { cursor: grabbing; }
.queue-item.dragging .queue-drag-handle { opacity: 1; color: var(--accent); }

.queue-thumb {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--surface-2);
}

.queue-thumb-placeholder {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    background: linear-gradient(135deg, #134e4a, #0c3a4a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.3);
}

.queue-item-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    padding: 2px 0;
}

.queue-item-title {
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.queue-item-title-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-item.now-playing .queue-item-title { color: var(--accent); font-weight: 600; }

.queue-item-sub {
    font-size: 0.74rem;
    color: var(--text-3);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.queue-remove-btn {
    width: 32px;
    height: 32px;
    min-height: 32px;
    min-width: 32px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-3);
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.queue-item:hover .queue-remove-btn { opacity: 0.8; }
.queue-remove-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); opacity: 1; }
.queue-remove-btn:focus-visible { opacity: 1; }

.queue-now-tag {
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    background: rgba(20,184,166,0.18);
    padding: 4px 9px;
    border-radius: 999px;
    white-space: nowrap;
    display: none;
    flex-shrink: 0;
}
.queue-item.now-playing .queue-now-tag { display: inline-flex; align-items: center; }
.queue-item.now-playing .queue-remove-btn { display: none; }

.queue-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 56px 20px 40px;
    text-align: center;
    gap: 10px;
}
.queue-empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    margin-bottom: 4px;
}
.queue-empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}
.queue-empty-sub {
    font-size: 0.85rem;
    color: var(--text-3);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================================================
   ACTION SHEET
   ========================================================================= */
#action-sheet-header {
    padding: 0 20px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

#action-sheet-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#action-sheet-subtitle {
    font-size: 0.75rem;
    color: var(--text-3);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#action-sheet-actions {
    padding: 8px 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#action-sheet-actions button {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 13px 14px;
    min-height: 50px;
    background: transparent;
    color: var(--text);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
}

#action-sheet-actions button:hover { background: var(--surface-2); }
#action-sheet-actions button.danger-text { color: var(--err); }
#action-sheet-actions button.danger-text:hover { background: rgba(248,113,113,0.1); }

/* =========================================================================
   MODAL
   ========================================================================= */
.modal {
    padding: 0 20px 20px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0 14px;
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.modal-close {
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 1.3rem;
    width: 34px;
    height: 34px;
    min-height: 34px;
    min-width: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.modal-close:hover { background: var(--surface-3); color: var(--text); }

.modal input { width: 100%; margin-bottom: 14px; }

.modal-actions { display: flex; gap: 8px; }
.modal-actions button { flex: 1; }

.error-modal-body {
    background: var(--surface-2);
    color: var(--err);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
    margin: 0 0 14px;
    font-family: "SF Mono", Menlo, Consolas, monospace;
}

/* =========================================================================
   MORE SCREEN
   ========================================================================= */
.more-list {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}

.more-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    min-height: 54px;
    background: transparent;
    color: var(--text);
    border-radius: 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
}

.more-item:last-child { border-bottom: none; }
.more-item:hover { background: var(--surface-2); }
.more-item span { flex: 1; }
.more-item .chevron { color: var(--text-3); }

/* iOS-style toggle switch used in More menu (theme toggle, etc.).
   Selectors are scoped under .more-item to outweigh `.more-item span { flex:1 }`. */
.more-item .toggle-switch {
    flex: none;
    position: relative;
    display: block;
    width: 44px;
    height: 26px;
    background: var(--surface-3);
    border-radius: 999px;
    transition: background-color 220ms var(--ease-out);
}
.more-item .toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2), 0 1px 1px rgba(0,0,0,0.1);
    transition: transform 220ms var(--ease-spring);
}
.more-toggle[aria-checked="true"] .toggle-switch { background: var(--accent); }
.more-toggle[aria-checked="true"] .toggle-thumb { transform: translateX(18px); }

.more-about { padding: 24px 16px; text-align: center; }

/* =========================================================================
   DISCOVER SHELVES / SEARCH song rows (densified)
   ========================================================================= */
.region {
    margin-bottom: 10px;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}

.shelf-header {
    padding: 12px 16px 8px;
    background: var(--surface);
    user-select: none;
}

.shelf-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 28px;
}

.shelf-title-row h2 {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shelf-subtitle {
    margin-top: 2px;
    font-size: 0.74rem;
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shelf-kind-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: rgba(96,165,250,0.14);
    color: #93c5fd;
    flex-shrink: 0;
}

.shelf-kind-chip.shelf-kind-quickpicks { background: rgba(52,211,153,0.16); color: #6ee7b7; }
.shelf-kind-chip.shelf-kind-personal   { background: rgba(192,132,252,0.16); color: #c4b5fd; }
.shelf-kind-chip.shelf-kind-home       { background: rgba(251,191,36,0.16); color: #fcd34d; }
.shelf-kind-chip.shelf-kind-library    { background: rgba(96,165,250,0.16); color: #93c5fd; }
.shelf-kind-chip.shelf-kind-radio_seed { background: rgba(244,114,182,0.16); color: #f9a8d4; }
.shelf-kind-chip.shelf-kind-charts     { background: rgba(34,197,94,0.16); color: #86efac; }
.shelf-kind-chip.shelf-kind-hero       { background: rgba(250,204,21,0.16); color: #fde047; }
.shelf-kind-chip.shelf-kind-artists    { background: rgba(167,139,250,0.16); color: #c4b5fd; }
.shelf-kind-chip.shelf-kind-albums     { background: rgba(244,114,182,0.16); color: #f9a8d4; }

.region-body.collapsed { display: none; }

.song-row {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    grid-template-rows: auto auto;
    gap: 3px 10px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-size: 0.88rem;
    align-items: center;
}

.song-row:has(> input[type="checkbox"]) {
    grid-template-columns: 24px 48px 1fr auto;
}

.song-row:active { background: var(--surface-2); }
.song-row:last-child { border-bottom: none; }

.song-row > input[type="checkbox"] {
    grid-row: 1 / 3;
    grid-column: 1;
    align-self: center;
}

.song-thumb {
    grid-row: 1 / 3;
    grid-column: 1;
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.song-row:has(> input[type="checkbox"]) > .song-thumb { grid-column: 2; }

.song-info {
    grid-row: 1;
    grid-column: 2;
    min-width: 0;
}
.song-row:has(> input[type="checkbox"]) > .song-info { grid-column: 3; }

.song-title {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}

.song-artist {
    color: var(--text-3);
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-row > .song-artist { display: none; }
.song-duration { display: none; }

.song-badge-col {
    grid-row: 1;
    grid-column: 3;
    text-align: right;
}
.song-row:has(> input[type="checkbox"]) > .song-badge-col { grid-column: 4; }

.song-actions {
    grid-row: 2;
    grid-column: 2 / 4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 3px;
}
.song-row:has(> input[type="checkbox"]) > .song-actions { grid-column: 3 / 5; }

.song-duration-mobile {
    color: var(--text-3);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.song-actions button.sm {
    padding: 7px 13px;
    min-height: 34px;
    font-size: 0.78rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
    white-space: nowrap;
}

.badge-new { background: rgba(20,184,166,0.18); color: #5eead4; }
.badge-exists { background: rgba(251,191,36,0.15); color: #fcd34d; }
.badge-queued { background: rgba(96,165,250,0.12); color: #93c5fd; }
.badge-downloading { background: rgba(96,165,250,0.18); color: #93c5fd; animation: badge-pulse 1.4s ease-in-out infinite; }
.badge-done { background: rgba(52,211,153,0.15); color: #86efac; }
.badge-error { background: rgba(248,113,113,0.18); color: #fca5a5; }
.badge-clickable { cursor: pointer; text-decoration: underline; }
.badge-clickable:hover { filter: brightness(1.3); }

@keyframes badge-pulse {
    0%, 100% { background: rgba(96,165,250,0.18); }
    50%      { background: rgba(96,165,250,0.42); }
}

/* Progress bar */
#progress-bar-container {
    margin-bottom: 14px;
    padding: 12px 14px;
    background: var(--surface);
    border-radius: var(--radius);
}

#progress-info { font-size: 0.82rem; color: var(--text-2); margin-bottom: 8px; }

.progress-track {
    height: 6px;
    background: var(--surface-3);
    border-radius: 3px;
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 3px;
}

/* Search input group */
.search-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.search-input-group .search-field { flex: 1; width: 100%; }

.search-input-group button {
    width: 100%;
    padding: 12px 18px;
}

#csv-selection-count {
    font-size: 0.82rem;
    color: var(--text-3);
    text-align: center;
}

#search-results {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}

#yt-search-cta {
    margin-top: 12px;
}

.yt-search-cta-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: var(--surface);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.yt-search-cta-btn:hover { background: var(--surface-2); }
.yt-search-cta-btn:active { background: var(--surface-3); }
.yt-search-cta-btn:disabled { opacity: 0.6; cursor: default; }
.yt-search-cta-btn .search-icon { color: var(--accent); flex-shrink: 0; }
.yt-search-cta-btn > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

#yt-search-section {
    margin-top: 16px;
}

.section-divider {
    padding: 12px 4px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: 4px;
}

/* Tables (History) */
table { width: 100%; border-collapse: collapse; }

thead { display: none; }

tbody tr {
    display: block;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: var(--surface);
    border-radius: var(--radius);
}

td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 0.88rem;
    border: none;
    gap: 10px;
}

td::before {
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-width: 82px;
    flex-shrink: 0;
}

td[data-label=""] {
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px solid rgba(255,255,255,0.04);
}

td[data-label=""]::before { display: none; }

/* =========================================================================
   PROFILE PICKER
   ========================================================================= */
#profile-picker-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 24px;
}

.profile-picker {
    text-align: center;
    width: 100%;
    max-width: 360px;
}

.pp-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.pp-brand-logo {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background:
        radial-gradient(50% 50% at 30% 30%, #14b8a6 0%, transparent 60%),
        radial-gradient(50% 50% at 70% 70%, #0ea5e9 0%, transparent 60%),
        linear-gradient(135deg, #134e4a 0%, #0c3a4a 100%);
    box-shadow: 0 8px 32px rgba(20, 184, 166, 0.3);
}

.pp-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.profile-picker h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    color: var(--text);
    font-weight: 700;
    letter-spacing: -0.01em;
}

#profile-name-form,
#profile-pin-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#profile-name-form.hidden,
#profile-pin-form.hidden {
    display: none;
}

#profile-name-input,
#profile-pin-input {
    padding: 14px 18px;
    font-size: 1.05rem;
    background: var(--surface);
    border: 2px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s;
}

#profile-pin-input {
    text-align: center;
    letter-spacing: 0.4em;
    font-size: 1.4rem;
}

#profile-name-input:focus,
#profile-pin-input:focus { border-color: var(--accent); }

.profile-pin-error {
    color: #ef4444;
    font-size: 0.85rem;
    margin: 4px 0 0;
    min-height: 1.1em;
}

.profile-pin-error.hidden { display: none; }

.profile-link-btn {
    background: none;
    border: 0;
    color: var(--accent);
    font-size: 0.9rem;
    margin-top: 4px;
    padding: 8px;
    cursor: pointer;
}

.profile-link-btn:hover { text-decoration: underline; }

.profile-pick-btn {
    padding: 14px 32px;
    font-size: 1.05rem;
    background: var(--accent);
    border: none;
    color: #fff;
    border-radius: var(--radius);
    cursor: pointer;
    min-height: 52px;
    font-weight: 700;
    box-shadow: 0 4px 16px var(--accent-glow);
}

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

.profile-picker-hint {
    font-size: 0.78rem;
    color: var(--text-3);
    margin: 2px 0 0;
}

/* Profile Badge */
.profile-badge {
    font-size: 0.72rem;
    color: var(--accent);
    padding: 3px 9px;
    background: var(--accent-glow);
    border-radius: 99px;
    font-weight: 600;
    white-space: nowrap;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-badge:empty { display: none; }

/* =========================================================================
   TOAST
   ========================================================================= */
#toast {
    position: fixed;
    bottom: calc(var(--nav-h) + 20px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--surface-3);
    color: var(--text);
    padding: 10px 18px;
    border-radius: 99px;
    font-size: 0.82rem;
    font-weight: 500;
    z-index: 300;
    box-shadow: var(--shadow);
    opacity: 0;
    transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
    pointer-events: none;
}

body.has-mini-player #toast {
    bottom: calc(var(--nav-h) + var(--mini-h) + 20px);
}

#toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* =========================================================================
   DESKTOP / TABLET adjustments
   ========================================================================= */
@media (min-width: 600px) {
    .toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    .toolbar button,
    .toolbar > input { width: auto; }
    .toolbar .search-field { flex: 1; min-width: 240px; }
    .toolbar .song-list-toggle { width: auto; }

    #queue-overlay, #modal-overlay, #error-modal-overlay, #action-sheet-overlay { align-items: center; }

    #queue-panel, #action-sheet, .modal {
        max-width: 500px;
        max-height: 80vh;
        border-radius: var(--radius-xl);
        animation: fadeIn 0.22s var(--ease-out);
    }

    .sheet-handle { display: none; }

    .modal-actions button { flex: none; padding: 10px 20px; }
}

@media (min-width: 900px) {
    body {
        max-width: none;
    }

    #app-main { padding: 20px 32px; }

    /* Song rows: full desktop layout */
    .song-row {
        grid-template-columns: 28px 50px 1fr 140px 60px 90px 90px;
        grid-template-rows: auto;
        gap: 10px;
        padding: 8px 14px;
    }

    .song-row:hover { background: var(--surface-2); }
    .song-row > input[type="checkbox"] { grid-row: auto; grid-column: auto; }

    .song-thumb {
        grid-row: auto;
        grid-column: auto;
        width: 50px;
        height: 38px;
        border-radius: var(--radius-sm);
    }

    .song-info { grid-row: auto; grid-column: auto; }
    .song-row > .song-artist { display: block; }
    .song-duration { display: block; color: var(--text-3); text-align: center; }

    .song-badge-col { grid-row: auto; grid-column: auto; text-align: center; }

    .song-actions {
        grid-row: auto;
        grid-column: auto;
        justify-content: flex-end;
        padding-top: 0;
    }

    .song-duration-mobile { display: none; }

    /* Tables: standard layout */
    thead { display: table-header-group; }

    tbody tr {
        display: table-row;
        padding: 0;
        margin: 0;
        background: transparent;
        border-radius: 0;
    }

    td {
        display: table-cell;
        padding: 10px 14px;
        border-bottom: 1px solid rgba(255,255,255,0.04);
        font-size: 0.85rem;
    }

    td::before { display: none; }
    td[data-label=""] { padding-top: 10px; margin-top: 0; border-top: none; }

    th {
        padding: 10px 14px;
        background: var(--surface);
        color: var(--text-3);
        font-weight: 600;
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        border-bottom: 1px solid rgba(255,255,255,0.04);
        text-align: left;
    }

    .queue-drag-handle { display: flex; }

    /* Bigger player artwork on desktop */
    #vinyl-stage { max-width: 420px; }
    #player-content { padding: 16px 40px 32px; max-width: 640px; margin: 0 auto; }
}

/* Mobile queue polish: bigger touch targets, drag handle on right, more breathing room */
@media (max-width: 899px) {
    .queue-item:hover { background: transparent; }
    .queue-drag-handle { opacity: 0.6; padding: 10px 8px; }
    .queue-item .queue-drag-handle { opacity: 0.6; }
    .queue-drag-handle svg { width: 20px; height: 20px; }

    .sheet-handle { width: 44px; height: 5px; margin: 10px auto 2px; }

    #queue-panel { max-height: 88vh; }

    .queue-header { padding: 6px 18px 14px; }
    .queue-header-top h3 { font-size: 1.25rem; }
    .queue-header-top .modal-close {
        width: 40px; height: 40px; min-width: 40px; min-height: 40px;
        border-radius: 50%;
        background: var(--surface-2);
    }
    .queue-header-meta { font-size: 0.82rem; margin-top: 4px; }
    .queue-header-actions { margin-top: 14px; gap: 10px; }
    .queue-action-btn {
        min-height: 40px;
        padding: 8px 16px;
        font-size: 0.88rem;
        flex: 1;
        justify-content: center;
    }

    .queue-item {
        padding: 12px 6px 12px 14px;
        gap: 14px;
        margin: 2px 6px;
    }

    .queue-thumb,
    .queue-thumb-placeholder {
        width: 52px;
        height: 52px;
        border-radius: 10px;
    }

    .queue-item-title { font-size: 0.96rem; }
    .queue-item-sub { font-size: 0.78rem; margin-top: 4px; }

    .queue-item-actions { gap: 2px; }

    .queue-remove-btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        opacity: 0.8;
        color: var(--text-2);
    }
    .queue-remove-btn svg { width: 16px; height: 16px; }

    .queue-item.now-playing {
        background: linear-gradient(90deg, rgba(20,184,166,0.22), rgba(20,184,166,0.04));
        box-shadow: inset 2px 0 0 0 var(--accent);
    }

    .queue-now-tag {
        padding: 5px 10px;
        font-size: 0.62rem;
    }

    .queue-empty { padding: 72px 20px 48px; }
    .queue-empty-icon { width: 84px; height: 84px; }
    .queue-empty-icon svg { width: 52px; height: 52px; }
    .queue-empty-title { font-size: 1.1rem; }
    .queue-empty-sub { font-size: 0.9rem; }
}

/* =========================================================================
   SMALL-PHONE & SHORT-VIEWPORT POLISH
   Tighten the player overlay so controls don't get pushed off-screen.
   ========================================================================= */
@media (max-width: 360px) {
    #player-content { padding: 8px 14px 18px; }
    #player-song-info { margin-bottom: 14px; padding: 0 4px; }
    .ctrl-btn { width: 48px; height: 48px; min-height: 48px; }
    #player-controls { gap: 6px; margin-bottom: 14px; }
    #player-extra-controls { padding: 0 8px; }
    #player-extra-controls .icon-btn { width: 42px; height: 42px; min-width: 42px; min-height: 42px; }
    #mini-player-content { gap: 8px; }
}

@media (max-height: 640px) {
    #vinyl-stage { max-height: 38vh; max-width: 38vh; }
    #player-artwork-wrap { padding: 8px 0; }
    #player-song-info { margin-bottom: 12px; }
    #player-progress { margin-bottom: 10px; }
    #player-controls { margin-bottom: 12px; }
}

/* =========================================================================
   LANDSCAPE: 2-column player layout for short, wide viewports.
   Artwork (or lyrics) on the left, info + controls stacked on the right.
   ========================================================================= */
@media (orientation: landscape) and (max-height: 500px) {
    #player-content {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
        column-gap: 20px;
        padding: 6px 16px 12px;
        overflow: hidden;
        align-content: start;
    }
    #player-header {
        grid-column: 1 / -1;
        padding: 4px 0;
    }
    #player-artwork-wrap {
        grid-column: 1;
        grid-row: 2 / span 4;
        padding: 0;
        align-self: stretch;
        min-height: 0;
    }
    #vinyl-stage {
        width: auto;
        height: 100%;
        max-height: 100%;
        max-width: 100%;
        aspect-ratio: 1;
    }
    #lyrics-panel { grid-column: 1; grid-row: 2 / span 4; }
    #player-song-info {
        grid-column: 2;
        grid-row: 2;
        margin: 0 0 8px;
        padding: 0;
        text-align: left;
    }
    #player-progress {
        grid-column: 2;
        grid-row: 3;
        padding: 0;
        margin: 0 0 4px;
    }
    #player-controls {
        grid-column: 2;
        grid-row: 4;
        margin: 0 0 6px;
        gap: 6px;
    }
    #player-extra-controls {
        grid-column: 2;
        grid-row: 5;
        margin: 0;
        padding: 0;
    }
    .ctrl-btn { width: 44px; height: 44px; min-height: 44px; }
    .ctrl-btn.primary { width: 56px; height: 56px; min-height: 56px; }
}

/* =============================================================
   STATS — Top Tracks / Top Artists / Dashboard / Library badges
   ============================================================= */
.meta-plays {
    color: var(--text-2);
}

.period-toolbar { padding: 8px 12px 0; }
.period-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.period-tabs::-webkit-scrollbar { display: none; }
.period-tab {
    flex-shrink: 0;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-2);
    border: 1px solid transparent;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.period-tab.active {
    background: var(--accent);
    color: #06241f;
}

.rank-list {
    display: flex;
    flex-direction: column;
    padding: 8px 0 96px;
}
.rank-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
}
.rank-row:hover { background: var(--surface); }
.rank-num {
    width: 28px;
    text-align: right;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
    font-size: 0.95rem;
}
.rank-thumb {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--surface-2);
    flex-shrink: 0;
}
.rank-thumb-text {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    color: var(--accent);
    font-weight: 700;
    font-size: 1.1rem;
}
.rank-info { min-width: 0; flex: 1; }
.rank-title {
    font-size: 0.95rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rank-meta {
    font-size: 0.78rem;
    color: var(--text-3);
    margin-top: 2px;
}

/* Dashboard cards */
.dash-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 12px;
}
.dash-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 12px;
    text-align: center;
}
.dash-card-label {
    font-size: 0.72rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.dash-card-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

.dash-section {
    padding: 8px 14px 18px;
}
.dash-section h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-2);
    margin: 8px 0 10px;
}

/* Bar chart (top artists) */
.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.bar-row {
    display: grid;
    grid-template-columns: 90px 1fr 36px;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}
.bar-label {
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bar-track {
    height: 10px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-2), var(--accent));
    border-radius: 999px;
    transition: width 0.3s var(--ease-out);
}
.bar-value {
    text-align: right;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

/* Heatmap */
.heatmap {
    display: flex;
    gap: 3px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0 8px;
}
.heatmap::-webkit-scrollbar { height: 4px; }
.heatmap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
.hm-col {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex-shrink: 0;
}
.hm-cell {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: var(--surface-2);
}
.hm-l0 { background: var(--surface-2); }
.hm-l1 { background: rgba(20, 184, 166, 0.25); }
.hm-l2 { background: rgba(20, 184, 166, 0.5); }
.hm-l3 { background: rgba(20, 184, 166, 0.75); }
.hm-l4 { background: var(--accent); }
.hm-out { visibility: hidden; }

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--text-3);
}
.heatmap-legend .hm-cell { width: 10px; height: 10px; }

/* =========================================================================
   DISCOVER: filter chips + horizontal card carousels
   ========================================================================= */

.discover-filters {
    display: flex;
    gap: 8px;
    padding: 4px 12px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-snap-type: x proximity;
}

.discover-filters::-webkit-scrollbar { display: none; }

.filter-chip {
    flex-shrink: 0;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    background: var(--surface);
    color: var(--text-2);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    scroll-snap-align: start;
    white-space: nowrap;
    min-height: 34px;
}

.filter-chip:hover { background: var(--surface-2); }

.filter-chip.active {
    background: var(--text);
    color: var(--bg, #08060c);
    border-color: var(--text);
}

/* Horizontal card carousel inside a shelf. Horizontal gutters are pseudo-
   element spacers rather than container padding because Chromium/WebKit
   clip flex-container padding once the row overflows. */
.shelf-cards {
    display: flex;
    gap: 12px;
    padding: 4px 0 14px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    scroll-padding-inline: 16px;
    -webkit-overflow-scrolling: touch;
}

.shelf-cards::before,
.shelf-cards::after {
    content: "";
    flex: 0 0 16px;
    align-self: stretch;
}

.shelf-cards::-webkit-scrollbar { height: 6px; }
.shelf-cards::-webkit-scrollbar-track { background: transparent; }
.shelf-cards::-webkit-scrollbar-thumb {
    background: var(--surface-2);
    border-radius: 3px;
}

.song-card {
    flex: 0 0 120px;
    width: 120px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-snap-align: start;
    background: transparent;
}

.card-thumb-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-2);
}

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

.card-thumb-empty {
    background: linear-gradient(135deg, var(--surface-2), var(--surface-3, var(--surface-2)));
}

.card-dl-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 30px;
    height: 30px;
    min-height: 0;
    padding: 0;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.card-dl-btn:hover { background: rgba(0,0,0,0.75); }
.card-dl-btn:active { transform: scale(0.92); }
.card-dl-btn svg { width: 16px; height: 16px; }

.card-play-btn {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    min-height: 0;
    padding: 0;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
    pointer-events: none;
}

.discover-card .card-thumb-wrap:hover .card-play-btn,
.discover-card .card-thumb-wrap:focus-within .card-play-btn {
    opacity: 1;
    pointer-events: auto;
}

.card-play-btn:hover { background: rgba(0,0,0,0.75); }
.card-play-btn:active { transform: translate(-50%, -50%) scale(0.92); }

@media (hover: none) {
    .card-play-btn {
        opacity: 1;
        pointer-events: auto;
    }
}

.card-add-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 30px;
    height: 30px;
    min-height: 0;
    padding: 0;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.card-add-btn:hover { background: rgba(0,0,0,0.75); }
.card-add-btn:active { transform: scale(0.92); }
.card-add-btn svg { width: 16px; height: 16px; }

.discover-card .card-thumb-wrap { cursor: pointer; }
.discover-card .card-info { cursor: pointer; }

.card-badge-wrap {
    position: absolute;
    bottom: 6px;
    left: 6px;
    z-index: 1;
}

.card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 0 2px;
}

.card-title {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text);
    letter-spacing: -0.01em;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-artist {
    font-size: 0.74rem;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Quick picks: larger cards */
.quickpicks-row .song-card {
    flex-basis: 160px;
    width: 160px;
}

/* Skeleton placeholders for discover */
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3, var(--surface-2)) 40%, var(--surface-2) 80%);
    background-size: 200% 100%;
    animation: shimmer 1.6s infinite linear;
    border-radius: var(--radius-sm);
}

.shelf-skeleton .skeleton-line-title {
    width: 40%;
    height: 16px;
    border-radius: 4px;
}

.shelf-skeleton .skeleton-line-sub {
    width: 25%;
    height: 11px;
    border-radius: 4px;
    margin-top: 8px;
}

.skeleton-card .card-thumb-wrap {
    background: none;
}

.skeleton-card .skeleton-line-card {
    width: 80%;
    height: 11px;
    border-radius: 4px;
}

.skeleton-card .skeleton-line-card-sub {
    width: 55%;
    height: 9px;
    border-radius: 4px;
    margin-top: 6px;
}

/* Desktop / tablet card sizing */
@media (min-width: 600px) {
    .song-card { flex-basis: 140px; width: 140px; }
    .quickpicks-row .song-card { flex-basis: 180px; width: 180px; }
    .card-title { font-size: 0.86rem; }
    .card-artist { font-size: 0.76rem; }
}

@media (min-width: 900px) {
    .song-card { flex-basis: 150px; width: 150px; }
    .quickpicks-row .song-card { flex-basis: 200px; width: 200px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.05ms !important;
    }
    .mesh-bg { animation: none; }
    .eq-icon span { animation: none; height: 50%; }
}

/* =========================================================================
   DISCOVER: hero / artists / albums layouts (Phase 2)
   ========================================================================= */

/* Hero — full-bleed featured card */
.shelf-hero .hero-card {
    display: flex;
    flex-direction: row;
    gap: 14px;
    padding: 12px 16px 18px;
    cursor: pointer;
    align-items: center;
}

.hero-thumb-wrap {
    position: relative;
    flex: 0 0 120px;
    width: 120px;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface-2);
}

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

.hero-thumb-empty {
    background: linear-gradient(135deg, #4338ca, #ec4899);
}

.hero-play-btn {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    min-height: 0;
    padding: 0;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.hero-play-btn:hover { background: rgba(0,0,0,0.8); }
.hero-play-btn:active { transform: translate(-50%, -50%) scale(0.92); }

.hero-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.hero-blurb {
    font-size: 0.72rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hero-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-artist {
    font-size: 0.84rem;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (min-width: 600px) {
    .hero-thumb-wrap { flex-basis: 160px; width: 160px; }
    .hero-title { font-size: 1.4rem; }
}

/* Artists row — circular avatars */
.shelf-artists .artists-row {
    align-items: flex-start;
}

.artist-card {
    flex: 0 0 100px;
    width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    scroll-snap-align: start;
}

.artist-thumb-wrap {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--surface-2);
}

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

.artist-thumb-empty {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--surface-2), var(--surface-3, var(--surface-2)));
}

.artist-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

@media (min-width: 600px) {
    .artist-card { flex-basis: 120px; width: 120px; }
    .artist-thumb-wrap { width: 104px; height: 104px; }
}

/* Albums row — square tiles, slightly bigger than song cards */
.shelf-albums .albums-row {
    align-items: flex-start;
}

.album-card {
    flex: 0 0 140px;
    width: 140px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-snap-align: start;
    cursor: pointer;
}

.album-thumb-wrap {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-2);
}

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

.album-thumb-empty {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--surface-2), var(--surface-3, var(--surface-2)));
}

.album-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 0 2px;
}

.album-title {
    font-weight: 600;
    font-size: 0.84rem;
    color: var(--text);
    letter-spacing: -0.01em;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.album-artist {
    font-size: 0.74rem;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.album-year {
    font-size: 0.7rem;
    color: var(--text-3);
}

@media (min-width: 600px) {
    .album-card { flex-basis: 160px; width: 160px; }
}

/* Chart rank badge over song card thumb */
.card-rank-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 3px 7px;
    border-radius: 6px;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    z-index: 1;
}
