/* ============================================================
   components.css – wiederverwendbare Bedienelemente
   ============================================================ */

/* ---------- Schaltflächen ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--c-border-firm);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover  { background: var(--c-surface-2); border-color: var(--c-text-faint); }
.btn:active { background: #f0f2f5; }

.btn--primary {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #fff;
}
.btn--primary:hover  { background: var(--c-accent-dark); border-color: var(--c-accent-dark); }
.btn--primary:active { background: var(--c-accent-dark); }

.btn--ghost { border-color: transparent; background: none; padding: 5px 7px; }
.btn--ghost:hover { background: var(--c-surface-2); border-color: var(--c-border); }

.btn--danger { color: var(--c-danger); }
.btn--danger:hover { background: #fdf2f1; border-color: #f0bdb9; }

.btn--block { width: 100%; justify-content: center; }

/* ---------- Umschalter 2D / 3D ---------- */
.segmented {
  display: flex;
  padding: 2px;
  gap: 2px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
}
.segmented__item {
  border: 0;
  background: none;
  padding: 4px 13px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--c-text-soft);
}
.segmented__item:hover { color: var(--c-text); }
.segmented__item.is-active {
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--shadow-1);
}

/* ---------- Werkzeug-Schaltflächen ---------- */
.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 2px 6px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: none;
  color: var(--c-text-soft);
  transition: background .12s ease, color .12s ease;
}
.tool:hover { background: var(--c-surface-2); color: var(--c-text); border-color: var(--c-border); }
.tool.is-active { background: var(--c-accent-soft); color: var(--c-accent); border-color: transparent; }
.tool.is-active .icon { stroke-width: 1.8; }
.tool:disabled { opacity: .38; cursor: default; }
.tool:disabled:hover { background: none; border-color: transparent; color: var(--c-text-soft); }

.tool__label { font-size: 10.5px; font-weight: 500; letter-spacing: -0.01em; }

/* ---------- Chips auf der Zeichenfläche ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 30px;
  height: 28px;
  padding: 0 9px;
  justify-content: center;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-1);
  font-size: 12px;
  font-weight: 500;
  color: var(--c-text-soft);
  white-space: nowrap;
}
.chip:hover { color: var(--c-text); border-color: var(--c-border-firm); }
.chip--wide { padding: 0 12px; }
.chip--toggle { cursor: pointer; }
.chip--toggle input { margin: 0; accent-color: var(--c-accent); }
.chip--select { padding-right: 5px; }
.chip--select select {
  border: 0;
  background: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-text);
  padding: 2px;
}
.chip--select select:focus { outline: none; }

/* ---------- Längeneingabe beim Zeichnen ---------- */
.length-entry {
  position: absolute;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: var(--r-md);
  background: var(--c-surface);
  border: 1px solid var(--c-accent);
  box-shadow: var(--shadow-2);
  font-size: 12px;
}
.length-entry[hidden] { display: none; }
.length-entry label { color: var(--c-text-soft); }
.length-entry input {
  width: 76px;
  border: 0;
  padding: 0;
  font-family: var(--font-num);
  font-size: 13px;
  font-weight: 600;
}
.length-entry input:focus { outline: none; }
.length-entry__unit { color: var(--c-text-faint); }

/* ---------- Begehungsmodus ---------- */
.walk-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(245, 246, 248, .72);
  backdrop-filter: blur(3px);
}
.walk-overlay[hidden] { display: none; }
.walk-overlay__card {
  width: 320px;
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-3);
  text-align: center;
  display: grid;
  gap: var(--sp-2);
}
.walk-overlay__card p { color: var(--c-text-soft); font-size: 12.5px; }
.walk-overlay__speed { display: grid; gap: 4px; font-size: 12px; color: var(--c-text-soft); text-align: left; }
.walk-overlay__speed input { width: 100%; accent-color: var(--c-accent); }

/* ---------- Eigenschaften-Formulare ---------- */
.section {
  margin-bottom: var(--sp-4);
}
.section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-2);
}
.section__title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--c-text-faint);
}
.section__badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--c-accent-soft);
  color: var(--c-accent);
  font-weight: 600;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }

.field { display: grid; gap: 3px; margin-bottom: var(--sp-2); }
.field__label { font-size: 11.5px; color: var(--c-text-soft); }
.field input[type="text"],
.field input[type="number"],
.field select {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--c-border-firm);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  font-size: 12.5px;
}
.field input[type="number"] { font-family: var(--font-num); }
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-soft);
}
.field input[type="range"] { width: 100%; accent-color: var(--c-accent); }
.field input[type="color"] {
  width: 100%;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--c-border-firm);
  border-radius: var(--r-sm);
  background: var(--c-surface);
}

.readout {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px dashed var(--c-border);
}
.readout:last-child { border-bottom: 0; }
.readout span:first-child { color: var(--c-text-soft); }
.readout span:last-child { font-family: var(--font-num); font-weight: 600; }

.empty {
  padding: var(--sp-5) var(--sp-3);
  text-align: center;
  color: var(--c-text-faint);
  font-size: 12.5px;
}
.empty strong { display: block; color: var(--c-text-soft); margin-bottom: 4px; font-size: 13px; }

.hint {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--c-accent-soft);
  color: var(--c-accent-dark);
  font-size: 12px;
  margin-bottom: var(--sp-3);
}

.actions-row { display: flex; gap: var(--sp-1); flex-wrap: wrap; }

/* ---------- Bibliothek ---------- */
.lib-group { margin-bottom: var(--sp-4); }
.lib-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-1); }

.lib-item {
  display: grid;
  gap: 2px;
  padding: 8px 8px 7px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  text-align: left;
  transition: border-color .12s ease, background .12s ease;
}
.lib-item:hover { border-color: var(--c-accent); background: var(--c-accent-soft); }
.lib-item.is-active { border-color: var(--c-accent); background: var(--c-accent-soft); }
.lib-item__name { font-size: 12px; font-weight: 500; line-height: 1.25; }
.lib-item__size { font-size: 10.5px; color: var(--c-text-faint); font-family: var(--font-num); }

/* ---------- Projektliste ---------- */
.project-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-1);
}
.project-row__main { flex: 1; min-width: 0; }
.project-row__name { font-weight: 600; }
.project-row__meta { font-size: 11.5px; color: var(--c-text-faint); }
.project-row.is-current { border-color: var(--c-accent); background: var(--c-accent-soft); }

/* ---------- Dialoge ---------- */
.dialog {
  border: 0;
  padding: 0;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  max-width: 460px;
  width: calc(100vw - 48px);
  color: var(--c-text);
}
.dialog--wide { max-width: 720px; }
.dialog::backdrop { background: rgba(20, 24, 30, .34); backdrop-filter: blur(2px); }

.dialog__form { display: grid; }
.dialog__title { padding: var(--sp-4) var(--sp-4) 0; font-size: 15px; }
.dialog__body { padding: var(--sp-3) var(--sp-4); max-height: 60vh; overflow-y: auto; }
.dialog__body--columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.dialog__body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--c-text-faint); margin-bottom: var(--sp-2); }
.dialog__text { color: var(--c-text-soft); font-size: 12.5px; }
.dialog__hint { color: var(--c-text-faint); font-size: 11.5px; margin: 0; }
.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin: 0;
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  border-top: 1px solid var(--c-border);
}

.keys { display: grid; grid-template-columns: auto 1fr; gap: 4px var(--sp-2); margin: 0; font-size: 12.5px; }
.keys dt {
  font-family: var(--font-num);
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid var(--c-border-firm);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--c-surface-2);
  justify-self: start;
  white-space: nowrap;
}
.keys dd { margin: 0; color: var(--c-text-soft); }

/* ---------- Meldung ---------- */
.toast {
  position: fixed;
  bottom: 46px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--c-text);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-2);
}
.toast--error { background: var(--c-danger); }

/* ---------- Oberflächenwahl ---------- */
.surface {
  display: grid;
  gap: 5px;
  padding: var(--sp-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface-2);
  margin-bottom: var(--sp-2);
}

.surface__head { display: flex; align-items: center; gap: var(--sp-2); }

.surface__preview {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-border-firm);
  flex: none;
  image-rendering: auto;
}

.surface__select {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--c-border-firm);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  font-size: 12.5px;
}
.surface__select:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-soft);
}

.surface__colors { display: flex; gap: var(--sp-2); }

.surface__color {
  flex: 1;
  display: grid;
  gap: 2px;
  font-size: 10.5px;
  color: var(--c-text-soft);
  cursor: pointer;
}
.surface__color input[type="color"] {
  width: 100%;
  height: 24px;
  padding: 1px;
  border: 1px solid var(--c-border-firm);
  border-radius: var(--r-sm);
  background: var(--c-surface);
}

.surface__presets { display: flex; gap: 4px; flex-wrap: wrap; }
.surface__chip {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid var(--c-border-firm);
  padding: 0;
}
.surface__chip:hover { transform: scale(1.12); border-color: var(--c-accent); }

/* ---------- Etagenwahl in der Kopfzeile ---------- */
.levels {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px 2px 2px 8px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface-2);
}

.levels__icon { color: var(--c-text-faint); width: 16px; height: 16px; }

.levels select {
  min-width: 150px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--c-surface);
  font-size: 12.5px;
  font-weight: 500;
}
.levels select:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-soft);
}

.level-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px var(--sp-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  margin-bottom: 4px;
  cursor: pointer;
  background: var(--c-surface);
}
.level-row:hover { border-color: var(--c-border-firm); background: var(--c-surface-2); }
.level-row.is-active { border-color: var(--c-accent); background: var(--c-accent-soft); }
.level-row__main { flex: 1; min-width: 0; }
.level-row__name { font-weight: 600; font-size: 12.5px; }
.level-row__meta { font-size: 11px; color: var(--c-text-faint); font-family: var(--font-num); }

/* ---------- Energie ---------- */
.energy-scale { display: flex; gap: 2px; margin-bottom: var(--sp-3); }
.energy-scale__step {
  flex: 1;
  padding: 4px 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  border-radius: 3px;
  opacity: .38;
}
.energy-scale__step.is-active { opacity: 1; transform: scaleY(1.5); box-shadow: var(--shadow-1); }

.energy-badge {
  border: 2px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-3);
  text-align: center;
  margin-bottom: var(--sp-3);
}
.energy-badge__value { font-size: 34px; font-weight: 700; line-height: 1.05; font-family: var(--font-num); }
.energy-badge__unit { font-size: 11px; color: var(--c-text-faint); }
.energy-badge__class { font-size: 12.5px; font-weight: 600; margin-top: 4px; }

.loss { margin-bottom: var(--sp-2); }
.loss__head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 3px; }
.loss__value { font-family: var(--font-num); font-weight: 600; }
.loss__bar { height: 7px; border-radius: 4px; background: var(--c-surface-2); overflow: hidden; }
.loss__fill { height: 100%; background: linear-gradient(90deg, #f4a81d, #e2521c); }

.measure {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--sp-2);
  margin-bottom: var(--sp-2);
  display: grid;
  gap: 4px;
}
.measure__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.measure__name { font-weight: 600; font-size: 12.5px; }
.measure__class {
  font-size: 11px; font-weight: 700; color: #fff;
  padding: 1px 8px; border-radius: 999px;
}
.measure__meta { font-size: 11.5px; color: var(--c-text-faint); font-family: var(--font-num); }
.measure__saving { font-size: 12px; color: var(--c-text-soft); }
.measure__saving.is-good { color: #1a7a3c; font-weight: 500; }

.field--check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--sp-2);
  cursor: pointer;
}
.field--check input { margin: 0; accent-color: var(--c-accent); }
.field--check .field__label { margin: 0; }

.topbar__version {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--c-text-faint);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 1px 7px;
  letter-spacing: 0;
}

.dialog__list { margin: 0 0 var(--sp-2); padding-left: 18px; font-size: 12.5px; color: var(--c-text-soft); }
.dialog__list li { margin-bottom: 2px; }

/* ---------- Meldung, wenn der Start scheitert ---------- */
.startfehler {
  position: fixed;
  inset: 0;
  z-index: 9999;
  margin: auto;
  align-self: center;
  max-width: 520px;
  height: fit-content;
  padding: 22px 24px;
  border: 1px solid #f0bdb9;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(16, 20, 26, .22);
  font-family: -apple-system, "Segoe UI", sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  color: #16191d;
}
.startfehler strong { display: block; font-size: 15px; margin-bottom: 8px; color: #c62a1e; }
.startfehler p { margin: 0 0 10px; }
.startfehler__detail {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11.5px;
  color: #5c636e;
  background: #f5f6f8;
  border-radius: 6px;
  padding: 8px 10px;
  word-break: break-word;
}
.startfehler button {
  border: 1px solid #2f6fed;
  background: #2f6fed;
  color: #fff;
  font: inherit;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
}

/* Ebenen-Panel: Gruppentitel und Zeilenumbruch für viele Häkchen */
.chip-row--layers { flex-wrap: wrap; align-items: center; max-width: 520px; }
.chip-group__title {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-text-faint);
  margin-right: 2px;
  align-self: center;
}

/* Druck-/PDF-Dialog (White-Label) */
.print-dialog {
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 0;
  max-width: 460px;
  width: 92vw;
  box-shadow: 0 24px 64px rgba(0,0,0,0.28);
}
.print-dialog::backdrop { background: rgba(20,24,31,0.45); }
.print-form { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 10px; }
.print-form h2 { margin: 0; font-size: 17px; }
.print-hint { margin: 0; font-size: 12px; color: var(--c-text-faint); line-height: 1.4; }
.print-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--c-text-faint); }
.print-field input[type="text"] {
  border: 1px solid var(--c-border); border-radius: 8px; padding: 8px 10px;
  font-size: 14px; color: var(--c-text);
}
.print-field input[type="text"]:focus { border-color: var(--c-accent); outline: none; }
.print-logo-row { display: flex; align-items: center; gap: 10px; min-height: 20px; }
.print-logo-row img { max-height: 40px; max-width: 140px; object-fit: contain; }
.print-logo-row img:not([src]) { display: none; }
.print-options { display: flex; align-items: center; gap: 16px; font-size: 13px; margin-top: 4px; }
.print-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* Bibliothek: Suchfeld und einklappbare Kategorien */
.lib-search { position: sticky; top: 0; z-index: 2; background: var(--c-surface); padding: 2px 0 6px; }
.lib-search__input {
  width: 100%;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--c-text);
  background: var(--c-surface-alt, #f6f7f9);
}
.lib-search__input:focus { border-color: var(--c-accent); outline: none; background: #fff; }

.lib-cat { border: 1px solid var(--c-border); border-radius: 8px; margin-bottom: var(--sp-1); overflow: hidden; }
.lib-cat__head {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border: 0; background: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--c-text); text-align: left;
}
.lib-cat__head:hover { background: var(--c-surface-alt, #f2f3f5); }
.lib-cat__caret { color: var(--c-text-faint); width: 12px; }
.lib-cat__title { flex: 1; }
.lib-cat__count {
  font-size: 11px; font-weight: 600; color: var(--c-text-faint);
  background: var(--c-surface-alt, #eef0f3); border-radius: 999px; padding: 1px 8px;
}
.lib-cat__body { padding: 4px 8px 10px; }

/* Sicherungs-Werkzeuge im Projekte-Dialog */
.project-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.project-tools__info { flex-basis: 100%; font-size: 11px; color: var(--c-text-faint); }
