/* CHAT (F2CHAT ab 1.30): Chat-Layout. Baut auf app.css (Farben, Menü, Dialoge) auf. */

/* Breite Ansicht für die Chats; Anmeldung und Einstellungen bleiben schmal */
body[data-mode="chat"] .shell { max-width: 64rem; padding: 0.75rem 0.75rem 0; }
body[data-mode="chat"] .topnav { --pad: max(0.75rem, calc((100% - 64rem) / 2 + 0.75rem)); }
body[data-mode="chat"] { overflow: hidden; }
body[data-mode="chat"] .shell:has(.chat-activate) { max-width: 40rem; }
.chat-shell .grow { flex: 1 1 auto; }
.center { text-align: center; }

/* Zweispaltig: Liste links, Unterhaltung rechts. Schmal: eines von beiden. */
.chat-shell {
  --chat-h: calc(100dvh - var(--nav-h) - 1.6rem - env(safe-area-inset-top));
  display: grid; grid-template-columns: 20rem minmax(0, 1fr); height: max(var(--chat-h), 22rem);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.chat-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.chat-list-head { display: flex; align-items: center; gap: 0.4rem; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); }
.chat-list-head .btn { display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap; min-height: 2.1rem; padding: 0.2rem 0.65rem; }
.chat-list-head .ico { width: 1rem; height: 1rem; }
.chat-rows { overflow-y: auto; flex: 1 1 auto; }
.chat-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; width: 100%; text-align: left;
  padding: 0.65rem 0.85rem; background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
}
.chat-row:hover { background: var(--bg); }
.chat-row[aria-current="true"] { background: var(--bg); box-shadow: inset 3px 0 0 var(--accent); }
.chat-row-main { display: grid; min-width: 0; }
.chat-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-prev { font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row-side { display: grid; justify-items: end; gap: 0.2rem; flex: none; }
.chat-row-side .count { margin: 0; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.empty { padding: 1rem; }

.chat-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-placeholder { margin: auto; text-align: center; padding: 2rem; }
.chat-placeholder .ico { width: 2.5rem; height: 2.5rem; opacity: 0.5; }
.chat-head { display: flex; align-items: center; gap: 0.35rem; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); min-height: 3.1rem; }
.chat-head-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backbtn { display: none; }
.msgs { flex: 1 1 auto; overflow-y: auto; padding: 0.75rem; display: flex; flex-direction: column; gap: 0.35rem; overscroll-behavior: contain; }
.msg { max-width: min(34rem, 82%); padding: 0.4rem 0.7rem; border-radius: 0.85rem; display: grid; gap: 0.1rem; background: var(--bg); border: 1px solid var(--line); align-self: flex-start; }
.msg.out { align-self: flex-end; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.msg.sys { align-self: center; max-width: 90%; background: transparent; border: 0; color: var(--danger); font-size: 0.875rem; text-align: center; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-time, .msg-from { opacity: 0.7; }
.msg-time { justify-self: end; font-size: 0.72rem; }
.msg-from { font-weight: 650; }
.msg-warn { color: var(--warn); }
.msg.out .msg-warn { color: inherit; }

.composer { display: flex; align-items: flex-end; gap: 0.5rem; padding: 0.55rem 0.6rem; border-top: 1px solid var(--line); }
.composer textarea { flex: 1 1 auto; resize: none; max-height: 10rem; min-height: 2.5rem; padding: 0.55rem 0.65rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); line-height: 1.35; }
.composer .btn { flex: none; }

.fp { font: 600 1.15rem/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.04em; word-spacing: 0.4em; text-align: center; padding: 0.6rem; background: var(--bg); border-radius: var(--radius); }

@media (max-width: 47.999rem) {
  body[data-mode="chat"] .shell { padding: 0; }
  .chat-shell { --chat-h: calc(100dvh - var(--nav-h) - var(--bottom-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom)); grid-template-columns: minmax(0, 1fr); border-width: 1px 0; border-radius: 0; }
  .chat-shell[data-open="1"] .chat-list, .chat-shell[data-open="0"] .chat-pane { display: none; }
  .chat-list { border-right: 0; }
  .backbtn { display: inline-flex; }
  .msg { max-width: 90%; }
}

/* Suche, Anheften, verschwindende Nachrichten, Schlüssel verifiziert */
.chat-search { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); }
.chat-find, .chat-tools input { width: 100%; min-height: 2.1rem; padding: 0.3rem 0.6rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.chat-row.hit .chat-prev mark { background: var(--accent); color: var(--accent-ink); border-radius: 0.2rem; padding: 0 0.1rem; }
.chat-tools { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-tools input { flex: 1 1 10rem; width: auto; }
.chat-tools .btn { display: inline-flex; align-items: center; gap: 0.3rem; min-height: 2.1rem; padding: 0.2rem 0.65rem; }
.chat-tools .btn[aria-pressed="true"], .menu .btn[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chat-head .btn.ghost:not(.backbtn) { display: inline-flex; align-items: center; }
.chat-head .ico, .chat-tools .ico, .msg .ico, .ttl-mark .ico { width: 1rem; height: 1rem; min-width: 1rem; min-height: 1rem; }
.verified-mark { display: inline-flex; align-items: center; color: var(--accent); flex: none; margin-left: 0.25rem; }
.verified-mark .ico { width: 1rem; height: 1rem; min-width: 1rem; min-height: 1rem; stroke-width: 3; }
.chat-title .verified-mark { vertical-align: -0.1em; }
.ttl-mark { display: inline-flex; align-items: center; gap: 0.15rem; white-space: nowrap; }
.msg mark { background: #ffe58a; color: #1b1b1b; border-radius: 0.2rem; padding: 0 0.1rem; }
.msg-time { display: inline-flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; justify-content: flex-end; }
.msg-flag { display: inline-flex; align-items: center; gap: 0.15rem; }
.msg.pinned { box-shadow: inset 3px 0 0 var(--warn); }
.msg.out.pinned { box-shadow: inset 3px 0 0 var(--accent-ink); }
.msg-more { background: transparent; border: 0; padding: 0 0.3rem; min-height: 1.4rem; min-width: 1.4rem; line-height: 1; color: inherit; opacity: 0.55; border-radius: 0.4rem; cursor: pointer; }
.msg-more:hover, .msg-more:focus-visible { opacity: 1; }
.msg-preview { overflow-wrap: anywhere; white-space: pre-wrap; margin: 0 0 0.5rem; }

/* Sichtschutz bei Tabwechsel */
.chat-shell { transition: filter 0.12s; }
body.chat-blur .chat-shell { filter: blur(12px); }
body.chat-blur .chat-shell * { pointer-events: none; }
.verify-hint { color: var(--muted); }

.msg.sys.info { color: var(--muted); }

/* Tagestrenner, Links, Zitate, Emoji, Nach-unten-Knopf, angeheftete Chats */
.msgs { position: relative; }
.day-sep { align-self: center; margin: 0.5rem 0 0.25rem; }
.day-sep span { font-size: 0.75rem; padding: 0.15rem 0.7rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.msg-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.msg-quote { margin: 0 0 0.3rem; padding: 0.15rem 0.6rem; border-left: 3px solid currentColor; opacity: 0.75; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.92em; }
.msg-text { white-space: pre-wrap; }
.fav-mark { display: inline-flex; margin-right: 0.3rem; color: var(--warn); vertical-align: -0.1em; }
.fav-mark .ico { width: 0.9rem; height: 0.9rem; }
.composer-field { position: relative; flex: 1 1 auto; display: flex; min-width: 0; }
.composer-field textarea { width: 100%; }
.composer-count { position: absolute; right: 0.5rem; bottom: 0.15rem; pointer-events: none; }
.emoji-btn { padding: 0.2rem 0.5rem; min-height: 2.5rem; font-size: 1.15rem; line-height: 1; }
.emoji-pop { position: absolute; bottom: calc(100% + 0.4rem); left: 0; z-index: 5; display: grid; grid-template-columns: repeat(8, 2.1rem); gap: 0.1rem; padding: 0.4rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,0.18); }
.emoji-pop[hidden] { display: none; }
.emoji-opt { background: transparent; border: 0; font-size: 1.25rem; min-height: 2.1rem; padding: 0; border-radius: 0.4rem; cursor: pointer; }
.emoji-opt:hover, .emoji-opt:focus-visible { background: var(--bg); }
.chat-pane { position: relative; }
.jump-bottom { position: absolute; right: 1rem; bottom: 4.6rem; width: 2.4rem; height: 2.4rem; min-height: 0; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 2px 10px rgba(0,0,0,0.25); }
.jump-bottom .ico { width: 1.1rem; height: 1.1rem; }
@media (max-width: 47.999rem) { .emoji-pop { grid-template-columns: repeat(6, 2.4rem); } }

/* Chat einschalten (Profil ohne Chat) */
.chat-activate { margin: 1rem auto; }
/* Hinweis unter dem Menü: wie die Hinweise zu Fristen und Backup (backup-banner), die Liste teilt sich deadline-list */
