* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0a0a0f;
    color: #ccc;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    overflow: hidden;
}

/* ------------------------------------------------------------------ */
/* Three.js canvas                                                     */
/* ------------------------------------------------------------------ */

#canvas-container {
    position: fixed;
    inset: 0;
    z-index: 0;
}

/* ------------------------------------------------------------------ */
/* Drawer toggle button                                                */
/* ------------------------------------------------------------------ */

#drawer-toggle {
    position: fixed;
    bottom: 12px;
    right: 12px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #7af;
    color: #0a0a0f;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 1100;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    transition: background 0.2s, color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

#drawer-toggle:hover {
    background: #9cf;
}

#drawer-toggle.open {
    background: #444;
    color: #fff;
    box-shadow: none;
}

/* ------------------------------------------------------------------ */
/* Scrim overlay                                                       */
/* ------------------------------------------------------------------ */

#drawer-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#drawer-scrim.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ------------------------------------------------------------------ */
/* Drawer — mobile-first (bottom sheet)                                */
/* ------------------------------------------------------------------ */

#drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 75vh;
    background: rgba(10, 10, 20, 0.98);
    border-top: 1px solid #333;
    border-radius: 12px 12px 0 0;
    z-index: 1060;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#drawer.open {
    transform: translateY(0);
}

/* ------------------------------------------------------------------ */
/* Drawer handle (mobile swipe affordance)                             */
/* ------------------------------------------------------------------ */

#drawer-handle {
    padding: 10px 0 4px;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
    cursor: grab;
}

#drawer-grip {
    width: 36px;
    height: 4px;
    background: #555;
    border-radius: 2px;
}

/* ------------------------------------------------------------------ */
/* Drawer content — scrollable                                         */
/* ------------------------------------------------------------------ */

#drawer-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 16px 20px;
    min-height: 0;
}

#drawer-content h1 {
    font-size: 13px;
    color: #7af;
    letter-spacing: 2px;
    margin-bottom: 4px;
}

#drawer-content .subtitle {
    font-size: 10px;
    color: #555;
    margin-bottom: 16px;
    line-height: 1.5;
}

#drawer-content h2 {
    font-size: 10px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 18px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #222;
}

/* ------------------------------------------------------------------ */
/* Form controls                                                       */
/* ------------------------------------------------------------------ */

.ctrl-row {
    margin-bottom: 10px;
}

.ctrl-row label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 11px;
    color: #999;
    margin-bottom: 4px;
}

.ctrl-row .val {
    color: #7af;
    font-size: 11px;
    font-weight: bold;
}

.ctrl-row input[type="range"] {
    width: 100%;
    accent-color: #7af;
    height: 4px;
}

.ctrl-row select,
.ctrl-row textarea {
    width: 100%;
    background: #151520;
    color: #ccc;
    border: 1px solid #333;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 12px;
    border-radius: 3px;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.ctrl-row select:focus,
.ctrl-row textarea:focus {
    border-color: #7af;
}

.ctrl-row textarea {
    height: 64px;
    resize: vertical;
    line-height: 1.4;
}

#grid-info {
    font-size: 11px;
    color: #7af;
    padding: 6px 8px;
    background: #111118;
    border-radius: 3px;
    border: 1px solid #222;
}

/* ------------------------------------------------------------------ */
/* Layer toggles                                                       */
/* ------------------------------------------------------------------ */

#layer-toggles {
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
}

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 11px;
    color: #aaa;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.layer-toggle:hover {
    color: #fff;
}

.layer-toggle input[type="checkbox"] {
    accent-color: #7af;
    margin: 0;
    width: 16px;
    height: 16px;
}

.layer-swatch {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

/* ------------------------------------------------------------------ */
/* Rebuild button                                                      */
/* ------------------------------------------------------------------ */

#rebuild-btn {
    width: 100%;
    padding: 12px;
    margin-top: 16px;
    background: #7af;
    color: #0a0a0f;
    border: none;
    font-family: inherit;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1.5px;
    cursor: pointer;
    border-radius: 3px;
    text-transform: uppercase;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

#rebuild-btn:hover {
    background: #9cf;
}

/* ------------------------------------------------------------------ */
/* Info bar                                                            */
/* ------------------------------------------------------------------ */

#info {
    position: fixed;
    bottom: 10px;
    left: 12px;
    font-size: 10px;
    color: #444;
    z-index: 100;
    pointer-events: none;
}

/* ------------------------------------------------------------------ */
/* Desktop: drawer becomes a side panel                                */
/* ------------------------------------------------------------------ */

@media (min-width: 769px) {
    #drawer {
        top: 0;
        bottom: 0;
        left: auto;
        right: 0;
        width: 300px;
        max-height: none;
        border-radius: 0;
        border-top: none;
        border-left: 1px solid #333;
        transform: translateX(100%);
    }

    #drawer.open {
        transform: translateX(0);
    }

    #drawer-handle {
        display: none;
    }

    #drawer-content {
        padding-top: 20px;
    }
}

/* ------------------------------------------------------------------ */
/* Small mobile: tighter layout                                        */
/* ------------------------------------------------------------------ */

@media (max-width: 480px) {
    #drawer {
        max-height: 80vh;
    }

    #drawer-content h1 {
        font-size: 12px;
    }

    #info {
        bottom: 68px;
        font-size: 9px;
    }
}
