:root {
  --bg: #eef0f3;
  --panel: #ffffff;
  --line: #d5d9df;
  --text: #1d2430;
  --muted: #6b7482;
  --accent: #0077bb;           /* bleu de Rack Matrix, comme les pages publiques */
  --checker-a: #c9ccd1;
  --checker-b: #e4e6e9;
  --desk: #5f6670;
  --cut-line: #1ea7ff;
  --frame-line: #ff8a00;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.4 'Panelitor UI', system-ui, "Segoe UI", sans-serif; display: flex; flex-direction: column; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; border-radius: 4px; padding: 3px 8px; }
button:hover { border-color: var(--accent); }
select, input[type=number], input[type=text] { font: inherit; padding: 2px 4px; border: 1px solid var(--line); border-radius: 3px; }

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.bar label { display: inline-flex; align-items: center; gap: 4px; }
.brand { font-size: 15px; color: var(--accent); }
.bar > a { color: var(--accent); text-decoration: none; }
.sep { width: 1px; height: 20px; background: var(--line); }
#template-layers { display: inline-flex; gap: 10px; }

.main { flex: 1; display: flex; min-height: 0; }
/* Barre d'outils, en haut de la zone de travail : des groupes d'icônes (Bootstrap Icons) séparés
   par un trait ; Aperçu 3D, Enregistrer et Designs à droite, avec leur nom. */
/* police de l'interface : Didact Gothic (libre, OFL, dessin proche de Century Gothic, celle de www.rack-matrix.com) */
@font-face { font-family: 'Panelitor UI'; src: url('/panelitor?aws_c=root&aws_a=file&f=fonts/DidactGothic/DidactGothic-Regular.ttf') format('truetype'); font-display: swap; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 10px; background: var(--panel); border-bottom: 1px solid var(--line); }
.toolbar .tb-group { display: flex; gap: 2px; }
.toolbar .tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.toolbar .spacer { flex: 1; }
.toolbar button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; min-width: 32px; padding: 0 6px;
                  border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text); }
.toolbar button .bi { font-size: 17px; line-height: 1; }
.toolbar button .tb-icon { width: 18px; height: 18px; stroke-width: 1; }
.toolbar button:hover:not(:disabled) { background: #edf3f8; border-color: var(--line); }
.toolbar button.on { background: #e1f0fa; border-color: var(--accent); color: var(--accent); }
.toolbar button:disabled { opacity: .35; cursor: default; }
.toolbar button.tb-labelled { padding: 0 10px; }
.toolbar #btn-save { border-color: var(--accent); color: var(--accent); }
/* infobulle d'un bouton de la barre (js/toolbar-tips.js) */
.tb-tip { position: fixed; z-index: 1000; max-width: 280px; padding: 6px 9px; border-radius: 6px; background: #1d2430; color: #fff;
          font-size: 12px; line-height: 1.35; box-shadow: 0 3px 10px rgba(0, 0, 0, .25); pointer-events: none; }
.tb-tip b { display: block; font-weight: 600; }
.tb-tip span { display: block; margin-top: 2px; color: #c5ccd6; }
.node-hud { position: absolute; top: 40px; right: 16px; z-index: 30; display: flex; align-items: center; gap: 6px; padding: 5px 8px; background: #fff; border: 1px solid var(--accent); border-radius: 6px; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); font-size: 12px; }
.node-hud-title { color: var(--muted); margin-right: 4px; }
.node-hud label { display: flex; align-items: center; gap: 3px; }
.node-hud input[type=number] { width: 68px; }

.workspace { flex: 1; display: flex; flex-direction: column; min-width: 0; }
/* un onglet par façade d'un boîtier à deux faces (avant, arrière) */
.face-tabs { display: flex; gap: 2px; padding: 6px 12px 0; background: var(--bg); border-bottom: 1px solid var(--line); }
.face-tabs[hidden] { display: none; }
.face-tabs button { padding: 5px 14px; border: 1px solid var(--line); border-bottom: 0; border-radius: 6px 6px 0 0; background: var(--panel); color: var(--muted); cursor: pointer; font: inherit; margin-bottom: -1px; }
.face-tabs button:hover { color: var(--text); }
.face-tabs button.on { color: var(--text); font-weight: 600; border-top: 2px solid var(--accent); padding-top: 4px; }
#view-3d-sides button { margin-left: 2px; }
#view-3d-sides button.on { font-weight: 600; outline: 1px solid var(--accent); }
.spacer { flex: 1; }
/* position du curseur (barre du bas) : sur une ligne, de largeur fixe (elle ne fait pas bouger la barre) */
#cursor-pos { flex: none; min-width: 22ch; padding: 2px 8px; white-space: nowrap; text-align: right; color: var(--text);
              font-variant-numeric: tabular-nums; background: #f3f5f8; border: 1px solid var(--line); border-radius: 5px; }
#cursor-pos:empty { visibility: hidden; }
/* la façade est centrée ; « margin: auto » dans un flex reste accessible au défilement quand elle déborde */
/* règles en mm (js/rulers.js) : 20 px, en haut et à gauche du plan de travail qui défile */
.ruled { flex: 1; display: grid; grid-template-columns: 20px minmax(0, 1fr); grid-template-rows: 20px minmax(0, 1fr); min-height: 0; }
.ruler-corner { grid-area: 1 / 1; background: #cfd4db; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.ruler { display: block; min-width: 0; min-height: 0; }
.ruler-x { grid-area: 1 / 2; width: 100%; height: 20px; }
.ruler-y { grid-area: 2 / 1; width: 20px; height: 100%; }
.scroller { grid-area: 2 / 2; min-width: 0; min-height: 0; overflow: auto; padding: 24px; background: var(--desk); display: flex; }
.stage { position: relative; margin: auto; flex: none; }
.stage.bleed .over { outline: 1px dashed rgba(255, 255, 255, .75); box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }   /* bord de la page, au-dessus de tout */
#zoom-label { white-space: nowrap; }
#btn-bleed.on { background: #e1f0fa; border-color: var(--accent); }
.stage .layer, .stage canvas { position: absolute; left: 0; top: 0; }
.stage .canvas-container { position: absolute !important; left: 0; top: 0; }
.stage .layer { pointer-events: none; overflow: visible; }
.stage .over { z-index: 5; }

/* Plaque PMMA : contour à la couleur du PMMA, découpes en damier */
.plate [data-cut] { stroke: none !important; }
.plate [data-cut="outline"] { fill: var(--pmma, #f4f4f2) !important; }
.plate [data-cut="hole"] { fill: none !important; }
.plate mask [data-cut="outline"] { fill: #fff !important; }
.plate mask [data-cut="hole"] { fill: #000 !important; }
/* Trait de coupe : 1 px quel que soit le zoom */
.over [data-cut] { stroke: var(--cut-line) !important; stroke-width: 1px !important; vector-effect: non-scaling-stroke; stroke-dasharray: none !important; }
.over [data-cut="outline"] { fill: none !important; }
.over [data-cut="hole"] { fill: none !important; }   /* la plaque est percée (masque) : on voit le fond du plan de travail */
.over.no-holes [data-cut="hole"] { display: none !important; }   /* plus fort qu'un style="display:inline" du gabarit */
/* Emplacements des ports : repères roses pointillés, jamais imprimés */
.over [data-role="placement"] * { fill: rgba(232, 0, 140, .07) !important; stroke: #e8008c !important; stroke-width: 1px !important; stroke-dasharray: 3 2 !important; vector-effect: non-scaling-stroke; }
.over.no-placement [data-role="placement"] { display: none; }
/* Noms des ports (data-name, option « Noms des ports ») : jamais imprimés */
#port-names text { fill: #1d2430; stroke: #fff; paint-order: stroke; stroke-linejoin: round; font-family: system-ui, sans-serif; font-weight: 600; }
/* Outil « Nommer les ports » (administrateur) : découpes et emplacements cliquables */
.stage .over.port-naming .holes [data-cut="hole"], .stage .over.port-naming [data-role="placement"] * { pointer-events: all; cursor: pointer; }
.over.port-naming .holes [data-cut="hole"]:hover, .over.port-naming [data-role="placement"] *:hover { fill: rgba(255, 122, 0, .3) !important; stroke: #ff7a00 !important; }
#port-name-mode.on { background: #e1f0fa; border-color: var(--accent); }
/* Repère choisi pour l'alignement */
.over .anchor, .over [data-role="placement"] .anchor { fill: rgba(255, 122, 0, .3) !important; stroke: #ff7a00 !important; stroke-width: 2px !important; stroke-dasharray: none !important; }
.over.frame-solid [data-role="frame"] * { fill: var(--frame) !important; stroke: none !important; }
.over [data-role="frame"] * { fill: url(#frame-hatch) !important; fill-opacity: 1 !important;
  stroke: var(--frame-line) !important; stroke-width: 1px !important; stroke-dasharray: 4 3 !important; vector-effect: non-scaling-stroke; }


.modal { position: fixed; inset: 0; background: rgba(10, 15, 25, .55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal[hidden] { display: none; }
.modal.modal-top { z-index: 60; }   /* question posée par-dessus une autre fenêtre (designs) */
.modal-box { background: var(--panel); width: min(1200px, 94vw); height: min(720px, 88vh); border-radius: 8px; display: flex; flex-direction: column; overflow: hidden; }
.modal-box:fullscreen, .modal-box.maximized { width: 100vw; height: 100vh; border-radius: 0; }
.modal-head {display: flex; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.view3d { flex: 1; position: relative; }
.modal-option { display: inline-flex; align-items: center; gap: 4px; margin-left: 16px; white-space: nowrap; }
#modal-3d .modal-box:not(.maximized):not(:fullscreen) { width: 96vw; height: 94vh; }   /* aperçu 3D : presque tout l'écran */
#modal-3d .modal-head { flex-wrap: wrap; row-gap: 6px; }
#modal-3d .modal-head > strong, #modal-3d .modal-head > button { white-space: nowrap; }
#modal-3d .modal-head > button { margin-left: 6px; }

.design-title { color: var(--muted); font-weight: 600; }
.affair-banner { background: var(--accent); color: #fff; padding: 2px 10px; border-radius: 4px; font-size: 13px; font-weight: 600; }
.affair-banner[hidden] { display: none; }
.affair-close { margin-left: 8px; border: 0; background: rgba(255,255,255,.2); color: #fff; border-radius: 3px; padding: 0 6px; font-size: 14px; line-height: 18px; cursor: pointer; }
.affair-close:hover { background: rgba(255,255,255,.4); }
.modal-box.modal-small { width: min(680px, 94vw); height: auto; max-height: 88vh; }
#modal-template-copy .hint { color: var(--muted); font-size: .9em; margin: 4px 0 0; }
#modal-template-copy .error { color: #c62828; margin: 4px 0 0; }
#modal-template-copy #tc-ref, #ti-ref { text-transform: uppercase; font-family: ui-monospace, Consolas, monospace; }
.designs { padding: 12px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.designs-row { display: flex; gap: 6px; align-items: center; }
.designs-row input[type=text] { flex: 1; }
.designs p { margin: 0; min-height: 1.4em; }
.cfont-rights { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0 8px; padding: 4px 6px; border: 1px solid transparent; border-radius: 4px; }
/* oubli dans la fenêtre des polices : champ encadré en rouge, secoué, message en rouge */
.cfont-missing { border: 1px solid #c62828 !important; background: #fdecea; color: #b71c1c; animation: cfont-shake .4s; }
#cfonts-status.cfont-error { color: #b71c1c; font-weight: 600; background: #fdecea; border-left: 4px solid #c62828; padding: 6px 10px; border-radius: 4px; }
/* ajout de polices, plusieurs à la fois : zone de dépôt (toute la fenêtre l'accepte), liste d'attente */
#modal-cfonts .modal-box { width: min(760px, 96vw); }
.cfont-drop { display: flex; align-items: center; gap: 8px; margin: 6px 0; padding: 14px 12px; border: 2px dashed #8aa4b8; border-radius: 6px; color: #00507e; background: #f7fbfe; cursor: pointer; }
.cfont-drop:hover, .cfont-drop.over { background: #e1f0fa; border-style: solid; }
.cfont-drop .bi { font-size: 1.4em; }
.cfont-pending { margin: 4px 0 6px; }
.cfont-pending th { text-align: left; font-weight: 600; font-size: .85em; color: #555; }
.cfont-pending td { vertical-align: middle; }
.cfont-pending input[type=text] { width: 100%; }
.cfont-pending tr.cfont-skip td { background: #fff8e1; }
.cfont-note { color: #b26a00; font-size: .85em; }
/* polices du design : pastille rouge de la barre du haut, fenêtre récapitulative */
.toolbar button.tb-alert { background: #c62828; color: #fff; border-radius: 999px; font-weight: 600; animation: tb-alert-pulse 2s ease-in-out 3; }
.toolbar button.tb-alert:hover { background: #b71c1c; color: #fff; }
.toolbar button.tb-alert .tb-count:not(:empty) { margin-left: 6px; background: #fff; color: #c62828; border-radius: 999px; padding: 0 6px; font-size: .85em; }
@keyframes tb-alert-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, .6); } 50% { box-shadow: 0 0 0 6px rgba(198, 40, 40, 0); } }
.modal-box.modal-dfonts { width: min(900px, 96vw); }
#dfonts-summary.cfont-error { color: #b71c1c; font-weight: 600; background: #fdecea; border-left: 4px solid #c62828; padding: 6px 10px; border-radius: 4px; }
.dfonts-table td { vertical-align: middle; }
.dfonts-table td:last-child { text-align: left; }
.dfonts-table tr.missing td { background: #fff5f5; }
.dfonts-family { font-size: 1.15em; }
.dfonts-state { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .85em; white-space: nowrap; }
.dfonts-free { background: #e3f2e5; color: #1b5e20; }
.dfonts-customer, .dfonts-shared { background: #e1f0fa; color: #00507e; }
.dfonts-missing { background: #c62828; color: #fff; }
.dfonts-face { display: inline-block; margin-right: 8px; white-space: nowrap; }
.dfonts-face.simulated { color: #b26a00; }
.dfonts-drop { display: flex; align-items: center; gap: 6px; min-width: 190px; padding: 8px 10px; border: 2px dashed #c62828; border-radius: 6px; color: #b71c1c; background: #fff; cursor: pointer; font-size: .9em; }
.dfonts-drop:hover, .dfonts-drop.over { background: #fdecea; border-style: solid; }
.dfonts-ask { border: 1px solid #b26a00; background: #fff8e1; border-radius: 4px; padding: 6px 10px; margin: 6px 0; }
@keyframes cfont-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.designs-owner { display: flex; align-items: center; gap: 8px; }
.designs-owner select { flex: 1; min-width: 0; }
.designs-owner[hidden] { display: none; }
.design-list { width: 100%; border-collapse: collapse; }
.design-list td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.design-list td:last-child { text-align: right; }
.design-list tr.sel td { background: #e1f0fa; }
.view3d canvas { display: block; }

/* Barre contextuelle (contrôles d'outil, comme Inkscape) */
.ctxbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 5px 12px; min-height: 38px; background: var(--panel); border-bottom: 1px solid var(--line); }
/* blocs de la barre (panels.js : X Y L H angle, police, paragraphe) : la barre passe à la ligne entre deux blocs */
.ctx-group { display: inline-flex; flex-wrap: nowrap; align-items: center; gap: 10px; white-space: nowrap; }
.ctx-field { display: inline-flex; align-items: center; gap: 5px; color: #3b4554; font-size: 13px; }
.ctx-field input { width: 80px; height: 26px; padding: 2px 6px; font-size: 13px; color: var(--text); text-align: right; font-variant-numeric: tabular-nums;
                   border-radius: 5px; }
.ctx-field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(0, 119, 187, .2); }
.ctx-btn { min-width: 26px; padding: 2px 6px; }
.ctx-btn.on { background: #e1f0fa; border-color: var(--accent); }
.ctx-btn:disabled { opacity: .35; cursor: default; }
.ctx-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.ctxbar select { max-width: 170px; }

/* Barre d'état */
.statusbar { display: flex; align-items: center; gap: 8px; padding: 4px 12px; background: var(--panel); border-top: 1px solid var(--line); }
.statusbar .hint { color: var(--text); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 2px 6px; border-radius: 4px; }
/* messages de la barre d'état (watchHint d'editor.js) : un message brille un instant, une erreur reste en rouge
   et ouvre une bannière en haut du plan de travail */
.statusbar.flash .hint { animation: hint-flash 2.4s ease-out; }
@keyframes hint-flash { 0%, 35% { background: #cfe8f7; color: #00507e; } 100% { background: transparent; } }
.statusbar.has-error { background: #fdecea; border-top-color: #c62828; }
.statusbar.has-error .hint { color: #b71c1c; }
.error-banner { position: fixed; top: 150px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; align-items: flex-start; gap: 12px;
                max-width: min(900px, calc(100vw - 40px)); padding: 10px 12px 10px 16px; background: #c62828; color: #fff; font-size: 14px;
                border-radius: 6px; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
.error-banner[hidden] { display: none; }
.error-banner::before { content: '⚠'; font-size: 18px; line-height: 1; }
.error-banner > span { flex: 1; white-space: pre-wrap; }
.error-banner-close { flex: none; border: 0; background: transparent; color: #fff; font-size: 20px; line-height: 1; padding: 0 4px; }
.error-banner-close:hover { background: rgba(255, 255, 255, .2); }
.statusbar input[type=range] { width: 120px; }
.statusbar button { white-space: nowrap; flex: none; }

/* Panneau à onglets (dock) */
.dock { position: relative; width: 360px; flex: none; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
/* poignée du bord gauche (panels.js) : élargir le panneau */
.dock-grip { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; z-index: 5; cursor: col-resize; }
.dock-grip:hover, body.dock-resizing .dock-grip { background: linear-gradient(90deg, transparent 3px, var(--accent) 3px 5px, transparent 5px); }
body.dock-resizing { cursor: col-resize; user-select: none; }
.dock-tabs { display: flex; border-bottom: 1px solid var(--line); }
.dock-tabs button { flex: 1; border: 0; border-radius: 0; border-bottom: 2px solid transparent; background: none; padding: 7px 4px; color: var(--muted); }
.dock-tabs button.sel { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.dock-panel { flex: 1; overflow: auto; padding: 10px 12px; }
.dock-panel h4 { margin: 12px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.dock-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.dock-row input[type=number] { width: 64px; }
/* champs numériques (panels.js : numInput) : sans flèches, chiffres alignés à droite ([type] : passe avant
   « .dock-row input[type=text] », qui les étirerait) */
input.num, .dock-row input.num[type] { flex: none; width: 76px; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; }
.dock-row input[type=text] { flex: 1; min-width: 0; }
.dock-row select { max-width: 100%; }
button.danger { background: #c62828; color: #fff; border-color: #c62828; padding: 5px 14px; }
button.danger:hover { background: #a31f1f; }
.tpl-actions button.tpl-admin { margin-left: 4px; border: 1px solid var(--line); border-radius: 3px; background: #fff; color: var(--text); display: inline-grid; place-content: center; height: 20px; padding: 0 5px; }
.tpl-actions button.tpl-admin:hover { border-color: var(--accent); color: var(--accent); }
.tpl-actions button.tpl-delete { border-color: #e6b8b8; background: #fff3f3; color: #c62828; }
.tpl-actions button.tpl-delete:hover { background: #c62828; border-color: #c62828; color: #fff; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); padding: 5px 14px; }
button:disabled { opacity: .5; cursor: default; }

/* Calques */
.tpl-layer { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 3px; color: var(--muted); }
.tpl-layer > span:not(.eye-off) { flex: 1; }
.tpl-layer.locked { opacity: .7; }
.tpl-layer-label { display: flex; align-items: center; gap: 6px; flex: 1; }
.tpl-layer-label > span { flex: 1; }
#template-layers { display: flex; flex-direction: column; }
input.eye { appearance: none; width: 22px; height: 18px; margin: 0; cursor: pointer; display: inline-grid; place-content: center; }
input.eye::before { content: '◌'; font-size: 14px; }
input.eye:checked::before { content: '👁'; }
.eye-off { width: 22px; text-align: center; }
.layers-head { display: flex; align-items: center; gap: 4px; margin: 10px 0 4px; }
.layers-head button { padding: 1px 6px; }
.layers-tree { border: 1px solid var(--line); border-radius: 4px; margin-bottom: 6px; }
.layer-row, .object-row { display: flex; align-items: center; gap: 2px; padding: 3px 6px; cursor: pointer; }
.layer-row { background: #f3f5f8; font-weight: 600; border-top: 1px solid var(--line); }
.layer-row:first-child { border-top: 0; }
.layer-row.current { background: #e1f0fa; box-shadow: inset 3px 0 var(--accent); }
.object-row { padding-left: 22px; }
.object-row.sel { background: #d6e4f8; }
.object-row.hidden-obj .name { opacity: .45; }
.object-row.empty { cursor: default; font-style: italic; }
.layer-row .name, .object-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 4px; }
.layer-row .count { font-weight: 400; font-size: 11px; }
.layer-row button.to-template { flex: none; margin: 0 4px; font-size: 11px; font-weight: 400; padding: 0 5px; height: 20px; border: 1px solid var(--line); border-radius: 3px; background: #fff; color: var(--text); white-space: nowrap; cursor: pointer; }
.layer-row button.to-template:hover { border-color: var(--accent); color: var(--accent); }
button.toggle { border: 0; background: none; padding: 0 3px; font-size: 12px; line-height: 18px; }
button.toggle.off { opacity: .55; }
button.toggle.state { display: inline-grid; place-content: center; width: 20px; height: 18px; padding: 0; color: #9aa1ab; }
button.toggle.state:hover { color: var(--accent); }
button.toggle.eye.active { color: var(--text); }
button.toggle.lock.active { color: #c0392b; }
button.toggle.public.active { color: #1f7a3a; }
.layer-row.locked .name, .object-row.locked .name { color: var(--muted); font-style: italic; }
.object-row.locked { cursor: default; }
.layer-row.template { background: #f6f1e6; font-weight: 500; }
.layer-row[draggable="true"] { cursor: grab; }
.layer-row.dragging, .object-row.dragging { opacity: .45; }
.layer-row.drop-above { box-shadow: inset 0 3px var(--accent); }
.layer-row.drop-below { box-shadow: inset 0 -3px var(--accent); }
.layer-row.drop-into { outline: 2px dashed var(--accent); outline-offset: -2px; }
button.toggle.del { color: #9aa1ab; }
button.toggle.del:hover { color: #c0392b; }
button.toggle.del.armed { color: #fff; background: #c0392b; border-radius: 3px; }
.layer-row.template.current { background: #efe3c6; box-shadow: inset 3px 0 #b07d16; }
.layer-row.template.editing { background: #e3f4e5; }
.layer-row.template.editing.current { background: #c9eacd; box-shadow: inset 3px 0 #2e7d32; }
.layer-row.template.editing .tpl-badge { color: #2e7d32; border-color: #8fca94; }
.layer-row.template.editing .tpl-lock { color: #2e7d32; }
.tpl-badge { font-size: 10px; font-weight: 600; text-transform: uppercase; color: #8a6412; border: 1px solid #d8c08a; border-radius: 3px; padding: 0 4px; margin: 0 2px; }
.tpl-actions { padding: 2px 6px 4px 22px; cursor: default; }
.tpl-actions button { font-size: 11px; padding: 1px 6px; }
.row-actions { display: none; }
.object-row:hover .row-actions, .layer-row:hover .row-actions { display: inline-flex; }
.lib-tile .lib-badge { position: absolute; top: 2px; left: 2px; font-size: 9px; background: #8a6412; color: #fff; border-radius: 2px; padding: 0 3px; }
.layers-move { display: flex; gap: 4px; margin-bottom: 10px; }
.layers-move button { flex: 1; font-size: 12px; }
.layers-to { margin-top: -6px; }
.layers-to select { flex: 2; min-width: 0; font-size: 12px; }
/* champ de renommage d'un calque ou d'un objet (panels.js) */
input.rename { flex: 1; min-width: 0; height: 24px; padding: 2px 6px; font: inherit; font-weight: normal; cursor: text; color: var(--text);
               background: #fff; border: 1px solid var(--accent); border-radius: 4px; outline: none; box-shadow: 0 0 0 3px rgba(0, 119, 187, .18); }
.bar button.facade-rename { border: 1px solid var(--line); border-radius: 3px; background: #fff; color: var(--text); display: inline-grid; place-content: center; height: 22px; padding: 0 5px; }
.bar button.facade-rename:hover { border-color: var(--accent); color: var(--accent); }
.bar button.facade-rename[hidden] { display: none; }
.bar input.facade-name { font: inherit; width: 22em; }

/* Aligner */
.icon-row { display: flex; flex-wrap: wrap; gap: 4px; }
/* Bibliothèque */
.dock-tabs button { font-size: 12px; padding: 7px 2px; }
.lib-search { width: 100%; margin-bottom: 4px; }
.lib-layer-list { display: flex; flex-direction: column; gap: 6px; }
.lib-tile.lib-layer { align-items: stretch; }
.lib-tile.lib-layer img { width: 100%; height: 34px; }
.lib-tile.lib-layer .lib-badge { position: static; align-self: flex-start; }
.lib-layer-name { display: flex; gap: 6px; align-items: center; }
.lib-layer-name span { flex: 1; }
.lib-head { display: flex; align-items: center; gap: 6px; }
.lib-head button { text-transform: none; letter-spacing: 0; font-size: 12px; }
.lib-cat summary { cursor: pointer; color: var(--muted); font-size: 12px; margin: 4px 0; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }
.lib-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px; border: 1px solid var(--line); border-radius: 4px; background: #fff; cursor: grab; }
.lib-tile:hover { border-color: var(--accent); }
.lib-tile img { width: 64px; height: 48px; object-fit: contain; background: repeating-conic-gradient(#eef0f3 0 25%, #fff 0 50%) 0 0 / 10px 10px; }
.lib-tile span { font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-del { position: absolute; top: 1px; right: 1px; padding: 0 4px; font-size: 10px; display: none; }
.lib-tile:hover .lib-del, .lib-del.armed { display: block; }
.lib-del.armed { background: #c0392b; color: #fff; border-color: #c0392b; }
.lib-drop { min-height: 70px; border: 1px dashed var(--line); border-radius: 4px; padding: 6px; }
.lib-drop.drop-target, .scroller.drop-target { outline: 2px dashed var(--accent); outline-offset: -4px; }
/* Numéros des repères d'alignement sur la façade */
#anchor-numbers circle { fill: #fff; stroke: #ff7a00; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
#anchor-numbers text { fill: #c25400; font-family: system-ui, sans-serif; font-weight: 700; }
#anchor-numbers .current circle { fill: #ff7a00; }
#anchor-numbers .current text { fill: #fff; }
.anchor-picker { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 8px; }
.anchor-picker button { min-width: 30px; padding: 2px 4px; }
.anchor-picker button.on { background: #ff7a00; border-color: #ff7a00; color: #fff; }
.icon-btn { width: 36px; height: 34px; padding: 0; display: grid; place-content: center; color: var(--text); }

/* Couleurs */
.paint-row { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.paint-row strong { width: 58px; font-weight: 600; }
.paint-row input[type=color] { width: 34px; height: 26px; padding: 0 2px; }
.paint-row .hex { width: 76px; font-family: monospace; }
.swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.swatch { width: 24px; height: 24px; padding: 0; border: 1px solid #9aa1ab; border-radius: 3px; }

/* Langues (L3) : drapeau de la langue courante, liste des langues au clic */
.l3-flags { position: relative; display: inline-flex; }
.l3-flag-button { padding: 1px 3px; background: none; border: 1px solid transparent; border-radius: 4px; line-height: 0; cursor: pointer; }
.l3-flag-button:hover { border-color: var(--line); background: rgba(0, 0, 0, .04); }
.l3-flag-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 60; background: #fff; border: 1px solid var(--line);
                border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); padding: 4px; min-width: 150px; }
.l3-flag-list a { display: flex; align-items: center; gap: 8px; padding: 5px 8px; color: inherit; text-decoration: none; border-radius: 4px; white-space: nowrap; }
.l3-flag-list a:hover, .l3-flag-list a.sel { background: #e6f2fa; }

/* champs des petites fenêtres (publication dans la galerie) */
.field { display: grid; gap: 4px; margin-bottom: 8px; }
.field input[type="text"], .field textarea { width: 100%; font: inherit; }

/* Administrateur connecté comme un client */
.login-as { background: #f0ad00; color: #1b1b1b; padding: 2px 10px; border-radius: 4px; font-size: 13px; }
.login-as[hidden] { display: none; }
/* un designer : le client pour qui il travaille */
.working-for { background: rgba(0, 119, 187, .25); border: 1px solid rgba(77, 179, 239, .5); padding: 1px 10px; border-radius: 4px; font-size: 13px; }
.working-for[hidden], #link-designers[hidden] { display: none; }
/* Visiteur sans compte (body.visitor) et invité (body.guest), posés par session.js */
body:not(.visitor) .visitor-only { display: none !important; }
body.visitor .account-only { display: none !important; }
body.visitor .member-only, body.guest .member-only { display: none !important; }
.visitor-note { background: #e8f0fe; color: #1f4e9c; padding: 2px 10px; border-radius: 4px; font-size: 13px; cursor: help; white-space: nowrap; }
.signup-link { background: #1f6feb; color: #fff !important; padding: 3px 10px; border-radius: 4px; text-decoration: none; white-space: nowrap; }
.signup-link:hover { background: #1a5fd0; }

/* Bon à tirer : le design approuvé est en lecture seule (on le regarde, on l'exporte, on le duplique). */
.bat-banner { background: #1e7a34; color: #fff; padding: 2px 10px; border-radius: 4px; font-size: 13px; font-weight: 600; }
.bat-banner[hidden], #btn-bat[hidden], #btn-bat-duplicate[hidden], #btn-bat-cert[hidden] { display: none; }
.ro-summary { font-size: 13px; color: var(--muted, #5b6472); white-space: nowrap; }
.ro-summary[hidden],
body.read-only .bar > label:has(#case),
body.read-only .bar > label:has(#product),
body.read-only .bar > label:has(#pmma),
body.read-only .bar > #frame-options,
body.read-only .bar > #custom-colors,
body.read-only .bar > #box-substrate { display: none; }
/* Support fixe d'un boîtier d'une autre marque (Broachlink : aluminium anodisé noir brossé), à la place de PMMA et Finition */
.box-substrate { font-size: 13px; padding: 2px 8px; border-radius: 3px; background: #1b1c1f; color: #e8e8e8; white-space: nowrap;
  background-image: repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 1px, transparent 1px 3px); }
.box-substrate[hidden], .bar > label[hidden], .modal-option[hidden] { display: none; }
a.button-link { display: inline-block; padding: 4px 10px; border: 1px solid var(--line); border-radius: 4px; color: inherit; text-decoration: none; font-size: 13px; }
.bat-preview { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.bat-preview figure { margin: 0; border: 1px solid var(--line); background: #f2f2f2; padding: 4px; }
.bat-preview img { display: block; width: 100%; height: auto; max-height: 220px; object-fit: contain; }
.bat-preview figcaption { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.bat-preview .bat-view + .bat-view { margin-top: 6px; }
.bat-preview .bat-view small { display: block; font-size: 11px; color: var(--muted); margin-bottom: 1px; }
.bat-legend { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.bat-legend-swatch { flex: none; width: 22px; height: 12px; background: #5f6670; border: 1px solid #1ea7ff; border-radius: 2px; }
.bat-agree { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; font-weight: 600; }
body.read-only .toolbar .tb-group,
body.read-only .toolbar #btn-snap,
body.read-only .toolbar #btn-save,
body.read-only .dock-panel[data-panel="layers"],
body.read-only .dock-panel[data-panel="align"],
body.read-only .dock-panel[data-panel="colors"],
body.read-only .dock-panel[data-panel="library"],
body.read-only #custom-colors { pointer-events: none; opacity: .45; }

/* Barre du haut : sombre, comme la barre des pages publiques (public/css/site.css) ; la zone de travail
   et le panneau de droite restent clairs. Les listes ouvertes gardent les couleurs du système. */
:root { --night: #0b0f15; --night-2: #161d28; --night-line: rgba(255, 255, 255, .12); --night-ink: #eef1f6; --night-muted: #9aa5b6; }
.bar { min-height: 52px; background: var(--night); color: var(--night-ink); border-bottom-color: var(--night-line); }
.bar .brand { margin-right: 6px; font-size: 19px; font-weight: normal; letter-spacing: .04em; color: #fff; }
.bar label { color: var(--night-muted); }
.bar input[type=text] { padding: 3px 8px; color: var(--night-ink); background: var(--night-2); border: 1px solid rgba(255, 255, 255, .22); border-radius: 6px; }
/* listes de la barre : sans la flèche du système, un chevron fin ; les choix ouverts sur le même fond sombre */
body .bar select { -webkit-appearance: none; appearance: none; height: 30px; padding: 0 30px 0 10px; color: var(--night-ink); cursor: pointer;
              background: var(--night-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%239aa5b6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M4 6l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 9px center / 12px;
              border: 1px solid rgba(255, 255, 255, .18); border-radius: 6px; transition: border-color .15s, background-color .15s; }
body .bar select:hover { background-color: #1d2633; border-color: rgba(255, 255, 255, .32); }
body .bar select:focus, .bar input[type=text]:focus { border-color: #4db3ef; outline: none; box-shadow: 0 0 0 3px rgba(0, 119, 187, .3); }
.bar select option, .bar select optgroup { color: var(--night-ink); background: var(--night-2); }
.bar select optgroup { color: var(--night-muted); }
.bar button, .bar button.facade-rename, .bar a.button-link { color: var(--night-ink); background: transparent; border-color: rgba(255, 255, 255, .25); }
.bar button:hover, .bar button.facade-rename:hover, .bar a.button-link:hover { color: #fff; border-color: #4db3ef; }
.bar button.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.bar > a { color: var(--night-muted); }
.bar > a:hover { color: #fff; }
.bar .design-title { color: var(--night-ink); }
.bar .muted, .bar .ro-summary { color: var(--night-muted); }
.bar .l3-flag-button:hover { border-color: var(--night-line); background: rgba(255, 255, 255, .08); }
.bar .visitor-note { color: #8fcdf2; background: rgba(0, 119, 187, .2); }
.bar .signup-link { background: var(--accent); }
.bar .signup-link:hover { background: var(--accent); filter: brightness(1.12); }
.bar .l3-flag-list { color: var(--text); }   /* la liste des langues est claire : pas le texte clair de la barre */
.bar .l3-flag-list a { gap: 10px; padding: 6px 12px; }

/* listes des zones claires (panneau de droite, fenêtres) : même dessin que celles de la barre, en clair
   (:where : sans poids, la barre et les règles propres à une liste l'emportent) */
select:where(:not([multiple]):not([size])) { -webkit-appearance: none; appearance: none; min-height: 26px; padding: 2px 26px 2px 8px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%236b7482' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M4 6l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 7px center / 11px;
  border: 1px solid var(--line); border-radius: 5px; transition: border-color .15s, box-shadow .15s; }
select:where(:not([multiple]):not([size])):hover:not(:disabled) { border-color: #a9b2be; }
select:where(:not([multiple]):not([size])):focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(0, 119, 187, .2); }
select:disabled { cursor: default; opacity: .55; }
.bar button.facade-rename { height: 30px; width: 30px; padding: 0; border-radius: 6px; }

/* filtre des calques du gabarit (panels.js) : tous, ou seulement ceux qui sont affichés */
.tpl-filter { display: flex; align-items: center; gap: 6px; width: 100%; margin: 0 0 6px; padding: 4px 8px; font-size: 12px; text-align: left;
              color: var(--muted); background: transparent; border: 1px dashed var(--line); border-radius: 6px; }
.tpl-filter:hover { color: var(--accent); border-color: var(--accent); }
.tpl-filter.on { color: var(--accent); background: #e1f0fa; border-style: solid; border-color: #a6d1ea; }
.tpl-filter[hidden] { display: none; }
/* sélecteur publics / privés des calques du gabarit (administrateur) */
.tpl-scope { display: block; width: 100%; margin: 0 0 6px; padding: 3px 6px; font-size: 12px; color: var(--muted); background: #fff;
             border: 1px dashed var(--line); border-radius: 6px; }
.tpl-scope.on { color: var(--accent); background: #e1f0fa; border-style: solid; border-color: #a6d1ea; }
.tpl-scope[hidden] { display: none; }

/* repli d'un calque (panels.js, comme Inkscape) ; replié, il signale qu'il contient la sélection */
button.toggle.fold { display: inline-grid; place-content: center; width: 16px; height: 18px; padding: 0; color: #7d8794; font-size: 11px; }
button.toggle.fold:hover { color: var(--accent); }
.layer-row.has-sel { box-shadow: inset -3px 0 var(--accent); }

/* Import d'un gabarit (js/template-import.js) */
.ti-box .modal-head .ti-step { margin-left: 10px; color: var(--muted); }
.ti-box .modal-head .ti-file { margin-left: auto; color: var(--muted); font-size: .9em; }
.ti-drop { flex: 1; margin: 16px; border: 2px dashed var(--line); border-radius: 8px; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; padding: 24px; color: var(--muted); }
.ti-drop.over { border-color: var(--accent); color: var(--text); }
.ti-work { flex: 1; min-height: 0; display: grid; grid-template-columns: 400px 1fr; gap: 12px; padding: 10px 14px; }
.ti-left { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.ti-left .field { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.ti-left .field > span { min-width: 130px; }
.ti-left .field input, .ti-left .field select { flex: 1; }
.ti-size { margin: 2px 0 6px; color: var(--muted); }
.ti-table { border: 1px solid var(--line); border-radius: 4px; max-height: 420px; overflow: auto; }
.ti-table table { width: 100%; border-collapse: collapse; font-size: .92em; }
.ti-table th { position: sticky; top: 0; background: var(--panel); text-align: left; font-weight: normal; color: var(--muted); padding: 4px 6px; border-bottom: 1px solid var(--line); }
.ti-table td { padding: 3px 6px; border-bottom: 1px solid var(--line); }
.ti-table tr:hover td { background: rgba(0, 119, 187, .08); }
.ti-table td.ti-count { text-align: right; color: var(--muted); }
.ti-table td.ti-hidden { color: var(--muted); font-style: italic; }
.ti-table select { width: 100%; }
.ti-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; background: transparent; border: 1px solid var(--line); }
.ti-row-cut .ti-swatch, .ti-c-cut { background: #ff5252; }
.ti-row-placement .ti-swatch, .ti-c-placement { background: #29b6f6; }
.ti-row-frame .ti-swatch { background: #ffa726; }
.ti-row-generic .ti-swatch, .ti-row-freebsd .ti-swatch, .ti-row-logo .ti-swatch, .ti-c-mark { background: #fdd835; }
.ti-row-extra .ti-swatch, .ti-c-extra { background: #66bb6a; }
.ti-row-ignore td:not(:last-child) { opacity: .45; }
.ti-warn { color: #c62828; margin: 2px 0; }
.ti-measures { margin: 8px 0; padding-left: 18px; }
.ti-measures li { margin: 2px 0; }
.ti-view { min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.ti-tools { display: flex; align-items: center; gap: 10px; }
.ti-legend { display: flex; align-items: center; gap: 4px; font-size: .85em; color: var(--muted); }
.ti-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 8px; }
.ti-preview { flex: 1; width: 100%; min-height: 0; background: #11151c; border-radius: 4px; cursor: grab; touch-action: none; }
.ti-preview.ti-white { background: #fff; }
.ti-preview .ti-page { fill: none; stroke: #8a8f98; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.ti-preview .ti-layer * { vector-effect: non-scaling-stroke; }
.ti-preview .ti-role-cut * { fill: none !important; stroke: #ff5252 !important; stroke-width: 1px !important; }
.ti-preview .ti-role-placement * { fill: rgba(41, 182, 246, .15) !important; stroke: #29b6f6 !important; stroke-width: 1px !important; }
.ti-preview .ti-role-frame * { fill: none !important; stroke: #ffa726 !important; stroke-width: 1px !important; }
.ti-preview .ti-role-generic *, .ti-preview .ti-role-freebsd *, .ti-preview .ti-role-logo * { fill: rgba(253, 216, 53, .25) !important; stroke: #fdd835 !important; stroke-width: 1px !important; }
.ti-preview .ti-role-extra * { fill: rgba(102, 187, 106, .2) !important; stroke: #66bb6a !important; stroke-width: 1px !important; }
.ti-preview .ti-role-ignore { display: none; }
/* import des calques dans un design : vraies couleurs, pas de légende des rôles */
.ti-design .ti-legend { display: none; }
.ti-row-design .ti-swatch { background: #66bb6a; }
.ti-preview .ti-hl * { stroke-width: 3px !important; }
.ti-tip { margin: 0; font-size: .85em; color: var(--muted); }
.ti-foot { padding: 8px 14px; border-top: 1px solid var(--line); align-items: center; }
.ti-foot .error { color: #c62828; margin: 0; }

/* Mode « Gabarit » (administrateur) : contour, découpes et emplacements modifiables */
.tpl-mode-bar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: #fff4e0; border-bottom: 1px solid #f0c27a; font-size: .92em; }
.tpl-mode-bar[hidden] { display: none; }
.tpl-mode-bar .tpl-mode-draft { background: #f0c27a; color: #5a3a00; border-radius: 3px; padding: 0 6px; }
.tpl-mode-bar .tpl-mode-help { color: #6b5a3a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bar button.facade-rename.on { color: #fff; border-color: #f0a030; background: #b86e00; }
/* l'ancienne découpe et les anciens emplacements ne sont pas montrés : ce sont les objets des calques du mode */
.over.tpl-mode .holes, .over.tpl-mode [data-role="placement"] { display: none; }
.plate.tpl-mode [data-cut="hole"], .plate.tpl-mode mask [data-cut="hole"] { display: none !important; }   /* plus fort qu'un style="display:inline" du gabarit */

/* Fond du plan de travail (comme Inkscape) : damier (oui par défaut), couleur et opacité par-dessus ; réglé par
   applyDesk (editor.js), gardé dans localStorage « panelitor.desk ». Les découpes laissent voir ce fond. */
.scroller.desk-checker { background: linear-gradient(var(--desk-color), var(--desk-color)), repeating-conic-gradient(#c9c9c9 0% 25%, #f2f2f2 0% 50%) 0 0 / 16px 16px; background-attachment: local; }
.scroller.desk-plain { background: linear-gradient(var(--desk-color), var(--desk-color)), #ffffff; background-attachment: local; }
.desk-wrap { position: relative; }
.desk-pop { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 30; display: grid; gap: 8px; min-width: 240px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
.desk-pop[hidden] { display: none; }
.desk-pop label { display: flex; align-items: center; gap: 8px; }
.desk-pop label > span:first-child { min-width: 64px; }
.desk-pop input[type="range"] { flex: 1; }
#btn-desk.on { border-color: var(--accent); color: var(--accent); }
#desk-alpha-value { min-width: 3.4em; white-space: nowrap; text-align: right; }
