/* LEGIO — configurateur (#cfg-root). Style « instrument de précision » :
   panneaux d'acier, codes latins en mono, cotes en bleu-plan, braise réservée à l'action principale.
   Tous les sélecteurs sont sous .cfg (ou .cfg-sticky, la barre mobile accrochée au <body>).
   Couleurs et polices : uniquement les jetons de SPEC §5. */

.cfg {
  --cfg-gap: 12px;
  --cfg-line: var(--steel-700);
  --cfg-glass: color-mix(in srgb, var(--steel-950) 78%, transparent);
  position: relative;
  display: grid;
  gap: var(--cfg-gap);
  grid-template-columns: minmax(0, 1fr);
  /* Même ordre que le DOM (et donc que la touche Tab) : barre → scène → palette → plan → panneau. */
  grid-template-areas: "toolbar" "viewport" "palette" "plan" "panel";
  color: var(--bone);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.45;
  text-align: left;
}
.cfg *, .cfg *::before, .cfg *::after { box-sizing: border-box; }
.cfg [hidden] { display: none !important; }
/* :where() = spécificité d'un simple élément : toute classe (.cfg__add, .cfg__fmt…) garde sa couleur. */
:where(.cfg) button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.cfg button:disabled, .cfg button[aria-disabled="true"] { cursor: not-allowed; }
.cfg :focus-visible { outline: 2px solid var(--blueprint); outline-offset: 2px; }
.cfg kbd { font-family: var(--f-mono); }

.cfg__sr, .cfg__sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.cfg__label {
  margin: 0;
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ash);
}
.cfg__code {
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .08em;
  color: var(--blueprint);
  white-space: nowrap;
}
.cfg__ico { width: 20px; height: 20px; flex: none; }
.cfg__glyph { width: 18px; height: 18px; flex: none; }

/* ─── Boutons de base ────────────────────────────────────────────────────── */
.cfg__ibtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 44px; min-height: 44px; padding: 0 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--bone);
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.cfg__ibtn:hover:not(:disabled) { background: var(--steel-800); border-color: var(--cfg-line); }
.cfg__ibtn:disabled { color: var(--steel-500); }
.cfg__ibtn--txt span { font-size: 13px; font-weight: 500; }

/* ─── Scène ──────────────────────────────────────────────────────────────── */
/* Mobile : la scène se « dissout » pour que la palette se glisse juste sous le 3D. */
.cfg__stage { display: contents; }
.cfg__viewport { grid-area: viewport; }
.cfg__toolbar { grid-area: toolbar; }

.cfg__toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 6px;
  background: var(--steel-900);
  border: 1px solid var(--cfg-line);
  border-radius: var(--r-md);
}
.cfg__formats {
  display: flex; gap: 2px; padding: 2px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--steel-950);
  border: 1px solid var(--cfg-line);
  border-radius: var(--r-sm);
}
.cfg__formats::-webkit-scrollbar { display: none; }
.cfg__fmt {
  position: relative;
  flex: none;
  display: grid; align-content: center; justify-items: start;
  min-height: 44px; padding: 4px 10px;
  background: transparent; border: 0; border-radius: 3px;
  color: var(--ash);
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.cfg__fmt-code { font-family: var(--f-mono); font-size: 11px; font-weight: 700; letter-spacing: .1em; line-height: 1.3; }
.cfg__fmt-size { font-family: var(--f-mono); font-size: 10px; color: var(--steel-300); line-height: 1.3; }
.cfg__fmt:hover { color: var(--bone); background: var(--steel-800); }
.cfg__fmt[aria-pressed="true"] { color: var(--bone); background: var(--steel-700); box-shadow: inset 0 -2px 0 var(--blueprint); }
.cfg__fmt.is-near { color: var(--bone); box-shadow: inset 0 -2px 0 var(--blueprint-dim); }
/* « Modifié » : un point bleu-plan, pas du texte (le bouton ne s'élargit pas, la barre ne passe pas sur deux rangées). */
.cfg__fmt.is-near::after {
  content: ""; position: absolute; top: 7px; right: 5px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--blueprint);
}

.cfg__dims { display: flex; flex-wrap: wrap; gap: 8px; }
.cfg__stepper {
  display: inline-grid;
  grid-template-columns: 44px minmax(64px, auto) 44px;
  align-items: stretch;
  position: relative;
  background: var(--steel-950);
  border: 1px solid var(--cfg-line);
  border-radius: var(--r-sm);
}
.cfg__stepper .cfg__ibtn { border-radius: 0; }
.cfg__stepper-lab {
  grid-column: 2; grid-row: 1;
  align-self: start;
  padding-top: 5px;
  text-align: center;
  font-family: var(--f-mono); font-size: 9px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ash);
  pointer-events: none;
}
.cfg__stepper-val {
  grid-column: 2; grid-row: 1;
  align-self: end;
  padding: 0 6px 5px;
  text-align: center;
  font-family: var(--f-mono); font-size: 13px; font-weight: 700;
  color: var(--blueprint);
  white-space: nowrap;
}
.cfg__stepper [data-act$="-"] { grid-column: 1; grid-row: 1; border-right: 1px solid var(--cfg-line); }
.cfg__stepper [data-act$="+"] { grid-column: 3; grid-row: 1; border-left: 1px solid var(--cfg-line); }
.cfg__edit { display: flex; gap: 2px; margin-left: auto; }

.cfg__viewport {
  position: relative;
  height: clamp(320px, 58vh, 640px);
  height: clamp(320px, 58svh, 640px);
  overflow: hidden;
  border: 1px solid var(--cfg-line);
  border-radius: var(--r-md);
  background:
    linear-gradient(var(--blueprint-dim) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(90deg, var(--blueprint-dim) 1px, transparent 1px) 0 0 / 48px 48px,
    radial-gradient(120% 90% at 50% 20%, var(--steel-800), var(--steel-950) 70%);
  background-blend-mode: soft-light, soft-light, normal;
}
/* Le canvas est posé en absolu : sa taille intrinsèque (attributs width/height) ne pousse jamais la mise en page. */
.cfg__canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
/* Focalisable (flèches = tourner) : l'anneau se dessine en dedans, le cadre coupe tout ce qui dépasse. */
.cfg .cfg__canvas:focus-visible { outline: 2px solid var(--blueprint); outline-offset: -2px; }
.cfg[data-tool]:not([data-tool=""]) .cfg__canvas { cursor: crosshair; }

.cfg__cotes {
  position: absolute; top: 10px; left: 10px;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  font-family: var(--f-mono); font-size: 11px; font-weight: 500; letter-spacing: .06em;
  color: var(--blueprint);
  background: var(--cfg-glass);
  border: 1px solid var(--blueprint-dim);
  border-radius: var(--r-sm);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.cfg__cote-x { color: var(--steel-300); }

.cfg__view {
  position: absolute; top: 10px; right: 10px;
  display: flex; flex-direction: column; gap: 4px;
  padding: 4px;
  background: var(--cfg-glass);
  border: 1px solid var(--cfg-line);
  border-radius: var(--r-md);
  backdrop-filter: blur(6px);
}
.cfg__vbtn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-sm);
  color: var(--bone);
}
.cfg__vbtn span {
  position: absolute; right: calc(100% + 8px); top: 50%;
  transform: translateY(-50%);
  padding: 4px 8px;
  font-size: 12px; white-space: nowrap;
  background: var(--steel-950); border: 1px solid var(--cfg-line); border-radius: var(--r-sm);
  opacity: 0; pointer-events: none;
  transition: opacity .15s var(--ease);
}
.cfg__vbtn:hover span, .cfg__vbtn:focus-visible span { opacity: 1; }
.cfg__vbtn:hover { background: var(--steel-800); }
.cfg__vbtn[aria-pressed="true"] { color: var(--steel-950); background: var(--blueprint); }
.cfg__vbtn:disabled { color: var(--steel-500); background: transparent; }
.cfg__view-sep { display: block; height: 1px; margin: 4px 6px; background: var(--cfg-line); }
.cfg__vbtn--edit, .cfg__view-sep { display: none; }

.cfg__help {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  display: flex; align-items: flex-start; gap: 10px;
  min-height: 44px;
  padding: 11px 14px;
  background: var(--cfg-glass);
  border: 1px solid var(--cfg-line);
  border-left: 3px solid var(--blueprint);
  border-radius: var(--r-sm);
  backdrop-filter: blur(8px);
  font-size: 13.5px; line-height: 1.4;
  color: var(--bone);
  pointer-events: none;
  transition: border-color .2s var(--ease);
}
.cfg__help-ico { display: inline-flex; color: var(--blueprint); padding-top: 0; }
.cfg__help-ico .cfg__ico { width: 18px; height: 18px; }
.cfg__help[data-tone="ok"] { border-left-color: var(--ok); }
.cfg__help[data-tone="ok"] .cfg__help-ico { color: var(--ok); }
.cfg__help[data-tone="bad"] { border-left-color: var(--bad); }
.cfg__help[data-tone="bad"] .cfg__help-ico { color: var(--bad); }
.cfg__help[data-tone="warn"] { border-left-color: var(--warn); }
.cfg__help[data-tone="warn"] .cfg__help-ico { color: var(--warn); }
.cfg__help[data-tone="idle"] { border-left-color: var(--steel-500); }
.cfg__help[data-tone="idle"] .cfg__help-ico { color: var(--ash); }

.cfg__notice {
  position: absolute; top: 10px; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px;
  width: min(520px, calc(100% - 140px));
  padding: 4px;
  background: var(--cfg-glass);
  border: 1px solid var(--blueprint-dim);
  border-radius: var(--r-md);
  backdrop-filter: blur(8px);
}
.cfg__notice-body { flex: 1; min-width: 0; display: grid; text-align: center; padding: 2px 4px; }
.cfg__notice-n { font-family: var(--f-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--blueprint); }
.cfg__notice-lab { font-family: var(--f-display); font-size: 20px; font-weight: 800; text-transform: uppercase; line-height: 1.22; letter-spacing: .02em; }
.cfg__notice-pcs { font-family: var(--f-mono); font-size: 10.5px; color: var(--ash); }
/* Puces de l'étape : elles se rangent en CSS seulement (la zone est aria-live : aucun fantôme). */
.cfg__nchip { display: inline-block; white-space: nowrap; animation: cfg-nchip 220ms var(--e-arrive, var(--ease)) backwards; animation-delay: calc(var(--i, 0) * 28ms); }
@keyframes cfg-nchip { from { opacity: .28; transform: translateY(6px); } }
.cfg.is-notice .cfg__cotes { display: none; }

.cfg__nogl {
  position: relative;
  z-index: 1;
  display: flex; gap: 12px; align-items: flex-start;
  margin: 12px 12px 0;
  padding: 12px 14px;
  background: var(--cfg-glass);
  border: 1px solid var(--cfg-line);
  border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--ash);
}
.cfg__nogl p { margin: 0; max-width: 70ch; }
.cfg__nogl strong { color: var(--bone); font-weight: 600; }
.cfg__nogl-ico { width: 28px; height: 28px; flex: none; color: var(--blueprint); }

/* ─── Palette d'outils ───────────────────────────────────────────────────── */
.cfg__palette {
  grid-area: palette;
  min-width: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.cfg__palette-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 2px; }
.cfg__palette-tip { font-size: 12px; color: var(--ash); }
.cfg__tools {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 128px;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  padding: 2px 2px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--steel-500) transparent;
}
.cfg__tool {
  position: relative;
  scroll-snap-align: start;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "thumb" "body" "side";
  gap: 6px;
  min-height: 44px;
  padding: 8px;
  text-align: left;
  background: var(--steel-900);
  border: 1px solid var(--cfg-line);
  border-radius: var(--r-md);
  transition: border-color .15s var(--ease), background-color .15s var(--ease), transform .15s var(--ease);
}
.cfg__tool:hover { border-color: var(--steel-500); background: var(--steel-800); }
.cfg__tool[aria-pressed="true"] {
  border-color: var(--blueprint);
  background: color-mix(in srgb, var(--blueprint) 9%, var(--steel-900));
  box-shadow: 0 0 0 1px var(--blueprint), 0 10px 28px -16px var(--blueprint);
}
.cfg__tool-thumb {
  grid-area: thumb;
  position: relative;
  display: grid; place-items: center;
  aspect-ratio: 1;
  width: 100%;
  overflow: hidden;
  background:
    linear-gradient(var(--blueprint-dim) 1px, transparent 1px) 0 0 / 12px 12px,
    linear-gradient(90deg, var(--blueprint-dim) 1px, transparent 1px) 0 0 / 12px 12px,
    radial-gradient(80% 80% at 50% 35%, var(--steel-800), var(--steel-950));
  background-blend-mode: soft-light, soft-light, normal;
  border: 1px solid var(--steel-800);
  border-radius: var(--r-sm);
}
.cfg__tool-glyph { display: grid; justify-items: center; gap: 4px; color: var(--bone); }
.cfg__tool-glyph .cfg__glyph { width: 30px; height: 30px; stroke-width: 1.3; }
.cfg__tool-glyph-code { font-family: var(--f-mono); font-size: 8.5px; letter-spacing: .14em; color: var(--blueprint); }
.cfg__tool[data-tool="focus"] .cfg__tool-glyph { color: var(--ember-hot); }
.cfg__tool[data-tool="ligna"] .cfg__tool-glyph, .cfg__tool[data-tool="mensa"] .cfg__tool-glyph { color: var(--wood); }
.cfg__tool-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cfg__tool.has-render .cfg__tool-glyph { display: none; }
.cfg__tool-body { grid-area: body; display: grid; gap: 1px; min-width: 0; }
.cfg__tool-name { font-weight: 600; font-size: 14.5px; line-height: 1.25; color: var(--bone); }
.cfg__tool-code { font-family: var(--f-mono); font-size: 10px; letter-spacing: .07em; color: var(--blueprint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfg__tool-meta { font-size: 11.5px; line-height: 1.35; color: var(--ash); }
.cfg__tool-side { grid-area: side; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cfg__tool-price { font-family: var(--f-mono); font-size: 12px; font-weight: 500; color: var(--bone); white-space: nowrap; }
.cfg__kbd {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 4px;
  font-size: 10px; color: var(--ash);
  border: 1px solid var(--cfg-line); border-bottom-width: 2px; border-radius: 3px;
  background: var(--steel-950);
}
.cfg__tool[aria-pressed="true"] .cfg__kbd { color: var(--steel-950); background: var(--blueprint); border-color: var(--blueprint); }
/* Outil en main : un rail de braise de 2 px sur le bord gauche, qui se lève en 220 ms et se
   replie en 120 ms quand on lâche l'outil. Statique sous mouvement réduit. */
.cfg__tool-rail {
  position: absolute; left: -1px; top: 10px; bottom: 10px; width: 2px;
  border-radius: 1px;
  background: var(--ember);
  box-shadow: 0 0 6px var(--glow);
  transform: scaleY(0);
  transition: transform 120ms var(--e-leave, ease-in);
  pointer-events: none;
}
.cfg__tool[aria-pressed="true"] .cfg__tool-rail { transform: none; transition: transform var(--m-ignite, 220ms) var(--e-ignite, ease-out); }
.cfg__tool-count {
  position: absolute; top: 12px; left: 12px;
  padding: 1px 6px;
  font-family: var(--f-mono); font-size: 10px; font-weight: 700;
  color: var(--steel-950); background: var(--bone);
  border-radius: 2px;
}
.cfg__tool--erase { border-style: dashed; }
.cfg__tool--erase .cfg__tool-glyph { color: var(--ash); }
.cfg__tool--erase[aria-pressed="true"] { border-color: var(--bad); border-style: solid; box-shadow: 0 0 0 1px var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--steel-900)); }
.cfg__tool--erase[aria-pressed="true"] .cfg__tool-glyph { color: var(--bad); }
.cfg__tool--erase[aria-pressed="true"] .cfg__kbd { background: var(--bad); border-color: var(--bad); }

/* ─── Plan 2D + inspecteur ───────────────────────────────────────────────── */
.cfg__plan {
  grid-area: plan;
  container: cfg-plan / inline-size;
  min-width: 0;
}
.cfg__plan-in { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--cfg-gap); }
@container cfg-plan (min-width: 600px) {
  .cfg__plan-in { grid-template-columns: auto minmax(0, 1fr); }
}
.cfg__map, .cfg__insp {
  min-width: 0;
  padding: 12px 14px;
  background: var(--steel-900);
  border: 1px solid var(--cfg-line);
  border-radius: var(--r-md);
}
.cfg__map-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.cfg__map-cote { font-family: var(--f-mono); font-size: 11px; color: var(--blueprint); }
.cfg__map-kbd { margin: 8px 0 0; text-align: center; font-size: 12px; color: var(--ash); }
@media (hover: none) { .cfg__map-kbd { display: none; } }
/* Répète, près du plan, le message de la ligne d'aide quand la scène est hors écran. */
.cfg__map-msg {
  margin: 0 0 8px; padding: 8px 10px;
  font-size: 14px; line-height: 1.35; color: var(--bone);
  background: var(--steel-950);
  border: 1px solid var(--cfg-line); border-left: 3px solid var(--blueprint);
  border-radius: var(--r-sm);
}
.cfg__map-msg[data-tone="ok"] { border-left-color: var(--ok); }
.cfg__map-msg[data-tone="bad"] { border-left-color: var(--bad); }
.cfg__map-msg[data-tone="warn"] { border-left-color: var(--warn); }
.cfg__map-frame { display: grid; justify-items: center; gap: 4px; }
.cfg__map-side { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--steel-300); }
.cfg__map-side--front { color: var(--ash); }
.cfg__map-row { display: flex; align-items: center; gap: 8px; max-width: 100%; }
.cfg__map-dim--d {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-family: var(--f-mono); font-size: 10px; color: var(--blueprint);
  padding: 6px 0;
  border-left: 1px solid var(--blueprint-dim);
}
.cfg__grid {
  --cols: 2; --rows: 2;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(52px, 76px));
  grid-auto-rows: 58px;
  gap: 4px;
  padding: 5px;
  background:
    linear-gradient(var(--blueprint-dim) 1px, transparent 1px) -1px -1px / 14px 14px,
    linear-gradient(90deg, var(--blueprint-dim) 1px, transparent 1px) -1px -1px / 14px 14px,
    var(--steel-950);
  background-blend-mode: soft-light, soft-light, normal;
  border: 1px dashed var(--blueprint-dim);
  border-radius: var(--r-sm);
  min-width: 0;
}
.cfg__cell {
  position: relative;
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  min-width: 44px; min-height: 44px;
  padding: 3px 2px;
  background: var(--steel-800);
  border: 1px solid var(--cfg-line);
  border-radius: 3px;
  color: var(--ash);
  transition: border-color .12s var(--ease), background-color .12s var(--ease), box-shadow .12s var(--ease);
}
.cfg__cell-l { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 0; overflow: hidden; }
.cfg__cell-l .cfg__glyph { width: 16px; height: 16px; stroke-width: 1.7; }
.cfg__cell-l em { display: none; font-style: normal; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cfg__cell-l i { display: block; width: 8px; height: 1px; background: var(--steel-500); }
.cfg__cell-l--top { color: var(--steel-300); }
.cfg__cell-l--work { color: var(--bone); }
.cfg__cell-l--base[data-v="focus"] { color: var(--ember-hot); }
.cfg__cell-l--base[data-v="ligna"], .cfg__cell-l--work[data-v="mensa"] { color: var(--wood); }
.cfg__cell.is-fire { box-shadow: inset 0 -10px 14px -10px var(--glow); }
.cfg__cell:hover, .cfg__cell.is-hover { border-color: var(--blueprint); background: color-mix(in srgb, var(--blueprint) 8%, var(--steel-800)); }
.cfg__cell.is-selected { border-color: var(--blueprint); box-shadow: 0 0 0 2px var(--blueprint-dim); }
.cfg__cell[data-preview="ok"] { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, var(--steel-800)); }
.cfg__cell[data-preview="bad"] { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 16%, var(--steel-800)); }
/* Refus : deux oscillations de ±4 px en 280 ms ; le rouge reste le temps du message. Deux noms
   (a/b) : un deuxième refus de suite relance la secousse. */
.cfg__cell[data-shake] { border-color: var(--bad); }
.cfg__cell[data-shake="a"] { animation: cfg-shake-a 280ms linear; }
.cfg__cell[data-shake="b"] { animation: cfg-shake-b 280ms linear; }
@keyframes cfg-shake-a {
  0%, 100% { transform: none; }
  12.5%, 62.5% { transform: translateX(-4px); }
  37.5%, 87.5% { transform: translateX(4px); }
}
@keyframes cfg-shake-b {
  0%, 100% { transform: none; }
  12.5%, 62.5% { transform: translateX(-4px); }
  37.5%, 87.5% { transform: translateX(4px); }
}
/* La grille grandit : les cases nouvelles entrent depuis le bord qui a poussé (.85 → 1, 200 ms,
   20 ms d'écart ; jamais sous .28 d'opacité). */
.cfg__cell.is-grown { animation: cfg-cell-in 200ms var(--e-arrive, var(--ease)) backwards; animation-delay: calc(var(--i, 0) * 20ms); }
@keyframes cfg-cell-in { from { opacity: .28; transform: scale(.85); } }

/* Plan agrandi : repli sans WebGL, dans la zone de la scène. Il est dans le flux (pas en
   absolu) : la zone grandit avec la grille, rien ne passe sous l'avis ni sous la ligne d'aide. */
.cfg[data-mode="2d"] .cfg__viewport { height: auto; min-height: 320px; }
.cfg__map--big {
  position: relative;
  display: flex; flex-direction: column; justify-content: center;
  padding: 16px 24px 84px;
  background: transparent; border: 0;
}
.cfg__map--big .cfg__map-head { justify-content: center; gap: 16px; }
.cfg__map--big .cfg__map-row { width: 100%; justify-content: center; }
.cfg__map--big .cfg__map-row { flex: 0 1 auto; }
.cfg__map--big .cfg__grid {
  width: min(100%, calc(var(--cols) * 210px));
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-auto-rows: clamp(88px, calc((100% - 40px) / var(--rows)), 150px);
  grid-auto-rows: clamp(88px, 15vh, 150px);
  gap: 6px;
  padding: 8px;
}
.cfg__map--big .cfg__cell { padding: 10px 6px; border-radius: var(--r-sm); }
.cfg__map--big .cfg__cell-l { justify-content: flex-start; padding-left: 10px; gap: 8px; }
.cfg__map--big .cfg__cell-l .cfg__glyph { width: 18px; height: 18px; }
.cfg__map--big .cfg__cell-l em { display: inline; font-size: 13px; }
.cfg__map--big .cfg__map-head { margin-bottom: 10px; }
.cfg__map--big .cfg__map-side { font-size: 10.5px; }
.cfg__map--big .cfg__map-dim--d { font-size: 11px; }
.cfg[data-mode="2d"] .cfg__cotes, .cfg[data-mode="2d"] .cfg__view { display: none; }
.cfg[data-mode="2d"] .cfg__plan-in { grid-template-columns: minmax(0, 1fr); }

/* Inspecteur */
.cfg__insp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -6px -6px 2px 0; }
.cfg__insp-head .cfg__label { color: var(--bone); }
.cfg__insp-rows { list-style: none; margin: 0; padding: 0; }
.cfg__insp-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 2px 0;
  border-top: 1px solid var(--steel-800);
}
.cfg__lvl { font-family: var(--f-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ash); }
.cfg__insp-val { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cfg__insp-val > span { display: grid; min-width: 0; line-height: 1.25; }
.cfg__insp-val strong { font-weight: 600; font-size: 14px; }
.cfg__insp-val.is-empty { font-size: 13px; color: var(--steel-300); }
.cfg__insp-row:not(.is-full) { grid-template-columns: 64px auto minmax(0, 1fr); }
.cfg__insp-add { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.cfg__mini {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 0 12px;
  font-size: 13px; font-weight: 500;
  background: var(--steel-800);
  border: 1px solid var(--cfg-line);
  border-radius: var(--r-sm);
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.cfg__mini:hover:not(:disabled):not([aria-disabled="true"]) { border-color: var(--blueprint); }
.cfg__mini--add { width: 44px; padding: 0; }
.cfg__mini--add .cfg__glyph { width: 20px; height: 20px; }
.cfg__mini--add[data-insp-tool="focus"] { color: var(--ember-hot); }
.cfg__mini--add[data-insp-tool="ligna"], .cfg__mini--add[data-insp-tool="mensa"] { color: var(--wood); }
.cfg__mini[aria-disabled="true"] { opacity: .38; }
.cfg__mini--ghost { background: transparent; }
.cfg__mini:disabled { opacity: .45; }
.cfg__insp-x { margin-left: auto; }
.cfg__insp-empty .cfg__insp-hint { margin: 6px 0 10px; font-size: 13px; color: var(--ash); max-width: 46ch; }
.cfg__layers-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.cfg__layers-legend li { display: grid; grid-template-columns: 72px 1fr; gap: 8px; padding: 7px 0; border-top: 1px solid var(--steel-800); font-size: 12.5px; color: var(--ash); }
.cfg__insp-foot { display: flex; justify-content: flex-end; margin-top: 6px; }

/* ─── Panneau « Ta légion » ──────────────────────────────────────────────── */
.cfg__panel {
  grid-area: panel;
  min-width: 0;
  display: flex; flex-direction: column;
  background: var(--steel-900);
  border: 1px solid var(--cfg-line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.cfg__panel-scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px 16px 8px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--steel-500) transparent;
}
.cfg__legion { padding-bottom: 14px; border-bottom: 1px solid var(--cfg-line); }
.cfg__legion-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; margin-top: -8px; }
.cfg__incart {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 14px;
  font-size: 12px; font-weight: 500;
  color: var(--bone);
  background: var(--steel-800);
  border: 1px solid var(--cfg-line);
  border-radius: 2px;
}
.cfg__incart .cfg__ico { width: 15px; height: 15px; color: var(--ember-hot); }
.cfg__incart:hover { border-color: var(--steel-500); }
.cfg__eyebrow { margin: 0; font-family: var(--f-mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ember-hot); }
.cfg__legion-name {
  margin: 2px 0 4px;
  font-family: var(--f-display);
  font-size: 44px; font-weight: 900; line-height: 1.24;
  letter-spacing: .01em;
  text-transform: uppercase;
  color: var(--bone);
}
.cfg__legion-sub { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--ash); }
.cfg__legion-sub span + span::before { content: "·"; margin-right: 12px; color: var(--steel-500); }
.cfg__dim { font-family: var(--f-mono); color: var(--blueprint); }

/* « Le 3D compte » : le compte des pièces par catégorie, visible sans défiler dans le panneau. */
.cfg__count { margin-top: 12px; padding: 10px 12px 4px; background: var(--steel-950); border: 1px solid var(--cfg-line); border-radius: var(--r-sm); }
.cfg__count-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 8px; margin: 0 0 4px; }
.cfg__count-head .cfg__label { white-space: nowrap; }
.cfg__count-head .cfg__label { color: var(--blueprint); }
.cfg__count-meta { font-family: var(--f-mono); font-size: 10.5px; color: var(--steel-300); }
.cfg__count-list { list-style: none; margin: 0; padding: 0; }
.cfg__count-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 72px; gap: 8px; align-items: baseline; padding: 4px 0; font-size: 13px; border-top: 1px dashed var(--steel-800); }
.cfg__count-row:first-child { border-top: 0; }
.cfg__count-cat { color: var(--bone); }
.cfg__count-cat .cfg__auto { margin-left: 4px; vertical-align: 1px; }
.cfg__count-q { font-family: var(--f-mono); font-size: 11.5px; color: var(--ash); white-space: nowrap; }
.cfg__count-s { font-family: var(--f-mono); font-size: 12px; text-align: right; color: var(--bone); white-space: nowrap; }
.cfg__count-more {
  display: inline-flex; align-items: center; gap: 2px;
  min-height: 44px; margin: 0 -4px; padding: 0 4px;
  font-size: 13px; font-weight: 500; color: var(--blueprint);
  background: none; border: 0;
}
.cfg__count-more .cfg__ico { width: 16px; height: 16px; transform: rotate(90deg); }
.cfg__count-more:hover { text-decoration: underline; text-underline-offset: 3px; }
.cfg__bom:focus { outline: none; }
.cfg__bom:focus-visible { outline: 2px solid var(--blueprint); outline-offset: 2px; }

.cfg__sec { padding: 16px 0; border-bottom: 1px solid var(--cfg-line); }
.cfg__sec:last-child { border-bottom: 0; }
.cfg__sec > .cfg__label { margin-bottom: 10px; }
.cfg__sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.cfg__sec-meta { font-family: var(--f-mono); font-size: 10.5px; color: var(--steel-300); }

.cfg__field { margin: 0 0 14px; padding: 0; border: 0; min-width: 0; }
.cfg__field:last-child { margin-bottom: 0; }
.cfg__field-lab {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px;
  margin: 0 0 8px; padding: 0;
  font-size: 13px; font-weight: 600; color: var(--bone);
}
.cfg__field-note { font-size: 11.5px; font-weight: 400; color: var(--ash); }

.cfg__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cfg__chips--stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.cfg__chip { position: relative; display: inline-flex; }
/* Les cases à cocher et boutons radio natifs restent dans l'arbre d'accessibilité et au clavier ;
   seule leur peinture est rognée (motif « visuellement caché », sans opacité 0). */
.cfg__chip input { position: absolute; width: 1px; height: 1px; margin: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; pointer-events: none; }
.cfg__chip-ui {
  display: inline-flex; align-items: center; gap: 8px;
  width: 100%;
  min-height: 44px; padding: 0 12px;
  font-size: 13.5px;
  color: var(--ash);
  background: var(--steel-950);
  border: 1px solid var(--cfg-line);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color .15s var(--ease), color .15s var(--ease), background-color .15s var(--ease);
}
.cfg__chip-ui em { font-style: normal; font-family: var(--f-mono); font-size: 10.5px; color: var(--steel-300); }
.cfg__chip:hover .cfg__chip-ui { border-color: var(--steel-500); color: var(--bone); }
.cfg__chip input:checked + .cfg__chip-ui {
  color: var(--bone);
  border-color: var(--blueprint);
  background: color-mix(in srgb, var(--blueprint) 10%, var(--steel-950));
}
.cfg__chip input:checked + .cfg__chip-ui em { color: var(--blueprint); }
.cfg__chip input:focus-visible + .cfg__chip-ui { outline: 2px solid var(--blueprint); outline-offset: 2px; }
.cfg__chips:not(.cfg__chips--stack) .cfg__chip input:checked + .cfg__chip-ui::before {
  content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--blueprint);
}
.cfg__chips--stack .cfg__chip-ui::after {
  content: ""; margin-left: auto; width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid var(--steel-500);
}
.cfg__chips--stack .cfg__chip input:checked + .cfg__chip-ui::after {
  border-color: var(--blueprint);
  background: radial-gradient(circle, var(--blueprint) 0 3.5px, transparent 4px);
}
.cfg__tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.cfg__tile { position: relative; display: flex; min-width: 0; }
.cfg__tile input { position: absolute; width: 1px; height: 1px; margin: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; pointer-events: none; }
.cfg__tile-ui {
  display: grid; align-content: start; gap: 7px;
  width: 100%; min-height: 72px;
  padding: 6px 6px 8px;
  font-size: 12px; line-height: 1.25;
  color: var(--ash);
  background: var(--steel-950);
  border: 1px solid var(--cfg-line);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color .15s var(--ease), color .15s var(--ease), background-color .15s var(--ease);
}
.cfg__tile-ui .cfg__sw { width: 100%; height: 26px; border-radius: 3px; }
.cfg__tile:hover .cfg__tile-ui { border-color: var(--steel-500); color: var(--bone); }
.cfg__tile input:checked + .cfg__tile-ui { color: var(--bone); border-color: var(--blueprint); box-shadow: 0 0 0 1px var(--blueprint); background: color-mix(in srgb, var(--blueprint) 8%, var(--steel-950)); }
.cfg__tile input:focus-visible + .cfg__tile-ui { outline: 2px solid var(--blueprint); outline-offset: 2px; }
.cfg__sw { display: inline-block; width: 18px; height: 18px; flex: none; border-radius: 3px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bone) 22%, transparent); }
.cfg__sw--noir { background: linear-gradient(135deg, var(--steel-500), var(--steel-950) 60%); }
.cfg__sw--brut { background: linear-gradient(135deg, var(--paper-2), var(--steel-300) 45%, var(--steel-500)); }
.cfg__sw--corten { background: linear-gradient(135deg, var(--ember-hot), var(--ember-deep) 45%, var(--wood-dark)); }
.cfg__sw--erable { background: linear-gradient(135deg, var(--paper-2), color-mix(in srgb, var(--wood) 70%, var(--paper))); }
.cfg__sw--noyer { background: linear-gradient(135deg, var(--wood), var(--wood-dark) 60%); }
.cfg__sw--acier { background: linear-gradient(135deg, var(--steel-300), var(--steel-700)); }

.cfg__switch {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  cursor: pointer;
}
.cfg__switch input { position: absolute; width: 1px; height: 1px; margin: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; pointer-events: none; }
.cfg__switch-ui {
  position: relative;
  width: 40px; height: 24px;
  background: var(--steel-700);
  border: 1px solid var(--steel-500);
  border-radius: 999px;
  transition: background-color .2s var(--ease), border-color .2s var(--ease);
}
.cfg__switch-ui::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ash);
  transition: transform .2s var(--ease), background-color .2s var(--ease);
}
.cfg__switch input:checked + .cfg__switch-ui { background: color-mix(in srgb, var(--blueprint) 35%, var(--steel-800)); border-color: var(--blueprint); }
.cfg__switch input:checked + .cfg__switch-ui::after { transform: translateX(16px); background: var(--bone); }
.cfg__switch input:focus-visible + .cfg__switch-ui { outline: 2px solid var(--blueprint); outline-offset: 2px; }
.cfg__switch-txt { display: grid; font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.cfg__switch-txt .cfg__code { display: inline; margin-left: 6px; }
.cfg__switch-txt small { font-size: 11.5px; font-weight: 400; color: var(--ash); }
.cfg__switch-price { font-family: var(--f-mono); font-size: 12px; color: var(--ash); white-space: nowrap; }

.cfg__engrave { position: relative; margin-top: 8px; transition: opacity .2s var(--ease); }
.cfg__engrave.is-off { opacity: .45; }
.cfg__engrave-input {
  width: 100%;
  height: 48px;
  padding: 0 56px 0 14px;
  font-family: var(--f-mono); font-size: 16px; font-weight: 700; letter-spacing: .24em; text-transform: uppercase;
  color: var(--bone);
  background: var(--steel-950);
  border: 1px solid var(--cfg-line);
  border-bottom: 2px solid var(--blueprint);
  border-radius: var(--r-sm) var(--r-sm) 2px 2px;
}
.cfg__engrave-input::placeholder { color: var(--steel-500); }
.cfg__engrave-input:focus { outline: none; border-color: var(--blueprint); box-shadow: 0 0 0 3px var(--blueprint-dim); }
.cfg__engrave-note { margin: 6px 0 0; font-size: 12.5px; line-height: 1.35; color: var(--warn); }
.cfg__engrave-count { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-family: var(--f-mono); font-size: 11px; color: var(--steel-300); pointer-events: none; }

/* Nomenclature */
.cfg__bom-note { margin: 0 0 8px; font-size: 11.5px; color: var(--ash); }
.cfg__auto {
  display: inline-block;
  padding: 0 5px;
  font-family: var(--f-mono); font-size: 9px; font-weight: 500; line-height: 16px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--blueprint);
  border: 1px solid var(--blueprint-dim);
  border-radius: 3px;
  white-space: nowrap;
}
.cfg__bom-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12.5px; }
.cfg__bom-table td, .cfg__bom-table th { padding: 0; }
.cfg__col-q { width: 44px; }
.cfg__col-s { width: 76px; }
.cfg__bom-cat-row th, .cfg__bom-cat-row td {
  padding: 12px 0 6px;
  font-family: var(--f-mono); font-size: 10px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ash);
  text-align: left;
  border-bottom: 1px solid var(--cfg-line);
}
.cfg__bom-cat-row .cfg__bom-cat-sum { text-align: right; color: var(--bone); letter-spacing: .04em; }
.cfg__bom-line td { padding: 6px 0; border-bottom: 1px dashed var(--steel-800); vertical-align: middle; }
.cfg__bom-main { padding-right: 8px !important; }
.cfg__bom-name { display: block; overflow-wrap: anywhere; font-size: 13px; line-height: 1.3; color: var(--bone); }
.cfg__bom-ref { display: flex; align-items: center; gap: 6px; margin-top: 1px; line-height: 16px; }
.cfg__bom-ref .cfg__code { font-size: 10px; }
.cfg__bom-qty { width: 44px; text-align: right; font-family: var(--f-mono); font-size: 12.5px; font-weight: 700; color: var(--bone); }
.cfg__bom-sub { width: 72px; text-align: right; font-family: var(--f-mono); font-size: 11.5px; color: var(--ash); white-space: nowrap; }
/* Rangée qui grandit (ou nouvelle) : un éclat de braise qui refroidit ; rangée qui diminue : le
   bleu du plan (retirer = refroidir). Le glissé des rangées vient de legioMotion.flip. */
.cfg__bom-line.is-new td, .cfg__bom-line.is-up td { animation: cfg-flash-up 1.2s var(--e-cool, var(--ease)); }
.cfg__bom-line.is-down td { animation: cfg-flash-down 1.2s var(--e-cool, var(--ease)); }
@keyframes cfg-flash-up { 0% { background-color: color-mix(in srgb, var(--ember) 18%, transparent); } 100% { background-color: transparent; } }
@keyframes cfg-flash-down { 0% { background-color: color-mix(in srgb, var(--blueprint) 18%, transparent); } 100% { background-color: transparent; } }

/* Vérifications */
.cfg__warn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cfg__warn {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  font-size: 13px; line-height: 1.4;
  color: var(--bone);
  background: color-mix(in srgb, var(--warn) 8%, var(--steel-950));
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  border-radius: var(--r-sm);
}
.cfg__warn .cfg__ico { width: 18px; height: 18px; color: var(--warn); margin-top: 1px; }
.cfg__warn--ok { background: color-mix(in srgb, var(--ok) 7%, var(--steel-950)); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ash); }
.cfg__warn--ok .cfg__ico { color: var(--ok); }

/* Pied du panneau : totaux + action */
.cfg__foot {
  flex: none;
  display: grid; gap: 10px;
  padding: 14px 16px 16px;
  background: linear-gradient(var(--steel-900), var(--steel-950));
  border-top: 1px solid var(--cfg-line);
}
.cfg__stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; margin: 0; }
.cfg__stats div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; min-height: 26px; padding-bottom: 3px; border-bottom: 1px dashed var(--steel-800); }
.cfg__stats dt { flex: none; font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ash); }
.cfg__stats dd { min-width: 0; margin: 0; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--bone); text-align: right; }
.cfg__total { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 0 12px; }
.cfg__total-lab { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ash); }
.cfg__total-val {
  grid-row: span 2; grid-column: 2;
  font-family: var(--f-display); font-size: 38px; font-weight: 800; line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--bone);
  white-space: nowrap;
}
.cfg__total-note { font-size: 11.5px; color: var(--ash); }
/* Totaux : un « tic » de couleur quand ils changent (chaleur = ajout, bleu = retrait), jamais
   d'interpolation des chiffres (MOTION fait rouler un fantôme sur les hôtes [data-roll]). Deux noms
   par sens : configurator-ui alterne a/b pour relancer l'animation sans recalcul forcé. La montée
   est instantanée, la descente prend .5 s (la chaleur monte vite, refroidit lentement). */
.cfg [data-tick="up-a"], .cfg-sticky [data-tick="up-a"] { animation: cfg-tick-up-a .5s var(--e-cool, var(--ease)); }
.cfg [data-tick="up-b"], .cfg-sticky [data-tick="up-b"] { animation: cfg-tick-up-b .5s var(--e-cool, var(--ease)); }
.cfg [data-tick="down-a"], .cfg-sticky [data-tick="down-a"] { animation: cfg-tick-down-a .5s var(--e-cool, var(--ease)); }
.cfg [data-tick="down-b"], .cfg-sticky [data-tick="down-b"] { animation: cfg-tick-down-b .5s var(--e-cool, var(--ease)); }
@keyframes cfg-tick-up-a { from { color: var(--heat-4, var(--ember-hot)); } }
@keyframes cfg-tick-up-b { from { color: var(--heat-4, var(--ember-hot)); } }
@keyframes cfg-tick-down-a { from { color: var(--heat-0, var(--blueprint)); } }
@keyframes cfg-tick-down-b { from { color: var(--heat-0, var(--blueprint)); } }

.cfg__add {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  min-height: 56px; padding: 10px 18px;
  font-size: 15.5px; font-weight: 700; line-height: 1.25;
  color: var(--steel-950);
  background: var(--ember);
  border: 0;
  border-radius: var(--r-md);
  box-shadow: 0 0 0 1px var(--ember-deep) inset, 0 12px 28px -12px var(--glow);
  transition: background-color .15s var(--ease), transform .1s var(--ease), box-shadow .2s var(--ease);
}
.cfg__add:hover { background: var(--ember-hot); box-shadow: 0 0 0 1px var(--ember) inset, 0 14px 34px -10px var(--glow); }
.cfg__add:active { transform: translateY(1px); }
.cfg__add:focus-visible { outline: 2px solid var(--ember-hot); outline-offset: 3px; }
.cfg__add b { font-weight: 800; font-variant-numeric: tabular-nums; }
.cfg__add.is-done { background: var(--ok); box-shadow: none; }
/* Deux états dans le même bouton (l'hôte [data-add-n] n'est jamais recréé) : « Ajouter les N
   pièces » / « Ajouté au panier — N pièces ». */
.cfg__add-state { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-width: 0; }
.cfg__add-state[hidden] { display: none; }
.cfg__share {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  min-height: 44px; padding: 0 14px;
  font-size: 13.5px; font-weight: 500;
  color: var(--bone);
  background: transparent;
  border: 1px solid var(--cfg-line);
  border-radius: var(--r-md);
  transition: border-color .15s var(--ease), color .15s var(--ease);
}
.cfg__share .cfg__ico { width: 18px; height: 18px; color: var(--blueprint); }
.cfg__share:hover { border-color: var(--blueprint); }
.cfg__share.is-done { border-color: var(--ok); color: var(--ok); }
.cfg__share.is-done .cfg__ico { color: var(--ok); }
/* Copié : l'icône du lien cède la place à un ✓ qui se trace en 220 ms (vu tout de suite en
   mouvement réduit). */
.cfg__share-ok { display: none; }
.cfg__share.is-done .cfg__ico:not(.cfg__share-ok) { display: none; }
.cfg__share.is-done .cfg__share-ok { display: block; }
.cfg__share.is-done .cfg__share-ok path { stroke-dasharray: 22; animation: cfg-check-draw var(--m-ignite, 220ms) var(--e-ignite, var(--ease)) backwards; }
@keyframes cfg-check-draw { from { stroke-dashoffset: 22; } to { stroke-dashoffset: 0; } }
.cfg__linkbox { display: grid; gap: 4px; }
.cfg__linkbox-lab { font-size: 11.5px; color: var(--ash); }
.cfg__linkbox-input {
  width: 100%; min-height: 44px; padding: 0 10px;
  font-family: var(--f-mono); font-size: 16px; color: var(--blueprint);
  background: var(--steel-950); border: 1px solid var(--blueprint-dim); border-radius: var(--r-sm);
}

/* ─── Barre collante mobile (accrochée au <body>) ────────────────────────── */
.cfg-sticky {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 90;
  display: flex; align-items: center; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--steel-950) 92%, transparent);
  border-top: 1px solid var(--steel-700);
  backdrop-filter: blur(10px);
  color: var(--bone);
  font-family: var(--f-body);
  transform: translateY(110%);
  visibility: hidden;
  transition: transform .3s var(--ease), visibility 0s linear .3s;
}
.cfg-sticky.is-on { transform: none; visibility: visible; transition: transform .3s var(--ease); }
.cfg-sticky__sum { flex: 1; min-width: 0; display: grid; line-height: 1.2; }
.cfg-sticky__price { font-family: var(--f-display); font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cfg-sticky__meta { font-size: 12px; color: var(--ash); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cfg-sticky__n { font-variant-numeric: tabular-nums; }
.cfg-sticky__add {
  flex: none;
  min-height: 48px; padding: 0 18px;
  font: 700 15px/1 var(--f-body);
  color: var(--steel-950);
  background: var(--ember);
  border: 0; border-radius: var(--r-md);
  box-shadow: 0 10px 24px -12px var(--glow);
  cursor: pointer;
}
.cfg-sticky__add.is-done { background: var(--ok); }
.cfg-sticky__add:focus-visible { outline: 2px solid var(--ember-hot); outline-offset: 3px; }

/* ─── Mise en page ───────────────────────────────────────────────────────── */

/* Le focus clavier ne doit jamais finir sous la barre collante du bas (WCAG 2.4.11). */
.cfg button, .cfg input, .cfg__insp { scroll-margin-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

@media (max-width: 1023.98px) {
  .cfg__tool-thumb { aspect-ratio: auto; height: 64px; }
  .cfg__tool-glyph { grid-auto-flow: column; align-items: center; gap: 8px; }
  .cfg__tool-glyph .cfg__glyph { width: 26px; height: 26px; }
  .cfg__tool-meta { display: none; }
  .cfg__tool-count { top: 12px; left: 12px; }
}
@media (hover: none) {
  .cfg__kbd { display: none; }
}
@media (min-width: 640px) {
  .cfg__tools { grid-auto-columns: 140px; }
}

@media (max-width: 1023.98px) {
  .cfg__panel-scroll { overflow: visible; }
  .cfg__toolbar { justify-content: space-between; }
  .cfg__formats { flex: 1 1 100%; }
  .cfg__fmt { flex: 1 0 auto; }
  .cfg__dims { flex: 1 1 auto; }
  .cfg__stepper { flex: 1 1 0; grid-template-columns: 44px minmax(56px, 1fr) 44px; }
  /* La ligne d'aide porte chaque consigne, aperçu et refus : lisible sur téléphone. */
  .cfg__help { font-size: 15px; line-height: 1.35; padding: 9px 12px; }
  .cfg__insp-empty .cfg__insp-hint, .cfg__warn { font-size: 14px; }
  .cfg__bom-table { font-size: 13.5px; }
  .cfg__bom-name { font-size: 14px; }
  .cfg__vbtn span { display: none; }
  .cfg__cotes { font-size: 10.5px; }
  .cfg__map--big { padding: 12px 12px 112px; }
  /* Notice : la carte d'étape prend toute la largeur à gauche du rail de vue (54 px). */
  .cfg__notice { left: 10px; right: 64px; width: auto; transform: none; }
  .cfg__notice-lab { font-size: 17px; }
  .cfg.is-notice .cfg__help { display: none; }
}

/* Tactile : les quatre boutons de vue ont leur nom écrit sous l'icône (pas de survol pour l'infobulle). */
@media (max-width: 1023.98px) and (hover: none) {
  .cfg__vbtn { flex-direction: column; gap: 2px; width: 56px; height: auto; min-height: 52px; padding: 5px 2px 4px; }
  .cfg__vbtn .cfg__ico { width: 18px; height: 18px; }
  .cfg__vbtn span {
    display: block; position: static; transform: none;
    padding: 0; border: 0; background: none; opacity: 1;
    font-family: var(--f-mono); font-size: 9.5px; line-height: 1.15; letter-spacing: .02em;
    white-space: normal; text-align: center; color: inherit;
  }
  .cfg__notice { right: 72px; }
}

@media (max-width: 479.98px) {
  .cfg__edit { margin-left: 0; flex: 1 1 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .cfg__edit .cfg__ibtn { border-color: var(--cfg-line); background: var(--steel-950); }
  .cfg__dims { flex: 1 1 100%; }
  /* Notice : le texte de l'étape prend toute la largeur, les trois boutons passent dessous. */
  .cfg__notice { flex-wrap: wrap; justify-content: center; }
  .cfg__notice-body { order: -1; flex: 1 1 100%; }
  /* Les quatre formats sur deux rangées : rien de caché à droite, rien à faire défiler. */
  .cfg__formats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .cfg__fmt { justify-items: center; }
  .cfg__legion-name { font-size: 38px; }
  .cfg__insp-row:not(.is-full) { grid-template-columns: 56px minmax(0, 1fr); }
  .cfg__insp-row:not(.is-full) .cfg__insp-val { display: none; }
  .cfg__insp-row { grid-template-columns: 56px minmax(0, 1fr) auto; }
  .cfg__insp-add { justify-content: flex-start; }
}

/* ─── Bureau (≥ 1024 px) ───────────────────────────────────────────────────
   La première rangée (outils · scène · panneau avec son bouton d'ajout) tient dans
   l'écran sous l'en-tête ; le plan 2D et l'inspecteur viennent juste dessous. */
@media (min-width: 1024px) {
  .cfg {
    --cfg-h: clamp(560px, calc(100vh - var(--header-h, 64px) - 24px), 900px);
    --cfg-h: clamp(560px, calc(100svh - var(--header-h, 64px) - 24px), 900px);
    --cfg-pal: 98px;
    /* 1024–1279 : la palette en bande compacte au-dessus de la scène (la scène garde sa largeur). */
    grid-template-columns: minmax(0, 1fr) 316px;
    grid-template-rows: var(--cfg-pal) calc(var(--cfg-h) - var(--cfg-pal) - var(--cfg-gap)) auto;
    grid-template-areas:
      "palette panel"
      "stage   panel"
      "plan    .";
  }
  .cfg__stage { grid-area: stage; display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; }
  .cfg__toolbar { order: 0; }
  .cfg__dims { margin-left: auto; }
  .cfg__viewport { order: 1; flex: 1 1 auto; height: auto; min-height: 0; }
  /* Sans WebGL, le plan agrandi remplace la scène : la rangée grandit avec lui au besoin. */
  .cfg[data-mode="2d"] { grid-template-rows: var(--cfg-pal) minmax(calc(var(--cfg-h) - var(--cfg-pal) - var(--cfg-gap)), auto) auto; }

  /* Le panneau défile dans sa colonne ; arrivé au bout, la molette passe à la page. */
  .cfg__panel { contain: size; }
  .cfg__panel-scroll { overscroll-behavior: auto; }

  .cfg__palette { overflow: hidden; }
  .cfg__palette-head { display: none; }
  .cfg__tools {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
    overscroll-behavior: auto;
    scroll-snap-type: none;
    padding: 0;
  }
  .cfg__tool {
    grid-template-columns: 34px minmax(0, 1fr);
    grid-template-rows: auto auto;
    grid-template-areas: "thumb body" "thumb side";
    align-items: center;
    gap: 0 8px;
    min-height: 46px;
    padding: 4px 8px 4px 4px;
  }
  .cfg__tool-thumb { width: 34px; height: 34px; }
  .cfg__tool-glyph .cfg__glyph { width: 20px; height: 20px; }
  .cfg__tool-glyph-code, .cfg__tool-meta, .cfg__tool-code, .cfg__kbd { display: none; }
  .cfg__tool-name { font-size: 13px; line-height: 1.15; }
  .cfg__tool-side { align-self: start; justify-content: flex-start; }
  .cfg__tool-body { align-self: end; }
  .cfg__tool-price { font-size: 10.5px; color: var(--ash); }
  .cfg__tool-count { top: 2px; left: 2px; font-size: 9px; padding: 0 4px; }

  .cfg__plan-in { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
  .cfg__grid { grid-auto-rows: 52px; }
  .cfg__edit { display: none; }
  .cfg__vbtn--edit, .cfg__view-sep { display: block; }
  .cfg__vbtn--edit { display: inline-flex; }
  .cfg[data-mode="2d"] .cfg__edit { display: flex; }

  /* Barre collante sur bureau : une carte en bas à droite, seulement quand le bouton
     d'ajout du panneau est hors écran (même règle que sur téléphone, voir refreshSticky). */
  .cfg-sticky {
    left: auto;
    right: max(24px, env(safe-area-inset-right, 0px));
    bottom: 24px;
    width: min(440px, calc(100vw - 48px));
    padding: 10px 10px 10px 16px;
    border: 1px solid var(--steel-700);
    border-radius: var(--r-md);
    box-shadow: 0 18px 40px -18px var(--steel-950);
    transform: translateY(calc(100% + 40px));
  }
}

@media (min-width: 1280px) {
  .cfg {
    --cfg-pal: 0px;
    grid-template-columns: 240px minmax(0, 1fr) 352px;
    grid-template-rows: var(--cfg-h) auto;
    grid-template-areas:
      "palette stage panel"
      ".       plan  .";
  }
  .cfg[data-mode="2d"] { grid-template-rows: minmax(var(--cfg-h), auto) auto; }
  /* La palette en colonne : elle défile dans sa colonne, puis la molette passe à la page. */
  .cfg__palette { contain: size; }
  .cfg__palette-head { display: flex; }
  .cfg__palette-tip { display: none; }
  .cfg__tools {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    overflow-x: hidden; overflow-y: auto;
    padding: 2px 4px 4px 2px;
    min-height: 0;
    flex: 1 1 auto;
  }
  .cfg__tool {
    grid-template-columns: 56px minmax(0, 1fr) auto;
    grid-template-rows: auto;
    grid-template-areas: "thumb body side";
    gap: 10px;
    padding: 7px 8px;
  }
  .cfg__tool-thumb { width: 56px; height: 56px; }
  .cfg__tool-glyph .cfg__glyph { width: 24px; height: 24px; }
  .cfg__tool-name { font-size: 14.5px; line-height: 1.25; }
  .cfg__tool-code { display: block; white-space: normal; overflow: visible; }
  .cfg__tool-meta { display: block; font-size: 11px; }
  .cfg__kbd { display: inline-grid; }
  .cfg__tool-body { align-self: center; }
  .cfg__tool-side { align-self: center; flex-direction: column; align-items: flex-end; justify-content: center; gap: 6px; }
  .cfg__tool-price { font-size: 12px; color: var(--bone); }
  .cfg__tool-count { top: 4px; left: 4px; }
}

@media (min-width: 1024px) and (max-height: 820px) {
  .cfg__tool-meta { display: none !important; }
  .cfg__legion-name { font-size: 36px; }
}
@media (min-width: 1024px) and (hover: none) {
  .cfg__kbd { display: none !important; }
}

/* ─── Rail de vue selon la hauteur de LA SCÈNE (requête de conteneur, pas de l'écran) ─────
   « Tourner à gauche / à droite » ne s'affichent que si le rail entier tient au-dessus de la
   ligne d'aide (mesuré : r2-rail.cjs). Sur une scène très basse, l'aide se range à gauche du rail.
   Seulement en 3D : en plan 2D, le cadre prend la hauteur du plan (pas de confinement de taille). */
.cfg[data-mode="3d"] .cfg__viewport { container: cfg-stage / size; }
@container cfg-stage (max-height: 382.98px) { .cfg__vbtn--orbit { display: none; } }
@media (max-width: 1023.98px) and (hover: none) {
  /* Boutons étiquetés (≈ 57 px) et aide sur trois lignes */
  @container cfg-stage (max-height: 452.98px) { .cfg__vbtn--orbit { display: none; } }
}
@media (min-width: 1024px) {
  /* Rail complet : neuf boutons, Annuler · Rétablir · Tout vider compris */
  @container cfg-stage (max-height: 539.98px) { .cfg__vbtn--orbit { display: none; } }
  @container cfg-stage (max-height: 443.98px) { .cfg__help { right: 72px; } }
}

/* ─── Contraste élevé (forced-colors) : les états cochés / enfoncés restent visibles ───── */
@media (forced-colors: active) {
  .cfg__chip input:checked + .cfg__chip-ui,
  .cfg__tile input:checked + .cfg__tile-ui,
  .cfg__tool[aria-pressed="true"],
  .cfg__fmt[aria-pressed="true"],
  .cfg__vbtn[aria-pressed="true"],
  .cfg__cell[aria-pressed="true"],
  .cfg__cell[data-preview="ok"],
  .cfg__cell[data-preview="bad"] { outline: 3px solid Highlight; outline-offset: -3px; }
  .cfg__switch-ui { border: 1px solid CanvasText; }
  .cfg__switch-ui::after { background: CanvasText; forced-color-adjust: none; }
  .cfg__switch input:checked + .cfg__switch-ui { background: Highlight; forced-color-adjust: none; }
  .cfg__switch input:checked + .cfg__switch-ui::after { background: HighlightText; }
  .cfg__chips:not(.cfg__chips--stack) .cfg__chip input:checked + .cfg__chip-ui::before { background: Highlight; forced-color-adjust: none; }
  .cfg__add, .cfg-sticky__add { border: 2px solid ButtonText; }
  .cfg__help, .cfg__map-msg { border-left-width: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .cfg *, .cfg *::before, .cfg *::after, .cfg-sticky, .cfg-sticky * { animation: none !important; transition: none !important; }
}
/* « Réduire les animations » (html.mx-pref-reduced) : le même état final, sur demande. */
html.mx-pref-reduced .cfg *, html.mx-pref-reduced .cfg *::before, html.mx-pref-reduced .cfg *::after,
html.mx-pref-reduced .cfg-sticky, html.mx-pref-reduced .cfg-sticky * { animation: none !important; transition: none !important; }

/* La cuisine (2026-11-19) : toit et spots */
.cfg__switch-price small { font-size: 10px; opacity: .7; margin-left: 1px; }
.cfg__field.is-off .cfg__switch { opacity: .48; cursor: not-allowed; }

/* ─── Les 5 étapes (2026-11-19) ───────────────────────────────────────────── */
.cfg__steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin: 0; padding: 0; list-style: none; }
.cfg__stepb {
  position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px 5px; border: 1px solid var(--steel-700); border-radius: var(--r-sm);
  background: var(--steel-900); color: var(--ash); font: 600 10.5px/1.1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; cursor: pointer;
}
.cfg__stepb b { font: 800 17px/1 var(--f-display); color: var(--bone); }
.cfg__stepb:hover { border-color: var(--steel-500); color: var(--bone); }
.cfg__stepb[aria-current="step"] { border-color: var(--ember); background: color-mix(in srgb, var(--ember) 14%, var(--steel-900)); color: var(--bone); }
.cfg__stepb[aria-current="step"] b { color: var(--ember); }
.cfg__stepb.is-done::after { content: ""; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; background: var(--ok); }
.cfg__stepcard { padding: 8px 10px; border-left: 2px solid var(--ember); background: color-mix(in srgb, var(--steel-900) 70%, transparent); }
.cfg__stepcard-t { margin: 0 0 2px; font: 800 17px/1.2 var(--f-display); text-transform: uppercase; letter-spacing: .02em; color: var(--bone); }
.cfg__stepcard-t b { color: var(--ember); margin-right: 4px; }
.cfg__stepcard-txt { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ash); }
.cfg__stepnext {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--ember); border-radius: var(--r-sm); background: transparent; color: var(--bone);
  font: 600 14px/1 var(--f-body); cursor: pointer;
}
.cfg__stepnext:hover { background: color-mix(in srgb, var(--ember) 16%, transparent); }
.cfg__stepnext .cfg__ico { width: 16px; height: 16px; }
.cfg[data-step="5"] .cfg__stepnext { background: var(--ember); color: var(--steel-950); }
.cfg[data-step="1"] .cfg__tools, .cfg[data-step="5"] .cfg__tools { display: none; }
/* Étape 1 : la barre des formats et des dimensions s'allume ; étape 5 : la finition. */
.cfg[data-step="1"] .cfg__toolbar { outline: 1px solid var(--ember); outline-offset: 4px; border-radius: var(--r-sm); }
.cfg[data-step="5"] .cfg__opts { outline: 1px solid var(--ember); outline-offset: 6px; border-radius: var(--r-sm); }
.cfg__opts-n { color: var(--ember); margin-right: 4px; }

/* Côtés : ouvert / acier / bois */
.cfg__sides { display: grid; gap: 6px; }
.cfg__side { display: grid; grid-template-columns: 84px repeat(3, minmax(0, 1fr)); gap: 4px; align-items: center; }
.cfg__side-lab { font-size: 13px; color: var(--bone); }
.cfg__side-lab em { font-style: normal; font-family: var(--f-mono); font-size: 11px; color: var(--ash); }
.cfg__seg { position: relative; display: block; }
.cfg__seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.cfg__seg span { display: block; padding: 7px 4px; text-align: center; border: 1px solid var(--steel-700); border-radius: var(--r-sm); font-size: 12.5px; color: var(--ash); background: var(--steel-900); }
.cfg__seg input:checked + span { border-color: var(--ember); color: var(--bone); background: color-mix(in srgb, var(--ember) 14%, var(--steel-900)); }
.cfg__seg input:focus-visible + span { outline: 2px solid var(--blueprint); outline-offset: 2px; }
.cfg__field-help { margin: 8px 0 0; font-size: 12px; line-height: 1.45; color: var(--ash); }
.cfg__sw--cedre { background: linear-gradient(135deg, #e3a06a, #b56a3c 60%); }
.cfg__sw--thermo { background: linear-gradient(135deg, #b98055, #6e4426 60%); }
.cfg__sw--brule { background: repeating-linear-gradient(135deg, #2a2421 0 4px, #3d3430 4px 6px); }

@media (min-width: 1024px) and (max-width: 1279.98px) {
  .cfg { --cfg-pal: 168px; }
  .cfg__palette { display: grid; grid-template-columns: 250px minmax(0, 1fr); grid-template-rows: auto 1fr auto; column-gap: 12px; row-gap: 6px; }
  .cfg__steps { grid-column: 1; grid-row: 1; }
  .cfg__stepcard { grid-column: 1; grid-row: 2; overflow: hidden; }
  .cfg__stepnext { grid-column: 1; grid-row: 3; }
  .cfg__tools { grid-column: 2; grid-row: 1 / 4; align-content: start; grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1280px) {
  .cfg__palette { gap: 8px; }
  .cfg__stepnext { margin-top: auto; flex: none; }
}

.cfg__stepb span { max-width: 100%; overflow: hidden; text-overflow: clip; white-space: nowrap; }
@media (min-width: 1280px) {
  .cfg__stepb span { font-size: 8.5px; letter-spacing: 0; }
}

/* Livraison sous le total (2026-11-19) */
.cfg__ship { margin: 8px 0 0; font: 500 11.5px/1.45 var(--f-mono, ui-monospace); letter-spacing: .04em; color: var(--ash, #A7ADB2); }
