:root{color-scheme:dark;--ink:#090c12;--panel:rgba(13,18,27,.9);--line:rgba(255,255,255,.13);--accent:#42d6a4;--muted:#9aa5b4}
*{box-sizing:border-box}
html,body{height:100%;margin:0;background:var(--ink);font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;color:#fff}
body{overflow:hidden}.viewer-shell{height:100%}
.topbar{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;padding:0 24px;border-bottom:1px solid var(--line);background:#0d121b;z-index:5}
.brand{display:flex;align-items:center;gap:12px;color:inherit;text-decoration:none;width:max-content}.brand-mark{display:grid;place-items:center;width:42px;height:42px;border-radius:12px;background:var(--accent);color:#07100d;font-weight:900;letter-spacing:-.08em}.brand strong{display:block;font-size:17px}.brand small,.project-title small{display:block;color:var(--muted);font-size:12px;margin-top:2px}.project-title{text-align:center}.project-title h1{font-size:18px;margin:3px 0 0}.icon-button{justify-self:end;width:42px;height:42px;border:1px solid var(--line);border-radius:12px;background:#151c27;color:#fff;font-size:22px;cursor:pointer}
.stage{position:relative;width:100%;height:100%;min-height:0;background:radial-gradient(circle at 50% 45%,#1a2432 0,#0b0f16 70%)}canvas{display:block;width:100%;height:100%;touch-action:none}
.fullscreen-button{position:absolute;right:20px;top:20px;z-index:2}
.loading,.error{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;background:rgba(7,10,15,.92);z-index:3}.loading strong{font-size:18px}.loading span:last-child{color:var(--muted);font-size:14px}.spinner{width:38px;height:38px;border:3px solid rgba(255,255,255,.15);border-top-color:var(--accent);border-radius:50%;animation:spin .8s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.error{padding:30px;text-align:center;color:#ffb8b8}.error[hidden],.loading[hidden]{display:none}
.controls{position:absolute;left:20px;top:20px;width:260px;padding:17px;border:1px solid var(--line);border-radius:16px;background:var(--panel);box-shadow:0 16px 40px rgba(0,0,0,.3);backdrop-filter:blur(12px)}.control-heading{display:flex;justify-content:space-between;align-items:center;font-weight:700;margin-bottom:17px}.control-heading output{font-size:12px;color:var(--accent);font-weight:600}.controls label{display:block;font-size:13px;color:var(--muted);margin-bottom:8px}.controls input{width:100%;accent-color:var(--accent)}.button-row{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:15px}.button-row button{border:1px solid var(--line);border-radius:9px;padding:10px 8px;background:#161e2a;color:#fff;cursor:pointer;font-weight:600}.button-row button:hover,.icon-button:hover{border-color:var(--accent)}
.help{position:absolute;bottom:18px;left:50%;transform:translateX(-50%);display:flex;gap:18px;padding:9px 14px;border:1px solid var(--line);border-radius:999px;background:var(--panel);color:var(--muted);font-size:12px;white-space:nowrap}
@media(max-width:700px){.controls{left:10px;top:10px;width:220px}.fullscreen-button{right:10px;top:10px}.help{bottom:10px;gap:8px;font-size:11px}.help span:last-child{display:none}}

.section-control,.gaussian-control{margin-top:15px;padding-top:14px;border-top:1px solid var(--line)}.section-line{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:8px}.section-line .check-label{display:flex;align-items:center;gap:7px;margin:0;color:#fff;font-weight:600}.section-line .check-label input{width:auto}.section-line output{font-size:12px;color:var(--accent)}#section-height:disabled,#section-thickness:disabled,#gaussian-strength:disabled{opacity:.35}
.slice-line{margin-top:12px}.slice-line label{margin:0}

/* Identité iGlobaLogik + thème clair/sombre */
.stage{transition:background .2s ease}
.stage.light-mode{background:radial-gradient(circle at 50% 45%,#ffffff 0,#edf1f4 72%);--panel-local:rgba(255,255,255,.92);--text-local:#111827;--muted-local:#5f6b78;--line-local:rgba(17,24,39,.14)}
.stage.dark-mode{background:radial-gradient(circle at 50% 45%,#1a2432 0,#0b0f16 70%);--panel-local:rgba(13,18,27,.90);--text-local:#fff;--muted-local:#9aa5b4;--line-local:rgba(255,255,255,.13)}
.brand-badge{position:absolute;top:18px;left:50%;transform:translateX(-50%);z-index:2;text-align:center;pointer-events:none;user-select:none;padding:8px 16px;border-radius:12px;background:rgba(255,255,255,.82);border:1px solid rgba(0,0,0,.09);backdrop-filter:blur(8px)}
.brand-wordmark{font-size:25px;line-height:1;font-weight:800;letter-spacing:-1px;color:#111}.brand-i{font-weight:900}.brand-logik{font-weight:500}.brand-tagline{font-size:8px;letter-spacing:1.45px;margin-top:5px;color:#4b5563;font-weight:700}
.stage.dark-mode .brand-badge{background:rgba(8,12,18,.78);border-color:rgba(255,255,255,.14)}.stage.dark-mode .brand-wordmark{color:#fff}.stage.dark-mode .brand-tagline{color:#aeb8c5}
.stage.light-mode .controls,.stage.light-mode .help{background:var(--panel-local);color:var(--text-local);border-color:var(--line-local);box-shadow:0 12px 34px rgba(17,24,39,.12)}
.stage.light-mode .controls label,.stage.light-mode .help{color:var(--muted-local)}
.stage.light-mode .section-line .check-label,.stage.light-mode .theme-label{color:var(--text-local)}
.stage.light-mode .button-row button,.stage.light-mode .icon-button{background:#fff;color:#111827;border-color:var(--line-local)}
.stage.light-mode .fullscreen-button{background:rgba(255,255,255,.92);color:#111827;border-color:rgba(17,24,39,.14)}
.theme-control{margin-top:15px;padding-top:14px;border-top:1px solid var(--line)}
.stage.light-mode .theme-control{border-top-color:var(--line-local)}
.theme-label{display:flex!important;align-items:center;gap:8px!important;margin:0!important;font-weight:600;color:#fff!important}.theme-label input{width:auto!important}
@media(max-width:700px){.brand-badge{top:12px;max-width:46%;padding:7px 10px}.brand-wordmark{font-size:19px}.brand-tagline{font-size:6px;letter-spacing:.8px}.help span:first-child{display:none}}

/* Logo officiel iGlobaLogik */
.brand-badge{display:flex;align-items:center;gap:10px;text-align:left;padding:7px 14px 7px 9px}
.brand-logo{display:block;width:42px;height:42px;object-fit:contain;flex:0 0 auto}
.brand-text{min-width:0}
.brand-wordmark{font-family:"SF Pro Display",-apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,sans-serif;font-size:24px;font-weight:600;letter-spacing:-.7px;white-space:nowrap}
.brand-tagline{font-family:"SF Pro Display",-apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,sans-serif}
@media(max-width:700px){.brand-logo{width:34px;height:34px}.brand-wordmark{font-size:18px}.brand-badge{gap:7px;padding:6px 9px 6px 7px}}


/* Outils de mesure en vue de dessus */
.plan-overlay{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:1;overflow:visible}
.plan-tools{margin-top:15px;padding-top:14px;border-top:1px solid var(--line)}
.stage.light-mode .plan-tools{border-top-color:var(--line-local)}
.plan-tools-title{font-size:13px;font-weight:700;margin-bottom:9px;color:inherit}
.plan-tools-row{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.plan-tools button{min-height:38px;border:1px solid var(--line);border-radius:9px;padding:8px;background:#161e2a;color:#fff;cursor:pointer;font-weight:650}
.stage.light-mode .plan-tools button{background:#fff;color:#111827;border-color:var(--line-local)}
.plan-tools button:disabled{opacity:.38;cursor:not-allowed}
.plan-tools button.active{border-color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent);background:rgba(66,214,164,.12)}
.clear-tool{width:100%;margin-top:8px}
.plan-tool-status{font-size:11px;line-height:1.35;margin-top:8px;color:var(--muted)}
.stage.light-mode .plan-tool-status{color:var(--muted-local)}
.plan-overlay .measure-line{stroke:#e67e22;stroke-width:2;vector-effect:non-scaling-stroke}
.plan-overlay .measure-tick{stroke:#e67e22;stroke-width:2;vector-effect:non-scaling-stroke}
.plan-overlay .measure-point{fill:#fff;stroke:#e67e22;stroke-width:2;vector-effect:non-scaling-stroke}
.plan-overlay .elev-point{fill:#fff;stroke:#c2185b;stroke-width:2.5;vector-effect:non-scaling-stroke}
.plan-overlay .elev-cross{stroke:#c2185b;stroke-width:2;vector-effect:non-scaling-stroke}
.plan-overlay .label-bg{fill:rgba(17,24,39,.92);stroke:rgba(255,255,255,.25);stroke-width:1}
.stage.light-mode .plan-overlay .label-bg{fill:rgba(255,255,255,.96);stroke:rgba(17,24,39,.22)}
.plan-overlay .label-text{fill:#fff;font:600 12px "SF Pro Display",-apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,sans-serif}
.stage.light-mode .plan-overlay .label-text{fill:#111827}
.plan-overlay .label-sub{fill:#cbd5e1;font:500 10px "SF Pro Display",-apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,sans-serif}
.stage.light-mode .plan-overlay .label-sub{fill:#52606d}
.canvas-measure-mode{cursor:crosshair!important}
@media(max-width:700px){.plan-tools-row{grid-template-columns:1fr}.plan-tools button{min-height:36px}.plan-tool-status{display:none}}

/* Colorisation altimétrique */
.height-color-control{margin-top:15px;padding-top:14px;border-top:1px solid var(--line)}
.stage.light-mode .height-color-control{border-top-color:var(--line-local)}
.height-color-label{display:flex!important;align-items:center;gap:8px!important;margin:0!important;font-weight:600;color:#fff!important}
.height-color-label input{width:auto!important}
.stage.light-mode .height-color-label{color:var(--text-local)!important}
.height-color-legend{margin-top:10px}
.height-gradient{height:9px;border-radius:999px;background:linear-gradient(90deg,#052ef2 0%,#00d9ff 25%,#00c733 50%,#ffe000 75%,#f20d05 100%);border:1px solid rgba(255,255,255,.18)}
.stage.light-mode .height-gradient{border-color:rgba(17,24,39,.16)}
.height-legend-values{display:flex;justify-content:space-between;margin-top:4px;font-size:10px;color:var(--muted)}
.stage.light-mode .height-legend-values{color:var(--muted-local)}

.height-range-controls{margin-top:10px;display:grid;gap:6px}
.height-range-controls .section-line{margin-top:2px}
.height-range-controls input[type="range"]{width:100%}
.height-range-controls output{font-variant-numeric:tabular-nums}
.height-range-controls .check-label{margin-top:4px}

.cloud-selector{display:grid;gap:6px;margin:0 0 12px}
.cloud-selector select{width:100%;padding:9px 10px;border-radius:8px;border:1px solid var(--line-local);background:var(--panel-local);color:var(--text-local);font:inherit;font-weight:600}

.clipbox-control{margin-top:12px;padding-top:10px;border-top:1px solid var(--line-local)}
.clip-axis{margin-top:8px;padding:8px;border:1px solid var(--line-local);border-radius:8px}
.clip-axis input[type="range"]{width:100%}
.clip-axis>label{font-size:11px;opacity:.72;display:block;margin-top:4px}
.mini-button{padding:5px 8px;font-size:11px}
.height-line{stroke:#8b5cf6;stroke-width:2;stroke-dasharray:5 3}
.height-point{fill:#8b5cf6;stroke:#fff;stroke-width:1.5}
.area-polygon{fill:rgba(16,185,129,.18);stroke:#10b981;stroke-width:2}
.area-pending{fill:none;stroke:#10b981;stroke-width:2;stroke-dasharray:5 4}
.area-point{fill:#10b981;stroke:#fff;stroke-width:1.5}

.controls{max-height:calc(100% - 28px);overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;scrollbar-gutter:stable;padding-right:8px}
.clipbox-control{margin-top:12px;padding-top:0;border-top:1px solid var(--line-local)}
.clipbox-control summary{cursor:pointer;user-select:none;font-weight:650;padding:11px 0}
.clipbox-inner{padding:0 2px 10px}

/* ViewCube v1.3.3 — vrai cube 3D, synchronisé avec la caméra */
.viewcube-wrap{
  position:absolute;right:16px;top:68px;width:118px;height:150px;z-index:8;
  user-select:none;pointer-events:auto;
}
.vc-stage{
  position:relative;width:90px;height:92px;margin:0 auto;
  perspective:360px;
}
.viewcube-object{
  position:absolute;left:15px;top:14px;width:60px;height:60px;
  transform-style:preserve-3d;
  transform:rotateX(-24deg) rotateY(38deg);
  transition:transform .08s linear;
}
.vc3-face{
  position:absolute;left:0;top:0;width:60px;height:60px;
  display:flex;align-items:center;justify-content:center;
  border:1px solid rgba(71,85,105,.72);
  background:rgba(248,250,252,.94);color:#475569;
  font:700 8px/1 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  cursor:pointer;padding:0;backface-visibility:hidden;
}
.vc3-face:hover,.vc3-face:focus-visible{
  background:#dbeafe;outline:2px solid rgba(59,130,246,.48);outline-offset:0;
}
.vc3-front{transform:translateZ(30px)}
.vc3-back{transform:rotateY(180deg) translateZ(30px)}
.vc3-right{transform:rotateY(90deg) translateZ(30px)}
.vc3-left{transform:rotateY(-90deg) translateZ(30px)}
.vc3-top{transform:rotateX(90deg) translateZ(30px)}
.vc3-bottom{transform:rotateX(-90deg) translateZ(30px)}
.vc3-iso{
  position:absolute;right:0;top:0;width:24px;height:24px;border:1px solid rgba(71,85,105,.55);
  border-radius:6px;background:rgba(248,250,252,.96);color:#64748b;cursor:pointer;font-size:12px;
}
.vc3-iso:hover,.vc3-iso:focus-visible{background:#dbeafe;outline:2px solid rgba(59,130,246,.45)}
.viewring{
  position:absolute;left:4px;right:4px;bottom:2px;height:38px;
  border:1px dashed rgba(100,116,139,.55);border-radius:50%;
  display:flex;align-items:center;justify-content:space-between;padding:0 8px;
}
.viewring button{
  width:30px;height:30px;border:1px solid rgba(148,163,184,.55);border-radius:50%;
  background:rgba(248,250,252,.96);color:#475569;cursor:pointer;font-size:16px;
}
.viewring button:hover,.viewring button:focus-visible{background:#dbeafe;outline:2px solid rgba(59,130,246,.45)}
.stage.dark-mode .vc3-face,.stage.dark-mode .vc3-iso,.stage.dark-mode .viewring button{
  background:rgba(30,41,59,.96);color:#f8fafc;border-color:rgba(148,163,184,.65)
}
@media(max-width:700px){
  .viewcube-wrap{right:10px;top:62px;transform:scale(.88);transform-origin:top right}
}

/* Bascule clair / sombre : uniquement soleil / lune */
.theme-control{display:flex;align-items:center;justify-content:flex-start}
.theme-toggle{
  position:relative;display:inline-grid;grid-template-columns:34px 34px;align-items:center;
  width:68px;height:34px;border:1px solid var(--line-local);border-radius:18px;
  overflow:hidden;cursor:pointer;background:rgba(148,163,184,.16)
}
.theme-toggle input{position:absolute;opacity:0;pointer-events:none}
.theme-icon{
  display:flex;align-items:center;justify-content:center;width:34px;height:34px;
  font-size:19px;line-height:1;transition:background .15s ease,color .15s ease,opacity .15s ease
}
.theme-sun{background:#fff;color:#d97706}
.theme-moon{background:#111827;color:#f8fafc;opacity:.55}
.theme-toggle:has(input:checked) .theme-sun{opacity:.45}
.theme-toggle:has(input:checked) .theme-moon{opacity:1}
.theme-toggle:focus-within{outline:2px solid rgba(59,130,246,.55);outline-offset:2px}

/* Le changement de thème s'applique à toute la fenêtre du viewer */
.stage.light-mode{background:#f6f8fa;color:#111827}
.stage.dark-mode{background:#09111d;color:#f8fafc}
.stage.dark-mode .controls{background:rgba(15,23,42,.94);color:#f8fafc;border-color:rgba(148,163,184,.35)}
.stage.dark-mode .controls label,
.stage.dark-mode .controls strong,
.stage.dark-mode .controls output,
.stage.dark-mode .plan-tools-title,
.stage.dark-mode .plan-tool-status{color:#f8fafc}
.stage.dark-mode .clip-axis{border-color:rgba(148,163,184,.35)}
.stage.dark-mode .clipbox-control{border-color:rgba(148,163,184,.35)}
.stage.dark-mode .brand-badge{color:#f8fafc}
