body { 
    font-family: 'Inter', sans-serif; 
    background-color: #f3f4f6;
    overscroll-behavior: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* --- Layout Principal --- */
#app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* --- Sidebar --- */
#sidebar {
    width: 320px;
    background: white;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    z-index: 50;
    box-shadow: 4px 0 24px rgba(0,0,0,0.05);
    transition: transform 0.3s ease;
}

/* Mobile Sidebar Toggle */
#sidebar-toggle {
    display: none;
}

@media (max-width: 768px) {
    #sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
    }
    #sidebar.open {
        transform: translateX(0);
    }
    #sidebar-toggle {
        display: block;
    }
}

/* --- Canvas Area --- */
#main-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: #e5e5e5;
    /* Damier de fond */
    background-image: 
        linear-gradient(45deg, #ddd 25%, transparent 25%), 
        linear-gradient(-45deg, #ddd 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #ddd 75%), 
        linear-gradient(-45deg, transparent 75%, #ddd 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

#canvas-wrapper {
    width: 100%;
    height: 100%;
    position: relative; /* Positioning context for children */
    overflow: hidden;
    background-color: #e5e5e5; /* Match main-area */
    touch-action: none;
    /* Removed flex to avoid centering interference with transform coordinates */
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 500px; /* Explicit size */
    height: 500px;
    transform-origin: 0 0; 
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    image-rendering: pixelated;
    background: white;
}

canvas {
    display: block;
    image-rendering: pixelated;
    background: white;
}

/* --- Curseur --- */
#pixel-cursor {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
    z-index: 10;
    display: none;
    /* Box shadow pour faire un contour qui reste visible */
    border: 1px solid rgba(0,0,0,0.5);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.5);
    transition: transform 0.05s linear; /* Smooth movement if needed, or remove for instant */
}

/* --- Palette --- */
#palette-grid {
    padding: 8px 12px;
    background: rgba(255,255,255,0.8);
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.color-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 10px;
    border: 2px solid rgba(0,0,0,0.1); /* Slightly darker border for visibility */
    background: #fff; /* Fallback */
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.color-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.color-btn.active {
    transform: scale(1.15) translateY(-4px);
    border-color: white;
    box-shadow: 0 0 0 2px #059669, 0 8px 16px rgba(0,0,0,0.2); /* Emerald ring */
    z-index: 10;
}

/* --- Onglets --- */
.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
}
.tab-content.active {
    display: block;
}

/* --- Loading --- */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.95);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
