/* ============================================================
   DACH Terrassen Systeme – 3D-Konfigurator
   Standalone Fullscreen-App. Desktop-first, tauglich auf
   Tablet/Laptop, vereinfacht (aber stabil) auf dem Handy.
   ============================================================ */

:root {
  --ink: #1D1D1D;
  --ink-soft: #33312D;
  --paper: #FFFFFF;
  --stone: #F6F4EF;
  --stone-2: #ECE8E0;
  --line: #E2DDD2;
  --muted: #6B675F;
  --gold-1: #C08C28;
  --gold-2: #CB982F;
  --gold-3: #E3B04B;
  --gold-grad: linear-gradient(115deg, #C08C28 0%, #E3B04B 52%, #CB982F 100%);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 2px 10px rgba(29, 29, 29, 0.08);
  --shadow-md: 0 12px 34px rgba(29, 29, 29, 0.16);
  --panel-w: 372px;
  --topbar-h: 60px;
  --font: "Segoe UI", "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow-x: clip;
  max-width: 100%;
}

body.k3-body {
  font-family: var(--font);
  color: var(--ink);
  background: #0e1116;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font: inherit; cursor: pointer; color: inherit; }
a { color: inherit; }

/* ---------- App-Grid ---------- */
.k3-app {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-columns: minmax(0, 1fr);
  height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

/* ---------- Topbar ---------- */
.k3-topbar {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  background: var(--gold-grad);
  color: #fff;
  padding-left: 0.9rem;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.25);
  z-index: 20;
  min-width: 0;
  max-width: 100%;
}

.k3-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: #fff;
  padding-right: 0.6rem;
  flex: 0 0 auto;
}
.k3-brand img { height: 32px; width: auto; display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); }
.k3-brand b { font-weight: 800; letter-spacing: 0.02em; }
.k3-brand span { font-size: 0.78rem; opacity: 0.9; font-weight: 600; }
.k3-brand-txt { display: flex; flex-direction: column; line-height: 1.05; }

.k3-tabs {
  display: flex;
  align-items: stretch;
  gap: 0.15rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.k3-tabs::-webkit-scrollbar { display: none; }

.k3-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 600;
  font-size: 0.94rem;
  padding: 0 1rem;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.k3-tab .k3-tab-ico { width: 20px; height: 20px; opacity: 0.9; }
.k3-tab .k3-tab-num {
  display: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(255,255,255,0.25);
  font-size: 0.75rem; font-weight: 700;
  align-items: center; justify-content: center;
}
.k3-tab:hover { color: #fff; background: rgba(255, 255, 255, 0.10); }
.k3-tab.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border-bottom-color: #fff;
}
.k3-tab.is-done .k3-tab-ico { opacity: 1; }

.k3-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.7rem;
  flex: 0 0 auto;
}
.k3-lang {
  position: relative;
}
.k3-lang-btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: rgba(255,255,255,0.16); border: none; color: #fff;
  border-radius: 999px; padding: 0.32rem 0.6rem; font-weight: 700; font-size: 0.8rem;
}
.k3-lang-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: #fff; color: var(--ink); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); overflow: hidden; min-width: 88px; display: none; z-index: 40;
}
.k3-lang.is-open .k3-lang-menu { display: block; }
.k3-lang-menu a { display: block; padding: 0.5rem 0.8rem; text-decoration: none; font-weight: 600; font-size: 0.85rem; }
.k3-lang-menu a:hover, .k3-lang-menu a.is-active { background: var(--stone); color: var(--gold-1); }

.k3-exit {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: rgba(255,255,255,0.16); border: none; color: #fff;
  border-radius: 999px; padding: 0.4rem 0.8rem; font-weight: 700; font-size: 0.82rem;
  text-decoration: none;
}
.k3-exit:hover { background: rgba(255,255,255,0.28); }
.k3-exit svg { width: 16px; height: 16px; }

/* ---------- Main split ---------- */
.k3-main {
  display: grid;
  grid-template-columns: var(--panel-w) minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  position: relative;
}

/* ---------- Panel ---------- */
.k3-panel {
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  z-index: 10;
}
.k3-panel-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.2rem 1.2rem 1.4rem;
}
.k3-tabpanel { display: none; }
.k3-tabpanel.is-active { display: block; animation: k3fade 0.25s ease; }
@keyframes k3fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

.k3-group { margin-bottom: 1.5rem; }
.k3-group:last-child { margin-bottom: 0.5rem; }
.k3-group > h2 {
  font-size: 0.78rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--gold-1); margin-bottom: 0.7rem; display: flex; align-items: center; gap: 0.5rem;
}
.k3-group > h2::before { content: ""; width: 22px; height: 3px; border-radius: 2px; background: var(--gold-grad); }

.k3-panel-lead { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.1rem; }

/* Product chips */
.k3-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.k3-chip {
  border: 1.5px solid var(--line); background: var(--paper); border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem; font-size: 0.86rem; font-weight: 600; text-align: left;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; color: var(--ink-soft);
}
.k3-chip:hover { border-color: var(--gold-3); }
.k3-chip.is-active { border-color: var(--gold-2); background: #fff8ec; box-shadow: inset 0 0 0 1px var(--gold-2); color: var(--ink); }

/* Option cards (mount / roof) */
.k3-cards { display: grid; gap: 0.6rem; }
.k3-card {
  display: grid; grid-template-columns: 34px 1fr; gap: 0.7rem; align-items: center;
  border: 1.5px solid var(--line); background: var(--paper); border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem; text-align: left; transition: border-color 0.15s, background 0.15s;
}
.k3-card:hover { border-color: var(--gold-3); }
.k3-card.is-active { border-color: var(--gold-2); background: #fff8ec; box-shadow: inset 0 0 0 1px var(--gold-2); }
.k3-card:disabled { opacity: 0.4; cursor: not-allowed; }
.k3-card .k3-card-ico { width: 30px; height: 30px; color: var(--gold-1); }
.k3-card strong { display: block; font-size: 0.92rem; }
.k3-card span { display: block; font-size: 0.78rem; color: var(--muted); }

/* Colour swatches */
.k3-swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.55rem; }
.k3-swatch {
  border: 1.5px solid var(--line); background: var(--paper); border-radius: var(--radius-sm);
  padding: 0.4rem; display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  font-size: 0.66rem; color: var(--muted); font-weight: 600; text-align: center;
}
.k3-swatch .sw { width: 100%; height: 28px; border-radius: 6px; background: var(--sw, #ccc); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12); }
.k3-swatch .sw-multi { background: conic-gradient(from 210deg, #6b8e23, #b8860b, #2f4f4f, #8b0000, #6b8e23); }
.k3-swatch.is-active { border-color: var(--gold-2); box-shadow: inset 0 0 0 1px var(--gold-2); color: var(--ink); }

/* Dimension sliders */
.k3-dim-row { margin-bottom: 1rem; }
.k3-dim-row:last-child { margin-bottom: 0; }
.k3-dim-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.35rem; }
.k3-dim-head label { font-size: 0.86rem; font-weight: 600; }
.k3-dim-val { font-variant-numeric: tabular-nums; }
.k3-dim-val input {
  width: 74px; text-align: right; font: inherit; font-weight: 700; color: var(--gold-1);
  border: 1px solid var(--line); border-radius: 8px; padding: 0.25rem 0.4rem;
}
.k3-dim-unit { color: var(--muted); font-size: 0.82rem; margin-left: 0.2rem; }
input[type="range"].k3-range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-2) var(--fill, 40%), var(--stone-2) var(--fill, 40%));
  outline: none;
}
input[type="range"].k3-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 3px solid var(--gold-2); box-shadow: var(--shadow-sm); cursor: pointer;
}
input[type="range"].k3-range::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 3px solid var(--gold-2); cursor: pointer;
}

/* Accessory chips */
.k3-acc { display: grid; gap: 0.5rem; }
.k3-acc-chip {
  display: flex; align-items: center; gap: 0.6rem; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); padding: 0.6rem 0.75rem; font-size: 0.88rem; font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.k3-acc-chip:hover { border-color: var(--gold-3); }
.k3-acc-chip.is-active { border-color: var(--gold-2); background: #fff8ec; }
.k3-acc-chip input { width: 18px; height: 18px; accent-color: var(--gold-2); }

/* Fields */
.k3-field { display: block; margin-bottom: 0.9rem; }
.k3-field > span { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 0.3rem; }
.k3-field input[type="text"],
.k3-field input[type="email"],
.k3-field input[type="tel"],
.k3-field textarea {
  width: 100%; font: inherit; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem; background: var(--paper); color: var(--ink); resize: vertical;
}
.k3-field input:focus, .k3-field textarea:focus { outline: none; border-color: var(--gold-2); box-shadow: 0 0 0 3px rgba(203,152,47,0.15); }
.k3-note { font-size: 0.8rem; color: var(--muted); margin-top: 0.4rem; }
.k3-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.k3-check { display: flex; gap: 0.55rem; align-items: flex-start; font-size: 0.85rem; margin: 0.4rem 0 0.9rem; }
.k3-check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--gold-2); flex: 0 0 auto; }
.k3-check a { color: var(--gold-1); font-weight: 600; }

/* Photos */
.k3-photo-btn {
  display: inline-flex; align-items: center; gap: 0.5rem; border: 1.5px dashed var(--line);
  background: var(--stone); border-radius: var(--radius-sm); padding: 0.7rem 1rem; font-weight: 600; color: var(--ink-soft);
}
.k3-photo-btn:hover { border-color: var(--gold-3); }
.k3-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 0.5rem; margin-top: 0.9rem; }
.k3-thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; box-shadow: var(--shadow-sm); }
.k3-thumb img { width: 100%; height: 100%; object-fit: cover; }
.k3-thumb button { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff; border: none; font-size: 1rem; line-height: 1; display: flex; align-items: center; justify-content: center; }

/* Summary list (request tab) */
.k3-sum { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 1.1rem; }
.k3-sum div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.55rem 0.85rem; font-size: 0.86rem; }
.k3-sum div:nth-child(odd) { background: var(--stone); }
.k3-sum dt { color: var(--muted); }
.k3-sum dd { font-weight: 700; text-align: right; }

/* Panel nav */
.k3-panel-nav {
  flex: 0 0 auto; display: flex; gap: 0.6rem; padding: 0.8rem 1.2rem;
  border-top: 1px solid var(--line); background: var(--paper);
}
.k3-status { padding: 0 1.2rem 0.8rem; font-size: 0.85rem; }
.k3-status.is-err { color: #b3261e; }
.k3-status.is-ok { color: #1c7a3e; }

/* Buttons */
.k3-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border: none; border-radius: 999px; padding: 0.7rem 1.2rem; font-weight: 700; font-size: 0.92rem;
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s;
}
.k3-btn:active { transform: translateY(1px); }
.k3-btn-gold { background: var(--gold-grad); color: #fff; box-shadow: 0 6px 18px rgba(203,152,47,0.35); }
.k3-btn-gold:disabled { opacity: 0.6; cursor: default; box-shadow: none; }
.k3-btn-ghost { background: var(--stone); color: var(--ink-soft); }
.k3-btn-ghost:hover { background: var(--stone-2); }
.k3-btn-block { width: 100%; }
.k3-flex-grow { flex: 1 1 auto; }

/* ---------- Stage (3D) ---------- */
.k3-stage { position: relative; min-height: 0; min-width: 0; overflow: hidden; background: linear-gradient(#bcd3e6, #e9eef2); }
#k3Canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.k3-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 0.8rem;
  background: linear-gradient(#bcd3e6, #e9eef2); color: var(--ink-soft); font-weight: 600; z-index: 5;
}
.k3-spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(0,0,0,0.12); border-top-color: var(--gold-2); animation: k3spin 0.9s linear infinite; }
@keyframes k3spin { to { transform: rotate(360deg); } }

/* Dimension labels overlay */
.k3-dims { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.k3-dim {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  background: rgba(29,29,29,0.82); color: #fff; font-size: 0.72rem; font-weight: 700;
  padding: 0.12rem 0.42rem; border-radius: 6px; font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3); will-change: left, top;
}

/* HUD */
.k3-hud { position: absolute; top: 0.9rem; right: 0.9rem; display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-end; z-index: 6; }
.k3-hud-row { display: flex; gap: 0.4rem; background: rgba(255,255,255,0.9); border-radius: 999px; padding: 0.3rem; box-shadow: var(--shadow-sm); backdrop-filter: blur(4px); }
.k3-hud-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none; background: transparent; color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
}
.k3-hud-btn svg { width: 20px; height: 20px; }
.k3-hud-btn:hover { background: var(--stone); }
.k3-hud-btn.is-active { background: var(--gold-grad); color: #fff; }

.k3-hint {
  position: absolute; bottom: 5.2rem; left: 50%; transform: translateX(-50%);
  background: rgba(29,29,29,0.72); color: #fff; font-size: 0.78rem; padding: 0.35rem 0.85rem; border-radius: 999px;
  display: flex; align-items: center; gap: 0.45rem; z-index: 6; opacity: 1; transition: opacity 0.6s; pointer-events: none;
}
.k3-hint.is-hidden { opacity: 0; }
.k3-hint svg { width: 16px; height: 16px; }

/* Summary bar (bottom overlay) */
.k3-sumbar {
  position: absolute; left: 0.9rem; right: 0.9rem; bottom: 0.9rem; z-index: 6;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: rgba(255,255,255,0.94); border-radius: var(--radius); padding: 0.6rem 0.9rem;
  box-shadow: var(--shadow-md); backdrop-filter: blur(6px);
}
.k3-sumbar-info { display: flex; align-items: center; gap: 0.7rem; flex: 1 1 auto; min-width: 0; flex-wrap: wrap; }
.k3-sumbar-info .k3-sb {
  display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.82rem; color: var(--ink-soft); white-space: nowrap;
}
.k3-sumbar-info .k3-sb b { font-weight: 700; }
.k3-sb-dot { width: 14px; height: 14px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15); }
.k3-sumbar .k3-btn { flex: 0 0 auto; }

/* ---------- Mobile / Tablet portrait ---------- */
.k3-mobile-hint { display: none; }

@media (max-width: 900px) {
  :root { --topbar-h: 54px; }
  .k3-app { grid-template-rows: var(--topbar-h) 1fr; height: 100dvh; }
  .k3-brand span { display: none; }
  .k3-tab { font-size: 0.85rem; padding: 0 0.7rem; }
  .k3-tab .k3-tab-lbl { display: none; }
  .k3-tab .k3-tab-num { display: inline-flex; }
  .k3-tab.is-active .k3-tab-lbl { display: inline; }
  .k3-exit .k3-exit-lbl { display: none; }

  .k3-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 42dvh 1fr;
  }
  .k3-stage { order: -1; }
  .k3-panel { border-right: none; border-top: 1px solid var(--line); }
  .k3-panel-scroll { padding: 1rem 1rem 1.2rem; }

  .k3-sumbar { left: 0.6rem; right: 0.6rem; bottom: 0.6rem; padding: 0.5rem 0.7rem; }
  .k3-sumbar-info { display: none; }
  .k3-hud { top: 0.6rem; right: 0.6rem; }
  .k3-hud-btn { width: 34px; height: 34px; }
  .k3-hint { display: none; }
  .k3-chips { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 460px) {
  .k3-chips { grid-template-columns: 1fr; }
  .k3-main { grid-template-rows: 38dvh 1fr; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .k3-tabpanel.is-active { animation: none; }
  .k3-spinner { animation-duration: 2s; }
}

/* ── Language suggestion banner ── */
.lang-suggest {
  background: var(--ink); color: #fff;
  overflow: hidden; max-height: 0;
  transition: max-height 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.lang-suggest.is-visible { max-height: 80px; }
.lang-suggest-inner {
  display: flex; align-items: center; gap: 0.8rem;
  max-width: 1180px; margin: 0 auto; padding: 0.65rem 1.2rem;
}
.lang-suggest-flag {
  width: 28px; height: 28px; border-radius: 50%; background: var(--gold-grad);
  color: var(--ink); font-weight: 800; font-size: 0.78rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.lang-suggest-text { flex: 1; font-size: 0.9rem; font-weight: 500; margin: 0; }
.lang-suggest-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 1rem; border-radius: 999px; background: var(--gold-grad);
  color: var(--ink); font-weight: 700; font-size: 0.82rem; text-decoration: none;
  white-space: nowrap; transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.lang-suggest-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(192, 140, 40, 0.4); }
.lang-suggest-close {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; background: none;
  border: 1px solid rgba(255,255,255,0.2); border-radius: 50%;
  color: rgba(255,255,255,0.7); cursor: pointer; flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s;
}
.lang-suggest-close:hover { border-color: rgba(255,255,255,0.5); color: #fff; }
@media (max-width: 600px) {
  .lang-suggest-inner { flex-wrap: wrap; gap: 0.5rem; }
  .lang-suggest-text { flex-basis: calc(100% - 72px); font-size: 0.84rem; }
  .lang-suggest-btn { margin-left: 36px; font-size: 0.78rem; }
}
