:root {
  --navy: #16202b;
  --accent: #059669;   /* één merkkleur, gelijk aan de site-CTA (emerald) */
  --light: #a7f3d0;
  --text: #1b2733;
  --line: #e3e8ee;
  --bg: #f4f6f9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- topbar ---------- */
.topbar {
  background: var(--navy);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  flex: 0 0 auto;
}
.topbar__logo { height: 34px; width: auto; display: block; }
.topbar__title { color: #fff; font-size: 15px; font-weight: 600; letter-spacing: .02em; }
.topbar__beta {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  border-radius: 999px;
  padding: 3px 8px;
  margin-left: 6px;
  vertical-align: 2px;
}

/* ---------- layout ---------- */
.layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

/* ---------- stage ---------- */
.stage {
  flex: 1 1 auto;
  position: relative;
  min-width: 0;
  background: #dfe9f2;
}
#viewport, #viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#viewport canvas { touch-action: none; }

.stage__vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 58%, rgba(18, 28, 40, .16) 100%);
}

.stage__views {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  flex-wrap: wrap;
  max-width: calc(100% - 32px);
  gap: 8px;
  z-index: 3;
}
.viewbtn {
  background: rgba(22, 32, 43, .82);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background .15s;
}
.viewbtn:hover { background: var(--accent); }
/* Na foto-ontgrendeling op mobiel: knop pulseert als duidelijke volgende stap. */
.viewbtn--cta { background: var(--accent); animation: viewbtnPulse 1.5s ease-in-out infinite; }
@keyframes viewbtnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, .55); }
  50%      { box-shadow: 0 0 0 7px rgba(5, 150, 105, 0); }
}
.foto-hint {
  position: absolute;
  top: 62px;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  max-width: min(90%, 320px);
  padding: 9px 15px;
  border-radius: 999px;
  background: rgba(22, 32, 43, .96);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
  opacity: 0;
  pointer-events: none;   /* nooit een tik op de knop eronder blokkeren */
  transition: opacity .25s ease, transform .25s ease;
  z-index: 6;
}
.foto-hint.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) { .viewbtn--cta { animation: none; } }

.stage__caption {
  position: absolute;
  left: 16px;
  bottom: 38px;
  z-index: 3;
  background: rgba(255, 255, 255, .88);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--navy);
  box-shadow: 0 2px 10px rgba(22, 32, 43, .12);
  backdrop-filter: blur(4px);
  max-width: calc(100% - 32px);
}
.stage__hint {
  position: absolute;
  left: 16px;
  bottom: 12px;
  z-index: 3;
  font-size: 11.5px;
  color: rgba(22, 32, 43, .55);
}

.stage__loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #dfe9f2;
  color: var(--navy);
  font-size: 14px;
  font-weight: 600;
  transition: opacity .4s;
}
.stage__loading.is-done { opacity: 0; pointer-events: none; }
.stage__loading span {
  width: 22px; height: 22px;
  border: 3px solid rgba(74, 141, 201, .25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- panel ---------- */
.panel {
  flex: 0 0 360px;
  background: #fff;
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 22px 22px 30px;
}
.panel__group { margin-bottom: 22px; }
.panel__label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--navy);
  margin-bottom: 10px;
}
.panel__label output { color: var(--accent); font-size: 14px; }
.panel__scale { display: flex; justify-content: space-between; font-size: 11px; color: #8b95a1; margin-top: 4px; }

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--fill, 11%), #e3e8ee var(--fill, 11%), #e3e8ee 100%);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(22,32,43,.25);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  cursor: pointer;
}

/* segmented buttons */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
#segRoof { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }  /* nette 2×2 */
#segRoof #btnLamellen { grid-column: 1 / -1; }                        /* 5e knop volle breedte, geen wees-knop */
.seg button {
  flex: 1 1 0;
  min-width: 44px;
  white-space: nowrap;
  padding: 9px 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
}
.seg button:hover { border-color: var(--accent); }
.seg button.is-active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.seg button:disabled {
  opacity: .45;
  cursor: not-allowed;
  text-decoration: line-through;
}

/* v2: keuze-opties gestapeld als leesbare kaarten i.p.v. dropdowns */
.seg--wrap { display: flex; flex-direction: column; gap: 8px; }
.seg--wrap button {
  flex: none;
  width: 100%;
  text-align: left;
  white-space: normal;
  padding: 13px 15px;
  font-size: 14px;
}
.seg--wrap button.is-active {
  background: #ecfdf5;
  border-color: var(--accent);
  color: var(--navy);
}
.panel__hint2 { margin: -2px 0 10px; font-size: 12.5px; color: #8b95a1; line-height: 1.4; }

/* v2 optiekaart-inhoud: swatch + titel + uitleg + badge */
.seg--wrap button { display: flex; align-items: center; gap: 12px; }
#segRoof.seg--wrap { display: flex; flex-direction: column; }   /* override id-grid */
.opt__sw { width: 40px; height: 40px; flex: none; border-radius: 9px; border: 1px solid rgba(22,32,43,.10); }
.opt__txt { display: flex; flex-direction: column; gap: 2px; line-height: 1.25; min-width: 0; }
.opt__txt b { font-weight: 700; font-size: 14px; }
.opt__txt small { font-weight: 400; font-size: 12px; color: #6b7480; white-space: normal; }
.seg--wrap button.is-active .opt__txt small { color: #3f7a63; }
.opt__badge { display: inline-block; font-size: 10px; font-weight: 700; color: #fff; background: var(--accent); padding: 2px 6px; border-radius: 999px; margin-left: 4px; vertical-align: middle; }
/* Kleur-swatch badge */
.swatches button { position: relative; }
.sw__badge { position: absolute; top: 5px; left: 5px; z-index: 1; font-size: 9px; font-weight: 700; color: #fff; background: var(--accent); padding: 2px 6px; border-radius: 999px; }

.panel__note {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #7a5b1e;
  background: #fdf6e5;
  border: 1px solid #f0e2bd;
  border-radius: 8px;
  padding: 10px 12px;
}
/* Neutrale "komt eraan"-notitie in de houtmodus (geen waarschuwing) */
.panel__note.hout-note { color: #5b6672; background: #f2f5f8; border-color: #dbe2ea; }

/* swatches */
.swatches { display: flex; gap: 8px; }
.swatches button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px 6px 10px;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.swatches button:hover { border-color: var(--accent); }
.swatches button.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(74,141,201,.25); }
.swatches i {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.08);
}
.swatches span { font-size: 12px; font-weight: 600; text-align: center; line-height: 1.25; }
.swatches small { display: block; color: #8b95a1; font-weight: 500; font-size: 10.5px; }

/* selects */
.field {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #4d5a68;
  margin-bottom: 12px;
}
.field select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.field select:focus { outline: none; border-color: var(--accent); }

/* toggle */
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.toggle input { display: none; }
.toggle__track {
  width: 44px; height: 25px;
  border-radius: 999px;
  background: #d4dae1;
  position: relative;
  transition: background .2s;
  flex: 0 0 auto;
}
.toggle__track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: transform .2s;
}
.toggle input:checked + .toggle__track { background: var(--accent); }
.toggle input:checked + .toggle__track::after { transform: translateX(19px); }

.panel__foot {
  font-size: 12px;
  color: #8b95a1;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 6px;
}

/* ---------- stapsgewijze bediening ---------- */
.panel__intro { margin-bottom: 16px; }
.panel__title { font-size: 20px; font-weight: 800; letter-spacing: -.01em; color: var(--navy); }
.panel__sub { font-size: 13px; color: #6b7681; margin-top: 3px; line-height: 1.45; }

.stepper__head { margin-bottom: 20px; }
.stepper__bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.stepper__bar span { display: block; height: 100%; width: 20%; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.stepper__meta { margin-top: 9px; font-size: 13px; color: #8b95a1; }
.stepper__meta b { color: var(--navy); font-weight: 700; }

.step { animation: stepIn .25s ease; }
@keyframes stepIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.stepper__nav { display: flex; gap: 10px; margin-top: 22px; }
.stepbtn {
  font-family: inherit; font-size: 15px; font-weight: 700;
  border-radius: 10px; padding: 14px 16px; min-height: 50px;
  cursor: pointer; border: 1.5px solid var(--line); background: #fff; color: var(--navy);
  transition: all .15s;
}
.stepbtn--back { flex: 0 0 auto; color: #5b6672; }
.stepbtn--back:hover { border-color: var(--accent); color: var(--navy); }
.stepbtn--next { flex: 1 1 auto; background: var(--accent); border-color: var(--accent); color: #fff; }
.stepbtn--next:hover { filter: brightness(1.06); }
.stepbtn--next.is-done { background: var(--navy); border-color: var(--navy); }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  body { overflow: auto; }
  .layout { flex-direction: column; }
  /* Kleiner 3D-vlak → meer ruimte voor het bedienpaneel (was 48vh/320px, paneel bleef ~282px). */
  .stage { flex: 0 0 auto; height: 40vh; min-height: 240px; }
  .panel { flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; border-left: 0; border-top: 1px solid var(--line); padding: 20px 18px 26px; }
  .stage__hint { display: none; }
  .stage__caption { bottom: 12px; font-size: 12px; }
  /* Touch: tap-targets ≥44px en 16px selects (voorkomt iOS focus-zoom) */
  .seg button { min-height: 44px; }
  .viewbtn { min-height: 44px; }
  .field select { font-size: 16px; }
  /* Op mobiel stuurt de sticky ouder-CTA de stappen aan (vc:next/vc:back) → verberg de interne
     stepper-nav zodat er precies één primaire "verder"-knop is en niks onder de vouw valt. */
  .stepper__nav { display: none; }
  /* Intro-kop + subtekst kosten schaarse paneelruimte op elke stap → verberg op mobiel. */
  .panel__intro { display: none; }
}
@media (prefers-reduced-motion: reduce) { .step { animation: none; } }
