/* ============================================================
   creatorV3.css — le créateur V3 (/creator3). Tout est scopé sous .c3, posé sur la racine .cnx de la
   V2 : la carte, la barre du haut, les outils de gauche et les éditeurs sont ceux de creatorNext.css.
   Ici : le panneau à espaces, la palette (Ctrl+K), et le CADRE D'ATELIER commun.
   ============================================================ */

.c3 {
    --c3-bg: #1f1f22;
    --c3-panel: #2b2b2f;
    --c3-panel-2: #35353a;
    --c3-line: #46464c;
    --c3-text: #e8e8e8;
    --c3-muted: #9a9aa2;
    --c3-accent: #00b1ca;
    --c3-accent-bg: rgba(0, 177, 202, 0.16);
    --c3-atelier-h: 44px;
}

/* ---------- le panneau ---------- */
.c3-panneau {
    position: absolute;
    right: 0; top: var(--cn-topbar-h); bottom: 0;
    width: 380px;
    background: var(--cn-panel);
    border-left: 1px solid var(--cn-line);
    z-index: 120;
    display: flex; flex-direction: column;
    color: var(--cn-text);
    box-sizing: border-box;
}
.c3-panneau.c3-replie { width: 52px; }
.c3-poignee {
    position: absolute; left: 0; top: 0; bottom: 0; width: 8px;
    cursor: col-resize; z-index: 130; background: transparent; transition: background .12s;
}
.c3-poignee:hover { background: var(--c3-accent-bg); box-shadow: inset 2px 0 0 var(--c3-accent); }

.c3-espaces {
    display: flex; gap: 4px; padding: 8px 8px 6px 12px;
    border-bottom: 1px solid var(--cn-line);
}
.c3-replie .c3-espaces { flex-direction: column; padding: 8px 6px; border-bottom: 0; }
.c3 .c3-espace {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 4px; border-radius: 6px; cursor: pointer;
    background: transparent; border: 1px solid transparent; color: var(--cn-muted);
}
.c3 .c3-espace:hover { background: var(--cn-panel-2); color: var(--cn-text); }
.c3 .c3-espace.on { background: var(--c3-accent-bg); border-color: var(--c3-accent); color: #bfeff7; }
.c3-espace-icone { font-size: 18px; line-height: 1; }
.c3-espace-nom { font-size: 11.5px; letter-spacing: .02em; }
.c3 .c3-replier {
    flex: 0 0 auto; align-self: stretch; width: 24px; border-radius: 6px; cursor: pointer;
    background: transparent; border: 1px solid transparent; color: var(--cn-muted); font-size: 16px;
}
.c3 .c3-replier:hover { background: var(--cn-panel-2); color: var(--cn-text); }

.c3-contenu { flex: 1; min-height: 0; flex-direction: column; }
.c3-outils {
    display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 10px 4px 14px;
}
.c3 .c3-outil {
    padding: 4px 10px; border-radius: 999px; cursor: pointer; font-size: 12.5px;
    background: var(--cn-rail); border: 1px solid var(--cn-line); color: var(--cn-text);
}
.c3 .c3-outil:hover { border-color: var(--c3-accent); }
.c3 .c3-outil.on { background: var(--c3-accent); border-color: var(--c3-accent); color: #062b31; font-weight: 600; }
.c3 .c3-outil-atelier { border-style: dashed; }
.c3-aide { padding: 2px 14px 6px; color: var(--cn-muted); font-size: 12px; }
.c3-corps { flex: 1; min-height: 0; overflow: auto; padding: 4px 10px 16px 14px; border-top: 1px solid var(--cn-line); }
.c3-outil-corps { padding-top: 6px; }
.c3-atelier-carte { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; }
.c3-atelier-carte .cn-up-send { align-self: flex-start; }
.c3-import { margin-top: 12px; border-top: 1px solid var(--cn-line); padding-top: 8px; }
.c3-import summary { cursor: pointer; color: var(--cn-muted); font-size: 12px; }
.c3-import[open] summary { margin-bottom: 8px; color: var(--cn-text); }
.c3 .cn-clib-filtre { margin: 0 0 8px; }

/* ---------- la recherche (barre du haut et cadre d'atelier) ---------- */
.c3 .c3-recherche {
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
    height: 30px; padding: 0 10px; margin-right: 10px; border-radius: 6px;
    background: var(--cn-rail); border: 1px solid var(--cn-line); color: var(--cn-text); font-size: 12.5px;
}
.c3 .c3-recherche:hover { border-color: var(--c3-accent); }
.c3 kbd {
    font: 11px ui-monospace, Consolas, monospace; color: var(--cn-muted);
    border: 1px solid var(--cn-line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: transparent;
}

/* ---------- la palette (Ctrl+K) ---------- */
.c3-palette-voile { position: fixed; inset: 0; z-index: 6000; background: rgba(0, 0, 0, .45); }
.c3-palette {
    position: absolute; left: 50%; top: 11vh; transform: translateX(-50%);
    width: min(680px, 92vw); max-height: 70vh; display: flex; flex-direction: column;
    background: var(--c3-panel); border: 1px solid var(--c3-line); border-radius: 10px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .55); overflow: hidden; color: var(--c3-text);
}
.c3 .c3-palette-champ {
    width: 100%; padding: 14px 16px; font-size: 16px; color: var(--c3-text);
    background: transparent; border: 0; border-bottom: 1px solid var(--c3-line);
}
.c3-palette-liste { list-style: none; margin: 0; padding: 6px; overflow: auto; flex: 1; }
.c3-palette-ligne {
    display: grid; grid-template-columns: 96px auto 1fr; align-items: baseline; gap: 10px;
    padding: 7px 10px; border-radius: 6px; cursor: pointer;
}
.c3-palette-ligne.on { background: var(--c3-accent-bg); box-shadow: inset 2px 0 0 var(--c3-accent); }
.c3-palette-genre { font-size: 11px; color: var(--c3-muted); text-transform: uppercase; letter-spacing: .05em; }
.c3-palette-titre { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
.c3-palette-sous { color: var(--c3-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c3-palette-vide { padding: 14px; color: var(--c3-muted); }
.c3-palette-pied { padding: 7px 12px; border-top: 1px solid var(--c3-line); color: var(--c3-muted); font-size: 11.5px; }
@media (max-width: 640px) {
    .c3-palette-ligne { grid-template-columns: 1fr; gap: 2px; }
    .c3-palette-titre { max-width: none; }
}

/* ---------- le CADRE D'ATELIER commun ----------
   Une barre pour les trois ateliers : « Retour au monde », des onglets pour passer de l'un à l'autre,
   la recherche. Chaque atelier perd son titre et son bouton de fermeture (la barre les porte) et prend
   la même palette de couleurs — ils en avaient trois. */
.c3-atelier-barre {
    position: fixed; left: 0; right: 0; top: 0; height: var(--c3-atelier-h); z-index: 5001;
    display: flex; align-items: center; gap: 6px; padding: 0 10px;
    background: var(--c3-panel); border-bottom: 1px solid var(--c3-line); color: var(--c3-text);
}
.c3 .c3-retour, .c3 .c3-atelier-onglet {
    height: 30px; padding: 0 12px; border-radius: 6px; cursor: pointer; font-size: 13px;
    background: transparent; border: 1px solid var(--c3-line); color: var(--c3-text);
}
.c3 .c3-retour:hover, .c3 .c3-atelier-onglet:hover { border-color: var(--c3-accent); }
.c3 .c3-atelier-onglet.on { background: var(--c3-accent); border-color: var(--c3-accent); color: #062b31; font-weight: 600; }
.c3-atelier-sep { width: 1px; height: 24px; background: var(--c3-line); margin: 0 6px; }
.c3-atelier-titre { flex: 1; min-width: 0; color: var(--c3-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 8px; }

.c3 .ae-hote, .c3 .ac-hote { top: var(--c3-atelier-h); }
.c3-atelier-hote {
    position: fixed; left: 0; right: 0; bottom: 0; top: var(--c3-atelier-h); z-index: 5000;
    flex-direction: column; background: var(--c3-bg);
}
.c3-coulisse { position: fixed; left: 0; top: 0; width: 0; height: 0; z-index: 5000; }
.c3-coulisse > * > :not(.ae-hote):not(.ac-hote) { display: none !important; }

/* la barre porte le titre et la fermeture */
.c3 .ae-barre > h1, .c3 .ac-barre > h1 { display: none; }
.c3 .ae-hote [data-a="fermer"], .c3 .ac-hote [data-r="fermer"] { display: none; }

/* une palette pour trois ateliers */
.c3 .ae-hote, .c3 .ac-hote { background: var(--c3-bg); }
.c3 .atelier-ecrans {
    --ae-bg: var(--c3-bg); --ae-fg: var(--c3-text); --ae-mute: var(--c3-muted); --ae-ligne: var(--c3-line);
    --ae-carte: var(--c3-panel); --ae-champ: #18181b; --ae-accent: var(--c3-accent);
}
.c3 .atelier-combattants {
    --ac-bg: var(--c3-bg); --ac-fg: var(--c3-text); --ac-mute: var(--c3-muted); --ac-ligne: var(--c3-line);
    --ac-carte: var(--c3-panel); --ac-champ: #18181b; --ac-accent: var(--c3-accent);
}
.c3 .tx {
    --tx-bg: var(--c3-bg); --tx-panel: var(--c3-panel); --tx-panel-2: var(--c3-panel-2); --tx-line: var(--c3-line);
    --tx-text: var(--c3-text); --tx-muted: var(--c3-muted); --tx-accent: var(--c3-accent); --tx-accent-bg: var(--c3-accent-bg);
}
/* le bouton principal de chaque atelier se lit pareil partout */
.c3 .ae-b.ae-prim, .c3 .ac-b.ac-prim { background: var(--c3-accent); border-color: var(--c3-accent); color: #062b31; font-weight: 600; }

/* ---------- la barre d'options des outils de carte (cible, déplacement) ---------- */
.c3-options {
    position: absolute; z-index: 125;
    top: calc(var(--cn-topbar-h) + 8px); left: calc(var(--cn-rail-w) + 8px);
    max-width: calc(100% - var(--cn-rail-w) - 420px);
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    padding: 6px 10px; border-radius: 8px;
    background: rgba(43, 43, 47, .94); border: 1px solid var(--cn-line); color: var(--cn-text);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .35); font-size: 12.5px;
}
.c3-segment { display: inline-flex; border: 1px solid var(--cn-line); border-radius: 6px; overflow: hidden; }
.c3 .c3-seg {
    padding: 4px 12px; cursor: pointer; font-size: 12.5px; background: transparent; border: 0;
    border-right: 1px solid var(--cn-line); color: var(--cn-text);
}
.c3 .c3-seg:last-child { border-right: 0; }
.c3 .c3-seg:hover { background: var(--cn-panel-2); }
.c3 .c3-seg.on { background: var(--c3-accent); color: #062b31; font-weight: 600; }
.c3-options-champ { display: inline-flex; align-items: center; gap: 6px; color: var(--cn-muted); }
.c3 .c3-options-champ select, .c3 .c3-case-champ select {
    padding: 3px 6px; border-radius: 5px; font-size: 12.5px;
    background: var(--cn-rail); border: 1px solid var(--cn-line); color: var(--cn-text);
}
.c3-options-aide { color: var(--cn-muted); }

/* ---------- la fiche d'une case ---------- */
.c3-case-flottant {
    position: absolute; z-index: 125; bottom: 16px; left: calc(var(--cn-rail-w) + 8px); width: 300px; max-height: 45%; overflow: auto;
    padding: 8px 10px; border-radius: 8px; background: rgba(43, 43, 47, .94); border: 1px solid var(--cn-line);
    color: var(--cn-text); box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.c3-case { display: flex; flex-direction: column; gap: 10px; }
.c3-case-tete { display: flex; flex-direction: column; gap: 2px; }
.c3-case-tete span { color: var(--cn-muted); font-size: 12px; }
.c3-case-modes { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.c3-case-champ { display: inline-flex; align-items: center; gap: 6px; color: var(--cn-muted); font-size: 12px; }
.c3-case-pile { display: flex; flex-direction: column; gap: 4px; }
.c3 .c3-case-tuile {
    display: grid; grid-template-columns: 36px 28px 1fr auto; align-items: center; gap: 8px;
    padding: 4px 8px; border-radius: 6px; cursor: pointer; text-align: left;
    background: var(--cn-rail); border: 1px solid var(--cn-line); color: var(--cn-text);
}
.c3 .c3-case-tuile:hover { border-color: var(--c3-accent); }
.c3 .c3-case-tuile.part { border-color: var(--c3-accent); background: var(--c3-accent-bg); }
.c3-case-vign { width: 32px; height: 32px; image-rendering: pixelated; background: #18181b; border-radius: 3px; }
.c3-case-z { font: 600 13px ui-monospace, Consolas, monospace; color: var(--c3-accent); text-align: center; }
.c3-case-nom { display: flex; flex-direction: column; min-width: 0; font-size: 12.5px; }
.c3-case-nom small { color: var(--cn-muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c3-case-part { font-size: 11px; color: #bfeff7; }
.c3-instance {
    margin: 0 0 8px; padding: 6px 8px; border-radius: 6px; font-size: 12px;
    background: var(--c3-accent-bg); border: 1px solid var(--c3-accent); color: #bfeff7;
}

/* curseurs des outils de la V3 */
.cnx-tool-SELECTION3 #map { cursor: move; }
.cnx-tool-CRAYONPREFAB #map { cursor: copy; }

/* ---------- les tiles complexes : la palette à peindre, et l'onglet de l'atelier des planches ---------- */
.c3-complexes { margin-top: 12px; border-top: 1px solid var(--cn-line); padding-top: 10px; }
.c3-complexes-tete { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.c3 .c3-lien { background: transparent; border: 0; color: var(--c3-accent); cursor: pointer; font-size: 12.5px; padding: 2px 4px; }
.c3 .c3-lien:hover { text-decoration: underline; }
.c3-arme {
    display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center;
    padding: 8px; margin-bottom: 8px; border-radius: 8px;
    background: var(--c3-accent-bg); border: 1px solid var(--c3-accent);
}
.c3-arme-vign { display: flex; align-items: center; justify-content: center; min-height: 40px; background: #18181b; border-radius: 4px; padding: 4px; }
.c3-arme-vign canvas { max-width: 48px; max-height: 48px; image-rendering: pixelated; }
.c3-arme-texte { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.c3-arme-texte span { color: var(--cn-muted); font-size: 12px; }
.c3-modifier { margin-left: 6px; cursor: pointer; color: var(--cn-muted); }
.c3-modifier:hover { color: var(--c3-accent); }
.c3-options-actions { display: inline-flex; gap: 6px; }

.c3-atelier-sous { display: inline-flex; gap: 4px; margin-left: 8px; }
.c3 .c3-atelier-sousonglet {
    height: 26px; padding: 0 10px; border-radius: 999px; cursor: pointer; font-size: 12.5px;
    background: transparent; border: 1px solid var(--c3-line); color: var(--c3-text);
}
.c3 .c3-atelier-sousonglet.on { background: var(--c3-accent-bg); border-color: var(--c3-accent); color: #bfeff7; }
.c3-sous-pane { flex: 1; min-height: 0; flex-direction: column; overflow: auto; }
.c3-sous-pane > .tx { flex: 1; }
.c3-complexes-pane { padding: 16px 20px 40px; }
.c3-complexes-contenu { max-width: 980px; margin: 0 auto; }
.c3-complexes-contenu .cn-pf-liste { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }

/* ---------- créer un tile complexe depuis un bloc de la planche ---------- */
.c3-bloc-ligne { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.c3-bloc-planche { max-height: 52vh; overflow: auto; border: 1px solid var(--c3-line); border-radius: 6px; background: #18181b; }
.c3-bloc-apercu { position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 760px) { .c3-bloc-ligne { grid-template-columns: 1fr; } }

.c3-reglages { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--c3-line); }
.c3-ordre-ligne { align-items: center; gap: 10px; }
.c3-ordre-z { min-width: 80px; font-weight: 600; color: var(--c3-accent); }
.c3-ordre-n { min-width: 70px; color: var(--cn-muted); font-size: 12px; }
.c3-reglages .cn-pf-canvas { max-width: 360px; height: auto; }
.c3-gabarit-genere {
    display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border-radius: 6px;
    background: var(--c3-accent-bg); border: 1px solid var(--c3-accent); font-size: 12.5px;
}
.c3-gabarit-genere b { color: #bfeff7; }
.c3-gabarit-formes { color: var(--cn-muted); font-size: 12px; }
.c3-pose { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; padding: 10px; border-radius: 8px; border: 1px dashed var(--c3-accent); background: rgba(0, 177, 202, 0.06); }
.c3-reglage-gabarit { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: -2px 0 8px; }
.c3-reglage-aide { color: var(--cn-muted); font-size: 12px; }
.c3-description { width: 100%; margin: 4px 0 8px; }
