/* ===== Agent-Knopf (unten rechts, jede Ansicht) und Einrichtungsmodus (#/einrichtung) ===== */

/* ---- Agent-Knopf: Foto + Name, öffnet das Chatfenster mit Bezug zur aktuellen Ansicht ---- */
.agent-knopf { position: fixed; right: 22px; bottom: 22px; z-index: 60; display: inline-flex; align-items: center; gap: 9px; height: 52px; min-width: 52px; max-width: 220px;
  padding: 0 18px 0 6px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .9); background: rgba(255, 255, 255, .9); color: var(--text); cursor: pointer;
  font-family: inherit; font-weight: 650; font-size: 14.5px; line-height: 1; box-shadow: 0 14px 34px -14px rgba(10, 12, 20, .45), 0 2px 6px rgba(10, 12, 20, .08);
  backdrop-filter: blur(24px) saturate(170%); -webkit-backdrop-filter: blur(24px) saturate(170%); transition: transform var(--tempo), bottom var(--tempo), right var(--tempo); }
.agent-knopf:hover { transform: translateY(-1px); }
.agent-knopf:focus-visible { outline: 2px solid var(--akzent); outline-offset: 3px; }
.agent-knopf .avatar { width: 40px; height: 40px; font-size: 16px; overflow: hidden; }
.agent-knopf .avatar img.agent-foto { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.agent-knopf-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Nichts verdecken: über der sichtbaren Speicherleiste, nie über Dialogen, Menüs, Vollbild-Werkstatt, eingebettet nie */
body:has(.speicher-leiste:not([hidden]):not([data-geaendert="nein"])) .agent-knopf { bottom: 84px; }
body:has(.schleier, .palette-schleier, .galerie, .pdf-vollbild) .agent-knopf { visibility: hidden; }
/* Plan-Ansicht (Vollbild mit eigener Werkzeugleiste unten): am Handy ohne schwebenden Agent-Knopf – er verdeckte „Messen“ */
@media (max-width: 860px) { body.im-plan .agent-knopf { display: none !important; } }
body.ws-voll .agent-knopf, html.eingebettet .agent-knopf { display: none !important; }
/* Am PC/Tablet liegen Agent-Knopf und Werkstatt-Pille unten rechts über dem Inhalt: Platz am Seitenende, damit man die
   letzten Knöpfe (z. B. „An die Werkstatt“ im Cockpit) freiscrollen kann */
@media (min-width: 861px) { body:has(.agent-knopf) .ansicht { padding-bottom: 104px; } }
body.ws-geteilt .agent-knopf { right: calc(var(--ws-b, 46vw) + 22px); }
@media (min-width: 1100px) { body.ws-klein .agent-knopf { right: calc(var(--ws-kb, 480px) + 36px); } }
/* Meldungen über dem Knopf statt darunter */
body.hat-agent-knopf .toasts { bottom: 86px; }
body.hat-agent-knopf:has(.speicher-leiste:not([hidden]):not([data-geaendert="nein"])) .toasts { bottom: 148px; }
/* Werkstatt-Pille links neben dem Agent-Knopf, gleiche Höhe */
body.hat-agent-knopf .ws-pille { right: calc(var(--agent-knopf-b, 120px) + 32px); bottom: 22px; height: 52px; padding: 0 18px; }
body.hat-agent-knopf:has(.speicher-leiste:not([hidden]):not([data-geaendert="nein"])) .ws-pille { bottom: 84px; }
/* Die letzte Zeile jeder Ansicht lässt sich über den Knopf hinaus scrollen */
body.hat-agent-knopf .inhalt:not(.voll) .ansicht { padding-bottom: 96px; }

@media (max-width: 860px) {
  .agent-knopf { right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); height: 48px; padding: 0 15px 0 5px; font-size: 14px; max-width: 46vw; }
  .agent-knopf .avatar { width: 38px; height: 38px; }
  body:has(.speicher-leiste:not([hidden]):not([data-geaendert="nein"])) .agent-knopf { bottom: calc(150px + env(safe-area-inset-bottom)); }
  /* Belegmaske, LV, Plan: keine Tab-Leiste, dafür der Fuß der Maske */
  body.im-editor .agent-knopf { bottom: calc(86px + env(safe-area-inset-bottom)); }
  body.im-plan .agent-knopf { bottom: calc(16px + env(safe-area-inset-bottom)); }
  body.ws-klein .agent-knopf { display: none; }
  body.ws-geteilt .agent-knopf { right: 12px; }
  /* Offene Tastatur: schwebende Knöpfe weg, damit das Feld sichtbar bleibt */
  body:has(input:focus, textarea:focus, select:focus) .agent-knopf { display: none !important; }
  body.hat-agent-knopf .ws-pille { right: auto; left: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); height: 48px; }
  body.hat-agent-knopf .toasts { bottom: calc(146px + env(safe-area-inset-bottom)); }
  body.hat-agent-knopf .inhalt:not(.voll) .ansicht { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
}

/* Bezug im Chatfenster: abgewählt → mit einem Tipp wieder mitschicken */
.bezug-wieder { border: 0; background: transparent; padding: 0; font: inherit; font-size: 12px; color: var(--leise); cursor: pointer; }
.bezug-wieder u { text-underline-offset: 2px; }

/* ---- Cockpit: schlanke Leiste im Einrichtungsmodus ---- */
.einr-leiste { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; margin-bottom: 16px; text-decoration: none !important; color: inherit; min-height: 52px; }
.einr-leiste .balken { flex: 0 1 160px; height: 6px; border-radius: 3px; background: rgba(10, 12, 20, .08); overflow: hidden; }
.einr-leiste .balken i { display: block; height: 100%; background: var(--text); border-radius: 3px; }
.einr-leiste .text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) { .einr-leiste .balken { display: none; } }

/* ---- Bereich „Einrichtung“ ---- */
.einr-kopf-zahl { display: flex; align-items: center; gap: 14px; margin: 4px 0 18px; }
.einr-kopf-zahl .balken { flex: 1 1 auto; max-width: 420px; height: 8px; border-radius: 4px; background: rgba(10, 12, 20, .08); overflow: hidden; }
.einr-kopf-zahl .balken i { display: block; height: 100%; background: var(--text); border-radius: 4px; transition: width .3s ease; }
.einr-gruppe { margin-bottom: 16px; padding: 6px 0; }
.einr-gruppe > h2 { font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--leise); font-weight: 650; margin: 8px 16px 4px; }
.einr-punkt { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; min-height: 56px; border-top: 1px solid var(--rand, rgba(10, 12, 20, .06)); }
.einr-punkt:first-of-type { border-top: 0; }
.einr-punkt .marke { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid rgba(10, 12, 20, .25); color: transparent; }
.einr-punkt.erledigt .marke { background: var(--text); border-color: var(--text); color: #fff; }
.einr-punkt.unnoetig .marke { border-style: dashed; color: var(--leise); }
.einr-punkt .mitte { flex: 1 1 auto; min-width: 0; }
.einr-punkt .titel { font-weight: 600; }
.einr-punkt.erledigt .titel, .einr-punkt.unnoetig .titel { color: var(--leise); }
.einr-punkt.unnoetig .titel { text-decoration: line-through; text-decoration-color: rgba(10, 12, 20, .3); }
.einr-punkt .stand { font-size: 12.5px; color: var(--leise); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.einr-punkt > .knopf { flex: none; min-height: 44px; }
.einr-punkt > .knopf.rund { width: 44px; height: 44px; padding: 0; }
.einr-abschluss { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px; }
.einr-abschluss .text { flex: 1 1 240px; }

/* Geführter Schritt */
.einr-schritt-kopf { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.einr-schritt-kopf h1 { margin: 0; flex: 1 1 auto; }
.einr-punkte-leiste { display: flex; gap: 6px; }
.einr-punkte-leiste a { width: 30px; height: 6px; border-radius: 3px; background: rgba(10, 12, 20, .12); }
.einr-punkte-leiste a.an { background: var(--text); }
.einr-punkte-leiste a.fertig { background: rgba(10, 12, 20, .45); }
.einr-weiter { position: sticky; bottom: 16px; z-index: 6; display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding: 6px; width: fit-content; margin-left: auto;
  border-radius: 999px; background: rgba(255, 255, 255, .86); border: 1px solid rgba(255, 255, 255, .9); box-shadow: 0 14px 34px -14px rgba(10, 12, 20, .4); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }
.einr-weiter .knopf { min-height: 44px; border-radius: 999px; }
body:has(.einr-weiter) .agent-knopf { bottom: 84px; }
body.einr-schritt .speicher-leiste { display: none !important; }   /* „Weiter“ und „Überspringen“ speichern mit */
body.hat-agent-knopf:has(.einr-weiter) .ws-pille { bottom: 84px; }
.einr-vorschau { display: grid; grid-template-columns: 120px minmax(0, 220px) minmax(0, 220px); gap: 18px; align-items: end; }
.einr-vorschau figure { margin: 0; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.einr-vorschau figcaption { font-size: 12px; color: var(--leise); }
.einr-symbol { width: 84px; height: 84px; border-radius: 20px; overflow: hidden; box-shadow: 0 6px 18px -8px rgba(10, 12, 20, .4); background: #fff; }
.einr-symbol img { width: 100%; height: 100%; display: block; }
.einr-leiste-muster { width: 100%; height: 150px; border-radius: 14px; background: var(--nav, #f4f4f6); border: 1px solid var(--karte-rand); padding: 12px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.einr-leiste-muster img { max-width: 100%; max-height: 36px; object-fit: contain; object-position: left center; }
.einr-leiste-muster .zeile-muster { height: 9px; border-radius: 5px; background: rgba(10, 12, 20, .08); }
.einr-leiste-muster .zeile-muster.an { background: rgba(10, 12, 20, .2); width: 70%; }
.einr-blatt { width: 100%; aspect-ratio: 210 / 297; background: #fff; border-radius: 4px; box-shadow: 0 8px 24px -10px rgba(10, 12, 20, .35), 0 0 0 1px rgba(10, 12, 20, .06); overflow: hidden; }
.einr-blatt svg { width: 100%; height: 100%; display: block; }
.einr-zwei { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.einr-zwei > .einr-rechts { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 12px; }
.einr-luecken { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.einr-luecken li { display: flex; gap: 8px; align-items: flex-start; }
.einr-luecken li .p { color: var(--fehler, #c0392b); font-weight: 650; }
.einr-luecken li.ok { color: var(--leise); }
@media (max-width: 1100px) { .einr-zwei { grid-template-columns: minmax(0, 1fr); } .einr-zwei > .einr-rechts { position: static; max-width: 420px; } }
@media (max-width: 700px) {
  .einr-vorschau { grid-template-columns: 90px minmax(0, 1fr); }
  .einr-vorschau figure:last-child { grid-column: 1 / -1; width: 170px; justify-self: center; }
  .einr-punkt { display: grid; grid-template-columns: 26px minmax(0, 1fr) 44px; column-gap: 12px; row-gap: 8px; padding-right: 8px; }
  .einr-punkt .marke { grid-column: 1; grid-row: 1; }
  .einr-punkt .mitte { grid-column: 2; grid-row: 1; }
  .einr-punkt > .knopf.rund { grid-column: 3; grid-row: 1; }
  .einr-punkt > .knopf.jetzt { grid-column: 2; grid-row: 2; justify-self: start; }
  .einr-punkt .stand { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .einr-weiter { width: auto; margin-left: 0; justify-content: stretch; bottom: calc(10px + env(safe-area-inset-bottom)); }
  .einr-weiter .knopf { flex: 1 1 auto; }
  /* Geführter Schritt am Handy: „Weiter“ ersetzt die Tab-Leiste (wie in der Belegmaske), der Agent-Knopf sitzt darüber */
  body.einr-schritt .tabbar { display: none !important; }
  body.einr-schritt .agent-knopf, body.einr-schritt:has(.speicher-leiste:not([hidden]):not([data-geaendert="nein"])) .agent-knopf { bottom: calc(80px + env(safe-area-inset-bottom)); }
  body.einr-schritt .inhalt:not(.voll) .ansicht { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
}

/* Nummernkreise: Felder nie breiter als ihre Spalte (sonst lief „Startnummer“ am Handy aus der Karte) */
.nummernkreis-felder input { width: 100%; min-width: 0; }
