/*
 * Chat im Stil von Nachrichten (Konzept 8.3): Liste, Verlauf mit Sprechblasen, Eingabeleiste, Inspektor.
 * Kopfzeile und Eingabeleiste sind durchscheinendes Material; der Verlauf scrollt darunter durch.
 * Animiert werden nur transform und opacity (WAAPI in den Komponenten); hier stehen nur Druck-Rückmeldungen.
 */

/* ================= Liste ================= */

.chat-list {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.list-head { flex: none; padding: 0 16px 10px; }

.list-title {
  padding: 4px 0 8px;
  font-size: 1.75rem;
  line-height: 2.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Trefferfläche 44 px; die getönte Fläche (36 px) liegt als ::before darunter. */
.search { position: relative; margin: -4px 0 6px; }
.search::before {
  content: '';
  position: absolute;
  inset: 4px 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  pointer-events: none;
}
.search:has(.search-input:focus-visible)::before { outline: 2px solid var(--focus); outline-offset: 1px; }
.search-icon {
  position: absolute;
  top: 50%;
  left: 9px;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  color: var(--ink-2);
  pointer-events: none;
}
.search-input {
  position: relative;
  width: 100%;
  height: var(--hit);
  padding: 0 10px 0 33px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 1rem; /* nie unter 16 px */
  line-height: 1.25rem;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
/* Platzhalter ist Lesetext: auf dem getönten Feld kräftiger als --ink-2. */
.search-input::placeholder { color: color-mix(in srgb, var(--ink) 66%, transparent); }
.search-input::-webkit-search-decoration { -webkit-appearance: none; }
.search-input:focus-visible { outline: none; }

/* Hinweis zum Einschalten der Benachrichtigungen. */
.notify {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  margin-top: 12px;
  padding: 12px 12px 10px;
  border-radius: var(--radius-card);
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--hairline);
}
.notify-icon { width: 20px; height: 20px; margin-top: 1px; color: var(--accent); }
.notify-text { font-size: 0.875rem; line-height: 1.25rem; color: var(--ink); }
.notify-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 6px; }
.notify-actions .button { min-height: 36px; padding: 0 12px; font-size: 0.875rem; border-radius: 10px; position: relative; }
/* Trefferfläche 44 px, ohne das Bild zu ändern. */
.notify-actions .button::after { content: ''; position: absolute; inset: -4px 0; }
.notify-off { color: var(--ink-2); }

.conv-scroll {
  position: relative; /* Bezug für offsetTop der Zeilen (eigene Scroll-Verankerung) */
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  padding: 2px 8px calc(16px + env(safe-area-inset-bottom));
}

.list-status { padding: 12px 8px; font-size: 0.9375rem; line-height: 1.375rem; color: var(--ink-2); }
.list-status:empty { display: none; }
.list-status-title { color: var(--ink); font-weight: 600; }
.list-status .button { margin-top: 10px; }

.conv-list { margin: 0; padding: 0; list-style: none; }
/* Deckende Zeilen: Beim Gleiten scheinen andere Zeilen nicht durch; die bewegte liegt oben. */
.conv-item { position: relative; background: var(--bg-side); }
.conv-item.is-raised { z-index: 2; }

.conv-row {
  /* Nebentexte: auf getönten Zeilen kräftiger, damit sie 4,5 : 1 halten. */
  --row-ink-2: var(--ink-2);
  --row-bg: var(--bg-side);
  position: relative;
  display: grid;
  grid-template-columns: 10px 40px minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  min-height: 72px;
  padding: 10px 10px 10px 4px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
/* Haarlinie zwischen Zeilen, eingerückt bis zum Text; nicht neben der Auswahl. */
.conv-item + .conv-item .conv-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 62px;
  right: 10px;
  border-top: 1px solid var(--hairline);
}
.conv-item:has(> [aria-current="page"]) + .conv-item .conv-row::before,
.conv-row[aria-current="page"]::before { border-top-color: transparent; }

.conv-row:active { --row-bg: color-mix(in srgb, var(--ink) 7%, var(--bg-side)); --row-ink-2: color-mix(in srgb, var(--ink) 74%, transparent); background: var(--row-bg); }
@media (hover: hover) and (pointer: fine) {
  .conv-row:hover { --row-bg: color-mix(in srgb, var(--ink) 5%, var(--bg-side)); --row-ink-2: color-mix(in srgb, var(--ink) 74%, transparent); background: var(--row-bg); }
  .conv-item:has(> .conv-row:hover) + .conv-item .conv-row::before,
  .conv-row:hover::before { border-top-color: transparent; }
}

/* Auswahl in Markenblau wie in Nachrichten am Mac. */
.conv-row[aria-current="page"] {
  --row-bg: var(--brand);
  --row-ink-2: rgb(255 255 255 / .82);
  background: var(--row-bg);
  color: var(--on-brand);
}

.conv-row:focus-visible { z-index: 1; outline: 2px solid var(--focus); outline-offset: 1px; }
/* Auf der blauen Auswahl zusätzlich ein innerer Ring in Weiß (8,9 : 1 bzw. 6,8 : 1 gegen --brand). */
.conv-row[aria-current="page"]:focus-visible { box-shadow: inset 0 0 0 2px var(--on-brand); }

.conv-dot {
  justify-self: center;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  visibility: hidden;
}
.conv-row.is-unread .conv-dot { visibility: visible; }
.conv-row[aria-current="page"] .conv-dot { background: var(--on-brand); }

.conv-avatar { position: relative; align-self: start; margin-top: 2px; }
.conv-badge {
  position: absolute;
  right: -7px;
  bottom: -5px;
  display: grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 3px;
  border-radius: 10px;
  background: var(--brand);
  box-shadow: 0 0 0 2px var(--row-bg);
  color: var(--on-brand);
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}
.conv-row[aria-current="page"] .conv-badge { background: var(--on-brand); color: var(--brand); }

.conv-main { display: grid; gap: 1px; min-width: 0; }
.conv-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.conv-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9375rem;
  line-height: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.conv-time {
  flex: none;
  font-size: 0.8125rem;
  line-height: 1.125rem;
  letter-spacing: 0.01em;
  color: var(--row-ink-2);
  font-variant-numeric: tabular-nums;
}
.conv-preview {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 0.875rem;
  line-height: 1.1875rem;
  color: var(--row-ink-2);
}

/* ================= Verlauf ================= */

.thread {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--bg);
  overflow: hidden;
}

/*
 * Durchscheinendes Material (Konzept 8.3). Unter Kopf- und Eingabeleiste kann alles liegen (blaue Sprechblase,
 * helles oder dunkles Foto): Damit Schrift darauf immer 4,5 : 1 hält, ist das Material etwas dichter
 * (hell 76 %, dunkel 86 %) und Nebentext kräftiger als --ink-2 (hell 76 %, dunkel 82 %).
 */
.thread {
  --chrome-material: color-mix(in srgb, var(--bg) 76%, transparent);
  --chrome-ink-2: color-mix(in srgb, var(--ink) 76%, transparent);
}
@media (prefers-color-scheme: dark) {
  .thread {
    --chrome-material: color-mix(in srgb, var(--bg) 86%, transparent);
    --chrome-ink-2: color-mix(in srgb, var(--ink) 82%, transparent);
  }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .thread { --chrome-material: var(--bg); }
}
.thread-head,
.thread-foot {
  position: absolute;
  inset-inline: 0;
  z-index: 2;
  background: var(--chrome-material);
  -webkit-backdrop-filter: var(--material-filter);
  backdrop-filter: var(--material-filter);
}
.thread-head {
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: calc(60px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0 16px;
}
.thread-foot { bottom: 0; }
/* Haarlinie nur, wo Inhalt darunter liegt. */
.thread-head::after,
.thread-foot::before {
  content: '';
  position: absolute;
  inset-inline: 0;
  border-top: 1px solid var(--hairline);
  opacity: 0;
  transition: opacity var(--dur-press) ease;
}
.thread-head::after { bottom: 0; }
.thread-foot::before { top: 0; }
.thread[data-under-head] .thread-head::after,
.thread[data-under-foot] .thread-foot::before { opacity: 1; }

.thread-back {
  display: none;
  align-items: center;
  gap: 0;
  min-width: var(--hit);
  min-height: var(--hit);
  margin-left: -10px;
  padding: 0 8px 0 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--accent);
  font-size: 1.0625rem;
  font-weight: 500;
  transition: transform var(--dur-press) var(--ease-out);
}
.thread-back .icon { width: 26px; height: 26px; }
.thread-back:active { transform: scale(0.97); }

.thread-who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.thread-titles { display: grid; min-width: 0; }
.thread-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
  line-height: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.thread-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8125rem;
  line-height: 1.125rem;
  letter-spacing: 0.01em;
  color: var(--chrome-ink-2);
}
.thread-details { flex: none; color: var(--accent); }
.thread-details .icon { width: 24px; height: 24px; }
.thread-details[aria-expanded="true"] { background: color-mix(in srgb, var(--brand) 12%, transparent); }

.thread-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  overflow-anchor: none;
  padding: 68px max(16px, env(safe-area-inset-right)) 76px max(16px, env(safe-area-inset-left));
}
/* Fokusring des Verlaufs: eigene Fläche zwischen Kopf- und Eingabeleiste (Lage setzt thread.js),
   damit er nicht unter dem Material verschwindet. */
.thread-scroll:focus-visible { outline: none; }
.thread-ring {
  position: absolute;
  inset-inline: 2px;
  z-index: 3;
  display: none;
  border-radius: 6px;
  outline: 2px solid var(--focus);
  outline-offset: -2px;
  pointer-events: none;
}
.thread:has(> .thread-scroll:focus-visible) > .thread-ring { display: block; }
.thread-sentinel { height: 1px; }
.thread-older { min-height: 20px; text-align: center; font-size: 0.8125rem; line-height: 1.25rem; color: var(--ink-2); }
.thread-items { display: flex; flex-direction: column; padding-bottom: 4px; }

/* Zustände: kein Chat gewählt, Chat fehlt. */
.thread-notice { display: none; }
.thread[data-state="empty"] > :not(.thread-notice),
.thread[data-state="missing"] > :not(.thread-notice, .thread-head) { display: none; }
.thread[data-state="missing"] .thread-who,
.thread[data-state="missing"] .thread-details { visibility: hidden; }
.thread[data-state="empty"] .thread-notice,
.thread[data-state="missing"] .thread-notice {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  flex: 1;
  padding: 32px 24px;
  text-align: center;
}
.thread-notice h2 { font-size: 1.0625rem; line-height: 1.375rem; font-weight: 600; letter-spacing: -0.01em; }
.thread-notice p { max-width: 26rem; font-size: 0.9375rem; line-height: 1.375rem; color: var(--ink-2); }
.thread-notice .button { margin-top: 10px; }

/* ---------- Marken und Systemzeilen ---------- */

.marker,
.sys {
  margin: 16px auto 8px;
  max-width: 85%;
  font-size: 0.75rem;
  line-height: 1rem;
  letter-spacing: 0.01em;
  color: var(--ink-2);
  text-align: center;
  text-wrap: balance;
}
.marker strong { font-weight: 600; }
.sys { margin: 12px auto; }
.sys-time { white-space: nowrap; }
.thread-items > :first-child { margin-top: 4px; }

/* ---------- Sprechblasen ---------- */

.msg { display: flex; flex-direction: column; margin-top: 2px; }
.msg.first { margin-top: 10px; }
.msg[data-dir="out"] { align-items: flex-end; }
.msg[data-dir="in"] { align-items: flex-start; }
.msg-row { display: flex; max-width: min(75%, 40rem); }
.msg[data-dir="out"] .msg-row { justify-content: flex-end; }

.msg-author {
  margin: 0 12px 2px;
  font-size: 0.75rem;
  line-height: 1rem;
  letter-spacing: 0.01em;
  color: var(--ink-2);
}

.bubble {
  position: relative;
  isolation: isolate; /* Zipfel hinter dem Text, über der Fläche */
  min-width: 2.25rem;
  padding: 7px 12px 8px;
  border-radius: var(--radius-bubble);
  font-size: 0.9375rem;
  line-height: 1.3125rem;
  overflow-wrap: anywhere;
}
.msg[data-dir="out"] .bubble { background: var(--brand); color: var(--on-brand); }
.msg[data-dir="in"] .bubble { background: var(--bubble-in); color: var(--ink); }
.bubble-text { white-space: pre-wrap; }
.bubble.is-muted .bubble-text { font-style: italic; opacity: 0.85; }
.bubble-placeholder { font-style: italic; }

/* Zipfel nur an der letzten Sprechblase einer Gruppe. */
.tail {
  position: absolute;
  bottom: 0;
  z-index: -1;
  display: none;
  width: 24px;
  height: 18px;
}
.msg.last .tail { display: block; }
.msg[data-dir="out"] .tail { right: -6px; color: var(--brand); }
.msg[data-dir="in"] .tail { left: -6px; color: var(--bubble-in); transform: scaleX(-1); }
/* Reine Bilder und Sticker stehen ohne Fläche und ohne Zipfel. */
.bubble.is-media,
.bubble.is-sticker { padding: 0; background: none !important; }
.bubble.is-media .tail,
.bubble.is-sticker .tail { display: none !important; }

.bubble-image {
  display: block;
  padding: 0;
  border: 0;
  border-radius: var(--radius-bubble);
  background: var(--bubble-in);
  overflow: hidden;
  cursor: zoom-in;
  transition: transform var(--dur-press) var(--ease-out);
}
.bubble-image:active { transform: scale(0.97); }
/* Feste Fläche, bevor das Bild geladen ist (Maße kennt die API nicht): Nachladen verschiebt den Verlauf
   nicht. Das ganze Bild zeigt die Großansicht. */
.bubble-image img {
  display: block;
  width: 240px;
  height: 240px;
  max-width: 100%;
  object-fit: cover;
}
.bubble.is-sticker .bubble-image { background: none; }
.bubble.is-sticker .bubble-image img { width: 160px; height: 160px; object-fit: contain; }
.bubble.has-media { padding: 4px 4px 7px; }
.bubble.has-media .bubble-image { border-radius: 14px; }
.bubble.has-media .bubble-text { padding: 5px 8px 0; }

.doc-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(220px, 100%);
  min-height: var(--hit);
  color: inherit;
  text-decoration: none;
}
.doc-icon { width: 30px; height: 30px; flex: none; }
.doc-text { display: grid; min-width: 0; }
.doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.doc-meta { font-size: 0.75rem; line-height: 1rem; letter-spacing: 0.01em; opacity: 0.85; }
a.doc-card:focus-visible { outline-offset: 4px; border-radius: 10px; }
.msg[data-dir="out"] a.doc-card:focus-visible { outline-color: var(--on-brand); }
.bubble.has-doc .bubble-text { margin-top: 6px; }
.bubble.has-player { padding: 6px; }
.bubble audio { display: block; width: min(280px, 100%); height: 40px; }
.bubble video { display: block; width: min(280px, 100%); aspect-ratio: 16 / 9; object-fit: contain; border-radius: 14px; background: #000; }
.bubble.has-player .bubble-text { padding: 4px 6px 0; }

/* Status unter der letzten ausgehenden Nachricht, in Worten. */
.msg-status {
  margin: 3px 4px 0;
  font-size: 0.75rem;
  line-height: 1rem;
  letter-spacing: 0.01em;
  color: var(--ink-2);
}
.msg-failed {
  display: grid;
  justify-items: end;
  gap: 1px;
  max-width: min(75%, 28rem);
  margin: 4px 4px 0;
  text-align: right;
  font-size: 0.8125rem;
  line-height: 1.125rem;
}
.msg-failed-label { display: inline-flex; align-items: center; gap: 4px; color: var(--danger); font-weight: 600; }
.msg-failed-label .icon { width: 16px; height: 16px; }
.msg-failed-text { color: var(--ink); }
.msg-retry {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 600;
  transition: transform var(--dur-press) var(--ease-out);
}
.msg-retry::after { content: ''; position: absolute; inset: -9px -8px; }
.msg-retry .icon { width: 16px; height: 16px; }
.msg-retry:active { transform: scale(0.97); }
.msg.is-failed .bubble { opacity: 0.92; }

/* ---------- Interne Notiz: volle Breite, Notizfarbe, ohne Zipfel ---------- */

.msg.note { align-items: stretch; margin-top: 12px; }
.msg.note:not(.first) { margin-top: 2px; }
.note-card {
  padding: 9px 14px 10px;
  border-radius: var(--radius-card);
  background: var(--note-bg);
  color: var(--note-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--note-ink) 16%, transparent);
  font-size: 0.9375rem;
  line-height: 1.3125rem;
}
.note-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.note-label .icon { width: 16px; height: 16px; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.note.is-pending .note-card { opacity: 0.7; }

/* ---------- Pille „Neue Nachricht“ und Ablegen ---------- */

.new-pill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 88px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  min-height: 36px;
  margin-inline: auto;
  padding: 0 14px 0 10px;
  border: 0;
  border-radius: 18px;
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: var(--shadow-float);
  font-size: 0.875rem;
  font-weight: 600;
  transition: transform var(--dur-press) var(--ease-out);
}
.new-pill::after { content: ''; position: absolute; inset: -4px -4px; }
.new-pill .icon { width: 18px; height: 18px; }
.new-pill:active { transform: scale(0.97); }

.drop-overlay {
  position: absolute;
  inset: 8px;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  border: 2px dashed var(--brand);
  border-radius: var(--radius-bubble);
  background: color-mix(in srgb, var(--bg) 88%, var(--brand));
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}
.drop-overlay p { max-width: 26rem; }

/* ================= Eingabeleiste ================= */

.composer {
  display: grid;
  gap: 6px;
  padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.composer-info {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  font-size: 0.75rem;
  line-height: 1rem;
  letter-spacing: 0.01em;
  color: var(--chrome-ink-2);
  text-align: center;
}
.composer-info:empty { display: none; }
.composer-info .icon { width: 16px; height: 16px; flex: none; }
/* Unter einer Stunde und im Notiz-Modus in der Notizfarbe. */
.composer-info[data-level="warn"],
.composer-info[data-level="note"] {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--note-bg);
  color: var(--note-ink);
  font-weight: 600;
}

.composer-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding-inline: 6px;
  color: var(--danger);
  font-size: 0.8125rem;
  line-height: 1.125rem;
  font-weight: 500;
}
.composer-error:empty { display: none; }
.composer-error .icon { width: 16px; height: 16px; margin-top: 1px; }

.composer-row { display: flex; align-items: flex-end; gap: 4px; }
.composer-plus { color: var(--accent); }
/* Im Notiz-Modus und bei geschlossenem Fenster unsichtbar, der Platz bleibt (nichts rückt unter dem Zeiger). */
.composer-plus.is-off { visibility: hidden; }
.composer-plus .icon { width: 24px; height: 24px; }

.note-toggle {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  margin: 6px 4px 6px 0;
  padding: 0 11px 0 8px;
  border: 0;
  border-radius: 16px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 600;
  transition: transform var(--dur-press) var(--ease-out);
}
.note-toggle::after { content: ''; position: absolute; inset: -6px -2px; }
.note-toggle .icon { width: 18px; height: 18px; }
.note-toggle:active { transform: scale(0.97); }
.note-toggle[aria-pressed="true"] {
  background: var(--note-bg);
  color: var(--note-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--note-ink) 35%, transparent);
}

.composer-field {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  min-height: 44px;
  padding: 0 5px 0 14px;
  border-radius: var(--radius-field);
  background: var(--bg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 16%, transparent);
}
.composer-field:has(.composer-input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }
.composer-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  max-height: 152px; /* 6 Zeilen à 22 px plus Innenabstand */
  margin: 0;
  padding: 10px 0;
  border: 0;
  background: transparent;
  font-size: 1rem;
  line-height: 22px;
  color: inherit;
  resize: none;
  overflow-y: auto;
  outline: none;
  scrollbar-width: thin;
}
.composer-input::placeholder { color: color-mix(in srgb, var(--ink) 62%, transparent); }
.composer-send {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  margin: 6px 0 6px 6px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand);
  transition: transform var(--dur-press) var(--ease-out);
}
.composer-send::after { content: ''; position: absolute; right: 0; bottom: 0; width: var(--hit); height: var(--hit); }
.composer-send .icon { width: 20px; height: 20px; stroke-width: 2.4; }
.composer-send:active { transform: scale(0.97); background: var(--brand-press); }
/* Senden erscheint erst mit Inhalt; der Platz bleibt reserviert, damit nichts springt. */
.composer-field[data-empty] .composer-send { visibility: hidden; }

/* Notiz-Modus: Feld in der Notizfarbe. */
.composer[data-mode="note"] .composer-field {
  background: var(--note-bg);
  color: var(--note-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--note-ink) 30%, transparent);
}
.composer[data-mode="note"] .composer-input::placeholder { color: color-mix(in srgb, var(--note-ink) 86%, transparent); }
.composer[data-mode="note"] .composer-send { background: var(--note-ink); color: var(--note-bg); }

/* Geschlossenes Fenster: ruhige Fläche statt Eingabezeile; Notizen bleiben erreichbar. */
.composer-closed { display: none; }
.composer[data-closed] .composer-row,
.composer[data-closed] .composer-tray { display: none; }
.composer[data-closed] .composer-closed {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 12px 14px 6px;
  text-align: center;
}
.composer-closed p { max-width: 30rem; font-size: 0.875rem; line-height: 1.25rem; color: var(--chrome-ink-2); }
.composer-closed .button { min-height: 40px; padding: 0 16px; border-radius: 20px; font-size: 0.9375rem; position: relative; }
.composer-closed .button::after { content: ''; position: absolute; inset: -2px 0; }
.composer-closed .button .icon { width: 18px; height: 18px; }

/* Vorschau der Anhänge vor dem Senden. */
.composer-tray {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 4px 2px 2px;
  list-style: none;
  overflow-x: auto;
}
.tray-item {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 12px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--hairline);
}
.tray-item.is-image { width: 64px; height: 64px; overflow: visible; }
.tray-item.is-image img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; }
.tray-item.is-doc { max-width: 240px; min-height: 64px; padding: 8px 36px 8px 10px; }
.tray-icon { width: 26px; height: 26px; color: var(--accent); }
.tray-text { display: grid; min-width: 0; }
.tray-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8125rem; font-weight: 600; }
.tray-meta { font-size: 0.75rem; color: var(--ink-2); }
.tray-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(27 29 33 / .72);
  color: #FFFFFF;
}
.tray-remove::after { content: ''; position: absolute; inset: -11px; }
.tray-remove .icon { width: 14px; height: 14px; stroke-width: 2.4; }

/* ================= Inspektor ================= */

.aside-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: calc(60px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0 20px;
  background: var(--bg-side);
}
.aside-title { flex: 1; font-size: 1.0625rem; line-height: 1.375rem; font-weight: 650; letter-spacing: -0.01em; }
.aside-back {
  display: none;
  align-items: center;
  min-height: var(--hit);
  margin-left: -10px;
  padding: 0 8px 0 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--accent);
  font-size: 1.0625rem;
  font-weight: 500;
}
.aside-back .icon { width: 26px; height: 26px; }
.aside-body { padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }

.insp { display: grid; gap: 22px; }
.sheet .insp { padding-bottom: 8px; }
.insp-contact { display: grid; justify-items: center; gap: 4px; padding-top: 8px; text-align: center; }
.insp-avatar { width: 64px; height: 64px; margin-bottom: 6px; font-size: 1.375rem; }
.insp-name { font-size: 1.25rem; line-height: 1.625rem; font-weight: 650; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.insp-number { font-size: 0.9375rem; line-height: 1.25rem; color: var(--ink-2); font-variant-numeric: tabular-nums; user-select: all; }

.insp-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.insp-label {
  display: block;
  margin: 0 0 6px;
  padding: 0 14px;
  font-size: 0.8125rem;
  line-height: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-2);
}
.insp-options { border-radius: var(--radius-card); background: var(--bg); overflow: hidden; }
.sheet .insp-options { background: var(--surface); }
.insp-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--hit);
  padding: 6px 14px;
  font-size: 0.9375rem;
  line-height: 1.25rem;
  cursor: pointer;
  user-select: none;
}
.insp-option + .insp-option::before {
  content: '';
  position: absolute;
  top: 0;
  left: 52px;
  right: 0;
  border-top: 1px solid var(--hairline);
}
.insp-option:has(input:focus-visible) { z-index: 1; outline: 2px solid var(--focus); outline-offset: -2px; border-radius: var(--radius-card); }
.insp-option:active { background: var(--hairline); }
@media (hover: hover) and (pointer: fine) {
  .insp-option:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
}
.insp-option-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp-you { color: var(--ink-2); }
.insp-check { width: 20px; height: 20px; color: var(--accent); visibility: hidden; stroke-width: 2.2; }
.insp-option:has(input:checked) .insp-check { visibility: visible; }
.insp-option:has(input:checked) .insp-option-name { font-weight: 600; }
.avatar-sm { width: 28px; height: 28px; font-size: 0.6875rem; }
.avatar-none { background: none; box-shadow: inset 0 0 0 1.5px var(--hairline); }
.insp-group .segmented { width: 100%; }
.insp-error:empty { display: none; }

/* ================= Großansicht ================= */

.lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  border: 0;
  background: transparent;
  color: #FFFFFF;
}
.lightbox[open] { display: grid; place-items: center; }
/* Die Abdunkelung liegt im ::backdrop, damit nur sie blendet und das Foto deckend bleibt. */
.lightbox::backdrop { background: rgb(0 0 0 / .88); }
.lightbox-image { max-width: 100%; max-height: 100%; border-radius: 12px; object-fit: contain; }
.lightbox-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  color: #FFFFFF;
  background: rgb(255 255 255 / .14);
}
.lightbox-close:focus-visible { outline-color: #FFFFFF; }

/* ================= Größen ================= */

/* Unter 640 px: Ebenen mit Zurück-Pfeil, größere Schrift in Sprechblasen und Feld. */
@media (max-width: 639px) {
  .thread-back { display: inline-flex; }
  .thread-head { padding-left: 12px; }
  .thread-who .avatar { display: none; }
  .bubble, .note-card { font-size: 1.0625rem; line-height: 1.4375rem; }
  .composer-input { font-size: 1.0625rem; }
  .aside-back { display: inline-flex; }
  .aside-head { padding-left: 12px; }
  .aside-title { flex: none; }
  .aside-close { display: none; }
}
@media (min-width: 640px) and (max-width: 1023px) {
  .aside-close { display: none; }
}

/* ================= Vorlieben ================= */

@media (hover: hover) and (pointer: fine) {
  .thread-back:hover, .aside-back:hover { background: color-mix(in srgb, var(--brand) 8%, transparent); }
  .note-toggle:hover { background: color-mix(in srgb, var(--ink) 11%, transparent); }
  .note-toggle[aria-pressed="true"]:hover { background: color-mix(in srgb, var(--note-ink) 14%, var(--note-bg)); }
  .composer-send:hover { background: var(--brand-press); }
  .composer[data-mode="note"] .composer-send:hover { background: color-mix(in srgb, var(--note-ink) 85%, black); }
  .new-pill:hover { background: var(--brand-press); }
  .msg-retry:hover { text-decoration: underline; text-underline-offset: 0.2em; }
}

@media (prefers-reduced-motion: reduce) {
  .thread-back:active, .bubble-image:active, .msg-retry:active, .new-pill:active,
  .note-toggle:active, .composer-send:active { transform: none; opacity: 0.7; }
}

@media (prefers-contrast: more) {
  .msg[data-dir="in"] .bubble { box-shadow: inset 0 0 0 1px var(--hairline); }
  .note-card { box-shadow: inset 0 0 0 2px var(--note-ink); }
  .composer-field { box-shadow: inset 0 0 0 1px var(--ink); }
}
