:root {
  --navy: #16202b;
  --accent: #4a8dc9;
  --light: #a9d4f0;
  --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;
  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); }

.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 button { flex: 1 1 45%; }   /* 4 dakvarianten → nette 2×2-grid */
.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;
}

.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;
}

/* 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;
}

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  body { overflow: auto; }
  .layout { flex-direction: column; }
  .stage { flex: 0 0 auto; height: 54vh; min-height: 340px; }
  .panel { flex: 1 1 auto; border-left: 0; border-top: 1px solid var(--line); }
  .stage__hint { display: none; }
  .stage__caption { bottom: 12px; font-size: 12px; }
  .topbar__logo { height: 28px; }
}
