/* ============================================================
   James B. Pollack MUSIC ARCHIVE - IMMERSIVE LISTENING EXPERIENCE
   Theme: Deep space / Aurora / Bioluminescence
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Core palette */
    --bg-deep: #05050f;
    --bg-primary: #0a0a1a;
    --bg-secondary: #0f0f25;
    --bg-tertiary: #141432;
    --bg-card: #12122a;
    --bg-card-hover: #1a1a3a;
    --bg-surface: rgba(15, 15, 40, 0.85);

    /* Accent colors - aurora inspired */
    --accent-primary: #4af5c7;
    --accent-secondary: #7b68ee;
    --accent-tertiary: #ff6b9d;
    --accent-warm: #ffa64d;
    --accent-cool: #4dc9f6;
    --accent-dim: #4a9a7a;
    --track-select-accent: #35d6ff;
    --track-select-bg: rgba(53, 214, 255, 0.12);
    --track-select-border: rgba(53, 214, 255, 0.36);
    --track-select-glow: rgba(53, 214, 255, 0.2);

    /* Text */
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0c0;
    --text-tertiary: #8a8aaa;
    --text-accent: var(--accent-primary);

    /* Type scale */
    --font-size-xs: 0.7rem;
    --font-size-sm: 0.8rem;
    --font-size-base: 0.9rem;
    --font-size-md: 1rem;
    --font-size-lg: 1.15rem;
    --font-size-xl: 1.4rem;
    --font-size-2xl: 1.8rem;

    /* Spacing scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 0.75rem;
    --space-lg: 1rem;
    --space-xl: 1.5rem;
    --space-2xl: 2rem;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

    /* Mood palette */
    --mood-atmospheric: #5ec4e8;
    --mood-dreamy: #b07aef;
    --mood-hypnotic: #c97ae8;
    --mood-driving: #f0a040;
    --mood-intense: #f05858;
    --mood-dark: #6878cc;
    --mood-bright: #e8d44a;
    --mood-uplifting: #5ee088;
    --mood-melancholic: #5a8ed8;

    /* Glow effects */
    --glow-primary: rgba(74, 245, 199, 0.15);
    --glow-secondary: rgba(123, 104, 238, 0.15);
    --glow-strong: rgba(74, 245, 199, 0.3);

    /* Sizing */
    --header-height: 64px;
    --player-height: 90px;
    --sidebar-width: 260px;
    --border-radius: 10px;
    --border-radius-sm: 5px;
    --border-radius-lg: 14px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Z-layers */
    --z-bg: 0;
    --z-content: 1;
    --z-sidebar: 10;
    --z-header: 20;
    --z-player: 30;
    --z-overlay: 100;
    --z-loading: 200;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    overflow: hidden;
    height: 100dvh;
    width: 100%;
    text-rendering: optimizeLegibility;
    font-kerning: normal;
    font-feature-settings: "kern" 1, "liga" 1;
}

button, input, textarea, select {
    text-rendering: optimizeLegibility;
    font-kerning: normal;
    -webkit-font-smoothing: antialiased;
}

/* Focus management — visible ring for keyboard, hidden for mouse */
:focus {
    outline: none;
}
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}
button:focus-visible,
[role="option"]:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: -2px;
    border-radius: var(--border-radius-sm);
}

/* Selection */
::selection {
    background: rgba(74, 245, 199, 0.3);
    color: var(--text-primary);
}

/* Touch interaction */
button, a, [role="option"], [role="tab"], input[type="range"] {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Skip navigation link */
.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    z-index: 10000;
    padding: 8px 16px;
    background: var(--accent-primary);
    color: var(--bg-deep);
    font-weight: 600;
    font-size: var(--font-size-sm);
    border-radius: var(--border-radius-sm);
    text-decoration: none;
}
.skip-link:focus {
    top: 8px;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--text-tertiary) transparent;
}

/* --- Background Canvas --- */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: var(--z-bg);
    pointer-events: none;
}

#viz-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: var(--z-overlay);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-slow);
}

#viz-canvas.fullscreen-active {
    opacity: 1;
    pointer-events: auto;
    cursor: none;
    background: var(--bg-deep);
}

#crowley-canvas,
#crowley-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: var(--z-overlay);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-slow);
}

#crowley-canvas.fullscreen-active,
#crowley-overlay.fullscreen-active {
    opacity: 1;
    cursor: none;
    background: transparent;
}

#crowley-canvas.fullscreen-active {
    pointer-events: auto;
    background: #000;
}

#crowley-overlay.fullscreen-active {
    pointer-events: none; /* overlay passes clicks through */
}

/* --- Loading Screen --- */
.loading-screen {
    position: fixed;
    inset: 0;
    z-index: var(--z-loading);
    background: var(--bg-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

.loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
}

.loading-title {
    font-size: 2.8rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
}

.loading-subtitle {
    font-size: 1.1rem;
    font-weight: 400;
    letter-spacing: 0.3em;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.loading-years {
    font-size: 0.9rem;
    color: var(--accent-primary);
    letter-spacing: 0.5em;
    margin-bottom: 2.5rem;
    opacity: 0.7;
}

.loading-bar {
    width: 200px;
    height: 2px;
    background: var(--bg-tertiary);
    border-radius: 1px;
    margin: 0 auto 1rem;
    overflow: hidden;
}

.loading-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 1px;
    transition: width 0.3s ease;
}

.loading-status {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    letter-spacing: 0.1em;
}

/* --- Utility --- */
.hidden {
    display: none !important;
}

/* --- App Container --- */
.app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    position: relative;
    z-index: var(--z-content);
}

/* --- Header --- */
.header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.2rem;
    background: rgba(10, 10, 18, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: var(--z-header);
    flex-shrink: 0;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    max-width: 420px;
    margin: 0 1.5rem;
}

.site-title {
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    cursor: default;
    white-space: nowrap;
}

.title-name {
    color: var(--text-primary);
    font-weight: 500;
}

.title-divider {
    color: var(--text-tertiary);
    margin: 0 0.4rem;
    font-weight: 300;
}

.title-archive {
    color: var(--text-secondary);
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 0.85em;
}

/* Search */
.search-container {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 0 2.2rem 0 2.6rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: background var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

.search-input:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--glow-primary);
}

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-clear:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Header buttons */
.header-link {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-primary);
    text-decoration: none;
    padding: 0.35rem 0.7rem;
    background: none;
    border: 1px solid rgba(74, 245, 199, 0.25);
    border-radius: var(--border-radius);
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
}

.header-link:hover {
    background: rgba(74, 245, 199, 0.1);
    border-color: rgba(74, 245, 199, 0.5);
    color: #fff;
}

.header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.header-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}

/* --- Main Layout --- */
.main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.queue-panel {
    width: 320px;
    flex-shrink: 0;
    min-width: 260px;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(10, 10, 18, 0.95);
    overflow: hidden;
    display: flex;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: rgba(10, 10, 18, 0.95);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
    z-index: var(--z-sidebar);
}

.sidebar-section {
    padding: 0 1rem;
    margin-bottom: 1.5rem;
}

.sidebar-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-tertiary);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-collapsible > .sidebar-title {
    margin-bottom: 0;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.sidebar-collapsible > .sidebar-title:hover {
    color: var(--text-secondary);
}

.sidebar-collapsible > .sidebar-title:focus-visible {
    outline: 1px solid rgba(74, 245, 199, 0.45);
    border-radius: var(--border-radius-sm);
}

.sidebar-collapsible > .sidebar-title::-webkit-details-marker {
    display: none;
}

.sidebar-collapsible > .sidebar-title::after {
    content: 'v';
    margin-left: auto;
    font-size: 0.78rem;
    color: var(--text-secondary);
    transition: transform var(--transition-fast), color var(--transition-fast);
}

.sidebar-collapsible:not([open]) > .sidebar-title::after {
    transform: rotate(-90deg);
    color: var(--text-tertiary);
}

.sidebar-content {
    margin-top: 0.6rem;
}

/* Year filter buttons */
.year-filters {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.year-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.35rem 0.6rem;
    background: none;
    border: none;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    text-align: left;
}

.year-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.year-btn.active {
    background: rgba(74, 245, 199, 0.1);
    color: var(--accent-primary);
}

.year-count {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    min-width: 24px;
    text-align: right;
}

.year-btn.active .year-count {
    color: var(--accent-dim);
}

/* Sort buttons */
.sort-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.sort-btn {
    padding: 0.3rem 0.5rem;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 0.72rem;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.sort-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.15);
}

.sort-btn.active {
    background: rgba(123, 104, 238, 0.15);
    color: var(--accent-secondary);
    border-color: rgba(123, 104, 238, 0.3);
}

/* --- Mood Filter --- */
.mood-filter {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mood-filter-controls {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.mood-mode-toggle,
.mood-filter-clear,
.mood-preset-btn {
    padding: 0.35rem 0.6rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-fast);
}

.mood-mode-toggle {
    border: 1px solid rgba(145, 209, 255, 0.24);
    background: rgba(145, 209, 255, 0.08);
    color: #c6eaff;
}

.mood-mode-toggle.active {
    border-color: rgba(65, 216, 163, 0.44);
    background: rgba(65, 216, 163, 0.16);
    color: #d7fff0;
}

.mood-filter-clear {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
}

.mood-filter-clear:hover {
    border-color: rgba(255, 115, 138, 0.34);
    background: rgba(255, 115, 138, 0.1);
    color: #ffc8d2;
}

.mood-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.mood-preset-btn {
    border: 1px dashed rgba(145, 209, 255, 0.3);
    background: rgba(145, 209, 255, 0.06);
    color: #b8dffa;
}

.mood-preset-btn:hover {
    border-color: rgba(145, 209, 255, 0.42);
    color: #cfeeff;
}

.mood-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.mood-chip-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.65rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-fast);
    line-height: 1.4;
}

.mood-chip-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.mood-chip-btn.active {
    color: #fff;
}

/* --- Per-mood chip colors --- */
.mood-chip-btn[data-mood="Atmospheric"]       { border-color: rgba(94, 196, 232, 0.35); }
.mood-chip-btn[data-mood="Atmospheric"].active { background: rgba(94, 196, 232, 0.18); border-color: rgba(94, 196, 232, 0.6); color: var(--mood-atmospheric); }
.mood-chip-btn[data-mood="Dreamy"]            { border-color: rgba(176, 122, 239, 0.35); }
.mood-chip-btn[data-mood="Dreamy"].active     { background: rgba(176, 122, 239, 0.18); border-color: rgba(176, 122, 239, 0.6); color: var(--mood-dreamy); }
.mood-chip-btn[data-mood="Hypnotic"]          { border-color: rgba(201, 122, 232, 0.35); }
.mood-chip-btn[data-mood="Hypnotic"].active   { background: rgba(201, 122, 232, 0.18); border-color: rgba(201, 122, 232, 0.6); color: var(--mood-hypnotic); }
.mood-chip-btn[data-mood="Driving"]           { border-color: rgba(240, 160, 64, 0.35); }
.mood-chip-btn[data-mood="Driving"].active    { background: rgba(240, 160, 64, 0.18); border-color: rgba(240, 160, 64, 0.6); color: var(--mood-driving); }
.mood-chip-btn[data-mood="Intense"]           { border-color: rgba(240, 88, 88, 0.35); }
.mood-chip-btn[data-mood="Intense"].active    { background: rgba(240, 88, 88, 0.18); border-color: rgba(240, 88, 88, 0.6); color: var(--mood-intense); }
.mood-chip-btn[data-mood="Dark"]              { border-color: rgba(104, 120, 204, 0.35); }
.mood-chip-btn[data-mood="Dark"].active       { background: rgba(104, 120, 204, 0.18); border-color: rgba(104, 120, 204, 0.6); color: var(--mood-dark); }
.mood-chip-btn[data-mood="Bright"]            { border-color: rgba(232, 212, 74, 0.35); }
.mood-chip-btn[data-mood="Bright"].active     { background: rgba(232, 212, 74, 0.18); border-color: rgba(232, 212, 74, 0.6); color: var(--mood-bright); }
.mood-chip-btn[data-mood="Uplifting"]         { border-color: rgba(94, 224, 136, 0.35); }
.mood-chip-btn[data-mood="Uplifting"].active  { background: rgba(94, 224, 136, 0.18); border-color: rgba(94, 224, 136, 0.6); color: var(--mood-uplifting); }
.mood-chip-btn[data-mood="Melancholic"]       { border-color: rgba(90, 142, 216, 0.35); }
.mood-chip-btn[data-mood="Melancholic"].active { background: rgba(90, 142, 216, 0.18); border-color: rgba(90, 142, 216, 0.6); color: var(--mood-melancholic); }

.mood-chip-count {
    color: var(--text-tertiary);
    font-size: 0.72rem;
}

.mood-chip-btn.active .mood-chip-count {
    opacity: 0.8;
}

.mood-filter-status {
    font-size: 0.78rem;
    color: #8cd7c0;
    min-height: 1.3em;
    line-height: 1.4;
}

.mood-filter-status:empty {
    display: none;
}

/* --- DJ Filter --- */
.dj-filter {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.dj-filter-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.dj-filter-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
}

.dj-bpm-inputs {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.dj-bpm-input {
    width: 60px;
    padding: 0.3rem 0.4rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-family: inherit;
    text-align: center;
    -moz-appearance: textfield;
}

.dj-bpm-input::-webkit-outer-spin-button,
.dj-bpm-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.dj-bpm-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px var(--glow-primary);
}

.dj-bpm-input::placeholder {
    color: var(--text-tertiary);
}

.dj-bpm-dash {
    color: var(--text-tertiary);
    font-size: 0.7rem;
}

.dj-camelot-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 3px;
}

.dj-cam-btn {
    --cam-hue: 180;
    padding: 0.25rem 0;
    background: hsla(var(--cam-hue), 88%, 58%, 0.14);
    border: 1px solid hsla(var(--cam-hue), 95%, 68%, 0.32);
    border-radius: var(--border-radius-sm);
    color: hsla(var(--cam-hue), 100%, 82%, 0.92);
    font-size: 0.7rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: center;
    text-shadow: 0 0 7px hsla(var(--cam-hue), 95%, 65%, 0.28);
}

.dj-cam-btn:hover {
    background: hsla(var(--cam-hue), 88%, 60%, 0.24);
    border-color: hsla(var(--cam-hue), 100%, 72%, 0.48);
    color: #ffffff;
}

.dj-cam-btn.active {
    background: hsla(var(--cam-hue), 92%, 62%, 0.36);
    color: #fff;
    border-color: hsla(var(--cam-hue), 100%, 75%, 0.68);
    box-shadow: 0 0 10px hsla(var(--cam-hue), 95%, 64%, 0.34);
}

.dj-cam-mode {
    display: flex;
    gap: 3px;
    margin-top: 0.2rem;
}

.dj-cam-mode-btn {
    --mode-hue: 190;
    flex: 1;
    padding: 0.2rem 0;
    background: hsla(var(--mode-hue), 92%, 60%, 0.1);
    border: 1px solid hsla(var(--mode-hue), 95%, 70%, 0.2);
    border-radius: var(--border-radius-sm);
    color: hsla(var(--mode-hue), 100%, 80%, 0.82);
    font-size: 0.65rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-fast);
}

.dj-cam-mode-btn[data-mode="A"] { --mode-hue: 168; }
.dj-cam-mode-btn[data-mode="B"] { --mode-hue: 44; }

.dj-cam-mode-btn:hover {
    background: hsla(var(--mode-hue), 94%, 62%, 0.2);
    border-color: hsla(var(--mode-hue), 100%, 76%, 0.35);
    color: #fff;
}

.dj-cam-mode-btn.active {
    background: hsla(var(--mode-hue), 96%, 64%, 0.32);
    color: #fff;
    border-color: hsla(var(--mode-hue), 100%, 78%, 0.58);
    box-shadow: 0 0 8px hsla(var(--mode-hue), 95%, 68%, 0.3);
}

.dj-cam-mode-sub {
    font-size: 0.68rem;
    opacity: 0.7;
}

.dj-filter-status {
    font-size: 0.7rem;
    color: var(--accent-primary);
    min-height: 1em;
}

.dj-filter-status:empty {
    display: none;
}

.dj-filter-clear {
    padding: 0.35rem 0.55rem;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-fast);
}

.dj-filter-clear:hover {
    background: rgba(255, 70, 70, 0.1);
    border-color: rgba(255, 70, 70, 0.3);
    color: #ff6b6b;
}

/* Catalog stats */
.catalog-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.stat {
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Queue */
.browser-queue-section {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 0.75rem 1rem 0.85rem 0.75rem;
    border-radius: 0;
    border: none;
    background: transparent;
    backdrop-filter: none;
    display: flex;
    flex-direction: column;
}

.browser-queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.25rem;
}

.browser-queue-title {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.queue-drop-hint {
    font-size: 0.68rem;
    color: var(--text-tertiary);
    margin-bottom: 0.45rem;
}

.queue-count {
    font-size: 0.7rem;
    color: var(--accent-primary);
    background: rgba(74, 245, 199, 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    font-weight: 500;
}

.queue-clear-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.22rem 0.42rem;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    border-radius: 999px;
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
}

.queue-clear-btn:hover {
    color: #ffd7de;
    border-color: rgba(255, 107, 157, 0.42);
    background: rgba(255, 107, 157, 0.12);
}

.queue-clear-label {
    display: inline-block;
    line-height: 1;
}

.queue-list {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border: 1px dashed transparent;
    border-radius: var(--border-radius-sm);
    padding: 0.2rem;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.queue-list.drag-target {
    border-color: rgba(74, 245, 199, 0.6);
    background: rgba(74, 245, 199, 0.08);
}

.queue-empty {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    font-style: italic;
    padding: 0.5rem 0;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.32rem 0.42rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), opacity var(--transition-fast);
    border: 1px solid transparent;
    contain: layout style;
}

.queue-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.queue-item.selected {
    border-color: rgba(123, 160, 255, 0.38);
    background: rgba(93, 130, 235, 0.14);
}

.queue-item.active {
    color: var(--accent-primary);
    border-color: rgba(74, 245, 199, 0.2);
    background: rgba(74, 245, 199, 0.08);
}

.queue-item.dragging {
    opacity: 0.45;
}

.queue-item.drag-over {
    border-color: rgba(74, 245, 199, 0.55);
    background: rgba(74, 245, 199, 0.16);
}

.queue-item-handle {
    color: var(--text-tertiary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
}

.queue-item.dragging .queue-item-handle {
    cursor: grabbing;
}

.queue-list.touch-drag-active {
    user-select: none;
}

.queue-item-index {
    color: var(--text-tertiary);
    font-size: 0.65rem;
    min-width: 16px;
}

.queue-item-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.queue-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.queue-item-time {
    color: var(--text-tertiary);
    font-size: 0.74rem;
    margin-left: 0.2rem;
}

.queue-harmonic-pill {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
    line-height: 1.4;
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.queue-harmonic-pill.exact {
    color: #8effdc;
    border-color: rgba(74, 245, 199, 0.45);
    background: rgba(74, 245, 199, 0.15);
}

.queue-harmonic-pill.compatible {
    color: #bca8ff;
    border-color: rgba(145, 120, 255, 0.42);
    background: rgba(145, 120, 255, 0.15);
}

.queue-harmonic-pill.off {
    color: #ffb0b8;
    border-color: rgba(255, 122, 140, 0.42);
    background: rgba(255, 122, 140, 0.15);
}

.queue-harmonic-pill.unknown {
    color: #c8d0dd;
    border-color: rgba(185, 197, 214, 0.35);
    background: rgba(185, 197, 214, 0.12);
}

.queue-item-remove {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 2px;
    margin-left: auto;
    display: flex;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.queue-item:hover .queue-item-remove {
    opacity: 1;
}

.queue-item-remove:hover {
    color: var(--accent-tertiary);
}

.track-container.queue-remove-target {
    outline: 2px dashed rgba(255, 107, 157, 0.62);
    outline-offset: -4px;
    background: rgba(255, 107, 157, 0.08);
}

/* --- Browser Area --- */
.browser {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.browser-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.2rem;
    flex-shrink: 0;
}

.browser-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.browser-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.browser-filter-label {
    color: var(--accent-primary);
    font-size: 0.75rem;
}

.play-all-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.8rem;
    background: rgba(74, 245, 199, 0.1);
    border: 1px solid rgba(74, 245, 199, 0.2);
    border-radius: var(--border-radius);
    color: var(--accent-primary);
    font-size: 0.78rem;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.play-all-btn:hover {
    background: rgba(74, 245, 199, 0.18);
    border-color: rgba(74, 245, 199, 0.35);
}

.random-song-btn {
    color: #ffe6a3;
    border-color: rgba(246, 207, 91, 0.36);
    background: rgba(246, 207, 91, 0.1);
}

.random-song-btn:hover {
    color: #fff0c8;
    border-color: rgba(246, 207, 91, 0.58);
    background: rgba(246, 207, 91, 0.18);
}

/* --- Timeline Ribbon --- */
.timeline-ribbon {
    display: flex;
    align-items: stretch;
    height: 32px;
    margin: 0 1.2rem 0.5rem;
    gap: 2px;
    flex-shrink: 0;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}

.timeline-segment {
    flex: 1;
    min-width: 2px;
    position: relative;
    cursor: pointer;
    transition: opacity var(--transition-fast), background var(--transition-fast);
    display: flex;
    align-items: flex-end;
    opacity: 0.8;
}

.timeline-segment:hover {
    opacity: 1;
}

.timeline-segment.active {
    outline: 2px solid var(--accent-primary);
    outline-offset: -1px;
    opacity: 1;
    background: rgba(255, 255, 255, 0.08);
}

.timeline-segment-fill {
    width: 100%;
    background: currentColor;
    border-radius: 1px 1px 0 0;
    transition: height var(--transition-normal);
}

.timeline-segment-label {
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.7);
    pointer-events: none;
    white-space: nowrap;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.timeline-ribbon[data-mode="mood"] .timeline-segment-label,
.timeline-ribbon[data-mode="energy"] .timeline-segment-label,
.timeline-ribbon[data-mode="bpm"] .timeline-segment-label {
    font-size: 0.64rem;
    letter-spacing: -0.01em;
}

.timeline-ribbon[data-mode="key"] .timeline-segment-label {
    font-size: 0.58rem;
}

/* --- Track Container --- */
.track-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 1.2rem 1rem;
    display: block;
    overflow-anchor: none;
}

/* Virtual scroll runway — fixed height, items absolutely positioned inside */
.vscroll-runway {
    will-change: contents;
}

/* Year group headers */
.year-group-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem 0;
    margin-top: 0;
    height: 36px;
    box-sizing: border-box;
    background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-deep) 70%, transparent 100%);
}

.year-group-label {
    font-size: 1.6rem;
    font-weight: 200;
    color: var(--text-primary);
    letter-spacing: 0.05em;
    font-variant-numeric: tabular-nums;
}

.year-group-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
}

.year-group-count {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* --- Mood group headers --- */
.mood-group-header .year-group-label {
    font-weight: 400;
    letter-spacing: 0.02em;
}

.mood-group-header .year-group-label::first-letter {
    font-size: 1.35em;
    font-weight: 600;
}

.mood-group-header[data-mood="Atmospheric"] .year-group-label { color: var(--mood-atmospheric); }
.mood-group-header[data-mood="Dreamy"] .year-group-label      { color: var(--mood-dreamy); }
.mood-group-header[data-mood="Hypnotic"] .year-group-label    { color: var(--mood-hypnotic); }
.mood-group-header[data-mood="Driving"] .year-group-label     { color: var(--mood-driving); }
.mood-group-header[data-mood="Intense"] .year-group-label     { color: var(--mood-intense); }
.mood-group-header[data-mood="Dark"] .year-group-label        { color: var(--mood-dark); }
.mood-group-header[data-mood="Bright"] .year-group-label      { color: var(--mood-bright); }
.mood-group-header[data-mood="Uplifting"] .year-group-label   { color: var(--mood-uplifting); }
.mood-group-header[data-mood="Melancholic"] .year-group-label { color: var(--mood-melancholic); }

.mood-group-header .year-group-line {
    background: linear-gradient(90deg, currentColor 0%, transparent 100%);
    opacity: 0.2;
}

/* --- Track Items (List View) --- */
.track-list-item {
    position: relative;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.8rem;
    padding: 0.65rem 0.75rem;
    height: 62px;
    box-sizing: border-box;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background var(--transition-fast);
    border: 1px solid transparent;
    contain: layout style;
}

.track-list-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.track-list-item.selected {
    background: rgba(123, 160, 255, 0.12);
    border-color: rgba(123, 160, 255, 0.34);
}

.track-list-item.playing {
    background: var(--track-select-bg);
    border-color: var(--track-select-border);
}

.track-list-item.selected .track-name {
    color: #d5e1ff;
}

.track-list-item.playing .track-name {
    color: var(--track-select-accent);
}

.track-list-item.highlight-flash,
.track-grid-item.highlight-flash {
    animation: highlightFlash 1.5s ease-out;
}
@keyframes highlightFlash {
    0%, 15% { background: rgba(53, 214, 255, 0.2); outline: 2px solid rgba(53, 214, 255, 0.3); outline-offset: -1px; }
    100% { background: transparent; outline: 2px solid transparent; outline-offset: -1px; }
}

.track-play-indicator {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    border-radius: var(--border-radius-sm);
    transition: color var(--transition-fast);
}

.track-list-item:hover .track-play-indicator {
    color: var(--accent-secondary);
}

.track-list-item.playing .track-play-indicator {
    color: var(--track-select-accent);
}

.track-play-indicator svg {
    display: none;
}

.track-list-item:hover .track-play-indicator .track-number,
.track-list-item.playing .track-play-indicator .track-number {
    display: none;
}

.track-list-item:hover .track-play-indicator svg,
.track-list-item.playing .track-play-indicator svg {
    display: block;
}

/* Playing animation bars */
.playing-bars {
    display: none;
    gap: 3px;
    height: 20px;
    align-items: flex-end;
}

.track-list-item.playing .playing-bars {
    display: flex;
}

.track-list-item.playing .track-play-indicator svg.play-icon,
.track-list-item.playing .track-play-indicator svg.readied-icon {
    display: none;
}

/* Readied (queued, not yet playing) */
.track-list-item.readied {
    background: linear-gradient(90deg, rgba(180, 140, 255, 0.08) 0%, transparent 60%);
}
.track-list-item.readied .track-play-indicator {
    color: rgba(180, 140, 255, 0.9);
}
.track-list-item.readied .track-play-indicator .track-number {
    display: none;
}
.track-list-item.readied .track-play-indicator svg.readied-icon {
    display: block;
    animation: readiedPulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 4px rgba(180, 140, 255, 0.6));
}
.track-list-item.readied .track-play-indicator svg.play-icon {
    display: none;
}
@keyframes readiedPulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.15); }
}

.playing-bar {
    width: 4px;
    background: var(--track-select-accent);
    border-radius: 1px;
    animation: playingBars 0.8s ease-in-out infinite;
    will-change: transform;
}

.playing-bar:nth-child(1) { animation-delay: 0s; height: 60%; }
.playing-bar:nth-child(2) { animation-delay: 0.15s; height: 100%; }
.playing-bar:nth-child(3) { animation-delay: 0.3s; height: 40%; }

@keyframes playingBars {
    0%, 100% { transform: scaleY(0.3); }
    50% { transform: scaleY(1); }
}

.track-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.track-name {
    font-size: 0.88rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 400;
}

.track-meta {
    font-size: 0.68rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-meta-pills {
    margin-top: 0.08rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.track-rec-chip {
    border: 1px solid rgba(123, 160, 255, 0.35);
    background: rgba(93, 130, 235, 0.14);
    color: #c6d7ff;
    border-radius: 999px;
    font-size: 0.62rem;
    line-height: 1;
    letter-spacing: 0.02em;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.62rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-rec-chip.try-chip {
    max-width: none;
    min-width: 116px;
    flex-shrink: 0;
}

.track-rec-chip:hover {
    border-color: rgba(145, 120, 255, 0.55);
    color: #d6c8ff;
    background: rgba(145, 120, 255, 0.12);
}

.track-row-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex-shrink: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.track-list-item:hover .track-row-actions,
.track-list-item:focus-within .track-row-actions,
.track-list-item.selected .track-row-actions,
.track-list-item.playing .track-row-actions {
    opacity: 1;
    pointer-events: auto;
}

.track-row-actions .track-inline-btn {
    width: 110px;
    min-width: 110px;
    max-width: 110px;
    padding: 0 0.6rem;
    border-radius: 5px;
}

.track-inline-btn.is-disabled,
.track-inline-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-tertiary);
}

.track-inline-btn.is-disabled:hover,
.track-inline-btn:disabled:hover {
    color: var(--text-tertiary);
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
}

.track-inline-btn {
    height: 34px;
    min-width: 64px;
    padding: 0 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-size: 0.74rem;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.track-inline-btn:hover {
    color: var(--text-primary);
    border-color: rgba(145, 120, 255, 0.52);
    background: rgba(145, 120, 255, 0.16);
}

.track-pill {
    display: inline;
    font-size: 0.76rem;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    line-height: 1.35;
    border: none;
    background: none;
    color: var(--text-tertiary);
}

.track-pill.mood {
    color: var(--text-secondary);
    cursor: default;
    position: relative;
}

/* Expandable mood tooltip on hover/tap */
.track-pill.mood[title]:hover::after,
.track-pill.mood[title]:focus::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.4rem 0.65rem;
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.76rem;
    white-space: nowrap;
    z-index: 20;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    margin-bottom: 4px;
}

.track-pill.bpm {
    color: #bdb8ee;
}

.track-pill.key {
    color: var(--accent-primary);
}

.track-pill.time {
    color: var(--text-tertiary);
}

.track-rec-chip.queue {
    max-width: none;
    min-width: 34px;
    text-align: center;
    border-color: rgba(246, 207, 91, 0.45);
    background: rgba(246, 207, 91, 0.14);
    color: #ffe6a3;
}

.track-rec-chip.queue:hover {
    border-color: rgba(74, 245, 199, 0.55);
    color: var(--accent-primary);
    background: rgba(74, 245, 199, 0.12);
}

.track-inline-btn.queue-btn {
    border-color: rgba(246, 207, 91, 0.42);
    color: #ffe6a3;
    background: rgba(246, 207, 91, 0.12);
}

.track-inline-btn.queue-btn:hover {
    color: #e0d4ff;
    border-color: rgba(145, 120, 255, 0.6);
    background: rgba(145, 120, 255, 0.16);
}

.track-inline-btn.license-btn {
    border-color: rgba(74, 245, 199, 0.38);
    color: #b9ffe8;
    background: rgba(74, 245, 199, 0.12);
}

.track-inline-btn.license-btn:hover {
    color: #ede7ff;
    border-color: rgba(145, 120, 255, 0.62);
    background: rgba(145, 120, 255, 0.2);
}

.track-actions {
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.track-list-item:hover .track-actions {
    opacity: 1;
}

.track-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.track-action-btn:hover {
    color: var(--accent-primary);
    background: rgba(74, 245, 199, 0.1);
}

/* --- Track Items (Grid View) --- */
.track-container.grid-view {
    display: block;
    overflow-x: hidden;
}

.track-grid-item {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.04);
    padding: 0;
    cursor: pointer;
    transition: background var(--transition-normal), border-color var(--transition-normal), transform var(--transition-normal);
    position: relative;
    overflow: hidden;
    min-width: 160px;
    min-height: 180px;
    contain: layout style;
}

.track-grid-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 0%, var(--glow-primary), transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.track-grid-item:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.track-grid-item.selected {
    border-color: rgba(123, 160, 255, 0.42);
    background: rgba(93, 130, 235, 0.12);
}

.track-grid-item:hover::before {
    opacity: 1;
}

.track-grid-item.playing {
    border-color: var(--track-select-border);
    background: var(--track-select-bg);
}

.track-grid-art {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 0;
    margin-bottom: 0;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.track-grid-art-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 200;
    color: rgba(255, 255, 255, 0.15);
    position: relative;
}

.track-grid-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity var(--transition-fast);
    border-radius: var(--border-radius);
    pointer-events: none;
}

.track-grid-rec-stack {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 4;
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
    max-width: calc(100% - 12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.track-grid-item:hover .track-grid-rec-stack,
.track-grid-item:focus-within .track-grid-rec-stack,
.track-grid-item.selected .track-grid-rec-stack,
.track-grid-item.playing .track-grid-rec-stack {
    opacity: 1;
    pointer-events: auto;
}

.track-grid-rec-chip {
    border: 1px solid rgba(123, 160, 255, 0.42);
    background: rgba(11, 20, 48, 0.72);
    color: #d5e1ff;
    border-radius: 999px;
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    padding: 0.2rem 0.45rem;
    cursor: pointer;
    opacity: 0.9;
}

.track-grid-rec-chip.similar-btn {
    max-width: 140px;
    font-size: 0.68rem;
    padding: 0.22rem 0.44rem;
    letter-spacing: 0.02em;
}

.track-grid-rec-chip.info {
    border-color: rgba(255, 255, 255, 0.3);
    color: #d8ddf4;
    background: rgba(18, 20, 34, 0.8);
}

.track-grid-rec-chip:hover {
    border-color: rgba(145, 120, 255, 0.62);
    color: #ddd0ff;
    background: rgba(30, 20, 52, 0.85);
}

.track-grid-rec-chip.queue {
    border-color: rgba(246, 207, 91, 0.45);
    color: #ffe6a3;
    background: rgba(34, 24, 8, 0.72);
}

.track-grid-rec-chip.license-btn {
    border-color: rgba(74, 245, 199, 0.45);
    color: #b9ffe8;
    background: rgba(10, 36, 33, 0.78);
}

.track-list-item.dragging-source,
.track-grid-item.dragging-source {
    opacity: 0.5;
    border-color: rgba(74, 245, 199, 0.4);
}

/* Label overlay on grid art */
.track-grid-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.8rem 0.5rem 0.4rem;
    background: linear-gradient(to top, rgba(5, 5, 15, 0.92) 0%, rgba(5, 5, 15, 0.6) 60%, transparent 100%);
    z-index: 2;
    pointer-events: none;
}

.track-grid-label-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #e8e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    line-height: 1.35;
}

.track-grid-item.playing .track-grid-label-name {
    color: var(--track-select-accent);
}

.track-list-item:focus-visible,
.track-grid-item:focus-visible,
.queue-item:focus-visible,
.timeline-segment:focus-visible {
    outline: 2px solid rgba(145, 120, 255, 0.7);
    outline-offset: 1px;
}

.track-grid-label-info {
    font-size: 0.72rem;
    color: rgba(200, 200, 220, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    line-height: 1.35;
    margin-top: 0.12rem;
}

.track-grid-item:hover .track-grid-play-overlay {
    opacity: 1;
}

.track-grid-play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg-deep);
    transform: scale(0.8);
    transition: transform var(--transition-fast);
}

.track-grid-item:hover .track-grid-play-btn {
    transform: scale(1);
}

/* .track-grid-name, .track-grid-meta, .track-grid-badges removed — unused (display: none) */

/* --- Player Bar --- */
.player-bar {
    height: var(--player-height);
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 0 1.2rem;
    background: rgba(10, 10, 18, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    z-index: var(--z-player);
    flex-shrink: 0;
    position: relative;
}

.player-viz {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    opacity: 0.12;
    pointer-events: auto;
    cursor: pointer;
    z-index: 0;
}

.player-viz:hover {
    opacity: 0.25;
    transition: opacity var(--transition-normal);
}

/* Track info in player */
.player-track-info {
    min-width: 0;
    max-width: 340px;
    position: relative;
    z-index: 1;
}

.player-track-name-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.player-track-name {
    font-size: 0.88rem;
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
    cursor: pointer;
}
.player-track-name:hover {
    text-decoration: underline;
    text-decoration-color: var(--text-tertiary);
    text-underline-offset: 2px;
}

.player-camelot-badge {
    flex-shrink: 0;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: var(--border-radius-sm);
    background: rgba(123, 104, 238, 0.18);
    color: var(--accent-secondary);
    letter-spacing: 0.03em;
    font-variant-numeric: tabular-nums;
    border: 1px solid rgba(123, 104, 238, 0.25);
}

.player-camelot-badge.harmonic-active {
    background: rgba(74, 245, 199, 0.15);
    color: var(--accent-primary);
    border-color: rgba(74, 245, 199, 0.3);
    box-shadow: 0 0 8px rgba(74, 245, 199, 0.2);
}

.player-track-meta {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Player controls */
.player-controls {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    position: relative;
    z-index: 1;
}

.player-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
    position: relative;
}

.player-btn.player-btn-text {
    width: auto;
    border-radius: var(--border-radius-sm);
    padding: 0 0.5rem;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.player-btn svg {
    transform: scale(1.15);
}

.player-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.player-btn.active {
    color: var(--accent-primary);
}

.player-btn[data-hover-label]::after {
    content: attr(data-hover-label);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 0.35rem);
    transform: translateX(-50%) translateY(2px);
    opacity: 0;
    pointer-events: none;
    padding: 0.14rem 0.38rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(5, 10, 20, 0.95);
    color: #d7e6ff;
    font-size: 0.58rem;
    line-height: 1;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
    transition: opacity 120ms ease, transform 120ms ease;
    z-index: 3;
}

.player-btn[data-hover-label]:hover::after,
.player-btn[data-hover-label]:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.track-change-status {
    position: absolute;
    top: -1.4rem;
    right: 0;
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.15s ease;
    white-space: nowrap;
    pointer-events: none;
}

.track-change-status.visible {
    opacity: 1;
}

.play-btn {
    width: 44px;
    height: 44px;
    color: var(--bg-deep);
    background: var(--accent-primary);
}

.play-btn:hover {
    color: var(--bg-deep);
    background: var(--accent-primary);
    transform: scale(1.08);
}

/* Progress bar */
.player-progress {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.player-time {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    min-width: 36px;
    text-align: center;
}

.progress-bar-container {
    flex: 1;
    height: 24px;
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.progress-bar-bg {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    position: relative;
    overflow: visible;
    transition: height 0.2s ease;
}

.progress-bar-container:hover .progress-bar-bg {
    height: 6px;
}

.progress-bar-buffered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    width: 0%;
}

.progress-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 2px;
    width: 0%;
    will-change: width;
}

.progress-bar-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%) scale(0);
    width: 14px;
    height: 14px;
    background: var(--accent-primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--glow-strong);
    transition: transform var(--transition-fast);
}

.progress-bar-container:hover .progress-bar-handle {
    transform: translate(-50%, -50%) scale(1);
}

/* Volume */
.player-volume {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    position: relative;
    z-index: 1;
}

.volume-slider-container {
    width: 80px;
    height: 24px;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.volume-slider-bg {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    position: relative;
    overflow: visible;
}

.volume-slider-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--accent-primary);
    border-radius: 2px;
    width: 80%;
}

.volume-slider-handle {
    position: absolute;
    top: 50%;
    left: 80%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: var(--accent-primary);
    border-radius: 50%;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.volume-slider-container:hover .volume-slider-handle {
    opacity: 1;
}

/* --- Overlays --- */
.overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    background: rgba(5, 5, 15, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: overlayFadeIn 0.2s ease;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.overlay-content {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.overlay-close {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.overlay-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

/* Shortcuts */
.shortcuts-content h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 1.2rem;
}

.shortcuts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.shortcut {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.shortcut kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 0.4rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    font-size: 0.7rem;
    font-family: inherit;
    color: var(--text-primary);
}

.shortcut span {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* Track detail overlay */
.track-detail-content {
    max-width: 550px;
}

.track-detail-content h2 {
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
    padding-right: 2rem;
}

.track-detail-content .detail-year {
    font-size: 0.85rem;
    color: var(--accent-primary);
    margin-bottom: 1rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.6rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--border-radius-sm);
}

.detail-item-label {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.detail-item-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.detail-energy-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    margin-top: 0.3rem;
    overflow: hidden;
}

.detail-energy-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-warm));
}

.detail-rec-section {
    margin-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 0.9rem;
}

.detail-rec-title {
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.55rem;
}

.detail-rec-loading,
.detail-rec-empty {
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 0.5rem 0;
}

.detail-rec-card {
    display: flex;
    gap: 0.55rem;
    align-items: center;
    justify-content: space-between;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 0.55rem;
    margin-bottom: 0.45rem;
}

.detail-rec-main {
    min-width: 0;
    flex: 1;
}

.detail-rec-name {
    font-size: 0.86rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-rec-meta,
.detail-rec-reason {
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-rec-actions {
    display: flex;
    gap: 0.34rem;
    flex-shrink: 0;
}

.detail-rec-btn {
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--border-radius-sm);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    font-size: 0.68rem;
    padding: 0.35rem 0.45rem;
    cursor: pointer;
}

.detail-rec-btn:hover {
    border-color: rgba(74, 245, 199, 0.55);
    color: var(--accent-primary);
}

/* --- Generative Art Backgrounds per Track --- */
.track-art-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--border-radius);
}

/* --- Scrub Tooltip --- */
.progress-tooltip {
    position: absolute;
    top: -28px;
    left: 0;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    padding: 0.2rem 0.45rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.12);
    pointer-events: none;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.12s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.progress-bar-container:hover .progress-tooltip {
    opacity: 1;
}

/* --- Fullscreen Exit Button --- */
.fullscreen-overlay-btn {
    position: fixed;
    top: 20px;
    z-index: calc(var(--z-overlay) + 10);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 15, 40, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.15s ease, color 0.15s ease;
    pointer-events: none;
}

.fullscreen-exit-btn {
    right: 20px;
}

.fullscreen-shortcuts-btn {
    right: 70px;
}

.fullscreen-overlay-btn.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.fullscreen-overlay-btn:hover {
    background: rgba(15, 15, 40, 0.85);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.25);
}

/* Fullscreen cursor management */
#viz-canvas.fullscreen-active {
    cursor: none;
}

#viz-canvas.fullscreen-active.cursor-visible {
    cursor: default;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    /* .sidebar display is handled by mobile slide-in behavior in FEATURE 2 */

    .main {
        flex-direction: column;
    }

    .queue-panel {
        width: 100%;
        min-width: 0;
        max-height: 240px;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
    }

    .browser-queue-section {
        padding: 0.6rem 0.85rem 0.6rem 0.65rem;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-rec-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .detail-rec-actions {
        width: 100%;
    }

    .detail-rec-btn {
        flex: 1;
    }

    .header-center {
        max-width: 280px;
    }

    .player-bar {
        grid-template-columns: auto auto 1fr;
        gap: 0.5rem;
        height: auto;
        min-height: var(--player-height);
        padding: 0.5rem 0.8rem;
    }

    .player-progress {
        grid-column: 1 / -1;
        order: -1;
    }

    .player-volume {
        display: none;
    }

    .player-track-info {
        max-width: 150px;
    }
}

@media (max-width: 600px) {
    .header {
        padding: 0 0.6rem;
    }

    .header-right {
        gap: 0.3rem;
    }

    .header-center {
        max-width: 200px;
        margin: 0 0.5rem;
    }

    .header-link {
        font-size: 0.65rem;
        padding: 0.3rem 0.5rem;
    }

    .header-btn {
        width: 32px;
        height: 32px;
    }

    .site-title {
        font-size: 0.85rem;
    }

    .title-archive {
        display: none;
    }

    .title-divider {
        display: none;
    }

    .track-container {
        padding: 0 0.6rem 1rem;
    }

    .track-list-item {
        grid-template-columns: 30px minmax(0, 1fr);
        gap: 0.45rem;
        padding: 0.45rem;
    }

    .track-list-item .track-row-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .track-meta-pills {
        gap: 0.28rem;
    }

    .track-row-actions .track-inline-btn {
        height: 26px;
        width: 100px;
        min-width: 100px;
        max-width: 100px;
        padding: 0 0.42rem;
        font-size: 0.6rem;
    }

    .track-pill {
        font-size: 0.6rem;
    }

    .browser-header {
        padding: 0.4rem 0.6rem;
    }

    .browser-actions {
        gap: 0.28rem;
    }

    .browser-actions .play-all-btn {
        font-size: 0.68rem;
        padding: 0.3rem 0.55rem;
    }

    .timeline-ribbon {
        margin: 0 0.6rem 0.5rem;
        height: 24px;
    }

    .queue-panel {
        max-height: 200px;
    }
}

/* --- Animation for new items --- */
@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.track-list-item, .track-grid-item {
    animation: none;
}
}

/* Stagger animation for visible tracks */
.track-list-item:nth-child(1) { animation-delay: 0.02s; }
.track-list-item:nth-child(2) { animation-delay: 0.04s; }
.track-list-item:nth-child(3) { animation-delay: 0.06s; }
.track-list-item:nth-child(4) { animation-delay: 0.08s; }
.track-list-item:nth-child(5) { animation-delay: 0.10s; }
.track-list-item:nth-child(6) { animation-delay: 0.12s; }
.track-list-item:nth-child(7) { animation-delay: 0.14s; }
.track-list-item:nth-child(8) { animation-delay: 0.16s; }
.track-list-item:nth-child(9) { animation-delay: 0.18s; }
.track-list-item:nth-child(10) { animation-delay: 0.20s; }

/* --- Camelot Wheel --- */
.camelot-content {
    max-width: 480px;
    padding: 1.5rem;
}

.camelot-header {
    text-align: center;
    margin-bottom: 1rem;
}

.camelot-header h2 {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.camelot-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0;
    text-transform: none;
    line-height: 1.4;
    max-width: 300px;
    margin: 0.3rem auto 0;
}

.mix-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 0.7rem;
    cursor: pointer;
    user-select: none;
}

.mix-toggle input {
    display: none;
}

.mix-toggle-slider {
    width: 40px;
    height: 22px;
    background: var(--bg-card);
    border-radius: 11px;
    position: relative;
    transition: background 0.2s ease;
    border: 1px solid var(--border-subtle);
}

.mix-toggle-slider::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-tertiary);
    top: 2px;
    left: 2px;
    transition: transform 0.2s ease, background 0.2s ease;
}

.mix-toggle input:checked + .mix-toggle-slider {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.mix-toggle input:checked + .mix-toggle-slider::after {
    transform: translateX(18px);
    background: white;
}

.mix-toggle-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 1.5rem;
}

.mix-toggle input:checked ~ .mix-toggle-label {
    color: var(--accent-primary);
}

.camelot-wheel-container {
    position: relative;
    width: 100%;
    max-width: 380px;
    margin: 0 auto 1rem;
    aspect-ratio: 1;
}

#camelot-wheel-svg {
    width: 100%;
    height: 100%;
    display: block;
}

#camelot-overlay:not(.hidden) #camelot-wheel-svg {
    filter: saturate(1.24) brightness(1.24);
}

/* SVG segment styling via CSS */
.cw-segment {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.cw-segment:hover {
    opacity: 0.85;
}

.cw-segment-path {
    stroke: var(--bg-deep);
    stroke-width: 1.5;
    transition: fill 0.3s ease, stroke 0.3s ease, filter 0.3s ease;
}

.cw-segment.active .cw-segment-path {
    stroke: var(--accent-primary);
    stroke-width: 2.5;
    fill-opacity: 1;
    filter: drop-shadow(0 0 8px rgba(74, 245, 199, 0.5));
}

.cw-segment.compatible .cw-segment-path {
    stroke: rgba(123, 104, 238, 0.6);
    stroke-width: 2;
    fill-opacity: 0.92;
    filter: drop-shadow(0 0 4px rgba(123, 104, 238, 0.3));
}

.cw-segment-label {
    fill: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: central;
    transition: fill 0.3s ease;
}

.cw-segment.active .cw-segment-label {
    fill: var(--accent-primary);
    font-weight: 700;
}

.cw-segment-count {
    fill: rgba(255, 255, 255, 0.45);
    font-size: 10px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: central;
}

.cw-segment.active .cw-segment-count {
    fill: rgba(74, 245, 199, 0.6);
}

.cw-ring-label {
    fill: rgba(255, 255, 255, 0.28);
    font-size: 11px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    text-anchor: middle;
    dominant-baseline: central;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* Camelot controls */
.camelot-controls {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 0.8rem;
}

.camelot-control-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}

.camelot-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.camelot-stepper {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.camelot-step-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--transition-fast);
}

.camelot-step-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.camelot-step-value {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.02);
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    font-variant-numeric: tabular-nums;
}

.camelot-direction-btns {
    display: flex;
    gap: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.camelot-dir-btn {
    padding: 0.25rem 0.6rem;
    background: rgba(255, 255, 255, 0.04);
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    letter-spacing: 0.05em;
}

.camelot-dir-btn:last-child {
    border-right: none;
}

.camelot-dir-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.camelot-dir-btn.active {
    background: rgba(123, 104, 238, 0.15);
    color: var(--accent-secondary);
}

.camelot-next-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1.2rem;
    margin: 0.3rem auto 0;
    background: rgba(74, 245, 199, 0.1);
    border: 1px solid rgba(74, 245, 199, 0.2);
    border-radius: var(--border-radius);
    color: var(--accent-primary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.camelot-next-btn:hover {
    background: rgba(74, 245, 199, 0.18);
    border-color: rgba(74, 245, 199, 0.35);
    box-shadow: 0 0 12px rgba(74, 245, 199, 0.15);
}

.camelot-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.camelot-info-current {
    color: var(--accent-primary);
    font-weight: 600;
}

.camelot-info-arrow {
    color: var(--text-tertiary);
}

.camelot-info-next {
    color: var(--accent-secondary);
    font-weight: 600;
}

.camelot-info-played {
    color: var(--text-tertiary);
    font-size: 0.68rem;
    margin-left: 0.3rem;
}

/* Harmonic BPM mix mode active indicator (combo button) */
.player-btn.mix-glow {
    animation: mixPulse 3s ease-in-out infinite;
    will-change: transform, opacity;
}

@keyframes mixPulse {
    0%, 100% { box-shadow: 0 0 0 0 transparent; color: var(--accent-primary); }
    50% { box-shadow: 0 0 0 2px rgba(255, 166, 77, 0.35); color: var(--accent-warm); }
}

/* Transport buttons glow when mix mode is active */
.player-btn.mix-active {
    color: var(--accent-primary);
    text-shadow: 0 0 8px rgba(74, 245, 199, 0.3);
}

/* BPM badge in player bar */
.player-bpm-badge {
    flex-shrink: 0;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: var(--border-radius-sm);
    background: rgba(255, 166, 77, 0.15);
    color: var(--accent-warm);
    letter-spacing: 0.03em;
    font-variant-numeric: tabular-nums;
    border: 1px solid rgba(255, 166, 77, 0.25);
}

.player-bpm-badge.bpm-active {
    box-shadow: 0 0 8px rgba(255, 166, 77, 0.2);
}

/* Mix status indicator in overlay */
.mix-status {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-secondary);
    min-height: 1.2em;
    padding: 0.2rem 0;
}

.mix-status:empty {
    display: none;
}

/* Divider in camelot overlay between harmonic and BPM controls */
.camelot-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 0.3rem 0;
}

/* Visualizer button in player controls */
.viz-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 84px;
    height: 42px;
    padding: 0 0.65rem;
    gap: 0.34rem;
    margin-left: 0.3rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px !important;
    color: var(--accent-cool);
    transition: color var(--transition-normal), background var(--transition-normal), border-color var(--transition-normal);
}

.viz-btn svg {
    display: block;
    flex-shrink: 0;
}

.viz-btn-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.05;
}

.viz-btn:hover {
    color: #fff !important;
    background: rgba(77, 201, 246, 0.15) !important;
    border-color: rgba(77, 201, 246, 0.35);
    box-shadow: 0 0 12px rgba(77, 201, 246, 0.2);
}

/* Pulsing glow when audio is playing */
.viz-btn.viz-playing {
    color: var(--accent-cool);
    border-color: rgba(77, 201, 246, 0.3);
    animation: vizPulse 2.5s ease-in-out infinite;
    will-change: transform, opacity;
}

@keyframes vizPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 transparent;
        border-color: rgba(77, 201, 246, 0.15);
    }
    50% {
        box-shadow: 0 0 0 2px rgba(77, 201, 246, 0.3);
        border-color: rgba(77, 201, 246, 0.4);
    }
}

@media (max-width: 700px) {
    .viz-btn {
        min-width: 72px;
        padding: 0 0.5rem;
        gap: 0.28rem;
        height: 40px;
    }

    .viz-btn-label {
        font-size: 0.62rem;
    }
}

/* Mix notification toast */
.mix-notification {
    position: fixed;
    bottom: calc(var(--player-height) + 20px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 15, 40, 0.95);
    border: 1px solid rgba(74, 245, 199, 0.2);
    border-radius: var(--border-radius-lg);
    padding: 1rem 1.5rem;
    z-index: 200;
    backdrop-filter: blur(12px);
    text-align: center;
    min-width: 280px;
    max-width: 90vw;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    animation: slideUpIn 0.3s ease;
}

.mix-notification.hidden {
    display: none;
}

.mix-notification-text {
    color: var(--text-primary);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.mix-notification-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.mix-notification-btn {
    padding: 0.4rem 1rem;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
}

.mix-notification-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mix-notification-btn.primary {
    border-color: rgba(74, 245, 199, 0.3);
    color: var(--accent-primary);
}

.mix-notification-btn.primary:hover {
    background: rgba(74, 245, 199, 0.15);
}

@keyframes slideUpIn {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* --- Share Button (in player track info row) --- */
.player-share-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 0;
}

.player-share-btn:hover {
    color: var(--accent-primary);
    border-color: rgba(74, 245, 199, 0.3);
    background: rgba(74, 245, 199, 0.1);
}

/* --- Share Overlay --- */
.share-content {
    max-width: 480px;
}

.share-content h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.share-track-name {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 1.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.share-field {
    margin-bottom: 1rem;
}

.share-field-label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.4rem;
}

.share-input-row {
    display: flex;
    gap: 0.4rem;
}

.share-input {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.7rem;
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.78rem;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    outline: none;
}

.share-input:focus {
    border-color: rgba(74, 245, 199, 0.3);
}

.share-copy-btn {
    flex-shrink: 0;
    padding: 0.5rem 1rem;
    background: rgba(74, 245, 199, 0.1);
    border: 1px solid rgba(74, 245, 199, 0.25);
    border-radius: var(--border-radius-sm);
    color: var(--accent-primary);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    white-space: nowrap;
}

.share-copy-btn:hover {
    background: rgba(74, 245, 199, 0.2);
    border-color: rgba(74, 245, 199, 0.4);
}

.share-copy-btn.copied {
    background: rgba(74, 245, 199, 0.25);
    color: #fff;
}

/* --- Embed Mode --- */
body.embed-mode {
    overflow: hidden;
}

body.embed-mode .header,
body.embed-mode .main,
body.embed-mode #loading-screen,
body.embed-mode .mix-notification,
body.embed-mode .fullscreen-overlay-btn,
body.embed-mode #viz-canvas {
    display: none !important;
}

body.embed-mode .app {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100vh;
}

body.embed-mode .player-bar {
    position: relative;
    width: 100%;
    height: 80px;
}

body.embed-mode #bg-canvas {
    display: block;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.72rem;
    padding: 0.3rem 0.5rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: none;
    white-space: nowrap;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* --- License Overlay --- */
.license-content {
    max-width: 620px;
}

.license-content h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.license-track-hint {
    font-size: 0.74rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.license-track-name {
    font-size: 0.82rem;
    color: var(--accent-primary);
    margin-bottom: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.license-track-name:empty {
    display: none;
}

.license-tiers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.2rem;
}

.license-tier {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius);
    text-align: center;
    transition: border-color var(--transition-fast);
}

.license-tier:hover {
    border-color: rgba(74, 245, 199, 0.25);
}

.license-tier-name {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.license-tier-price {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    line-height: 1;
}

.license-tier-desc {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    line-height: 1.4;
    margin-bottom: 0.8rem;
    flex: 1;
}

.license-buy-btn {
    padding: 0.45rem 0.8rem;
    background: rgba(74, 245, 199, 0.1);
    border: 1px solid rgba(74, 245, 199, 0.25);
    border-radius: var(--border-radius-sm);
    color: var(--accent-primary);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.license-buy-btn:hover {
    background: rgba(74, 245, 199, 0.2);
    border-color: rgba(74, 245, 199, 0.4);
}

.license-buy-btn:disabled,
.license-buy-btn:disabled:hover {
    opacity: 0.45;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--text-tertiary);
}

.license-needs-track .license-tier {
    opacity: 0.65;
}

.license-contact {
    text-align: center;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.license-contact-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.license-contact-desc {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.license-contact-btn {
    display: inline-block;
    padding: 0.4rem 1rem;
    background: rgba(123, 104, 238, 0.1);
    border: 1px solid rgba(123, 104, 238, 0.25);
    border-radius: var(--border-radius-sm);
    color: var(--accent-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.license-contact-btn:hover {
    background: rgba(123, 104, 238, 0.2);
    border-color: rgba(123, 104, 238, 0.4);
    color: #fff;
}

.license-fine-print {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    text-align: center;
    line-height: 1.5;
}

/* --- Set Builder Overlay --- */
.set-builder-content {
    max-width: 640px;
}

.set-builder-content h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.set-builder-subtitle {
    font-size: 0.76rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 1rem;
}

.set-builder-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
    margin-bottom: 0.9rem;
}

.set-builder-row {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.set-builder-input {
    font-family: inherit;
}

.set-builder-dual-input {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 76px;
    gap: 0.45rem;
    align-items: center;
}

.set-builder-slider {
    width: 100%;
    accent-color: var(--accent-primary);
}

.set-builder-toggles {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.set-builder-check {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.set-builder-check input {
    accent-color: var(--accent-primary);
}

.set-builder-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.45rem;
    margin-bottom: 0.6rem;
}

.set-builder-actions .share-copy-btn {
    padding: 0.5rem 0.4rem;
}

.set-builder-status {
    font-size: 0.74rem;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
}

.set-builder-preview {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius);
    background: rgba(255, 255, 255, 0.02);
    padding: 0.35rem;
}

.set-builder-empty {
    font-size: 0.74rem;
    color: var(--text-tertiary);
    padding: 0.4rem;
}

.set-builder-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.38rem 0.45rem;
    border-radius: var(--border-radius-sm);
}

.set-builder-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.set-builder-item-index {
    width: 24px;
    color: var(--text-tertiary);
    font-size: 0.68rem;
}

.set-builder-item-name {
    flex: 1;
    min-width: 0;
    font-size: 0.78rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.set-builder-item-meta {
    font-size: 0.66rem;
    color: var(--text-tertiary);
}

/* --- Booking Overlay --- */
.booking-content {
    max-width: 480px;
}

.booking-content h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.booking-subtitle {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 1.2rem;
    line-height: 1.4;
}

.booking-form {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.booking-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.booking-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238888aa' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    padding-right: 2rem;
    cursor: pointer;
}

.booking-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.booking-textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
    line-height: 1.4;
}

.booking-submit {
    padding: 0.6rem 1.2rem;
    background: rgba(74, 245, 199, 0.12);
    border: 1px solid rgba(74, 245, 199, 0.25);
    border-radius: var(--border-radius);
    color: var(--accent-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    margin-top: 0.3rem;
}

.booking-submit:hover {
    background: rgba(74, 245, 199, 0.2);
    border-color: rgba(74, 245, 199, 0.4);
}

.booking-submit.sent {
    background: rgba(74, 245, 199, 0.25);
    color: #fff;
    pointer-events: none;
}

.booking-alt-contact {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    text-align: center;
    margin-top: 1rem;
}

.booking-alt-contact a {
    color: var(--accent-primary);
    text-decoration: none;
}

.booking-alt-contact a:hover {
    text-decoration: underline;
}

/* --- License Toast --- */
.license-toast {
    position: fixed;
    top: 1.2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1.2rem;
    background: rgba(15, 15, 40, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    max-width: 90vw;
    animation: toastSlideDown 0.35s ease;
}

.license-toast.license-success {
    border-color: rgba(74, 245, 199, 0.3);
}

.license-toast.license-cancel {
    border-color: rgba(255, 107, 157, 0.3);
}

.license-toast-msg {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.license-success .license-toast-msg {
    color: var(--accent-primary);
}

.license-cancel .license-toast-msg {
    color: var(--accent-tertiary);
}

.license-toast-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.2rem;
    line-height: 1;
    flex-shrink: 0;
}

.license-toast-close:hover {
    color: var(--text-primary);
}

@keyframes toastSlideDown {
    from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.license-toast.fade-out {
    animation: toastFadeOut 0.3s ease forwards;
}

@keyframes toastFadeOut {
    from { transform: translateX(-50%) translateY(0); opacity: 1; }
    to { transform: translateX(-50%) translateY(-20px); opacity: 0; }
}

/* License & Booking responsive */
@media (max-width: 600px) {
    .license-tiers {
        grid-template-columns: 1fr;
    }

    .license-content {
        max-width: 95%;
    }

    .set-builder-controls {
        grid-template-columns: 1fr;
    }

    .set-builder-dual-input {
        grid-template-columns: minmax(0, 1fr) 70px;
    }

    .set-builder-actions {
        grid-template-columns: 1fr 1fr;
    }
}


/* ================================================================
   FEATURE 1: SKELETON / SHIMMER LOADER
   ================================================================ */
#app-skeleton {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-primary, #0a0a1a);
    display: grid;
    grid-template-rows: 56px 1fr 72px;
    transition: opacity 0.4s ease;
}

#app-skeleton.fade-out {
    opacity: 0;
    pointer-events: none;
}

.skel-header {
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.skel-body {
    display: grid;
    grid-template-columns: 220px 1fr;
    overflow: hidden;
}

.skel-sidebar {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    border-right: 1px solid rgba(255,255,255,0.05);
}

.skel-tracks {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow: hidden;
}

.skel-player {
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
    background: rgba(255,255,255,0.02);
    border-top: 1px solid rgba(255,255,255,0.05);
}

.skel-block {
    border-radius: 4px;
    background: rgba(255,255,255,0.04);
    position: relative;
    overflow: hidden;
}

.skel-block::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%);
    animation: shimmer 1.8s ease-in-out infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.skel-title { width: 160px; height: 20px; }
.skel-search { flex: 1; max-width: 300px; height: 32px; border-radius: 16px; }
.skel-btn { width: 32px; height: 32px; border-radius: 50%; }
.skel-section { height: 24px; width: 80%; }
.skel-filter { height: 28px; width: 100%; }
.skel-track-row { height: 52px; width: 100%; border-radius: 6px; }
.skel-progress { flex: 1; height: 4px; border-radius: 2px; }
.skel-circle { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }

@media (max-width: 900px) {
    .skel-body { grid-template-columns: 1fr; }
    .skel-sidebar { display: none; }
}


/* ================================================================
   FEATURE 2: RESPONSIVE MOBILE OVERHAUL
   ================================================================ */
.mobile-filter-toggle {
    display: none;
}

@media (max-width: 900px) {
    .mobile-filter-toggle {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 500;
        background: var(--bg-secondary);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        border-right: 1px solid rgba(255,255,255,0.08);
        padding-top: 56px;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 499;
        background: rgba(0,0,0,0.6);
        backdrop-filter: blur(2px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .sidebar-backdrop.active {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Touch-friendly player on mobile */
@media (max-width: 600px) {
    .player-bar {
        flex-wrap: wrap;
        height: auto;
        min-height: 120px;
        padding: 0.4rem 0.6rem;
        gap: 0.3rem;
    }

    .player-track-info {
        order: 1;
        width: 100%;
        padding: 0.2rem 0;
    }

    .player-controls {
        order: 3;
        width: 100%;
        justify-content: center;
        gap: 0.3rem;
    }

    .player-controls .player-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }

    .player-controls .play-btn {
        width: 52px;
        height: 52px;
    }

    .player-progress {
        order: 2;
        width: 100%;
    }

    .player-volume {
        order: 4;
        width: 100%;
        justify-content: center;
    }

    .player-viz {
        display: none;
    }

    .main {
        padding-bottom: 130px;
    }

    .header {
        flex-wrap: wrap;
        height: auto;
        min-height: 48px;
        padding: 0.3rem 0.5rem;
        gap: 0.3rem;
    }

    .header-left {
        flex: 0 0 auto;
    }

    .header-center {
        flex: 1 1 100%;
        order: 3;
    }

    .header-right {
        flex: 0 0 auto;
    }

    .search-input {
        height: 40px;
        font-size: 0.9rem;
    }

    .track-list-item {
        min-height: 60px;
        padding: 0.65rem;
    }

    .viz-btn {
        display: none;
    }

    .header-link {
        font-size: 0.65rem;
        padding: 0.25rem 0.4rem;
    }
}

/* Small phone adjustments */
@media (max-width: 400px) {
    .header-right .header-link {
        display: none;
    }

    .track-row-actions .track-inline-btn {
        width: 70px;
        min-width: 70px;
        max-width: 70px;
        font-size: 0.55rem;
    }

    .player-controls .player-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
}


/* ================================================================
   FEATURE 3: WAVEFORM SCRUBBING
   ================================================================ */
.waveform-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.progress-bar-container:hover .progress-bar-bg,
.progress-bar-container.waveform-active .progress-bar-bg {
    height: 28px;
    border-radius: 4px;
}

.progress-bar-container.waveform-active .progress-bar-fill {
    opacity: 0.3;
}

.progress-bar-container.waveform-active .progress-bar-buffered {
    opacity: 0.15;
}


/* ================================================================
   FEATURE 4: LISTENING HISTORY DASHBOARD
   ================================================================ */
.history-content {
    max-width: 560px;
}

.history-content h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.history-subtitle {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    margin-bottom: 1.2rem;
}

.history-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.history-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.8rem 0.4rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--border-radius);
    text-align: center;
}

.history-stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent-primary);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.history-stat-label {
    font-size: 0.62rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.3rem;
}

.history-section {
    margin-bottom: 1.2rem;
}

.history-section h3 {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.history-top-track {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.4rem;
    border-radius: var(--border-radius-sm);
}

.history-top-track:hover {
    background: rgba(255,255,255,0.04);
}

.history-top-track-rank {
    width: 22px;
    font-size: 0.72rem;
    color: var(--text-tertiary);
    font-weight: 600;
    text-align: center;
    flex-shrink: 0;
}

.history-top-track-name {
    flex: 1;
    min-width: 0;
    font-size: 0.78rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-top-track-plays {
    font-size: 0.68rem;
    color: var(--accent-primary);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.history-bar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.history-bar-label {
    width: 60px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: right;
    flex-shrink: 0;
}

.history-bar-track {
    flex: 1;
    height: 18px;
    background: rgba(255,255,255,0.04);
    border-radius: 3px;
    overflow: hidden;
}

.history-bar-fill {
    height: 100%;
    border-radius: 3px;
    min-width: 2px;
    transition: width 0.5s ease;
}

.history-bar-fill.era {
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-cool));
}

.history-bar-fill.mood {
    background: linear-gradient(90deg, var(--accent-secondary), var(--accent-warm));
}

.history-bar-fill.mood[data-mood="Atmospheric"] { background: var(--mood-atmospheric); }
.history-bar-fill.mood[data-mood="Dreamy"]      { background: var(--mood-dreamy); }
.history-bar-fill.mood[data-mood="Hypnotic"]    { background: var(--mood-hypnotic); }
.history-bar-fill.mood[data-mood="Driving"]     { background: var(--mood-driving); }
.history-bar-fill.mood[data-mood="Intense"]     { background: var(--mood-intense); }
.history-bar-fill.mood[data-mood="Dark"]        { background: var(--mood-dark); }
.history-bar-fill.mood[data-mood="Bright"]      { background: var(--mood-bright); }
.history-bar-fill.mood[data-mood="Uplifting"]   { background: var(--mood-uplifting); }
.history-bar-fill.mood[data-mood="Melancholic"] { background: var(--mood-melancholic); }

.history-bar-value {
    font-size: 0.62rem;
    color: var(--text-tertiary);
    width: 36px;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.history-timeline {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 60px;
    padding: 0.3rem 0;
}

.history-timeline-bar {
    flex: 1;
    min-width: 3px;
    background: rgba(74, 245, 199, 0.4);
    border-radius: 2px 2px 0 0;
    transition: height 0.3s ease;
    position: relative;
}

.history-timeline-bar:hover {
    background: rgba(74, 245, 199, 0.7);
}

.history-timeline-bar::after {
    content: attr(data-label);
    position: absolute;
    bottom: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.5rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    display: none;
}

.history-timeline-bar:nth-child(4n+1)::after {
    display: block;
}

.history-footer {
    text-align: center;
    padding-top: 0.8rem;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.history-clear-btn {
    padding: 0.4rem 1rem;
    background: rgba(255, 107, 157, 0.08);
    border: 1px solid rgba(255, 107, 157, 0.2);
    border-radius: var(--border-radius-sm);
    color: var(--accent-tertiary);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.history-clear-btn:hover {
    background: rgba(255, 107, 157, 0.16);
    border-color: rgba(255, 107, 157, 0.35);
}

@media (max-width: 500px) {
    .history-summary {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* ================================================================
   TRACK OF THE DAY
   ================================================================ */
.track-of-the-day-banner {
    margin: 0.5rem 0.75rem 0.75rem;
    padding: 0.85rem 1rem;
    background: linear-gradient(135deg, rgba(74, 245, 199, 0.08) 0%, rgba(123, 104, 238, 0.08) 100%);
    border: 1px solid rgba(74, 245, 199, 0.2);
    border-radius: var(--border-radius-lg);
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.track-of-the-day-banner:hover {
    border-color: rgba(74, 245, 199, 0.4);
    background: linear-gradient(135deg, rgba(74, 245, 199, 0.12) 0%, rgba(123, 104, 238, 0.12) 100%);
}
.totd-label {
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-primary);
    white-space: nowrap;
}
.totd-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}
.totd-meta {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-shrink: 0;
}
.totd-play-btn {
    padding: 0.4rem 1rem;
    border-radius: 999px;
    border: 1px solid rgba(74, 245, 199, 0.4);
    background: rgba(74, 245, 199, 0.1);
    color: var(--accent-primary);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.totd-play-btn:hover {
    background: rgba(74, 245, 199, 0.2);
    border-color: rgba(74, 245, 199, 0.6);
}

/* ================================================================
   FEATURE 5: SOCIAL PROOF (PLAY COUNTS + TRENDING)
   ================================================================ */
.track-pill.plays {
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
}

.track-pill.trending {
    color: #ff9d5c;
    font-weight: 600;
    position: relative;
    padding-left: 0.2rem;
}

.track-pill.trending::before {
    content: '\1F525';
    font-size: 0.6rem;
    margin-right: 0.15rem;
}

.trending-badge-glow {
    animation: trendGlow 2s ease-in-out infinite;
}

@keyframes trendGlow {
    0%, 100% { text-shadow: none; }
    50% { text-shadow: 0 0 6px rgba(255, 157, 92, 0.4); }
}

/* Sort button for popular */
.sort-btn[data-sort="popular"] {
    color: #ff9d5c;
}

/* ================================================================
   FEATURE: SLEEP TIMER & SPEED POPUP MENUS
   ================================================================ */
.player-btn-group {
    position: relative;
    display: inline-flex;
}

.player-popup-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--border-radius);
    padding: 0.3rem;
    min-width: 100px;
    z-index: calc(var(--z-player) + 10);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.popup-menu-item {
    padding: 0.45rem 0.8rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    text-align: left;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.popup-menu-item:hover {
    background: rgba(74, 245, 199, 0.1);
    color: var(--text-primary);
}

.popup-menu-item.active {
    color: var(--accent-primary);
    font-weight: 600;
}

/* Speed button */
.speed-btn {
    font-size: 0.72rem !important;
    font-weight: 600;
    min-width: 36px;
    letter-spacing: -0.02em;
}

.speed-btn.active {
    color: var(--accent-primary);
}

/* Sleep timer active glow */
#btn-sleep-timer.active {
    color: var(--accent-warm);
}
#btn-sleep-timer.active svg {
    filter: drop-shadow(0 0 4px rgba(255, 166, 77, 0.4));
}

/* ================================================================
   FEATURE: SLEEP TIMER TOAST
   ================================================================ */
.sleep-timer-toast {
    position: fixed;
    bottom: calc(var(--player-height) + 16px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 166, 77, 0.3);
    color: var(--accent-warm);
    padding: 0.5rem 1.2rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 500;
    z-index: calc(var(--z-player) + 5);
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.sleep-timer-toast.hidden {
    opacity: 0;
}

/* ================================================================
   FEATURE: PULL TO REFRESH
   ================================================================ */
.pull-refresh-indicator {
    position: fixed;
    top: calc(var(--header-height) + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: var(--bg-secondary);
    border: 1px solid rgba(74, 245, 199, 0.2);
    color: var(--accent-primary);
    padding: 0.35rem 1rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 500;
    z-index: calc(var(--z-header) + 1);
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

/* ================================================================
   FEATURE: STREAK BADGE
   ================================================================ */
.streak-badge {
    position: fixed;
    top: calc(var(--header-height) + 12px);
    right: 16px;
    background: linear-gradient(135deg, rgba(255, 166, 77, 0.15), rgba(255, 107, 157, 0.15));
    border: 1px solid rgba(255, 166, 77, 0.3);
    color: var(--accent-warm);
    padding: 0.45rem 1rem;
    border-radius: var(--border-radius);
    font-size: 0.78rem;
    font-weight: 600;
    z-index: calc(var(--z-header) + 1);
    animation: streakSlideIn 0.4s ease-out, streakFadeOut 0.6s ease 5.4s forwards;
    pointer-events: none;
}

@keyframes streakSlideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes streakFadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* ================================================================
   FEATURE: RECENTLY PLAYED
   ================================================================ */
.recently-played-content {
    max-width: 420px;
}

.recently-played-list {
    max-height: 60vh;
    overflow-y: auto;
}

.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.65rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    gap: 0.5rem;
}

.recent-item:hover {
    background: rgba(74, 245, 199, 0.06);
}

.recent-item.playing {
    background: rgba(74, 245, 199, 0.1);
}

.recent-item.playing .recent-name {
    color: var(--accent-primary);
}

.recent-name {
    font-size: 0.82rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.recent-year {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.recent-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.8rem;
}

/* ================================================================
   FEATURE: MOBILE QUEUE COLLAPSE
   ================================================================ */
@media (max-width: 900px) {
    .queue-panel {
        position: relative;
        transition: max-height 0.25s ease;
    }

    .queue-panel.collapsed {
        max-height: 44px !important;
        overflow: hidden;
    }

    .queue-panel .browser-queue-header {
        cursor: pointer;
        user-select: none;
        position: relative;
    }

    .queue-panel .browser-queue-header::after {
        content: '';
        display: inline-block;
        width: 8px;
        height: 8px;
        border-right: 2px solid var(--text-tertiary);
        border-bottom: 2px solid var(--text-tertiary);
        transform: rotate(45deg);
        margin-left: 6px;
        transition: transform 0.2s ease;
        vertical-align: middle;
    }

    .queue-panel.collapsed .browser-queue-header::after {
        transform: rotate(-135deg);
    }
}

/* ================================================================
   FEATURE: MOBILE OVERLAY IMPROVEMENTS
   ================================================================ */
@media (max-width: 600px) {
    .overlay-content {
        width: 96%;
        max-height: 85vh;
        padding: 1.2rem;
        border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
        margin-top: auto;
    }

    .overlay {
        align-items: flex-end;
    }

    .overlay-content h2 {
        font-size: 1.1rem;
        padding-right: 2rem;
    }

    /* Swipe hint bar at top of overlay content on mobile */
    .overlay-content::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--text-tertiary);
        border-radius: 2px;
        margin: 0 auto 0.8rem;
        opacity: 0.5;
    }
}

/* ================================================================
   MOBILE TABBED NAVIGATION
   ================================================================ */

/* Hide mobile-only elements on desktop */
.mobile-only {
    display: none !important;
}

@media (max-width: 600px) {
    /* --- Show mobile-only elements --- */
    .mobile-only {
        display: flex !important;
    }

    /* --- Mobile Tab Bar --- */
    #mobile-tab-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: var(--bg-primary);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        display: flex !important;
        z-index: 50;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .mob-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        background: none;
        border: none;
        color: var(--text-tertiary);
        font-size: 0.6rem;
        padding: 4px 0;
        cursor: pointer;
        position: relative;
        transition: color var(--transition-fast);
        -webkit-tap-highlight-color: transparent;
    }

    .mob-tab.active {
        color: var(--accent-primary);
    }

    .mob-tab svg {
        width: 22px;
        height: 22px;
    }

    .mob-tab-badge {
        position: absolute;
        top: 2px;
        right: calc(50% - 18px);
        background: var(--accent-tertiary);
        color: #fff;
        font-size: 0.55rem;
        font-weight: 700;
        min-width: 16px;
        height: 16px;
        line-height: 16px;
        text-align: center;
        border-radius: 8px;
        padding: 0 4px;
    }

    .mob-tab-badge.hidden {
        display: none;
    }

    /* --- Mobile Mini-Player --- */
    #mobile-mini-player {
        position: fixed;
        bottom: 56px; /* above tab bar */
        left: 0;
        right: 0;
        height: 52px;
        background: var(--bg-secondary);
        border-top: 1px solid rgba(255, 255, 255, 0.06);
        display: none !important; /* hidden until track loaded */
        align-items: center;
        gap: 10px;
        padding: 0 12px;
        z-index: 49;
        margin-bottom: env(safe-area-inset-bottom, 0);
    }

    #mobile-mini-player.has-track {
        display: flex !important;
    }

    /* Hide mini-player on Now Playing tab */
    body.mobile-tab-playing #mobile-mini-player {
        display: none !important;
    }

    #mini-progress {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 2px;
        background: rgba(255, 255, 255, 0.05);
    }

    #mini-progress-fill {
        height: 100%;
        width: 0%;
        background: var(--accent-primary);
        transition: width 0.2s linear;
    }

    #mini-art {
        width: 36px;
        height: 36px;
        border-radius: 4px;
        background: var(--bg-tertiary);
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    #mini-art::after {
        content: '';
        width: 14px;
        height: 14px;
        border: 2px solid var(--text-tertiary);
        border-radius: 50%;
    }

    #mini-art.has-art::after {
        display: none;
    }

    #mini-info {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 1px;
    }

    #mini-title {
        font-size: 0.78rem;
        font-weight: 500;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #mini-artist {
        font-size: 0.65rem;
        color: var(--text-secondary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #mini-play-pause {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        border-radius: 50%;
        -webkit-tap-highlight-color: transparent;
    }

    #mini-play-pause:active {
        background: rgba(255, 255, 255, 0.1);
    }

    /* --- Tab Content Visibility Rules --- */

    /* Hide desktop sidebar on non-discover tabs */
    body.mobile-tab-browse .sidebar,
    body.mobile-tab-queue .sidebar,
    body.mobile-tab-playing .sidebar {
        display: none !important;
    }

    /* Hide desktop filter toggle when mobile tabs are active */
    body[class*="mobile-tab-"] .mobile-filter-toggle {
        display: none !important;
    }

    /* Always hide desktop player bar on mobile (mini-player replaces it) */
    body.mobile-tab-browse .player-bar,
    body.mobile-tab-queue .player-bar,
    body.mobile-tab-discover .player-bar {
        display: none !important;
    }

    /* BROWSE tab: show track list, search, timeline */
    body.mobile-tab-browse .main {
        display: flex;
        flex-direction: column;
    }
    body.mobile-tab-browse .queue-panel {
        display: none !important;
    }
    body.mobile-tab-browse .track-container {
        padding-bottom: 120px;
    }

    /* QUEUE tab: show queue panel full-screen */
    body.mobile-tab-queue .main {
        display: flex;
        flex-direction: column;
    }
    body.mobile-tab-queue .browser {
        display: none !important;
    }
    body.mobile-tab-queue .queue-panel {
        display: block !important;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 108px; /* tab bar + mini-player */
        width: 100%;
        max-width: 100%;
        border: none;
        overflow-y: auto;
        z-index: 5;
        background: var(--bg-primary);
    }
    body.mobile-tab-queue .queue-panel .browser-queue-section {
        max-height: none;
    }
    body.mobile-tab-queue .queue-panel .queue-list {
        max-height: none;
        overflow-y: auto;
    }
    body.mobile-tab-queue .queue-panel.collapsed .queue-list {
        display: block;
        max-height: none;
    }

    /* DISCOVER tab: show sidebar as full-width scrollable page */
    body.mobile-tab-discover .main {
        display: flex;
        flex-direction: column;
    }
    body.mobile-tab-discover .browser {
        display: none !important;
    }
    body.mobile-tab-discover .queue-panel {
        display: none !important;
    }
    body.mobile-tab-discover .sidebar {
        display: block !important;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 108px;
        width: 100% !important;
        max-width: 100% !important;
        overflow-y: auto;
        z-index: 5;
        background: var(--bg-primary);
        border-right: none;
        transform: translateX(0) !important; /* override 900px slide-in */
    }

    /* NOW PLAYING tab: show full player bar expanded */
    body.mobile-tab-playing .main {
        display: none !important;
    }
    body.mobile-tab-playing .player-bar {
        display: grid !important;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 56px; /* just tab bar, no mini-player */
        height: auto;
        min-height: unset;
        padding: 1.5rem 1rem;
        z-index: 5;
        background: var(--bg-primary);
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto auto;
        gap: 1rem;
        align-content: center;
        overflow-y: auto;
    }

    body.mobile-tab-playing .player-track-info {
        max-width: 100%;
        text-align: center;
        order: 1;
    }

    body.mobile-tab-playing .player-track-name {
        font-size: 1.2rem;
        white-space: normal;
    }

    body.mobile-tab-playing .player-track-meta {
        font-size: 0.85rem;
        margin-top: 0.3rem;
    }

    body.mobile-tab-playing .player-viz {
        order: 2;
        width: 100%;
        height: 120px;
        opacity: 1;
        position: relative;
    }

    body.mobile-tab-playing .player-controls {
        order: 3;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    body.mobile-tab-playing .player-progress {
        order: 4;
        grid-column: 1;
    }

    body.mobile-tab-playing .player-volume {
        display: flex;
        order: 5;
        justify-content: center;
    }

    body.mobile-tab-playing .player-btn {
        width: 44px;
        height: 44px;
    }

    body.mobile-tab-playing .play-btn {
        width: 56px;
        height: 56px;
    }

    /* Adjust header for mobile tabs */
    body[class*="mobile-tab-"] .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 25;
    }

    /* Content area needs top padding for fixed header */
    body[class*="mobile-tab-"] .main {
        margin-top: var(--header-height);
    }

    /* Ensure body overflow is handled */
    body[class*="mobile-tab-"] {
        overflow: hidden;
    }

    /* Landscape on short phones: hide mini-player to save space */
    @media (max-height: 500px) {
        #mobile-mini-player {
            display: none !important;
        }

        /* Adjust queue/discover bottom since no mini-player */
        body.mobile-tab-queue .queue-panel,
        body.mobile-tab-discover .sidebar {
            bottom: 56px;
        }
    }
}

/* Virtual scrolling is handled by JS in applyVirtualVisibility() */

/* ============================================================
   CONTEXT MENUS
   ============================================================ */
.ctx-menu {
    position: fixed;
    z-index: 500;
    min-width: 180px;
    max-width: 260px;
    padding: 6px 0;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    animation: ctxFadeIn 0.1s ease;
}

@keyframes ctxFadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}

.ctx-menu-item {
    display: block;
    width: 100%;
    padding: 8px 16px;
    margin: 0;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s;
    white-space: nowrap;
    font-family: inherit;
}

.ctx-menu-item:hover,
.ctx-menu-item:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    color: var(--accent-primary);
}

.ctx-menu-item.disabled {
    color: var(--text-tertiary);
    cursor: default;
    pointer-events: none;
}

.ctx-menu-sep {
    height: 1px;
    margin: 4px 12px;
    background: rgba(255, 255, 255, 0.08);
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================
   SAFE AREAS (notch / Dynamic Island)
   ============================================================ */
@supports (padding: env(safe-area-inset-left)) {
    .app-header,
    #player-bar,
    .mobile-tab-bar {
        padding-left: env(safe-area-inset-left, 0);
        padding-right: env(safe-area-inset-right, 0);
    }
}

/* ============================================================
   OFFLINE INDICATOR
   ============================================================ */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    padding: 6px 16px;
    background: var(--accent-warm);
    color: var(--bg-deep);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-align: center;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}
.offline-banner.visible {
    transform: translateY(0);
}

/* ============================================================
   PWA INSTALL PROMPT
   ============================================================ */
.pwa-install-banner {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    animation: ctxFadeIn 0.2s ease;
    max-width: 340px;
    width: calc(100vw - 32px);
}
.pwa-install-banner button {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-size: var(--font-size-sm);
    cursor: pointer;
    white-space: nowrap;
}
.pwa-install-btn {
    background: var(--accent-primary);
    color: var(--bg-deep);
    font-weight: 600;
}
.pwa-dismiss-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}
.pwa-install-banner p {
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    margin: 0;
}

/* ============================================================
   SW UPDATE TOAST
   ============================================================ */
.sw-update-toast {
    position: fixed;
    bottom: 100px;
    right: 16px;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    animation: ctxFadeIn 0.2s ease;
}
.sw-update-toast button {
    padding: 5px 12px;
    border: none;
    border-radius: 6px;
    background: var(--accent-primary);
    color: var(--bg-deep);
    font-weight: 600;
    font-size: var(--font-size-xs);
    cursor: pointer;
}

