/* FactGrid Chat -- Stylesheet. Farben und Schrift wie die Tool-Uebersicht. */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #5b6675;
  --accent: #2b6cb0;
  --accent-ink: #ffffff;
  --border: #e2e6ec;
  --hover: #eef2f7;
  --online: #2f9e44;
  --danger: #b42318;
  --radius: 10px;
  --shadow: 0 4px 14px rgba(43, 108, 176, .12);
  --side-w: 270px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
  /* Mobil: Schrift nicht eigenmaechtig vergroessern, beim Tippen kein grauer Kasten. */
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(43, 108, 176, .12);
}
/* Beim Scrollen am Ende einer Liste nicht die Seite darunter mitziehen. */
.messages, .sidebar, .thread-body, .search-results, .notif-list { overscroll-behavior: contain; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Knoepfe ------------------------------------------------------------- */

.btn {
  font: inherit; font-size: 14px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; display: inline-block; line-height: 1.3;
}
.btn:hover { background: var(--hover); border-color: #c9d2de; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #245a94; }
.btn.big { font-size: 16px; padding: 10px 20px; }
.btn.small { font-size: 13px; padding: 4px 10px; }
.btn:disabled { opacity: .55; cursor: default; }
.linklike {
  font: inherit; font-size: 13px; border: 0; background: none; color: var(--accent);
  cursor: pointer; padding: 0;
}
.linklike:hover { text-decoration: underline; }
.iconbtn {
  font: inherit; font-size: 20px; border: 1px solid var(--border); background: #fff;
  border-radius: 8px; width: 36px; height: 36px; cursor: pointer; display: none;
}

/* Glocke mit Zaehler und Aufklapp-Liste der Erwaehnungen. */
.bell-wrap { position: relative; }
.iconbtn.bell { display: inline-flex; align-items: center; justify-content: center; font-size: 17px; position: relative; }
.iconbtn.bell:hover { background: var(--hover); }
.bell-count {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #d9480f; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.notif-panel {
  position: absolute; right: 0; top: calc(100% + 6px); width: min(380px, calc(100vw - 24px)); z-index: 40;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  display: flex; flex-direction: column; max-height: min(70vh, 520px);
}
.notif-head { display: flex; align-items: baseline; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.notif-head h2 { margin: 0; font-size: 14px; }
.notif-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.notif-list li { padding: 9px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: grid; grid-template-columns: 30px 1fr; gap: 10px; }
.notif-list li:hover { background: var(--hover); }
.notif-list li.unread { background: #fffbe6; }
.notif-list li.unread:hover { background: #fff6cc; }
.notif-list li .avatar { width: 28px; height: 28px; font-size: 13px; margin: 0; }
.notif-list li .who { font-size: 13px; }
.notif-list li .who b { font-weight: 700; }
.notif-list li .when { color: var(--muted); font-size: 12px; margin-left: 6px; }
.notif-list li .snippet { font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-list .notif-empty { padding: 16px 14px; color: var(--muted); font-size: 13px; text-align: center; cursor: default; display: block; }
.notif-foot { display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 14px; border-top: 1px solid var(--border); background: var(--bg); border-radius: 0 0 12px 12px; }
.msg.flash { animation: flash 2s ease-out; }
@keyframes flash { 0% { background: #fde68a; } 100% { background: transparent; } }
.toast.clickable { cursor: pointer; }

/* Anmeldeseite -------------------------------------------------------- */

.login-view {
  min-height: 100%; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 2rem 1rem; gap: 2rem;
}
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 2.25rem 2rem; max-width: 460px; width: 100%; text-align: center;
  box-shadow: var(--shadow);
}
.login-logo {
  width: 56px; height: 56px; margin: 0 auto 1rem; border-radius: 14px; background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='7' fill='%23000'/%3E%3Cpath d='M8 9h16v11H14l-5 4v-4H8z' fill='%23fff'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='7' fill='%23000'/%3E%3Cpath d='M8 9h16v11H14l-5 4v-4H8z' fill='%23fff'/%3E%3C/svg%3E") center / contain no-repeat;
}
.login-card h1 { margin: 0 0 .5rem; font-size: 1.6rem; }
.login-card p { margin: 0 0 1.25rem; }
.login-card .btn.big { margin-bottom: 1.25rem; }
.login-error {
  background: #fdecea; color: var(--danger); border: 1px solid #f5c2bd;
  border-radius: 8px; padding: .6rem .9rem; font-size: 14px;
}
.login-footer { font-size: 13px; color: var(--muted); }

/* Grundgeruest -------------------------------------------------------- */

.app { height: 100%; height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: var(--panel); border-bottom: 1px solid var(--border); flex: none;
}
.brand { display: flex; align-items: baseline; gap: 16px; min-width: 0; flex: 1; }
.brand-title { font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.room-head { min-width: 0; display: flex; align-items: baseline; gap: 10px; overflow: hidden; }
.room-name { font-weight: 600; white-space: nowrap; }
.room-name.direct::before { content: "✉"; margin-right: 6px; }
.room-topic { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex: none; }
.me { font-size: 14px; font-weight: 600; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: #c9d2de; display: inline-block; }
.conn.ok { background: var(--online); }
.conn.bad { background: var(--danger); }

.body { flex: 1; display: flex; min-height: 0; }

/* Seitenleiste -------------------------------------------------------- */

.sidebar {
  width: var(--side-w); flex: none; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; overflow-y: auto;
}
.side-section { padding: 14px 12px 8px; }
.side-section.grow { flex: 1; }
.side-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 6px; }
.side-head h2 {
  margin: 0 0 6px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.side-foot { padding: 10px 18px; border-top: 1px solid var(--border); }

.rooms, .users { list-style: none; margin: 0; padding: 0; }
.rooms li {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer;
}
.rooms li:hover { background: var(--hover); }
.rooms li.active { background: var(--accent); color: #fff; }
.rooms li .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rooms li.unread .label { font-weight: 700; }
.rooms li .badge {
  min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700; text-align: center; line-height: 20px;
}
.rooms li.active .badge { background: #fff; color: var(--accent); }
.rooms li .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
/* Direktnachrichten: Online-Punkt des Gegenuebers vor dem Namen. */
.directs li .status { width: 8px; height: 8px; border-radius: 50%; background: #c9d2de; flex: none; margin: 0 2px; }
.directs li .status.online { background: var(--online); }
.directs li.active .status { background: rgba(255, 255, 255, .6); }
.directs li.active .status.online { background: #fff; }
.side-hint { margin: -2px 6px 6px; font-size: 12px; }

.new-room { display: flex; flex-direction: column; gap: 6px; padding: 6px 6px 10px; }
.new-room input {
  font: inherit; font-size: 14px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
}
.new-room .row { display: flex; gap: 6px; }

.users li { display: flex; align-items: center; gap: 8px; padding: 4px 8px; font-size: 14px; }
.users li .status { width: 8px; height: 8px; border-radius: 50%; background: #c9d2de; flex: none; }
.users li.online .status { background: var(--online); }
.users li.offline { color: var(--muted); }
.users li .uname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Klick auf ein Mitglied sucht seine Erwaehnungen; das Kuvert am rechten Rand
   (nur bei freigegebenen Direktnachrichten) oeffnet die Unterhaltung. */
.users li.clickable { cursor: pointer; border-radius: 8px; }
.users li.clickable:hover { background: var(--hover); color: var(--ink); }
.users li .dm {
  margin-left: auto; font: inherit; font-size: 12px; line-height: 1; color: var(--muted);
  background: none; border: 0; border-radius: 6px; padding: 2px 4px; cursor: pointer; opacity: 0;
}
.users li:hover .dm, .users li .dm:focus-visible { opacity: 1; }
.users li .dm:hover { background: var(--panel); color: var(--accent); }

/* Marken (Hashtags): Chips unter den Mitgliedern, ein Klick sucht die Marke. */
.tags-section { flex: none; border-top: 1px solid var(--border); }
.tags { list-style: none; margin: 0; padding: 0 6px; display: flex; flex-wrap: wrap; gap: 6px; max-height: 30vh; overflow-y: auto; }
.tags li {
  display: flex; align-items: baseline; gap: 5px; max-width: 100%; cursor: pointer;
  padding: 2px 9px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg); font-size: 13px;
}
.tags li:hover { background: var(--hover); border-color: var(--accent); color: var(--accent); }
.tags li .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tags li .count { color: var(--muted); font-size: 11px; flex: none; }
.tags li:hover .count { color: inherit; }

/* Griff am linken Rand der rechten Panels: zieht sie breiter oder schmaler
   (chat.js merkt sich die Breite je Panel). Die Linie erscheint erst beim
   Zeigen, Anfassen oder Tastaturfokus. */
.grabber {
  position: absolute; top: 0; bottom: 0; left: -4px; width: 9px; z-index: 5;
  cursor: col-resize; touch-action: none;
}
.grabber::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 4px; width: 1px;
  background: transparent; transition: background .12s ease;
}
.grabber:hover::after, .grabber:focus-visible::after, .grabber.dragging::after { background: var(--accent); }
.grabber:focus-visible { outline: none; }
/* Waehrend des Ziehens nichts markieren und ueberall denselben Zeiger. */
body.resizing { cursor: col-resize; user-select: none; }

/* Nachrichten --------------------------------------------------------- */

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.messages { flex: 1; overflow-y: auto; padding: 12px 20px 8px; }
.history-top { text-align: center; padding: 6px 0 12px; }
.history-top p { margin: 0; }

.day {
  display: flex; align-items: center; gap: 12px; margin: 18px 0 10px; color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: .06em;
}
.day::before, .day::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

.msg { display: grid; grid-template-columns: 38px 1fr; column-gap: 12px; padding: 4px 8px; margin: 0 -8px; border-radius: 8px; position: relative; }
.msg:hover { background: var(--hover); }
.msg.cont { margin-top: -2px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center; margin-top: 2px; user-select: none;
}
.msg.cont .avatar { visibility: hidden; height: 0; margin: 0; }
.msg.cont .meta { display: none; }
.msg .meta { display: flex; align-items: baseline; gap: 8px; }
.msg .author { font-weight: 700; }
.msg .author a { color: inherit; text-decoration: none; }
.msg .author a:hover { text-decoration: underline; }
.msg .time { color: var(--muted); font-size: 12px; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .text a.fg { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .93em; }
/* [[Q123|Label]]: Label als Link, ID klein dahinter. */
.msg .text a.entity { font-weight: 600; text-decoration: none; border-bottom: 1px dotted var(--accent); }
.msg .text a.entity:hover { border-bottom-style: solid; }
.msg .text .qid {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8em; color: var(--muted);
  margin-left: 3px; vertical-align: 1px;
}
/* @Erwaehnung */
.msg .text a.mention {
  background: #e8f0fb; color: var(--accent); border-radius: 4px; padding: 0 4px; font-weight: 600;
  text-decoration: none;
}
.msg .text a.mention.me { background: #fde68a; color: #7c4a03; }
/* Marken im Text: ein Knopf, der wie Text aussieht -- ein Klick sucht die Marke. */
.msg .text .taglink {
  font: inherit; font-weight: 600; color: var(--accent); background: none; border: 0;
  padding: 0 1px; border-radius: 4px; cursor: pointer;
}
.msg .text .taglink:hover, .msg .text .taglink:focus-visible { background: #e8f0fb; text-decoration: underline; }
.msg.mentioned { background: #fffbe6; box-shadow: inset 3px 0 0 #f59e0b; }
.msg.mentioned:hover { background: #fff6cc; }
.rooms li .badge.mention { background: #d9480f; }
.rooms li.active .badge.mention { background: #fff; color: #d9480f; }
.msg .stamp { position: absolute; left: 14px; top: 6px; font-size: 11px; color: var(--muted); display: none; }
.msg.cont:hover .stamp { display: block; }
.msg.cont { grid-template-columns: 38px 1fr; }
.msg .actions { position: absolute; right: 8px; top: 2px; display: none; gap: 4px; }
.msg:hover .actions, .msg:focus-within .actions { display: flex; }
.msg .actions button {
  font: inherit; font-size: 12px; padding: 1px 8px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: #fff; color: var(--muted);
}
.msg .actions button:hover { color: var(--accent); border-color: var(--accent); }
.msg .actions button.del:hover { color: var(--danger); border-color: var(--danger); }
/* Ohne Maus gibt es kein "Zeigen". Dauerhaft eingeblendet wuerden
   "Antworten"/"Loeschen" als Overlay den Anfang der Nachricht verdecken --
   deshalb erscheinen sie erst auf einen Tipp, und dann unter der Nachricht
   statt darueber (chat.js setzt .active). Das Kuvert am Mitglied ist klein
   genug, um dauerhaft dazustehen. */
@media (hover: none) {
  .msg .actions, .msg:focus-within .actions { display: none; }
  .msg.active .actions {
    display: flex; position: static; grid-column: 2; justify-content: flex-end;
    opacity: 1; margin: 4px 0 2px;
  }
  .msg.active { background: var(--hover); }
  .msg.active .stamp { display: block; }
  .users li .dm { opacity: 1; }
}
.msg.mine .author { color: var(--accent); }
.msg.pending { opacity: .55; }
.msg.deleted .text { font-style: italic; color: var(--muted); }
.msg.deleted .avatar { opacity: .4; }

/* Verweis auf den Thread unter einer Nachricht mit Antworten. */
.thread-link {
  font: inherit; font-size: 13px; margin-top: 4px; padding: 2px 8px; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent; background: none; color: var(--accent); display: inline-flex; gap: 6px; align-items: center;
}
.thread-link:hover { border-color: var(--border); background: #fff; }
.thread-link .when { color: var(--muted); font-size: 12px; }
.msg.in-thread-open { background: #eaf1fa; }

/* Thread-Panel ---------------------------------------------------------- */

.thread {
  width: var(--thread-w, 380px); flex: none; display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-left: 1px solid var(--border); position: relative;
}
.thread-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.thread-head h2 { margin: 0; font-size: 15px; flex: none; }
.thread-head .small { flex: 1; }
.iconbtn-small {
  font: inherit; font-size: 20px; line-height: 1; border: 0; background: none; color: var(--muted);
  cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.iconbtn-small:hover { background: var(--hover); color: var(--ink); }
.thread-body { flex: 1; overflow-y: auto; padding: 12px 14px 8px; }
.thread-divider {
  display: flex; align-items: center; gap: 10px; margin: 10px 0 8px; color: var(--muted); font-size: 12px;
}
.thread-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.thread .msg { margin: 0 -6px; padding: 4px 6px; }
.thread-composer { padding: 8px 12px 12px; }
.thread-composer textarea { min-height: 38px; }

/* Suche: Panel rechts (mobil als Overlay), Treffer mit hervorgehobenen Begriffen. */
.iconbtn.search-btn { display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.iconbtn.search-btn:hover { background: var(--hover); }
.search {
  width: var(--search-w, 360px); flex: none; display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-left: 1px solid var(--border); position: relative;
}
.search-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.search-head h2 { margin: 0; font-size: 15px; flex: 1; }
.search-form { display: flex; flex-direction: column; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.search-form input[type="search"] {
  font: inherit; font-size: 14px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; width: 100%;
}
.search-form input[type="search"]:focus { outline: 2px solid rgba(43, 108, 176, .35); border-color: var(--accent); }
.search-scope { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.search-status { margin: 0; padding: 8px 14px 4px; }
.search-results { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.search-results li { padding: 9px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: grid; grid-template-columns: 30px 1fr; gap: 10px; }
.search-results li:hover { background: var(--hover); }
.search-results li .avatar { width: 28px; height: 28px; font-size: 13px; margin: 0; }
.search-results li .who { font-size: 13px; }
.search-results li .who b { font-weight: 700; }
.search-results li .when { color: var(--muted); font-size: 12px; margin-left: 6px; }
.search-results li .snippet { font-size: 13px; color: var(--ink); overflow-wrap: anywhere; }
.search-results mark { background: #fde68a; color: inherit; border-radius: 3px; padding: 0 1px; }
.search-foot { padding: 8px 14px 12px; text-align: center; }
.search-foot:empty { display: none; }

.jump {
  position: absolute; right: 24px; bottom: 84px; font: inherit; font-size: 13px; padding: 6px 12px;
  border-radius: 20px; border: 1px solid var(--border); background: #fff; box-shadow: var(--shadow); cursor: pointer;
}

/* Eingabe ------------------------------------------------------------- */

.composer {
  flex: none; display: flex; gap: 10px; align-items: flex-end; padding: 10px 20px 14px;
  border-top: 1px solid var(--border); background: var(--panel); position: relative;
}

/* Vorschlagsliste fuer @Mitglied und !Q / !P (schwebt ueber dem Eingabefeld). */
.ac {
  position: absolute; left: 20px; right: 20px; bottom: calc(100% - 2px); max-width: 520px; z-index: 30;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15);
  overflow: hidden; max-height: 320px; overflow-y: auto;
}
.thread-composer .ac { left: 12px; right: 12px; }
.ac-head { padding: 6px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--bg); }
.ac-item { display: flex; align-items: center; gap: 10px; padding: 7px 12px; cursor: pointer; font-size: 14px; }
.ac-item.active, .ac-item:hover { background: var(--hover); }
.ac-item .avatar { width: 26px; height: 26px; font-size: 12px; margin: 0; flex: none; }
.ac-item .ac-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ac-item .ac-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-item .ac-desc { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-item .ac-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); flex: none; }
.ac-item .ac-online { width: 8px; height: 8px; border-radius: 50%; background: var(--online); flex: none; }
.ac-empty { padding: 10px 12px; font-size: 13px; color: var(--muted); }
/* Kurzanleitung unter dem Eingabefeld (bricht als eigene Zeile um); die Kuerzel sind anklickbar. */
.composer.with-hint { flex-wrap: wrap; row-gap: 4px; }
.hint { flex-basis: 100%; margin: 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.hint .key {
  font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-weight: 600;
  padding: 0 5px; border: 1px solid var(--border); border-radius: 5px; background: #fff; color: var(--accent);
  cursor: pointer; margin-right: 2px;
}
.hint .key:hover { border-color: var(--accent); background: #e8f0fb; }
.hint .hint-more { white-space: nowrap; }
.composer textarea {
  flex: 1; font: inherit; resize: none; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 10px; max-height: 40vh; min-height: 42px; line-height: 1.4;
}
.composer textarea:focus { outline: 2px solid rgba(43, 108, 176, .35); border-color: var(--accent); }
/* Abgeschaltete Direktnachrichten: der Verlauf bleibt lesbar, die Eingabe ist gesperrt. */
.composer.readonly textarea { background: var(--bg); color: var(--muted); cursor: not-allowed; }
.composer-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

.toast {
  position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%); margin: 0;
  background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 14px;
  box-shadow: var(--shadow); max-width: 90%;
}
.toast.error { background: var(--danger); }

/* Export-Dialog ------------------------------------------------------- */

.dialog {
  border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 32px));
  box-shadow: 0 12px 40px rgba(0, 0, 0, .2); color: var(--ink);
}
.dialog::backdrop { background: rgba(31, 39, 51, .45); }
.dialog form { padding: 22px 24px 18px; display: flex; flex-direction: column; gap: 14px; }
.dialog h2 { margin: 0; font-size: 1.15rem; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1; }
.field select, .field input {
  font: inherit; font-size: 14px; color: var(--ink); padding: 7px 9px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.field-row { display: flex; gap: 10px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: 12px; padding: 3px 10px; border-radius: 12px;
  border: 1px solid var(--border); background: #fff; color: var(--muted); cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.formats { border: 0; padding: 0; margin: 0; display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.formats legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 4px; }
.formats label { display: flex; align-items: center; gap: 5px; }
#export-count { margin: 0; min-height: 1.2em; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Schmale Bildschirme ------------------------------------------------- */

@media (max-width: 800px) {
  /* Daumenbreite, Symbol mittig. */
  .iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; }
  .iconbtn-small { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .brand { flex-direction: column; gap: 0; }
  .body { position: relative; }
  .room-topic { display: none; }
  .me { display: none; }
  #export-open { display: none; }
  .topbar .btn { padding: 8px 12px; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 20; transform: translateX(-100%);
    transition: transform .18s ease; box-shadow: none;
    width: min(84vw, 300px);
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar.open { transform: none; box-shadow: 0 0 30px rgba(0, 0, 0, .25); }
  .backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 15; }
  /* Genug Flaeche zum Antippen: Raeume, Mitglieder, Marken, kleine Knoepfe. */
  .rooms li { padding: 9px 10px; }
  .users li { padding: 8px; }
  .tags li { padding: 5px 11px; font-size: 14px; }
  .linklike { font-size: 14px; }
  .btn.small { font-size: 14px; padding: 7px 12px; }
  .chip { font-size: 13px; padding: 6px 12px; }
  .msg .actions button { font-size: 13px; padding: 4px 10px; }
  .thread-link { padding: 4px 10px; }
  .messages { padding: 10px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left)); }
  /* Eingabe: 16px, sonst zoomt iOS beim Hineintippen. Unten bleibt Platz fuer
     die Leiste des Telefons. */
  .composer {
    padding: 8px max(12px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  .composer textarea, .search-form input[type="search"], .field select, .field input { font-size: 16px; }
  .composer-side .small { display: none; }
  .hint .hint-more { display: none; }
  .ac { left: 12px; right: 12px; max-height: 40vh; }
  .jump { right: 12px; }
  /* Thread und Suche liegen als Overlay ueber allem -- also selbst bis in die
     Kerbe und bis zur unteren Leiste; zu ziehen gibt es hier nichts. */
  .thread { position: fixed; inset: 0; width: auto; z-index: 25; border-left: 0; }
  .search { position: fixed; inset: 0; width: auto; z-index: 26; border-left: 0; }
  .grabber { display: none; }
  .thread-head, .search-head { padding-top: calc(10px + env(safe-area-inset-top)); }
  .thread-composer { padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); }
  .search-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .search-results li, .notif-list li { padding: 11px 14px; }
}

/* Telefone im Hochformat: Kopfzeile und Nachrichten schmaler schneiden. */
@media (max-width: 480px) {
  .topbar { gap: 8px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .brand-title { display: none; }          /* der Weg zu den Tools steht in der Seitenleiste */
  .brand { flex-direction: row; align-items: baseline; }
  .room-name { font-size: 15px; }
  .topbar .btn { padding: 8px 10px; font-size: 13px; }
  .msg { grid-template-columns: 30px 1fr; column-gap: 9px; padding: 5px 6px; margin: 0 -6px; }
  .msg.cont { grid-template-columns: 30px 1fr; }
  .avatar { width: 30px; height: 30px; font-size: 14px; }
  .day { margin: 14px 0 8px; }
  .field-row { flex-direction: column; }   /* Von/Bis untereinander */
  .login-card { padding: 1.75rem 1.25rem; }
  .dialog form { padding: 18px 16px 16px; }
}
