/* ============================================================
   tuiles.css — l'atelier des tuiles (route /tuiles, et fenêtre
   ouverte depuis /creator2). Tout est scopé sous .tx : l'atelier
   s'ouvre PAR-DESSUS le créateur et ne doit rien lui repeindre.
   ============================================================ */

.tx {
    --tx-bg: #1f1f22;
    --tx-panel: #2b2b2f;
    --tx-panel-2: #35353a;
    --tx-line: #46464c;
    --tx-text: #e8e8e8;
    --tx-muted: #9a9aa2;
    --tx-accent: #00b1ca;
    --tx-accent-bg: rgba(0, 177, 202, 0.16);
    --tx-ok: #66bb6a;
    --tx-err: #ef5350;
    position: fixed;
    inset: 0;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 5000;
    background: var(--tx-bg);
    color: var(--tx-text);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 13px;
    line-height: 1.35;
}
/* 🔴 `:where(:not(.tx-compte *))` partout où l'atelier habille ses contrôles : le widget de compte (et
   la fenêtre de connexion qu'il ouvre) est CELUI d'Inckor, il doit rester iso. Mesuré le 2026-09-13 :
   sans cette exclusion, `.tx button` repeignait « Se connecter » en gris de l'atelier. `:where` garde
   la spécificité inchangée pour tout le reste de l'atelier. */
.tx :where(button, input, select, textarea):where(:not(.tx-compte *)) {
    all: revert;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 13px;
    margin: 0;
}
.tx *, .tx *::before, .tx *::after { box-sizing: border-box; }

.tx-atelier { display: flex; flex-direction: column; height: 100%; }

/* ---------- barre du haut ---------- */
.tx-barre {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    min-height: 48px; padding: 6px 12px;
    background: var(--tx-panel); border-bottom: 1px solid var(--tx-line);
}
.tx-titre { font-weight: 600; font-size: 14px; margin-right: 6px; white-space: nowrap; }
.tx-barre label:where(:not(.tx-compte *)) { color: var(--tx-muted); display: flex; align-items: center; gap: 6px; }
.tx select:where(:not(.tx-compte *)), .tx input[type=text]:where(:not(.tx-compte *)),
.tx input[type=number]:where(:not(.tx-compte *)), .tx textarea:where(:not(.tx-compte *)) {
    background: var(--tx-panel-2); color: var(--tx-text);
    border: 1px solid var(--tx-line); border-radius: 4px; padding: 4px 6px;
}
.tx textarea:where(:not(.tx-compte *)) { width: 100%; min-height: 48px; resize: vertical; }
.tx input[type=text]:where(:not(.tx-compte *)) { min-width: 0; }
.tx button:where(:not(.tx-compte *)) {
    background: var(--tx-panel-2); color: var(--tx-text);
    border: 1px solid var(--tx-line); border-radius: 4px; padding: 4px 10px; cursor: pointer;
}
.tx button:hover:not(:disabled):where(:not(.tx-compte *)) { border-color: var(--tx-accent); }
.tx button:disabled:where(:not(.tx-compte *)) { opacity: 0.45; cursor: default; }
.tx .tx-actif, .tx button.tx-actif { background: var(--tx-accent-bg); border-color: var(--tx-accent); color: #fff; }
.tx-modes { display: flex; gap: 0; }
.tx-modes button { border-radius: 0; }
.tx-modes button:first-child { border-radius: 4px 0 0 4px; }
.tx-modes button:last-child { border-radius: 0 4px 4px 0; }
.tx-zoom { display: flex; align-items: center; gap: 4px; }
.tx-zoom span { min-width: 28px; text-align: center; color: var(--tx-muted); }
.tx-etat { color: var(--tx-muted); margin-left: auto; white-space: nowrap; }
.tx-etat.tx-sale { color: #ffca28; }
.tx button.tx-enregistrer { background: var(--tx-accent); border-color: var(--tx-accent); color: #002b31; font-weight: 600; }
.tx button.tx-enregistrer:disabled { background: var(--tx-panel-2); color: var(--tx-muted); border-color: var(--tx-line); }

.tx-message { padding: 6px 12px; border-bottom: 1px solid var(--tx-line); display: flex; gap: 10px; align-items: center; }
.tx-message.tx-ok { background: rgba(102, 187, 106, 0.14); }
.tx-message.tx-erreur { background: rgba(239, 83, 80, 0.16); }
.tx-message.tx-info { background: var(--tx-accent-bg); }
.tx-lecture { padding: 5px 12px; background: rgba(255, 202, 40, 0.12); color: #ffe082; border-bottom: 1px solid var(--tx-line); }

/* Le compte, en haut à droite : LE widget du site (WidgetUser), pas un formulaire propre à l'atelier.
   Son habillage vit dans public.css (`.tx-compte` y partage les règles du bandeau d'Inckor) ; ici,
   seulement ce que la barre impose — l'atelier recouvre le bandeau, le widget n'y est plus en absolu. */
.tx-compte {
    margin-left: auto;
    /* le contexte typographique du SITE, pas celui de l'atelier (13px / 1.35) : le widget et sa fenêtre
       héritent de body sur Inckor */
    font-size: 1rem; line-height: 1.5; color: #FFFFFF;
}
/* seul écart voulu : dans la barre, le widget suit le flux au lieu d'être posé en absolu à droite */
.tx .tx-compte #widgetUser { position: relative; right: auto; padding: 0; z-index: 10; }

/* ---------- corps ---------- */
.tx-corps { flex: 1; display: flex; min-height: 0; }
.tx-atlas {
    flex: 1; overflow: auto; position: relative;
    padding: 16px; background: #18181b;
}
.tx-atlas canvas { display: block; cursor: crosshair; image-rendering: pixelated; }
.tx-vide, .tx-attente { color: var(--tx-muted); padding: 40px; text-align: center; }
.tx-pied {
    padding: 4px 12px; border-top: 1px solid var(--tx-line); background: var(--tx-panel);
    color: var(--tx-muted); font-size: 12px; min-height: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- inspecteur ---------- */
.tx-inspecteur {
    width: 360px; flex-shrink: 0; overflow-y: auto;
    background: var(--tx-panel); border-left: 1px solid var(--tx-line); padding: 10px 12px 40px;
}
.tx-bloc { border-bottom: 1px solid var(--tx-line); padding: 10px 0; }
.tx-bloc:last-child { border-bottom: 0; }
.tx-bloc h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--tx-muted); font-weight: 600; }
.tx-aide { color: var(--tx-muted); font-size: 12px; margin: 4px 0 8px; }
.tx-grille { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.tx-grille button { padding: 5px 4px; font-size: 12px; }
.tx-valeurs { display: flex; flex-direction: column; gap: 3px; }
.tx-valeurs button { display: flex; align-items: center; gap: 8px; text-align: left; }
.tx-pastille { width: 12px; height: 12px; border-radius: 2px; flex-shrink: 0; border: 1px solid rgba(255, 255, 255, 0.25); }
.tx-ligne { display: flex; align-items: center; gap: 6px; margin: 5px 0; }
.tx-ligne > label { width: 96px; flex-shrink: 0; color: var(--tx-muted); }
.tx-ligne > select, .tx-ligne > input { flex: 1; min-width: 0; }
.tx-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tx-declarer { display: flex; flex-direction: column; gap: 4px; }
.tx-declarer button { text-align: left; }
.tx-declarer small { display: block; color: var(--tx-muted); font-size: 11px; }
.tx-stat { color: var(--tx-muted); font-size: 12px; }
.tx-alerte { color: #ffca28; font-size: 12px; margin: 4px 0; }
.tx-erreur-texte { color: var(--tx-err); font-size: 12px; margin: 4px 0; }

.tx-groupes { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; }
.tx-groupe {
    display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 4px; cursor: pointer;
    border: 1px solid transparent;
}
.tx-groupe:hover { background: var(--tx-panel-2); }
.tx-groupe.tx-actif { border-color: var(--tx-accent); background: var(--tx-accent-bg); }
.tx-groupe small { color: var(--tx-muted); margin-left: auto; }

.tx-puces { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
/* les tags par questions : des pastilles qu'on allume, pas un menu de 56 entrées */
.tx-tags { margin: 10px 0 4px; }
.tx-tags-titre { color: var(--tx-muted); margin-bottom: 2px; }
.tx-question { margin: 6px 0 10px; }
.tx-question-titre { font-size: 12px; color: var(--tx-text); margin-bottom: 5px; }
.tx-question-titre span { color: var(--tx-muted); margin-left: 8px; }
.tx-pastilles { display: flex; flex-wrap: wrap; gap: 5px; }
.tx button.tx-tag { border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--tx-muted); }
.tx button.tx-tag.tx-pose { background: var(--tx-accent-bg); border-color: var(--tx-accent); color: #fff; }
.tx button.tx-tag.tx-partiel { border-color: var(--tx-accent); border-style: dashed; color: var(--tx-text); }
.tx button.tx-tag.tx-plus { border-style: dashed; }

/* le mode Signaler : un nom, une note, la couche si elle compte, et la liste */
.tx-couches { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
.tx-couches button { display: flex; align-items: center; gap: 5px; font-size: 12px; }
.tx-signalements { display: flex; flex-direction: column; gap: 3px; }
.tx-signalement { display: flex; gap: 8px; align-items: baseline; padding: 4px 6px; border: 1px solid var(--tx-line); border-radius: 4px; cursor: pointer; }
.tx-signalement:hover { border-color: var(--tx-accent); }
.tx-signalement.tx-actif { background: var(--tx-accent-bg); border-color: var(--tx-accent); }
.tx-signalement b { color: #ffd740; min-width: 18px; }
.tx-signalement span { flex: 1; }
.tx-signalement small { color: var(--tx-muted); }
.tx-signalement.tx-a-placer > small:last-child { color: #ffab40; }
.tx button.tx-lien { background: none; border: none; color: var(--tx-accent); padding: 0 4px; text-decoration: underline; }

/* l'étirement d'un ensemble : la grille entre deux règles, la croix en cyan */
.tx-etirement { display: inline-grid; gap: 2px; margin: 6px 0 4px; }
.tx .tx-etirement button { padding: 0; min-width: 0; font-size: 11px; line-height: 1; color: var(--tx-muted); }
.tx .tx-etirement button.tx-regle-on { background: rgba(0, 229, 255, 0.35); border-color: #00e5ff; color: #fff; }
.tx-etirement .tx-cellule { position: relative; width: 48px; height: 48px; background: var(--tx-panel-2); }
.tx-etirement .tx-cellule canvas { display: block; width: 48px; height: 48px; image-rendering: pixelated; }
.tx-etirement .tx-cellule.tx-repete::after { content: ''; position: absolute; inset: 0; background: rgba(0, 229, 255, 0.22); pointer-events: none; }
.tx-etirement .tx-coin { width: 18px; height: 18px; }
.tx-puce { background: var(--tx-panel-2); border: 1px solid var(--tx-line); border-radius: 10px; padding: 1px 8px; font-size: 12px; }
.tx-puce button { all: unset; cursor: pointer; margin-left: 4px; color: var(--tx-muted); }

.tx-images { display: flex; flex-direction: column; gap: 3px; }
.tx-image { display: flex; align-items: center; gap: 6px; }
.tx-image canvas { width: 32px; height: 32px; image-rendering: pixelated; background: #18181b; border: 1px solid var(--tx-line); }
.tx-image input { width: 70px; }
.tx-image button { padding: 2px 6px; }
.tx-apercu { width: 96px; height: 96px; image-rendering: pixelated; background: #18181b; border: 1px solid var(--tx-line); }
.tx-apercu-large { image-rendering: pixelated; background: #18181b; border: 1px solid var(--tx-line); max-width: 100%; }

.tx-terrains { display: flex; flex-direction: column; gap: 4px; }
.tx-terrain { display: flex; align-items: center; gap: 6px; }
.tx-terrain input[type=color] { width: 28px; height: 24px; padding: 0; border: 1px solid var(--tx-line); background: none; }
.tx-terrain input[type=text] { flex: 1; }
.tx-motifs { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; margin-top: 6px; }
.tx-motif { display: grid; grid-template-columns: 1fr 1fr; width: 26px; height: 26px; border: 1px solid var(--tx-line); }
.tx-motif.tx-bords { grid-template-columns: 1fr 1fr 1fr; }
.tx-motif.tx-present { opacity: 0.28; }

.tx-vocab { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.tx-vocab-ligne { display: flex; align-items: center; gap: 6px; }
.tx-vocab-ligne span { flex: 1; }
.tx-vocab-ligne.tx-inactif span { color: var(--tx-muted); text-decoration: line-through; }
.tx-vocab-ligne small { color: var(--tx-muted); }
.tx-vocab-ligne button { padding: 1px 6px; font-size: 11px; }

.tx-legende { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--tx-muted); font-size: 12px; }
.tx-legende span { display: inline-flex; align-items: center; gap: 4px; }
.tx kbd { background: var(--tx-panel-2); border: 1px solid var(--tx-line); border-radius: 3px; padding: 0 4px; font-size: 11px; }

/* ---------- assembler, fiche ---------- */
.tx-inspecteur.tx-large { width: 540px; }
.tx-sous-titre { font-size: 12px; color: var(--tx-muted); margin: 12px 0 4px; font-weight: 600; }
.tx-ligne > textarea { flex: 1; }
.tx input.tx-mini { width: 64px; flex: 0 0 64px; }
.tx-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.tx-chips button { padding: 2px 9px; font-size: 12px; border-radius: 10px; }

.tx-asm { overflow: auto; max-height: 480px; background: #18181b; border: 1px solid var(--tx-line); padding: 6px; margin: 6px 0; }
.tx-asm canvas { display: block; image-rendering: pixelated; cursor: crosshair; }
.tx-pile { display: flex; flex-direction: column; gap: 3px; }

.tx-fiche { display: flex; flex-direction: column; gap: 10px; max-width: 100%; }
.tx textarea.tx-export { min-height: 320px; font-family: Consolas, 'Courier New', monospace; font-size: 11px; white-space: pre; }

.tx-bilan { display: flex; flex-direction: column; gap: 4px; max-height: 420px; overflow-y: auto; }
.tx-bilan-item { display: flex; gap: 6px; align-items: flex-start; padding: 4px 6px; border-radius: 4px; background: var(--tx-panel-2); }
.tx-bilan-item b { flex-shrink: 0; font-size: 10px; padding: 1px 5px; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.03em; }
.tx-bilan-item span { flex: 1; font-size: 12px; }
.tx-bilan-item button { padding: 1px 7px; font-size: 11px; flex-shrink: 0; }
.tx-niv-manque b { background: #c62828; }
.tx-niv-incoherent b { background: #ef6c00; }
.tx-niv-conseil b { background: #455a64; }

.tx-roles { display: flex; flex-direction: column; gap: 2px; }
.tx-role { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.tx-role canvas { width: 24px; height: 24px; image-rendering: pixelated; background: #18181b; border: 1px solid var(--tx-line); flex-shrink: 0; }
.tx-role span { flex: 1; }
.tx-role small { color: var(--tx-muted); }
.tx-role button { padding: 1px 7px; font-size: 11px; }
/* ---------- barre : recherche, compteur, raccourcis ---------- */
.tx-atelier { position: relative; }
.tx input.tx-recherche { width: 230px; background: var(--tx-panel-2); color: var(--tx-text); border: 1px solid var(--tx-line); border-radius: 4px; padding: 4px 6px; }
.tx input.tx-recherche:focus { border-color: #ffd740; outline: none; }
.tx button.tx-afaire { background: rgba(255, 152, 0, 0.16); border-color: #ef6c00; color: #ffcc80; font-weight: 600; }
.tx button.tx-afaire.tx-complet { background: rgba(102, 187, 106, 0.16); border-color: var(--tx-ok); color: #c8e6c9; }
.tx-raccourcis {
    position: absolute; top: 56px; right: 16px; z-index: 10; width: 420px;
    background: var(--tx-panel); border: 1px solid var(--tx-accent); border-radius: 6px;
    padding: 10px 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.tx-raccourcis h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--tx-muted); }
.tx-raccourcis table { width: 100%; border-collapse: collapse; }
.tx-raccourcis td { padding: 3px 4px; font-size: 12px; vertical-align: top; border-bottom: 1px solid var(--tx-line); }
.tx-raccourcis td:first-child { white-space: nowrap; color: #fff; font-family: Consolas, 'Courier New', monospace; font-size: 11px; }
.tx-touche { display: inline-block; min-width: 12px; font-size: 10px; color: var(--tx-muted); text-align: right; }

/* ---------- fiche d'une tuile ---------- */
.tx-carte { display: flex; gap: 10px; align-items: flex-start; }
.tx-carte canvas { width: 96px; height: 96px; image-rendering: pixelated; background: #18181b; border: 1px solid var(--tx-line); flex-shrink: 0; }
.tx-carte-infos { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tx-code { font-family: Consolas, 'Courier New', monospace; font-size: 11px; background: var(--tx-panel-2); padding: 2px 5px; border-radius: 3px; cursor: copy; word-break: break-all; }
.tx-ok-texte { color: var(--tx-ok); font-size: 12px; }

/* ---------- vue d'ensemble ---------- */
.tx-progres { margin: 8px 0; }
.tx-progres-tete { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.tx-progres-tete small { color: var(--tx-muted); white-space: nowrap; }
.tx-progres-barre { height: 8px; background: var(--tx-panel-2); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.tx-progres-barre span { display: block; height: 100%; background: var(--tx-accent); }
.tx-progres-barre span.tx-plein { background: var(--tx-ok); }
.tx-galerie { display: flex; flex-wrap: wrap; gap: 10px; }
.tx-mini-asm { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; cursor: pointer; padding: 6px; border: 1px solid var(--tx-line); border-radius: 4px; background: #18181b; }
.tx-mini-asm:hover { border-color: var(--tx-accent); }
.tx-mini-asm canvas { image-rendering: pixelated; }
.tx-mini-asm span { font-size: 11px; color: var(--tx-muted); max-width: 150px; text-align: center; }
