:root {
    --font-primary: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Color Palette */
    --bg-dark: #090a10;
    --bg-card: rgba(18, 20, 32, 0.65);
    --bg-card-hover: rgba(28, 31, 48, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(0, 242, 254, 0.3);
    
    --accent-cyan: #00f2fe;
    --accent-blue: #4facfe;
    --accent-purple: #7f00ff;
    --accent-pink: #ff007f;
    
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --gradient-primary: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    --gradient-glow: linear-gradient(135deg, rgba(0,242,254,0.4), rgba(127,0,255,0.4));
    
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;
    
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100dvh;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: stretch;
    touch-action: manipulation;
}

/* Background Animated Orbs */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at 50% 50%, #0d111d 0%, #05060a 100%);
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.45;
    animation: floatOrb 18s infinite alternate ease-in-out;
}

.orb-1 {
    width: 450px;
    height: 450px;
    background: var(--accent-purple);
    top: -100px;
    left: -100px;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: var(--accent-cyan);
    bottom: -150px;
    right: -100px;
    animation-delay: -6s;
}

.orb-3 {
    width: 350px;
    height: 350px;
    background: var(--accent-pink);
    top: 40%;
    left: 45%;
    animation-delay: -12s;
}

@keyframes floatOrb {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(60px, 40px) scale(1.15); }
    100% { transform: translate(-40px, -50px) scale(0.9); }
}

/* Container */
.container {
    width: 100%;
    max-width: 1280px;
    padding: 24px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 100dvh;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(18, 20, 32, 0.5);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-glass);
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.4);
}

.logo-text h1 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: #fff;
}

.logo-text h1 span {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tagline {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Buttons & Touch Target Ergonomics */
.btn {
    min-height: 44px;
    padding: 10px 20px;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
    touch-action: manipulation;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.3);
}

.btn-primary:active {
    transform: scale(0.96);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.btn-icon:hover, .btn-icon:active {
    color: var(--text-main);
}

/* Mobile Tabs Switcher (Hidden on Desktop) */
.mobile-tabs {
    display: none;
    background: rgba(18, 20, 32, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 4px;
    gap: 6px;
}

.mobile-tab-btn {
    flex: 1;
    min-height: 44px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-fast);
}

.mobile-tab-btn.active {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 4px 16px rgba(0, 242, 254, 0.3);
}

/* Workspace Grid */
.workspace {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 20px;
    flex: 1;
}

.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

/* Player Section */
.player-section {
    gap: 18px;
}

.visualizer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.now-playing-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-dim);
    transition: var(--transition-fast);
}

.status-dot.playing {
    background-color: #10b981;
    box-shadow: 0 0 10px #10b981;
    animation: pulseGlow 1.5s infinite;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.viz-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.viz-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.viz-btn.active, .viz-btn:active {
    background: var(--gradient-primary);
    color: #fff;
    border-color: transparent;
}

/* Canvas Visualizer */
.visualizer-container {
    position: relative;
    width: 100%;
    height: 220px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

#audioVisualizer {
    width: 100%;
    height: 100%;
    display: block;
}

.visualizer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(9, 10, 16, 0.75);
    transition: opacity 0.5s ease;
}

.visualizer-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.fallback-icon {
    font-size: 42px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.overlay-hint {
    font-size: 14px;
    color: var(--text-muted);
}

/* Track Info */
.track-details {
    display: flex;
    align-items: center;
    gap: 14px;
}

.album-art {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    background: var(--gradient-glow);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--accent-cyan);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.track-info {
    flex: 1;
    overflow: hidden;
}

.track-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-artist {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.favorite-btn {
    font-size: 20px;
    padding: 8px;
}

.favorite-btn.active {
    color: var(--accent-pink);
}

/* Touch Friendly Sliders */
.progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.time-display {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 36px;
}

.slider-wrapper {
    position: relative;
    flex: 1;
    height: 10px; /* Enhanced hit area for touch */
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    touch-action: none;
}

.progress-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    width: 0%;
    pointer-events: none;
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.5);
}

.audio-slider {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

/* Main Controls */
.player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 4px 0;
}

.control-btn {
    font-size: 18px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
}

.control-btn.active {
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
    background: rgba(0, 242, 254, 0.12);
}

.play-btn {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: #fff;
    font-size: 24px;
    box-shadow: 0 6px 20px rgba(0, 242, 254, 0.4);
}

.play-btn:active {
    transform: scale(0.93);
}

/* Volume */
.volume-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.volume-btn {
    font-size: 16px;
}

.volume-slider-wrapper {
    max-width: 140px;
}

.volume-percentage {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 35px;
}

/* Playlist & Dropzone Section */
.playlist-section {
    gap: 18px;
}

.dropzone {
    border: 2px dashed rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.dropzone:active, .dropzone.dragover {
    border-color: var(--accent-cyan);
    background: rgba(0, 242, 254, 0.08);
}

.drop-icon {
    font-size: 30px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

.dropzone h3 {
    font-size: 15px;
    font-weight: 700;
}

.drop-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.upload-progress-container {
    margin-top: 14px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.upload-progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    width: 0%;
    transition: width 0.2s ease;
}

.upload-status {
    font-size: 11px;
    color: var(--accent-cyan);
    display: block;
    margin-top: 6px;
}

/* Playlist Header */
.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.playlist-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.playlist-title-group h3 {
    font-size: 16px;
    font-weight: 700;
}

.badge {
    font-size: 11px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.08);
    color: var(--accent-cyan);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(0, 242, 254, 0.2);
}

.search-box {
    position: relative;
    max-width: 170px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    height: 36px;
    padding: 6px 12px 6px 32px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-main);
    font-family: inherit;
    font-size: 12px;
    outline: none;
}

.search-box input:focus {
    border-color: var(--accent-cyan);
}

/* Track List Items */
.track-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    max-height: 380px;
    padding-right: 4px;
}

.track-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    min-height: 60px; /* Touch target */
    transition: var(--transition-smooth);
}

.track-item:active {
    transform: scale(0.98);
}

.track-item.active {
    background: rgba(0, 242, 254, 0.08);
    border-color: var(--accent-cyan);
    box-shadow: 0 4px 16px rgba(0, 242, 254, 0.15);
}

.track-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.track-item.active .track-icon {
    background: var(--gradient-primary);
    color: #fff;
}

.track-meta {
    flex: 1;
    overflow: hidden;
}

.track-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-sub {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
}

.fmt-pill {
    text-transform: uppercase;
    font-size: 9px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--accent-cyan);
}

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

.delete-btn {
    min-width: 40px;
    min-height: 40px;
    font-size: 15px;
    color: var(--text-dim);
}

.delete-btn:active {
    color: var(--accent-pink);
}

.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Equalizer Animated Bars */
.eq-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 16px;
}

.eq-bar {
    width: 3px;
    background: #fff;
    border-radius: 1px;
    animation: eqAnim 0.8s infinite ease-in-out alternate;
}

.eq-bar:nth-child(1) { height: 40%; animation-delay: 0.1s; }
.eq-bar:nth-child(2) { height: 100%; animation-delay: 0.3s; }
.eq-bar:nth-child(3) { height: 60%; animation-delay: 0.2s; }

@keyframes eqAnim {
    0% { height: 20%; }
    100% { height: 100%; }
}

/* Mobile Sticky Mini-Player */
.mobile-mini-player {
    display: none;
    position: fixed;
    bottom: 12px;
    left: 12px;
    right: 12px;
    height: 64px;
    background: rgba(18, 20, 32, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 6px 14px;
    align-items: center;
    gap: 12px;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
}

.mini-art {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    flex-shrink: 0;
}

.mini-info {
    flex: 1;
    overflow: hidden;
}

.mini-title {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-sub {
    font-size: 11px;
    color: var(--accent-cyan);
}

.mini-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: #fff;
    font-size: 16px;
}

/* Mobile Responsive Breakpoints */
@media (max-width: 768px) {
    .container {
        padding: 12px;
        gap: 14px;
        padding-bottom: 90px; /* Safe padding for sticky mini player */
    }

    .header {
        padding: 12px 16px;
    }

    .btn-text {
        display: none; /* Icon-only upload button on small screens */
    }

    .mobile-tabs {
        display: flex;
    }

    .workspace {
        grid-template-columns: 1fr;
    }

    /* Mobile Tab Switching Logic */
    .player-section, .playlist-section {
        display: none;
    }

    .player-section.mobile-view-active, .playlist-section.mobile-view-active {
        display: flex;
    }

    .visualizer-container {
        height: 180px;
    }

    .track-list {
        max-height: calc(100vh - 380px);
    }

    /* Show mini player on mobile when library is open */
    .mobile-mini-player.show {
        display: flex;
    }
}
