/* Chat 1:1 (public/chat.js) – keine Inline-Stile (CSP) */
.chat-fab { position: fixed; right: 1rem; bottom: 1rem; z-index: 2500; width: 3.4rem; height: 3.4rem; border-radius: 50%; border: 1px solid var(--color-border, rgba(127, 127, 127, 0.35)); background: var(--color-primary, var(--primary, #3854d6)); color: var(--on-primary, #fff); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); cursor: pointer; display: grid; place-items: center; font-size: 1.5rem; }
.chat-fab[hidden], .chat-panel[hidden], .chat-badge[hidden] { display: none; }
.chat-fab-icon { line-height: 1; }
.chat-badge { position: absolute; top: -0.25rem; right: -0.25rem; min-width: 1.35rem; height: 1.35rem; padding: 0 0.3rem; border-radius: 999px; background: #b3261e; color: #fff; font-size: 0.75rem; font-weight: 700; display: grid; place-items: center; }
.chat-badge-inline { position: static; margin-left: auto; }
.chat-panel { position: fixed; right: 1rem; bottom: 5.2rem; z-index: 2500; width: min(23rem, calc(100vw - 2rem)); max-height: min(36rem, calc(100vh - 7rem)); display: flex; flex-direction: column; gap: 0.5rem; padding: 0.8rem; border-radius: 14px; border: 1px solid var(--color-border, rgba(127, 127, 127, 0.4)); background: var(--color-surface, var(--surface, #fff)); color: var(--color-text, var(--text, #12141c)); box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35); }
.chat-head { display: flex; align-items: center; gap: 0.5rem; }
.chat-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-link { border: 0; background: none; color: inherit; font: inherit; cursor: pointer; padding: 0.2rem 0.4rem; text-decoration: underline; }
.chat-head .chat-link:last-child { text-decoration: none; font-size: 1.4rem; line-height: 1; }
.chat-notice { margin: 0; padding: 0.5rem 0.6rem; border-radius: 10px; background: rgba(245, 179, 1, 0.16); border: 1px solid rgba(245, 179, 1, 0.55); font-size: 0.82rem; }
.chat-list { display: flex; flex-direction: column; gap: 0.3rem; overflow: auto; min-height: 3rem; }
.chat-row { display: flex; align-items: center; gap: 0.5rem; text-align: left; width: 100%; padding: 0.55rem 0.6rem; border-radius: 10px; border: 1px solid var(--color-border, rgba(127, 127, 127, 0.3)); background: transparent; color: inherit; font: inherit; cursor: pointer; }
.chat-row:hover { border-color: var(--color-primary, var(--primary, #3854d6)); }
.chat-row-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chat-row-time { font-size: 0.78rem; opacity: 0.7; }
.chat-new, .chat-send { border: 0; border-radius: 10px; background: var(--color-primary, var(--primary, #3854d6)); color: var(--on-primary, #fff); font: inherit; font-weight: 600; padding: 0.55rem 0.8rem; cursor: pointer; }
.chat-send:disabled { opacity: 0.5; cursor: default; }
.chat-empty, .chat-note, .chat-error { margin: 0.3rem 0; font-size: 0.85rem; opacity: 0.8; }
.chat-error { color: #b3261e; opacity: 1; }
.chat-log { flex: 1; min-height: 8rem; overflow: auto; display: flex; flex-direction: column; gap: 0.35rem; padding: 0.2rem; }
.chat-msg { max-width: 85%; padding: 0.4rem 0.6rem; border-radius: 12px; font-size: 0.92rem; }
.chat-msg.is-mine { align-self: flex-end; background: var(--color-primary, var(--primary, #3854d6)); color: var(--on-primary, #fff); }
.chat-msg.is-theirs { align-self: flex-start; background: rgba(127, 127, 127, 0.2); }
.chat-msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-msg-time { font-size: 0.75rem; opacity: 0.75; text-align: right; }
.chat-form { display: flex; gap: 0.4rem; align-items: stretch; }
.chat-input { flex: 1; min-width: 0; resize: none; font: inherit; padding: 0.4rem 0.5rem; border-radius: 10px; border: 1px solid var(--color-border, rgba(127, 127, 127, 0.4)); background: transparent; color: inherit; }
.chat-del { align-self: flex-start; font-size: 0.78rem; opacity: 0.8; }
@media print { .chat-fab, .chat-panel { display: none !important; } }
.chat-fab .uic { width: 1.6rem; height: 1.6rem; margin: 0; }
/* Handy: Seiten mit unterer Leiste (Seitenleiste wird zur Leiste unten) – der Chat-Knopf sitzt über der Leiste und ist kleiner, damit er keine Beschriftung und möglichst wenig Inhalt verdeckt */
@media (max-width: 899px) {
  body:has(.sidebar) .chat-fab { bottom: calc(5.4rem + env(safe-area-inset-bottom)); right: 0.7rem; width: 2.9rem; height: 2.9rem; font-size: 1.3rem; opacity: 0.92; }
  body:has(.sidebar) .chat-fab .uic { width: 1.35rem; height: 1.35rem; }
  /* Erfassungsansichten mit fester Speichern-Leiste (Audit 19.10.2026, B-07): Der Chat-Knopf verdeckte dort das Mikrofon und die letzten Zeilen
     des Eingabefelds. Er ist ausgeblendet, solange keine ungelesene Nachricht wartet; mit Zähler erscheint er über der Leiste. */
  body:has(.savebar) .chat-fab { display: none; }
  body:has(.savebar) .chat-fab:has(.chat-badge:not([hidden])) { display: grid; bottom: calc(9.6rem + env(safe-area-inset-bottom)); }
  body:has(.sidebar) .chat-panel { bottom: calc(8.6rem + env(safe-area-inset-bottom)); max-height: min(36rem, calc(100vh - 11rem)); }
}

/* Eigenes Chat-Fenster (chat-fenster.html, fenster.js): das Panel füllt das Fenster, ohne Knopf zum Schließen */
html.ubo-window .chat-panel { position: fixed; inset: 0; width: auto; max-height: none; border-radius: 0; z-index: 1; }
html.ubo-window .chat-fab, html.ubo-window .chat-close, html.ubo-window .chat-win { display: none !important; }
