/* Stellwerk Cockpit — gemeinsames Design-System (white-label über CSS-Variablen,
   gesetzt von assets/app.js aus kunde.json). Keine externen Fonts/CDNs: das
   Cockpit muss offline funktionieren. */

:root {
  --dunkel: #1f2d3a;
  --hell: #f6f4ef;
  --akzent: #8a4b38;
  --flaeche: #ffffff;
  --tinte: #22303c;
  --tinte-soft: #5a6672;
  --rand: rgba(15, 30, 25, .10);
  --rand-stark: rgba(15, 30, 25, .18);
  --schatten: 0 1px 2px rgba(15, 30, 25, .06), 0 4px 16px rgba(15, 30, 25, .05);
  --radius: 14px;
  --ok: #2f7a43;
  --warn: #b07c18;
  --rot: #a83c31;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  /* Deutlich von den weißen Karten abgesetzt (Thomas, 21.09. mittags: „alles in
     sehr ähnlichen Weiß- und Pastelltönen, da hebt sich nichts ab"), aber kühl-neutral
     statt erdig (Thomas, 21.09. abends: die Khaki-Mischung wirkte „altbacken wie zu
     DOS-Zeiten") — Karten heben sich über Schatten + Rand ab, nicht über braunen Grund. */
  background: color-mix(in srgb, var(--hell) 45%, #e4e9ef);
  color: var(--tinte);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ---------- Kopfleiste ---------- */
.topbar {
  background: var(--dunkel);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .marke {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.topbar .marke::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--akzent);
  align-self: center;
  flex: none;
}
.topbar .produkt {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.1rem;
  letter-spacing: .02em;
  white-space: nowrap;
}
.topbar .kunde-badge {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
}
.topbar nav {
  margin-left: auto;
  display: flex;
  gap: 4px;
}
.topbar nav a {
  color: rgba(255, 255, 255, .75);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 8px;
  transition: background .15s, color .15s;
}
.topbar nav a:hover { color: #fff; background: rgba(255, 255, 255, .10); }
.topbar nav a.aktiv { color: #fff; background: color-mix(in srgb, var(--akzent) 42%, transparent); }

.demo-band {
  background: var(--akzent);
  color: #fff;
  text-align: center;
  font-size: .78rem;
  font-weight: 500;
  letter-spacing: .02em;
  padding: 5px 12px;
}

/* ---------- Seitenkopf + Inhalt ---------- */
main { max-width: 920px; margin: 0 auto; padding: 28px 20px 80px; }
/* Seiten mit zweispaltigen Kacheln (Schreibtisch) dürfen am PC breiter laufen. */
main.breit { max-width: 1160px; }
.seitenkopf { margin-bottom: 22px; }
.seitenkopf h1 {
  margin: 0 0 4px;
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: -.01em;
  color: var(--tinte);
}
.seitenkopf p { margin: 0; color: var(--tinte-soft); font-size: .92rem; max-width: 60ch; }

.abschnitt-titel {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 30px 0 12px;
  font-size: .8rem;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--tinte-soft);
}
.abschnitt-titel::before {
  content: "";
  width: 16px;
  height: 4px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--akzent) 70%, white);
  flex: none;
}
.abschnitt-titel .zaehler {
  background: var(--rand);
  color: var(--tinte);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: .75rem;
  letter-spacing: 0;
}

/* ---------- Karten ---------- */
.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-top: 4px solid var(--rand-stark);
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 6px rgba(15, 30, 25, .10), 0 8px 24px rgba(15, 30, 25, .08);
  transition: border-color .15s;
}
.karte.freigabe { border-top-color: var(--akzent); }
.karte.frage { border-top-color: var(--warn); }
.karte.hinweis { border-top-color: var(--tinte-soft); }
.karte:hover { border-color: var(--rand-stark); }
.karte .bild { margin: 4px 0 14px; }
.karte .bild img {
  display: block;
  width: 100%;
  max-width: 440px;
  border-radius: 10px;
  border: 1px solid var(--rand);
  cursor: zoom-in;
}

/* Kachel-Körper mit Motiv: am PC zwei Spalten — Bild links (verkleinert), der zu
   kommunizierende Text rechts, Aktionen zentriert darunter (Thomas, 21.09.: eine
   ganze Kachel soll ohne Scrollen auf den Bildschirm passen). */
.karte-koerper {
  display: grid;
  grid-template-columns: minmax(200px, 300px) 1fr;
  gap: 22px;
  align-items: start;
  margin: 4px 0 4px;
}
.karte-koerper .bild { margin: 0; }
.karte-koerper .bild img { max-width: 100%; }
.karte-koerper .karte-text { min-width: 0; max-width: 62ch; }
.karte .aktionen { justify-content: center; }
.karte .aktionen .hilfe-knopf { margin-left: 0; }
@media (max-width: 700px) {
  .karte-koerper { grid-template-columns: 1fr; gap: 12px; }
  .karte .aktionen { justify-content: flex-start; }
}
.karte h3 { margin: 0 0 4px; font-size: 1.02rem; font-weight: 620; line-height: 1.35; }
.karte .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 0 0 10px;
  font-size: .76rem;
  color: var(--tinte-soft);
}
.chip {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
  border-radius: 999px;
  padding: 2px 9px;
  border: 1px solid transparent;
}
.chip.freigabe { color: #fff; background: var(--akzent); }
.chip.frage    { color: #fff; background: var(--warn); }
.chip.hinweis  { color: #fff; background: var(--tinte-soft); }
.chip.status   { color: #fff; background: var(--ok); }
.karte .inhalt { white-space: pre-wrap; font-size: .92rem; color: var(--tinte); }
.karte .notiz { margin-top: 10px; font-size: .8rem; color: var(--tinte-soft); border-left: 2px solid var(--rand-stark); padding-left: 10px; }
.karte .folge {
  margin-top: 10px;
  font-size: .8rem;
  color: var(--tinte-soft);
  border-left: 2px solid color-mix(in srgb, var(--akzent) 60%, white);
  padding-left: 10px;
}
.karte .folge strong { color: var(--tinte); font-weight: 600; }

/* ---------- Aktionen ---------- */
.aktionen { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 9px;
  height: 36px;
  padding: 0 14px;
  font-family: inherit;
  font-size: .86rem;
  font-weight: 550;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s, border-color .15s, transform .05s;
  background: transparent;
  color: var(--tinte);
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
.btn-primaer { background: var(--akzent); color: #fff; box-shadow: 0 1px 2px rgba(15, 30, 25, .18); }
.btn-primaer:hover { background: color-mix(in srgb, var(--akzent) 86%, black); }
.btn-sekundaer { border-color: var(--rand-stark); background: var(--flaeche); }
.btn-sekundaer:hover { background: color-mix(in srgb, var(--tinte) 4%, white); }
.btn-leise { color: var(--tinte-soft); }
.btn-leise:hover { background: color-mix(in srgb, var(--tinte) 5%, white); }
.btn-rot { color: var(--rot); }
.btn-rot:hover { background: color-mix(in srgb, var(--rot) 7%, white); }
.btn[disabled] { opacity: .45; cursor: default; }

/* Einheitliche Eingabefelder (statt Inline-Stile in den Seiten) */
.feld {
  font-family: inherit;
  font-size: .88rem;
  color: var(--tinte);
  background: var(--flaeche);
  border: 1px solid var(--rand-stark);
  border-radius: 9px;
  padding: 8px 11px;
}
.feld:focus {
  outline: 2px solid color-mix(in srgb, var(--akzent) 55%, white);
  outline-offset: 1px;
  border-color: var(--akzent);
}
.feld[disabled] {
  background: color-mix(in srgb, var(--tinte) 4%, white);
  color: var(--tinte-soft);
}

main a { color: color-mix(in srgb, var(--akzent) 80%, var(--tinte)); }

textarea.notizfeld {
  width: 100%;
  font-family: inherit;
  font-size: .86rem;
  border: 1px solid var(--rand-stark);
  border-radius: 9px;
  padding: 9px 11px;
  margin-top: 12px;
  min-height: 44px;
  resize: vertical;
  display: none;
  background: var(--flaeche);
  color: var(--tinte);
}
textarea.notizfeld:focus { outline: 2px solid var(--akzent); outline-offset: 1px; }
.hilfe-knopf { margin-left: auto; width: 36px; justify-content: center; padding: 0;
  border-radius: 50%; border: 1px solid var(--rand-stark); font-weight: 700; }
.hilfe { display: none; margin-top: 12px; padding: 12px 14px; font-size: .82rem;
  line-height: 1.55; white-space: pre-line; color: var(--tinte-soft);
  background: color-mix(in srgb, var(--tinte) 4%, white);
  border: 1px solid var(--rand); border-radius: 10px; }

/* ---------- Leerzustand, Aufklapper ---------- */
.leer {
  text-align: center;
  padding: 44px 20px;
  color: var(--tinte-soft);
  background: var(--flaeche);
  border: 1px dashed var(--rand-stark);
  border-radius: var(--radius);
}
.leer .zeichen { font-size: 1.8rem; display: block; margin-bottom: 6px; color: var(--ok); }
details.bereich { margin-top: 26px; }
details.bereich > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--tinte-soft);
  padding: 6px 0;
  user-select: none;
}
details.bereich > summary::before { content: "▸"; transition: transform .15s; font-size: .7rem; }
details.bereich[open] > summary::before { transform: rotate(90deg); }
details.bereich > summary::-webkit-details-marker { display: none; }
details.bereich > div { margin-top: 10px; }

/* ---------- Abhakbare Checkliste (z. B. Schaltungs-Checkliste im Anzeigen-Modul).
   Haken leben nur im Browser des Betrachters (localStorage) — reine Gedächtnisstütze. */
.checkliste { padding: 8px 0 14px; }
.checkliste .check-intro {
  font-size: .86rem;
  color: var(--tinte-soft);
  margin: 10px 0 4px;
  max-width: 62ch;
  line-height: 1.55;
}
.check-abschnitt {
  margin: 20px 0 6px;
  font-size: .76rem;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--tinte-soft);
}
.check-schritt {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 10px;
  margin: 2px -10px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s;
}
.check-schritt:hover { background: color-mix(in srgb, var(--tinte) 4%, white); }
.check-schritt input {
  appearance: none;
  flex: none;
  width: 19px;
  height: 19px;
  margin: 2px 0 0;
  border: 1.5px solid var(--rand-stark);
  border-radius: 6px;
  background: var(--flaeche);
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: background .15s, border-color .15s;
}
.check-schritt input:checked { background: var(--akzent); border-color: var(--akzent); }
.check-schritt input:checked::before {
  content: "✓";
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  line-height: 1;
}
.check-schritt input:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
.check-schritt .text { font-size: .88rem; line-height: 1.5; }
.check-schritt.erledigt .text {
  color: var(--tinte-soft);
  text-decoration: line-through;
  text-decoration-color: var(--rand-stark);
}
.check-warnung {
  margin-top: 16px;
  padding: 11px 14px;
  font-size: .84rem;
  line-height: 1.55;
  color: color-mix(in srgb, var(--rot) 82%, black);
  background: color-mix(in srgb, var(--rot) 6%, white);
  border: 1px solid color-mix(in srgb, var(--rot) 25%, white);
  border-radius: 10px;
}

/* ---------- Einstellungen: Zeilen + Segmentregler ---------- */
.block {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 6px 20px;
  margin-bottom: 14px;
}
.zeile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rand);
  flex-wrap: wrap;
}
.zeile:last-child { border-bottom: none; }
.zeile .name { font-weight: 600; font-size: .94rem; }
.zeile .detail { font-size: .8rem; color: var(--tinte-soft); margin-top: 2px; max-width: 52ch; }
.segment { display: inline-flex; border: 1px solid var(--rand-stark); border-radius: 9px; overflow: hidden; }
.segment button {
  appearance: none;
  border: none;
  background: var(--flaeche);
  font-family: inherit;
  font-size: .8rem;
  font-weight: 550;
  color: var(--tinte-soft);
  padding: 8px 13px;
  cursor: pointer;
  border-right: 1px solid var(--rand);
  transition: background .15s, color .15s;
}
.segment button:last-child { border-right: none; }
.segment button:hover { background: color-mix(in srgb, var(--tinte) 4%, white); }
.segment button.aktiv { background: var(--dunkel); color: #fff; }
.punkt { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.punkt.gruen { background: var(--ok); } .punkt.gelb { background: var(--warn); }
.punkt.rot { background: var(--rot); } .punkt.grau { background: var(--rand-stark); }

/* ---------- Modul-Katalog ---------- */
.raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 16px; }
.kachel {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 20px;
  display: flex;
  flex-direction: column;
  transition: border-color .15s;
}
.kachel:hover { border-color: var(--rand-stark); }
.kachel.gesperrt { opacity: .62; }
.kachel .kopf { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.kachel h3 { margin: 0; font-size: 1.05rem; font-weight: 650; }
.kachel .preis { font-size: .78rem; font-weight: 600; color: var(--tinte-soft); white-space: nowrap; }
.kachel p { font-size: .86rem; color: var(--tinte); margin: 0 0 14px; flex: 1; }
.kachel .fuss { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hinweisbox {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 20px;
  font-size: .86rem;
  white-space: pre-wrap;
  display: none;
}
.fussnote { font-size: .78rem; color: var(--tinte-soft); margin-top: 22px; }

/* ---------- Chat (Kern-Baustein, kern/chat.py + chat.html) ---------- */
main.chat-seite {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 56px);
  padding-bottom: 16px;
}
.chat-verlauf {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 0 14px;
}
.blase {
  max-width: 76%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .92rem;
  line-height: 1.55;
  overflow-wrap: break-word;
}
.blase.du {
  align-self: flex-end;
  background: var(--dunkel);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.blase.stellwerk {
  align-self: flex-start;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  box-shadow: var(--schatten);
  border-bottom-left-radius: 5px;
}
.blase.hinweis {
  align-self: center;
  max-width: 90%;
  background: none;
  font-size: .78rem;
  color: var(--tinte-soft);
  text-align: center;
  padding: 2px 8px;
}
.blase.fehler { border-color: color-mix(in srgb, var(--rot) 40%, white); color: var(--rot); }
.blase pre {
  background: color-mix(in srgb, var(--tinte) 5%, white);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 8px 10px;
  overflow-x: auto;
  font-size: .8rem;
  margin: 6px 0;
}
.blase code {
  background: color-mix(in srgb, var(--tinte) 6%, white);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: .84em;
}
.blase.du code, .blase.du pre { background: rgba(255, 255, 255, .14); border: none; color: #fff; }
.blase.freigabe-blase { border-left: 3px solid var(--akzent); }
.freigabe-kopf {
  font-size: .72rem;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--akzent);
  margin-bottom: 4px;
}
.freigabe-text { font-size: .86rem; word-break: break-word; }
.freigabe-knoepfe { display: flex; gap: 8px; margin-top: 10px; }
.tippt { color: var(--tinte-soft); font-size: .84rem; }
.tippt::after { content: ""; animation: tipp 1.2s infinite; }
@keyframes tipp { 0% { content: ""; } 33% { content: "."; } 66% { content: ".."; } 100% { content: "..."; } }
.chat-eingabe {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 0 6px;
  background: linear-gradient(transparent, color-mix(in srgb, var(--hell) 45%, #e4e9ef) 30%);
}
.chat-eingabe textarea { flex: 1; resize: none; max-height: 160px; }

/* ---------- Schwebendes Chatfenster (assets/chat-widget.js, alle Seiten) ---------- */
.cw-start {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--akzent);
  color: #fff;
  font-size: 1.35rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(15, 30, 25, .22), 0 12px 32px rgba(15, 30, 25, .18);
  z-index: 60;
  transition: transform .12s, box-shadow .12s;
}
.cw-start:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(15, 30, 25, .26), 0 16px 40px rgba(15, 30, 25, .2); }
.cw-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 384px;
  height: 560px;
  max-height: calc(100vh - 84px);
  max-width: calc(100vw - 44px);
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 16px;
  box-shadow: 0 8px 22px rgba(15, 30, 25, .2), 0 24px 64px rgba(15, 30, 25, .22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 60;
}
.cw-panel.gross { width: min(880px, calc(100vw - 44px)); height: calc(100vh - 84px); }
/* display:flex/fixed überstimmt sonst das hidden-Attribut — ohne diese Regel
   ließe sich das Fenster nicht schließen (Thomas, 21.09.). */
.cw-panel[hidden], .cw-start[hidden] { display: none !important; }
.cw-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--dunkel);
  color: #fff;
  padding: 10px 14px;
  flex: none;
}
.cw-titel { font-weight: 600; font-size: .92rem; }
.cw-titel::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: var(--akzent);
  margin-right: 8px;
  vertical-align: 1px;
}
.cw-knoepfe { display: flex; gap: 4px; }
.cw-knopf {
  border: none;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  cursor: pointer;
  font-size: .95rem;
  line-height: 1;
}
.cw-knopf:hover { background: rgba(255, 255, 255, .22); }
.cw-verlauf {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cw-verlauf .blase { max-width: 86%; }
.cw-eingabe {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px;
  border-top: 1px solid var(--rand);
  background: var(--flaeche);
  flex: none;
}
.cw-eingabe textarea { flex: 1; resize: none; max-height: 120px; }
@media (max-width: 640px) {
  .cw-panel, .cw-panel.gross {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    max-width: 100vw;
    border-radius: 0;
    border: none;
  }
  .cw-start { right: 14px; bottom: 14px; }
}

/* Mobil: die Kopfleiste wird zweizeilig — Marke oben, Menü darunter als
   wischbare Zeile. Die Seite selbst darf nie seitlich scrollen. */
@media (max-width: 700px) {
  html, body { overflow-x: hidden; }
  .blase { max-width: 88%; }
  .topbar {
    flex-wrap: wrap;
    height: auto;
    gap: 0;
    padding: 10px 12px 0;
  }
  .topbar .marke { width: 100%; }
  .topbar .kunde-badge { max-width: 55vw; }
  .topbar nav {
    margin: 6px -12px 0;
    width: calc(100% + 24px);
    max-width: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 8px 10px;
  }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a { white-space: nowrap; flex: none; }
  main { padding: 20px 14px 70px; }
  .zeile { align-items: flex-start; flex-direction: column; }
}
