* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #0c1220;
  color: #edf3ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ha-lab-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10050;
  margin: 0;
  padding: 6px 12px;
  background: #6b1d12;
  color: #fff4e5;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  pointer-events: none;
}

body.ha-lab {
  padding-top: 28px;
}

body.ha-xr .ha-lab-banner {
  display: none;
}

button,
input {
  font: inherit;
}

#app {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  height: 100vh;
  min-height: 0;
  transition: grid-template-columns 0.22s ease;
}

body.panel-collapsed #app {
  grid-template-columns: minmax(0, 0) 1fr;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100vh;
  min-width: 0;
  min-height: 0;
  padding: 28px;
  background: linear-gradient(180deg, #121a2e 0%, #0e1526 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  overflow-y: auto;
  overscroll-behavior: contain;
  transition: opacity 0.18s ease, transform 0.22s ease, width 0.22s ease, padding 0.22s ease;
}

body.panel-collapsed .panel {
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  min-width: 0;
  max-width: 0;
  width: 0;
  padding: 0;
  border: 0;
  transform: translateX(-12px);
}

.panel-toolbar {
  display: none;
}

.panel-collapse-btn {
  display: none;
}

/* Collé au bord droit du panneau outils (position JS via syncPanelEdgeTogglePosition). */
.panel-edge-toggle {
  position: fixed;
  z-index: 80;
  top: 50%;
  left: 0;
  right: auto;
  transform: translateY(-50%);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  padding: 18px 8px;
  min-height: 148px;
  max-width: 40px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-left: 0;
  border-radius: 0 12px 12px 0;
  background: rgba(12, 18, 32, 0.94);
  color: #edf3ff;
  cursor: pointer;
  pointer-events: auto;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 22px rgba(0, 0, 0, 0.35);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transition: left 0.22s ease, transform 0.22s ease, border-radius 0.22s ease;
}

/* Panneau ouvert : centré sur la couture (bord droit du panneau). */
body:not(.panel-collapsed) .panel-edge-toggle {
  border-left: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  transform: translate(-50%, -50%);
}

body.panel-collapsed .panel-edge-toggle {
  border-left: 0;
  border-radius: 0 12px 12px 0;
  transform: translateY(-50%);
}

.panel-edge-toggle[hidden] {
  display: none !important;
}

.panel-edge-toggle:hover {
  background: rgba(18, 28, 48, 0.98);
  padding-right: 10px;
}

.panel-edge-toggle__label {
  transform: rotate(180deg);
  white-space: nowrap;
}

/* Compat anciennes classes */
.panel-expand-fab {
  position: fixed;
  z-index: 40;
  top: 50%;
  left: max(0px, env(safe-area-inset-left, 0px));
  transform: translateY(-50%);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  padding: 18px 8px;
  min-height: 148px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-left: 0;
  border-radius: 0 12px 12px 0;
  background: rgba(12, 18, 32, 0.92);
  color: #edf3ff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  backdrop-filter: blur(10px);
  box-shadow: 4px 0 22px rgba(0, 0, 0, 0.35);
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.panel-expand-fab[hidden] {
  display: none !important;
}

.panel-expand-fab:hover {
  background: rgba(18, 28, 48, 0.98);
  padding-right: 10px;
}

.panel-expand-fab__chev {
  display: none;
}

.panel-expand-fab__label {
  transform: rotate(180deg);
  white-space: nowrap;
}

body.ha-mobile-fs .panel-edge-toggle,
body.ha-mobile-fs .panel-expand-fab,
body.ha-mobile-fs .panel-toolbar {
  display: none !important;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.lang-switch label {
  margin: 0;
  color: #b8c7e4;
  font-size: 13px;
  font-weight: 600;
}

.lang-switch select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #edf3ff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.brand-logo-link {
  display: block;
  flex-shrink: 0;
  border-radius: 16px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.brand-logo-link:hover,
.brand-logo-link:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(118, 228, 247, 0.18);
  outline: none;
}

.brand-logo-link img {
  display: block;
  width: 58px;
  height: 58px;
  object-fit: contain;
  padding: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.brand-site-link {
  color: #b8f0f8;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.brand-site-link:hover,
.brand-site-link:focus-visible {
  color: #76e4f7;
  text-decoration: underline;
  outline: none;
}

.eyebrow {
  margin: 0;
  color: #76e4f7;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
}

h2 {
  margin-bottom: 12px;
  font-size: 18px;
}

.intro,
.hint {
  color: #aab8d4;
  line-height: 1.5;
}

.model-form {
  display: grid;
  gap: 8px;
}

label {
  color: #d7e2f7;
  font-weight: 700;
}

.url-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

input {
  min-width: 0;
  padding: 12px 14px;
  color: #edf3ff;
  background: #0b1020;
  border: 1px solid #2d3957;
  border-radius: 12px;
  outline: none;
}

input:focus {
  border-color: #76e4f7;
  box-shadow: 0 0 0 3px rgba(118, 228, 247, 0.15);
}

button {
  padding: 12px 16px;
  color: #07111f;
  font-weight: 800;
  background: #76e4f7;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

button:hover {
  background: #9bf0ff;
}

button.secondary {
  width: 100%;
  color: #edf3ff;
  background: #22304f;
}

button.secondary:hover {
  background: #2d3d63;
}

.card {
  padding: 18px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
}

.tool-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}

.tool-selector legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  color: #d7e2f7;
  font-weight: 800;
}

.tool-selector label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
}

.tool-selector input {
  min-width: auto;
  accent-color: #76e4f7;
}

.axis-lock {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 10px;
  padding: 10px 12px;
  background: rgba(118, 228, 247, 0.1);
  border: 1px solid rgba(118, 228, 247, 0.24);
  border-radius: 12px;
}

.axis-lock legend {
  grid-column: 1 / -1;
  color: #d7e2f7;
  font-weight: 800;
}

.axis-lock label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #dce7fb;
  font-size: 13px;
}

.axis-lock input {
  min-width: auto;
  accent-color: #76e4f7;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.scale-calibration {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
}

.scale-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.scale-row input {
  width: 100%;
}

.scale-row button {
  white-space: nowrap;
}

.measurements-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding-left: 0;
  color: #dce7fb;
  list-style: none;
}

.measurements-list:empty {
  display: none;
}

.measurements-list li {
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  font-weight: 800;
}

.measurement-title {
  margin-bottom: 8px;
}

.measurement-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.measurement-actions button {
  padding: 7px 9px;
  color: #edf3ff;
  font-size: 12px;
  font-weight: 800;
  background: #22304f;
  border-radius: 9px;
}

.measurement-actions button:hover {
  background: #2d3d63;
}

.distance {
  margin-bottom: 14px;
  color: #76e4f7;
  font-size: 22px;
  font-weight: 900;
}

.status {
  margin: auto 0 0;
  padding: 12px 14px;
  color: #aab8d4;
  background: rgba(0, 0, 0, 0.24);
  border-radius: 12px;
}

.viewer-wrap {
  position: relative;
  height: 100vh;
  min-width: 0;
  overflow: hidden;
}

#app:fullscreen,
#app:-webkit-full-screen,
html:fullscreen,
html:-webkit-full-screen {
  width: 100%;
  height: 100%;
  max-height: none;
  background: #0c1220;
}

html:fullscreen body,
html:-webkit-full-screen body,
html:fullscreen #app,
html:-webkit-full-screen #app,
#app:fullscreen .viewer-wrap,
#app:-webkit-full-screen .viewer-wrap,
#app:fullscreen #viewer,
#app:-webkit-full-screen #viewer,
html:fullscreen .viewer-wrap,
html:-webkit-full-screen .viewer-wrap,
html:fullscreen #viewer,
html:-webkit-full-screen #viewer {
  height: 100%;
}

#viewer {
  display: block;
  width: 100%;
  height: 100vh;
}

.embed-viewer {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  background: #0c1220;
}

.embed-viewer iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.measure-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.measure-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.measure-svg line {
  stroke: #ffd166;
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.55));
}

.measure-svg circle {
  fill: #76e4f7;
  stroke: #07111f;
  stroke-width: 2;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.55));
}

.measure-svg circle.measure-end {
  fill: #ffd166;
}

.measure-svg circle.measure-middle {
  fill: #ff6b9d;
}

.measure-labels {
  position: absolute;
  inset: 0;
}

.measure-overlay-label {
  position: absolute;
  padding: 7px 10px;
  color: #07111f;
  font-weight: 900;
  background: #ffd166;
  border-radius: 999px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
  white-space: nowrap;
}

.measure-point-label {
  position: absolute;
  min-width: 24px;
  padding: 3px 6px;
  color: #edf3ff;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  background: rgba(7, 17, 31, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  transform: translate(8px, -140%);
  white-space: nowrap;
}

.viewer-wrap.has-embed #viewer {
  visibility: hidden;
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#pc-splat-xr {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}

body.ha-ss-pc-xr #pc-splat-xr {
  display: block;
  pointer-events: auto;
}

body.ha-ss-pc-xr #embed-viewer {
  visibility: hidden;
  pointer-events: none;
}

body.ha-xr .viewer-wrap.has-embed #viewer {
  visibility: visible;
  pointer-events: auto;
}

body.ha-xr .embed-viewer {
  visibility: hidden;
  pointer-events: none;
}

.panel-head {
  position: relative;
}

.panel-tuto-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 100%;
  margin: 0 0 12px;
  padding: 8px 10px;
  color: #07111f;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  background: #f5c400;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  cursor: pointer;
}

.panel-tuto-btn__line {
  display: block;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.panel-tuto-btn:hover {
  background: #ffd633;
}

.viewer-help {
  position: absolute;
  left: 50%;
  /* Même hauteur que la barre d’icônes Sketchfab (bas) */
  bottom: max(10px, calc(env(safe-area-inset-bottom, 0px) + 8px));
  z-index: 3;
  padding: 8px 12px;
  color: #dce7fb;
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
  background: rgba(5, 10, 20, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  transform: translateX(-50%);
  pointer-events: none;
}

.vr-dock {
  position: fixed;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: max(10px, env(safe-area-inset-right, 0px));
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: auto;
  max-width: none;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
  background: none !important;
  border: none;
  box-shadow: none;
}

.vr-dock__row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

.vr-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 40px;
  height: 40px;
  padding: 0 12px 0 6px;
  color: #07111f;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: #f5c400;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 9px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  pointer-events: auto;
}

.vr-button__icon {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
  background: transparent;
  flex-shrink: 0;
}

.vr-button__label {
  white-space: nowrap;
  line-height: 1;
}

.vr-button.is-text {
  padding: 0 12px;
  color: #07111f;
  background: #f5c400;
  border-color: rgba(255, 255, 255, 0.22);
}

.vr-button.is-text .vr-button__icon {
  display: none;
}

.vr-button::after {
  content: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 2;
  width: max-content;
  max-width: min(220px, 55vw);
  margin: 0;
  padding: 0;
  color: #ffffff;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: 0;
  text-align: right;
  white-space: normal;
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  text-shadow: 0 1px 2px #000, 0 0 6px #000;
  pointer-events: none;
}

.vr-button:hover::after,
.vr-button:focus-visible::after,
.vr-button[aria-pressed="true"]::after,
body.ha-viewer-fs .vr-button::after,
#app:fullscreen .vr-button::after,
#app:-webkit-full-screen .vr-button::after,
.viewer-wrap:fullscreen .vr-button::after {
  content: attr(data-vr-tip);
}

.vr-button:hover:not(:disabled) {
  background: #ffd633;
}

.vr-button:disabled {
  cursor: not-allowed;
  opacity: 1;
  filter: none;
}

.vr-live-status {
  max-width: min(380px, 72vw);
  margin: 8px 0 0;
  padding: 8px 10px;
  color: #fff8d6;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  text-align: right;
  text-shadow: 0 1px 2px #000, 0 0 8px #000;
  pointer-events: none;
  white-space: pre-wrap;
}

.vr-live-status[hidden] {
  display: none !important;
}

body.ha-vr-off .vr-button,
.vr-button[hidden] {
  display: none !important;
}

.vr-button[aria-pressed="true"] {
  background: #76e4f7;
  color: #07111f;
  border-color: rgba(255, 255, 255, 0.22);
}

.vr-fs-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 9px;
  background: rgba(8, 14, 28, 0.82);
  color: #edf3ff;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
}

.vr-fs-button[hidden] {
  display: none !important;
}

.vr-fs-button:hover {
  background: rgba(18, 28, 48, 0.95);
}

/* Mobile mesure : barre dédiée. */
body.ha-mobile-fs .vr-fs-button {
  display: none;
}

body.ha-embed .vr-dock {
  top: max(10px, env(safe-area-inset-top, 0px));
  right: max(10px, env(safe-area-inset-right, 0px));
}

body.ha-embed .vr-dock,
.viewer-wrap.has-embed .vr-dock {
  display: flex;
}

.embed-viewer.ha-sf-vr-nudge::after {
  content: "Casque Sketchfab ↓";
  position: absolute;
  right: 8px;
  bottom: 52px;
  z-index: 8;
  padding: 8px 10px;
  color: #07111f;
  font-size: 13px;
  font-weight: 800;
  background: #f5c400;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .vr-button {
    padding: 0 10px 0 5px;
    font-size: 12px;
  }
  .vr-button.is-text {
    padding: 8px 10px;
  }
}

body.ha-xr .viewer-help {
  white-space: normal;
  max-width: min(420px, 70vw);
}

.model-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 14, 28, 0.78);
  backdrop-filter: blur(2px);
}

/* Fly / pilote PC : au-dessus de Config VR (sinon barre invisible). */
body.ha-salon-pc-pilot .model-loading,
body.ha-fly-passenger .model-loading {
  z-index: 100;
  pointer-events: none;
}

.fly-load-hud {
  position: fixed;
  left: 50%;
  top: 1rem;
  transform: translateX(-50%);
  z-index: 10060;
  width: min(420px, calc(100vw - 2rem));
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: rgba(12, 16, 24, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #f3ebe0;
  font: 600 14px/1.35 "Segoe UI", "Helvetica Neue", sans-serif;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.fly-load-hud[hidden] {
  display: none !important;
}
.fly-load-hud.is-error {
  border-color: rgba(240, 120, 100, 0.7);
  background: rgba(48, 18, 14, 0.94);
}
.fly-load-hud.is-ok {
  border-color: rgba(120, 200, 140, 0.55);
}
.fly-load-hud__title {
  margin: 0 0 0.45rem;
}
.fly-load-hud__track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
}
.fly-load-hud__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, #c4a35a, #e8d19a);
  transition: width 0.2s ease;
}
.fly-load-hud.is-indeterminate .fly-load-hud__fill {
  width: 35%;
  animation: fly-load-indeterminate 1.1s ease-in-out infinite;
}
@keyframes fly-load-indeterminate {
  0% { left: 0; width: 28%; }
  50% { left: 40%; width: 40%; }
  100% { left: 0; width: 28%; }
}
.fly-load-hud__meta {
  margin: 0.4rem 0 0;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.85;
}

.model-loading[hidden] {
  display: none !important;
}

.model-loading__box {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  width: min(320px, 86%);
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  text-align: center;
}

.model-loading__label {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(232, 238, 248, 0.92);
}

/* Barre façon Sketchfab : piste + fill fluide + reflet qui glisse */
.model-loading__track {
  position: relative;
  width: 100%;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.model-loading__fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1da0f2 0%, #5cc8ff 55%, #9fe0ff 100%);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.45);
  transition: width 0.28s ease-out;
  will-change: width, transform;
}

.model-loading__fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 100%
  );
  transform: translateX(-120%);
  animation: ha-model-bar-shine 1.15s ease-in-out infinite;
}

/* Mode indéterminé : segment qui va-et-vient (comme Sketchfab avant %) */
.model-loading.is-indeterminate .model-loading__fill {
  width: 34% !important;
  transition: none;
  animation: ha-model-bar-slide 1.25s ease-in-out infinite;
}

.model-loading.is-indeterminate .model-loading__fill::after {
  animation: none;
  opacity: 0.35;
}

@keyframes ha-model-bar-shine {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(120%);
  }
}

@keyframes ha-model-bar-slide {
  0% {
    left: -34%;
  }
  50% {
    left: 100%;
  }
  100% {
    left: -34%;
  }
}

.model-loading__meta {
  margin: 0;
  min-height: 1.1em;
  font-size: 12px;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

.salon-vr-gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0;
  padding: 28px 22px;
  border: 0;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(42, 78, 110, 0.55), transparent 55%),
    rgba(6, 12, 22, 0.92);
  color: #e8eef5;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  font: inherit;
  text-align: center;
}

.salon-vr-gate.is-hidden,
.salon-vr-gate[hidden] {
  display: none !important;
}

.salon-vr-gate__title {
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.salon-vr-gate__code {
  display: block;
  margin: 0.4rem 0 0.15rem;
  padding: 0.5rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(242, 238, 230, 0.35);
  background: rgba(12, 16, 22, 0.55);
  font-size: clamp(1.4rem, 5.5vw, 2.05rem);
  font-weight: 700;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
  color: #f2eee6;
}

.salon-vr-gate__code[hidden] {
  display: none;
}

.salon-vr-gate__hint {
  max-width: 22rem;
  font-size: 1.05rem;
  line-height: 1.35;
  color: #c5d4e4;
}

.salon-vr-gate__load {
  margin-top: 10px;
  max-width: 24rem;
  font-size: 0.92rem;
  color: #9eb2c6;
}

.salon-vr-gate__bar {
  display: block;
  width: min(280px, 78vw);
  height: 8px;
  margin-top: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.salon-vr-gate__fill {
  display: block;
  height: 100%;
  width: 8%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5aa0d6, #8fd0ff);
  transition: width 0.2s ease;
}

.salon-vr-gate.is-indeterminate .salon-vr-gate__fill {
  width: 40% !important;
  animation: ha-model-bar-slide 1.4s ease-in-out infinite;
}

body.ha-salon-pc-pilot .viewer-help {
  display: none;
}

body.ha-salon-pc-pilot #vr-live-status {
  display: block !important;
  position: absolute;
  left: 12px;
  bottom: 72px;
  z-index: 8;
  max-width: min(420px, 90%);
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(8, 14, 28, 0.72);
  color: #d7e6f5;
  font-size: 13px;
}

/* Playlist pilote — fixed au-dessus des overlays (loading z=100). */
.ha-fly-pilot-playlist {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: min(340px, 92vw);
  pointer-events: none;
}

.ha-fly-pilot-playlist__toggle,
.ha-fly-pilot-playlist__panel,
.ha-fly-pilot-playlist__btn,
.ha-fly-pilot-playlist__narr,
.ha-fly-pilot-playlist__narr-btn {
  pointer-events: auto;
}

.ha-fly-pilot-playlist__toggle {
  border: 1px solid rgba(143, 191, 122, 0.45);
  border-radius: 10px;
  background: rgba(12, 18, 12, 0.92);
  color: #e8f5de;
  font: 600 13px/1.2 "Segoe UI", system-ui, sans-serif;
  padding: 8px 12px;
  cursor: pointer;
}

.ha-fly-pilot-playlist__panel {
  width: min(320px, 90vw);
  max-height: min(70vh, 520px);
  overflow: auto;
  border-radius: 12px;
  background: rgba(8, 12, 8, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 10px;
  margin-top: 8px;
  color: #e8e4dc;
  font: 13px/1.35 "Segoe UI", system-ui, sans-serif;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}

.ha-fly-pilot-playlist__msg {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 0 8px;
  min-height: 1.2em;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(20, 14, 12, 0.96);
  border: 1px solid rgba(208, 120, 104, 0.35);
  font-size: 12px;
  color: #c9c4b8;
  font-weight: 600;
}

.ha-fly-pilot-playlist__msg.is-err {
  color: #ffb4a8;
  border-color: rgba(255, 120, 100, 0.55);
}

.ha-fly-pilot-playlist__label {
  margin: 0 0 8px;
  color: #b8b3a6;
  font-size: 12px;
}

.ha-fly-pilot-playlist__narr {
  width: min(320px, 90vw);
  margin: 8px 0 0;
  padding: 8px 8px 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(8, 12, 8, 0.92);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.ha-fly-pilot-playlist__narr-label {
  margin: 0 0 6px;
  font-size: 11px;
  color: #c4a35a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ha-fly-pilot-playlist__narr-actions {
  display: flex;
  gap: 6px;
  margin: 0 0 8px;
}

.ha-fly-pilot-playlist__narr-btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(143, 191, 122, 0.2);
  color: #e8f5de;
  font: 11px/1.2 "Segoe UI", system-ui, sans-serif;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.ha-fly-pilot-playlist__narr-btn.is-stop {
  background: rgba(208, 120, 104, 0.22);
  color: #f0d4ce;
}

.ha-fly-pilot-playlist__narr-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.ha-fly-pilot-playlist__narr-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.ha-fly-pilot-playlist__narr-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8fbf7a, #c4a35a);
  transition: width 0.35s linear;
}

.ha-fly-pilot-playlist__narr-time {
  margin: 4px 0 0;
  font-size: 11px;
  color: #b8b3a6;
  font-variant-numeric: tabular-nums;
}

.ha-fly-pilot-playlist__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ha-fly-pilot-playlist__list li {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ha-fly-pilot-playlist__list li:first-child {
  border-top: 0;
}

.ha-fly-pilot-playlist__btn {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 8px 6px;
  cursor: pointer;
}

.ha-fly-pilot-playlist__btn:hover,
.ha-fly-pilot-playlist__btn.is-active {
  background: rgba(143, 191, 122, 0.18);
  color: #e8f5de;
}

body.ha-embed .ha-fly-pilot-playlist {
  z-index: 10001;
}

/* Popup carte (embed sans Fly) : Config invisible. Hub Fly = embed+fly → inchangé. */
body.ha-embed:not(.ha-fly) #salon-pc-config {
  display: none !important;
}

.salon-pc-config {
  position: fixed;
  top: 56px;
  right: 12px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.salon-pc-config__toggle {
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  background: rgba(12, 22, 36, 0.88);
  color: #e8eef5;
  font: 600 13px/1.2 system-ui, sans-serif;
  cursor: pointer;
}

.salon-pc-config__panel {
  width: min(280px, 82vw);
  max-height: min(70vh, 560px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(8, 14, 28, 0.92);
  color: #d7e6f5;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  scrollbar-width: thin;
}

.salon-pc-config__sky {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 12px;
}

.salon-pc-config__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
  margin: 0 0 10px;
  font-size: 12px;
}

.salon-pc-config__row input[type='range'] {
  grid-column: 1 / -1;
  width: 100%;
}

.salon-pc-config__check {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  margin: 0 0 8px;
}

.salon-pc-config__orient {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 12px;
}

.salon-pc-config__orient-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.salon-pc-config__orient-row button {
  border: 0;
  border-radius: 6px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #e8eef5;
  font: 600 11px/1 system-ui, sans-serif;
  cursor: pointer;
}

.salon-pc-config__orient-row button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.salon-pc-config__hint {
  margin: 0;
  font-size: 11px;
  color: #9eb2c6;
}

.salon-pc-config__salon-btn {
  flex: 1 1 auto;
  font-weight: 600;
  background: #1a3a4a !important;
  color: #e8f4fa !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(8px);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  width: min(720px, 100%);
  max-height: min(780px, 88vh);
  overflow-y: auto;
  padding: 28px;
  background: #111a2e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.modal-card h2 {
  margin-bottom: 18px;
  font-size: 28px;
}

.modal-card h3 {
  margin: 22px 0 8px;
  color: #76e4f7;
}

.modal-card ul {
  margin: 0;
  padding-left: 22px;
  color: #dce7fb;
  line-height: 1.6;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 42px;
  height: 42px;
  padding: 0;
  color: #edf3ff;
  font-size: 28px;
  line-height: 1;
  background: #22304f;
}

.modal-card--video {
  width: min(960px, 100%);
  max-height: 90vh;
  padding: 20px 20px 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-card--video h2 {
  margin: 0 48px 14px 0;
  font-size: clamp(18px, 3vw, 24px);
}

.tuto-video-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
  border-radius: 14px;
}

.tuto-yt-host {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.tuto-yt-host iframe {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  border: 0;
}

@media (max-width: 840px) {
  #app {
    grid-template-columns: 1fr;
  }

  body.panel-collapsed #app {
    grid-template-columns: 1fr;
    grid-template-rows: 0 1fr;
  }

  body.panel-collapsed .panel {
    height: 0;
    min-height: 0;
    min-width: 0;
    max-width: none;
    width: auto;
    padding: 0;
    border: 0;
    transform: none;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  #viewer,
  .embed-viewer {
    height: 62vh;
  }

  /* Mobile : même ancrage (bord droit du panneau), onglet plus compact. */
  .panel-edge-toggle,
  body:not(.panel-collapsed) .panel-edge-toggle,
  body.panel-collapsed .panel-edge-toggle {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 0;
    max-height: min(42vh, 220px);
    width: auto;
    max-width: 34px;
    padding: 12px 5px;
    font-size: 11px;
    letter-spacing: 0.02em;
    right: auto;
    box-shadow: 0 0 16px rgba(0, 0, 0, 0.4);
  }

  body:not(.panel-collapsed) .panel-edge-toggle {
    border-radius: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.16);
    transform: translate(-50%, -50%);
  }

  body.panel-collapsed .panel-edge-toggle {
    border-left: 0;
    border-radius: 0 10px 10px 0;
    transform: translateY(-50%);
  }

  .panel-edge-toggle__label,
  body:not(.panel-collapsed) .panel-edge-toggle__label {
    transform: rotate(180deg);
    max-height: min(36vh, 190px);
    overflow: hidden;
  }
}

/* Mobile : plein écran paysage (outil Mesurer) */
.ha-rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  padding: 28px 22px;
  text-align: center;
  background: rgba(8, 12, 22, 0.94);
  color: #edf3ff;
  font-size: 16px;
  line-height: 1.45;
}

.ha-rotate-hint__icon {
  font-size: 42px;
  line-height: 1;
  opacity: 0.9;
}

body.ha-mobile-fs .ha-rotate-hint {
  display: none;
}

@media (max-width: 900px) and (orientation: portrait) {
  body.ha-mobile-fs .ha-rotate-hint {
    display: flex;
  }
}

body.ha-mobile-fs {
  overflow: hidden;
  background: #0c1220;
}

body.ha-mobile-fs #app {
  display: block;
  height: 100dvh;
  width: 100%;
  position: relative;
}

body.ha-mobile-fs .viewer-wrap {
  position: absolute;
  inset: 0;
  height: 100% !important;
  min-height: 100dvh;
}

body.ha-mobile-fs #viewer,
body.ha-mobile-fs .embed-viewer {
  height: 100% !important;
  min-height: 100dvh;
}

body.ha-mobile-fs .viewer-help {
  bottom: max(10px, calc(env(safe-area-inset-bottom, 0px) + 8px));
  left: 50%;
  right: auto;
  max-width: min(52vw, 360px);
  font-size: 11px;
  opacity: 0.95;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.ha-mobile-fs .panel {
  position: absolute;
  z-index: 30;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(340px, 78vw);
  height: 100dvh;
  max-height: 100dvh;
  padding: 14px 14px 18px;
  gap: 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 0;
  transform: translateX(-105%);
  transition: transform 0.22s ease;
  box-shadow: 8px 0 28px rgba(0, 0, 0, 0.35);
}

body.ha-mobile-fs.ha-mobile-fs--tools-open .panel {
  transform: translateX(0);
}

body.ha-mobile-fs .panel-head h1,
body.ha-mobile-fs .panel-head .intro,
body.ha-mobile-fs .brand-text .eyebrow {
  display: none;
}

body.ha-mobile-fs .brand {
  margin-bottom: 6px;
}

body.ha-mobile-fs .brand-logo-link img {
  width: 44px;
  height: 44px;
}

body.ha-mobile-fs .model-form {
  display: none;
}

.ha-mobile-fs-bar {
  display: none;
}

body.ha-mobile-fs .ha-mobile-fs-bar {
  display: flex;
  position: absolute;
  z-index: 35;
  top: max(8px, env(safe-area-inset-top, 0px));
  left: max(8px, env(safe-area-inset-left, 0px));
  right: max(8px, env(safe-area-inset-right, 0px));
  gap: 8px;
  pointer-events: none;
}

body.ha-mobile-fs .ha-mobile-fs-bar > * {
  pointer-events: auto;
}

body.ha-mobile-fs .ha-mobile-fs-bar button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(12, 18, 32, 0.82);
  color: #edf3ff;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(8px);
}

body.ha-mobile-fs .ha-mobile-fs-exit {
  border-color: rgba(245, 196, 0, 0.55);
  color: #ffe9a8;
  background: rgba(20, 28, 44, 0.95);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

body.ha-mobile-fs .ha-mobile-fs-distance {
  margin-left: auto;
  align-self: center;
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  color: #9be7ff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}

/* Embed popup / fiche : remplir l’iframe, panneau en overlay */
html.ha-embed,
body.ha-embed {
  width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

body.ha-embed #app {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
}

body.ha-embed .viewer-wrap {
  width: 100%;
  height: 100%;
  min-height: 0;
}

body.ha-embed #viewer,
body.ha-embed .embed-viewer {
  width: 100%;
  height: 100%;
  min-height: 0;
}

body.ha-embed .embed-viewer iframe {
  width: 100%;
  height: 100%;
  min-height: 0;
}

body.ha-embed .viewer-help {
  display: none !important;
}

body.ha-splat-mode .embed-viewer iframe {
  border: 0;
  width: 100%;
  height: 100%;
  background: #0c1220;
}

#splat-publish-card input[type='file'] {
  display: block;
  width: 100%;
  margin-top: 6px;
  color: #d5def0;
  font-size: 13px;
}

.viewer-wrap.has-embed .viewer-help {
  display: none !important;
}

body.ha-embed .panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 30;
  width: min(300px, 86%);
  height: auto;
  max-height: 100%;
  padding: 14px 14px 18px;
  gap: 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 8px 0 28px rgba(0, 0, 0, 0.45);
  transform: none;
}

body.ha-embed.panel-collapsed .panel {
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  min-width: 0;
  max-width: 0;
  width: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
}

body.ha-embed .panel-head h1,
body.ha-embed .panel-head .intro,
body.ha-embed .brand-text .eyebrow,
body.ha-embed .model-form {
  display: none !important;
}

body.ha-embed .brand {
  margin: 0 0 8px;
}

body.ha-embed .brand-logo-link img {
  height: 28px;
  width: auto;
}

body.ha-embed .panel-edge-toggle {
  top: 50%;
  right: auto;
  min-height: 96px;
  max-height: min(42vh, 220px);
  max-width: 34px;
  padding: 12px 6px;
  font-size: 11px;
}

body.ha-embed:not(.panel-collapsed) .panel-edge-toggle {
  border-radius: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
  transform: translate(-50%, -50%);
}

body.ha-embed.panel-collapsed .panel-edge-toggle {
  border-left: 0;
  border-radius: 0 10px 10px 0;
  transform: translateY(-50%);
}

/* Fly — confirmation hub pilote (étape 1) */
.fly-pilot-hub {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 80;
  width: min(440px, calc(100% - 1.5rem));
  pointer-events: none;
}
.fly-pilot-hub__card {
  pointer-events: auto;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  background: rgba(18, 14, 10, 0.92);
  border: 1px solid rgba(243, 235, 224, 0.18);
  color: #f3ebe0;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.fly-pilot-hub__ok {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: #c8e6a0;
}
.fly-pilot-hub__detail {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
  color: #e8dcc8;
}
.fly-pilot-hub__hint {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: #b9a890;
  line-height: 1.35;
}
.fly-pilot-hub__err {
  margin: 0.6rem 0 0;
  color: #f0a0a0;
  font-size: 0.88rem;
}
.fly-pilot-hub__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.fly-pilot-hub__row .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid rgba(243, 235, 224, 0.2);
  background: #2a2218;
  color: #f3ebe0;
  font: inherit;
}
.fly-pilot-hub__row .btn.primary {
  background: #5a7a3a;
  border-color: #7aa050;
}
body.ha-fly-pilot-hub #tools-panel,
body.ha-fly-pilot-hub .ha-mobile-fs-bar,
body.ha-fly-pilot-hub #salon-vr-gate,
body.ha-fly-pilot-hub .salon-vr-gate {
  display: none !important;
}


