:root {
  --fond: #f6f4ef;
  --papier: #ffffff;
  --encre: #1f2328;
  --gris: #5f6670;
  --ligne: #e3dfd6;
  --accent: #2c5f5a;
  --accent-clair: #e4efed;
  --alerte: #a8562b;
  --alerte-clair: #f8e9df;
  --tuile: #b8603a;
  --voisin: #cfcac0;
  --bandea: #2c5f5a;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fond); color: var(--encre);
  font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif; font-size: 16px; line-height: 1.5; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
header { background: var(--papier); border-bottom: 1px solid var(--ligne); position: sticky; top: 0; z-index: 10; }
header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 6px; }
.marque { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--accent); }
.marque img { height: 34px; display: block; }
.marque span { font-weight: 600; letter-spacing: 2px; text-transform: uppercase; font-size: 14px; }
h1 { font-size: 22px; margin: 0; font-weight: 600; letter-spacing: .2px; }
.titre p { margin: 2px 0 10px; color: var(--gris); font-size: 14px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
.onglet { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 12px 12px; font: inherit; font-size: 15px; color: var(--gris); cursor: pointer; }
.onglet.actif { color: var(--encre); border-bottom-color: var(--accent); font-weight: 600; }
.onglet:hover { color: var(--encre); }
main .page { display: none; }
main .page.actif { display: block; }
h2 { font-size: 24px; font-weight: 600; margin: 36px 0 12px; }
h3 { font-size: 17px; font-weight: 600; margin: 24px 0 8px; }
p.chapeau { color: var(--gris); max-width: 760px; margin-top: 0; }
.petit { font-size: 13px; color: var(--gris); }
code { background: var(--accent-clair); padding: 1px 5px; border-radius: 3px; font-size: 90%; }

/* viewer */
.viewer { position: relative; height: calc(100vh - 92px); min-height: 520px; background: #dfe7ec; }
#c3d { width: 100%; height: 100%; display: block; }
.panneau { position: absolute; top: 14px; left: 14px; width: 270px; background: rgba(255,255,255,.94); border: 1px solid var(--ligne); border-radius: 8px; padding: 10px 12px; font-size: 13px; backdrop-filter: blur(4px); }
.panneau .bloc { padding: 8px 0; border-top: 1px solid var(--ligne); }
.panneau .bloc:first-child { border-top: 0; padding-top: 2px; }
.etiquette { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--gris); margin-bottom: 6px; }
.etiquette span { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--encre); margin-left: 6px; }
.panneau label { display: block; margin: 4px 0; }
.panneau input[type=range] { width: 100%; margin: 2px 0 0; accent-color: var(--accent); }
.panneau label span { color: var(--gris); }
.segment { display: flex; border: 1px solid var(--ligne); border-radius: 6px; overflow: hidden; }
.segment button { flex: 1; border: 0; background: #fff; padding: 6px; font: inherit; cursor: pointer; color: var(--gris); }
.segment button.actif { background: var(--accent); color: #fff; }
.segment button:disabled { cursor: not-allowed; color: #aaa; }
.raccourcis { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.raccourcis button { border: 1px solid var(--ligne); background: #fff; border-radius: 5px; padding: 4px 8px; font: inherit; font-size: 12px; cursor: pointer; }
.raccourcis button:hover { border-color: var(--accent); }
.case { display: flex; align-items: center; gap: 6px; }
.legende { position: absolute; bottom: 12px; left: 14px; right: 14px; display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--encre); background: rgba(255,255,255,.85); padding: 6px 10px; border-radius: 6px; width: max-content; max-width: calc(100% - 28px); }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -2px; margin-right: 4px; }
.sw.tuile { background: var(--tuile); } .sw.terrasse { background: #bcae8f; } .sw.parcelle { background: #d33; }
.sw.bandea { background: var(--bandea); } .sw.voisin { background: var(--voisin); }
.notes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding-top: 20px; padding-bottom: 30px; }
.carte { background: var(--papier); border: 1px solid var(--ligne); border-radius: 8px; padding: 16px 18px; }
.carte h3 { margin-top: 0; }
.carte p:last-child { margin-bottom: 0; }
.carte.accent { border-top: 3px solid var(--accent); }
.carte .num { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; margin-bottom: 8px; }
.trois { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 12px 0 8px; }
.grille-faits { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 10px 0 20px; }
.fait { background: var(--papier); border: 1px solid var(--ligne); border-radius: 8px; padding: 12px 14px; }
.fait .k { font-size: 12px; color: var(--gris); text-transform: uppercase; letter-spacing: .5px; }
.fait .v { font-size: 20px; font-weight: 600; margin: 2px 0; }
.fait .s { font-size: 12px; color: var(--gris); }
.tab { width: 100%; border-collapse: collapse; background: var(--papier); border: 1px solid var(--ligne); border-radius: 8px; overflow: hidden; font-size: 14px; }
.tab th, .tab td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--ligne); vertical-align: top; }
.tab th { background: #f1efe9; font-weight: 600; }
.tab tr:last-child td { border-bottom: 0; }
.tab td.ref { color: var(--gris); white-space: nowrap; font-size: 13px; }
.liste li { margin: 6px 0; }
.simu { display: grid; grid-template-columns: 1fr 1.2fr; gap: 20px; margin: 16px 0 30px; }
.colonne { background: var(--papier); border: 1px solid var(--ligne); border-radius: 8px; padding: 16px 18px; }
.colonne h3:first-child { margin-top: 0; }
.colonne label { display: block; margin: 10px 0; font-size: 14px; }
.colonne label .val { float: right; color: var(--gris); }
.colonne input[type=range] { width: 100%; accent-color: var(--accent); }
.colonne input[type=number] { width: 120px; font: inherit; padding: 4px 6px; border: 1px solid var(--ligne); border-radius: 5px; }
.colonne select { width: 100%; font: inherit; padding: 5px 6px; border: 1px solid var(--ligne); border-radius: 5px; margin-top: 4px; background: #fff; }
.colonne small { display: block; color: var(--gris); margin-top: 3px; }
.lien { background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; font-size: 13px; padding: 0; }
.apreciser { display: inline-block; background: var(--alerte-clair); color: var(--alerte); border-radius: 4px; font-size: 11px; padding: 1px 6px; vertical-align: middle; margin-left: 4px; }
.resultat .total { font-size: 28px; font-weight: 600; }
.resultat .ligne { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--ligne); font-size: 14px; }
.resultat .ligne b { font-weight: 600; }
.resultat .ligne.total-l { border-bottom: 0; font-size: 16px; }
.scenario { border: 1px solid var(--ligne); border-radius: 8px; padding: 12px 14px; margin: 12px 0; }
.scenario.meilleur { border-color: var(--accent); background: var(--accent-clair); }
.scenario h4 { margin: 0 0 6px; font-size: 15px; }
.scenario .ecart { font-size: 13px; color: var(--gris); }
.scenario .ecart b { color: var(--alerte); }
.scenario.meilleur .ecart b { color: var(--accent); }
.barre { height: 8px; background: #e9e5dc; border-radius: 4px; overflow: hidden; margin: 6px 0; }
.barre i { display: block; height: 100%; background: var(--accent); }
.alerte { background: var(--alerte-clair); color: var(--alerte); padding: 8px 10px; border-radius: 6px; font-size: 13px; margin-top: 8px; }
.ok { background: var(--accent-clair); color: var(--accent); padding: 8px 10px; border-radius: 6px; font-size: 13px; margin-top: 8px; }
main section { padding-bottom: 50px; }
@media (max-width: 900px) {
  .trois, .notes, .simu { grid-template-columns: 1fr; }
  .grille-faits { grid-template-columns: 1fr 1fr; }
  .viewer { height: 70vh; }
  .panneau { width: 220px; font-size: 12px; }
  .legende { display: none; }
}

/* hero */
.hero { background: #f6f4f0; text-align: center; padding: 48px 20px 40px; border-bottom: 1px solid var(--ligne); }
.hero-logo { width: min(640px, 90vw); display: block; margin: 0 auto 18px; }
.hero-sous { max-width: 640px; margin: 0 auto 26px; color: var(--gris); font-size: 17px; }
.hero-chiffres { display: flex; justify-content: center; gap: 36px; flex-wrap: wrap; margin-bottom: 28px; }
.hero-chiffres div { display: flex; flex-direction: column; }
.hero-chiffres b { font-size: 26px; font-weight: 600; color: var(--accent); }
.hero-chiffres span { font-size: 13px; color: var(--gris); }
.hero-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.bouton { background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: 6px; padding: 10px 18px; font: inherit; font-size: 15px; cursor: pointer; }
.bouton.secondaire { background: #fff; color: var(--accent); }
.bouton:hover { filter: brightness(1.08); }
.galerie { columns: 3; column-gap: 14px; margin: 14px 0 10px; }
.galerie figure { break-inside: avoid; margin: 0 0 14px; background: var(--papier); border: 1px solid var(--ligne); border-radius: 8px; overflow: hidden; }
.galerie img { width: 100%; display: block; aspect-ratio: var(--ratio, 4 / 3); object-fit: cover; }
.galerie figcaption { padding: 8px 12px 10px; font-size: 13px; color: var(--gris); }
.galerie figcaption b { color: var(--encre); font-weight: 600; display: block; }
.galerie.plans img { object-fit: contain; background: #fff; }
/* onglet Avant-projet */
.deux-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 10px 0 8px; }
.deux-col .tab td.s { text-align: right; white-space: nowrap; }
.deux-col .tab tr.total td { font-weight: 600; background: var(--accent-clair); }
.questions { max-width: 860px; padding-left: 22px; }
.questions li { margin-bottom: 8px; }
.statut { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.statut.ok { margin: 0; padding: 1px 8px; }
.statut.alerte { margin: 0; padding: 1px 8px; }
.statut.neutre { background: var(--ligne); color: var(--encre); }
.hyp { display: inline-block; font-size: 11px; color: var(--alerte); border: 1px solid var(--alerte); border-radius: 10px; padding: 0 6px; margin-left: 4px; vertical-align: 1px; }
@media (max-width: 900px) { .deux-col { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .galerie { columns: 2; } .hero-chiffres { gap: 20px; } }
@media (max-width: 560px) { .galerie { columns: 1; } }

/* thèmes sombres : bis (vert noir du logo) et verte (vert profond de l'accent) */
:root[data-theme="bis"] {
  --fond: #1f2a28; --papier: #273431; --encre: #f3f1ec; --gris: #b8c2bd; --ligne: #3a4744;
  --accent: #9fd3c4; --accent-clair: #2f433e; --alerte: #e3a27a; --alerte-clair: #3f3330; --voisin: #6a7570;
  --controle: #2f3b38; --voile: rgba(31,42,40,.92); --sur-accent: #1f2a28;
}
:root[data-theme="vert"] {
  --fond: #163a34; --papier: #1d4740; --encre: #f4f1e8; --gris: #bcd3cb; --ligne: #2e5c54;
  --accent: #e6c88a; --accent-clair: #25534b; --alerte: #f0a77c; --alerte-clair: #4a3b2e; --voisin: #7d948d;
  --controle: #22524a; --voile: rgba(22,58,52,.92); --sur-accent: #163a34;
}
:root:is([data-theme="bis"],[data-theme="vert"]) body, :root:is([data-theme="bis"],[data-theme="vert"]) header { background: var(--fond); color: var(--encre); }
:root:is([data-theme="bis"],[data-theme="vert"]) .hero { background: var(--fond); border-bottom-color: var(--ligne); }
:root:is([data-theme="bis"],[data-theme="vert"]) .tab th { background: var(--controle); }
:root:is([data-theme="bis"],[data-theme="vert"]) :is(.segment button, .raccourcis button, .bouton.secondaire, .colonne select, .colonne input[type=number]) { background: var(--controle); color: var(--encre); border-color: var(--ligne); }
:root:is([data-theme="bis"],[data-theme="vert"]) :is(.segment button.actif, .bouton) { background: var(--accent); color: var(--sur-accent); border-color: var(--accent); }
:root:is([data-theme="bis"],[data-theme="vert"]) .bouton.secondaire { background: var(--controle); color: var(--accent); }
:root:is([data-theme="bis"],[data-theme="vert"]) .carte .num { color: var(--sur-accent); }
:root:is([data-theme="bis"],[data-theme="vert"]) :is(.panneau, .legende) { background: var(--voile); color: var(--encre); }
:root:is([data-theme="bis"],[data-theme="vert"]) .barre { background: var(--ligne); }
:root:is([data-theme="bis"],[data-theme="vert"]) :is(.marque img.clair, .hero-logo.clair) { display: none; }
:root:not([data-theme="bis"]):not([data-theme="vert"]) :is(.marque img.sombre, .hero-logo.sombre) { display: none; }
.theme-toggle { background: none; border: 1px solid var(--ligne); border-radius: 20px; padding: 4px 12px; font: inherit; font-size: 12px; color: var(--gris); cursor: pointer; margin-left: 8px; }
.theme-toggle:hover { color: var(--encre); border-color: var(--accent); }

/* visite à pied dans la maquette */
.visite-piece { font-size: 18px; font-weight: 700; line-height: 1.2; margin-top: 2px; text-transform: capitalize; }
#visite-plan { width: 100%; height: auto; display: block; border: 1px solid var(--ligne); border-radius: 6px; cursor: crosshair; margin-top: 4px; }
#visite-panneau .segment button { font-size: 12px; }
#visite-panneau .petit { font-size: 12px; color: var(--gris); }
.viewer.en-visite canvas#c3d { cursor: grab; touch-action: none; outline: none; }
.visite-pad { position: absolute; right: 22px; bottom: 60px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.55); border: 1px solid var(--ligne); touch-action: none; }
.visite-pad i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: var(--accent); opacity: .85; }
@media (pointer: fine) { .visite-pad { display: none !important; } }
@media (pointer: coarse) { #visite-aide { display: none; } }
