/* Signalétique d'école : une couleur et une lettre par bâtiment. */
:root{
  --bg:#f5f6f8; --surface:#ffffff; --fg:#17202e; --muted:#5b6678; --line:#d5dae3; --ground:#e9ecf1;
  --road:#c9ced8; --road-edge:#aab1be; --green:#cfe6c8; --green-edge:#93c287; --accent:#2357d8; --danger:#c62f3a;
  --hl:#fff1a8; --sel:#ff7a00; --grid:rgba(23,32,46,.06);
  --display:"Archivo","Arial Narrow",Arial,sans-serif; --body:"IBM Plex Sans","Segoe UI",Arial,sans-serif; --mono:"IBM Plex Mono",Consolas,monospace;
  color-scheme:light;
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --bg:#11161f; --surface:#19202c; --fg:#e8ecf3; --muted:#9aa5b8; --line:#2c3545; --ground:#1d2430;
  --road:#3a4354; --road-edge:#4c566a; --green:#21382a; --green-edge:#3c6a49; --accent:#5b8cff; --danger:#ff6470;
  --hl:#5a4b00; --sel:#ffa040; --grid:rgba(232,236,243,.06); color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#11161f; --surface:#19202c; --fg:#e8ecf3; --muted:#9aa5b8; --line:#2c3545; --ground:#1d2430;
  --road:#3a4354; --road-edge:#4c566a; --green:#21382a; --green-edge:#3c6a49; --accent:#5b8cff; --danger:#ff6470;
  --hl:#5a4b00; --sel:#ffa040; --grid:rgba(232,236,243,.06); color-scheme:dark}
*{box-sizing:border-box}
html{padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}
body{margin:0;background:var(--bg);color:var(--fg);font-family:var(--body);font-size:15px;line-height:1.5}
[hidden]{display:none!important}
.wrap{max-width:1280px;margin:0 auto;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));padding-block:20px 40px}
.tete{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:12px 24px;padding-bottom:14px;border-bottom:2px solid var(--fg)}
.titres{min-width:0;flex:1 1 420px}
h1{font-family:var(--display);font-weight:800;font-size:clamp(24px,3.6vw,36px);line-height:1.05;margin:0;text-wrap:balance;letter-spacing:-.01em}
.sub{color:var(--muted);margin:4px 0 0;font-size:14px}
.tete input.inline{font:inherit;color:inherit;background:var(--surface);border:1.5px dashed var(--muted);border-radius:4px;padding:2px 6px;width:100%}
nav{display:flex;gap:6px;flex-wrap:wrap}
nav a{font-family:var(--display);font-weight:700;font-size:14px;text-decoration:none;color:var(--fg);padding:8px 14px;border:2px solid var(--fg);border-radius:4px}
nav a[aria-current="page"]{background:var(--fg);color:var(--bg)}
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,[tabindex]:focus-visible{outline:3px solid var(--accent);outline-offset:2px}

.barre{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding-top:12px}
.barre .edition-seule{display:inline-flex;flex-wrap:wrap;gap:8px}
body:not(.edition) .edition-seule{display:none!important}
body.edition #btn-modifier{display:none}
.statut{font-size:13px;color:var(--muted);margin-left:auto}
.statut.attente{color:var(--sel)} .statut.erreur{color:var(--danger);font-weight:600}
.btn{font-family:var(--display);font-weight:700;font-size:13px;padding:7px 12px;border:2px solid var(--fg);border-radius:4px;background:var(--surface);color:var(--fg);cursor:pointer;line-height:1.2}
.btn:hover{background:var(--ground)}
.btn:disabled{opacity:.4;cursor:default}
.btn-plein{background:var(--fg);color:var(--bg)} .btn-plein:hover{background:var(--fg);opacity:.88}
.btn.danger{border-color:var(--danger);color:var(--danger)}
.btn.petit{padding:3px 8px;font-size:12px;border-width:1.5px}
.alerte{margin-top:12px;padding:12px 14px;border:2px solid var(--danger);border-radius:6px;background:var(--surface);display:flex;flex-wrap:wrap;gap:10px;align-items:center}
section[data-view]{padding-top:18px}

/* ---- plan ---- */
.plan-grid{display:grid;grid-template-columns:minmax(0,1fr) 280px;gap:20px;align-items:start}
.svgbox{background:var(--surface);border:1px solid var(--line);border-radius:6px;overflow:auto;max-height:calc(100vh - 40px)}
.svgbox svg{display:block;width:100%;min-width:640px;height:auto;touch-action:none;user-select:none;-webkit-user-select:none}
body:not(.edition) .svgbox svg{touch-action:auto}
svg text{font-family:var(--body);fill:var(--fg)}
.s-sol{fill:var(--ground)}
.s-route{fill:var(--road);stroke:var(--road-edge);stroke-width:1.5}
.s-pelouse{fill:var(--green);stroke:var(--green-edge);stroke-width:1.5}
.s-ligne{fill:none;stroke:var(--green-edge);stroke-width:2}
.s-parking{fill:var(--surface);stroke:var(--road-edge);stroke-width:1.5;stroke-dasharray:6 4}
.s-bat{stroke:var(--fg);stroke-width:2}
.s-plein{fill:var(--fg)}
.s-cercle{fill:var(--surface);stroke:var(--line);stroke-width:1.5}
.t-muted{fill:var(--muted)}
.lettre{font-family:var(--display);font-weight:800}
.el{cursor:default}
body:not(.edition) .el.lien{cursor:pointer}
body:not(.edition) .el.lien:hover .s-bat{filter:brightness(1.12)}
body.edition .el{cursor:move}
.hit{fill:transparent}
.grille{fill:url(#grille)}
.sel-cadre{fill:none;stroke:var(--sel);stroke-width:1.5;stroke-dasharray:5 3;pointer-events:none}
.poignee{fill:var(--surface);stroke:var(--sel);stroke-width:2}
.poignee.coin-nw,.poignee.coin-se{cursor:nwse-resize} .poignee.coin-ne,.poignee.coin-sw{cursor:nesw-resize}
.poignee.bord-n,.poignee.bord-s{cursor:ns-resize} .poignee.bord-e,.poignee.bord-w{cursor:ew-resize}
.poignee.rot{cursor:grab;fill:var(--sel)}
.tige{stroke:var(--sel);stroke-width:1.5}

.cote{display:flex;flex-direction:column;gap:14px;min-width:0}
.cote h2{font-family:var(--display);font-weight:800;font-size:13px;letter-spacing:.12em;text-transform:uppercase;margin:0;color:var(--muted)}
.leg{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}
.leg a{display:grid;grid-template-columns:34px 1fr;gap:10px;align-items:center;text-decoration:none;color:var(--fg);padding:4px;border-radius:4px}
.leg a:hover{background:var(--surface)}
.tag{display:inline-grid;place-items:center;min-width:34px;height:34px;padding:0 4px;border-radius:4px;font-family:var(--display);font-weight:800;font-size:18px}
.leg small{display:block;color:var(--muted);font-size:12px;line-height:1.3}
.note{font-size:13px;color:var(--muted);border-left:3px solid var(--line);padding-left:10px;margin:0}

/* inspecteur */
.insp{background:var(--surface);border:1px solid var(--line);border-radius:6px;padding:12px;display:flex;flex-direction:column;gap:10px}
.ajouts{display:flex;flex-wrap:wrap;gap:6px}
.champ{display:flex;flex-direction:column;gap:3px;min-width:0}
.champ label,.insp .lbl{font-size:12px;font-weight:600;color:var(--muted)}
.champs4{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
.champs2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
input,select,textarea{font:inherit;font-size:14px;color:var(--fg);background:var(--bg);border:1.5px solid var(--line);border-radius:4px;padding:5px 7px;min-width:0;width:100%}
input[type=color]{padding:1px;height:32px}
input[type=checkbox]{width:auto}
textarea{resize:vertical;min-height:54px}
.case{display:flex;gap:6px;align-items:center;font-size:13px}
.insp .rangee{display:flex;flex-wrap:wrap;gap:6px}
.aide{font-size:12px;color:var(--muted);margin:0;line-height:1.4}
kbd{font-family:var(--mono);font-size:11px;border:1px solid var(--line);border-radius:3px;padding:0 4px;background:var(--bg)}

/* ---- détail ---- */
.finder{display:flex;flex-wrap:wrap;gap:10px 16px;align-items:center;background:var(--surface);border:1px solid var(--line);border-radius:6px;padding:14px 16px;margin-bottom:22px}
.finder label{font-family:var(--display);font-weight:700}
.finder input{font-family:var(--mono);font-size:16px;padding:8px 10px;border:2px solid var(--fg);width:170px}
#resultat{flex:1 1 260px;min-width:0;font-size:14px}
#resultat b{font-family:var(--mono)}
.det{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}
.card{background:var(--surface);border:1px solid var(--line);border-radius:6px;overflow:hidden;min-width:0;scroll-margin-top:16px}
.card.wide{grid-column:1/-1}
.card-h{display:flex;gap:14px;align-items:center;padding:14px 16px}
.card-h .big{font-family:var(--display);font-weight:800;font-size:40px;line-height:1;min-width:52px;text-align:center}
.card-h h3{font-family:var(--display);font-weight:800;font-size:20px;margin:0;line-height:1.15}
.card-h p{margin:2px 0 0;font-size:13px;opacity:.92}
.card-h .entete-ed{flex:1;display:grid;gap:6px;min-width:0}
.card-h .entete-ed input{background:rgba(255,255,255,.92);color:#17202e;border-color:transparent}
.card-h .big-ed{width:58px;text-align:center;font-family:var(--display);font-weight:800;font-size:26px;background:rgba(255,255,255,.92);color:#17202e;border-color:transparent}
.card-outils{display:flex;flex-wrap:wrap;gap:6px;align-items:center;padding:8px 16px;border-bottom:1px solid var(--line);background:var(--bg);font-size:13px}
.card-outils .champ{flex-direction:row;align-items:center;gap:6px}
.card-outils input[type=color]{width:44px}
.card-b{padding:14px 16px 16px;display:flex;flex-direction:column;gap:14px}
.floor{display:grid;grid-template-columns:110px minmax(0,1fr);gap:10px;align-items:start}
.floor>.fnom{font-family:var(--display);font-weight:700;font-size:13px;padding-top:5px;display:flex;flex-direction:column;gap:4px}
.floor>.fnom input{font-family:var(--display);font-weight:700;font-size:13px;padding:3px 5px}
.floor>.fnom .rangee{display:flex;gap:4px}
.rooms{display:flex;flex-wrap:wrap;gap:6px;min-height:36px;border-radius:4px}
.rooms.cible{outline:2px dashed var(--sel);outline-offset:3px}
.room{display:inline-flex;flex-direction:column;border:1.5px solid var(--line);border-radius:4px;padding:3px 8px;min-width:62px;background:var(--bg);text-align:left;font:inherit;color:inherit}
.room b{font-family:var(--mono);font-weight:600;font-size:14px}
.room i{font-style:normal;font-size:11.5px;color:var(--muted);line-height:1.25}
.room.service{border-style:dashed}
.room.escalier{border-color:var(--fg);background:var(--fg)} .room.escalier b,.room.escalier i{color:var(--bg)}
.room.hit{background:var(--hl);border-color:var(--fg)}
body.edition .room{cursor:grab}
body.edition .room:hover{border-color:var(--sel)}
.room.glisse{opacity:.35}
.room.avant{box-shadow:-4px 0 0 var(--sel)}
.room.ajout{border-style:dashed;color:var(--muted);justify-content:center;cursor:pointer;font-weight:600;font-size:13px}
.empty{color:var(--muted);font-size:14px;margin:0}
.todo{font-size:12.5px;color:var(--muted);margin:0;white-space:pre-line}
.todo::before{content:"À vérifier · ";font-weight:600;color:#d0601b}
.ajout-bat{margin-top:16px}
.sources,.pied{margin-top:24px;font-size:13px;color:var(--muted)}
.sources a{color:inherit}

dialog{border:2px solid var(--fg);border-radius:8px;background:var(--surface);color:var(--fg);padding:20px;width:min(440px,calc(100vw - 32px))}
dialog::backdrop{background:rgba(10,14,20,.5)}
dialog h2{font-family:var(--display);font-weight:800;font-size:20px;margin:0 0 6px}
dialog p{margin:0 0 12px;font-size:14px;color:var(--muted)}
dialog form{display:flex;flex-direction:column;gap:6px}
dialog label{font-size:13px;font-weight:600;margin-top:6px}
dialog .actions{display:flex;gap:8px;justify-content:flex-end;margin-top:14px;flex-wrap:wrap}
dialog .sep{flex:1}
.erreur{color:var(--danger)!important;font-weight:600}
.histo{list-style:none;margin:0;padding:0;max-height:50vh;overflow:auto;display:flex;flex-direction:column;gap:4px}
.histo li{display:flex;gap:8px;align-items:center;justify-content:space-between;padding:6px 8px;border:1px solid var(--line);border-radius:4px;font-size:13px}

@media (max-width:900px){.plan-grid{grid-template-columns:1fr}.det{grid-template-columns:1fr}.svgbox{max-height:none}}
@media (max-width:480px){.floor{grid-template-columns:1fr}.floor>.fnom{padding-top:0}.champs4{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;scroll-behavior:auto!important}}
/* ---- export PDF ---- */
#export{display:none}
@page{size:A4 portrait;margin:10mm}
@page paysage{size:A4 landscape;margin:9mm}
@media print{
  :root{--bg:#ffffff!important;--surface:#ffffff!important;--fg:#17202e!important;--muted:#4f5a6b!important;--line:#c9cfd9!important;--ground:#eef0f4!important;
    --road:#c9ced8!important;--road-edge:#9aa2b1!important;--green:#d6ebd0!important;--green-edge:#86b879!important;--hl:#ffffff!important;color-scheme:light}
  html,body{background:#fff!important;padding:0!important}
  body>.wrap,dialog{display:none!important}
  #export{display:block;color:var(--fg);font-size:10pt}
  *{-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .ex-plan{page:paysage;height:190mm;display:flex;flex-direction:column;gap:3mm;break-after:page}
  .ex-tete{display:flex;justify-content:space-between;align-items:flex-end;gap:8mm;border-bottom:1.5pt solid var(--fg);padding-bottom:2mm}
  .ex-tete h1{font-size:19pt}
  .ex-tete p{margin:1mm 0 0;font-size:9pt;color:var(--muted)}
  .ex-date{white-space:nowrap}
  .ex-corps{flex:1;min-height:0;display:grid;grid-template-columns:1fr 62mm;gap:5mm;align-items:start}
  .ex-corps svg{width:100%;height:auto;max-height:158mm;border:.75pt solid var(--line);border-radius:2mm;display:block}
  .ex-corps aside h2{font-family:var(--display);font-size:8.5pt;letter-spacing:.12em;text-transform:uppercase;color:var(--muted);margin:0 0 2mm}
  .ex-corps .leg{gap:1.6mm}
  .leg-l{display:grid;grid-template-columns:8mm 1fr;gap:2.5mm;align-items:center;font-size:9pt;line-height:1.25}
  .ex-corps .tag{min-width:8mm;height:8mm;font-size:12pt;border-radius:1mm}
  .ex-corps .leg small{font-size:7.5pt}
  .ex-corps .note{margin-top:3mm;font-size:8pt}
  .ex-pied{margin:0;font-size:7.5pt;color:var(--muted)}
  .ex-det .ex-tete{margin-bottom:4mm}
  .ex-det .det{grid-template-columns:repeat(2,minmax(0,1fr));gap:4mm}
  .ex-det .card{break-inside:avoid;border-color:var(--line);border-radius:2mm}
  .ex-det .card-h{padding:2.5mm 3.5mm;gap:3mm}
  .ex-det .card-h .big{font-size:20pt;min-width:9mm}
  .ex-det .card-h h3{font-size:12pt}
  .ex-det .card-h p{font-size:8pt}
  .ex-det .card-b{padding:3mm 3.5mm;gap:2.5mm}
  .ex-det .floor{grid-template-columns:20mm minmax(0,1fr);gap:2mm}
  .ex-det .floor>.fnom{font-size:8.5pt;padding-top:1mm}
  .ex-det .rooms{gap:1.2mm;min-height:0}
  .ex-det .room{min-width:12mm;padding:.6mm 1.8mm;border-width:.75pt;border-radius:1mm}
  .ex-det .room b{font-size:8.5pt}
  .ex-det .room i{font-size:6.8pt}
  .ex-det .todo,.ex-det .empty{font-size:7.5pt}
  .ex-det .ex-pied{margin-top:4mm}
}
