/* ============================================================
   v714: Bauleiter-Symbol auf der Startseite (bauleiter-assistent.js)
   Nur eigene Klassen (.bas-*); Farben aus den App-Tokens, daher hell und dunkel ohne eigene Regeln.
   Maße: Symbol 56 px (Handy 52 px), Fläche 400 px breit, Kopf 64 px, Eingabe und „Senden“ 44 px auf einer Linie.
   Eine Achse: Inhalte stehen links und rechts 16 px vom Rand der Fläche (Kopf, Lage, Verlauf, Eingabe).
   ============================================================ */
.bas-knopf, .bas-flaeche {
  --bas-surface: var(--bg-elevated, #ffffff);
  --bas-sunk: color-mix(in srgb, var(--text) 5%, var(--bg-elevated, #ffffff));
  --bas-hover: color-mix(in srgb, var(--accent) 7%, var(--bg-elevated, #ffffff));
  --bas-line: var(--border);
  --bas-line-strong: color-mix(in srgb, var(--text) 24%, var(--border));
  --bas-text: var(--text);
  --bas-muted: var(--text-muted, var(--muted));
  --bas-accent: var(--accent);
  --bas-accent-soft: color-mix(in srgb, var(--accent) 14%, var(--bg-elevated, #ffffff));
  --bas-tint: color-mix(in srgb, var(--ok) 20%, var(--bg-elevated, #ffffff));
  --bas-machbar: var(--ok);
  --bas-klaeren: var(--warn);
  --bas-klaeren-ink: color-mix(in srgb, var(--warn) 78%, var(--text));
  --bas-block: var(--bad);
  --bas-termin: #6064d6;
  --bas-schatten: 0 18px 44px rgba(16, 24, 40, .22), 0 3px 10px rgba(16, 24, 40, .10);
  font-family: var(--font, system-ui, sans-serif);
  color: var(--bas-text);
  box-sizing: border-box;
}
.bas-knopf *, .bas-flaeche *, .bas-flaeche *::before, .bas-flaeche *::after { box-sizing: border-box; }
.bas-knopf[hidden], .bas-flaeche[hidden], .bas-flaeche [hidden] { display: none !important; }

/* ---------- Symbol */
.bas-symbol { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.bas-symbol .bas-symbol-flaeche { fill: var(--bas-tint); stroke: none; }
.bas-symbol .bas-symbol-papier { fill: var(--bas-surface); }

.bas-knopf {
  position: fixed; right: 24px; bottom: var(--bas-unten, calc(24px + env(safe-area-inset-bottom))); z-index: 1100;
  width: 56px; height: 56px; padding: 0; display: grid; place-items: center;
  border: 1px solid var(--bas-line); border-radius: 50%; background: var(--bas-surface); color: var(--bas-text);
  box-shadow: var(--bas-schatten); cursor: pointer; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.bas-knopf .bas-symbol { width: 34px; height: 34px; }
.bas-knopf:hover { transform: translateY(-1px); border-color: var(--bas-line-strong); }
.bas-knopf[aria-expanded="true"] { border-color: var(--bas-accent); box-shadow: 0 0 0 3px var(--bas-accent-soft), var(--bas-schatten); }
.bas-knopf:focus-visible { outline: 2px solid var(--bas-accent); outline-offset: 3px; }


/* ---------- Fläche */
.bas-flaeche {
  position: fixed; right: 24px; bottom: calc(var(--bas-unten, calc(24px + env(safe-area-inset-bottom))) + 72px); z-index: 1100;
  width: 400px; max-height: min(680px, calc(100vh - var(--bas-unten, 24px) - 104px)); max-height: min(680px, calc(100dvh - var(--bas-unten, 24px) - 104px));
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--bas-line); border-radius: 16px; background: var(--bas-surface); box-shadow: var(--bas-schatten);
  animation: bas-auf .16s ease-out;
}
@keyframes bas-auf { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.bas-kopf { flex: none; display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 16px; border-bottom: 1px solid var(--bas-line); }
.bas-avatar { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--bas-sunk); }
.bas-avatar .bas-symbol { width: 30px; height: 30px; }
.bas-kopf-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.bas-kopf-text h2 { margin: 0; font-size: 15px; line-height: 20px; font-weight: 700; letter-spacing: 0; }
.bas-kontext { justify-self: start; max-width: 100%; min-width: 0; display: inline-flex; align-items: center; gap: 2px; height: 18px; padding: 0;
  border: 0; background: none; color: var(--bas-muted); font: inherit; font-size: 12.5px; line-height: 18px; cursor: pointer; }
.bas-kontext span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bas-kontext svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.bas-kontext[aria-expanded="true"] svg { transform: rotate(180deg); }
.bas-kontext:hover { color: var(--bas-text); }
.bas-kopf-knoepfe { flex: none; display: flex; align-items: center; gap: 4px; }

.bas-ikon { width: 36px; height: 36px; flex: none; padding: 0; display: grid; place-items: center; border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--bas-muted); cursor: pointer; }
.bas-ikon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bas-ikon:hover:not([disabled]) { background: var(--bas-sunk); color: var(--bas-text); }
.bas-ikon[disabled] { opacity: .45; cursor: default; }
.bas-ikon.bas-klein { width: 28px; height: 28px; border-radius: 8px; }
.bas-ikon.bas-klein svg { width: 15px; height: 15px; }
.bas-flaeche button:focus-visible, .bas-flaeche select:focus-visible { outline: 2px solid var(--bas-accent); outline-offset: 2px; }

/* ---------- Elementart (das Projekt ist immer das geöffnete) */
.bas-kontextwahl { flex: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--bas-line); background: var(--bas-sunk); }
/* label: globale Regel (15 px, Abstand 18 px oben außer beim ersten) gilt hier nicht – beide Felder auf einer Linie */
.bas-kontextwahl .bas-feld { display: grid; align-content: start; gap: 4px; min-width: 0; margin: 0; font-size: 12px; }
.bas-feld span { font-size: 12px; line-height: 16px; font-weight: 650; color: var(--bas-muted); }
.bas-feld select { width: 100%; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--bas-line); border-radius: 8px;
  background: var(--input-bg, var(--bas-surface)); color: var(--bas-text); font: inherit; font-size: 13.5px; }

/* ---------- Verlauf ausgeblendet */
.bas-zu-zeile { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 44px; padding: 0 16px;
  border-bottom: 1px solid var(--bas-line); font-size: 13px; color: var(--bas-muted); }

/* ---------- Inhalt (scrollt) */
.bas-inhalt { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 16px; display: grid; align-content: start; gap: 16px; }

/* Lage „Was wäre jetzt sinnvoll?“ */
.bas-lage { display: grid; gap: 12px; }
.bas-lage-kopf h3 { margin: 0; font-size: 16px; line-height: 22px; font-weight: 700; }
.bas-lage-kopf p { margin: 2px 0 0; font-size: 13px; line-height: 19px; color: var(--bas-muted); }
.bas-lage-kopf b { color: var(--bas-text); font-weight: 650; }
.bas-punkte { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.bas-punkt { width: 100%; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 16px; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--bas-line); border-radius: 12px; background: var(--bas-surface); color: var(--bas-text); font: inherit; text-align: left; cursor: pointer; }
.bas-punkt:hover { border-color: var(--bas-line-strong); background: var(--bas-hover); }
.bas-marke { width: 10px; height: 10px; border-radius: 50%; background: var(--bas-muted); }
.bas-marke.m-machbar { background: var(--bas-machbar); }
.bas-marke.m-klaeren { background: var(--bas-klaeren); }
.bas-marke.m-block { background: var(--bas-block); }
.bas-marke.m-termin { background: var(--bas-termin); }
.bas-punkt-text { min-width: 0; display: grid; gap: 2px; }
.bas-punkt-text b { font-size: 13.5px; line-height: 19px; font-weight: 650; overflow-wrap: anywhere; }
.bas-punkt-text span { font-size: 12.5px; line-height: 17px; color: var(--bas-muted); overflow-wrap: anywhere; }
.bas-zahl { min-width: 56px; display: grid; justify-items: center; padding: 4px 8px; border-radius: 8px; background: var(--bas-sunk);
  font-size: 15px; line-height: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bas-zahl small { font-size: 10.5px; line-height: 13px; font-weight: 650; color: var(--bas-muted); }
.bas-zahl.z-machbar { color: color-mix(in srgb, var(--bas-machbar) 72%, var(--bas-text)); }
.bas-zahl.z-klaeren { color: var(--bas-klaeren-ink); }
.bas-zahl.z-block { color: color-mix(in srgb, var(--bas-block) 85%, var(--bas-text)); }
.bas-zahl.z-termin { color: var(--bas-termin); }
.bas-pfeil { display: grid; place-items: center; color: var(--bas-muted); }
.bas-pfeil svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bas-lage-fuss { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; font-size: 12px; color: var(--bas-muted); }
.bas-lage-fehler { margin: 0; font-size: 13px; color: var(--bas-block); }
.bas-skelett { display: grid; gap: 8px; }
.bas-skelett i { display: block; height: 58px; border-radius: 12px; background: var(--bas-sunk); animation: bas-puls 1.2s ease-in-out infinite; }
.bas-skelett i:nth-child(2) { animation-delay: .15s; } .bas-skelett i:nth-child(3) { animation-delay: .3s; }
@keyframes bas-puls { 50% { opacity: .5; } }

/* Gespräch */
.bas-verlauf { display: grid; gap: 14px; padding-top: 16px; border-top: 1px solid var(--bas-line); }
.bas-runde { display: grid; gap: 8px; }
.bas-frage { justify-self: end; max-width: 85%; min-width: 0; padding: 8px 12px; border: 1px solid color-mix(in srgb, var(--bas-accent) 26%, var(--bas-line));
  border-radius: 14px 14px 4px 14px; background: var(--bas-accent-soft); }
.bas-frage p { margin: 0; font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.bas-antwort { min-width: 0; display: grid; gap: 8px; padding: 10px 12px 6px; border: 1px solid var(--bas-line); border-radius: 14px 14px 14px 4px; background: var(--bas-sunk); }
.bas-antwort-fuss { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.bas-antwort-fuss .bas-ikon { margin-left: auto; }
.bas-zeit { font-size: 11.5px; color: var(--bas-muted); font-variant-numeric: tabular-nums; }
.bas-md { min-width: 0; font-size: 13.5px; line-height: 1.55; overflow-wrap: anywhere; }
.bas-md > * { margin: 0; }
.bas-md > * + * { margin-top: 8px; }
.bas-md ul, .bas-md ol { padding-left: 18px; }
.bas-md li + li { margin-top: 2px; }
.bas-md h4, .bas-md h5 { font-size: 13.5px; line-height: 1.4; font-weight: 700; }
.bas-md code { padding: 0 4px; border-radius: 4px; background: var(--bas-surface); font-size: 12.5px; }
.bas-md hr { border: 0; border-top: 1px solid var(--bas-line); }
.bas-md .blf-tabelle { max-width: 100%; overflow-x: auto; }
.bas-md table { border-collapse: collapse; font-size: 12.5px; }
.bas-md th, .bas-md td { padding: 4px 8px; border-bottom: 1px solid var(--bas-line); text-align: left; white-space: nowrap; }
.bas-md .r { text-align: right; } .bas-md .c { text-align: center; }
.bas-hinweise { margin: 0; padding-left: 16px; font-size: 12px; line-height: 1.45; color: var(--bas-klaeren-ink); }
.bas-still { color: var(--bas-muted); }
.bas-denkt { display: flex; align-items: center; gap: 8px; min-height: 32px; font-size: 13px; color: var(--bas-muted); }
.bas-denkt .bas-link { margin-left: auto; }
.bas-punkte-animation { display: inline-flex; gap: 3px; }
.bas-punkte-animation i { width: 6px; height: 6px; border-radius: 50%; background: var(--bas-accent); animation: bas-hupf 1s ease-in-out infinite; }
.bas-punkte-animation i:nth-child(2) { animation-delay: .15s; } .bas-punkte-animation i:nth-child(3) { animation-delay: .3s; }
@keyframes bas-hupf { 0%, 80%, 100% { opacity: .35; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }
.bas-fehler { display: grid; justify-items: start; gap: 4px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--bas-block) 40%, var(--bas-line));
  border-radius: 12px; background: color-mix(in srgb, var(--bas-block) 8%, var(--bas-surface)); }
.bas-fehler b { font-size: 13.5px; }
.bas-fehler p { margin: 0; font-size: 13px; line-height: 1.45; }
.bas-fehler-detail { color: var(--bas-muted); }
.bas-verlauf-fuss { display: flex; justify-content: center; }
.bas-link { padding: 4px 0; border: 0; background: none; color: var(--bas-accent); font: inherit; font-size: 12.5px; font-weight: 650; cursor: pointer; }
.bas-link:hover:not([disabled]) { text-decoration: underline; }
.bas-link[disabled] { opacity: .5; cursor: default; }

/* ---------- Eingabe */
.bas-unten { flex: none; display: grid; gap: 6px; padding: 12px 16px; border-top: 1px solid var(--bas-line); background: var(--bas-surface); }
.bas-eingabe { display: flex; align-items: flex-end; gap: 8px; margin: 0; }
.bas-eingabe textarea { flex: 1; min-width: 0; height: 44px; min-height: 44px; max-height: 120px; resize: none; padding: 11px 12px;
  border: 1px solid var(--bas-line); border-radius: 12px; background: var(--input-bg, var(--bas-surface)); color: var(--bas-text);
  font: inherit; font-size: 14px; line-height: 20px; }
.bas-eingabe textarea:focus { outline: none; border-color: var(--bas-accent); box-shadow: 0 0 0 3px var(--bas-accent-soft); }
.bas-eingabe textarea[disabled] { opacity: .6; }
.bas-senden { width: 44px; height: 44px; flex: none; padding: 0; display: grid; place-items: center; border: 0; border-radius: 12px;
  background: var(--bas-accent); color: #ffffff; cursor: pointer; }
.bas-senden svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.bas-senden[disabled] { background: var(--bas-sunk); color: var(--bas-muted); cursor: default; }
.bas-fuss { margin: 0; font-size: 11.5px; line-height: 16px; color: var(--bas-muted); text-align: center; }
.bas-fuss.bas-fuss-hinweis { font-size: 12.5px; line-height: 18px; color: var(--bas-klaeren-ink); }
.bas-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Handy: Fläche als Blatt über die volle Breite, Eingabe über der Bildschirmtastatur */
@media (max-width: 640px) {
  .bas-knopf { right: 16px; bottom: var(--bas-unten, calc(16px + env(safe-area-inset-bottom))); width: 52px; height: 52px; }
  .bas-knopf .bas-symbol { width: 32px; height: 32px; }
  body.bas-offen .bas-knopf { display: none; }
  .bas-flaeche { left: 8px; right: 8px; width: auto; bottom: calc(8px + env(safe-area-inset-bottom) + var(--bas-tastatur, 0px));
    max-height: calc(100vh - 24px - var(--bas-tastatur, 0px)); max-height: min(88dvh, calc(100dvh - 24px - var(--bas-tastatur, 0px))); }
  .bas-eingabe textarea { font-size: 16px; } /* iOS vergrößert sonst beim Antippen */
}
@media (prefers-reduced-motion: reduce) {
  .bas-flaeche, .bas-skelett i, .bas-punkte-animation i { animation: none; }
  .bas-knopf { transition: none; }
}
