:root {
    --bg-deep: #2a0a38;
    --sidebar-bg: #14051e;
    --workspace-bg: transparent;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --primary: #d946ef;
    --primary-glow: rgba(217, 70, 239, 0.4);
    --text-main: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
    --player-bg: #1a0524;
    
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --ease: cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    background-color: var(--bg-deep);
    color: var(--text-main);
    font-family: var(--font-family);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* Hide Scrollbars */
::-webkit-scrollbar { display: none; }
* { -ms-overflow-style: none; scrollbar-width: none; }

/* Background Canvas */
#bg-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    opacity: 0.6;
    pointer-events: none;
}

/* App Layout Grid */
.app-layout {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-areas: 
        "sidebar workspace"
        "player player";
    grid-template-columns: 250px 1fr;
    grid-template-rows: 1fr 80px;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    grid-area: sidebar;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 100;
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    color: white;
    margin-bottom: 40px;
}
.brand .ext { color: var(--primary); }

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    transition: 0.2s;
}

.nav-links a:hover, .nav-links a.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-footer {
    margin-top: auto;
}

/* Workspace */
.workspace {
    grid-area: workspace;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 32px;
    overflow-y: auto;
    background: var(--workspace-bg);
}

.mobile-menu-btn {
    display: none;
    position: absolute;
    top: 24px;
    left: 20px;
    z-index: 50;
    color: white;
}

/* Drop Overlay */
.drop-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(20, 5, 30, 0.8);
    backdrop-filter: blur(5px);
    z-index: 100;
    transition: opacity 0.3s;
}
.drop-overlay.hidden { opacity: 0; pointer-events: none; }

.drop-message {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 40px;
    border: 2px dashed var(--card-border);
    border-radius: 16px;
}
.drop-message h2 { font-size: 1.5rem; }
.drop-message p { color: var(--text-muted); }

.btn-browse {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px 24px;
    border-radius: 24px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}
.btn-browse:hover { background: rgba(255, 255, 255, 0.2); }

/* Workspace Content */
.track-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
}
.header-actions {
    display: flex;
    gap: 12px;
}
.track-meta h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 500px;
}
.time-tag { font-family: monospace; color: var(--primary); font-size: 0.9rem; }

.btn-action {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    transition: 0.2s;
}
.btn-action:hover:not(:disabled) { background: white; color: black; }
.btn-action:disabled { opacity: 0.5; cursor: default; }

.loader-mini {
    display: none;
    width: 14px; height: 14px;
    border: 2px solid rgba(0,0,0,0.1);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Waveform Visualizer */
.visualizer-container {
    position: relative;
    width: 100%;
    height: 160px;
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    margin-bottom: 32px;
    overflow: hidden;
    border: 1px solid var(--card-border);
    cursor: crosshair;
}
#waveform-canvas {
    width: 100%; height: 100%;
}
.waveform-overlay {
    position: absolute;
    top: 0; left: 0; height: 100%;
    width: 2px;
    background: white;
    pointer-events: none;
    display: none; /* Controlled by JS */
}

/* Controls */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.section-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.presets-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.preset-btns { display: flex; gap: 12px; flex-wrap: wrap; }

.btn-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: 0.2s;
}
.btn-chip:hover { border-color: var(--primary); color: var(--primary); }
.btn-chip.outline { background: transparent; border: 1px solid var(--text-muted); color: var(--text-muted); }

.sliders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.control-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.95rem;
}
.control-header .val { color: var(--primary); font-family: monospace; }
.control-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Range Inputs - Pro Style */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    cursor: pointer;
    height: 24px; /* Touch target */
    margin: 4px 0;
}

/* Track */
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

input[type=range]:hover::-webkit-slider-runnable-track {
    background: rgba(255, 255, 255, 0.25);
}

input[type=range]::-moz-range-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

/* Thumb */
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: white;
    margin-top: -8px; /* Center on track */
    box-shadow: 0 0 15px var(--primary-glow), 0 0 5px rgba(0,0,0,0.5);
    border: 2px solid var(--bg-deep); /* Contrast ring */
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: var(--primary);
}

input[type=range]::-moz-range-thumb {
    height: 20px;
    width: 20px;
    border: none;
    border-radius: 50%;
    background: white;
    box-shadow: 0 0 15px var(--primary-glow), 0 0 5px rgba(0,0,0,0.5);
    border: 2px solid var(--bg-deep);
    transition: transform 0.1s;
}

input[type=range]::-moz-range-thumb:hover {
    transform: scale(1.1);
    background: var(--primary);
}

/* Toggle Switch */
.switch { position: relative; width: 32px; height: 18px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer;
    inset: 0; background: #444; border-radius: 18px; transition: .4s;
}
.slider:before {
    position: absolute; content: "";
    height: 14px; width: 14px;
    left: 2px; bottom: 2px;
    background: white; border-radius: 50%; transition: .4s;
}
input:checked + .slider { background: var(--primary); }
input:checked + .slider:before { transform: translateX(14px); }


/* Player Bar */
.player-bar {
    grid-area: player;
    background: var(--player-bg);
    border-top: 1px solid var(--card-border);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 24px;
    gap: 40px;
    z-index: 20;
    transition: background-color 0.2s;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn-icon {
    background: transparent; border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
    display: flex; align-items: center;
}
.btn-icon:hover { color: white; }
.btn-icon.toggle.active { color: var(--primary); }

.btn-play {
    width: 50px; height: 50px;
    border-radius: 50%;
    background: white;
    color: black;
    border: none;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer;
    transition: transform 0.2s;
}
.btn-play:hover:not(:disabled) { transform: scale(1.05); }
.btn-play:disabled { background: #444; color: #888; cursor: not-allowed; }

.divider { width: 1px; height: 24px; background: rgba(255,255,255,0.1); margin: 0 8px; }

.volume-control {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 150px;
    color: var(--text-muted);
}

/* Animations */
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Modals */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex; justify-content: center; align-items: center;
    opacity: 1; transition: opacity 0.3s;
}
.modal-overlay.hidden { opacity: 0; pointer-events: none; }

.modal-content {
    background: var(--sidebar-bg);
    border: 1px solid var(--card-border);
    padding: 30px;
    border-radius: 16px;
    width: 90%; max-width: 500px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    display: none;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-content h3 { margin-bottom: 20px; font-size: 1.5rem; color: white; }
.modal-body p { margin-bottom: 12px; line-height: 1.5; color: var(--text-muted); }
.modal-body strong { color: white; }

.theme-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 12px;
}
.color-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.color-item label {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.theme-row input[type=color] {
    width: 100%; height: 36px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
}
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .app-layout {
        grid-template-areas: 
            "workspace";
        grid-template-columns: 1fr;
        grid-template-rows: 1fr; /* Fill height */
        height: 100vh;
        height: -webkit-fill-available;
    }
    
    .sidebar { 
        position: fixed;
        top: 0; left: 0; bottom: 70px; /* Leave space for player */
        width: 250px;
        transform: translateX(-100%);
        transition: transform 0.3s var(--ease), background-color 0.2s;
        border-right: 1px solid rgba(255,255,255,0.1);
        background: var(--sidebar-bg);
        display: flex; 
        z-index: 200;
    }
    .sidebar.open { transform: translateX(0); }
    
    .mobile-menu-btn { display: flex; }

    .workspace { 
        padding: 16px; 
        padding-top: 70px; /* Space for header/menu */
        padding-bottom: 90px; /* Space for fixed player */
    }

    .track-header {
        margin-bottom: 16px;
    }

    /* Adjust positioning of absolute header elements */
    .track-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .header-actions {
        position: absolute;
        top: 20px;
        right: 16px;
    }

    .track-meta { width: 100%; padding-right: 140px; } /* Space for buttons */
    .track-meta h2 { font-size: 1.2rem; }
    
    .btn-action span { display: none; } /* Icon only on mobile */
    .player-bar { 
        gap: 12px; 
        padding: 0 16px; 
        justify-content: space-between; 
        height: 70px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        background: var(--player-bg);
        border-top: 1px solid var(--card-border);
    }
    
    .divider { display: none; }

    .volume-control { width: 30%; gap: 8px; }
    
    .visualizer-container { height: 100px; margin-bottom: 20px; }
    
    .sliders-grid { grid-template-columns: 1fr; gap: 16px; }
    
    /* Make sliders thumb bigger for touch */
    input[type=range]::-webkit-slider-thumb {
        width: 24px; height: 24px; margin-top: -10px;
    }
    input[type=range]::-moz-range-thumb {
        width: 24px; height: 24px;
    }

    /* Adjust controls spacing */
    .controls-section { gap: 16px; padding-bottom: 20px; }
    
    .preset-btns { gap: 8px; }
    .btn-chip { padding: 6px 12px; font-size: 0.8rem; }
}

