body {
    margin: 0;
    display: flex;
    font-family: system-ui, -apple-system, sans-serif;
    height: 100vh;
    overflow: hidden;
}

#sidebar {
    width: 300px;
    background: #0f172a;
    color: white;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 10;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

#sidebar h2 {
    margin: 0;
    font-size: 1.2rem;
    border-bottom: 1px solid #334155;
    padding-bottom: 10px;
}

.tool-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

button {
    padding: 10px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    text-align: left;
    transition: all 0.2s;
}

button:hover {
    background: #2563eb;
}

button.active {
    background: #059669;
}

button.secondary-btn {
    background: #475569;
}

button.secondary-btn:hover {
    background: #64748b;
}

button.danger {
    background: #ef4444;
}

button.danger:hover {
    background: #dc2626;
}

.param-box {
    background: #1e293b;
    padding: 14px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 0.85rem;
    border: 1px solid #334155;
}

.param-box label {
    display: grid;
    grid-template-columns: 1fr auto 10px;
    /* Texte | Input | Unité alignée sur une largeur fixe de 10px */
    align-items: center;
    gap: 8px;
    color: #cbd5e1;
}

.param-box input {
    width: 50px;
    height: 20px;
    background: #0f172a;
    border: 1px solid #475569;
    color: white;
    border-radius: 4px;
    text-align: center;
    font-size: 0.85rem;
}

.param-box input:focus {
    outline: none;
    border-color: #38bdf8;
}

.param-box .unit {
    text-align: center;
}

.param-box input[type="checkbox"] {
    width: auto;
    height: auto;
    background: transparent;
    border: none;
}

.info-box {
    background: #334155;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    line-height: 1.4;
    color: #cbd5e1;
}

#canvas-container {
    flex: 1;
    background: #f8fafc;
    position: relative;
    overflow: hidden;
}

canvas {
    display: block;
    touch-action: none;
    /* Bloque le scroll tactile natif sur le canvas */
}

/* Boutons spécifiques au mobile */
#menuToggleBtn {
    display: none;
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 15;
    background: #0f172a;
    color: white;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: bold;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.mobile-only-btn {
    display: none;
    background: #475569;
    text-align: center;
}

#sidebarOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 25;
}

/* RESPONSIVE MOBILE */
@media (max-width: 768px) {
    #menuToggleBtn {
        display: block;
    }

    .mobile-only-btn {
        display: block;
    }

    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        z-index: 30;
        transform: translateX(-100%);
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.3);
    }

    #sidebar.open {
        transform: translateX(0);
    }

    #sidebarOverlay.open {
        display: block;
    }
}

/* POPUP CONTEXTUEL */
.context-popup {
    position: absolute;
    display: none;
    background: #1e293b;
    color: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    border: 1px solid #475569;
    font-size: 0.85rem;
    z-index: 20;
    flex-direction: column;
    gap: 10px;
    width: 190px;
}

.context-popup strong {
    color: #38bdf8;
    font-size: 0.9rem;
}

.context-popup label {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.context-popup input {
    width: 65px;
    padding: 4px;
    background: #334155;
    border: 1px solid #64748b;
    color: white;
    border-radius: 4px;
    text-align: right;
}

.context-popup .popup-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.context-popup button {
    padding: 6px 10px;
    font-size: 0.75rem;
    text-align: left;
    color: black;
    width: 100%;
}

#popupCloseBtn {
    padding: 6px 10px;
    font-size: 0.75rem;
    text-align: right;
    color: black;
    width: 100%;
}

#view3dBtn {
    background: #8b5cf6;
    color: #ffffff;
    font-weight: 600;
    transition: background 0.2s ease;
}

#view3dBtn:hover {
    background: #7c3aed;
}