/* Reset and basic setup */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    font-family:
        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
    color: #333;
}

#canvas-container {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Control Panel */
#control-panel {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 300px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 12px;
    padding: 24px;
    z-index: 10;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

#drawer-handle {
    display: none; /* Hidden on desktop */
}

/* Header */
.panel-header {
    display: flex;
    align-items: center;
    margin-bottom: 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 16px;
}

.logo {
    height: 32px;
    width: auto;
    margin-right: 12px;
}

.panel-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    letter-spacing: -0.02em;
}

/* Control Sections */
.control-section {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.section-label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    font-weight: 600;
}

/* Range Slider */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: #000;
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #e0e0e0;
    border-radius: 2px;
}

/* Layer Toggles */
.layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.layer-item:last-child {
    border-bottom: none;
}

.layer-label {
    font-size: 14px;
    font-weight: 500;
    color: #4a4a4a;
    text-transform: capitalize;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
    background-color: #000; /* Premium black active state */
}

input:focus + .slider {
    box-shadow: 0 0 1px #000;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Action Button */
.action-btn {
    flex: 1;
    padding: 12px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 24px;
}

.action-btn:hover {
    background: #333;
}

/* Loading Overlay */
#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #f0f0f0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    transition: opacity 0.5s ease-out;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #ccc;
    border-top: 5px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

#loading-text {
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Mobile Styles --- */
@media (max-width: 768px) {
    #control-panel {
        width: 100%;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        transform: translateY(0);
        border-radius: 20px 20px 0 0;
        padding-top: 12px;
        max-height: 80vh; /* Prevent covering whole screen */
        overflow-y: auto;
    }

    #control-panel.collapsed {
        transform: translateY(calc(100% - 30px));
    }

    #drawer-handle {
        display: block;
        width: 40px;
        height: 5px;
        background-color: #ccc;
        border-radius: 3px;
        margin: 0 auto 16px auto;
        cursor: pointer;
        position: relative;
    }
    
    /* Ensure handle click area is easy to hit */
    #drawer-handle::after {
        content: '';
        display: block;
        position: absolute;
        top: -10px;
        left: -20px;
        right: -20px;
        bottom: -10px;
    }
}
