/* [P2:T2] Team-Chat in mVOS (team.js, Spezifikation 6.2.4).
   Ab 900 px zwei Spalten (280 px | Rest), darunter Liste oder Gespräch.
   Zustände nie nur über Farbe: Ungelesenes fett mit Zahl, Status mit Symbolform. */
[hidden] { display: none !important; }

:root {
  --tc-flaeche: var(--surface, #fff);
  --tc-rand: var(--border, #E2E8F0);
  --tc-leise: var(--text-muted, #64748B);
  --tc-hover: var(--nav-hover, #F1F5F9);
  --tc-aktiv: var(--nav-aktiv-flaeche, #E8F0FE);
  --tc-aktiv-text: var(--nav-aktiv, #1D4ED8);
  --tc-mark: #FEF3C7;
  --tc-mark-text: #713F12;
  --tc-eigen: #F5F8FF;
  --tc-neu: #B42318;
}

#page-teamchat.active { display: block; }
.tc { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 0; background: var(--tc-flaeche);
  border-radius: var(--radius, 10px); box-shadow: var(--shadow); overflow: hidden;
  height: calc(100vh - var(--topbar-h, 60px) - 56px); height: calc(100dvh - var(--topbar-h, 60px) - 56px); min-height: 440px; }
body.sitzung-aus .tc { height: calc(100dvh - var(--sitzung-unten, 60px) - 56px); }
.tc :focus-visible { outline: 2px solid var(--accent, #2563EB); outline-offset: 2px; }

/* ── Linke Spalte ─────────────────────────────────────────────────────── */
.tc-liste { display: flex; flex-direction: column; gap: 14px; padding: 16px 12px; border-right: 1px solid var(--tc-rand);
  overflow-y: auto; min-height: 0; background: #FBFCFE; }
.tc-seitentitel { font-size: 18px; font-weight: 700; color: var(--text, #0F172A); padding: 0 6px; }
.tc-suche { width: 100%; padding: 8px 12px; border: 1.5px solid var(--tc-rand); border-radius: 8px; font: inherit; font-size: 14px; background: #fff; }
.tc-suche:focus { border-color: var(--accent, #2563EB); }
.tc-gruppe h2 { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--tc-leise); padding: 0 6px 6px; }
.tc-eintraege { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.tc-eintrag { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px; padding: 6px 8px; border: 0; border-radius: 8px;
  background: none; color: var(--nav-text, #334155); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.tc-eintrag:hover { background: var(--tc-hover); }
.tc-eintrag[aria-current="true"] { background: var(--tc-aktiv); color: var(--tc-aktiv-text); }
.tc-eintrag:disabled { cursor: default; opacity: .7; }
.tc-eintrag:disabled:hover { background: none; }
.tc-eintrag-symbol { width: 1.2em; flex: none; text-align: center; color: var(--tc-leise); }
.tc-eintrag-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-fett .tc-eintrag-name { font-weight: 700; color: var(--text, #0F172A); }
.tc-stumm .tc-eintrag-name { color: var(--tc-leise); }
.tc-stumm .tc-eintrag-symbol::after { content: " ∅"; font-size: 10px; }
.tc-zahl, .tc-at { flex: none; min-width: 20px; padding: 1px 6px; border-radius: 10px; font-size: 11px; font-weight: 700; text-align: center; }
.tc-zahl { background: var(--zahl-blau-flaeche, #DCE7FD); color: var(--zahl-blau, #1D4ED8); }
.tc-at { background: var(--zahl-rot-flaeche, #FDE8E7); color: var(--zahl-rot, #B42318); }
.tc-person { align-items: flex-start; }
.tc-person-text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.tc-person-status { font-size: 12px; color: var(--tc-leise); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-status-symbol { flex: none; width: 1.1em; text-align: center; line-height: 1.4; }
.tc-status-symbol[data-anzeige="verfuegbar"], .tc-status-symbol[data-anzeige="untaetig"] { color: #15803D; }
.tc-status-symbol[data-anzeige="beschaeftigt"] { color: #B45309; }
.tc-status-symbol[data-anzeige="nicht_stoeren"] { color: #B91C1C; }
.tc-status-symbol[data-anzeige="abwesend"], .tc-status-symbol[data-anzeige="offline"] { color: #64748B; }
.tc-status-symbol[data-anzeige="im_gespraech"] { color: #6D28D9; }
.tc-neu, .tc-archiv-knopf { margin-top: 4px; padding: 6px 8px; border: 0; border-radius: 8px; background: none; font: inherit; font-size: 13px;
  font-weight: 600; color: var(--accent-hover, #1D4ED8); cursor: pointer; text-align: left; min-height: 32px; }
.tc-neu:hover, .tc-archiv-knopf:hover { background: var(--tc-hover); }
.tc-archiv-knopf { color: var(--tc-leise); }
.tc-archiv-knopf::before { content: "▸ "; }
.tc-archiv-knopf[aria-expanded="true"]::before { content: "▾ "; }
.tc-klein { font-size: 12px; line-height: 1.45; color: var(--tc-leise); }
.tc-nichts { padding: 4px 8px; }

/* ── Gespräch ─────────────────────────────────────────────────────────── */
.tc-gespraech { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tc-zurueck { align-self: flex-start; margin: 10px 12px 0; padding: 6px 10px; border: 0; border-radius: 8px; background: none; font: inherit;
  font-size: 14px; font-weight: 600; color: var(--accent-hover, #1D4ED8); cursor: pointer; min-height: 40px; }
.tc-kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 18px 12px; border-bottom: 1px solid var(--tc-rand); }
.tc-kopf-text { min-width: 0; }
.tc-kopf h1 { font-size: 18px; font-weight: 700; line-height: 1.3; color: var(--text, #0F172A); overflow-wrap: anywhere; }
.tc-kopf h1:focus { outline: none; }
.tc-kopf h1:focus-visible { outline: 2px solid var(--accent, #2563EB); outline-offset: 2px; }
.tc-unterzeile { margin-top: 2px; font-size: 13px; color: var(--tc-leise); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; overflow-wrap: anywhere; }
.tc-kopf-knoepfe { position: relative; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tc-mehr { font-size: 16px; line-height: 1; min-width: 34px; justify-content: center; }
.tc-hinweis, .tc-archiviert { display: flex; align-items: center; gap: 12px; margin: 10px 18px 0; padding: 10px 12px; border-radius: 8px;
  background: #EFF6FF; color: #1E3A8A; font-size: 13px; line-height: 1.45; }
.tc-hinweis p, .tc-archiviert p { flex: 1 1 auto; }
.tc-archiviert { background: #F1F5F9; color: #334155; }

.tc-verlauf-rahmen { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px 18px 12px; overscroll-behavior: contain; }
.tc-aelter { display: flex; margin: 6px auto 10px; }
.tc-leer { margin: 24px 0; text-align: center; color: var(--tc-leise); font-size: 14px; }
.tc-verlauf { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.tc-trenner { display: flex; align-items: center; gap: 10px; margin: 12px 0 6px; font-size: 12px; font-weight: 600; color: var(--tc-leise); }
.tc-trenner::before, .tc-trenner::after { content: ""; flex: 1; height: 1px; background: var(--tc-rand); }
.tc-trenner-neu { color: var(--tc-neu); }
.tc-trenner-neu::before, .tc-trenner-neu::after { background: var(--tc-neu); }
.tc-system { padding: 4px 0 4px 46px; font-size: 13px; color: var(--tc-leise); font-style: italic; }
.tc-system time { font-style: normal; font-size: 11px; margin-left: 4px; }

.tc-n { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 6px 8px; border-radius: 8px; }
.tc-n:hover { background: #FAFBFC; }
.tc-eigen { background: var(--tc-eigen); }
.tc-eigen:hover { background: #EEF3FF; }
.tc-fuer-mich { box-shadow: inset 3px 0 0 #D97706; }
.tc-ziel { background: #FEF9C3; transition: background .6s; }
.tc-avatar { width: 32px; height: 32px; border-radius: 50%; background: #E0E7FF; color: #3730A3; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 2px; }
.tc-eigen .tc-avatar { background: #DBEAFE; color: #1E40AF; }
.tc-n-kopf { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.tc-n-name { font-weight: 700; font-size: 14px; color: var(--text, #0F172A); }
.tc-n-kopf time { font-size: 12px; color: var(--tc-leise); }
.tc-n-bearbeitet { font-size: 12px; color: var(--tc-leise); }
.tc-n-text { margin-top: 2px; font-size: 14px; line-height: 1.5; color: var(--text, #0F172A); white-space: pre-wrap; overflow-wrap: anywhere; }
.tc-n-text a { color: var(--accent-hover, #1D4ED8); text-decoration: underline; }
.tc-n-weg { color: var(--tc-leise); font-style: italic; }
.tc-erwaehnung { background: var(--tc-mark); color: var(--tc-mark-text); border-radius: 4px; padding: 0 2px; }
.tc-erwaehnung-ich { font-weight: 700; box-shadow: 0 0 0 1.5px #D97706; }
.tc-anhang { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; padding: 8px 10px; max-width: 520px;
  border: 1px solid var(--tc-rand); border-radius: 8px; background: #fff; }
.tc-anhang-symbol { font-size: 18px; }
.tc-anhang-name { flex: 1 1 160px; min-width: 0; font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.tc-anhang-groesse { font-size: 12px; color: var(--tc-leise); }
.tc-n-aktion { width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--tc-leise); font-size: 16px; line-height: 1;
  cursor: pointer; opacity: .55; }
.tc-n:hover .tc-n-aktion, .tc-n-aktion:focus-visible, .tc-n-aktion[aria-expanded="true"] { opacity: 1; background: var(--tc-hover); }
@media (hover: none) { .tc-n-aktion { opacity: 1; } }
.tc-nach-unten { position: absolute; right: 24px; bottom: 132px; z-index: 5; padding: 8px 14px; border: 0; border-radius: 18px;
  background: var(--accent, #2563EB); color: #fff; font: inherit; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-md); cursor: pointer; }

/* ── Eingabe ──────────────────────────────────────────────────────────── */
.tc-eingabe { padding: 10px 18px 14px; border-top: 1px solid var(--tc-rand); background: #fff; }
.tc-feld-rahmen { position: relative; }
.tc-feld { display: block; width: 100%; min-height: 42px; max-height: 12em; padding: 10px 12px; border: 1.5px solid var(--tc-rand); border-radius: 10px;
  font: inherit; font-size: 14px; line-height: 1.45; resize: none; overflow-y: auto; background: #fff; color: var(--text, #0F172A); }
.tc-feld:focus { border-color: var(--accent, #2563EB); outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.tc-eingabe-zeile { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.tc-eingabe-zeile .tc-klein { flex: 1 1 auto; min-width: 0; }
.tc-eingabe-zeile .btn { flex: none; }
.tc-fehler { margin-top: 6px; font-size: 13px; color: #B42318; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tc-fehler:empty { display: none; }
.tc-vorschlaege { position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 30; min-width: 260px; max-width: 100%; max-height: 260px; overflow-y: auto;
  list-style: none; margin: 0; padding: 4px; background: #fff; border: 1px solid var(--tc-rand); border-radius: 10px; box-shadow: 0 12px 32px rgba(15,23,42,.18); }
.tc-vorschlaege [role="option"] { display: flex; align-items: baseline; gap: 8px; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.tc-vorschlaege [role="option"]:hover { background: var(--tc-hover); }
.tc-vorschlaege .tc-gewaehlt { background: var(--tc-aktiv); color: var(--tc-aktiv-text); outline: 2px solid var(--accent, #2563EB); outline-offset: -2px; }
.tc-vorschlag-name { font-weight: 600; }
.tc-vorschlag-hilfe { font-size: 12px; color: var(--tc-leise); }

/* ── Menüs ────────────────────────────────────────────────────────────── */
.tc-menue { position: absolute; right: 0; top: calc(100% + 4px); z-index: 40; min-width: 210px; padding: 6px; background: #fff; color: var(--text, #0F172A);
  border: 1px solid var(--tc-rand); border-radius: 10px; box-shadow: 0 12px 32px rgba(15,23,42,.18); display: flex; flex-direction: column; }
/* Menü einer Nachricht: in #tc-menue-ort (außerhalb von role=log), top/right setzt team.js am Knopf */
.tc-menue-ort > .tc-menue { top: 0; right: 0; }
.tc-menue [role="menuitem"] { display: block; width: 100%; min-height: 34px; padding: 6px 10px; border: 0; border-radius: 8px; background: none;
  font: inherit; font-size: 14px; color: inherit; text-align: left; cursor: pointer; }
.tc-menue [role="menuitem"]:hover, .tc-menue [role="menuitem"]:focus-visible { background: var(--tc-hover); }
.tc-menue [role="menuitem"]:focus-visible { outline: 2px solid var(--accent, #2563EB); outline-offset: -2px; }
.tc-menue .tc-gefahr { color: #B42318; }

/* ── Dialoge ──────────────────────────────────────────────────────────── */
/* Wie .modal-bg (500): unter der Hinweisleiste der Sitzung (.sitzung-hinweis 600). Solange sie
   steht, rückt der Dialog unter ihre Unterkante (body.sitzung-aus, --sitzung-unten, 14.11). */
.tc-dialog-bg { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15,23,42,.45); }
body.sitzung-aus .tc-dialog-bg { padding-top: calc(var(--sitzung-unten, var(--topbar-h, 60px)) + 16px); }
body.sitzung-aus .tc-dialog { max-height: calc(100dvh - var(--sitzung-unten, var(--topbar-h, 60px)) - 32px); }
.tc-dialog { width: min(460px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 22px 22px 18px; border-radius: 14px; background: #fff;
  color: var(--text, #0F172A); box-shadow: 0 24px 60px rgba(15,23,42,.3); display: flex; flex-direction: column; gap: 8px; }
.tc-dialog-breit { width: min(760px, 100%); }
.tc-dialog textarea.tc-bearbeiten { min-height: 96px; resize: vertical; }
.tc-dialog h2 { font-size: 17px; font-weight: 700; line-height: 1.35; margin-bottom: 4px; overflow-wrap: anywhere; }
.tc-dialog label { font-size: 13px; font-weight: 600; color: #334155; }
.tc-dialog input[type="text"], .tc-dialog textarea, .tc-dialog select { width: 100%; padding: 9px 12px; border: 1.5px solid var(--tc-rand); border-radius: 8px;
  font: inherit; font-size: 14px; background: #fff; color: var(--text, #0F172A); }
.tc-dialog input[type="text"]:focus, .tc-dialog textarea:focus, .tc-dialog select:focus { border-color: var(--accent, #2563EB); outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.tc-dialog fieldset { border: 1px solid var(--tc-rand); border-radius: 8px; padding: 8px 12px 10px; margin-top: 4px; }
.tc-dialog legend { padding: 0 4px; font-size: 13px; font-weight: 600; color: #334155; }
.tc-wahl, .tc-haken { display: flex; align-items: flex-start; gap: 8px; padding: 4px 0; }
.tc-wahl input, .tc-haken input { margin-top: 3px; width: 16px; height: 16px; flex: none; }
.tc-wahl label { display: flex; flex-direction: column; font-weight: 400; }
.tc-wahl strong { font-weight: 600; }
.tc-haken label { font-weight: 400; }
.tc-dialog .tc-fehler:empty { display: none; }
.tc-dialog progress { width: 100%; height: 8px; }
.tc-dialog-knoepfe { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.tc-mitglieder { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.tc-mitglieder li { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid #F1F5F9; }
.tc-mitglied-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.tc-hinzu { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.tc-hinzu select { flex: 1 1 180px; width: auto; }
.tc-tabelle-rahmen { overflow-x: auto; }
.tc-tabelle { width: 100%; border-collapse: collapse; font-size: 14px; }
.tc-tabelle th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--tc-leise); padding: 8px; border-bottom: 1px solid var(--tc-rand); }
.tc-tabelle td { padding: 8px; border-bottom: 1px solid #F1F5F9; vertical-align: middle; overflow-wrap: anywhere; }
.tc-tabelle-knoepfe { white-space: nowrap; text-align: right; }
.tc-tabelle-knoepfe .btn + .btn { margin-left: 6px; }

/* ── Schmal: Liste oder Gespräch ──────────────────────────────────────── */
@media (max-width: 899px) {
  .tc { grid-template-columns: minmax(0, 1fr); height: calc(100vh - var(--topbar-h, 60px) - 32px); height: calc(100dvh - var(--topbar-h, 60px) - 32px); min-height: 380px; }
  .tc-liste { border-right: 0; }
  .tc-kopf { flex-direction: column; padding: 8px 14px 10px; }
  .tc-kopf-knoepfe { justify-content: flex-start; }
  .tc-verlauf-rahmen { padding: 6px 10px 10px; }
  .tc-eingabe { padding: 8px 10px 10px; }
  .tc-hinweis, .tc-archiviert { margin: 8px 10px 0; flex-wrap: wrap; }
  .tc-n { grid-template-columns: 30px minmax(0, 1fr) auto; gap: 8px; padding: 6px 4px; }
  .tc-avatar { width: 28px; height: 28px; font-size: 11px; }
  .tc-system { padding-left: 38px; }
  .tc-eingabe-zeile { flex-wrap: wrap; }
  .tc-eingabe-zeile .tc-klein { order: 3; flex-basis: 100%; }
  .tc-eingabe-zeile .tc-anhaengen { flex: 1 1 auto; }
  .tc-eintrag { min-height: 44px; }
  .tc-nach-unten { bottom: 150px; right: 14px; }
}
@media (max-width: 560px) {
  .tc { height: calc(100dvh - var(--topbar-h, 60px) - 24px); border-radius: 8px; }
  .tc-eingabe-zeile .btn { width: auto; }
  .tc-dialog { padding: 18px 14px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .tc-ziel { transition: none; }
}
@media (forced-colors: active) {
  .tc-eintrag[aria-current="true"] { outline: 2px solid Highlight; }
  .tc-erwaehnung { border: 1px solid CanvasText; }
  .tc-zahl, .tc-at { border: 1px solid CanvasText; }
}
