/* Farb- und Formensprache wie LED-Planer, AV-Rechner und Signalflow-
   Konfigurator, damit die eigenen Tools als eine Familie erkennbar bleiben. */
:root {
  --bg: #f4f5f7;
  --flaeche: #ffffff;
  --flaeche-2: #f8f9fb;
  --rand: #d6d9de;
  --rand-stark: #b3b8c0;
  --text: #1f2328;
  --leise: #6b727c;
  --primaer: #2f6fb5;
  --primaer-hell: #e7f0fa;
  --primaer-text: #ffffff;
  --gefahr: #c0392b;
  --ok-bg: #eef6ee;
  --ok-rand: #7fae7f;
  --warn-bg: #fdf3e3;
  --warn-rand: #e0b054;
  --fehler-bg: #fdecea;
  --fehler-rand: #d9534f;
  --schatten: 0 4px 18px rgba(15, 23, 42, 0.16);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1d21;
    --flaeche: #24272c;
    --flaeche-2: #1f2226;
    --rand: #3a3f46;
    --rand-stark: #50565e;
    --text: #e6e8ea;
    --leise: #9aa1aa;
    --primaer: #4b8fd6;
    --primaer-hell: #22344a;
    --ok-bg: #21301f;
    --ok-rand: #4d7a4d;
    --warn-bg: #3a2f1c;
    --warn-rand: #8a6b2a;
    --fehler-bg: #3a2320;
    --fehler-rand: #a4453f;
    --schatten: 0 4px 18px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.versteckt { display: none !important; }
.luecke { flex: 1; }
.mini { font-size: 12px; color: var(--leise); }
.breit { width: 100%; justify-content: center; }
kbd {
  font: 11px/1 ui-monospace, Consolas, monospace;
  border: 1px solid var(--rand-stark);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 4px;
  background: var(--flaeche);
}

/* ---------- Grundelemente ---------- */
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--flaeche);
  border: 1px solid var(--rand-stark);
  border-radius: 6px;
  padding: 6px 8px;
  min-width: 0;
}
textarea { resize: vertical; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primaer); outline-offset: -1px; }
input[type="checkbox"], input[type="radio"] { min-width: auto; margin: 0; }
input[type="range"] { padding: 0; width: 100%; accent-color: var(--primaer); }
input[type="color"] { padding: 1px; width: 34px; height: 30px; cursor: pointer; }

button, .knopf-link {
  font: inherit;
  background: var(--flaeche);
  color: var(--text);
  border: 1px solid var(--rand-stark);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
button:hover:not(:disabled), .knopf-link:hover { border-color: var(--primaer); }
button:disabled { opacity: 0.45; cursor: default; }
button.klein { padding: 3px 9px; font-size: 13px; }
button.primaer { background: var(--primaer); color: var(--primaer-text); border-color: var(--primaer); }
button.gefahr { background: var(--gefahr); color: #fff; border-color: var(--gefahr); }

label { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--leise); }
label > input, label > select, label > textarea { color: var(--text); font-size: 14px; }

.zeile { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.zeile.umbruch { flex-wrap: wrap; }
.paar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.drei { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.haken { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.haken label, label.haken-zeile { flex-direction: row; align-items: center; gap: 7px; color: var(--text); font-size: 13.5px; }
.hinweis { font-size: 12.5px; color: var(--leise); margin: 6px 0 10px; }

/* ---------- Kopf ---------- */
.kopf {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
  flex-wrap: wrap;
  flex: none;
}
.kopf h1 { font-size: 17px; margin: 0; font-weight: 600; white-space: nowrap; }
.kopf .projektname { flex: 0 1 300px; }
#status.ungespeichert { color: #b26a00; }

/* ---------- Arbeitsfläche ---------- */
.arbeitsflaeche {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
}
.steuerung {
  overflow-y: auto;
  border-right: 1px solid var(--rand);
  background: var(--flaeche-2);
  padding: 10px 12px 24px;
}
.reiter { display: flex; gap: 2px; margin-bottom: 10px; border-bottom: 1px solid var(--rand); }
.reiter button {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  padding: 7px 10px;
  color: var(--leise);
}
.reiter button.aktiv { color: var(--text); border-bottom-color: var(--primaer); font-weight: 600; }
.reiter .zahl { font-size: 11px; background: var(--rand); border-radius: 9px; padding: 0 6px; color: var(--text); }
.reiter .zahl:empty { display: none; }
.tab label { margin: 7px 0; }

details.gruppe { border: 1px solid var(--rand); border-radius: 8px; background: var(--flaeche); margin: 10px 0; }
details.gruppe > summary { cursor: pointer; padding: 8px 10px; font-weight: 600; font-size: 13.5px; }
details.gruppe > .inhalt { padding: 2px 10px 10px; }
.kuerzel { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px 8px; font-size: 12px; }
.kuerzel .breit { grid-column: 1 / -1; }

/* ---------- Objektliste ---------- */
.objektliste { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 10px; }
.objektliste .eintrag {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}
.objektliste .eintrag:hover { background: var(--flaeche); border-color: var(--rand); }
.objektliste .eintrag.gewaehlt { background: var(--primaer-hell); border-color: var(--primaer); }
.objektliste .eintrag.unsichtbar .text { opacity: 0.45; }
.objektliste .muster { display: flex; align-items: center; justify-content: center; }
.objektliste .text { min-width: 0; }
.objektliste .text b { display: block; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.objektliste .text span { display: block; font-size: 11.5px; color: var(--leise); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.symknopf {
  border: none;
  background: none;
  padding: 2px 4px;
  font-size: 14px;
  line-height: 1;
  opacity: 0.35;
  border-radius: 4px;
}
.symknopf.an { opacity: 1; }
.symknopf:hover { background: var(--rand); }

/* ---------- Kategorien ---------- */
.kategorien { display: flex; flex-direction: column; gap: 6px; }
.kategorie { border: 1px solid var(--rand); border-radius: 8px; background: var(--flaeche); padding: 6px 8px; }
.kategorie.aktiv { border-color: var(--primaer); box-shadow: 0 0 0 1px var(--primaer); }
.kategorie .kopfzeile { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.kategorie .kopfzeile input[type="text"] { font-weight: 600; }
.kategorie .knoepfe { display: flex; gap: 2px; }
.kategorie .details { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-top: 6px; }
.kategorie .details label { margin: 0; }
.kategorie .fuss { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.kategorie .fuss .mini { flex: 1; }

/* ---------- Kartenbereich ---------- */
.kartenbereich { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.werkzeugleiste {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
  flex-wrap: wrap;
  flex: none;
}
.werkzeuge { display: flex; gap: 2px; background: var(--flaeche-2); border: 1px solid var(--rand); border-radius: 8px; padding: 2px; }
button.werkzeug {
  border: 1px solid transparent;
  background: none;
  padding: 5px 7px;
  border-radius: 6px;
  color: var(--text);
}
button.werkzeug svg { width: 18px; height: 18px; display: block; }
button.werkzeug.aktiv { background: var(--primaer); color: #fff; }
button.werkzeug:hover:not(.aktiv):not(:disabled) { background: var(--rand); border-color: transparent; }
.werkzeug .pfeilchen { font-size: 9px; margin-left: -3px; }
.trenner { width: 1px; align-self: stretch; background: var(--rand); margin: 2px 2px; }
.kategoriewahl, .vorlagewahl { flex-direction: row; align-items: center; gap: 6px; margin: 0; }
.kategoriewahl select { max-width: 210px; }
.vorlagewahl select { max-width: 230px; }
#grundkarte { max-width: 220px; }

.suche { position: relative; }
.suche input { width: 250px; }
.suchtreffer {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  width: 380px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--flaeche);
  border: 1px solid var(--rand-stark);
  border-radius: 8px;
  box-shadow: var(--schatten);
  z-index: 1200;
}
.suchtreffer button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--rand);
  border-radius: 0;
  padding: 7px 10px;
  white-space: normal;
}
.suchtreffer button:hover, .suchtreffer button.aktiv { background: var(--primaer-hell); }
.suchtreffer .leer { padding: 10px; color: var(--leise); font-size: 13px; }

.kartenhalter { position: relative; flex: 1; min-height: 0; }
#karte { position: absolute; inset: 0; background: #ffffff; }
#karte.lp-zeichnen { cursor: crosshair; }
#karte.lp-zeichnen .leaflet-interactive { pointer-events: none !important; }
#karte.lp-zeichnen .leaflet-grab { cursor: crosshair; }

.kartenhinweis {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--warn-bg);
  border: 1px solid var(--warn-rand);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  box-shadow: var(--schatten);
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ---------- Eigenschaften ---------- */
.eigenschaften {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 300px;
  max-height: calc(100% - 20px);
  overflow-y: auto;
  z-index: 1000;
  background: var(--flaeche);
  border: 1px solid var(--rand-stark);
  border-radius: 10px;
  box-shadow: var(--schatten);
  padding: 0 12px 12px;
  font-size: 13.5px;
}
.eig-kopf {
  position: sticky;
  top: 0;
  background: var(--flaeche);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 0 8px;
  border-bottom: 1px solid var(--rand);
  margin-bottom: 4px;
  z-index: 1;
}
.eig-kopf .typ { font-weight: 600; flex: 1; }
.eig-abschnitt { border-top: 1px solid var(--rand); padding-top: 6px; margin-top: 10px; }
.eig-abschnitt:first-of-type { border-top: none; margin-top: 0; }
.eig-abschnitt > h4 { margin: 2px 0 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--leise); }
.eigenschaften label { margin: 6px 0; }
.eigenschaften .paar, .eigenschaften .drei { margin: 4px 0; }
.eigenschaften .paar label, .eigenschaften .drei label { margin: 0; }
.eig-info { font-size: 12.5px; background: var(--flaeche-2); border: 1px solid var(--rand); border-radius: 6px; padding: 6px 8px; margin: 6px 0; }
.eig-info b { font-weight: 600; }
.eig-knoepfe { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.einheit { position: relative; }
.einheit input { width: 100%; padding-right: 26px; }
.einheit::after { content: attr(data-einheit); position: absolute; right: 8px; bottom: 7px; font-size: 12px; color: var(--leise); pointer-events: none; }

/* ---------- Symbolpalette ---------- */
.symbolpalette {
  position: absolute;
  top: 8px;
  left: 10px;
  z-index: 1100;
  background: var(--flaeche);
  border: 1px solid var(--rand-stark);
  border-radius: 10px;
  box-shadow: var(--schatten);
  padding: 8px 10px 10px;
  width: 360px;
  max-height: calc(100% - 20px);
  overflow-y: auto;
}
.symbolpalette h4 { margin: 8px 0 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--leise); }
.symbolpalette .raster { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.symbolpalette button { padding: 3px; border-radius: 6px; justify-content: center; }
.symbolpalette button.aktiv { border-color: var(--primaer); box-shadow: 0 0 0 1px var(--primaer); }

/* ---------- Leaflet: Objekte, Griffe, Beschriftungen ---------- */
.leaflet-container { font-family: "DM Sans", "Segoe UI", sans-serif; }
.lp-symbol svg { display: block; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45)); }
.lp-symbol.gewaehlt svg { outline: 2px dashed #fff; outline-offset: 2px; }
.lp-schrift-anker { width: 0 !important; height: 0 !important; }
.lp-schrift {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  text-align: center;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid #888;
  border-radius: 4px;
  padding: 1px 5px 2px;
  color: #1a1a20;
  font-family: "DM Sans", "Segoe UI", sans-serif;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.lp-schrift .z1 { font-weight: 700; }
.lp-schrift .z2 { font-weight: 500; font-size: 0.82em; }
.lp-schrift.ohne-kasten {
  background: none;
  border: none;
  box-shadow: none;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff;
}
.lp-schrift.gewaehlt { outline: 2px dashed var(--primaer); outline-offset: 1px; }
.leaflet-interactive .lp-schrift { cursor: move; }
/* Die Schrift wird um ihren Mittelpunkt gedreht: translate(-50%,-50%)
   rotate(…) mit transform-origin in der Ecke dreht um die Ecke — deshalb hier
   die Mitte als Ursprung. */
.lp-schrift { transform-origin: center center; }

.lp-griff {
  background: #fff;
  border: 2px solid var(--primaer);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  cursor: grab;
}
.lp-griff-mitte { border-radius: 50%; opacity: 0.8; border-width: 1.5px; cursor: copy; }
.lp-griff-kante { border-radius: 3px; background: var(--primaer-hell); }
.lp-griff-dreh { border-radius: 50%; background: var(--primaer); border-color: #fff; cursor: alias; }
.lp-griff-schrift { border-radius: 50%; background: #F57C00; border-color: #fff; cursor: move; }
.lp-griff-schrift::after { content: "T"; display: block; color: #fff; font: 700 8px/10px "DM Sans", sans-serif; text-align: center; }
.lp-messanzeige {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
  background: rgba(20, 24, 31, 0.86);
  color: #fff;
  font-size: 12.5px;
  line-height: 1.35;
  padding: 5px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.lp-messanzeige .leise { color: #b8c0cc; font-size: 11.5px; }
.lp-messung {
  position: absolute;
  transform: translate(10px, -50%);
  background: #1a1a20;
  color: #ffeb3b;
  font-weight: 700;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.lp-rahmenlinie { cursor: move; }
.lp-rahmen-schild {
  position: absolute;
  transform: translate(0, calc(-100% - 6px));
  background: #fff;
  color: #1a1a20;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: move;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* ---------- Dialoge ---------- */
dialog {
  border: 1px solid var(--rand-stark);
  border-radius: 12px;
  background: var(--flaeche);
  color: var(--text);
  box-shadow: var(--schatten);
  padding: 0;
}
dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
dialog.rueckfrage { padding: 18px 20px; max-width: 440px; }
dialog.rueckfrage h3 { margin: 0 0 6px; }
dialog.rueckfrage .knoepfe { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dlg-kopf { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--rand); }
.dlg-kopf h3 { margin: 0; font-size: 16px; }
dialog.gross { width: min(760px, 94vw); }
.projektliste { max-height: 70vh; overflow-y: auto; padding: 8px 16px 16px; }
.projektliste .eintrag { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--rand); }
.projektliste .eintrag b { display: block; }
.projektliste .leer { color: var(--leise); padding: 14px 0; }

dialog.ausgabe { width: min(1400px, 96vw); height: min(900px, 94vh); }
dialog.ausgabe[open] { display: flex; flex-direction: column; }
.ausgabe-inhalt { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 270px; }
.vorschau { overflow: auto; background: #6b727c; padding: 18px; display: flex; align-items: flex-start; justify-content: center; }
.vorschau svg { background: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); max-width: 100%; height: auto; }
.ausgabe-seite { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; border-left: 1px solid var(--rand); overflow-y: auto; }
.fortschritt .balken { height: 8px; border-radius: 4px; background: var(--rand); overflow: hidden; }
.fortschritt .balken span { display: block; height: 100%; width: 0; background: var(--primaer); transition: width 0.2s; }

/* ---------- Meldung ---------- */
.meldung {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  z-index: 3000;
  background: #1f2328;
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  box-shadow: var(--schatten);
  transition: opacity 0.2s, transform 0.2s;
  max-width: 80vw;
}
.meldung.sichtbar { opacity: 1; transform: translate(-50%, 0); }
.meldung.fehler { background: var(--gefahr); }
.meldung.ok { background: #2e7d32; }

/* ---------- schmale Bildschirme ---------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  .arbeitsflaeche { grid-template-columns: 1fr; grid-template-rows: auto minmax(70vh, 1fr); }
  .steuerung { border-right: none; border-bottom: 1px solid var(--rand); max-height: 40vh; }
  .eigenschaften { width: min(300px, calc(100% - 20px)); }
  .suche input { width: 160px; }
  .ausgabe-inhalt { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
}
