/* Dunkles Discord-Gerüst, Chatbereich im WhatsApp-Stil */
:root {
  --rail: #1e1f22;
  --sidebar: #2b2d31;
  --sidebar-hover: #35373c;
  --sidebar-active: #404249;
  --chat-bg: #0b141a;
  --chat-pattern: rgba(255, 255, 255, 0.025);
  --head: #202c33;
  --bubble-in: #202c33;
  --bubble-out: color-mix(in srgb, var(--accent) 48%, #111b21);
  --text: #e9edef;
  --muted: #8696a0;
  --border: #2f3b43;
  --input: #2a3942;
  --accent: #00a884;
  --accent-hover: color-mix(in srgb, var(--accent) 80%, #fff);
  --blurple: #5865f2;
  --tick-read: #53bdeb;
  --online: #23a55a;
  --danger: #f23f43;
  --radius: 8px;
  --name-l: 62%;
}

/* Hell: automatisch nach Gerät – oder fest eingestellt (Einstellungen → Aussehen) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --sidebar: #f2f3f5;
    --sidebar-hover: #e3e5e8;
    --sidebar-active: #d7d9dc;
    --chat-bg: #efeae2;
    --chat-pattern: rgba(0, 0, 0, 0.035);
    --head: #f0f2f5;
    --bubble-in: #ffffff;
    --text: #111b21;
    --muted: #667781;
    --border: #d1d7db;
    --input: #ffffff;
    --tick-read: #34b7f1;
    --name-l: 38%;
    --bubble-out: color-mix(in srgb, var(--accent) 20%, #fff);
  }
}
:root[data-theme="light"] {
  --sidebar: #f2f3f5;
  --sidebar-hover: #e3e5e8;
  --sidebar-active: #d7d9dc;
  --chat-bg: #efeae2;
  --chat-pattern: rgba(0, 0, 0, 0.035);
  --head: #f0f2f5;
  --bubble-in: #ffffff;
  --text: #111b21;
  --muted: #667781;
  --border: #d1d7db;
  --input: #ffffff;
  --tick-read: #34b7f1;
  --name-l: 38%;
  --bubble-out: color-mix(in srgb, var(--accent) 20%, #fff);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background: var(--rail);
  color: var(--text);
  overflow: hidden;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
}
button:hover { background: var(--accent-hover); }
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.ghost {
  background: none; color: var(--muted); padding: 0.4rem 0.55rem; font-size: 1.15rem; line-height: 1;
  border-radius: 50%;
}
button.ghost:hover { color: var(--text); background: rgba(127, 127, 127, 0.15); }

input, textarea {
  font: inherit;
  color: var(--text);
  background: var(--input);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 1rem;
  position: relative; user-select: none;
}
.avatar.sm { width: 32px; height: 32px; font-size: 0.85rem; }
.avatar.xl { width: 96px; height: 96px; font-size: 2.4rem; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar.clickable { cursor: pointer; }
.avatar.clickable:hover { filter: brightness(1.1); }
.avatar.online::after {
  content: ""; position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--online); border: 3px solid var(--sidebar);
}

/* ---------- Anmeldung ---------- */
.auth {
  display: grid; place-items: center; height: 100%; padding: 16px; overflow-y: auto;
  background: linear-gradient(135deg, var(--blurple), var(--accent));
}
.auth[hidden] { display: none; }
.auth-card {
  background: var(--sidebar); border-radius: 16px; padding: 2rem;
  width: 100%; max-width: 380px; text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
.auth-card .logo { font-size: 3rem; }
.auth-card h1 { margin: 0.2rem 0 1rem; }
.auth-form { display: grid; gap: 0.7rem; }
.auth-form[hidden] { display: none; }
.auth-form p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.auth-form .error { color: var(--danger); min-height: 0; }
.auth-form .error:empty { display: none; }

.tabs { display: flex; gap: 4px; background: rgba(0, 0, 0, 0.2); border-radius: 10px; padding: 4px; margin-bottom: 1rem; }
.tabs[hidden] { display: none; }
.tab { flex: 1; background: none; color: var(--muted); padding: 0.45rem 0.6rem; font-size: 0.9rem; }
.tab:hover { background: var(--sidebar-hover); color: var(--text); }
.tab.active { background: var(--sidebar-active); color: var(--text); font-weight: 600; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: 320px 1fr auto;
  grid-template-rows: minmax(0, 1fr); /* Spalten nie höher als das Fenster */
  height: 100%;
  overflow: hidden;
}
.app[hidden] { display: none; }

/* ---------- Seitenleiste ---------- */
.sidebar {
  background: var(--sidebar); display: flex; flex-direction: column; min-width: 0;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  height: 56px; padding: 0 0.75rem 0 1rem; border-bottom: 1px solid rgba(0, 0, 0, 0.25);
  font-weight: 700; font-size: 1.05rem;
}
.sidebar-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search { padding: 0.6rem 0.75rem 0.25rem; }
.search input { padding: 0.45rem 0.8rem; font-size: 0.9rem; }
.sidebar-list { list-style: none; margin: 0; padding: 0.4rem; overflow-y: auto; flex: 1; min-height: 0; }
.list-label {
  color: var(--muted); font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 1rem 0.5rem 0.3rem; display: flex; justify-content: space-between;
}
.list-label button { padding: 0 0.3rem; font-size: 1rem; }
.empty-list { color: var(--muted); font-size: 0.9rem; padding: 1rem 0.5rem; text-align: center; }

/* WhatsApp-Chatliste */
.chat-item {
  display: flex; align-items: center; gap: 0.75rem; width: 100%; text-align: left;
  background: none; color: var(--text); padding: 0.55rem 0.6rem; border-radius: var(--radius);
}
.chat-item:hover { background: var(--sidebar-hover); }
.chat-item.active { background: var(--sidebar-active); }
.chat-item .info { flex: 1; min-width: 0; }
.chat-item .row { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.chat-item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .when { color: var(--muted); font-size: 0.75rem; flex: none; }
.chat-item .preview {
  color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-item.unread .when { color: var(--accent); }
.chat-item.unread .preview { color: var(--text); }
.count {
  flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 0.72rem; font-weight: 700; display: grid; place-items: center;
}

/* Discord-Kanalliste */
.channel-item {
  display: flex; align-items: center; gap: 0.4rem; width: 100%; text-align: left;
  background: none; color: var(--muted); padding: 0.4rem 0.5rem; border-radius: 4px; font-weight: 500;
}
.channel-item:hover { background: var(--sidebar-hover); color: var(--text); }
.channel-item.active { background: var(--sidebar-active); color: var(--text); }
.channel-item.unread { color: var(--text); font-weight: 700; }
.channel-item .hash { font-size: 1.2rem; opacity: 0.7; width: 1.1rem; text-align: center; }
.channel-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-item .count { background: var(--danger); }
.channel-item .hash { font-size: 1rem; }
.channel-item.home-item { margin-top: 0.4rem; }

/* ---------- Community-Kopf (wie bei WhatsApp-Communitys) ---------- */
.community-head { height: 68px; padding: 0 0.5rem; }
.community {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.7rem; text-align: left;
  background: none; color: var(--text); padding: 0.4rem 0.5rem; border-radius: 10px;
}
.community:hover, .community.active { background: var(--sidebar-hover); }
.community-icon {
  width: 44px; height: 44px; border-radius: 12px; font-size: 1.5rem;
  background: color-mix(in srgb, var(--accent) 35%, var(--sidebar-active));
}
.community-text { display: grid; min-width: 0; line-height: 1.25; }
.community-text strong { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.community-text span { font-size: 0.78rem; color: var(--muted); font-weight: 400; }

/* ---------- Gruppen in der Chatliste ---------- */
.avatar.group { font-size: 1.15rem; }
.avatar.group.sm { font-size: 1rem; }
.avatar.group.xl { font-size: 2.8rem; }
.lock-badge {
  position: absolute; right: -4px; bottom: -4px; font-size: 0.7rem; line-height: 1;
  background: var(--sidebar); border-radius: 50%; padding: 2px;
}
.channel-item.dm { padding: 0.5rem 0.55rem; gap: 0.7rem; border-radius: 8px; }
.channel-item.dm .avatar.sm { width: 42px; height: 42px; }
.channel-item.dm .label { font-weight: 600; color: var(--text); }
.channel-item .side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; flex: none; }
.channel-item.locked .label { color: var(--muted); }
.channel-item.announce .avatar { border-radius: 12px; }

/* ---------- Gruppeninfo (rechte Spalte) ---------- */
.group-info {
  display: grid; justify-items: center; text-align: center; gap: 0.25rem;
  padding: 1rem 0.5rem 1.2rem; margin-bottom: 0.5rem; border-bottom: 1px solid var(--border);
}
.group-info .avatar.xl { width: 88px; height: 88px; margin-bottom: 0.4rem; }
.group-info h3 { margin: 0; font-size: 1.1rem; }
.group-info p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.group-info .group-desc { color: var(--text); margin: 0.4rem 0; }
.group-info small { color: var(--muted); font-size: 0.75rem; }
.chat-title { cursor: pointer; }
.admin-row input.emoji-input, input.emoji-input { flex: none; width: 56px; min-width: 0; text-align: center; font-size: 1.2rem; padding: 0.4rem; }
.channel-item.locked { opacity: 0.55; }
.channel-item.locked:hover { opacity: 0.8; }
.welcome.locked { margin-top: 4rem; }
.lock-icon { font-size: 2.5rem; margin-bottom: 0.3rem; }
.channel-item.dm .avatar.online::after { border-color: var(--sidebar); }
.channel-item.dm:hover .avatar.online::after { border-color: var(--sidebar-hover); }
.channel-item.dm.active .avatar.online::after { border-color: var(--sidebar-active); }
.channel-item .preview {
  display: block; font-size: 0.78rem; font-weight: 400; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.channel-item .when { font-size: 0.7rem; font-weight: 400; color: var(--muted); }
.channel-item.unread .when { color: var(--accent); }
.channel-item.dm .count { background: var(--accent); }
.role {
  display: inline-block; font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  background: var(--blurple); color: #fff; border-radius: 4px; padding: 0.05rem 0.3rem;
  vertical-align: middle; margin-left: 0.3rem;
}

.me {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.6rem;
  background: rgba(0, 0, 0, 0.15);
}
.me .avatar.online::after { border-color: #232428; }
.me-name { cursor: pointer; flex: 1; min-width: 0; display: grid; line-height: 1.2; }
.me-name strong { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-name span { font-size: 0.75rem; color: var(--muted); }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; background: var(--chat-bg); }
.chat-head {
  display: flex; align-items: center; gap: 0.75rem; height: 56px; flex: none;
  padding: 0 0.75rem; background: var(--head); border-left: 1px solid var(--border);
}
.chat-head .avatar { width: 38px; height: 38px; }
.chat-head .avatar.channel { background: var(--sidebar-active); color: var(--muted); font-size: 1.3rem; }
.chat-title { flex: 1; min-width: 0; }
.chat-title h2 { margin: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title p {
  margin: 0; font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-title p.typing { color: var(--accent); }
.back { display: none; }

.messages {
  flex: 1; min-height: 0; overflow-y: auto; padding: 0.75rem 5% 0.5rem;
  background-image: radial-gradient(var(--chat-pattern) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
}
.welcome {
  margin: 1.5rem auto; max-width: 420px; text-align: center; color: var(--muted);
  background: var(--head); border-radius: var(--radius); padding: 1rem 1.25rem; font-size: 0.9rem;
}
.welcome strong { display: block; color: var(--text); font-size: 1.1rem; margin-bottom: 0.3rem; }

.day { display: flex; justify-content: center; margin: 0.9rem 0 0.5rem; position: sticky; top: 0; z-index: 1; }
.day span {
  background: var(--head); color: var(--muted); font-size: 0.75rem; font-weight: 600;
  padding: 0.3rem 0.75rem; border-radius: 8px; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}

.msg { display: flex; gap: 0.5rem; align-items: flex-end; margin-top: 2px; }
.msg.first { margin-top: 0.6rem; }
.msg.mine { flex-direction: row-reverse; }
.msg .avatar { width: 32px; height: 32px; font-size: 0.85rem; align-self: flex-start; }
.msg .spacer { width: 32px; flex: none; }
.msg-body { display: flex; flex-direction: column; max-width: min(75%, 560px); min-width: 0; }
.msg.mine .msg-body { align-items: flex-end; }

.bubble {
  position: relative; background: var(--bubble-in); padding: 0.35rem 0.55rem 0.4rem;
  border-radius: 8px; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15); min-width: 70px;
}
.msg.mine .bubble { background: var(--bubble-out); }
/* WhatsApp-"Schwänzchen" an der ersten Blase */
.msg.first .bubble::before {
  content: ""; position: absolute; top: 0; width: 10px; height: 12px; background: inherit;
}
.msg.first:not(.mine) .bubble { border-top-left-radius: 0; }
.msg.first:not(.mine) .bubble::before { left: -8px; clip-path: polygon(100% 0, 0 0, 100% 100%); }
.msg.first.mine .bubble { border-top-right-radius: 0; }
.msg.first.mine .bubble::before { right: -8px; clip-path: polygon(0 0, 100% 0, 0 100%); }

.sender { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 0.15rem; line-height: 1.2; }
.link-name { background: none; padding: 0; font-size: 0.82rem; font-weight: 700; border-radius: 0; }
.link-name:hover { background: none; text-decoration: underline; }
/* Unterrolle unter dem Namen, z. B. „Azubi“ */
.subrole {
  font-size: 0.68rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.subrole::before { content: "🏷️ "; }
.subrole.big { font-size: 0.8rem; margin-top: -0.2rem; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.38; font-size: 0.94rem; }
.text a { color: var(--tick-read); }
/* Platz für Uhrzeit rechts unten freihalten */
.text::after { content: ""; display: inline-block; width: var(--meta-w, 48px); }
.meta {
  position: absolute; right: 0.5rem; bottom: 0.25rem; font-size: 0.68rem; color: var(--muted);
  display: flex; gap: 0.2rem; align-items: center; white-space: nowrap;
}
.msg.mine .meta { color: color-mix(in srgb, var(--text) 60%, transparent); }
.msg.mine .bubble { --meta-w: 64px; }
.tick { font-size: 0.8rem; letter-spacing: -0.3em; margin-right: 0.3em; }
.tick.read { color: var(--tick-read); }

.quote {
  display: grid; background: rgba(0, 0, 0, 0.18); border-left: 4px solid var(--accent);
  border-radius: 6px; padding: 0.3rem 0.5rem; margin-bottom: 0.3rem; font-size: 0.82rem;
  cursor: pointer; min-width: 0;
}
.quote strong { color: var(--accent); }
.quote span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.actions {
  position: absolute; top: -14px; display: none; gap: 2px; background: var(--head);
  border-radius: 8px; padding: 2px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); z-index: 2;
}
.msg:not(.mine) .actions { right: -8px; }
.msg.mine .actions { left: -8px; }
.msg:hover .actions, .msg.touched .actions { display: flex; }
.actions button { font-size: 0.95rem; padding: 0.25rem 0.4rem; }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.reaction {
  display: flex; align-items: center; gap: 4px; padding: 0.1rem 0.45rem; font-size: 0.82rem;
  background: var(--head); color: var(--text); border: 1px solid transparent; border-radius: 10px;
}
.reaction:hover { background: var(--head); border-color: var(--muted); }
.reaction.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 20%, var(--head)); }

.msg.flash .bubble { animation: flash 1.2s; }
@keyframes flash { 30% { box-shadow: 0 0 0 3px var(--accent); } }

/* ---------- Eingabe ---------- */
.reply-bar {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem 0;
  background: var(--head); border-left: 1px solid var(--border);
}
.reply-bar[hidden] { display: none; }
.reply-bar .quote { flex: 1; margin: 0; cursor: default; }
.composer {
  display: flex; align-items: flex-end; gap: 0.5rem; padding: 0.55rem 0.75rem;
  background: var(--head); border-left: 1px solid var(--border);
}
.composer[hidden] { display: none; }
.readonly-bar {
  padding: 0.9rem 1rem; background: var(--head); color: var(--muted); font-size: 0.9rem;
  text-align: center; border-left: 1px solid var(--border);
}
.readonly-bar[hidden] { display: none; }
.composer textarea { resize: none; max-height: 140px; border-radius: 20px; padding: 0.6rem 1rem; }
.send {
  flex: none; width: 44px; height: 44px; border-radius: 50%; padding: 0; font-size: 1.1rem;
  display: grid; place-items: center;
}

/* ---------- Mitgliederliste ---------- */
.members { width: 240px; background: var(--sidebar); overflow-y: auto; padding: 0.5rem; }
.members[hidden] { display: none; }
.member {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; text-align: left;
  background: none; color: var(--text); padding: 0.35rem 0.5rem; border-radius: 4px;
}
.member:hover { background: var(--sidebar-hover); }
.member.offline { opacity: 0.45; }
.member .avatar.online::after { border-color: var(--sidebar); }
.member small { display: block; color: var(--muted); font-size: 0.72rem; }

/* ---------- Emoji-Auswahl ---------- */
.picker {
  position: fixed; z-index: 20; display: flex; gap: 2px; padding: 4px;
  background: var(--head); border: 1px solid var(--border); border-radius: 24px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.picker[hidden] { display: none; }
.picker button { background: none; font-size: 1.35rem; padding: 0.25rem 0.35rem; border-radius: 50%; }
.picker button:hover { background: rgba(127, 127, 127, 0.2); transform: scale(1.15); }

/* ---------- Dialog ---------- */
dialog {
  border: none; border-radius: 12px; padding: 1.5rem;
  background: var(--sidebar); color: var(--text); width: min(420px, calc(100% - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h3 { margin-top: 0; }
dialog select { font: inherit; color: var(--text); background: var(--input); border: none; border-radius: var(--radius); padding: 0.55rem; }

/* ---------- Admin-Bereich ---------- */
dialog.admin { width: min(560px, calc(100% - 24px)); padding: 1.25rem; max-height: calc(100% - 32px); }
.admin-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.8rem; }
.admin-head h3 { margin: 0; }
.admin-body { display: grid; gap: 0.8rem; }
.admin-body p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.admin-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.admin-row input { flex: 1; min-width: 140px; }
.admin-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.admin-list li {
  display: flex; align-items: center; gap: 0.6rem; background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius); padding: 0.5rem 0.6rem;
}
.admin-list .grow { flex: 1; min-width: 0; }
.admin-list small { display: block; color: var(--muted); font-size: 0.75rem; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; font-weight: 700; letter-spacing: 0.08em; }
button.small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
button.danger { background: var(--danger); }
button.danger:hover { background: #d83c3e; }
.admin-body p.hint {
  color: var(--text); background: color-mix(in srgb, #f0b232 18%, transparent);
  border-left: 4px solid #f0b232; border-radius: 6px; padding: 0.5rem 0.7rem;
}
.role-dot { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%; }
input.color { flex: none; width: 44px; min-width: 0; height: 40px; padding: 2px; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 0.4rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.15rem 0.55rem; font-size: 0.78rem;
  background: transparent; color: var(--muted); border: 1px dashed var(--border); border-radius: 999px;
}
.chip:hover { background: var(--sidebar-hover); color: var(--text); }
.chip.on { background: var(--sidebar-active); color: var(--text); border-style: solid; }
.chip:disabled { opacity: 0.4; cursor: not-allowed; }
span.chip { cursor: default; }
.checks.column { flex-direction: column; gap: 0.4rem; }
.admin-row.center { justify-content: center; }
.title-field { display: flex !important; flex-direction: row !important; align-items: center; gap: 0.4rem !important; margin: 0.4rem 0 0 !important; }
.title-field input { padding: 0.3rem 0.6rem; font-size: 0.82rem; max-width: 240px; }
dialog textarea { resize: vertical; }
.counter { text-align: right; }

/* ---------- Startseite ---------- */
.home { max-width: 640px; margin: 0 auto; padding: 1.5rem 0 2rem; display: grid; gap: 1rem; }
.home-hero { text-align: center; padding: 1rem 0 0.5rem; }
.home-icon { font-size: 4rem; line-height: 1; }
.home-hero h1 { margin: 0.5rem 0 0.25rem; font-size: 1.8rem; }
.home-hero p { margin: 0; color: var(--muted); }
.home-hero strong { color: var(--text); }
.home-card { background: var(--head); border-radius: 12px; padding: 1rem 1.25rem; }
.home-card h3 { margin: 0 0 0.5rem; }
.home-card p { margin: 0 0 0.5rem; color: var(--muted); }
.home-card .about { color: var(--text); white-space: pre-wrap; line-height: 1.5; }
.home-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.stat { background: var(--head); border-radius: 12px; padding: 0.8rem; text-align: center; display: grid; }
.stat strong { font-size: 1.5rem; color: var(--accent); }
.stat span { font-size: 0.8rem; color: var(--muted); }
.home-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; }

/* ---------- Profil ---------- */
dialog.profile-card { padding: 0; width: min(380px, calc(100% - 24px)); overflow: hidden; }
.profile-banner { height: 72px; }
.profile-close { position: absolute; top: 8px; right: 8px; color: #fff; background: rgba(0, 0, 0, 0.3); }
.profile-body { padding: 0 1.25rem 1.25rem; display: grid; justify-items: start; gap: 0.35rem; }
.profile-body > .avatar.xl { margin-top: -48px; border: 6px solid var(--sidebar); box-sizing: content-box; }
.profile-body h2 { margin: 0.2rem 0 0; font-size: 1.3rem; }
.profile-body h4 { margin: 0.6rem 0 0; font-size: 0.75rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
.profile-status, .profile-since { margin: 0; color: var(--muted); font-size: 0.82rem; }
.profile-bio { margin: 0; white-space: pre-wrap; line-height: 1.45; }
.profile-body .dialog-actions { justify-self: stretch; margin-top: 0.6rem; }
.profile-body.edit { justify-items: center; padding-top: 1.25rem; }
.profile-body.edit h3 { margin: 0 0 0.5rem; }
.profile-body.edit label { justify-self: stretch; }
.profile-body.edit > .avatar.xl { margin-top: 0; border: none; }
.chip:not(.on) .role-dot { opacity: 0.4; }
.admin-list li.channel-admin { flex-wrap: wrap; }
.rights {
  flex-basis: 100%; display: grid; gap: 0.8rem; margin-top: 0.4rem; padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}
.rights label { margin: 0; }
.rights strong { font-size: 0.88rem; }
.rights small { display: block; margin-bottom: 0.35rem; }
.checks { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; }
.check { display: flex !important; align-items: center; gap: 0.4rem; color: var(--text) !important; cursor: pointer; }
.check input { width: auto; margin: 0; }
.admin-empty { color: var(--muted); font-size: 0.9rem; text-align: center; padding: 0.8rem; }
dialog label, dialog .field { display: grid; gap: 0.3rem; margin-bottom: 0.8rem; font-size: 0.85rem; color: var(--muted); }
.user-pick { list-style: none; padding: 0; margin: 0 0 0.8rem; max-height: 240px; overflow-y: auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.error { color: var(--danger); font-size: 0.85rem; min-height: 1em; margin: 0 0 0.5rem; }

/* ---------- Tablet: Gruppeninfo als Overlay von rechts ---------- */
@media (max-width: 1100px) {
  .members {
    position: fixed; right: 0; top: 0; bottom: 0; z-index: 10;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
  }
}

/* ---------- Handy: Liste und Chat nacheinander (wie WhatsApp) ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .chat {
    position: fixed; inset: 0; z-index: 5; transform: translateX(100%); transition: transform 0.2s;
  }
  .app.chat-open .chat { transform: none; }
  .back { display: block; }
  .chat-head, .composer, .reply-bar { border-left: none; }
  .messages { padding: 0.5rem 0.6rem; }
  .msg-body { max-width: 85%; }
  /* Gruppeninfo am Handy als ganze Seite (wie bei WhatsApp) */
  .members { inset: 0; width: 100%; z-index: 12; box-shadow: none; }
}

/* ---------- Fotos, Videos, Sprachnachrichten ---------- */
.bubble .media { display: block; margin: -0.1rem -0.3rem 0.3rem; border-radius: 6px; overflow: hidden; }
.bubble .media img, .bubble video.media {
  display: block; max-width: min(340px, 68vw); max-height: 340px; width: auto; height: auto;
  border-radius: 6px; background: rgba(0, 0, 0, 0.2);
}
.bubble video.media { width: min(340px, 68vw); }
.bubble.media-only { padding: 0.2rem; }
.bubble.media-only .media { margin: 0; }
.bubble.media-only:not(.has-voice):not(.has-audio) .meta {
  right: 0.6rem; bottom: 0.5rem; color: #fff; background: rgba(0, 0, 0, 0.45); padding: 0.05rem 0.4rem; border-radius: 8px;
}
.bubble.media-only.has-voice, .bubble.media-only.has-audio { padding: 0.35rem 0.5rem 1.1rem; }
.voice { display: flex; align-items: center; gap: 0.5rem; min-width: 250px; }
.voice audio { height: 36px; flex: 1; min-width: 180px; max-width: 280px; }
.voice-icon { font-size: 1.5rem; }
.bubble.has-voice .text, .bubble.has-audio .text { margin-top: 0.3rem; }

.attach-bar { align-items: center; }
.attach-preview { width: 48px; height: 48px; flex: none; border-radius: 6px; overflow: hidden; display: grid; place-items: center; background: var(--sidebar-active); font-size: 1.5rem; }
.attach-preview img, .attach-preview video { width: 100%; height: 100%; object-fit: cover; }
.attach-bar .quote { cursor: default; border-left-color: var(--accent); }
.attach-bar .quote strong { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.record-bar {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0.75rem;
  background: var(--head); border-left: 1px solid var(--border);
}
.record-bar[hidden] { display: none; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
#record-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.rec-hint { flex: 1; color: var(--muted); font-size: 0.9rem; }
.composer .send[hidden] { display: none; }

/* ---------- Gruppenbild, Gruppen-Admins, Beitrittsanfragen ---------- */
.avatar.group img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.welcome.locked { display: grid; justify-items: center; gap: 0.4rem; }
.welcome.locked .avatar.xl { width: 88px; height: 88px; }
.welcome.locked p { margin: 0; }
.home-actions.center { justify-content: center; }
.group-admin {
  display: inline-block; font-size: 0.62rem; font-weight: 700; text-transform: uppercase; margin-left: 0.3rem;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 0 0.25rem; vertical-align: middle;
}
.group-info button { margin-top: 0.6rem; }
.member-row { display: flex; align-items: center; }
.member-row .member { flex: 1; min-width: 0; }
.member-actions { display: flex; flex: none; }
.member-actions button { font-size: 0.95rem; padding: 0.3rem 0.4rem; }
.requests { margin-bottom: 0.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
.request { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.5rem; }
.request .grow { flex: 1; min-width: 0; font-size: 0.9rem; }
.request small { display: block; color: var(--muted); font-size: 0.72rem; }
.request button { padding: 0.25rem 0.55rem; }
.count.requests { background: #f0b232; color: #1e1f22; }
.members .leave { display: block; margin: 1rem auto 0.5rem; }

/* ---------- Medien, Links & Audio ---------- */
.media-row { margin: 0 0 0.6rem; padding: 0 0.25rem 0.8rem; border-bottom: 1px solid var(--border); }
.media-head {
  display: flex; justify-content: space-between; width: 100%; background: none; color: var(--text);
  padding: 0.4rem 0.25rem; font-size: 0.9rem;
}
.media-head:hover { background: var(--sidebar-hover); }
.media-count { color: var(--muted); }
.media-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 0.3rem; }
.tile {
  padding: 0; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--sidebar-active);
  display: block; width: 100%;
}
.tile:hover { background: var(--sidebar-active); filter: brightness(1.12); }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-thumb { position: relative; width: 100%; height: 100%; }
.video-thumb span {
  position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1.4rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}
dialog.media-dialog { width: min(640px, calc(100% - 24px)); max-height: calc(100% - 32px); padding: 1.25rem; }
.media-body { max-height: 65vh; overflow-y: auto; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 4px; }
.media-body .admin-list audio { display: block; width: 100%; height: 34px; margin-top: 0.35rem; }
.link-icon { font-size: 1.3rem; }
.link-url { display: block; color: var(--tick-read); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer { display: grid; gap: 0.5rem; justify-items: center; text-align: center; }
.viewer img, .viewer video { max-width: 100%; max-height: 55vh; border-radius: 8px; background: #000; }
.viewer p { margin: 0; }
.viewer small { color: var(--muted); }
.viewer .dialog-actions { justify-self: stretch; flex-wrap: wrap; }
a.button {
  display: inline-block; padding: 0.6rem 1rem; border-radius: var(--radius); text-decoration: none;
  background: var(--accent); color: #fff;
}
a.button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.hint-text { color: var(--muted); font-size: 0.82rem; margin: 0 0 0.5rem; }
.member-actions button:disabled { opacity: 1; cursor: default; color: #f0b232; }

/* ---------- Gruppeninfo (wie bei WhatsApp) ---------- */
.members { width: 380px; padding: 0; background: var(--chat-bg); border-left: 1px solid var(--border); }
.info-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 0.5rem;
  height: 56px; padding: 0 0.75rem; background: var(--head);
}
.info-head strong { flex: 1; font-size: 1rem; }
.info-card { background: var(--sidebar); padding: 0.9rem 1rem; margin-bottom: 0.5rem; }
.info-card h4 { margin: 0 0 0.6rem; font-size: 0.85rem; color: var(--accent); font-weight: 600; }
.info-card.hero { display: grid; justify-items: center; text-align: center; gap: 0.3rem; padding: 1.5rem 1rem 1.2rem; }
.info-card.hero h2 { margin: 0.5rem 0 0; font-size: 1.35rem; }
.info-card.hero p { margin: 0; }
.avatar.xxl { width: 150px; height: 150px; font-size: 4.5rem; }
.muted { color: var(--muted); font-size: 0.88rem; }
.info-card.about { display: grid; gap: 0.35rem; }
.info-card.about .group-desc { margin: 0 0 0.3rem; white-space: pre-wrap; line-height: 1.45; color: var(--text); text-align: left; }
.info-card.about small { color: var(--muted); font-size: 0.78rem; }
.link-btn { background: none; color: var(--accent); padding: 0; text-align: left; justify-self: start; }
.link-btn:hover { background: none; text-decoration: underline; }
.info-card.media { padding: 0.5rem 0.75rem; }
.info-card.media .media-row { margin: 0; padding: 0; border: none; }
.setting { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0; border-top: 1px solid var(--border); }
.setting:first-of-type { border-top: none; }
.setting .grow { flex: 1; min-width: 0; display: grid; gap: 0.1rem; }
.setting .grow span { font-size: 0.92rem; }
.setting .grow small { color: var(--muted); font-size: 0.75rem; }
.setting select { font: inherit; font-size: 0.85rem; color: var(--text); background: var(--input); border: none; border-radius: var(--radius); padding: 0.4rem 0.5rem; }
.info-card.settings > small { display: block; margin-top: 0.4rem; }
/* Schalter wie in WhatsApp-Einstellungen */
input.switch {
  appearance: none; width: 40px; height: 22px; flex: none; border-radius: 11px; padding: 0; margin: 0;
  background: var(--sidebar-active); position: relative; cursor: pointer; transition: background 0.15s; border: none;
}
input.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform 0.15s;
}
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(18px); }
.card-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; }
.card-title h4 { margin: 0; color: var(--muted); }
.info-card.people .member-row { margin: 0 -0.5rem; }
.info-card.requests .request { padding: 0.35rem 0; }
.info-card.danger { display: grid; gap: 0.2rem; padding: 0.5rem 1rem; }
.danger-link { background: none; color: var(--danger); text-align: left; padding: 0.6rem 0; font-weight: 600; }
.danger-link:hover { background: none; text-decoration: underline; }
.pick .check { padding: 0.25rem 0; }
@media (max-width: 760px) {
  .members { width: 100%; border-left: none; }
}

/* ---------- Bereiche (Gruppen in Abschnitten) ---------- */
.sidebar-list .section { margin-top: 0.35rem; }
.section-head {
  display: flex; align-items: center; gap: 0.35rem; width: 100%; text-align: left;
  background: none; color: var(--muted); padding: 0.4rem 0.5rem; border-radius: 6px;
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.section-head:hover { color: var(--text); background: var(--sidebar-hover); }
.section-head.static { cursor: default; }
.section-head.static:hover { background: none; color: var(--muted); }
.section-head .chevron { width: 0.8rem; font-size: 0.75rem; }
.section-head .section-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-head .count { background: var(--accent); color: #fff; text-transform: none; letter-spacing: 0; }

.section-admin { border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem; }
.section-admin-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.section-admin-head .grow { flex: 1; min-width: 0; }
.section-admin-head small { color: var(--muted); font-size: 0.75rem; }
.section-admin-head form { margin: 0; }
.order { display: flex; flex-direction: column; flex: none; }
.order button { padding: 0 0.3rem; font-size: 0.8rem; line-height: 1.2; border-radius: 4px; }
.order button:disabled { opacity: 0.25; cursor: default; }
.channel-admin select { font: inherit; font-size: 0.8rem; color: var(--text); background: var(--input); border: none; border-radius: 6px; padding: 0.3rem; max-width: 150px; }
/* Verwaltung breiter, damit Bereiche und Gruppen übersichtlich bleiben */
dialog.admin { width: min(780px, calc(100% - 24px)); }
#admin-tabs .tab { white-space: nowrap; }
.section-admin .channel-admin .grow { min-width: 170px; }
.section-admin .channel-admin > select { flex: none; }
#admin-tabs { overflow-x: auto; scrollbar-width: none; }
#admin-tabs::-webkit-scrollbar { display: none; }
#admin-tabs .tab { flex: 1 0 auto; }
dialog.admin { overflow-x: hidden; }
.admin-body { grid-template-columns: minmax(0, 1fr); }
.admin-body select { max-width: 100%; min-width: 0; }
.admin-row > select { flex: 1 1 160px; }

/* ---------- Schriftgröße vom Gerät übernehmen ----------
   Alle Größen hängen an „rem“ (= die im Handy/PC/Browser eingestellte Grundschrift).
   Kopfzeilen, Profilbilder, Zähler und Knöpfe wachsen mit, damit bei großer Schrift nichts abgeschnitten wird. */

/* iPhone/iPad: Textgröße aus Einstellungen → Anzeige & Helligkeit (Dynamic Type) übernehmen.
   -webkit-touch-callout gibt es nur auf iOS – so bleibt Safari am Mac bei der normalen Browser-Schriftgröße. */
@supports (font: -apple-system-body) and (-webkit-touch-callout: none) {
  html { font: -apple-system-body; }
}

.avatar { width: 2.5rem; height: 2.5rem; }
.avatar.sm, .msg .avatar { width: 2rem; height: 2rem; }
.avatar.xl { width: 6rem; height: 6rem; }
.avatar.xxl { width: min(9.5rem, 40vw); height: min(9.5rem, 40vw); }
.avatar.online::after { width: 0.75rem; height: 0.75rem; }
.channel-item.dm .avatar.sm { width: 2.65rem; height: 2.65rem; }
.chat-head .avatar { width: 2.4rem; height: 2.4rem; }
.community-icon { width: 2.75rem; height: 2.75rem; }
.group-info .avatar.xl, .welcome.locked .avatar.xl { width: 5.5rem; height: 5.5rem; }
.profile-body > .avatar.xl { margin-top: -3rem; }

.sidebar-head, .chat-head, .info-head { height: auto; min-height: 3.5rem; padding-top: 0.35rem; padding-bottom: 0.35rem; }
.community-head { height: auto; min-height: 4.25rem; }
.count { min-width: 1.25rem; height: 1.25rem; border-radius: 0.625rem; padding: 0 0.4em; }
.send { width: 2.75rem; height: 2.75rem; }
.attach-preview { width: 3rem; height: 3rem; }
.role-dot, .rec-dot { width: 0.75em; height: 0.75em; }
input.color { width: 2.75rem; height: 2.5rem; }
.voice audio { height: 2.25rem; }
.profile-banner { height: 4.5rem; }

input.switch { width: 2.5rem; height: 1.375rem; border-radius: 0.7rem; }
input.switch::after { top: 0.1875rem; left: 0.1875rem; width: 1rem; height: 1rem; }
input.switch:checked::after { transform: translateX(1.125rem); }

/* Bei großer Schrift: lange Namen umbrechen statt aus dem Rahmen zu laufen */
/* Bei großer Schrift wächst der Text voll mit, Symbole und Knöpfe nur begrenzt –
   so bleibt am Handy genug Platz für Namen und Eingabefeld */
button.ghost { font-size: min(1.15rem, 24px); }
.send { width: min(2.75rem, 52px); height: min(2.75rem, 52px); font-size: min(1.1rem, 22px); }
.chat-head .avatar { width: min(2.4rem, 48px); height: min(2.4rem, 48px); font-size: min(1rem, 20px); }
.avatar.sm, .msg .avatar { width: min(2rem, 44px); height: min(2rem, 44px); font-size: min(0.85rem, 18px); }
.channel-item.dm .avatar.sm { width: min(2.65rem, 54px); height: min(2.65rem, 54px); }
.avatar.group.sm, .avatar.group { font-size: min(1.1rem, 24px); }
.composer { gap: 0.3rem; }
.composer textarea { min-width: 5.5rem; }
.composer button.ghost { padding: 0.4rem 0.35rem; }
/* Platz für die Uhrzeit in der Sprechblase wächst mit der Schrift */
.text::after { width: var(--meta-w, 3.3em); }
.msg.mine .bubble { --meta-w: 4.4em; }
.setting { flex-wrap: wrap; }
.composer textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home { grid-template-columns: minmax(0, 1fr); }
.home-stats { grid-template-columns: repeat(auto-fit, minmax(min(7rem, 100%), 1fr)); }
.home-card, .stat { min-width: 0; overflow-wrap: anywhere; }
/* Am PC wachsen Seitenleiste und Gruppeninfo mit der Schrift mit (in Grenzen) */
@media (min-width: 761px) {
  .app { grid-template-columns: clamp(300px, 20rem, 440px) 1fr auto; }
  .members { width: clamp(340px, 24rem, 500px); }
}

/* ---------- Stummgeschaltete Gruppen und Chats ---------- */
.channel-item .badges { display: flex; align-items: center; gap: 0.3rem; }
.muted-icon { font-size: 0.8em; opacity: 0.75; }
.count.muted { background: var(--muted); color: var(--sidebar); }
.channel-item.is-muted .when { color: var(--muted); }
.info-card.mute { padding: 0.4rem 1rem; }
.info-card.mute .setting, .profile-body .mute-row { border-top: none; }
.profile-body .mute-row { justify-self: stretch; margin-top: 0.4rem; }
.channel-item.dm .count.muted, .section-head .count.muted { background: var(--muted); color: var(--sidebar); }

/* ---------- Moderation: Meldungen, Protokoll, Sicherungen, Schreibverbot ---------- */
#admin-btn { position: relative; }
#admin-btn:not([data-count=""])[data-count]::after {
  content: attr(data-count); position: absolute; top: -2px; right: -2px; min-width: 1.1rem; height: 1.1rem;
  padding: 0 0.3em; border-radius: 0.55rem; background: var(--danger); color: #fff; font-size: 0.68rem; font-weight: 700;
  display: grid; place-items: center;
}
.member-tools { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.member-tools select { font: inherit; font-size: 0.8rem; color: var(--text); background: var(--input); border: none; border-radius: 6px; padding: 0.3rem 0.4rem; }
.admin-list .report { align-items: flex-start; }
.admin-list .report .quote { margin-bottom: 0.35rem; cursor: default; }
.admin-list .report .admin-row { margin-top: 0.5rem; }
.admin-list .report.done { opacity: 0.6; }
.sub-title { margin: 0.8rem 0 0.3rem; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.admin-list.audit li { padding: 0.4rem 0.6rem; }
.admin-list.audit .when { flex: none; color: var(--muted); font-size: 0.75rem; }
.backups { display: grid; gap: 0.6rem; border-top: 1px solid var(--border); margin-top: 0.8rem; padding-top: 0.4rem; }
.backups p { margin: 0; }
a.button.small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

/* ---------- @Erwähnungen ---------- */
.mention { color: var(--tick-read); font-weight: 600; }
.mention.self { background: color-mix(in srgb, #f0b232 30%, transparent); color: var(--text); border-radius: 4px; padding: 0 0.15em; }
.bubble.mentions-me { box-shadow: inset 3px 0 0 #f0b232, 0 1px 1px rgba(0, 0, 0, 0.15); }
.count.mention { background: #f0b232 !important; color: #1e1f22 !important; font-weight: 800; }
.mention-list {
  list-style: none; margin: 0; padding: 0.3rem; background: var(--head); border-top: 1px solid var(--border);
  border-left: 1px solid var(--border); max-height: 16rem; overflow-y: auto;
}
.mention-list[hidden] { display: none; }
.mention-item {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; text-align: left; background: none; color: var(--text);
  padding: 0.35rem 0.5rem; border-radius: 6px;
}
.mention-item:hover, .mention-item.active { background: var(--sidebar-active); }

/* ---------- Benachrichtigungen ---------- */
.notify-card .setting:first-of-type { border-top: none; }
.notify-card .hint-text { display: block; margin: 0.4rem 0 0; }
.notify-card > button { margin-top: 0.6rem; }

/* ---------- Paket 3: Chat-Komfort ---------- */
.forwarded { font-size: 0.75rem; font-style: italic; color: var(--muted); margin-bottom: 0.15rem; }
.edited { font-style: italic; margin-right: 0.3em; }
.msg.mine .bubble { --meta-w: 6.4em; }
.tick.partial { color: var(--muted); }

/* Menü „⋯“ */
.msg-menu {
  position: fixed; z-index: 30; min-width: 12rem; padding: 0.3rem; display: grid;
  background: var(--head); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.msg-menu[hidden] { display: none; }
.menu-item {
  display: flex; align-items: center; gap: 0.6rem; background: none; color: var(--text); text-align: left;
  padding: 0.5rem 0.7rem; border-radius: 6px; font-size: 0.92rem;
}
.menu-item:hover { background: var(--sidebar-active); }
.menu-item.danger { color: var(--danger); }
.menu-item span { width: 1.2rem; text-align: center; }

/* Angepinnte Nachrichten */
.pin-bar {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; text-align: left; flex: none;
  background: var(--head); color: var(--text); border-radius: 0; border-top: 1px solid var(--border);
  border-left: 1px solid var(--border); padding: 0.45rem 1rem;
}
.pin-bar:hover { background: var(--sidebar-hover); }
.pin-bar[hidden] { display: none; }
.pin-text { display: grid; min-width: 0; line-height: 1.25; }
.pin-text strong { font-size: 0.75rem; color: var(--accent); }
.pin-text span { font-size: 0.85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Umfragen */
.bubble.has-poll { min-width: min(18rem, 70vw); }
.poll { display: grid; gap: 0.35rem; margin-bottom: 1rem; }
.poll-question { font-weight: 700; }
.poll-hint, .poll-total { color: var(--muted); font-size: 0.75rem; }
.poll-option {
  position: relative; display: flex; align-items: center; gap: 0.5rem; width: 100%; text-align: left; overflow: hidden;
  background: rgba(0, 0, 0, 0.18); color: var(--text); padding: 0.45rem 0.6rem; border-radius: 8px; border: 1px solid transparent;
}
.poll-option:hover { background: rgba(0, 0, 0, 0.28); }
.poll-option.voted { border-color: var(--accent); }
.poll-check {
  flex: none; width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 2px solid var(--muted);
  display: grid; place-items: center; font-size: 0.7rem; font-weight: 800; z-index: 1;
}
.poll-option.voted .poll-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.poll-text { flex: 1; z-index: 1; }
.poll-count { z-index: 1; font-weight: 700; font-size: 0.85rem; }
.poll-bar { position: absolute; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 22%, transparent); transition: width 0.25s; }
.poll-options-edit { display: grid; gap: 0.3rem; }

/* Suche */
.search-result {
  display: grid; gap: 0.15rem; width: 100%; text-align: left; background: none; color: var(--text);
  padding: 0.45rem 0.6rem; border-radius: 8px;
}
.search-result:hover { background: var(--sidebar-hover); }
.search-result .row { display: flex; justify-content: space-between; gap: 0.5rem; }
.search-result strong { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result small { color: var(--muted); font-size: 0.72rem; flex: none; }
.search-result .preview { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results { max-height: 55vh; overflow-y: auto; margin-top: 0.6rem; }
.search-results li { padding: 0; background: none; }

/* Bildbetrachter */
dialog.lightbox {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border-radius: 0;
  background: rgba(0, 0, 0, 0.92); color: #fff; display: none; flex-direction: column;
}
dialog.lightbox[open] { display: flex; }
dialog.lightbox::backdrop { background: rgba(0, 0, 0, 0.85); }
.lb-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.9rem; }
.lb-head .grow { flex: 1; display: grid; }
.lb-head small { color: #bbb; font-size: 0.78rem; }
.lb-btn { color: #fff !important; text-decoration: none; font-size: 1.2rem; }
.lb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; padding: 0 3rem; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255, 255, 255, 0.12); color: #fff;
  width: 2.6rem; height: 2.6rem; border-radius: 50%; font-size: 1.6rem; padding: 0; line-height: 1;
}
.lb-nav:hover { background: rgba(255, 255, 255, 0.25); }
.lb-nav.prev { left: 0.6rem; }
.lb-nav.next { right: 0.6rem; }
.lb-caption { text-align: center; padding: 0.6rem 1rem 1rem; margin: 0; }
@media (max-width: 760px) {
  .lb-stage { padding: 0 0.5rem; }
  .lb-nav { display: none; } /* am Handy wischen */
}
.msg-menu .menu-item.danger { background: none; color: var(--danger); }
.msg-menu .menu-item.danger:hover { background: var(--sidebar-active); }
/* Platz für „bearbeitet“ + Uhrzeit */
.bubble.is-edited { --meta-w: 7.8em; }
.msg.mine .bubble.is-edited { --meta-w: 9em; }

/* ---------- Dokumente ---------- */
.doc-card {
  display: flex; align-items: center; gap: 0.6rem; min-width: min(16rem, 65vw); max-width: 20rem;
  padding: 0.55rem 0.65rem; border-radius: 8px; background: rgba(0, 0, 0, 0.18);
  color: inherit; text-decoration: none; margin-bottom: 0.2rem;
}
.doc-card:hover { background: rgba(0, 0, 0, 0.26); }
.doc-icon { font-size: 1.9rem; line-height: 1; flex: none; }
.doc-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.doc-text strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-text small { color: var(--muted); font-size: 0.75rem; }
.doc-dl {
  flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--muted); color: var(--muted); font-size: 0.9rem;
}
.bubble.has-file:not(.is-edited) .meta { position: static; float: right; margin-top: 0.1rem; }

/* ---------- Linkvorschau ---------- */
.link-preview {
  display: block; margin: 0.35rem 0 0.15rem; border-radius: 8px; overflow: hidden;
  background: rgba(0, 0, 0, 0.18); color: inherit; text-decoration: none; max-width: 22rem;
  border-left: 3px solid var(--accent);
}
.link-preview:hover { background: rgba(0, 0, 0, 0.26); }
.link-preview img { display: block; width: 100%; max-height: 11rem; object-fit: cover; }
.lp-text { display: flex; flex-direction: column; gap: 0.1rem; padding: 0.45rem 0.6rem 0.5rem; }
.lp-text small { color: var(--muted); font-size: 0.72rem; text-transform: lowercase; }
.lp-text strong { font-size: 0.9rem; line-height: 1.25; }
.lp-text span {
  color: var(--muted); font-size: 0.8rem; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.bubble.has-preview { max-width: min(24rem, 80%); }

/* ---------- Ältere Nachrichten ---------- */
.load-more { display: flex; justify-content: center; padding: 0.6rem 0 0.4rem; }
.load-more button { font-size: 0.85rem; padding: 0.35rem 0.9rem; border-radius: 999px; }

/* ---------- Termine ---------- */
#calendar-btn { position: relative; }
#calendar-btn:not([data-count=""])[data-count]::after {
  content: attr(data-count); position: absolute; top: -2px; right: -2px; min-width: 1.1rem; height: 1.1rem;
  padding: 0 0.3em; border-radius: 0.55rem; background: var(--accent); color: #fff; font-size: 0.68rem; font-weight: 700;
  display: grid; place-items: center;
}
.event { display: grid; gap: 0.5rem; margin-bottom: 1rem; min-width: min(17rem, 68vw); }
.event-head { display: flex; gap: 0.7rem; align-items: flex-start; }
.event-date {
  flex: none; width: 3.1rem; border-radius: 8px; overflow: hidden; text-align: center;
  background: var(--input); display: flex; flex-direction: column; line-height: 1.1;
}
.event-date small {
  background: var(--danger); color: #fff; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; padding: 0.15rem 0;
}
.event-date strong { font-size: 1.35rem; padding: 0.2rem 0 0.25rem; }
.event-title { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.event-title strong { font-size: 1.02rem; overflow-wrap: anywhere; }
.event-title span { color: var(--muted); font-size: 0.8rem; }
.event-desc { margin: 0; font-size: 0.88rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.event-banner { background: rgba(242, 63, 67, 0.15); color: var(--danger); border-radius: 6px; padding: 0.3rem 0.5rem; font-size: 0.82rem; font-weight: 600; }
.event.cancelled .event-title strong { text-decoration: line-through; opacity: 0.7; }
.event-counts {
  display: flex; gap: 0.7rem; align-items: center; background: none; color: inherit; padding: 0.2rem 0; font-size: 0.85rem;
}
.event-who { margin-left: auto; color: var(--accent); font-size: 0.78rem; }
.event-rsvp { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; }
.rsvp {
  background: var(--input); color: var(--text); font-size: 0.8rem; padding: 0.4rem 0.2rem; border: 1px solid transparent; white-space: nowrap;
}
.rsvp.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); font-weight: 600; }
.event-ics { justify-self: start; font-size: 0.8rem; }
.event.past { opacity: 0.85; }
.field-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 0.5rem; }
.field-row label { min-width: 0; }
.field-row input { width: 100%; min-width: 0; }
@media (max-width: 420px) { .field-row { grid-template-columns: 1fr 1fr; } .field-row label:first-child { grid-column: 1 / -1; } }
.calendar-list li { padding: 0; }
.calendar-item {
  display: flex; gap: 0.7rem; align-items: center; width: 100%; text-align: left; background: none; color: inherit; padding: 0.5rem 0.3rem;
}
.calendar-item:hover { background: var(--sidebar-hover); }
.calendar-item .grow { display: flex; flex-direction: column; min-width: 0; }
.calendar-item .grow strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-item small { color: var(--muted); font-size: 0.78rem; }
.calendar-item.cancelled strong { text-decoration: line-through; }
.calendar-status { flex: none; font-size: 0.78rem; color: var(--muted); }
.calendar-list.past { opacity: 0.7; }

/* Erinnerung */
.toast {
  position: fixed; left: 50%; top: 1rem; transform: translateX(-50%); z-index: 50; width: min(28rem, calc(100vw - 2rem));
  display: flex; gap: 0.6rem; align-items: center; padding: 0.7rem 0.8rem; border-radius: 12px;
  background: var(--head); color: var(--text); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45); border-left: 4px solid var(--accent);
}
.toast[hidden] { display: none; }
.toast-icon { font-size: 1.6rem; }
.toast .grow { display: flex; flex-direction: column; min-width: 0; }
.toast small { color: var(--muted); font-size: 0.78rem; }
.toast button.secondary { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

/* ---------- Aussehen: Chat-Hintergründe ---------- */
:root[data-wallpaper="plain"] .messages { background-image: none; }
:root[data-wallpaper="sunset"] .messages { background: linear-gradient(160deg, rgba(255, 140, 90, 0.16), rgba(200, 60, 120, 0.14)), var(--chat-bg); }
:root[data-wallpaper="ocean"] .messages { background: linear-gradient(160deg, rgba(40, 150, 220, 0.16), rgba(20, 60, 140, 0.16)), var(--chat-bg); }
:root[data-wallpaper="forest"] .messages { background: linear-gradient(160deg, rgba(60, 160, 90, 0.16), rgba(20, 90, 60, 0.16)), var(--chat-bg); }
:root[data-wallpaper="lavender"] .messages { background: linear-gradient(160deg, rgba(160, 120, 230, 0.18), rgba(90, 70, 170, 0.14)), var(--chat-bg); }
:root[data-wallpaper="custom"] .messages {
  background: linear-gradient(var(--wallpaper-dim), var(--wallpaper-dim)), var(--wallpaper-image) center / cover no-repeat, var(--chat-bg);
}
:root { --wallpaper-dim: rgba(11, 20, 26, 0.55); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --wallpaper-dim: rgba(239, 234, 226, 0.45); } }
:root[data-theme="light"] { --wallpaper-dim: rgba(239, 234, 226, 0.45); }

.settings-section { display: grid; gap: 0.6rem; margin-bottom: 1.2rem; }
.settings-section h4 { margin: 0.4rem 0 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.3rem; background: var(--input); padding: 0.25rem; border-radius: 10px; }
.segmented button { background: none; color: var(--text); padding: 0.45rem 0.3rem; border-radius: 8px; }
.segmented button.on { background: var(--accent); color: #fff; font-weight: 600; }
.swatches { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.swatch {
  flex: 0 0 2.2rem; min-width: 0; max-width: 2.2rem; position: relative;
  width: 2.2rem; height: 2.2rem; border-radius: 50%; padding: 0; border: 3px solid transparent;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.15); display: grid; place-items: center; color: #fff; font-weight: 700;
}
.swatch.on { border-color: var(--text); }
.swatch.from-community { background: conic-gradient(#00a884, #3b82f6, #8b5cf6, #ec4899, #f97316, #00a884); }
.swatch input[type="color"] { opacity: 0; position: absolute; width: 1px; height: 1px; }
.wallpapers { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.2rem, 1fr)); gap: 0.5rem; }
.wallpaper {
  height: 4.2rem; border-radius: 10px; border: 3px solid transparent; color: var(--text); font-size: 0.75rem;
  display: flex; align-items: flex-end; justify-content: center; padding: 0.25rem; background-color: var(--chat-bg);
  background-size: cover; background-position: center; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.wallpaper.on { border-color: var(--accent); }
.wallpaper.dots { background-image: radial-gradient(var(--chat-pattern) 1.5px, transparent 1.5px); background-size: 12px 12px; }
.wallpaper.sunset { background-image: linear-gradient(160deg, rgba(255, 140, 90, 0.35), rgba(200, 60, 120, 0.3)); }
.wallpaper.ocean { background-image: linear-gradient(160deg, rgba(40, 150, 220, 0.35), rgba(20, 60, 140, 0.35)); }
.wallpaper.forest { background-image: linear-gradient(160deg, rgba(60, 160, 90, 0.35), rgba(20, 90, 60, 0.35)); }
.wallpaper.lavender { background-image: linear-gradient(160deg, rgba(160, 120, 230, 0.38), rgba(90, 70, 170, 0.3)); }
.settings-preview { border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.settings-preview .messages { padding: 0.8rem; min-height: 7.5rem; display: grid; gap: 0.4rem; align-content: end; }
.settings-preview .bubble { max-width: 75%; font-size: 0.9rem; }
.settings-preview .msg.mine { justify-content: flex-end; }

/* Zwei-Faktor */
.twofa-qr { display: grid; place-items: center; padding: 0.6rem; background: #fff; border-radius: 10px; justify-self: center; }
.twofa-qr img { width: 11rem; height: 11rem; image-rendering: pixelated; display: block; }
.secret-key { font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.08em; word-break: break-all; user-select: all; background: var(--input); padding: 0.4rem 0.6rem; border-radius: 6px; font-size: 0.85rem; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.3rem 1rem; font-family: ui-monospace, Consolas, monospace; font-size: 0.95rem; background: var(--input); padding: 0.7rem 0.9rem; border-radius: 8px; user-select: all; }
.status-pill { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.status-pill.on { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.status-pill.off { background: var(--input); color: var(--muted); }
.code-input { font-size: 1.4rem !important; letter-spacing: 0.3em; text-align: center; font-family: ui-monospace, Consolas, monospace; }
.wordfilter textarea { font-family: inherit; }

/* ---------- Markiert, Standort, Geburtstage ---------- */
.meta .star { font-size: 0.7rem; margin-right: 0.15rem; }
.starred-list li { align-items: center; }
.starred-list .search-result { min-width: 0; }
.location { display: grid; gap: 0.4rem; margin-bottom: 1rem; }
.map-link { display: block; border-radius: 8px; overflow: hidden; }
.map { position: relative; overflow: hidden; background: #aad3df; max-width: 100%; }
.map img { position: absolute; width: 256px; height: 256px; max-width: none; }
.map-pin { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -100%); font-size: 1.8rem; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4)); }
.map-credit { position: absolute; right: 0; bottom: 0; background: rgba(255, 255, 255, 0.8); color: #333; font-size: 0.6rem; padding: 0 0.25rem; }
.location-text { display: flex; flex-direction: column; }
.location-text small { color: var(--muted); font-size: 0.75rem; }
.location-links { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; font-size: 0.8rem; }
.location-links a { color: var(--accent); }
.location-preview:empty { display: none; }
.location-preview .map { border-radius: 8px; }
.bubble.has-location { max-width: min(20rem, 80%); }
.profile-birthday { margin: 0.2rem 0; }
.birthday-list li.today { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 8px; }
.birthday-list .grow { display: flex; flex-direction: column; }
.birthday-list small { color: var(--muted); font-size: 0.78rem; }
.lang-switch { margin-top: 1rem; font-size: 0.85rem; opacity: 0.85; }
