/* =========================================
   WILD CANVAS - Styles
   ========================================= */

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

body {
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a1a;
    color: #eee;
    height: 100vh;
    width: 100vw;
}

/* --- NOM DU CANVAS (haut gauche) --- */
#canvas-title {
    position: fixed;
    top: 20px;
    left: 24px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
}
#canvas-title-text {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.02em;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.2s;
    outline: none;
    min-width: 40px;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#canvas-title-text:hover {
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}
#canvas-title-text.editing {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(56, 189, 248, 0.5);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
    white-space: normal;
    overflow: visible;
}

/* --- CANEVAS --- */
#canvas {
    position: absolute;
    inset: 0;
    overflow: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: crosshair;
    background-image:
        radial-gradient(circle, rgba(199, 199, 199, 0.219) 1px, rgb(22, 22, 22) 1px);
    background-size: 30px 30px;
}
#canvas::-webkit-scrollbar {
    display: none;
}

/* --- GRILLE FIXE --- */
.fixed-grid {
    position: absolute;
    width: 1280px;
    height: 368px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 6px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(4, 1fr);
    pointer-events: none;
    user-select: none;
    z-index: 1;
}
.fixed-grid .grid-cell {
    border: 1px solid rgba(255, 255, 255, 0.15);
}

body.painting #canvas {
    cursor: cell;
}

body.erasing #canvas {
    cursor: crosshair;
}

body.erasing .canvas-visual,
body.erasing .canvas-block {
    cursor: pointer;
    outline: 2px dashed transparent;
    transition: outline-color 0.15s;
}
body.erasing .canvas-visual:hover,
body.erasing .canvas-block:hover {
    outline-color: #ff4444;
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.3);
}
body.erasing .audio-player,
body.erasing .video-player,
body.erasing .pdf-embed,
body.erasing .block-open-btn,
body.erasing iframe,
body.erasing .iframe-open-btn {
    pointer-events: none !important;
}
body.erasing .magnet-core {
    cursor: pointer;
    transition: box-shadow 0.15s, background 0.15s;
}
body.erasing .drawn-rect,
body.erasing .drawn-text {
    cursor: pointer;
}
body.erasing .drawn-rect:hover {
    border-color: #ff4444 !important;
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.3);
}
body.erasing .drawn-text:hover {
    border-color: #ff4444;
    color: #ff4444;
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.3);
}
/* Désactiver TOUS les blocs pendant le drag de l'aimant */
body.magnet-dragging .canvas-visual,
body.magnet-dragging .canvas-block {
    pointer-events: none !important;
}
body.erasing .magnet-core:hover {
    background: rgba(255, 68, 68, 0.5) !important;
    border-color: #ff4444 !important;
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.4);
}

/* --- PALETTE (bas droite, discrète) --- */
#palette {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    transform: scale(0.7);
    transform-origin: bottom right;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    transition: box-shadow 0.2s, outline 0.2s, bottom 0.4s cubic-bezier(.4,0,.2,1), right 0.4s cubic-bezier(.4,0,.2,1);
    border-radius: 30px;
    padding: 6px;
}
#palette.collapsed {
    bottom: 10px;
    right: 10px;
}
#palette.magnet-drop-target {
    outline: 2px dashed rgba(100, 140, 255, 0.8);
    box-shadow: 0 0 24px rgba(100, 140, 255, 0.4);
    background: rgba(100, 140, 255, 0.1);
}

#palette-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(.4,0,.2,1);
    flex-shrink: 0;
}
#palette-toggle:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.1);
}
#palette.collapsed #palette-toggle {
    transform: scale(0.9);
    opacity: 0.7;
}

#palette-circles {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-wrap: wrap-reverse;
    max-width: 400px;
    justify-content: flex-end;
    transition: opacity 0.3s, transform 0.3s;
}

#palette.collapsed #palette-circles {
    opacity: 0;
    pointer-events: none;
    transform: translateX(20px);
}

/* --- ROND DE PALETTE --- */
.palette-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border: 2px solid transparent;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}
.palette-circle:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.palette-circle.active {
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.5), 0 4px 16px rgba(0,0,0,0.4);
    transform: scale(1.2);
}

/* Rond vidé (encre épuisée) */
.palette-circle.empty {
    opacity: 0.5;
    filter: grayscale(0.4);
}

/* Rond survolé pendant un drag de bloc */
.palette-circle.drop-target {
    border-color: #fff;
    transform: scale(1.3);
    box-shadow: 0 0 0 4px rgba(255,255,255,0.6), 0 4px 20px rgba(0,0,0,0.5);
}

.palette-circle .circle-label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    white-space: nowrap;
    color: rgba(255,255,255,0.7);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.palette-circle:hover .circle-label,
.palette-circle.active .circle-label {
    opacity: 1;
}

.palette-circle .circle-count-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.palette-circle .circle-count-badge.depleted {
    background: rgba(120, 0, 0, 0.7);
    color: #ff6b6b;
}

/* --- INDICATEUR DE PINCEAU ACTIF --- */
#brush-indicator {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.2s, transform 0.2s;
}
#brush-indicator.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(-10px);
}

#brush-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
}

#brush-name { color: #fff; }

#brush-cancel {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 18px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}
#brush-cancel:hover { color: #fff; }


/* =========================================
   POINT DE COULEUR (haut droite de chaque élément)
   ========================================= */

.color-dot {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    z-index: 30;
    pointer-events: none;
}


/* =========================================
   ÉLÉMENTS VISUELS (images / PDF) - PLEIN FORMAT
   ========================================= */

.canvas-visual {
    position: absolute;
    cursor: grab;
    z-index: 10;
    user-select: none;
    transition: box-shadow 0.2s;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0;
    max-width: fit-content;
}
.canvas-visual:active { cursor: grabbing; }
.canvas-visual:hover {
    z-index: 20;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

/* Images : taille naturelle, pas de crop */
.canvas-visual img {
    display: block;
    max-width: none;
    max-height: 20px;
    width: auto;
    height: 20px;
    border-radius: 2px;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* PDFs : wrapper */
.pdf-wrap {
    position: relative;
    width: 51px;
    height: 70px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.pdf-wrap.interactive {
    outline: 2px solid rgba(56, 189, 248, 0.7);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
}
.pdf-wrap.interactive .pdf-embed {
    pointer-events: auto;
}
.pdf-grab-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(40, 40, 60, 0.95);
    cursor: grab;
    user-select: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.pdf-grab-bar:active {
    cursor: grabbing;
}
.pdf-grab-dots {
    color: rgba(255,255,255,0.3);
    font-size: 12px;
    letter-spacing: 2px;
    line-height: 1;
}
.pdf-grab-title {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,0.6);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.canvas-visual .pdf-embed {
    display: block;
    width: 510px;
    height: 700px;
    border: none;
    transform: scale(0.1);
    transform-origin: top left;
    pointer-events: none;
}

/* Audio : lecteur natif */
.canvas-visual .audio-player {
    display: block;
    width: 120px;
    height: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* Vidéo : lecteur natif */
.canvas-visual .video-player {
    display: block;
    max-width: none;
    max-height: 20px;
    width: auto;
    height: 20px;
    border-radius: 2px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* Iframe : lien web en miniature */
.iframe-wrap {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    width: 102px;          /* 1024 * 0.10 */
    height: 64px;          /* 640 * 0.10 */
}
.iframe-grab-bar {
    display: none;
}
.iframe-grab-dots {
    letter-spacing: 2px;
    opacity: 0.4;
    font-size: 12px;
}
.iframe-grab-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.iframe-open-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.6);
    font-size: 12px;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}
.iframe-open-btn:hover {
    border-color: rgba(255,255,255,0.4);
    color: #fff;
    background: rgba(255,255,255,0.1);
}
.iframe-wrap iframe {
    display: block;
    width: 1024px;
    height: 640px;
    border: none;
    transform: scale(0.10);
    transform-origin: top left;
    pointer-events: none;
}

/* Mode interactif : double-clic pour naviguer dans le site */
.iframe-wrap.interactive {
    outline: 2px solid rgba(56, 189, 248, 0.7);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
}
.iframe-wrap.interactive iframe {
    pointer-events: auto;
}
.iframe-lock-btn {
    display: none;
}
.iframe-wrap.interactive .iframe-lock-btn {
    display: flex;
    background: rgba(56, 189, 248, 0.3);
    border: 1px solid rgba(56, 189, 248, 0.5);
    color: #fff;
    font-size: 11px;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 4px;
    transition: all 0.15s;
}
.iframe-wrap.interactive .iframe-lock-btn:hover {
    background: rgba(56, 189, 248, 0.5);
}
.iframe-resize-handle {
    display: none;
}

/* Étiquette de titre sous le visuel */
.visual-tag {
    margin-top: 2px;
    padding: 2px 4px;
    font-size: 7px;
    font-weight: 600;
    color: #fff;
    display: block;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    align-self: start;
}


/* =========================================
   BLOCS CLASSIQUES (liens, fichiers non visuels)
   ========================================= */

.canvas-block {
    position: absolute;
    background: rgba(30, 30, 50, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 6px;
    border-left: 3px solid;
    padding: 4px 6px;
    min-width: 60px;
    max-width: 120px;
    font-size: 9px;
    cursor: grab;
    z-index: 10;
    transition: box-shadow 0.2s;
    user-select: none;
}
.canvas-block:active { cursor: grabbing; }
.canvas-block:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,0.4);
    z-index: 20;
}

.block-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.block-type-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.block-title {
    font-size: 12px;
    font-weight: 600;
    color: #eee;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.block-actions {
    display: flex;
    justify-content: flex-end;
}

.block-open-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.6);
    font-size: 10px;
    padding: 3px 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.block-open-btn:hover {
    border-color: rgba(255,255,255,0.4);
    color: #fff;
}

/* --- BLOC TEXTE ÉDITABLE --- */
.canvas-text-block {
    position: absolute;
    background: rgba(20, 20, 30, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    min-width: 180px;
    max-width: 400px;
    padding: 12px 14px;
    cursor: grab;
    z-index: 10;
    user-select: none;
}
.canvas-text-block:active { cursor: grabbing; }
.canvas-text-block .text-block-content {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #e0e0e0;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 300px;
    overflow-y: auto;
    outline: none;
    cursor: default;
}
.canvas-text-block .text-block-content[contenteditable="true"] {
    background: rgba(255,255,255,0.05);
    cursor: text;
    padding: 6px;
    margin: -6px;
    border-radius: 3px;
}

/* --- PREVIEW PROCHAIN MÉDIA --- */
#next-media-preview {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 999;
    max-width: 120px;
    max-height: 100px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(30, 30, 50, 0.9);
    backdrop-filter: blur(10px);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
}
#next-media-preview.hidden {
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    pointer-events: none;
}
#next-media-preview img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 80px;
    object-fit: cover;
}
#next-media-preview .preview-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 60px;
    font-size: 28px;
}
#next-media-preview .preview-label {
    padding: 4px 8px;
    font-size: 9px;
    font-weight: 600;
    color: rgba(255,255,255,0.7);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-top: 1px solid rgba(255,255,255,0.08);
}
#next-media-preview .preview-badge {
    position: absolute;
    top: -6px;
    left: -6px;
    background: rgba(0,0,0,0.75);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,0.2);
}

/* --- OUTILS ACTION (bas gauche) --- */
#tools {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
    display: flex;
    gap: 8px;
    align-items: center;
    transform: scale(0.55);
    transform-origin: bottom left;
}
.tools-separator {
    width: 1px;
    height: 24px;
    background: rgba(255,255,255,0.15);
    flex-shrink: 0;
}

/* --- OUTILS DESSIN (bas centre) --- */
#draw-tools {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) scale(0.55);
    transform-origin: bottom center;
    z-index: 1000;
    display: flex;
    gap: 8px;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    padding: 6px 10px;
    border-radius: 28px;
    border: 1px solid rgba(255,255,255,0.08);
}

/* --- DROPDOWN FORMES --- */
#shape-dropdown {
    position: relative;
}
#shape-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
    padding: 0;
}
#shape-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
#shape-btn.active {
    background: rgba(56, 189, 248, 0.3);
    border-color: rgba(56, 189, 248, 0.6);
    color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}
#shape-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}
.shape-arrow {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 7px;
    color: rgba(255,255,255,0.4);
    line-height: 1;
    pointer-events: none;
}
#shape-btn.active .shape-arrow {
    color: rgba(56, 189, 248, 0.7);
}

/* Menu déroulant des formes */
#shape-menu {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 30, 0.95);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 140px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    transition: opacity 0.15s, transform 0.15s;
}
#shape-menu.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(6px);
}
.shape-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s;
    white-space: nowrap;
}
.shape-option:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.shape-option.active {
    background: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
}

#clear-btn {
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.5);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
#clear-btn:hover {
    background: rgba(220, 50, 50, 0.3);
    color: #fff;
    border-color: rgba(220, 50, 50, 0.5);
}

#eraser-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
#eraser-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
#eraser-btn.active {
    background: rgba(255, 68, 68, 0.3);
    border-color: rgba(255, 68, 68, 0.6);
    color: #ff4444;
    box-shadow: 0 0 12px rgba(255, 68, 68, 0.25);
}

#magnet-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
#magnet-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
#magnet-btn.active {
    background: rgba(100, 140, 255, 0.3);
    border-color: rgba(100, 140, 255, 0.6);
    color: #648cff;
    box-shadow: 0 0 12px rgba(100, 140, 255, 0.25);
}

body.magneting #canvas {
    cursor: copy;
}

/* --- PIPETTE --- */
#pipette-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
#pipette-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
#pipette-btn.active {
    background: rgba(168, 85, 247, 0.3);
    border-color: rgba(168, 85, 247, 0.6);
    color: #a855f7;
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.25);
}

/* --- Bouton Verrouillage --- */
#lock-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
#lock-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
#lock-btn.active {
    background: rgba(245, 158, 11, 0.3);
    border-color: rgba(245, 158, 11, 0.6);
    color: #f59e0b;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
}

/* Curseur en mode verrouillage */
body.locking,
body.locking #canvas,
body.locking .canvas-visual,
body.locking .canvas-block {
    cursor: pointer !important;
}

/* Élément verrouillé */
.canvas-visual.locked,
.canvas-block.locked,
.drawn-rect.locked,
.drawn-ellipse.locked,
.drawn-triangle.locked,
.drawn-text.locked {
    outline: 2px solid rgba(245, 158, 11, 0.4);
    outline-offset: 2px;
}
.canvas-visual.locked .resize-handle,
.canvas-block.locked .resize-handle,
.canvas-visual.locked .iframe-resize-handle,
.drawn-rect.locked .resize-handle {
    display: none;
}
.locked { pointer-events: auto; }

/* Icône cadenas sur élément verrouillé */
.lock-indicator {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: rgba(245, 158, 11, 0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    z-index: 15;
    transition: transform 0.15s, background 0.15s;
    line-height: 1;
    color: #000;
}
.lock-indicator:hover {
    transform: scale(1.2);
    background: rgba(245, 158, 11, 1);
}

/* Lasso verrouillage hover */
.lock-lasso-hover {
    outline: 2px dashed rgba(245, 158, 11, 0.7) !important;
    outline-offset: 2px;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}

/* --- Handle de resize universel --- */
.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    z-index: 10;
    background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.25) 50%);
    border-radius: 0 0 4px 0;
    transition: background 0.15s;
    opacity: 0;
}
.canvas-visual:hover .resize-handle,
.canvas-block:hover .resize-handle {
    opacity: 1;
}
.resize-handle:hover {
    background: linear-gradient(135deg, transparent 50%, rgba(56, 189, 248, 0.6) 50%);
}

body.pipetting,
body.pipetting #canvas,
body.pipetting .canvas-visual,
body.pipetting .canvas-block,
body.pipetting .magnet-core {
    cursor: none !important;
}
body.pipetting .canvas-visual,
body.pipetting .canvas-block {
    outline: 2px dashed transparent;
    transition: outline-color 0.15s;
}
body.pipetting .audio-player,
body.pipetting .video-player,
body.pipetting .pdf-embed,
body.pipetting .block-open-btn,
body.pipetting iframe,
body.pipetting .iframe-open-btn {
    pointer-events: none !important;
}
body.pipetting .canvas-visual:hover,
body.pipetting .canvas-block:hover {
    outline-color: #a855f7;
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
}
body.pipetting .magnet-core {
    outline: 2px dashed transparent;
    transition: outline-color 0.15s;
}
body.pipetting .magnet-core:hover {
    outline-color: #a855f7;
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
}

/* Lasso de sélection pipette */
#pipette-lasso {
    overflow: visible;
}
#pipette-lasso.hidden { display: none; }

.canvas-visual.pipette-highlighted,
.canvas-block.pipette-highlighted {
    outline: 2px solid rgba(168, 85, 247, 0.8);
    box-shadow: 0 0 16px rgba(168, 85, 247, 0.3);
}

/* Curseur pipette custom */
#pipette-cursor {
    position: fixed;
    z-index: 99999;
    pointer-events: none;
    transform: translate(-2px, -2px);
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6));
}
#pipette-cursor.hidden { display: none; }
#pipette-cursor-dot {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.9);
    background: transparent;
    transition: background-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
#pipette-cursor-dot.loaded {
    transform: scale(1.3);
    box-shadow: 0 0 8px currentColor;
}
/* Flash animation quand on pick */
@keyframes pipette-flash {
    0% { transform: scale(1.3); }
    50% { transform: scale(1.8); }
    100% { transform: scale(1.3); }
}
#pipette-cursor-dot.flash {
    animation: pipette-flash 0.3s ease;
}

/* --- AIMANT --- */
.magnet {
    position: absolute;
    z-index: 8;
    pointer-events: none;
}

.magnet-field {
    position: absolute;
    border-radius: 50%;
    border: 2px dashed rgba(100, 140, 255, 0.3);
    background: radial-gradient(circle, rgba(100, 140, 255, 0.06) 0%, transparent 70%);
    pointer-events: none;
    animation: magnet-pulse 3s ease-in-out infinite;
}

@keyframes magnet-pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.03); }
}

.magnet-core {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(100, 140, 255, 0.5);
    border: 2px solid rgba(100, 140, 255, 0.8);
    cursor: grab;
    pointer-events: all;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 2;
}
/* Zone cliquable élargie autour du core */
.magnet-core::before {
    content: '';
    position: absolute;
    top: -22px;
    left: -22px;
    right: -22px;
    bottom: -22px;
    border-radius: 50%;
}
.magnet-core:hover {
    background: rgba(100, 140, 255, 0.7);
    transform: scale(1.1);
}
.magnet-core:active {
    cursor: grabbing;
}
.magnet-core.has-items {
    cursor: cell;
    background: rgba(100, 140, 255, 0.7);
    box-shadow: 0 0 16px rgba(100, 140, 255, 0.4);
}

.magnet-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: rgba(100, 140, 255, 0.9);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 3;
}
.magnet-badge.empty {
    display: none;
}

/* Label texte de l'aimant */
.magnet-label {
    position: absolute;
    width: 120px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    pointer-events: all;
    cursor: default;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 2px 6px;
    border-radius: 6px;
    min-height: 18px;
    outline: none;
    transition: background 0.2s, box-shadow 0.2s;
}
.magnet-label:empty {
    pointer-events: none;
}
/* Micro-interaction hint au hover du core : affiche un placeholder */
.magnet-core:hover ~ .magnet-label:empty::after {
    content: 'Nommer...';
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
    font-weight: 400;
    animation: label-hint 1.5s ease-in-out;
}
@keyframes label-hint {
    0% { opacity: 0; transform: translateY(4px); }
    30% { opacity: 1; transform: translateY(0); }
    100% { opacity: 1; transform: translateY(0); }
}
.magnet-label.editing {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3);
    pointer-events: all;
    cursor: text;
    white-space: nowrap;
}
.magnet-label.editing:focus {
    box-shadow: 0 0 0 2px rgba(100, 140, 255, 0.6);
}

.magnet-unstack {
    position: absolute;
    bottom: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 80, 80, 0.8);
    border: none;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    pointer-events: all;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3;
    line-height: 1;
    transition: all 0.15s;
}
.magnet-unstack:hover {
    background: rgba(255, 50, 50, 1);
    transform: scale(1.15);
}
.magnet-unstack.visible {
    display: none;
}

/* Bouton restack au bout du spread */
.spread-restack-btn {
    position: absolute;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 80, 80, 0.85);
    border: 2px solid rgba(255,255,255,0.3);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    line-height: 1;
    transition: all 0.15s;
    box-shadow: 0 2px 10px rgba(255, 80, 80, 0.4);
}
.spread-restack-btn:hover {
    background: rgba(255, 50, 50, 1);
    transform: scale(1.2);
    box-shadow: 0 4px 16px rgba(255, 50, 50, 0.5);
}

/* --- Trajectoire prédictive aimant --- */
#trajectory-svg .trajectory-path {
    fill: none;
    stroke: rgba(255, 255, 255, 0.6);
    stroke-width: 2;
    stroke-dasharray: 8 4;
    stroke-linecap: round;
    animation: trajectory-dash 0.5s linear infinite;
}
@keyframes trajectory-dash {
    to { stroke-dashoffset: -12; }
}
#trajectory-svg .trajectory-ghost {
    fill: none;
    stroke: rgba(255, 255, 255, 0.15);
    stroke-width: 2;
    stroke-dasharray: 6 6;
    stroke-linecap: round;
    transition: opacity 0.5s ease;
}
#trajectory-svg .trajectory-ghost.trajectory-fadeout {
    opacity: 0;
}
#trajectory-svg .trajectory-ghost.trajectory-active-ghost {
    opacity: 0.05;
}
#trajectory-svg .trajectory-active {
    fill: none;
    stroke: rgba(56, 189, 248, 0.7);
    stroke-width: 3;
    stroke-linecap: round;
    filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.4));
}
.magnet-core.trajectory-drawing {
    animation: traj-pulse 0.6s ease-out;
}
@keyframes traj-pulse {
    0% { box-shadow: 0 0 0 0 rgba(255,255,255,0.5); }
    100% { box-shadow: 0 0 0 14px rgba(255,255,255,0); }
}

/* Aimant imbriqué (sur la ligne du champ de force, style atome) */
.magnet.magnet-nested {
    transform: scale(0.3);
    transform-origin: center center;
    opacity: 0.9;
    pointer-events: none;
    filter: drop-shadow(0 0 6px rgba(168, 85, 247, 0.5));
    transition: left 0.3s ease, top 0.3s ease, transform 0.3s ease;
}
.magnet.magnet-nested .magnet-core {
    pointer-events: all;
    cursor: grab;
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.6), inset 0 0 6px rgba(168, 85, 247, 0.2);
}
.magnet.magnet-nested .magnet-field {
    border-color: rgba(168, 85, 247, 0.4);
    background: radial-gradient(circle, rgba(168, 85, 247, 0.1) 0%, transparent 70%);
}

/* Aimant en cours d'extraction (drag hors du parent) */
.magnet.magnet-extracting {
    opacity: 1;
    filter: drop-shadow(0 0 10px rgba(168, 85, 247, 0.8));
    transition: none;
}
.magnet.magnet-extracting .magnet-core {
    cursor: grabbing;
}

/* Feedback visuel : aimant-sur-aimant (nesting) */
.magnet-core.magnet-merge-hover {
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.5), inset 0 0 12px rgba(168, 85, 247, 0.2);
    border: 2px solid rgba(168, 85, 247, 0.6);
    transition: box-shadow 0.3s ease, border 0.3s ease;
}
.magnet-core.magnet-merge-ready {
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.8), inset 0 0 16px rgba(168, 85, 247, 0.3);
    border: 2px solid rgba(168, 85, 247, 0.9);
    animation: merge-pulse 0.8s ease-in-out infinite;
}
@keyframes merge-pulse {
    0%, 100% { box-shadow: 0 0 30px rgba(168, 85, 247, 0.8), inset 0 0 16px rgba(168, 85, 247, 0.3); }
    50% { box-shadow: 0 0 40px rgba(168, 85, 247, 1), inset 0 0 20px rgba(168, 85, 247, 0.5); }
}

/* Phase 1 : vol vers l'aimant */
.canvas-visual.attracting,
.canvas-block.attracting {
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                top 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.4s ease;
    transform: scale(0.5);
    transform-origin: top left;
    opacity: 0.7;
    pointer-events: none;
    z-index: 7;
    box-shadow: 0 4px 20px rgba(100, 140, 255, 0.4);
}

/* Phase 2 : miniaturisé dans la pile */
.canvas-visual.stacked,
.canvas-block.stacked {
    transition: left 0.3s ease, top 0.3s ease, transform 0.2s ease, opacity 0.2s ease;
    transform: scale(0.15);
    transform-origin: top left;
    opacity: 0.85;
    pointer-events: none;
    z-index: 6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.canvas-visual.stacked img,
.canvas-visual.stacked .pdf-embed,
.canvas-visual.stacked iframe,
.canvas-visual.stacked .audio-player,
.canvas-visual.stacked .video-player {
    pointer-events: none;
}
.canvas-block.stacked {
    min-width: unset;
}

/* =========================================
   OUTILS DE DESSIN (rect, line, connector, text)
   ========================================= */

/* Boutons — même style glassmorphism que les autres */
#connector-btn, #text-btn, #frame-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
#connector-btn:hover, #text-btn:hover, #frame-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
#connector-btn.active, #text-btn.active, #frame-btn.active {
    background: rgba(56, 189, 248, 0.3);
    border-color: rgba(56, 189, 248, 0.6);
    color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

/* Color composer pour les outils de dessin */
#draw-color-picker {
    position: absolute;
    bottom: 54px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 30, 0.95);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 200px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    transition: opacity 0.15s, transform 0.15s;
    z-index: 1001;
}
#draw-color-picker.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(6px);
}

/* Preview stroke/fill superposés */
#color-preview {
    position: relative;
    width: 36px;
    height: 36px;
    margin: 0 auto;
    cursor: pointer;
}
#color-preview-fill {
    position: absolute;
    top: 0; left: 0;
    width: 26px; height: 26px;
    border-radius: 4px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
}
#color-preview-stroke {
    position: absolute;
    bottom: 0; right: 0;
    width: 26px; height: 26px;
    border-radius: 4px;
    background: transparent;
    border: 3px solid #ffffff;
    box-sizing: border-box;
}
/* Motif "none" (damier) */
#color-preview-fill.is-none,
#color-preview-stroke.is-none {
    background: repeating-conic-gradient(rgba(255,255,255,0.12) 0% 25%, transparent 0% 50%) 50% / 8px 8px;
    border-style: dashed;
    border-color: rgba(255,255,255,0.2);
}

/* Channel buttons (Stroke / Fill) */
#color-channels {
    display: flex;
    gap: 4px;
}
.channel-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 8px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    background: transparent;
    color: rgba(255,255,255,0.45);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.15s;
}
.channel-btn:hover {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.7);
}
.channel-btn.active {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
    color: #38bdf8;
}
.channel-icon { display: flex; align-items: center; }
.channel-label { font-weight: 500; }

/* Swatches */
#color-swatches {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}
.draw-color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.draw-color-swatch[data-color="none"] {
    background: repeating-conic-gradient(rgba(255,255,255,0.1) 0% 25%, transparent 0% 50%) 50% / 6px 6px;
    border-color: rgba(255,255,255,0.15);
}
.draw-color-swatch:hover {
    transform: scale(1.2);
}
.draw-color-swatch.active {
    border-color: #38bdf8;
    transform: scale(1.15);
    box-shadow: 0 0 6px rgba(56, 189, 248, 0.4);
}

/* Input couleur custom */
#color-custom-input {
    width: 100%;
    height: 28px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    cursor: pointer;
    padding: 2px;
}
#color-custom-input::-webkit-color-swatch-wrapper { padding: 0; }
#color-custom-input::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
}

/* Bouton "Créer un rond" */
#color-to-circle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 10px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.7);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
#color-to-circle-btn:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}
.color-to-circle-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid rgba(255,255,255,0.3);
    flex-shrink: 0;
    transition: background 0.15s;
}

/* Curseurs selon l'outil actif */
body.tool-rect #canvas,
body.tool-line #canvas,
body.tool-ellipse #canvas,
body.tool-triangle #canvas,
body.tool-connector #canvas { cursor: crosshair; }
body.tool-text #canvas { cursor: text; }

/* --- Rectangle dessiné --- */
.drawn-rect {
    position: absolute;
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    pointer-events: all;
    cursor: grab;
    z-index: 5;
    transition: box-shadow 0.15s;
}
.drawn-rect:active { cursor: grabbing; }
.drawn-rect:hover {
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.3);
    z-index: 20;
}
/* Poignées de resize */
.drawn-rect .resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: rgba(56, 189, 248, 0.8);
    border: 1px solid #fff;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: all;
}
.drawn-rect:hover .resize-handle { opacity: 1; }
.drawn-rect .resize-handle.se { bottom: -5px; right: -5px; cursor: nwse-resize; }

/* --- Ellipse dessinée --- */
.drawn-ellipse {
    position: absolute;
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    pointer-events: all;
    cursor: grab;
    z-index: 5;
    transition: box-shadow 0.15s;
}
.drawn-ellipse:active { cursor: grabbing; }
.drawn-ellipse:hover {
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.3);
    z-index: 20;
}
body.erasing .drawn-ellipse {
    cursor: pointer;
}
body.erasing .drawn-ellipse:hover {
    border-color: #ff4444 !important;
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.3);
}

/* --- Triangle dessiné --- */
.drawn-triangle {
    position: absolute;
    pointer-events: none;
    z-index: 5;
    overflow: visible;
}
.drawn-triangle polygon {
    fill: rgba(255, 255, 255, 0.04);
    stroke: rgba(255, 255, 255, 0.7);
    stroke-width: 2;
    stroke-linejoin: round;
    pointer-events: all;
    cursor: grab;
    transition: filter 0.15s;
}
.drawn-triangle polygon:active { cursor: grabbing; }
.drawn-triangle polygon:hover {
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.4));
}
body.erasing .drawn-triangle polygon {
    cursor: pointer;
}
body.erasing .drawn-triangle polygon:hover {
    stroke: #ff4444;
    filter: drop-shadow(0 0 8px rgba(255, 68, 68, 0.5));
}

/* Preview ellipse pendant le dessin */
.drawing-preview-ellipse {
    position: absolute;
    border: 2px dashed;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    pointer-events: none;
    z-index: 50;
    opacity: 0.7;
}

/* Preview triangle pendant le dessin */
.drawing-preview-triangle {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 50;
    overflow: visible;
}
.drawing-preview-triangle polygon {
    fill: rgba(255, 255, 255, 0.03);
    stroke-width: 2;
    stroke-dasharray: 6 4;
    opacity: 0.7;
}

/* --- Ligne dessinée --- */
.drawn-line {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 4;
    overflow: visible;
}
.drawn-line line {
    stroke: rgba(255, 255, 255, 0.9);
    stroke-width: 2.5;
    stroke-linecap: round;
    pointer-events: visiblePainted;
    cursor: grab;
}
.drawn-line line:hover {
    filter: drop-shadow(0 0 6px currentColor);
}
/* Zone de clic élargie pour les lignes */
.drawn-line .line-hitzone {
    stroke: transparent;
    stroke-width: 36;
    stroke-linecap: round;
    pointer-events: stroke;
    cursor: grab;
    fill: none;
}
body.erasing .drawn-line .line-hitzone {
    cursor: pointer;
}
body.erasing .drawn-line .line-hitzone:hover + line {
    stroke: #ff4444;
    filter: drop-shadow(0 0 8px rgba(255, 68, 68, 0.5));
}

/* --- Connecteur entre médias --- */
.connector-svg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 3;
    overflow: visible;
}
.connector-svg path {
    fill: none;
    stroke: rgba(255, 255, 255, 0.5);
    stroke-width: 2;
    stroke-dasharray: 6 4;
    pointer-events: stroke;
    cursor: pointer;
    transition: stroke 0.15s;
}
.connector-svg path:hover {
    stroke: #38bdf8;
    filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.4));
}
.connector-svg circle.connector-dot {
    fill: rgba(56, 189, 248, 0.8);
    stroke: #fff;
    stroke-width: 1;
    pointer-events: none;
}
/* Hover sur bloc pendant sélection du connecteur */
body.tool-connector .canvas-visual,
body.tool-connector .canvas-block {
    outline: 2px dashed transparent;
    transition: outline-color 0.15s;
}
body.tool-connector .canvas-visual:hover,
body.tool-connector .canvas-block:hover {
    outline-color: rgba(56, 189, 248, 0.6);
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.2);
}

/* --- Texte libre --- */
.drawn-text {
    position: absolute;
    min-width: 40px;
    min-height: 24px;
    padding: 6px 10px;
    color: #fff;
    font-size: 16px;
    font-family: inherit;
    background: transparent;
    cursor: grab;
    z-index: 5;
    outline: none;
    white-space: pre-wrap;
    word-break: break-word;
    border: 2px solid transparent;
    border-radius: 4px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.drawn-text:active { cursor: grabbing; }
.drawn-text:hover {
    border-color: rgba(255,255,255,0.2);
}
.drawn-text.editing {
    cursor: text;
    border-color: rgba(56, 189, 248, 0.5);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
    background: rgba(0,0,0,0.3);
}
.drawn-text:empty::before {
    content: 'Tapez...';
    color: rgba(255,255,255,0.25);
    font-style: italic;
}

/* Preview pendant le dessin */
.drawing-preview-rect {
    position: absolute;
    border: 2px dashed;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    pointer-events: none;
    z-index: 50;
    opacity: 0.7;
}
.drawing-preview-line {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 50;
    overflow: visible;
}
.drawing-preview-line line {
    stroke: rgba(56, 189, 248, 0.6);
    stroke-width: 2.5;
    stroke-linecap: round;
}

/* --- Cadre (Frame) --- */
/* Overlay visuel du cadre actif */
#frame-overlay {
    position: absolute;
    pointer-events: none;
    border: 2px dashed rgba(56, 189, 248, 0.7);
    background: rgba(56, 189, 248, 0.06);
    border-radius: 4px;
    z-index: 12;
    box-sizing: border-box;
    transition: opacity 0.15s;
}
#frame-overlay.hidden { display: none; }

/* --- CELLULES DE GRILLE ACTIVES --- */
/* Cellule active en mode normal : visuel subtil, les clics traversent jusqu'au canvas */
.fixed-grid .grid-cell.active {
    background: rgba(56, 189, 248, 0.04);
    border-color: rgba(56, 189, 248, 0.2);
    pointer-events: none;
}
/* Mode frame : toutes les cellules reçoivent les événements (règle plus spécifique = après .active) */
body.tool-frame .fixed-grid .grid-cell,
body.tool-frame .fixed-grid .grid-cell.active {
    pointer-events: auto;
    cursor: crosshair;
}
body.tool-frame .fixed-grid .grid-cell:hover {
    background: rgba(56, 189, 248, 0.08);
    border-color: rgba(56, 189, 248, 0.35);
}
/* Highlight pendant la sélection drag */
.fixed-grid .grid-cell.frame-selecting {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.45);
}
.fixed-grid .grid-cell.filled {
    background: rgba(56, 189, 248, 0.04);
}

/* Bloc dans une cellule */
.canvas-visual.in-cell,
.canvas-block.in-cell {
    pointer-events: none;
}
body.erasing .canvas-visual.in-cell,
body.erasing .canvas-block.in-cell,
body.tool-frame .canvas-visual.in-cell,
body.tool-frame .canvas-block.in-cell {
    pointer-events: auto;
    cursor: pointer;
}
.canvas-visual.in-cell .iframe-grab-bar { display: none; }
.canvas-visual.in-cell .iframe-resize-handle { display: none; }
.canvas-visual.in-cell .iframe-wrap {
    width: 100% !important;
    height: 100% !important;
}
.canvas-visual.in-cell .iframe-wrap iframe {
    transform: none !important;
    width: 100% !important;
    height: 100% !important;
}
.canvas-visual.in-cell {
    overflow: hidden !important;
}
.canvas-visual.in-cell img {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    display: block;
}
.canvas-visual.in-cell .video-player {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover;
}
.canvas-visual.in-cell .pdf-wrap {
    width: 100% !important;
    height: 100% !important;
}
.canvas-visual.in-cell .visual-tag { display: none; }
.canvas-visual.in-cell .color-dot { display: none; }
.canvas-visual.in-cell .resize-handle { display: none; }
.canvas-block.in-cell .resize-handle { display: none; }

/* =========================================
   SÉLECTION LASSO
   ========================================= */

#selection-lasso {
    overflow: visible;
}
#selection-lasso.hidden { display: none; }

/* Hover pendant le lasso */
.canvas-visual.lasso-hover,
.canvas-block.lasso-hover {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 16px rgba(255, 255, 255, 0.15);
}
.drawn-rect.lasso-hover {
    box-shadow: 0 0 16px rgba(255, 255, 255, 0.3);
}
.drawn-ellipse.lasso-hover {
    box-shadow: 0 0 16px rgba(255, 255, 255, 0.3);
}
.drawn-text.lasso-hover {
    border-color: rgba(255, 255, 255, 0.4);
}

/* Hover pendant le lasso eraser */
.canvas-visual.eraser-lasso-hover,
.canvas-block.eraser-lasso-hover {
    outline: 2px solid rgba(255, 68, 68, 0.6);
    box-shadow: 0 0 16px rgba(255, 68, 68, 0.25);
}
.drawn-rect.eraser-lasso-hover,
.drawn-ellipse.eraser-lasso-hover {
    box-shadow: 0 0 16px rgba(255, 68, 68, 0.35);
}
.drawn-text.eraser-lasso-hover {
    border-color: rgba(255, 68, 68, 0.5);
}


/* Hover pendant le lasso aimant */
.canvas-visual.magnet-lasso-hover,
.canvas-block.magnet-lasso-hover {
    outline: 2px solid rgba(168, 85, 247, 0.6);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
}

/* Éléments sélectionnés */
.canvas-visual.selected,
.canvas-block.selected {
    outline: 2px solid rgba(56, 189, 248, 0.7);
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.25);
}
.drawn-rect.selected {
    outline: 2px solid rgba(56, 189, 248, 0.7);
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.25);
}
.drawn-ellipse.selected {
    outline: 2px solid rgba(56, 189, 248, 0.7);
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.25);
}
.drawn-text.selected {
    border-color: rgba(56, 189, 248, 0.6);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}
/* --- POPUP DE CONFIRMATION --- */
#confirm-popup {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    animation: popup-fade-in 0.15s ease;
}
#confirm-popup.hidden {
    display: none;
}
@keyframes popup-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
#confirm-popup-inner {
    background: rgba(30, 30, 40, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 24px 28px;
    min-width: 300px;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    animation: popup-scale-in 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popup-scale-in {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
#confirm-popup-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#confirm-popup-text {
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    line-height: 1.5;
    margin: 0 0 20px;
}
#confirm-popup-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}
#confirm-popup-cancel,
#confirm-popup-ok {
    padding: 8px 20px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: all 0.15s;
}
#confirm-popup-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
}
#confirm-popup-cancel:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}
#confirm-popup-ok {
    background: rgba(255, 68, 68, 0.25);
    color: #ff6b6b;
    border-color: rgba(255, 68, 68, 0.3);
}
#confirm-popup-ok:hover {
    background: rgba(255, 68, 68, 0.4);
    color: #fff;
}

/* Eraser hover sur les ronds de palette */
body.erasing .palette-circle {
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
body.erasing .palette-circle:hover {
    box-shadow: 0 0 0 3px rgba(255, 68, 68, 0.6), 0 0 20px rgba(255, 68, 68, 0.3);
    transform: scale(1.1);
}

/* --- MAGNET VIEWER (popover contenu aimant) --- */
#magnet-viewer {
    position: absolute;
    z-index: 200;
    width: 360px;
    max-height: 380px;
    display: flex;
    flex-direction: column;
    background: rgba(20, 20, 28, 0.97);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    animation: popup-scale-in 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#magnet-viewer.hidden {
    display: none !important;
}
#magnet-viewer-inner {
    display: flex;
    flex-direction: column;
    max-height: 380px;
    overflow: hidden;
}
#magnet-viewer-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}
#magnet-viewer-title {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    flex: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid transparent;
    outline: none;
    transition: all 0.15s;
}
#magnet-viewer-title:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}
#magnet-viewer-title.editing {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(56, 189, 248, 0.5);
    color: #fff;
    cursor: text;
}
#magnet-viewer-count {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 8px;
    border-radius: 10px;
}
#magnet-viewer-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
#magnet-viewer-close:hover {
    background: rgba(255, 68, 68, 0.25);
    color: #ff6b6b;
}
#magnet-viewer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    padding: 14px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
#magnet-viewer-grid::-webkit-scrollbar { width: 6px; }
#magnet-viewer-grid::-webkit-scrollbar-track { background: transparent; }
#magnet-viewer-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.mv-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
    cursor: grab;
    transition: all 0.15s;
    position: relative;
}
.mv-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.mv-card-thumb {
    width: 100%;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;
}
.mv-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.mv-card-thumb .mv-icon {
    font-size: 28px;
    opacity: 0.6;
}
.mv-card-info {
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.mv-card-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.mv-card-title {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.mv-card-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.15s;
}
.mv-card:hover .mv-card-remove {
    opacity: 1;
}
.mv-card-remove:hover {
    background: rgba(255, 68, 68, 0.6);
    color: #fff;
}
.mv-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.3);
    font-size: 13px;
}

/* --- MAGNET VIEWER COLOR DOT & PICKER --- */
#magnet-viewer-color-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(100, 140, 255, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
#magnet-viewer-color-dot:hover {
    transform: scale(1.15);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 10px rgba(100, 140, 255, 0.4);
}
#magnet-viewer-color-dot.active {
    border-color: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

#magnet-color-picker {
    padding: 10px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: popup-fade-in 0.15s ease;
}
#magnet-color-picker.hidden {
    display: none;
}
#magnet-color-swatches {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}
.magnet-color-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
}
.magnet-color-swatch:hover {
    transform: scale(1.2);
    border-color: rgba(255, 255, 255, 0.4);
}
.magnet-color-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
    transform: scale(1.15);
}
.magnet-color-swatch.swatch-none {
    background: repeating-conic-gradient(rgba(255,255,255,0.1) 0% 25%, transparent 0% 50%) 50% / 6px 6px;
    border-color: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}
#magnet-color-custom {
    width: 100%;
    height: 26px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    padding: 2px;
}
#magnet-color-custom::-webkit-color-swatch-wrapper { padding: 0; }
#magnet-color-custom::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
}

/* --- ROUND INSPECTOR (right-click popup) --- */
#round-inspector {
    position: fixed;
    z-index: 5000;
    width: 340px;
    max-height: 420px;
    display: flex;
    flex-direction: column;
    background: rgba(20, 20, 28, 0.97);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    animation: popup-scale-in 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#round-inspector.hidden {
    display: none !important;
}
#ri-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}
#ri-color-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    flex-shrink: 0;
}
#ri-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#ri-count {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 8px;
    border-radius: 10px;
}
#ri-close {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
#ri-close:hover {
    background: rgba(255, 68, 68, 0.25);
    color: #ff6b6b;
}
#ri-grid-container {
    overflow-y: auto;
    max-height: 360px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
    position: relative;
}
#ri-grid-container::-webkit-scrollbar { width: 6px; }
#ri-grid-container::-webkit-scrollbar-track { background: transparent; }
#ri-grid-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
#ri-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 10px;
}

/* Tile in inspector */
.ri-tile {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
    cursor: grab;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
    user-select: none;
    -webkit-user-select: none;
}
.ri-tile:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
.ri-tile.dragging {
    opacity: 0.4;
    transform: scale(0.95);
}
.ri-tile.drag-over {
    border-color: rgba(56, 189, 248, 0.6);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}
.ri-tile.used {
    opacity: 0.35;
}
.ri-tile-thumb {
    width: 100%;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;
    pointer-events: none;
}
.ri-tile-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.ri-tile-thumb .ri-tile-icon {
    font-size: 22px;
    opacity: 0.5;
}
.ri-tile-label {
    padding: 4px 6px;
    font-size: 9px;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}
.ri-tile-order {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(56, 189, 248, 0.85);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.12s;
    pointer-events: none;
    z-index: 2;
}
.ri-tile-order.visible {
    opacity: 1;
}

/* Snake mode visual feedback */
.ri-tile.snake-visited {
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.08);
}
.ri-tile.snake-hover {
    border-color: rgba(56, 189, 248, 0.7);
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.3);
}

/* Snake line overlay */
#ri-snake-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    overflow: visible;
}
#ri-snake-line.hidden {
    display: none;
}
#ri-snake-line polyline {
    fill: none;
    stroke: rgba(56, 189, 248, 0.6);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 4 3;
}

/* DnD placeholder */
.ri-tile-placeholder {
    border: 2px dashed rgba(56, 189, 248, 0.4);
    border-radius: 10px;
    background: rgba(56, 189, 248, 0.05);
    min-height: 70px;
}

/* Drop on canvas ghost */
.ri-drag-ghost {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    opacity: 0.85;
    transform: scale(0.9);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* --- GROUPES (Ctrl+G) --- */
/* --- UI HIDE MODE (raccourci H) --- */
body.ui-hidden #tools,
body.ui-hidden #draw-tools,
body.ui-hidden #palette,
body.ui-hidden #canvas-title,
body.ui-hidden #brush-indicator {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: opacity 0.35s cubic-bezier(.4,0,.2,1), transform 0.35s cubic-bezier(.4,0,.2,1);
}

#tools,
#draw-tools,
#palette,
#canvas-title,
#brush-indicator {
    transition: opacity 0.35s cubic-bezier(.4,0,.2,1), transform 0.35s cubic-bezier(.4,0,.2,1);
}

.canvas-group {
    position: absolute;
    border: 1.5px dashed rgba(56, 189, 248, 0.35);
    border-radius: 8px;
    pointer-events: none;
    z-index: 1;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.canvas-group.selected {
    border-color: rgba(56, 189, 248, 0.6);
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.15);
}
/* SVG shapes (line groups, triangles) */
.selected line:not(.line-hitzone) {
    stroke: #38bdf8 !important;
    filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.5));
}
.selected polygon {
    stroke: #38bdf8 !important;
    filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.5));
}

/* --- BOUTON PLEIN ÉCRAN (tablette uniquement) --- */
#fullscreen-btn {
    display: none;
}
@media (pointer: coarse) {
    #fullscreen-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 16px;
        right: 16px;
        z-index: 1000;
        width: 32px;
        height: 32px;
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        color: rgba(255, 255, 255, 0.35);
        cursor: pointer;
        transition: opacity 0.2s;
    }
    #fullscreen-btn:active {
        opacity: 0.5;
    }
}
:fullscreen #fullscreen-btn,
:-webkit-full-screen #fullscreen-btn {
    display: none !important;
}

/* --- TABLETTES : le scale JS gère l'affichage --- */
@media (pointer: coarse) {
    #canvas {
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
}

/* --- TOOLBAR DRAG HANDLE --- */
.toolbar-handle {
    width: 14px;
    height: 28px;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.2);
    font-size: 13px;
    user-select: none;
    flex-shrink: 0;
    border-radius: 4px;
    transition: color 0.2s;
}
.toolbar-handle:hover { color: rgba(255,255,255,0.6); }
.toolbar-handle:active { cursor: grabbing; }
