:root {
  --fond: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --texte: #1f2023;
  --texte-2: #5d5f66;
  --bord: #dcdad3;
  --accent: #2f6fd1;
  --accent-doux: #e3ecfa;
  --alerte: #b3261e;
  --alerte-doux: #fbe9e7;
  --avis: #8a5a00;
  --avis-doux: #fff3d6;
  --ok: #2e7d32;
  --fond-3d: #f1f0ec;
  --rayon: 8px;
  /* Les axes, comme sur le cube : X rouge, Y vert, Z bleu ; les cotes en orange. */
  --axe-x: #d1201a; --axe-y: #1f8f4e; --axe-z: #1d6fd6; --cote: #d9760a;
  --voile: rgba(255, 255, 255, .85);
  --plan-mur: #a9a59b; --plan-trait: #6f6c64; --plan-fenetre: #cfe3f5; --plan-meuble: #e9e5dc; --plan-meuble-choisi: #cddcf5; --plan-element: #8c8073;
  --volume-choisi: #dff3e3; --volume-choisi-texte: #1f7a33; --marque: #1f9d5c; --marque-fond: rgb(53 208 127 / 0.35);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--texte);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #17181b; --surface: #1f2024; --surface-2: #26282d; --texte: #e8e8ea; --texte-2: #a3a5ad;
    --bord: #34363c; --accent: #6ea2f0; --accent-doux: #1f2f4a; --alerte: #f28b82; --alerte-doux: #3a1f1e;
    --avis: #f0c060; --avis-doux: #3a3020; --ok: #81c995; --fond-3d: #25272c;
    --axe-x: #ff4d45; --axe-y: #3ccf7a; --axe-z: #4c9dff; --cote: #ffab40; --voile: rgba(31, 32, 36, .85);
    --plan-mur: #6b675f; --plan-trait: #9a968c; --plan-fenetre: #2b4560; --plan-meuble: #3a3b40; --plan-meuble-choisi: #2a3d5c; --plan-element: #5c5750;
    --volume-choisi: #1e3a25; --volume-choisi-texte: #7fd18f; --marque: #3ddc84; --marque-fond: rgb(61 220 132 / 0.3);
  }
}
:root[data-theme="dark"] {
  --fond: #17181b; --surface: #1f2024; --surface-2: #26282d; --texte: #e8e8ea; --texte-2: #a3a5ad;
  --bord: #34363c; --accent: #6ea2f0; --accent-doux: #1f2f4a; --alerte: #f28b82; --alerte-doux: #3a1f1e;
  --avis: #f0c060; --avis-doux: #3a3020; --ok: #81c995; --fond-3d: #25272c;
  --axe-x: #ff4d45; --axe-y: #3ccf7a; --axe-z: #4c9dff; --cote: #ffab40; --voile: rgba(31, 32, 36, .85);
  --plan-mur: #6b675f; --plan-trait: #9a968c; --plan-fenetre: #2b4560; --plan-meuble: #3a3b40; --plan-meuble-choisi: #2a3d5c; --plan-element: #5c5750;
  --volume-choisi: #1e3a25; --volume-choisi-texte: #7fd18f; --marque: #3ddc84; --marque-fond: rgb(61 220 132 / 0.3);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--fond); color: var(--texte); }
header.barre {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--bord); flex-wrap: wrap;
}
header.barre h1 { font-size: 16px; margin: 0; letter-spacing: 0.02em; }
header.barre nav { display: flex; gap: 4px; flex-wrap: wrap; }
header.barre nav a {
  color: var(--texte-2); text-decoration: none; padding: 6px 10px; border-radius: 6px;
}
header.barre nav a[aria-current="page"] { background: var(--accent-doux); color: var(--accent); }
header.barre .actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

button, select, input { font: inherit; color: inherit; }
button {
  background: var(--surface-2); border: 1px solid var(--bord); border-radius: 6px;
  padding: 5px 10px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.principal { background: var(--accent); color: #fff; border-color: var(--accent); }
button.petit { padding: 2px 7px; font-size: 12px; }
input, select {
  background: var(--surface); border: 1px solid var(--bord); border-radius: 6px; padding: 4px 7px; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent-doux); border-color: var(--accent); }
input.faux { border-color: var(--alerte); background: var(--alerte-doux); }

/* La colonne, sa poignée (l'écart entre elle et la vue), la vue ; la largeur
   de la colonne se règle (disposition.js). */
main.meuble {
  display: grid; grid-template-columns: var(--largeur-colonne, minmax(300px, 380px)) 12px minmax(0, 1fr); gap: 12px 0; padding: 12px;
  height: calc(100vh - var(--barre, 53px));
}
@media (max-width: 900px) {
  main.meuble { grid-template-columns: minmax(0, 1fr); height: auto; gap: 12px; }
  /* Sur une colonne, la vue n'a plus la hauteur de l'écran à partager. */
  main.meuble .vue { grid-template-rows: 65vh auto minmax(240px, auto); gap: 8px; }
  main.meuble .poignee-colonne, main.meuble .poignee-vue { display: none; }
  main.meuble .vue > .panneau-onglet { margin-top: 0; }
}
/* La colonne défile en hauteur, pas de côté : ce qu'elle contient se
   resserre à sa largeur (les grilles en minmax(0, 1fr), les listes qui
   s'étrécissent), et ce qui ne se resserre pas passe à la ligne. */
.colonne { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: auto; }
main.meuble > .colonne select, main.meuble > .colonne input:not([type=checkbox]):not([type=radio]) { max-width: 100%; }
main.meuble > .colonne th, main.meuble > .colonne td { white-space: normal; overflow-wrap: break-word; }
/* Une liste dans un tableau prend la largeur de sa cellule : le tableau peut la resserrer. */
main.meuble > .colonne td select { width: 100%; }
section.carte {
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 10px 12px;
}
section.carte h2 { font-size: 13px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--texte-2); }

.champ { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 6px; align-items: center; margin: 4px 0; }
.champ label { color: var(--texte-2); }
.champ .valeur { font-variant-numeric: tabular-nums; color: var(--texte-2); font-size: 12px; min-width: 50px; text-align: right; }
.erreur { color: var(--alerte); font-size: 12px; grid-column: 1 / -1; }
.aide { color: var(--texte-2); font-size: 12px; }

.variables .ligne { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 60px auto; gap: 4px; margin: 3px 0; align-items: center; }
.variables .origine { font-size: 11px; color: var(--texte-2); grid-column: 1 / -1; margin-top: -2px; }

.volume { border-left: 2px solid var(--bord); padding-left: 8px; margin: 6px 0; }
/* Un réglage à choix (une liste, une case) : même colonne de libellés qu'un champ. */
.reglage { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 4px; align-items: center; margin: 3px 0; }

/* La vue (outils compris), sa poignée, la barre des onglets, le panneau ;
   la hauteur de la vue se règle (disposition.js). */
.vue { display: grid; grid-template-rows: var(--hauteur-toile, minmax(260px, 48%)) 10px auto minmax(0, 1fr); min-height: 0; }
.vue > .panneau-onglet { margin-top: 8px; }
.poignee-colonne, .poignee-vue { position: relative; touch-action: none; outline: none; }
.poignee-colonne { cursor: col-resize; }
.poignee-vue { cursor: row-resize; }
/* Un trait discret au milieu de l'écart, qui s'affirme au survol et pendant qu'on tire. */
.poignee-colonne::after, .poignee-vue::after { content: ""; position: absolute; border-radius: 2px; background: var(--bord); transition: background .15s; }
.poignee-colonne::after { top: 50%; left: 4px; width: 4px; height: 44px; transform: translateY(-50%); }
.poignee-vue::after { left: 50%; top: 3px; height: 4px; width: 44px; transform: translateX(-50%); }
.poignee-colonne:hover::after, .poignee-vue:hover::after, .poignee-colonne:focus-visible::after, .poignee-vue:focus-visible::after,
body.en-glisse-x .poignee-colonne::after, body.en-glisse-y .poignee-vue::after { background: var(--accent); }
.vue > .se-tire { cursor: row-resize; }
body.en-glisse-x, body.en-glisse-x * { cursor: col-resize !important; user-select: none; }
body.en-glisse-y, body.en-glisse-y * { cursor: row-resize !important; user-select: none; }
.toile-3d { position: relative; background: var(--fond-3d); border: 1px solid var(--bord); border-radius: var(--rayon); overflow: hidden; }
/* La toile remplit sa place sans la dicter : sa taille ne nourrit pas celle du cadre. */
.toile-3d canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.toile-3d .outils { position: absolute; top: 8px; right: 8px; z-index: 2; display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 90px); }
.toile-3d .legende { position: absolute; left: 8px; bottom: 6px; font-size: 11px; color: var(--texte-2); }

.onglets { display: flex; gap: 2px; border-bottom: 1px solid var(--bord); }
.onglets button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 6px 12px; }
.onglets button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; background: var(--surface-2); margin-left: 4px; }
.badge.rouge { background: var(--alerte); color: #fff; }

.panneau-onglet { overflow: auto; min-height: 0; background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--bord); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; font-size: 12px; z-index: 1; }
td.nombre, th.nombre { text-align: right; }
tr.choisie td { background: var(--accent-doux); }
tbody tr { cursor: pointer; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
.chants span { display: inline-block; width: 16px; text-align: center; border-radius: 3px; font-size: 11px; margin-right: 2px; background: var(--surface-2); }
.chants span.pose { background: var(--accent); color: #fff; }
.chants span.voulu { outline: 1px dashed var(--texte-2); }

ul.alertes { list-style: none; margin: 0; padding: 8px; }
ul.alertes li { padding: 6px 8px; border-radius: 6px; margin-bottom: 4px; background: var(--avis-doux); }
ul.alertes li.grave { background: var(--alerte-doux); }
ul.alertes .source { font-size: 11px; color: var(--texte-2); margin-right: 6px; text-transform: uppercase; }

.detail { padding: 8px 12px; border-top: 1px solid var(--bord); }

dialog { border: 1px solid var(--bord); border-radius: var(--rayon); background: var(--surface); color: var(--texte); max-width: min(720px, 94vw); }
dialog::backdrop { background: rgb(0 0 0 / 0.35); }
dialog h3 { margin-top: 0; }
dialog .boutons { display: flex; justify-content: flex-end; gap: 6px; margin-top: 12px; }
.diff td.avant { color: var(--alerte); text-decoration: line-through; }
.diff td.apres { color: var(--ok); }

main.page { display: flex; flex-direction: column; gap: 12px; padding: 12px; max-width: 1400px; margin: 0 auto; }
.defile { overflow-x: auto; margin-bottom: 8px; }
.defile table td { padding: 3px 6px; }
.deux { display: grid; grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); gap: 12px; padding: 12px; min-height: calc(100vh - var(--barre, 53px)); }
@media (max-width: 900px) { .deux { grid-template-columns: minmax(0, 1fr); } }
ul.choix { list-style: none; padding: 0; margin: 0 0 8px; }
ul.choix li { padding: 6px 8px; border-radius: 6px; cursor: pointer; }
ul.choix li[aria-current="true"] { background: var(--accent-doux); color: var(--accent); }
ul.choix li .aide { display: block; font-size: 11px; }
.formulaire { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 6px 10px; align-items: center; max-width: 640px; }
.apercu-3d { height: 320px; position: relative; background: var(--fond-3d); border: 1px solid var(--bord); border-radius: var(--rayon); overflow: hidden; }
.apercu-3d canvas { width: 100%; height: 100%; display: block; touch-action: none; }
td input { max-width: 100%; }

/* L'arbre du meuble */
.arbre ul { list-style: none; margin: 0; padding-left: 14px; }
.arbre > ul { padding-left: 0; }
.arbre li > span { display: inline-block; padding: 2px 6px; border-radius: 5px; cursor: pointer; }
.arbre li > span:hover { background: var(--surface-2); }
.arbre li > span[aria-current="true"] { background: var(--accent-doux); color: var(--accent); }
.arbre li.volume > span[aria-current="true"] { background: var(--volume-choisi); color: var(--volume-choisi-texte); }
.arbre .aide { font-size: 11px; }
#proprietes h2 { display: flex; align-items: baseline; gap: 6px; }
.titre-aide { text-transform: none; letter-spacing: 0; }
#proprietes h3 { font-size: 12px; margin: 12px 0 4px; color: var(--texte-2); text-transform: uppercase; letter-spacing: .04em; }

/* Les cotes d'ensemble sur la 3D */
svg.cotes-3d { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
svg.cotes-3d line { stroke: var(--accent); stroke-width: 1.2; }
svg.cotes-3d text { fill: var(--accent); font-size: 12px; font-weight: 600; paint-order: stroke; stroke: var(--fond-3d); stroke-width: 3px; }

/* L'aperçu de la courbe d'un meuble arrondi */
.apercu-courbe { margin: 8px 0; }
svg.plan-courbe { width: 100%; height: auto; max-height: 240px; background: var(--surface-2); border-radius: 6px; }
svg.plan-courbe .cadre { fill: none; stroke: var(--bord); stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
svg.plan-courbe .face-vue { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
svg.plan-courbe .face-int { fill: none; stroke: var(--texte-2); stroke-width: 1; vector-effect: non-scaling-stroke; }
svg.plan-courbe .rayon { stroke: var(--texte-2); stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
svg.plan-courbe .centre, svg.plan-courbe .sommet { fill: var(--texte); }
svg.plan-courbe text { fill: var(--texte); font-family: system-ui, sans-serif; }
svg.plan-courbe .legende { fill: var(--texte-2); }

/* L'outil de dessin de la courbe */
.editeur-dessin { margin: 6px 0; }
svg.dessin-courbe { width: 100%; height: auto; max-height: 320px; background: var(--surface-2); border-radius: 6px; touch-action: none; user-select: none; }
svg.dessin-courbe .cadre { fill: none; stroke: var(--bord); stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
svg.dessin-courbe .axe { stroke: var(--bord); stroke-dasharray: 2 6; vector-effect: non-scaling-stroke; }
svg.dessin-courbe .trace { stroke: var(--texte-2); stroke-width: 1; stroke-dasharray: 4 3; fill: none; vector-effect: non-scaling-stroke; }
svg.dessin-courbe .segment { stroke-width: 10; stroke: transparent; stroke-dasharray: none; cursor: copy; }
svg.dessin-courbe .segment:hover { stroke: color-mix(in srgb, var(--accent) 25%, transparent); }
svg.dessin-courbe .miroir { opacity: 0.45; }
svg.dessin-courbe .courbe { fill: none; stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; pointer-events: none; }
svg.dessin-courbe .poignee { fill: var(--surface); stroke: var(--texte); stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: grab; }
svg.dessin-courbe .point.choisi .poignee { fill: var(--accent); stroke: var(--accent); }
svg.dessin-courbe .halo { fill: none; stroke: var(--accent); stroke-width: 1; stroke-dasharray: 2 2; vector-effect: non-scaling-stroke; pointer-events: none; }
svg.dessin-courbe text { fill: var(--texte); font-family: system-ui, sans-serif; pointer-events: none; }
.reglage-point { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; min-height: 28px; }

/* La page Projet */
main.projet .toile-3d svg.plan-projet { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; }
.plan-projet .sol { fill: var(--surface); stroke: none; }
.plan-projet .mur { fill: var(--plan-mur); stroke: var(--plan-trait); stroke-width: 1; vector-effect: non-scaling-stroke; cursor: pointer; }
.plan-projet .mur.choisi { fill: var(--accent); }
.plan-projet .ouverture { stroke: var(--plan-trait); stroke-width: 1; vector-effect: non-scaling-stroke; cursor: pointer; }
.plan-projet .ouverture.fenetre { fill: var(--plan-fenetre); }
.plan-projet .ouverture.porte { fill: var(--surface); }
.plan-projet .ouverture.choisi { fill: var(--accent-doux); stroke: var(--accent); stroke-width: 2; }
.plan-projet .debattement, .plan-projet .vantail { fill: none; stroke: var(--texte-2); stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.plan-projet .occurrence { fill: var(--plan-meuble); stroke: var(--texte-2); stroke-width: 1.2; vector-effect: non-scaling-stroke; cursor: grab; }
.plan-projet .occurrence.haut { opacity: 0.6; stroke-dasharray: 6 4; }
.plan-projet .occurrence.choisi { fill: var(--plan-meuble-choisi); stroke: var(--accent); stroke-width: 2; }
.plan-projet .avant { stroke: var(--texte); stroke-width: 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.plan-projet .avant.haut { stroke-dasharray: 6 4; }
.plan-projet .element { stroke: var(--texte-2); stroke-width: 1; vector-effect: non-scaling-stroke; cursor: pointer; }
.plan-projet .element.plan_de_travail { fill: var(--plan-element); opacity: 0.4; }
.plan-projet .element.plinthe, .plan-projet .element.fileur { fill: var(--plan-element); }
.plan-projet .element.choisi { fill: var(--plan-meuble-choisi); stroke: var(--accent); stroke-width: 2; }
.plan-projet text { fill: var(--texte); pointer-events: none; }
.plan-projet text.nom { fill: var(--texte); }
.plan-projet text.cote { fill: var(--texte-2); }
.bascule { display: flex; }
.bascule button[aria-pressed="true"], .toile-3d .outils button[aria-pressed="true"] { background: var(--accent-doux); color: var(--accent); border-color: var(--accent); }
.boutons-ligne { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 6px 0; }
.boutons-ligne select { flex: 1; min-width: 0; }
.ajout-main { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.ajout-main > select, .ajout-main .champ-cherche { min-width: 0; }
.points-sol { display: grid; gap: 3px; margin: 4px 0; }
.point-sol { display: grid; grid-template-columns: 20px minmax(0, 1fr) minmax(0, 1fr) auto; gap: 4px; align-items: center; }
.cases { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0; }
label.case { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; }
button.danger { color: var(--alerte); }
button.danger:hover { border-color: var(--alerte); }

/* Le cube d'orientation, en coin sur la vue 3D (repris du suivi). Un élément
   à six faces en perspective, que la vue tourne comme sa caméra ; les faces
   cachées ne se voient pas et ne se touchent pas. */
.cube3d {
  position: absolute; top: 12px; left: 12px; z-index: 1; width: 3.6rem; height: 3.6rem; perspective: 14rem;
  touch-action: none; cursor: grab; user-select: none;
}
.cube3d-corps { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }
.face3d {
  position: absolute; inset: 0; margin: 0; padding: 0; border-radius: 4px;
  font-size: .62rem; font-weight: 600; line-height: 1;
  background: var(--voile); border: 2px solid var(--bord); color: var(--texte);
  backface-visibility: hidden; cursor: pointer;
}
.face3d:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
/* Les arêtes portent les couleurs des axes : devant et derrière, X en
   travers et Z debout ; sur les côtés, Y et Z ; dessus et dessous, X et Y. */
.face3d[data-vue="avant"], .face3d[data-vue="arriere"] { border-color: var(--axe-x) var(--axe-z); }
.face3d[data-vue="droite"], .face3d[data-vue="gauche"] { border-color: var(--axe-y) var(--axe-z); }
.face3d[data-vue="dessus"], .face3d[data-vue="dessous"] { border-color: var(--axe-y) var(--axe-x); }
.face3d[data-vue="avant"]   { transform: translateZ(1.8rem); }
.face3d[data-vue="arriere"] { transform: rotateY(180deg) translateZ(1.8rem); }
.face3d[data-vue="droite"]  { transform: rotateY(90deg) translateZ(1.8rem); }
.face3d[data-vue="gauche"]  { transform: rotateY(-90deg) translateZ(1.8rem); }
.face3d[data-vue="dessus"]  { transform: rotateX(90deg) translateZ(1.8rem); }
.face3d[data-vue="dessous"] { transform: rotateX(-90deg) rotateZ(180deg) translateZ(1.8rem); }
/* L'angle figé : le cube ne tourne plus rien, et porte son cadenas. */
.verrou3d { position: absolute; right: -.35rem; bottom: -.35rem; color: var(--accent); display: none; }
.cube3d.fige .verrou3d { display: block; }
.cube3d.fige, .cube3d.fige .face3d { cursor: default; }
.cube3d.fige .face3d:hover { background: var(--voile); color: var(--texte); }

/* Les mesures, par-dessus la toile : seules leurs poignées se touchent. */
svg.mesure3d { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.mesure3d { --marque-trait: var(--cote); }
.mesure3d line { stroke: var(--marque-trait); stroke-width: 2; }
.mesure3d line.arete { stroke-width: 6; stroke-opacity: .4; stroke-linecap: round; }
.mesure3d line.rappel { stroke-width: 1.5; stroke-dasharray: 4 4; }
.mesure3d line.rappel-etiquette { stroke-width: 1; stroke-dasharray: 2 3; }
.mesure3d line.cote-angle { stroke-width: 1.2; }
.mesure3d path.arc { fill: none; stroke: var(--marque-trait); stroke-width: 2; }
.mesure3d path.longueur { fill: none; stroke: var(--marque-trait); stroke-width: 4; stroke-opacity: .85; stroke-linejoin: round; }
.mesure3d path.longueur.choisie { stroke-width: 5.5; stroke-opacity: 1; }
.mesure3d circle { fill: var(--marque-trait); stroke: #fff; stroke-width: 1.5; }
.mesure3d circle.bout-longueur { stroke-width: 1; }
.mesure3d rect { fill: var(--surface); stroke: var(--marque-trait); }
.mesure3d text { fill: var(--texte); font: 600 13px system-ui, sans-serif; }
.mesure3d text.sous { font: 500 11px system-ui, sans-serif; fill: var(--texte-2); }
.mesure3d .cote3d.axe-x { --marque-trait: var(--axe-x); }
.mesure3d .cote3d.axe-y { --marque-trait: var(--axe-y); }
.mesure3d .cote3d.axe-z { --marque-trait: var(--axe-z); }
.mesure3d.une-choisie .cote3d:not(.choisie) { opacity: .55; }
.mesure3d .cote3d.provisoire line { stroke-dasharray: 6 4; }
.mesure3d .etiquette[data-mesure]:not([data-mesure=""]) { pointer-events: auto; cursor: grab; touch-action: none; }
.mesure3d .cote3d:not(.choisie) .etiquette:hover rect { stroke-width: 2; }
.mesure3d .point { pointer-events: auto; cursor: grab; touch-action: none; }
.mesure3d .point .prise { fill: transparent; stroke: none; }
.mesure3d .croix, .mesure3d .type { pointer-events: auto; cursor: pointer; }
.mesure3d .croix circle, .mesure3d .type circle { fill: var(--surface); stroke: var(--marque-trait); stroke-width: 1.5; }
.mesure3d .croix text { fill: var(--marque-trait); font-size: 15px; }
.mesure3d .croix:hover circle, .mesure3d .type:hover circle, .mesure3d .type.actif circle { fill: var(--marque-trait); }
.mesure3d .croix:hover text, .mesure3d .type:hover text, .mesure3d .type.actif text { fill: #fff; }
.mesure3d .type text { font: 600 11px system-ui, sans-serif; }
.mesure3d .type[data-axe="x"] { --marque-trait: var(--axe-x); }
.mesure3d .type[data-axe="y"] { --marque-trait: var(--axe-y); }
.mesure3d .type[data-axe="z"] { --marque-trait: var(--axe-z); }
.mesure3d .aimant { fill: none; stroke: var(--marque-trait); stroke-width: 2; }
.mesure3d .aimant.surface { fill: var(--marque-trait); stroke: #fff; stroke-width: 1; }
.mesure3d .aimant.centre line { stroke-width: 1.5; }
.mesure3d .aimant.centre circle { fill: none; stroke: var(--marque-trait); }
.consigne-mesure {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 1;
  background: var(--voile); border: 1px solid var(--bord); border-radius: 6px; padding: 3px 10px;
  font-size: 12px; color: var(--texte); pointer-events: none; max-width: 90%; text-align: center;
}
/* Les outils de la vue 3D, par groupes : mesurer, regarder, ouvrir. */
.groupe-mesure, .groupe-outils { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.groupe-mesure, .groupe-vue { margin-right: 6px; padding-right: 6px; border-right: 1px solid var(--bord); }
.groupe-mesure[hidden] { display: none; }

/* Les règles d'une sous-méthode citée, en lecture. */
fieldset.lecture { border: none; margin: 4px 0 0; padding: 0; opacity: .8; min-width: 0; }
section.carte.reference { border-left: 3px solid var(--accent); }
h3.section-pour { font-size: 13px; margin: 10px 0 0; text-transform: uppercase; letter-spacing: .05em; color: var(--texte-2); }
h3.section-pour .aide { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* La structure d'un panneau (structure_ui.js) */
.bloc-structure { border: 1px solid var(--bord); border-radius: 6px; padding: 6px 8px; margin: 6px 0; display: grid; gap: 4px; }
.ligne-structure { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
label.champ-structure { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; color: var(--texte-2); }
.apercu-structure-cadre { margin-top: 6px; }
svg.apercu-structure { width: 100%; max-height: 220px; display: block; background: var(--surface-2); border-radius: 6px; }
svg.apercu-structure .panneau { fill: none; stroke: var(--texte-2); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 4 3; }
svg.apercu-structure .partie { fill: rgb(47 111 209 / 0.12); stroke: var(--accent); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
svg.apercu-structure .usinage { fill: rgb(217 118 10 / 0.25); stroke: var(--cote); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
svg.apercu-structure .usinage.traversant { fill: var(--fond); }
.structure-regle { margin: 4px 0 4px 16px; }
svg.apercu-structure .partie.panneau-flottant { fill: rgb(217 118 10 / 0.12); stroke: var(--cote); stroke-dasharray: 3 2; }
/* Les marques de la vue 3D : les quincailleries entre meubles, les trous d'un usinage du projet. */
svg.cotes-3d .marque { pointer-events: auto; }
svg.cotes-3d .marque circle { fill: var(--marque-fond); stroke: var(--marque); stroke-width: 2; }
svg.cotes-3d .marque line { stroke: var(--marque); stroke-width: 1.5; }
svg.cotes-3d .marque.usinage circle { fill: rgb(217 118 10 / 0.35); stroke: var(--cote); }
svg.cotes-3d .marque.usinage line { stroke: var(--cote); }
ul.liste-poses { margin: 4px 0; padding-left: 18px; font-size: 12px; }
/* Sur la page Meuble : le modèle du projet, et le retour. */
section.bandeau-projet { border-left: 3px solid var(--accent); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
section.bandeau-projet p { margin: 0; flex: 1 1 200px; font-size: 13px; }
/* Les liens : la couleur d'accent, lisible en clair comme en sombre. */
a { color: var(--accent); }
a.bouton { display: inline-block; text-decoration: none; color: var(--texte); background: var(--surface-2); border: 1px solid var(--bord); border-radius: 6px; padding: 2px 8px; font-size: 12px; }
a.bouton:hover { border-color: var(--accent); }
.bascule.gammes { gap: 4px; flex-wrap: wrap; }
dialog.inserer .bascule { gap: 4px; margin-bottom: 10px; }
/* La vue éclatée : le curseur, parmi les outils de la vue ; les numéros de
   débit sur les pièces écartées ; les mesures, prises assemblé, se cachent. */
.toile-3d .outils label.eclate { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--texte-2); background: var(--surface); border: 1px solid var(--bord); border-radius: 6px; padding: 0 6px; }
.toile-3d .outils label.eclate input { width: 90px; padding: 0; }
.toile-3d .outils label.eclate[hidden] { display: none; }
svg.cotes-3d .repere circle { fill: var(--surface); stroke: var(--accent); stroke-width: 1.2; }
svg.cotes-3d .repere text { font-size: 11px; stroke-width: 0; }
svg.cotes-3d .repere.choisi circle { fill: var(--accent); }
svg.cotes-3d .repere.choisi text { fill: #fff; }
svg.mesure3d.sous-eclate { display: none; }
/* Un décaissement : ses cotes, de / à, par axe. */
.decaissement { border-left: 2px solid var(--bord); padding-left: 8px; margin: 8px 0; }
.grille-decaissement { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 4px 6px; align-items: center; }
/* Un point du plan libre : son numéro, x, y, le rôle du bord qui suit, sa porte. */
.point-plan { display: grid; grid-template-columns: 1.4rem minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.1fr) auto auto auto; gap: 4px; align-items: center; margin: 3px 0; }

/* ——— Les dialogues ——— */
dialog.dialogue { border: 1px solid var(--bord); border-radius: var(--rayon); background: var(--surface); color: var(--texte); padding: 14px 16px; min-width: 320px; max-width: 480px; }
dialog.dialogue::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog.dialogue h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
dialog.dialogue .boutons-ligne { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
dialog.dialogue .erreur { margin-top: 4px; }

/* ——— Les classes utilitaires, à la place des styles en ligne ——— */
.a-droite { margin-left: auto; }
.large { width: 100%; }
.court { width: 80px; }
.tres-court { width: 70px; }
.serre { margin: 0; }
.espace-haut { margin-top: 8px; }
.espace-droite { margin-right: 4px; }
.sur-une-ligne { white-space: nowrap; }
.encadre { padding: 8px; }

/* ——— L'aperçu d'une répartition (page Quincailleries) ——— */
.apercu-repartition { width: 100%; max-width: 640px; display: block; margin: 6px 0; }
.apercu-repartition .zone { fill: var(--volume-choisi, #cfe8cf); fill-opacity: 0.5; stroke: var(--texte-2); }
.apercu-repartition .depasse { fill: none; stroke: var(--texte-2); stroke-dasharray: 3 3; }
.apercu-repartition .pose { fill: var(--accent); }
.apercu-repartition .legende, .apercu-repartition .cote { fill: var(--texte-2); font-size: 11px; text-anchor: middle; font-variant-numeric: tabular-nums; }

/* La suite d'une règle de méthode, sur sa propre ligne (la répartition d'une quincaillerie). */
.ligne-suite { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0 0 20px; }

/* ——— L'annulation dans la barre ——— */
.annulation { display: inline-flex; gap: 2px; margin-right: 6px; }

/* ——— Les listes filtrées ——— */
input.filtre { margin: 0 0 6px; }

/* ——— La page Quincailleries : le tableau des usinages et la fiche de l'usinage choisi ——— */
table.usinages tbody tr { cursor: pointer; }
table.usinages tbody tr[aria-current="true"] { background: var(--surface-2); }
table.usinages tbody tr[aria-current="true"] td:first-child { color: var(--accent); font-weight: 600; }
.fiche-usinage { margin-top: 8px; padding: 8px 10px; border: 1px solid var(--bord); border-radius: var(--rayon); }
.fiche-usinage h3 { margin: 0 0 6px; font-size: 13px; }
svg.cotes-3d .marque.usinage circle { stroke: var(--accent); }
svg.cotes-3d .marque.usinage line { stroke: var(--accent); }

/* ——— La page Méthodes : le tableau des liaisons ——— */
.tableau-liaisons { margin-top: 10px; }
.tableau-liaisons summary { cursor: pointer; font-weight: 600; }
.tableau-liaisons table { margin-top: 6px; }

/* ——— La palette des chants, dans la toile 3D (mode Chants) ——— */
.toile-3d .palette-chants { position: absolute; left: 8px; right: 8px; bottom: 24px; z-index: 2; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; background: var(--surface); border: 1px solid var(--bord); border-radius: 6px; padding: 4px 6px; font-size: 12px; }
.toile-3d .palette-chants .chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 7px; border: 1px solid var(--bord); border-radius: 12px; background: var(--surface-2); color: var(--texte); cursor: pointer; }
.toile-3d .palette-chants .chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-doux); color: var(--accent); }
.toile-3d .palette-chants .pastille { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.25); display: inline-block; }
.toile-3d .palette-chants .pastille.nu { background: #ed4545; }
.toile-3d .palette-chants .pastille.nu-voulu { background: #8c919e; }
.toile-3d .palette-chants .pastille.methode { background: transparent; border-style: dashed; }

/* Sur les fiches : un usinage venu du projet (entre meubles, passe-câble). */
.fiche td.du-projet { color: var(--accent); font-weight: 600; }

/* Un repère de la 3D qui porte une cote (l'écart entre deux tasseaux). */
svg.cotes-3d .marque .texte-marque { fill: var(--marque); stroke: var(--fond-3d); stroke-width: 3px; paint-order: stroke; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* L'implantation des tasseaux sur la fiche de la peau. */
svg.plan .repere-tasseau { fill: var(--accent); fill-opacity: 0.12; stroke: var(--accent); stroke-width: 0.6; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
svg.plan .repere-tasseau.retouche { fill-opacity: 0.25; }
td.nombre.propre { font-weight: 600; }
svg.plan .axe-tasseau { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 10 4 2 4; vector-effect: non-scaling-stroke; }

/* ——— L'arborescence d'une bibliothèque (arborescence_ui.js) ——— */
.arborescence { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.arbre-outils { display: flex; gap: 6px; align-items: center; }
.arbre-outils .arbre-filtre { flex: 1; min-width: 0; }
ul.arbre, ul.arbre ul { list-style: none; margin: 0; padding: 0; }
ul.arbre ul { padding-left: 14px; border-left: 1px solid var(--bord); margin-left: 7px; }
ul.arbre li.element { padding: 5px 8px; border-radius: 6px; cursor: pointer; }
ul.arbre li.element:hover, ul.arbre li.element:focus-visible { background: var(--surface-2); outline: none; }
ul.arbre li.element[aria-current="true"] { background: var(--accent-doux); color: var(--accent); }
ul.arbre li.element .aide { display: block; font-size: 11px; }
ul.arbre li.vide { padding: 5px 8px; }
.ligne-dossier { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; cursor: pointer; user-select: none; }
.ligne-dossier:hover { background: var(--surface-2); }
.ligne-dossier.actif { box-shadow: inset 2px 0 0 var(--accent); }
.ligne-dossier.cible { background: var(--accent-doux); outline: 1px dashed var(--accent); }
.ligne-dossier .fleche { width: 14px; color: var(--texte-2); font-size: 11px; cursor: pointer; text-align: center; }
.ligne-dossier .nom { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-dossier .compte { font-size: 11px; color: var(--texte-2); }
.ligne-dossier.racine .nom { font-weight: 400; color: var(--texte-2); }
.actions-dossier { display: none; gap: 2px; }
.ligne-dossier:hover .actions-dossier, .ligne-dossier.actif .actions-dossier, .ligne-dossier:focus-within .actions-dossier { display: inline-flex; }
button.icone { border: none; background: none; padding: 0 4px; font-size: 13px; color: var(--texte-2); cursor: pointer; line-height: 1.4; }
button.icone:hover { color: var(--accent); }
/* Une liste de choix où l'on cherche. */
/* La liste prend la place, la recherche garde la sienne ; trop étroit, la
   recherche passe dessous plutôt que de tout écraser. */
.avec-recherche { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; max-width: 100%; }
.avec-recherche select { flex: 1 1 6em; min-width: 0; }
.avec-recherche .champ-cherche { flex: 0 1 9.5em; min-width: 6em; }
.champ-cherche { width: 9.5em; min-width: 0; cursor: pointer; }
.champ-cherche.large { width: 100%; max-width: 22em; }
.pop-choix { position: fixed; z-index: 50; overflow: auto; background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); }
/* Une bibliothèque en tableau (la page Matières) : l'arborescence à gauche, le tableau à droite. */
.bibliotheque-rangee { display: grid; grid-template-columns: minmax(200px, 260px) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 760px) { .bibliotheque-rangee { grid-template-columns: minmax(0, 1fr); } }
td.poignee { cursor: grab; color: var(--texte-2); user-select: none; }
tr.choisie > td { background: var(--accent-doux); }
/* Les liaisons d'une pièce, réglables sur place. */
.liaison-de-piece { border-top: 1px solid var(--bord); padding: 4px 0; }
.ligne-liaison { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; }
.ligne-liaison button.icone { margin-left: auto; }
.detail-liaison { padding: 4px 0 4px 12px; }
/* L'onglet Surcharges : filtre, tri, sélection. */
.barre-surcharges { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-bottom: 6px; }
.barre-surcharges input[type=search] { flex: 1; min-width: 200px; }
th.triable { cursor: pointer; user-select: none; }
th.triable:hover { color: var(--accent); }
/* Les tableaux filtrables (tableau_ui.js). */
.barre-tableau { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-bottom: 6px; }
.barre-tableau input[type=search] { flex: 1; min-width: 200px; }
.actions-tableau { display: inline-flex; flex-wrap: wrap; gap: 4px; }
th.case-tableau, td.case-tableau { width: 22px; }
tr.cochee > td { background: var(--surface-2); }
/* Le menu du clic droit (ui.js, menuContextuel). */
.menu-contextuel { position: fixed; z-index: 60; min-width: 220px; max-width: 320px; max-height: 80vh; overflow: auto; background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 4px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.2); display: flex; flex-direction: column; }
.menu-contextuel button { text-align: left; border: none; background: none; padding: 6px 10px; border-radius: 6px; color: var(--texte); font: inherit; cursor: pointer; }
.menu-contextuel button:hover, .menu-contextuel button:focus-visible { background: var(--accent-doux); color: var(--accent); outline: none; }
.menu-contextuel button.danger { color: var(--alerte); }
.menu-contextuel button:disabled { opacity: .45; cursor: default; background: none; color: var(--texte-2); }
.menu-contextuel hr { border: none; border-top: 1px solid var(--bord); margin: 4px 0; }
.menu-contextuel .menu-titre { font-weight: 600; padding: 4px 10px 6px; border-bottom: 1px solid var(--bord); margin-bottom: 4px; }
.menu-contextuel .menu-groupe { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--texte-2); padding: 6px 10px 2px; }

/* La porte : se connecter avant tout (web/porte.js). */
main.page-porte { display: flex; justify-content: center; padding: 48px 16px; }
.carte.porte { width: min(420px, 100%); }
.carte.porte .boutons { display: flex; justify-content: flex-end; gap: 6px; }
a.bouton.principal { background: var(--accent); color: #fff; border-color: var(--accent); }
.carte.porte .formulaire input { width: 100%; }
/* L'accueil : les projets. */
main.projets { max-width: 1100px; }
main.projets tbody tr { cursor: pointer; }
/* Le mode Jour ou Nuit, au bout de la barre (theme.js). */
.bascule.theme { gap: 2px; }
