/* Die Chat-Fläche sieht absichtlich nach WhatsApp aus: der Mitarbeiter soll sehen, was der Kunde sieht. Ihre Farbwerte (`--wa-*`) stehen einmal, in `outbound.css`. */

.cwmon-overlay {
  align-items: center;
  padding: var(--space-page);
}
#ask-modal {
  align-items: center;
}
.cwmon-box {
  width: 100%;
  max-width: 1080px;
  height: 86vh;
  display: flex;
  flex-direction: column;
  background-color: var(--popover);
  border-radius: var(--radius-3);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}
.cwmon-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-inset) var(--space-group);
  border-bottom: 1px solid var(--border-subtle);
  flex: none;
}
.cwmon-head strong {
  font-size: var(--text-3);
  line-height: var(--leading-3);
  font-weight: var(--weight-semibold);
}
.cwmon-head .x {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--control-md);
  height: var(--control-md);
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  border-radius: var(--radius-2);
  transition: background var(--motion-fast), color var(--motion-fast);
}
.cwmon-head .x:hover {
  background: var(--surface-hover);
  color: var(--foreground);
}
.cwmon-head .x svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}
.cwmon-wsim {
  height: auto;
  flex: 1;
  min-height: 0;
  border-radius: 0;
  box-shadow: none;
}
.cwmon-wsim .wa-btn {
  cursor: default;
  pointer-events: none;
}

.cwmon-foot {
  border-top: 1px solid var(--border-subtle);
  background: var(--surface);
  padding: var(--space-stack) var(--space-inset);
  display: flex;
  flex-direction: column;
  gap: var(--space-stack);
}
.cwmon-status {
  display: flex;
  align-items: center;
  gap: var(--space-stack);
  flex-wrap: wrap;
}
.cw-status-txt {
  flex: 1;
  min-width: 0;
}
.cw-status-main {
  font-size: var(--text-2);
  line-height: var(--leading-2);
  display: flex;
  align-items: center;
  gap: var(--space-stack);
}
.cw-status-hint {
  font-size: var(--text-1);
  line-height: var(--leading-1);
  color: var(--muted-foreground);
  margin-top: var(--space-inline);
  padding-left: var(--space-inset);
}
.cw-dot {
  flex: none;
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-circle);
  background: var(--warning-solid);
}
.cw-dot.ok {
  background: var(--success-solid);
  /* Der Halo macht die Lampe auch ohne Farbunterscheidung erkennbar. */
  box-shadow: 0 0 0 3px var(--success-surface);
}
.cw-dot.bot {
  background: var(--muted-foreground);
}
.cw-actbtn {
  flex: none;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  height: var(--control-md);
  font-size: var(--text-1);
  line-height: var(--leading-1);
  font-weight: var(--weight-semibold);
  padding: 0 var(--space-inset);
  border-radius: var(--radius-2);
  border: none;
  background: var(--surface-hover);
  color: var(--foreground);
  cursor: pointer;
  transition: background var(--motion-fast), color var(--motion-fast);
}
.cw-actbtn.take {
  background: var(--primary);
  color: var(--primary-foreground);
}
.cw-actbtn:hover {
  background: var(--surface-active);
}
.cw-actbtn.take:hover {
  background: var(--primary-hover);
}
.cw-actbtn:disabled {
  background: var(--disabled-surface);
  color: var(--disabled-foreground);
  cursor: not-allowed;
}
.cwmon-inputrow {
  display: flex;
  gap: var(--space-stack);
}
/* `display:flex` schlägt sonst `[hidden]`. */
.cwmon-inputrow[hidden],
.cwmon-foot[hidden] {
  display: none;
}
.cwmon-inputrow input {
  flex: 1;
  min-width: 0;
  height: var(--control-lg);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 0 var(--space-group);
  font: inherit;
  font-size: var(--text-2);
  line-height: var(--leading-2);
  background: var(--surface-hover);
  box-shadow: var(--inset-shadow);
  color: var(--foreground);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
.cwmon-inputrow input::placeholder {
  color: var(--muted-foreground);
}
.cwmon-inputrow input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--inset-shadow), 0 0 0 3px var(--accent-surface);
}
.cwmon-inputrow input:disabled {
  background: var(--disabled-surface);
  color: var(--disabled-foreground);
  cursor: not-allowed;
  font-style: italic;
}
.wa-send {
  border: none;
  border-radius: var(--radius-pill);
  height: var(--control-lg);
  padding: 0 var(--space-group);
  background: var(--primary);
  color: var(--primary-foreground);
  font: inherit;
  font-weight: var(--weight-semibold);
  font-size: var(--text-2);
  line-height: var(--leading-2);
  cursor: pointer;
  transition: background var(--motion-fast);
}
.wa-send:hover {
  background: var(--primary-hover);
}
.wa-send:disabled {
  background: var(--disabled-surface);
  color: var(--disabled-foreground);
  cursor: not-allowed;
}
.wsim-body .ob-bubble.op .bt-main {
  border-left: 0;
}
.op-tag {
  font-size: var(--text-1);
  line-height: var(--leading-1);
  font-weight: var(--weight-semibold);
  color: var(--accent-text);
  margin-bottom: var(--space-inline);
}
.op-tag--error {
  color: var(--danger-foreground);
}

/* Spezifität über `.acc .acts button`, das alles auf Link-Optik zurücksetzt. */
.acc .acts button.cw-monbtn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-stack);
  height: var(--control-md);
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: var(--radius-2);
  padding: 0 var(--space-inset);
  font-size: var(--text-1);
  line-height: var(--leading-1);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: background var(--motion-fast);
}
.acc .acts button.cw-monbtn:hover {
  background: var(--primary-hover);
  color: var(--primary-foreground);
}
.acc .acts button.cw-monbtn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}
.cw-monbadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 var(--space-inline);
  border-radius: var(--radius-pill);
  background: var(--warning-badge);
  color: var(--warning-badge-foreground);
  font-size: var(--text-1);
  line-height: var(--leading-1);
  font-weight: var(--weight-semibold);
}

.wt-badge {
  display: inline-block;
  font-size: var(--text-1);
  line-height: var(--leading-1);
  font-weight: var(--weight-medium);
  padding: var(--space-inline) var(--space-stack);
  border-radius: var(--radius-pill);
  background: var(--warning-badge);
  color: var(--warning-badge-foreground);
  margin-left: var(--space-inline);
}
.wt-unread {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--radius-circle);
  background: var(--danger-solid);
  color: white;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-left: var(--space-inline);
  flex: none;
}

.modal-box {
  background-color: var(--popover);
  border-radius: var(--radius-3);
  box-shadow: var(--shadow-float);
  width: 100%;
  max-width: 520px;
  padding: var(--space-section);
}
.modal-box h3 {
  margin: 0 0 var(--space-group);
  font-size: var(--text-3);
  line-height: var(--leading-3);
  font-weight: var(--weight-semibold);
}
.mb-actions {
  display: flex;
  gap: var(--space-stack);
  justify-content: flex-end;
  margin-top: var(--space-stack);
}

.wsim {
  display: grid;
  grid-template-columns: 340px 1fr;
  /* `vh` misst vor dem Zoom (grundlage.css). Die 132px sind nur Fallback ausserhalb des Chats-Tabs; dort gilt `#chats .wsim`. */
  height: calc(100vh / var(--ui-zoom, 1) - 132px);
  min-height: 520px;
  background-color: var(--surface);
  border-radius: var(--radius-3);
  box-shadow: var(--shadow-raised);
  overflow: hidden;
}
/* Füllt den echten Rest der Seite statt einer geschätzten Abzugszahl; die höhere Spezifität schlägt die Basisregel unabhängig von der Reihenfolge. */
#chats.active {
  display: flex;
  flex-direction: column;
  height: 100%;
}
#chats .wsim {
  height: auto;
  flex: 1;
  min-height: 520px;
}
.wsim-list {
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  padding: var(--space-inline);
}
.wsim-thread {
  display: flex;
  flex-direction: column;
  gap: var(--space-inline);
  padding: var(--space-inset);
  border-radius: var(--radius-2);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--foreground);
  transition: background var(--motion-fast);
}
.wsim-thread:hover {
  background: var(--surface-hover);
}
.wsim-thread.active {
  background: var(--accent-surface);
}
.wsim-thread .wt-top {
  display: flex;
  align-items: baseline;
  gap: var(--space-stack);
}
.wsim-thread .wt-name {
  font-weight: var(--weight-semibold);
  font-size: var(--text-2);
  line-height: var(--leading-2);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wsim-thread .wt-time {
  font-size: var(--text-1);
  line-height: var(--leading-1);
  color: var(--muted-foreground);
  flex: none;
}
.wsim-thread .wt-last {
  font-size: var(--text-1);
  line-height: var(--leading-1);
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wsim-thread .wt-last.in {
  color: var(--accent-text);
  font-weight: var(--weight-medium);
}

.wsim-thread.ungelesen .wt-last {
  color: var(--foreground);
  font-weight: var(--weight-medium);
}
.wsim-thread.ungelesen {
  box-shadow: inset 2px 0 0 var(--success-solid);
}

.wsim-chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.wsim-empty {
  margin: auto;
  color: var(--muted-foreground);
  font-size: var(--text-2);
  line-height: var(--leading-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-stack);
  padding: var(--space-page) var(--space-group);
}
.wsim-empty svg {
  width: 40px;
  height: 40px;
  stroke: var(--muted-foreground);
  fill: none;
  stroke-width: 1.5;
  opacity: 0.6;
}
/* [hidden] muss display:flex/grid schlagen (gleiche Spezifität, Quell-Reihenfolge) */
.wsim-empty[hidden],
.wsim-conv[hidden] {
  display: none;
}
#chats .wsim--no-chats {
  grid-template-columns: 1fr;
}
#chats .wsim--no-chats .wsim-list {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: none;
}
#chats .wsim--no-chats .wsim-chat {
  display: none;
}
.wsim-conv {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  min-height: 0;
}
.ch-history {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
}
.ch-history > .wsim-body { min-width: 0; }
.ch-bottom {
  --primary: var(--brand-9);
  --primary-hover: var(--brand-10);
  position: absolute;
  bottom: var(--space-stack);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-float);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.ch-bottom[hidden] { display: none; }
.ch-bottom:hover { background: var(--primary-hover); }
.ch-bottom:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ch-bottom svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.wsim-head {
  display: flex;
  align-items: center;
  gap: var(--space-stack);
  padding: var(--space-inset) var(--space-group);
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border-subtle);
  flex: none;
}
.wsim-head .wh-av {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-circle);
  background: var(--primary);
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-semibold);
  font-size: var(--text-2);
  line-height: var(--leading-2);
  flex: none;
}
.wsim-head .wh-name {
  font-weight: var(--weight-semibold);
  font-size: var(--text-2);
  line-height: var(--leading-2);
}
.wsim-head .wh-sub {
  font-size: var(--text-1);
  line-height: var(--leading-1);
  color: var(--muted-foreground);
}
#ch-back {
  display: none;
  flex: none;
}

/* Unter 760px nur eine Spalte, Liste oder Gespräch. Auf `#chats` begrenzt: die Kampagnen-Überwachung nutzt dieselbe `.wsim` ohne `#ch-back` und `.wsim--open`. */
@media (max-width: 760px) {
  #chats .wsim {
    grid-template-columns: 1fr;
  }
  #chats .wsim-chat {
    display: none;
  }
  #chats .wsim.wsim--open .wsim-list {
    display: none;
  }
  #chats .wsim.wsim--open .wsim-chat {
    display: flex;
  }
  #chats #ch-back {
    display: inline-flex;
  }
  /* Treffen `--open` und `--no-chats` zusammen (ein Poll liefert eine leere Liste), gewinnt «keine Chats». */
  #chats .wsim--no-chats.wsim--open .wsim-chat {
    display: none;
  }
}

.ch-korb {
  flex: none;
  padding: var(--space-stack) var(--space-group);
  background: var(--surface-hover);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-2);
  line-height: var(--leading-2);
}
.ch-korb[hidden] {
  display: none;
}
.ch-korb-kopf {
  font-size: var(--text-1);
  line-height: var(--leading-1);
  color: var(--muted-foreground);
  margin-bottom: var(--space-inline);
}
.ch-korb-zeile {
  display: flex;
  justify-content: space-between;
  gap: var(--space-inset);
}
.ch-korb-zeile span:last-child {
  color: var(--muted-foreground);
}

.ch-zuordnen {
  flex: none;
  padding: var(--space-inset) var(--space-group);
  background: var(--surface-hover);
  border-bottom: 1px solid var(--border-subtle);
}
.ch-zuordnen[hidden] {
  display: none;
}
.ch-zuordnen-kopf {
  font-size: var(--text-1);
  line-height: var(--leading-1);
  color: var(--muted-foreground);
  margin-bottom: var(--space-stack);
}
.ch-zuordnen input {
  width: 100%;
  height: var(--control-lg);
  padding: 0 var(--space-inset);
  border: 1px solid transparent;
  border-radius: var(--radius-2);
  background: var(--surface);
  box-shadow: var(--inset-shadow);
  color: var(--foreground);
  font: inherit;
  font-size: var(--text-2);
  line-height: var(--leading-2);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
.ch-zuordnen input::placeholder {
  color: var(--muted-foreground);
}
.ch-zuordnen input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--inset-shadow), 0 0 0 3px var(--accent-surface);
}
.ch-zuordnen-treffer {
  margin-top: var(--space-stack);
  max-height: 160px;
  overflow: auto;
}
.ch-zuordnen-treffer .cz-sub {
  color: var(--muted-foreground);
  font-size: var(--text-1);
  line-height: var(--leading-1);
}
.ch-zuordnen-treffer .cz-leer {
  padding: var(--space-inline) var(--space-stack);
}
.wsim-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-group) 7%;
  background: var(--wa-bg);
  display: flex;
  flex-direction: column;
  gap: var(--space-inline);
}
.wsim-body .ob-bubble {
  position: relative;
  z-index: 1;
  max-width: 85%;
}
.wsim-body .ob-bubble.out {
  align-self: flex-end;
  min-width: 0;
  background: var(--wa-out);
  /* 7.5px ist WhatsApps Blasenradius, wie an `.ob-bubble` in `outbound.css`. */
  border-top-left-radius: 7.5px;
  border-top-right-radius: 0;
}
.wsim-body .ob-bubble.out::after {
  left: auto;
  right: -7px;
  background: var(--wa-out);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.wsim-body .wa-btn {
  cursor: pointer;
}
.wsim-body .wa-btn:hover {
  background: color-mix(in srgb, var(--wa-accent) 10%, transparent);
}
.wsim-typing {
  align-self: flex-start;
  z-index: 1;
  color: var(--wa-meta);
  font-size: var(--text-1);
  line-height: var(--leading-1);
  font-style: italic;
  padding: var(--space-inline) var(--space-stack);
}
.wsim-input {
  display: flex;
  gap: var(--space-stack);
  padding: var(--space-stack) var(--space-inset);
  background: var(--surface-subtle);
  border-top: 1px solid var(--border-subtle);
  flex: none;
}
.wsim-input input {
  flex: 1;
  min-width: 0;
  height: var(--control-lg);
  border: 1px solid transparent;
  background: var(--surface-hover);
  box-shadow: var(--inset-shadow);
  border-radius: var(--radius-pill);
  padding: 0 var(--space-group);
  font: inherit;
  font-size: var(--text-2);
  line-height: var(--leading-2);
  color: var(--foreground);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
.wsim-input input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--inset-shadow), 0 0 0 3px var(--accent-surface);
}
.wsim-input button {
  width: var(--control-lg);
  height: var(--control-lg);
  border-radius: var(--radius-circle);
  border: none;
  background: var(--primary);
  color: var(--primary-foreground);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: background var(--motion-fast);
}
.wsim-input button:hover {
  background: var(--primary-hover);
}
.wsim-input button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Thread- und Treffer-Zeile sind Knöpfe ohne Kontur; ohne Ring weiss man mit der Tastatur nicht, wo man steht. */
.wsim-thread:focus-visible,
.ch-zuordnen-treffer button:focus-visible,
.cw-actbtn:focus-visible,
.wa-send:focus-visible,
.cwmon-head .x:focus-visible,
.wsim-input button:focus-visible,
.acc .acts button.cw-monbtn:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.wsim-laden {
  display: flex;
  flex-direction: column;
  gap: var(--space-stack);
  padding: var(--space-stack);
}
.wsim-laden-zeile {
  display: flex;
  flex-direction: column;
  gap: var(--space-stack);
  padding: var(--space-inset);
}
.wsim-body .wsim-laden {
  align-self: stretch;
  padding: 0;
  gap: var(--space-inset);
}
.wsim-lade-blase {
  height: 44px;
  width: 60%;
  border-radius: var(--radius-2);
}
.wsim-lade-blase.out {
  align-self: flex-end;
  width: 45%;
}
.wsim-list > .state,
.wsim-body > .state,
.wsim-chat > .state {
  margin: auto;
}
/* `.state` ist flex und schlägt sonst `[hidden]`. */
.wsim-chat > .state[hidden] {
  display: none;
}

/* Dieselbe Füllstufe wie beim System-`.input`, Messwerte in grundlage.css. `:where()` lässt Fokus und Sperre gewinnen. */
:where(html) .cwmon-inputrow input,
:where(html) .ch-zuordnen input,
:where(html) .wsim-input input {
  background: var(--surface-active);
}

.wsim { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
.wsim-list { padding: var(--space-stack); }
.wsim-thread {
  flex-direction: row;
  align-items: center;
  gap: var(--space-inset);
  min-height: 76px;
  padding: var(--space-inset) var(--space-stack);
}
.wsim-thread.active { background: var(--surface-active); }
.wsim-thread.ungelesen {
  box-shadow: none;
  background: var(--accent-surface);
}
.wt-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface-hover);
  color: var(--muted-foreground);
  overflow: hidden;
}
.wt-avatar svg { width: 26px; height: 26px; }
.wt-copy { display: flex; flex: 1; flex-direction: column; gap: 5px; min-width: 0; }
.wsim-thread .wt-name { color: var(--muted-foreground); font-weight: var(--weight-regular); }
.wsim-thread.ungelesen .wt-name { color: var(--foreground); font-weight: 700; }
.wsim-thread.active .wt-name { color: var(--foreground); }
.wt-bottom { display: flex; align-items: center; gap: var(--space-stack); min-width: 0; }
.wsim-thread .wt-last,
.wsim-thread .wt-last.in { color: var(--muted-foreground); font-weight: var(--weight-regular); flex: 1; min-width: 0; }
.wsim-thread.ungelesen .wt-last { color: var(--foreground); }
.wsim-thread.ungelesen .wt-time { color: var(--accent-text); }
.wt-bottom .wt-unread { flex: none; margin: 0; }
.wt-bottom .wt-badge { margin: 0; flex: none; }
.wsim-head { min-height: 68px; padding: var(--space-inset) var(--space-group); }
.wsim-head > div { min-width: 0; }
.wsim-head .wh-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wsim-body { gap: var(--space-stack); padding: var(--space-group) 6%; }
.wsim-body .ob-bubble { align-self: flex-start; max-width: min(82%, 580px); min-width: 0; overflow-wrap: anywhere; }
.wsim-body .ob-bubble.out { align-self: flex-end; }
.wa-day {
  align-self: center;
  margin: var(--space-inset) 0;
  padding: 5px 12px;
  border-radius: var(--radius-2);
  background: var(--surface);
  color: var(--muted-foreground);
  font-size: var(--text-1);
  box-shadow: var(--shadow-raised);
}
.cwmon-foot { padding: var(--space-inset) var(--space-group); gap: var(--space-inset); }
.cwmon-inputrow { align-items: center; gap: var(--space-inset); }
.cwmon-inputrow input { min-height: 44px; border-radius: 24px; padding-inline: 18px; }
.cwmon-inputrow button { min-height: 44px; border-radius: 22px; padding-inline: 18px; }
.wsim-empty { gap: var(--space-group); }
@media (max-width: 760px) {
  #chats .wsim { grid-template-columns: minmax(0, 1fr); }
  .wsim-body { padding-inline: var(--space-group); }
  .cwmon-foot { padding-inline: var(--space-inset); }
}

.wsim-body {
  background-image: linear-gradient(color-mix(in srgb, var(--wa-bg) 94%, transparent), color-mix(in srgb, var(--wa-bg) 94%, transparent)), url("/dashboard/assets/wa-doodle.png");
  background-attachment: local;
}
.wsim-body::before { display: none; }

.wsim-thread { border-bottom: 1px solid var(--border-subtle); border-radius: var(--radius-2); margin-bottom: 4px; }
.wsim-thread:hover { background: var(--surface-hover); }
.wsim-thread.ungelesen { background: transparent; box-shadow: none; }
.wsim-thread.ungelesen:hover { background: var(--surface-hover); }
.wsim-thread.active,
.wsim-thread.active:hover {
  background: var(--accent-surface);
  box-shadow: none;
}
.ch-list-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 4px 16px; }
.ch-context-menu { display: flex; position: fixed; z-index: 1000; min-width: 220px; }
.ch-firm { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border-subtle); }
.ch-firm > div { min-width: 0; }
.ch-firm small { display: block; color: var(--muted-foreground); overflow-wrap: anywhere; }

.ch-customer-button { margin-left: auto; flex: none; }
.ch-customer-dialog { width: min(520px, calc(100vw - 32px)); max-height: 75vh; overflow: auto; padding: 24px; border: 1px solid var(--border-subtle); border-radius: var(--radius-3); background: var(--surface); color: var(--foreground); box-shadow: var(--shadow-raised); }
.ch-customer-dialog::backdrop { background: rgb(0 0 0 / 50%); }
.ch-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.ch-dialog-head h3 { margin: 0; font-size: var(--text-3); }
.ch-customer-dialog .ch-zuordnen { padding: 0; background: none; border: 0; }
.ch-customer-dialog .ch-zuordnen[hidden] { display: none; }
.ch-customer-dialog { position: fixed; inset: 0; margin: auto; }
.ch-customer-dialog .cz-sub { display: block; margin-top: 4px; }

.ch-list-filter { display: flex; width: 100%; padding: 3px; gap: 3px; border-radius: var(--radius-2); background: var(--surface-hover); }
.ch-list-filter button { flex: 1; min-width: 0; min-height: 40px; padding: 0 16px; border: 0; border-radius: var(--radius-2); background: transparent; color: var(--muted-foreground); font-size: 14px; font-weight: var(--weight-semibold); cursor: pointer; }
.ch-list-filter button[aria-pressed="true"] { background: var(--accent-surface); color: var(--accent-text); }

#chats .ch-sidebar { display: flex; flex-direction: column; overflow: hidden; padding: 0; min-height: 0; }
#chats .ch-list-tools { flex: none; height: 68px; padding: 0 16px; border-bottom: 1px solid var(--border-subtle); background: var(--surface-subtle); }
#chats .wsim-head { height: 68px; }
.ch-list-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-stack); }
.ch-list-filter button { display: flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.ch-filter-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 10px; background: var(--danger-solid); color: white; font-size: 11px; font-variant-numeric: tabular-nums; }
.ch-filter-count--empty { visibility: hidden; }
#chats .ch-list-tools { justify-content: center; }

.ch-customer-result { display: flex; align-items: center; gap: 16px; padding: 12px; border-radius: var(--radius-2); }
.ch-customer-result:hover, .ch-customer-result:focus-within { background: var(--surface-hover); }
.ch-customer-result__identity { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ch-customer-result__identity strong { font-size: var(--text-2); font-weight: var(--weight-medium); }
.ch-customer-result .btn { flex: none; }
@media (hover: hover) and (pointer: fine) {
  .ch-customer-result .btn { opacity: 0; }
  .ch-customer-result:hover .btn, .ch-customer-result:focus-within .btn { opacity: 1; }
}

#ask-modal .modal-box { max-width: 560px; width: calc(100vw - 32px); }
#ask-modal .ask-actions { flex-wrap: wrap; }
#ask-modal .ask-actions .btn { max-width: 100%; white-space: normal; overflow-wrap: anywhere; height: auto; min-height: var(--control-md); }

#ask-modal .modal-box { max-width: 640px; }
#ask-modal #ask-title::before { display: inline-block; margin-right: 12px; vertical-align: -3px; }
#ask-modal.ask--busy #ask-title::before { content: ""; width: 20px; height: 20px; border: 2px solid var(--border-subtle); border-top-color: var(--accent-text); border-radius: 50%; animation: ask-spin .8s linear infinite; }
#ask-modal.ask--error #ask-title::before { content: "!"; width: 22px; height: 22px; border-radius: 50%; text-align: center; line-height: 22px; background: var(--danger-solid); color: white; }
#ask-modal.ask--success #ask-title::before { content: "✓"; color: var(--success-text); }
#ask-modal.ask--busy .ask-actions { display: none; }
@keyframes ask-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #ask-modal.ask--busy #ask-title::before { animation: none; } }

.wa-audio { min-width: 0; width: min(320px, 100%); white-space: normal; }
.wa-audio-title { display: flex; justify-content: space-between; gap: 12px; font-weight: var(--weight-medium); }
.wa-audio audio { display: block; width: 100%; max-width: 100%; height: 40px; margin: 8px 0; }
.wa-audio-status, .wa-audio-unavailable { font-size: var(--text-1); opacity: .8; margin: 6px 0; }
.wa-audio-transcript { white-space: pre-wrap; overflow-wrap: anywhere; }

.ch-unread-button { margin-left: auto; flex: none; }
.ch-customer-button + .ch-unread-button { margin-left: 8px; }
