/* SMESK Konfigurator — Markenoptik: Blau #154064 / #186eaf, Akzent #ee7523,
   Statusgrün #1a7a35. Schrift Zalando Sans mit Fallback Segoe UI / system-ui. */

:root {
  --blau-tief: #154064;
  --blau: #186eaf;
  --blau-hell: #eaf2f9;
  --orange: #ee7523;
  --gruen: #1a7a35;
  --rot: #b3261e;
  --tinte: #16212b;
  --grau: #5b6773;
  --linie: #dde3e9;
  --flaeche: #ffffff;
  --hintergrund: #f4f6f8;
  --radius: 10px;
  --schrift: 'Zalando Sans', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  --schatten: 0 1px 2px rgba(21, 64, 100, .06), 0 6px 20px rgba(21, 64, 100, .07);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--schrift);
  color: var(--tinte);
  background: var(--hintergrund);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: contain;
}

#app { display: flex; height: 100%; width: 100%; }

/* ---------------------------------------------------------------- Bühne */
#buehne-wrap { position: relative; flex: 1 1 auto; min-width: 0; background: #eef0f2; }
#buehne { position: absolute; inset: 0; }
#buehne canvas { touch-action: none; }
#buehne:focus { outline: none; }
#buehne:focus-visible { outline: 3px solid var(--orange); outline-offset: -3px; }

/* Bedienhinweis der Bühne: sichtbar, sobald die Bühne den Fokus hat */
#buehne-hilfe {
  position: absolute; left: 50%; top: .9rem; transform: translateX(-50%);
  margin: 0; padding: .35rem .85rem; border-radius: 999px;
  background: rgba(255,255,255,.94); border: 1px solid var(--linie);
  font-size: .76rem; color: var(--grau); pointer-events: none;
  opacity: 0; transition: opacity .15s;
}
#buehne:focus-visible ~ #buehne-hilfe { opacity: 1; }

#buehne-leiste {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-wrap: wrap; gap: .5rem; padding: .9rem 1rem;
  justify-content: center; pointer-events: none;
}
.buehne-taste {
  pointer-events: auto;
  font: 600 .875rem/1.2 var(--schrift);
  color: #fff; background: var(--blau-tief);
  border: 1px solid rgba(255,255,255,.18); border-radius: 999px;
  padding: .62rem 1.15rem; cursor: pointer;
  box-shadow: 0 2px 10px rgba(21,64,100,.25);
  transition: background .15s, transform .08s;
}
.buehne-taste:hover { background: var(--blau); }
.buehne-taste:active { transform: translateY(1px); }
.buehne-taste-still { background: rgba(255,255,255,.92); color: var(--blau-tief); border-color: var(--linie); box-shadow: 0 2px 10px rgba(21,64,100,.12); }
.buehne-taste-still:hover { background: #fff; color: var(--blau); }
.buehne-taste:focus-visible, button:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

#laden {
  position: absolute; top: 1rem; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: .55rem;
  background: rgba(255,255,255,.94); border: 1px solid var(--linie);
  border-radius: 999px; padding: .45rem 1rem; font-size: .82rem; color: var(--grau);
}
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--linie); border-top-color: var(--blau);
  animation: dreh .8s linear infinite;
}
@keyframes dreh { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

#fehler {
  position: absolute; left: 1rem; right: 1rem; top: 1rem;
  background: #fff; border-left: 4px solid var(--rot); border-radius: var(--radius);
  padding: .9rem 1rem; box-shadow: var(--schatten); font-size: .875rem;
}
#fehler p { margin: .35rem 0 0; color: var(--grau); }

#debug {
  position: absolute; left: 1rem; top: 1rem; max-width: 30rem; max-height: 60%;
  overflow: auto; margin: 0; padding: .7rem .85rem;
  background: rgba(22,33,43,.9); color: #d7e3ee; border-radius: var(--radius);
  font: 12px/1.5 ui-monospace, 'Cascadia Mono', Consolas, monospace;
  white-space: pre-wrap;
}

/* ---------------------------------------------------------------- Panel */
#panel {
  flex: 0 0 390px; max-width: 390px;
  background: var(--flaeche); border-left: 1px solid var(--linie);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 0 0 3rem;
}

.kopf { padding: 1.5rem 1.35rem 1.1rem; background: var(--blau-tief); color: #fff; }
.kopf-marke { font-size: .7rem; letter-spacing: .22em; font-weight: 700; opacity: .8; }
.kopf-titel { margin: .35rem 0 .5rem; font-size: 1.4rem; line-height: 1.15; font-weight: 700; }
.kopf-text { margin: 0; font-size: .82rem; line-height: 1.5; color: #cfdceb; }

.ab { padding: 1.15rem 1.35rem; border-bottom: 1px solid var(--linie); }
.ab-titel { margin: 0 0 .7rem; font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--blau-tief); font-weight: 700; }
.ab-hinweis { margin: .7rem 0 0; font-size: .76rem; line-height: 1.5; color: var(--grau); }
.feld-titel { margin: 1rem 0 .45rem; font-size: .78rem; font-weight: 600; color: var(--tinte); }
.feld-titel:first-of-type { margin-top: 0; }
.warn {
  margin: .7rem 0 0; font-size: .78rem; line-height: 1.5; color: #6b3b06;
  background: #fdf4e8; border-left: 3px solid var(--orange);
  border-radius: 0 6px 6px 0; padding: .55rem .7rem;
}

/* Segmente / Chips */
.segment { display: flex; gap: .5rem; }
.segment-taste {
  flex: 1; display: flex; flex-direction: column; gap: .15rem; align-items: flex-start;
  background: #fff; border: 1.5px solid var(--linie); border-radius: var(--radius);
  padding: .7rem .8rem; cursor: pointer; font-family: var(--schrift); text-align: left;
  transition: border-color .15s, background .15s;
}
.segment-klein .segment-taste { align-items: center; padding: .5rem .6rem; }
.segment-taste:hover:not(:disabled) { border-color: var(--blau); }
.segment-taste.ist-aktiv { border-color: var(--blau-tief); background: var(--blau-hell); }
.segment-taste:disabled { opacity: .4; cursor: not-allowed; }
.segment-name { font-size: .9rem; font-weight: 600; }
.segment-sub { font-size: .72rem; color: var(--grau); }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
  background: #fff; border: 1.5px solid var(--linie); border-radius: 999px;
  padding: .45rem .95rem; font: 600 .85rem var(--schrift); color: var(--tinte); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.chip:hover { border-color: var(--blau); }
.chip.ist-aktiv { border-color: var(--blau-tief); background: var(--blau-tief); color: #fff; }

/* Swatches */
.swatches { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.swatches-dekor { grid-template-columns: 1fr 1fr 1fr; }
.swatch {
  display: flex; flex-direction: column; gap: .3rem; align-items: stretch;
  background: #fff; border: 1.5px solid var(--linie); border-radius: var(--radius);
  padding: .45rem; cursor: pointer; font-family: var(--schrift); text-align: left;
}
.swatch:hover { border-color: var(--blau); }
.swatch.ist-aktiv { border-color: var(--blau-tief); box-shadow: inset 0 0 0 1px var(--blau-tief); }
.swatch-farbe { display: block; height: 40px; border-radius: 6px; border: 1px solid rgba(0,0,0,.12); background-size: cover; }
.swatch-name { font-size: .76rem; font-weight: 600; line-height: 1.2; }
.swatch-sub { font-size: .68rem; color: var(--grau); }

/* Listen / Zeilen */
.liste { display: flex; flex-direction: column; gap: .4rem; }
.zeile-wrap { display: flex; align-items: stretch; gap: .4rem; }
.zeile {
  flex: 1; display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  background: #fff; border: 1.5px solid var(--linie); border-radius: var(--radius);
  padding: .6rem .75rem; cursor: pointer; font-family: var(--schrift); text-align: left;
}
.zeile:hover:not(:disabled) { border-color: var(--blau); }
.zeile.ist-aktiv { border-color: var(--blau-tief); background: var(--blau-hell); }
.zeile.ist-gesperrt, .zeile:disabled { opacity: .45; cursor: not-allowed; }
.zeile-links { display: flex; flex-direction: column; gap: .12rem; min-width: 0; }
.zeile-name { font-size: .85rem; font-weight: 600; }
.zeile-sub { font-size: .72rem; color: var(--grau); line-height: 1.35; }
.haken { color: var(--gruen); font-weight: 700; width: 1rem; text-align: center; flex: 0 0 auto; }

.karte { background: #fbfcfd; border: 1px solid var(--linie); border-radius: var(--radius); padding: .75rem; margin-bottom: .6rem; }
.karte-kopf { display: flex; justify-content: space-between; margin-bottom: .5rem; }
.karte-titel { font-size: .78rem; font-weight: 700; color: var(--blau-tief); }
.karte .zeile { margin-top: .45rem; }

.menge { display: flex; align-items: center; gap: .1rem; border: 1.5px solid var(--linie); border-radius: var(--radius); background: #fff; }
.menge-taste { width: 30px; height: 100%; min-height: 38px; border: 0; background: none; cursor: pointer; font-size: 1.05rem; color: var(--blau-tief); }
.menge-taste:hover { color: var(--orange); }
.menge-wert { min-width: 1.4rem; text-align: center; font-size: .85rem; font-weight: 600; }

/* Stückliste */
.bom { display: flex; flex-direction: column; }
.bom-zeile { display: flex; justify-content: space-between; gap: .8rem; padding: .55rem 0; border-bottom: 1px dashed var(--linie); }
.bom-zeile:last-child { border-bottom: 0; }
.bom-links { min-width: 0; }
.bom-name { font-size: .84rem; font-weight: 600; line-height: 1.3; }
.bom-meta { display: flex; gap: .45rem; align-items: center; margin-top: .15rem; font-size: .72rem; color: var(--grau); }
.bom-kode { font-family: ui-monospace, Consolas, monospace; letter-spacing: .02em; }
.bom-tag { color: var(--gruen); background: #e9f5ec; border-radius: 4px; padding: .05rem .35rem; font-weight: 600; }
.bom-menge { font-size: .84rem; font-weight: 700; color: var(--blau-tief); white-space: nowrap; }

.fuss { padding: 1.1rem 1.35rem; font-size: .72rem; line-height: 1.5; color: var(--grau); }
.fuss p { margin: 0; }

/* ---------------------------------------------------------------- Mobil */
@media (max-width: 860px) {
  #app { flex-direction: column; }
  #buehne-wrap { flex: 0 0 46vh; min-height: 260px; }
  #panel {
    flex: 1 1 auto; max-width: none; width: 100%;
    border-left: 0; border-top: 1px solid var(--linie);
    border-radius: 16px 16px 0 0; margin-top: -14px; position: relative; z-index: 2;
    box-shadow: 0 -6px 20px rgba(21,64,100,.10);
  }
  .kopf { border-radius: 16px 16px 0 0; }
  #buehne-leiste { padding-bottom: 1.4rem; }
  .swatches-dekor { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 400px) {
  .swatches { grid-template-columns: 1fr; }
  .swatches-dekor { grid-template-columns: 1fr 1fr; }
}
