/* quik Sites: Chat und Kanäle (public/js/chat.js, docs/BAUPLAN.md Abschnitt 33).
   Nur Variablen aus app.css (hell und dunkel), keine festen Farben, keine eigenen Layout-Animationen. */

/* Der Chat füllt das Fenster (Höhe setzt chat.js), darunter braucht die Seite keinen Leerraum */
.page:has(.ch) { padding-bottom: 24px; }
.ch-page > .page-h, .za-page:has(.ch) > .page-h { margin-bottom: 20px; }
.ch { display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: 360px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.ch.solo { grid-template-columns: minmax(0, 1fr); }
.ch.solo > .ch-list { display: none; }

/* ---------- Kanalliste ---------- */
.ch-list { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.ch-list > .skel-set, .ch-thread > .skel-set { padding: 16px; }
.ch-list-h { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; }
.ch-list-h .ch-suche { flex: 1 1 auto; width: auto; }
.ch-list-h .ch-suche > .input { background: var(--surface-2); }
.ch-seg { display: flex; flex-wrap: nowrap; margin: 0 12px 8px; }
.ch-list > .ch-seg > button { flex: 1 1 0; justify-content: center; padding-inline: 8px; white-space: nowrap; }
.ch-rows { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.ch-row { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; padding: 9px 10px; border: 0; border-radius: 12px; background: none; color: var(--fg); font: inherit; text-align: left; cursor: pointer; }
.ch-row:hover { background: var(--hover); }
.ch-row.on { background: var(--surface-2); }
.ch-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ch-row.archiv { opacity: .6; }
.ch-av { flex: none; width: 34px; height: 34px; font-size: var(--fs-xs); }
.ch-av.is-intern, .ch-av.is-kanal { display: inline-grid; place-items: center; border-radius: 10px; background: var(--surface-3); color: var(--ink-soft); }
.ch-row-t { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.ch-row-1 { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.ch-row-1 > b { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: var(--fs-sm); font-weight: 550; }
.ch-row.neu .ch-row-1 > b { font-weight: 700; }
.ch-row-1 > time { flex: none; font-size: var(--fs-2xs); color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.ch-row-2 { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-xs); color: var(--ink-faint); }
.ch-row.neu .ch-row-2 { color: var(--ink-soft); }
.ch-row-v { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ch-chip { display: inline-flex; align-items: center; flex: none; max-width: 120px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--ink-soft); font-size: var(--fs-2xs); font-weight: 550; line-height: 1.5; }
.ch-n { display: inline-grid; place-items: center; flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent-strong); color: var(--on-accent); font-size: var(--fs-2xs); font-weight: 650; font-variant-numeric: tabular-nums; }
.ch-leer-l { padding: 8px 0; }

/* ---------- Verlauf ---------- */
.ch-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); position: relative; }
.ch-thread.drop::after { content: "Hier ablegen"; position: absolute; inset: 8px; display: grid; place-items: center; border: 2px dashed var(--line-strong); border-radius: var(--r); background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--ink-soft); font-weight: 600; pointer-events: none; }
.ch-kopf { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 56px; padding: 8px 12px 8px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.ch-kopf-t { flex: 1 1 auto; min-width: 0; }
.ch-kopf-t > h2 { display: flex; align-items: baseline; gap: 8px; min-width: 0; margin: 0; font-size: var(--fs-md); font-weight: 650; letter-spacing: -.01em; }
.ch-kopf-t > h2 > b { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: inherit; }
.ch-kopf-k { flex: none; max-width: 40%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ink-faint); font-size: var(--fs-sm); font-weight: 500; }
.ch-kopf-t > p { margin: 1px 0 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: var(--fs-xs); color: var(--ink-faint); }
.ch-art-c { display: inline-flex; align-items: center; gap: 5px; flex: none; height: 24px; padding: 0 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-soft); font-size: var(--fs-2xs); font-weight: 600; white-space: nowrap; }
.ch-art-c.is-intern { background: var(--orange-tint); color: var(--orange-ink); }
.ch-kopf-leute { display: inline-flex; flex: none; padding: 2px; border: 0; border-radius: 999px; background: none; cursor: pointer; }
.ch-kopf-leute:hover { background: var(--hover); }
.ch-kopf-leute:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ch-kopf-leute .av { width: 24px; height: 24px; font-size: var(--fs-2xs); }
.ch-zurueck { display: none; }
.ch-thread.is-intern > .ch-kopf { box-shadow: inset 0 -2px 0 var(--orange-line); }
.ch-suchleiste { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.ch-suchleiste > .ct-search { flex: 1 1 auto; width: auto; }

.ch-msgs { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 18px 12px; display: flex; flex-direction: column; gap: 10px; }
.ch-msgs:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ch-msgs > .skel-set { width: 100%; }
.ch-leer { margin: auto; }
.ch-mehr { align-self: center; }
.ch-tag, .ch-neu { display: flex; align-items: center; gap: 12px; margin: 6px 0 2px; font-size: var(--fs-2xs); font-weight: 600; color: var(--ink-faint); }
.ch-tag::before, .ch-tag::after, .ch-neu::before, .ch-neu::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--line-soft); }
.ch-neu { color: var(--accent-ink); }
.ch-neu::before, .ch-neu::after { background: var(--accent); opacity: .5; }

.ch-msg { position: relative; display: flex; align-items: flex-start; gap: 10px; min-width: 0; padding-left: 0; }
.ch-msg.folge { margin-top: -6px; padding-left: 40px; }
.ch-msg.ich { flex-direction: row-reverse; padding-left: 0; }
.ch-msg-av { margin-top: 2px; }
.ch-b-w { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; max-width: min(620px, 82%); }
.ch-msg.ich .ch-b-w { align-items: flex-end; }
.ch-b { min-width: 0; max-width: 100%; padding: 8px 13px 9px; border: 1px solid var(--line-soft); border-radius: 14px; border-top-left-radius: 5px; background: var(--surface); }
.ch-msg.ich .ch-b { border-radius: 14px; border-top-right-radius: 5px; background: var(--accent-soft); border-color: transparent; }
.ch-msg.folge .ch-b { border-radius: 14px; }
.ch-msg.at .ch-b { box-shadow: inset 3px 0 0 var(--accent); }
.ch-msg.blink .ch-b { outline: 2px solid var(--accent); outline-offset: 2px; }
.ch-b-h { display: flex; align-items: center; gap: 6px; min-width: 0; margin-bottom: 2px; font-size: var(--fs-xs); color: var(--ink-faint); }
.ch-b-h > b { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ink-soft); font-weight: 600; }
.ch-b-h > time { flex: none; margin-left: auto; padding-left: 8px; font-variant-numeric: tabular-nums; }
.ch-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-base); line-height: 1.5; }
.ch-text a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.ch-at-m { padding: 0 3px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 550; }
.ch-msg.ich .ch-at-m { background: var(--surface); }
.ch-bearb { display: block; margin-top: 2px; font-size: var(--fs-2xs); color: var(--ink-faint); }
.ch-weg { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-style: italic; color: var(--ink-faint); }
.ch-msg.weg .ch-b { background: none; border-style: dashed; border-color: var(--line-strong); }
.ch-zitat { display: flex; flex-direction: column; gap: 1px; width: 100%; min-width: 0; margin: 2px 0 6px; padding: 4px 9px; border: 0; border-left: 3px solid var(--line-strong); border-radius: 4px; background: var(--surface-2); color: var(--ink-soft); font: inherit; font-size: var(--fs-xs); text-align: left; cursor: pointer; }
.ch-msg.ich .ch-zitat { background: color-mix(in srgb, var(--surface) 60%, transparent); }
.ch-zitat > b { font-weight: 600; }
.ch-zitat > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ch-zitat:focus-visible, .ch-pille:focus-visible, .ch-treffer:focus-visible, .ch-anh-x:focus-visible, .ch-at-it:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ch-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ch-img { display: block; flex: none; width: 200px; max-width: 100%; height: 150px; overflow: hidden; border-radius: 10px; border: 1px solid var(--line-soft); background: var(--surface-3); }
.ch-img > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ch-file { max-width: 260px; }
.ch-wunsch { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-soft); font-size: var(--fs-2xs); font-weight: 600; text-decoration: none; }
.ch-wunsch:hover { background: var(--hover); color: var(--fg); }
.ch-reakt { display: flex; flex-wrap: wrap; gap: 4px; }
.ch-pille { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-soft); font: inherit; font-size: var(--fs-2xs); font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; }
.ch-pille:hover { background: var(--hover); }
.ch-pille.on { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.ch-acts { display: inline-flex; align-items: center; gap: 2px; flex: none; align-self: center; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); opacity: 0; transition: opacity .12s; }
.ch-acts > .icon-btn.sm { width: 26px; height: 26px; min-height: 0; }
.ch-msg:hover > .ch-acts, .ch-msg:focus-within > .ch-acts { opacity: 1; }
@media (hover: none) { .ch-acts { opacity: 1; border-color: transparent; background: none; } .ch-acts > .icon-btn.sm:not(:last-child) { display: none; } }
.ch-edit-b { display: flex; flex-direction: column; gap: 6px; min-width: min(420px, 70vw); }
.ch-edit { width: 100%; min-height: 60px; resize: vertical; font: inherit; line-height: 1.5; }
.ch-edit-f { display: flex; justify-content: flex-end; gap: 6px; }

.ch-sys { display: flex; justify-content: center; margin: 2px 0; }
.ch-sys-p { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; min-width: 0; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); color: var(--ink-soft); font-size: var(--fs-xs); }
.ch-sys-p > span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ch-sys-p > time { flex: none; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.ch-sys-p > a { flex: none; color: var(--accent-ink); font-weight: 600; }
.ch-sys-p > .ic { flex: none; }

.ch-treffer { display: flex; flex-direction: column; gap: 3px; width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--surface); color: var(--fg); font: inherit; text-align: left; cursor: pointer; }
.ch-treffer:hover { background: var(--hover); }
.ch-treffer-h { display: flex; align-items: baseline; gap: 8px; font-size: var(--fs-xs); color: var(--ink-faint); }
.ch-treffer-h > b { color: var(--ink-soft); font-weight: 600; }
.ch-treffer-t { font-size: var(--fs-sm); overflow-wrap: anywhere; }

/* ---------- Schreibfeld ---------- */
.ch-compose { position: relative; display: flex; flex-direction: column; gap: 6px; margin: 0 14px 14px; padding: 8px 8px 8px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.ch-compose:focus-within { border-color: var(--ink-soft); }
.ch-compose.is-intern { border-style: dashed; border-color: var(--orange-line); }
.ch-ta { width: 100%; min-height: 24px; max-height: 160px; padding: 4px 0 0; border: 0; background: none; box-shadow: none; resize: none; color: var(--fg); font: inherit; font-size: var(--fs-base); line-height: 1.5; }
.ch-ta:focus { outline: none; box-shadow: none; }
.ch-ta::placeholder { color: var(--ink-faint); }
.ch-compose-f { display: flex; align-items: center; gap: 4px; min-width: 0; }
.ch-pw { display: inline-flex; align-items: center; gap: 5px; min-width: 0; margin-left: 6px; margin-right: auto; overflow: hidden; color: var(--ink-faint); font-size: var(--fs-2xs); white-space: nowrap; cursor: help; }
.ch-pw > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ch-pw > .ic { flex: none; }
.ch-pw:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.ch-send { flex: none; width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 999px; justify-content: center; }
.ch-antwort { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 4px 4px 4px 8px; border-left: 3px solid var(--accent); border-radius: 4px; background: var(--surface-2); font-size: var(--fs-xs); color: var(--ink-soft); }
.ch-antwort > span { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ch-antwort > .ic { flex: none; }
.ch-antwort[hidden], .ch-anh[hidden], .ch-at[hidden] { display: none; }
.ch-anh { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-anh-c { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; padding: 3px 4px 3px 9px; border: 1px solid var(--line); border-radius: 999px; font-size: var(--fs-xs); }
.ch-anh-c > span { min-width: 0; max-width: 180px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ch-anh-c.laedt { padding-right: 10px; color: var(--ink-faint); border-style: dashed; }
.ch-anh-x { display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--ink-faint); cursor: pointer; }
.ch-anh-x:hover { background: var(--hover); color: var(--fg); }
.ch-at { position: absolute; left: 8px; bottom: calc(100% + 6px); z-index: 5; display: flex; flex-direction: column; min-width: 220px; max-width: calc(100% - 16px); padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--pop, var(--surface)); box-shadow: var(--shadow-pop); }
.ch-at-it { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 6px 8px; border: 0; border-radius: 8px; background: none; color: var(--fg); font: inherit; font-size: var(--fs-sm); text-align: left; cursor: pointer; }
.ch-at-it > span:nth-child(2) { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ch-at-it .av { width: 22px; height: 22px; font-size: var(--fs-2xs); }
.ch-at-it.on, .ch-at-it:hover { background: var(--hover); }
.ch-zu { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 14px 14px; padding: 10px 14px; border: 1px dashed var(--line-strong); border-radius: 14px; color: var(--ink-soft); font-size: var(--fs-sm); }

/* ---------- Dialoge ---------- */
.ch-art { display: flex; flex-wrap: nowrap; }
.modal .ch-art > button { flex: 1 1 0; justify-content: center; }
.ch-dlg-note { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.ch-dlg-note > .ic { flex: none; margin-top: 2px; color: var(--ink-faint); }
.ch-leute { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.ch-leute > li, .ch-leute-z { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 40px; padding: 4px 6px; border-radius: 10px; }
.ch-leute > li > b, .ch-leute-z > b { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 550; font-size: var(--fs-sm); }
.ch-leute-z { cursor: pointer; }
.ch-leute-z:hover { background: var(--hover); }
.ch-leute-z > input { flex: none; width: 16px; height: 16px; accent-color: var(--fg); }
.ch-leute-b { display: flex; flex-direction: column; gap: 16px; }
.ch-leute-b h3 { margin: 0 0 4px; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-faint); text-transform: none; }
.ch-leute-l { display: flex; flex-direction: column; gap: 2px; }
.ch-einst { display: flex; flex-direction: column; }
.ch-einst > .ch-dlg-note { margin-top: 12px; }
.ch-einst .srow-c > .ch-frist { width: 132px; min-width: 0; }

/* ---------- Tablet und Handy: erst die Liste, dann der Verlauf ---------- */
@media (max-width: 1100px) { .ch { grid-template-columns: 280px minmax(0, 1fr); } .ch-art-c { display: none; } .ch-thread.is-intern .ch-art-c { display: inline-flex; } }
@media (max-width: 760px) {
  .page:has(.ch) { padding-bottom: 12px; }
  .ch { grid-template-columns: minmax(0, 1fr); border-radius: var(--r); }
  .ch:not(.show-thread):not(.solo) > .ch-thread { display: none; }
  .ch.show-thread:not(.solo) > .ch-list { display: none; }
  .ch:not(.solo) .ch-zurueck { display: inline-grid; }
  /* Im Verlauf zählt jede Zeile: Seitenkopf und Reiter weichen, zurück führt der Pfeil im Kopf des Kanals */
  .page:has(.ch.show-thread) > .page-h, .page:has(.ch.show-thread) > .za-tabs { display: none; }
  .ch-kopf { padding-left: 8px; min-height: 52px; }
  .ch-kopf-leute { display: none; }
  .ch-msgs { padding: 12px 10px 8px; }
  .ch-b-w { max-width: 86%; }
  .ch-compose, .ch-zu { margin: 0 8px 8px; }
  .ch-pw > span { display: none; }
  .ch-row { min-height: 56px; }
  .ch-send { width: 40px; height: 40px; }
  .ch-compose-f > .icon-btn.sm { width: 40px; height: 40px; }
  .ch-acts > .icon-btn.sm { width: 36px; height: 36px; }
  .ch-img { width: 160px; height: 120px; }
}
