/* Kunden-Messenger als Live-Chat (messenger-chat.js). Baut auf .wm (workspace-modules.css) und den Lila-Tokens auf.
   Zwei Spalten ab 900 px (Gesprächsliste links, Gespräch rechts); darunter zwei Ansichten mit Zurück (data-state list|chat).
   Dark Mode über html[data-workspace-theme="dark"]. Nur Bildschirm. */
@media screen {
  .mc { --mc-team-bg:var(--wm-accent); --mc-team-text:#fff; --mc-family-bg:var(--wm-surface); --mc-tick:var(--wm-muted); --mc-tick-read:var(--wm-accent); --mc-new:#fbf5ff;
    display:grid; grid-template-columns:minmax(300px,380px) minmax(0,1fr); gap:0; height:calc(100vh - 168px); min-height:520px; max-height:1100px;
    border:1px solid var(--wm-line); border-radius:12px; background:var(--wm-soft); box-shadow:var(--wm-shadow); overflow:hidden; }
  html[data-workspace-theme="dark"] .mc { --mc-team-bg:#4f2b63; --mc-team-text:#f8f1fc; --mc-tick-read:#deb6ef; --mc-new:#2f2436; }
  .mc h1, .mc h2 { margin:0; font-weight:600; }
  .mc h1 { font-size:22px; line-height:1.2; }
  .mc h2 { font-size:16px; line-height:1.25; }
  .mc .muted { font-size:11px; letter-spacing:.06em; text-transform:uppercase; margin:6px 0 2px; }

  /* Gesprächsliste */
  .mc-list { display:flex; flex-direction:column; min-width:0; min-height:0; border-right:1px solid var(--wm-line); background:var(--wm-surface); }
  .mc-head { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; padding:16px 16px 10px; }
  .mc-head .wm-eyebrow { margin-bottom:2px; }
  .mc-bell { padding:7px; border-radius:50%; }
  .mc-bell[data-mode="on"] { border-color:var(--wm-accent); background:var(--wm-tint); color:var(--wm-accent); }
  .mc-search { padding:0 16px 10px; }
  .mc-search-field { display:flex; align-items:center; gap:8px; height:36px; padding:0 11px; border:1px solid var(--wm-line); border-radius:8px; background:var(--wm-soft); color:var(--wm-muted); }
  .mc-search-field:focus-within { border-color:var(--wm-accent); box-shadow:0 0 0 2px rgba(100,49,130,.14); }
  .mc-search-field input { flex:1; min-width:0; border:0; background:transparent; font:inherit; color:var(--wm-text); outline:none; }
  .mc-filters { display:flex; gap:6px; padding:0 16px 10px; flex-wrap:wrap; }
  .mc-filters button { display:inline-flex; align-items:center; gap:6px; height:28px; padding:0 10px; border:1px solid var(--wm-line); border-radius:999px; background:var(--wm-surface); font:inherit; font-size:12.5px; color:var(--wm-text); cursor:pointer; }
  .mc-filters button[aria-pressed="true"] { border-color:var(--wm-accent); background:var(--wm-tint); color:var(--wm-accent); font-weight:600; }
  .mc-filters button b { min-width:18px; padding:0 5px; border-radius:999px; background:var(--wm-soft); font-size:11px; line-height:18px; text-align:center; color:var(--wm-muted); }
  .mc-filters button[aria-pressed="true"] b { background:var(--wm-accent); color:#fff; }
  .mc-rows { flex:1; margin:0; padding:0 8px 8px; list-style:none; overflow-y:auto; border-top:1px solid var(--wm-line); }
  .mc-rows li { min-width:0; }
  .mc-row { display:grid; grid-template-columns:40px minmax(0,1fr) auto; align-items:center; gap:10px; width:100%; padding:10px 10px; margin-top:6px; border:1px solid transparent; border-radius:10px; background:transparent; font:inherit; color:inherit; text-align:left; cursor:pointer; transition:background .15s, border-color .15s; }
  .mc-row:hover { background:var(--wm-soft); }
  .mc-row.active { border-color:var(--wm-line); background:var(--wm-tint); }
  .mc-row.unread strong, .mc-row.unread .mc-row-last { color:var(--wm-text); font-weight:650; }
  .mc-row-main { display:grid; gap:2px; min-width:0; }
  .mc-row-top { display:flex; align-items:baseline; justify-content:space-between; gap:8px; min-width:0; }
  .mc-row-top strong { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; font-weight:600; font-size:14px; }
  .mc-row-top time { flex-shrink:0; font-size:11.5px; color:var(--wm-muted); font-variant-numeric:tabular-nums; }
  .mc-row small { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; font-size:11.5px; color:var(--wm-muted); }
  .mc-row-last { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; font-size:13px; color:var(--wm-muted); }
  .mc-row-last em { font-style:italic; color:var(--wm-accent); }
  .mc-you { color:var(--wm-muted); }
  .mc-chip { justify-self:start; margin-top:3px; padding:1px 7px; border-radius:999px; background:var(--wm-soft); border:1px solid var(--wm-line); font-size:11px; color:var(--wm-muted); max-width:100%; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
  .mc-unread { min-width:22px; height:22px; padding:0 6px; border-radius:999px; background:var(--wm-accent); color:#fff; font-size:12px; font-weight:700; line-height:22px; text-align:center; }
  .mc-empty { padding:24px 16px; color:var(--wm-muted); font-size:13.5px; text-align:center; }
  .mc-empty p { margin:0; }

  .mc-avatar { display:inline-flex; align-items:center; justify-content:center; width:40px; height:40px; border-radius:50%; font-size:14px; font-weight:700; letter-spacing:.02em; color:#fff; background:var(--wm-accent); flex-shrink:0; }
  .mc-avatar[data-tone="1"] { background:#2f6f68; } .mc-avatar[data-tone="2"] { background:#476b92; } .mc-avatar[data-tone="3"] { background:#8a5a2b; }
  .mc-avatar[data-tone="4"] { background:#a451aa; } .mc-avatar[data-tone="5"] { background:#5a6b35; } .mc-avatar[data-tone="6"] { background:#b45b55; }

  /* Gespräch */
  .mc-chat { display:flex; flex-direction:column; min-width:0; min-height:0; background:var(--wm-soft); }
  .mc-blank { display:grid; place-content:center; justify-items:center; gap:8px; height:100%; padding:32px; text-align:center; color:var(--wm-muted); }
  .mc-blank-icon { display:inline-flex; width:56px; height:56px; align-items:center; justify-content:center; border-radius:50%; background:var(--wm-tint); color:var(--wm-accent); }
  .mc-blank-icon svg { width:26px; height:26px; }
  .mc-blank h2 { color:var(--wm-text); }
  .mc-blank p { max-width:380px; margin:0; font-size:13.5px; line-height:1.5; }
  .mc-chat-head { display:flex; align-items:center; gap:12px; padding:12px 16px; border-bottom:1px solid var(--wm-line); background:var(--wm-surface); }
  .mc-back { display:none; padding:6px; }
  .mc-back svg { transform:rotate(180deg); }
  .mc-chat-title { flex:1; min-width:0; }
  .mc-chat-title h2 { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
  .mc-chat-title small { display:block; font-size:12px; color:var(--wm-muted); }
  .mc-typing { margin:2px 0 0; font-size:12px; font-style:italic; color:var(--wm-accent); }
  .mc-typing::after { content:""; display:inline-block; width:4px; height:4px; margin-left:4px; border-radius:50%; background:currentColor; animation:mc-blink 1s infinite; }
  @keyframes mc-blink { 50% { opacity:.2; } }
  .mc-chat-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
  .mc-assign { display:flex; align-items:center; gap:6px; font-size:12px; color:var(--wm-muted); }
  .mc-assign select { height:30px; max-width:170px; padding:0 8px; border:1px solid var(--wm-line); border-radius:7px; background:var(--wm-surface); font:inherit; font-size:12.5px; color:var(--wm-text); }
  .mc-chat-actions .button { height:30px; padding:0 10px; font-size:12.5px; }
  .mc-messages { flex:1; min-height:0; overflow-y:auto; padding:14px 18px; display:flex; flex-direction:column; gap:6px; }
  .mc-messages:focus-visible { outline-offset:-2px; }
  .mc-day { display:flex; align-items:center; gap:10px; margin:10px 0 6px; color:var(--wm-muted); font-size:11.5px; letter-spacing:.04em; text-transform:uppercase; }
  .mc-day::before, .mc-day::after { content:""; flex:1; height:1px; background:var(--wm-line); }
  .mc-bubble { position:relative; max-width:min(72%, 620px); padding:9px 12px 7px; border-radius:14px; box-shadow:var(--wm-shadow); font-size:14px; line-height:1.45; word-break:break-word; }
  .mc-bubble p { margin:0; white-space:pre-wrap; }
  .mc-bubble.family { align-self:flex-start; border:1px solid var(--wm-line); border-bottom-left-radius:4px; background:var(--mc-family-bg); color:var(--wm-text); }
  .mc-bubble.family.new { background:var(--mc-new); }
  .mc-bubble.team { align-self:flex-end; border-bottom-right-radius:4px; background:var(--mc-team-bg); color:var(--mc-team-text); }
  .mc-bubble.pending { opacity:.7; }
  .mc-bubble-author { display:block; margin-bottom:2px; font-size:11.5px; font-weight:600; color:var(--wm-accent); }
  .mc-bubble.team .mc-bubble-author { color:inherit; opacity:.85; }
  .mc-bubble footer { display:flex; align-items:center; justify-content:flex-end; gap:6px; margin-top:4px; font-size:11px; opacity:.85; }
  .mc-bubble.family footer { color:var(--wm-muted); }
  .mc-status { font-weight:700; letter-spacing:-.12em; color:var(--mc-tick); }
  .mc-bubble.team .mc-status { color:rgba(255,255,255,.8); }
  .mc-bubble.team .mc-status[data-status="read"] { color:#ffe9a8; }
  html[data-workspace-theme="dark"] .mc-bubble.team .mc-status[data-status="read"] { color:#ffe9a8; }
  .mc-status.compact { font-size:12px; color:var(--mc-tick); }
  .mc-status.compact[data-status="read"] { color:var(--mc-tick-read); }
  .mc-read-by { font-style:italic; }
  .mc-attachment { display:inline-flex; align-items:center; gap:6px; margin-top:6px; padding:5px 9px; border:1px solid rgba(255,255,255,.4); border-radius:8px; background:rgba(255,255,255,.14); font:inherit; font-size:12.5px; color:inherit; cursor:pointer; }
  .mc-bubble.family .mc-attachment { border-color:var(--wm-line); background:var(--wm-soft); color:var(--wm-accent); }
  .mc-attachment span { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; max-width:260px; }
  .mc-empty-chat { margin:auto; max-width:380px; text-align:center; color:var(--wm-muted); font-size:13.5px; }

  /* Schreibfeld */
  .mc-compose { display:grid; gap:6px; padding:10px 14px 12px; border-top:1px solid var(--wm-line); background:var(--wm-surface); }
  .mc-compose-tools { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
  .mc-compose-tools .button { height:28px; padding:0 9px; font-size:12px; }
  .mc-compose-tools select { height:28px; max-width:240px; padding:0 8px; border:1px solid var(--wm-line); border-radius:7px; background:var(--wm-surface); font:inherit; font-size:12px; color:var(--wm-text); }
  .mc-hint { margin-left:auto; font-size:11px; color:var(--wm-muted); }
  .mc-templates { display:grid; gap:4px; max-height:220px; overflow-y:auto; padding:8px; border:1px solid var(--wm-line); border-radius:10px; background:var(--wm-soft); }
  .mc-templates button { display:grid; gap:2px; padding:7px 9px; border:1px solid transparent; border-radius:8px; background:var(--wm-surface); font:inherit; font-size:12.5px; line-height:1.4; color:var(--wm-text); text-align:left; cursor:pointer; }
  .mc-templates button:hover { border-color:var(--wm-accent); }
  .mc-templates button strong { font-size:12px; color:var(--wm-accent); }
  .mc-compose-row { display:flex; align-items:flex-end; gap:8px; }
  .mc-compose textarea { flex:1; min-height:40px; max-height:170px; padding:9px 12px; border:1px solid var(--wm-line); border-radius:12px; background:var(--wm-soft); font:inherit; font-size:14px; line-height:1.4; color:var(--wm-text); resize:none; }
  .mc-compose textarea:focus { border-color:var(--wm-accent); outline:none; box-shadow:0 0 0 2px rgba(100,49,130,.14); }
  .mc-send { width:40px; height:40px; padding:0; border-radius:50%; justify-content:center; }
  .mc-send svg { width:18px; height:18px; }
  .mc-sr { position:absolute; width:1px; height:1px; margin:-1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

  @media (max-width: 899px) {
    .mc { grid-template-columns:1fr; height:calc(100vh - 150px); min-height:460px; border-radius:10px; }
    .mc-list { border-right:0; }
    .mc[data-state="list"] .mc-chat, .mc[data-state="chat"] .mc-list { display:none; }
    .mc-back { display:inline-flex; }
    .mc-chat-head { flex-wrap:wrap; padding:10px 12px; }
    .mc-chat-actions { width:100%; justify-content:flex-start; }
    .mc-assign select { max-width:140px; }
    .mc-messages { padding:10px 12px; }
    .mc-bubble { max-width:86%; }
    .mc-compose { padding:8px 10px 10px; }
    .mc-hint { display:none; }
  }
}
