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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

h1 {
    color: #333;
    margin-bottom: 20px;
}

.controls {
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
}

.controls input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

#grid-container {
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: auto;
    min-height: 500px;
}

/* Grille de fond (debug) */
#grid-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.1;
    pointer-events: none;
    background-image: 
        linear-gradient(to right, #ccc 1px, transparent 1px),
        linear-gradient(to bottom, #ccc 1px, transparent 1px);
    background-size: var(--cell-width) var(--cell-height);
    background-position: var(--gap-x) var(--gap-y);
    display: none;
}

#grid-background.show {
    display: block;
}

/* SVG pour les ligatures */
#links-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

#links-svg path {
    fill: none;
    stroke-width: 2;
    pointer-events: stroke;
    transition: stroke-width 0.2s ease;
}

#links-svg path.straight {
    stroke: #4a90e2;
}

#links-svg path.curved {
    stroke: #50c878;
}

#links-svg path.highlighted {
    stroke-width: 4;
    opacity: 1;
}

#links-svg path.faded {
    opacity: 0.2;
}

/* Conteneur des éléments */
#elements-container {
    position: relative;
    z-index: 2;
}

/* Éléments de la grille */
.grid-element {
    position: absolute;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 2px solid #5a67d8;
    border-radius: 8px;
    padding: 12px;
    color: white;
    font-weight: 500;
    font-size: 14px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    cursor: move;
    cursor: grab;
    transition: box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 40px;
    user-select: none;
}

.grid-element:hover:not(.dragging) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    z-index: 10;
}

.grid-element.dragging {
    cursor: grabbing;
    cursor: move;
    opacity: 0.8;
    z-index: 1000;
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    transform: scale(1.05);
}

.grid-element.highlighted {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-color: #e53e3e;
    box-shadow: 0 0 0 4px rgba(245, 87, 108, 0.3);
    z-index: 10;
}

/* Points d'ancrage visuels (optionnel, pour debug) */
.anchor-point {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #ff0000;
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 100;
    pointer-events: none;
}

.grid-element:hover .anchor-point {
    opacity: 1;
}

