/* Feuille de style de l'application (extraite d'index.html — seul le loader
   d'amorçage reste inline, il doit s'afficher avant tout le reste).
   Système de design léger : les couleurs, espacements, rayons et ombres passent
   par les variables (tokens) définies sur `.app` ci-dessous. */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "Segoe UI", system-ui, sans-serif; }

/* Thème sombre (défaut) */
.app {
  --bg: #1e1e22; --panel: #26262c; --surface: #1b1b20;
  --text: #e6e6e9; --muted: #9a9aa4; --accent: #c9a36a; --accent-ink: #20160a;
  --border: #34343c; --border2: #3a3a44; --danger: #5a2a2a; --danger-ink: #f0c9c9;
  /* Poignées / aperçus du viewport 3D (lus par viewport.js via getComputedStyle) */
  --h-accent: #e0a83c; --h-hover: #ffd166; --h-ok: #34c759;
  --h-axis-x: #e5484d; --h-axis-y: #46a758; --h-axis-z: #3e63dd;
  --h-preview: #33c0ff; --h-edge: #2a2a2e;
  /* Échelles (tokens) : espacement, rayons, ombres */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --r-1: 6px; --r-2: 8px; --r-3: 12px;
  --shadow-1: 0 2px 10px rgba(0,0,0,.3);
  --shadow-2: 0 14px 40px rgba(0,0,0,.4);
  display: flex; flex-direction: column; height: 100vh;
  background: var(--bg); color: var(--text);
}
/* Thème clair */
.app.light {
  --bg: #ecedee; --panel: #f7f7f5; --surface: #ffffff;
  --text: #1d1d22; --muted: #6b6b73; --accent: #9a7434; --accent-ink: #ffffff;
  --border: #d8d8d3; --border2: #cacac4; --danger: #b34a4a; --danger-ink: #fff;
  --h-accent: #cf9433; --h-hover: #e8a812; --h-ok: #2da44e;
  --h-axis-x: #d13438; --h-axis-y: #2e8b46; --h-axis-z: #3455d1;
  --h-preview: #0d8ecf; --h-edge: #46433d;
  --shadow-1: 0 2px 10px rgba(0,0,0,.14);
  --shadow-2: 0 14px 40px rgba(0,0,0,.18);
}

/* Topbar */
.topbar {
  height: 50px; display: flex; align-items: center; gap: var(--sp-1);
  padding: 0 var(--sp-3); background: var(--panel); border-bottom: 1px solid var(--border);
}
.topbar .brand { font-size: 20px; font-weight: 800; letter-spacing: 1px;
  color: var(--accent); margin-right: 14px; }
.topbar .spacer { flex: 1; }
.menu-wrap { position: relative; }
.menubtn { background: transparent; color: var(--text); font-weight: 600;
  font-size: 14px; padding: 8px 12px; border-radius: var(--r-1); }
.menubtn:hover, .menubtn.open { background: var(--surface); }
.dropdown { position: absolute; top: 100%; left: 0; margin-top: var(--sp-1); min-width: 240px;
  background: var(--panel); border: 1px solid var(--border2); border-radius: var(--r-2);
  box-shadow: var(--shadow-2); padding: 6px; z-index: 60; }
.dropdown button { display: block; width: 100%; text-align: left; background: transparent;
  color: var(--text); font-weight: 500; padding: 9px 10px; border-radius: var(--r-1); }
.dropdown button:hover { background: var(--surface); }
.dropdown .sep { height: 1px; background: var(--border); margin: 5px 4px; }
.dropdown .filelabel { display: block; font-size: 13px; color: var(--text);
  padding: 9px 10px; cursor: pointer; }
.dropdown .filelabel input { display: block; margin-top: var(--sp-1); font-size: 11px; color: var(--muted); }
/* Menu Fichier : sous-menu « Projets en ligne », saisie du nom, statut */
.dropdown .submenu-toggle { display: flex; align-items: center; justify-content: space-between; }
.dropdown .submenu-toggle .chev { color: var(--muted); transition: transform .15s; }
.dropdown .submenu-toggle.open .chev { transform: rotate(90deg); }
.menu-input { display: flex; gap: 6px; padding: 4px 10px 8px; }
.menu-input input { flex: 1 1 auto; min-width: 0; padding: 6px 8px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r-1); }
.menu-input button.ok { flex: 0 0 auto; width: auto; padding: 6px 12px; text-align: center; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); border-radius: var(--r-1); }
.menu-sub { border-top: 1px solid var(--border); margin: 4px 4px 0; padding-top: var(--sp-1); max-height: 260px; overflow-y: auto; }
.menu-subhead { font-size: 11px; color: var(--muted); padding: 2px 6px 6px; margin: 0; }
.menu-empty { font-size: 12px; color: var(--muted); padding: 4px 6px 8px; margin: 0; }
.menu-proj { display: flex; align-items: center; gap: var(--sp-1); }
.menu-proj button.open { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.menu-proj button.open small { color: var(--muted); font-weight: 400; }
.menu-proj button.del { flex: 0 0 auto; width: auto; padding: 7px 9px; color: var(--danger); }
.menu-status { font-size: 12px; color: var(--accent); padding: 6px 10px 2px; margin: 4px 0 0; }
.iconbtn { background: var(--surface); color: var(--text); border: 1px solid var(--border2);
  width: 36px; height: 36px; border-radius: var(--r-2); font-size: 16px; padding: 0; margin-left: 6px;
  display: inline-flex; align-items: center; justify-content: center; }
.iconbtn:hover { border-color: var(--accent); }
.iconbtn.active { border-color: var(--accent); color: var(--accent); }
.iconbtn .icon { width: 18px; height: 18px; }
/* Icône profil **grise** tant que la personne n'est pas connectée */
.iconbtn.off { color: var(--muted); border-color: var(--border); }
/* Voile transparent : un clic en dehors referme le panneau déroulant */
.menu-backdrop { position: fixed; inset: 0; z-index: 55; background: transparent; }
/* Panneau de compte ancré sous l'icône profil (connexion / création) */
.account-panel { position: absolute; top: 100%; right: 0; margin-top: 6px; min-width: 270px;
  background: var(--panel); border: 1px solid var(--border2); border-radius: var(--r-2);
  box-shadow: var(--shadow-2); padding: 14px; z-index: 60; }
.account-panel .field { display: block; margin-bottom: 9px; }
.account-panel .field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.account-panel .field input { width: 100%; box-sizing: border-box; padding: 7px 9px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r-1); }
.account-panel .err { color: var(--danger); font-size: 12px; margin: 2px 0 8px; }
.account-panel .acct-head { margin-bottom: 11px; }
.account-panel .acct-head strong { display: block; color: var(--accent); }
.account-panel .acct-head small { color: var(--muted); font-size: 12px; word-break: break-all; }
.account-panel .primary { width: 100%; padding: 9px; margin-top: var(--sp-1); text-align: center; font-weight: 600;
  cursor: pointer; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: var(--r-1); }
.account-panel .primary:disabled { opacity: .6; cursor: progress; }
/* Bouton plein écran : visible partout (entrer/sortir du plein écran). */
.fsbtn { display: inline-flex; align-items: center; justify-content: center; }
/* Barre flottante (déplacer / éditer) ancrée au coin haut-droit du meuble.
   left/top sont posés par le viewport (JS) ; le transform colle la barre
   juste au-dessus du coin sans masquer le meuble. */
.obj-toolbar { position: absolute; left: 0; top: 0; transform: translate(-100%, -100%);
  display: flex; gap: var(--sp-2); z-index: 6; padding-bottom: var(--sp-1); }
.obj-toolbar .iconbtn { width: 40px; height: 40px; font-size: 18px; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.obj-toolbar .iconbtn .icon { width: 20px; height: 20px; }
/* Menu contextuel (clic droit) : posé au curseur (left/top en px par le viewport). */
.ctx-menu { position: fixed; z-index: 20; display: flex; flex-direction: column;
  min-width: 150px; padding: var(--sp-1); border-radius: var(--r-2); background: var(--panel);
  box-shadow: 0 6px 22px rgba(0,0,0,.4); border: 1px solid var(--border); }
.ctx-menu button { display: block; width: 100%; text-align: left; padding: 7px 12px;
  background: transparent; color: var(--text); border: 0; border-radius: var(--r-1);
  font-size: 13px; cursor: pointer; }
.ctx-menu button:hover { background: rgba(127,127,127,.22); }
.ctx-menu button .icon { width: 13px; height: 13px; }
/* Rectangle de sélection (A6) : crossing (pointillé, droite→gauche) vs window (plein).
   Couleurs tirées de la palette thémée du viewport. */
.box-select { position: absolute; display: none; z-index: 7; pointer-events: none; left: 0; top: 0; }
.box-select.window { border: 1.5px solid var(--h-ok);
  background: color-mix(in srgb, var(--h-ok) 12%, transparent); }
.box-select.crossing { border: 1.5px dashed var(--h-preview);
  background: color-mix(in srgb, var(--h-preview) 12%, transparent); }
/* Badge multi-sélection : compteur + actions par lot (haut-centre du viewport). */
.multi-badge { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 8;
  display: flex; align-items: center; gap: var(--sp-2); padding: 4px 6px 4px 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-1);
  color: var(--text); font-size: 13px; }
.multi-badge button { border: 0; border-radius: 999px; padding: 4px 10px; cursor: pointer;
  background: rgba(127,127,127,.18); color: var(--text); font-size: 12px; }
.multi-badge button:hover { background: rgba(127,127,127,.3); }
/* Étiquette de cote du mètre : collée au milieu de la ligne mesurée (left/top
   posés par le viewport JS). Non interactive ; suit la couleur d'aperçu du thème. */
.measure-label { position: absolute; left: 0; top: 0; transform: translate(-50%, -140%);
  display: none; z-index: 6; pointer-events: none; white-space: nowrap;
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: var(--r-2);
  color: #fff; background: var(--h-preview); box-shadow: var(--shadow-1); }
/* Value-box du dessin (A1) : boîte de cote en bas à droite (style SketchUp). */
.draw-vbi { position: absolute; right: 16px; bottom: 16px; z-index: 6; pointer-events: none;
  display: flex; align-items: baseline; gap: var(--sp-2); white-space: nowrap;
  font-size: 14px; padding: 6px 12px; border-radius: var(--r-2);
  color: var(--text); background: var(--panel); border: 1px solid var(--border2);
  box-shadow: var(--shadow-1); }
.draw-vbi .lbl { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.draw-vbi .val { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 4ch; }
.draw-vbi .unit { font-size: 11px; color: var(--muted); }
/* Aide navigation : bouton « ? » en haut à droite du viewport + panneau des
   commandes de déplacement (caméra souris/tactile, meuble). */
.nav-help-btn { position: absolute; top: 12px; right: 12px; z-index: 8; margin-left: 0;
  border-radius: 50%; background: var(--panel); box-shadow: var(--shadow-1); font-weight: 700; }
.nav-help { position: absolute; top: 56px; right: 12px; z-index: 8; width: 320px; max-width: calc(100% - 24px);
  max-height: calc(100% - 70px); overflow-y: auto; padding: var(--sp-2) var(--sp-3) var(--sp-3);
  border-radius: var(--r-2); background: var(--panel); border: 1px solid var(--border);
  box-shadow: var(--shadow-1); color: var(--text); font-size: 13px; }
.nav-help h3 { margin: 2px 0 4px; font-size: 13px; }
.nav-help .nh-sec { margin: 8px 0 2px; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .03em; }
.nav-help .nh-row { display: flex; justify-content: space-between; gap: var(--sp-2); padding: 2px 0; }
.nav-help .nh-key { color: var(--accent); text-align: right; }
/* Contrôles de rotation : boutons ronds disposés en arc, sous le bouton rotation. */
.rot-arc { position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: 132px; height: 76px; pointer-events: none; }
.rot-deg { position: absolute; left: 50%; transform: translateX(-50%); top: 58px;
  font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--border2); color: var(--text);
  box-shadow: var(--shadow-1); white-space: nowrap; cursor: pointer; }
.rot-deg:hover { border-color: var(--accent); }
/* Saisie directe de l'angle (clic sur la pastille — retour pilote) */
.rot-input { position: absolute; left: 50%; transform: translateX(-50%); top: 56px;
  width: 64px; font-size: 12px; font-weight: 600; text-align: center; padding: 2px 4px;
  border-radius: 10px; background: var(--surface); color: var(--text);
  border: 1px solid var(--accent); box-shadow: var(--shadow-1); }
.rotbtn { position: absolute; width: 36px; height: 36px; border-radius: 50%;
  background: var(--panel); color: var(--text); border: 1px solid var(--border2);
  box-shadow: 0 3px 12px rgba(0,0,0,.35); font-size: 16px; padding: 0; cursor: pointer;
  pointer-events: auto; }
.rotbtn:hover { border-color: var(--accent); color: var(--accent); }
.rotbtn.l { left: 0; top: 4px; }                                   /* ← (haut-gauche de l'arc) */
.rotbtn.r { right: 0; top: 4px; }                                  /* → (haut-droit) */
.rotbtn.m { left: 50%; transform: translateX(-50%); top: 20px; }   /* ▦ (bas-centre) */
.rotbtn.rotgrab { cursor: ew-resize; touch-action: none; }

/* Navigation pleine largeur (sous la topbar, hors menu latéral). */
.topnav { display: flex; gap: 5px; flex-wrap: wrap; padding: var(--sp-2) 14px;
  background: var(--panel); border-bottom: 1px solid var(--border2); }
.topnav button { padding: 7px 14px; font-size: 13px; font-weight: 600; white-space: nowrap;
  background: var(--surface); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r-2); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; }
.topnav button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
/* Séparateur sobre entre onglets de domaine et actions rapides */
.topnav .sep { align-self: center; width: 1px; height: 22px; margin: 0 7px;
  background: var(--border); flex: 0 0 auto; }
/* Boutons d'action rapide : icône seule, carrés */
.topnav button.quick { padding: 0; width: 38px; height: 34px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; }
.topnav button.quick .icon { width: 19px; height: 19px; }
/* Icônes d'outils en SVG ligne (héritent la couleur du texte du bouton) */
.icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -2px; flex: 0 0 auto; }
.workspace { flex: 1; display: flex; min-height: 0; }
.panel { width: 290px; min-width: 290px; overflow-y: auto; padding: var(--sp-4) 18px;
  background: var(--panel); border-right: 1px solid var(--border); }
.subtitle { margin: 0 0 16px; font-size: 12px; color: var(--muted); }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 4px 0 10px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 16px 0 8px; }
.field { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-2); }
.field label { font-size: 13px; color: var(--text); }
.field input[type="number"], .field input.calc, .field select {
  width: 150px; padding: 6px 8px; text-align: right;
  background: var(--surface); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r-1);
}
.field input[type="color"] {
  width: 150px; height: 34px; padding: 2px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border2); border-radius: var(--r-1);
}
ul.cabs { list-style: none; padding: 0; margin: 0 0 8px; }
ul.cabs li { padding: 7px 10px; font-size: 13px; cursor: pointer; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-1); margin-bottom: 4px; }
ul.cabs li.active { border-color: var(--accent); color: var(--accent); }
.seg { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.seg button { flex: 1 1 auto; padding: 7px 4px; font-size: 12px; font-weight: 600;
  white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border2); }
.seg button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.prefrow { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.prefrow .star { flex: 0 0 auto; background: var(--surface); color: var(--muted);
  border: 1px solid var(--border2); border-radius: var(--r-1); padding: 5px 9px; cursor: pointer; font-size: 15px; }
.prefrow .star.on { color: var(--accent); border-color: var(--accent); }
.prefrow .pname { flex: 1 1 80px; min-width: 80px; padding: 6px 8px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r-1); }
.prefrow select { flex: 0 0 auto; }
.prefentry { padding: 6px 0 8px; border-bottom: 1px solid var(--border); }
.prefcat { display: flex; gap: var(--sp-2); align-items: center; margin: 2px 0 0 40px; flex-wrap: wrap; }
.prefcat .catstat { flex: 1 1 180px; color: var(--muted); font-size: 12px; }
.prefcat button { padding: 4px 9px; font-size: 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border2); }
.prefcat button.catclear { color: var(--muted); }
.scrow { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.scrow .scname { flex: 1 1 auto; }
.scrow .sckey { flex: 0 0 170px; text-align: center; padding: 5px 8px; border: 1px solid var(--border2);
  border-radius: var(--r-1); background: var(--surface); color: var(--accent); font-family: monospace; font-size: 13px; }
.scrow button { padding: 5px 10px; font-size: 13px; background: var(--surface); color: var(--text); border: 1px solid var(--border2); }
.scrow button.catclear { color: var(--muted); }
.scrow input.pfx { flex: 0 0 90px; padding: 5px 8px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border2); border-radius: var(--r-1); }
.scrow button.vis { flex: 0 0 auto; font-size: 15px; padding: 3px 8px; }
.actions { display: flex; flex-direction: column; gap: var(--sp-2); margin: 16px 0; }
button { padding: 9px 12px; border: 0; border-radius: var(--r-1); cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 13px; }
button:hover { filter: brightness(1.08); }
table.cutlist { width: 100%; border-collapse: collapse; font-size: 12px; }
table.cutlist th, table.cutlist td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--border); }
table.cutlist th:first-child, table.cutlist td:first-child { text-align: left; }
ul.ops { list-style: none; padding: 0; margin: 8px 0 0; }
ul.ops li { display: flex; justify-content: space-between; align-items: center; font-size: 12px;
  padding: 4px 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; margin-bottom: 4px; }
ul.ops button.del { background: var(--danger); color: var(--danger-ink); padding: 2px 8px; font-size: 11px; }
.totals { font-size: 12px; color: var(--accent); margin-top: 10px; font-weight: 600; }
.note { font-size: 11px; color: var(--muted); margin-top: 14px; line-height: 1.4; }
.viewport-wrap { flex: 1; position: relative; min-width: 0; }
#viewport { width: 100%; height: 100%; display: block; cursor: pointer; }

/* Onglets de la popup objet */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border2); margin: 6px 0 12px; flex-wrap: wrap; }
.tab { background: transparent; color: var(--muted); padding: 8px 12px; border: 0;
  border-bottom: 2px solid transparent; border-radius: 0; font-weight: 600; font-size: 13px; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
/* Hauteur relative à l'écran → la vue 3D tient dans la popup sans défilement,
   quelle que soit la taille (capée pour ne pas être démesurée sur grand écran). */
#mini-viewport { width: 100%; height: min(340px, 46vh); display: block; background: var(--surface);
  border: 1px solid var(--border2); border-radius: var(--r-2); }
.gallery { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.gallery > div { display: flex; flex-direction: column; align-items: center; }
.gallery small { color: var(--muted); font-size: 10px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-start; justify-content: center; z-index: 50; }
.modal { width: min(460px, 94vw); max-width: 94vw; max-height: 92vh; overflow-y: auto; margin-top: 3vh; padding: 18px 22px;
  background: var(--panel); border: 1px solid var(--border2); border-radius: var(--r-3); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal.matwide { width: min(600px, 96vw); }
.modal.bandwide { width: min(720px, 96vw); }
.bandrow { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.bandrow .field { flex: 1; min-width: 180px; }
.bandrow select { padding: 6px 8px; background: var(--surface); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r-1); width: 100%; }
.modal.wide { width: min(720px, 94vw); }
.modal.editor { width: min(960px, 96vw); }
/* Popup objet : Réglages fixes à gauche, onglets (3D/2D/parcours/simu) à droite. */
.editor-cols { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.edit-left { flex: 0 0 300px; max-width: 320px; max-height: 66vh; overflow-y: auto; padding-right: 4px; }
.edit-left h3:first-child { margin-top: 4px; }
.edit-right { flex: 1 1 360px; min-width: 320px; max-height: 66vh; overflow-y: auto; }
/* Accordéon des réglages : une seule section dépliée à la fois. */
.acc { border: 1px solid var(--border); border-radius: var(--r-2); margin-bottom: 8px; overflow: hidden; }
.acc-head { display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: var(--surface); color: var(--text); border: 0; border-radius: 0;
  padding: 10px 12px; font-weight: 600; font-size: 13px; cursor: pointer; }
.acc-head:hover { filter: brightness(1.06); }
.acc-head.open { color: var(--accent); }
.acc-head .chev { color: var(--muted); font-size: 11px; }
.acc-body { padding: 10px 12px 2px; border-top: 1px solid var(--border); }
.acc-body h3:first-child { margin-top: 2px; }
/* Sous-groupes de la section Construction (Structure / Aménagement / Quincaillerie) */
.acc-body .subh { font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); margin: 12px 0 4px;
  border-bottom: 1px solid var(--border); padding-bottom: 3px; }
.left-actions { margin-top: 14px; display: flex; flex-direction: column; gap: var(--sp-2); }
.left-actions button { width: 100%; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; color: var(--accent); text-transform: none; letter-spacing: 0; font-size: 18px; }
.modal .field input[type="text"]:not(.calc),
.modal .field input[type="email"], .modal .field input[type="password"] { width: 220px; padding: 6px 8px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r-1); }
button.close { background: var(--surface); color: var(--text); border: 1px solid var(--border2); padding: 4px 10px; }
/* Bascule connexion ↔ création de compte */
.authtabs { display: flex; gap: 0; margin: 2px 0 14px; border: 1px solid var(--border2); border-radius: var(--r-2); overflow: hidden; }
.authtabs button { flex: 1; padding: 8px 10px; font-weight: 600; font-size: 13px;
  background: var(--surface); color: var(--muted); border: none; border-radius: 0; cursor: pointer; }
.authtabs button.active { background: var(--accent); color: var(--accent-ink); }
.modal .actions button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.modal .actions button.primary:disabled { opacity: .6; cursor: progress; }
button.danger { background: var(--danger); color: var(--danger-ink); }
.matrow { display: flex; gap: 6px; margin-bottom: 5px; align-items: center; }
.matrow input[type="text"] { flex: 1; }
.matrow input { padding: 5px 7px; background: var(--surface); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r-1); }
.matrow input[type="number"] { width: 62px; text-align: right; }
.matrow input.swatch { width: 40px; min-width: 40px; height: 32px; padding: 2px; cursor: pointer; flex: 0 0 auto; }
.matrow input.decchk { width: 18px; min-width: 18px; flex: 0 0 auto; cursor: pointer; }
.matrow button.del { background: var(--danger); color: var(--danger-ink); padding: 3px 8px; }
.toolrow { display: flex; gap: 5px; margin-bottom: 5px; align-items: center; }
.toolrow input, .toolrow select { padding: 5px 6px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border2); border-radius: var(--r-1); min-width: 0; }
.toolrow input.tname { flex: 1 1 auto; }
.toolrow select { flex: 0 0 84px; }
.toolrow input[type="number"] { flex: 0 0 72px; width: 72px; text-align: right; }
.toolrow button.del { flex: 0 0 auto; background: var(--danger); color: var(--danger-ink); padding: 3px 8px; }
.toolrow.toolhead { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.toolrow.toolhead span { flex: 0 0 72px; text-align: right; }
.toolrow.toolhead span.tname { flex: 1 1 auto; text-align: left; }
.toolrow.cutrow { gap: 4px; }
.toolrow.cutrow input[type="number"] { flex: 0 0 46px; width: 46px; padding: 5px 4px; }
.toolrow.cutrow.toolhead span { flex: 0 0 46px; }
.toolinfo { font-style: italic; }
input.search { width: 100%; box-sizing: border-box; padding: 8px 10px; margin-bottom: 8px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r-2); }
.decogrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.decobtn { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 12px 6px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border2);
  border-radius: var(--r-2); cursor: pointer; font-size: 12px; }
.decobtn:hover { border-color: var(--accent); }
.decobtn .ico { font-size: 28px; line-height: 1; }
.decobtn .dim { font-size: 11px; color: var(--muted, #888); }
/* Carte de bibliothèque : bouton de pose + ✕ de suppression superposé. */
.libcard { position: relative; }
.libcard .decobtn { width: 100%; }
.libcard .del { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
  line-height: 1; padding: 0; border-radius: 50%; border: 1px solid var(--border2);
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 11px; }
.libcard .del:hover { border-color: var(--danger, #c0392b); color: var(--danger, #c0392b); }
@media (max-width: 560px) { .decogrid { grid-template-columns: repeat(3, 1fr); } }
.postcard { border: 1px solid var(--border2); border-radius: var(--r-2); padding: 8px 10px; margin-bottom: 8px; }
.postrow { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.postrow input.pname { flex: 1; }
.postcard input { padding: 4px 6px; background: var(--surface); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r-1); }
.postrow button.del { background: var(--danger); color: var(--danger-ink); padding: 3px 8px; flex: 0 0 auto; }
.postgrid { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 5px 8px; align-items: center; }
.postgrid label { font-size: 11px; color: var(--muted); text-align: right; }
.postgrid input { min-width: 0; }
.postchecks { display: flex; gap: 18px; margin-top: 8px; }
.checkok { color: var(--h-ok); font-weight: 600; }
.warnbox { border: 1px solid var(--danger); border-radius: var(--r-2); padding: 8px 10px; margin: 6px 0; font-size: 12px; }
.warnbox strong { color: var(--danger); display: block; margin-bottom: 2px; }
.warnbox ul { margin: 2px 0 0; padding-left: 18px; }
.warnbox li { margin: 2px 0; }

/* Rapport « Vérifier le projet » (cohérence métier) */
.checkok { font-size: 14px; color: var(--ok, #2e9e44); margin: 12px 4px; }
.checksum { font-size: 12px; opacity: 0.8; margin: 4px 0 8px; }
.findings { list-style: none; margin: 0; padding: 0; max-height: 55vh; overflow-y: auto; }
.findings li { display: flex; align-items: baseline; gap: 8px; padding: 6px 8px; border-radius: var(--r-2); margin: 3px 0; font-size: 12.5px; }
.findings li.err { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.findings li.warn { background: color-mix(in srgb, orange 14%, transparent); }
.findings li.info { background: color-mix(in srgb, var(--accent, #4a90d9) 10%, transparent); }
.findings .ico { flex: none; }
.findings .msg { flex: 1; }
.findings .see { flex: none; font-size: 11px; padding: 2px 8px; }
label.check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text); margin: 6px 0; cursor: pointer; }
textarea.outline { width: 100%; box-sizing: border-box; font-family: monospace; font-size: 12px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r-1); padding: 6px; resize: vertical; }
ul.cloud { list-style: none; padding: 0; margin: 0; }
ul.cloud li { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2);
  padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-1); margin-bottom: 5px; font-size: 13px; }
ul.cloud li button { padding: 5px 10px; font-size: 12px; }
ul.cloud li .cloud-acts { display: flex; gap: 6px; flex: 0 0 auto; }

/* ---- Menu latéral rétractable (bouton menu en haut-gauche) ---- */
.navtoggle { background: transparent; color: var(--text); font-size: 18px;
  padding: 6px 10px; border-radius: var(--r-1); margin-right: 2px;
  display: inline-flex; align-items: center; justify-content: center; }
.navtoggle .icon { width: 18px; height: 18px; }
.navtoggle:hover { background: var(--surface); }
.nav-backdrop { display: none; }
/* Desktop : le menu reste une colonne ; fermé → on le masque (vue 3D pleine largeur). */
@media (min-width: 821px) {
  .app:not(.navopen) .panel { display: none; }
}
/* Mobile / petit écran : menu en tiroir par-dessus, rétracté par défaut. */
@media (max-width: 820px) {
  .topbar { gap: 0; padding: 0 6px; }
  .topbar .brand { font-size: 17px; margin-right: 6px; }
  .menubtn { padding: 8px 7px; font-size: 13px; }
  .iconbtn { width: 32px; height: 32px; margin-left: 4px; }
  .panel {
    position: fixed; top: 50px; left: 0; bottom: 0;
    width: min(280px, 82vw); z-index: 40;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 6px 0 24px rgba(0,0,0,.35);
  }
  .app.navopen .panel { transform: translateX(0); }
  .app.navopen .nav-backdrop {
    display: block; position: fixed; inset: 50px 0 0 0;
    background: rgba(0,0,0,.45); z-index: 35;
  }
  /* Éditeur d'objet : un SEUL défilement (celui de la fenêtre), pas de barre
     propre par colonne — sinon, avec la zone 3D qui capte le toucher, on ne
     peut plus faire défiler. Le mini-viewport est aussi raccourci. */
  .edit-left, .edit-right { flex: 1 1 100%; min-width: 0; max-width: none;
    max-height: none; overflow: visible; }
  #mini-viewport { height: 240px; }
}

/* Incite au paysage sur mobile en portrait (un onglet ne peut pas forcer
   l'orientation ; on bloque proprement avec un message). */
.rotate-hint { display: none; }
@media (max-width: 820px) and (orientation: portrait) {
  .rotate-hint {
    display: flex; position: fixed; inset: 0; z-index: 200;
    align-items: center; justify-content: center; text-align: center;
    padding: 28px; background: var(--bg); color: var(--text);
    font-size: 18px; line-height: 1.5;
  }
  .rotate-hint .rot { font-size: 44px; display: block; margin-bottom: 12px; }
}
