/* Familienchat */
:root {
  --brand: #1a56b0;
  --brand-2: #2468cc;
  --accent: #2f7de1;
  --bg: #f0f2f5;
  --panel: #ffffff;
  --panel-2: #f6f7f8;
  --line: #e4e7ea;
  --text: #111b21;
  --muted: #667781;
  --chat-bg: #e7edf4;
  --chat-pattern: rgba(26, 86, 176, .05);
  --in: #ffffff;
  --out: #dbeaff;
  --sys: #fff5c4;
  --tick: #0b63d6;
  --danger: #d9363e;
  --shadow: 0 1px .5px rgba(11, 20, 26, .13);
  --head: #f0f2f5;
  --hover: #f5f6f6;
  --active: #e9edef;
  --badge: #2f7de1;
  --radius: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0b141a;
  --panel: #111b21;
  --panel-2: #1a252c;
  --line: #222d34;
  --text: #e9edef;
  --muted: #8696a0;
  --chat-bg: #0b141a;
  --chat-pattern: rgba(255, 255, 255, .025);
  --in: #202c33;
  --out: #1d4673;
  --sys: #3b3420;
  --head: #202c33;
  --tick: #6cc4ff;
  --hover: #202c33;
  --active: #2a3942;
  --shadow: 0 1px .5px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { overflow: hidden; }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand-2); }
html[data-theme="dark"] a { color: #53bdeb; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.spacer { flex: 1; }
.ic { width: 24px; height: 24px; fill: currentColor; flex: none; }

/* ---------- Boot / Auth */
.boot { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; background: var(--brand); color: #fff; font-weight: 600; gap: 8px; }
.boot img { border-radius: 20px; }
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px calc(24px + var(--safe-b)); background: linear-gradient(160deg, var(--brand) 0 220px, var(--bg) 220px); overflow: auto; height: 100%; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border-radius: 16px; padding: 28px 24px; box-shadow: 0 10px 40px rgba(0,0,0,.15); text-align: center; }
.auth-logo { border-radius: 16px; }
.auth h1 { margin: 8px 0 2px; font-size: 24px; }
.auth-sub { margin: 0 0 20px; color: var(--muted); }
.auth-foot { margin: 20px 0 0; font-size: 12.5px; color: var(--muted); }
.auth form { text-align: left; display: grid; gap: 12px; }
.auth .switch { margin-top: 14px; font-size: 14px; }

.field { display: grid; gap: 4px; }
.field > span { font-size: 13px; color: var(--muted); }
.input, .field input, .field textarea, .field select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); outline: none;
}
.input:focus, .field input:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,125,225,.2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 22px; border: 0; background: var(--brand); color: #fff; font-weight: 600; min-height: 42px; }
.btn:hover { background: var(--brand-2); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 14px; min-height: 32px; font-size: 14px; }
.btn.block { width: 100%; }
.link-btn { background: none; border: 0; color: var(--brand-2); padding: 0; text-decoration: underline; }
.error { color: var(--danger); font-size: 14px; min-height: 1em; }
.notice { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; }
.notice.warn { background: #fff4e0; border-color: #f2c77c; color: #6b4b00; }
html[data-theme="dark"] .notice.warn { background: #3a2f17; border-color: #6b5420; color: #f3d9a0; }

/* ---------- Layout */
.app { display: flex; height: 100%; height: 100dvh; max-width: 1600px; margin: 0 auto; background: var(--panel); position: relative; overflow: hidden; }
@media (min-width: 1440px) { body { background: linear-gradient(var(--brand) 0 127px, var(--bg) 127px); } .app { height: calc(100dvh - 38px); margin-top: 19px; box-shadow: 0 6px 18px rgba(0,0,0,.1); } }
.sidebar { width: 34%; min-width: 320px; max-width: 460px; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--panel); position: relative; }
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--chat-bg); }

.bar { height: 60px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 10px 0 16px; background: var(--head); }
.bar h1, .bar h2 { font-size: 19px; margin: 0; font-weight: 600; }
.side-bar { padding-top: var(--safe-t); height: calc(60px + var(--safe-t)); }
.icon-btn { width: 40px; height: 40px; border: 0; border-radius: 50%; background: none; display: inline-grid; place-items: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: rgba(0,0,0,.06); }
html[data-theme="dark"] .icon-btn:hover { background: rgba(255,255,255,.08); }
.icon-btn.on { color: var(--brand-2); }
.me-btn { border: 0; padding: 0; background: none; border-radius: 50%; }

.searchbox { padding: 7px 12px; border-bottom: 1px solid var(--line); }
.searchbox input { width: 100%; border: 0; border-radius: 8px; background: var(--panel-2); padding: 8px 14px; outline: none; }
#hints:empty { display: none; }
.hint { display: flex; gap: 12px; align-items: center; padding: 12px 16px; background: #e8f1fd; border-bottom: 1px solid var(--line); font-size: 14px; }
html[data-theme="dark"] .hint { background: #132a45; }
.hint .ic { color: var(--brand-2); }
.hint > div { flex: 1; }
.hint b { display: block; }
.net-state { background: #ffe9a8; color: #5c4400; font-size: 13px; text-align: center; padding: 6px; }

/* ---------- Avatare */
.avatar { width: 49px; height: 49px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 18px; overflow: hidden; background: #b9c4ca; user-select: none; position: relative; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 40px; height: 40px; font-size: 15px; }
.avatar.xs { width: 32px; height: 32px; font-size: 13px; }
.avatar.xl { width: 160px; height: 160px; font-size: 56px; }
.avatar .ic { width: 60%; height: 60%; }

/* ---------- Chatliste */
.chat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; padding-bottom: var(--safe-b); }
.chat-item { display: flex; align-items: center; gap: 13px; padding: 0 0 0 13px; cursor: pointer; height: 72px; }
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); }
.chat-item .ci-body { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: center; border-bottom: 1px solid var(--line); padding-right: 15px; gap: 2px; }
.ci-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ci-name { flex: 1; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-time { font-size: 12px; color: var(--muted); flex: none; }
.chat-item.unread .ci-time { color: var(--badge); font-weight: 600; }
.ci-preview { flex: 1; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 3px; min-width: 0; }
.ci-preview > span { overflow: hidden; text-overflow: ellipsis; }
.ci-preview .ic { width: 17px; height: 17px; }
.ci-preview.typing { color: var(--badge); font-weight: 500; }
.badge { background: var(--badge); color: #fff; border-radius: 12px; min-width: 21px; height: 21px; padding: 0 6px; font-size: 12px; font-weight: 600; display: grid; place-items: center; flex: none; }
.ci-muted { color: var(--muted); width: 18px; height: 18px; }
.list-empty { padding: 40px 24px; text-align: center; color: var(--muted); }

/* ---------- Chatansicht */
.chat-empty { flex: 1; display: grid; place-content: center; justify-items: center; text-align: center; padding: 30px; background: var(--panel-2); border-bottom: 6px solid var(--brand); }
.chat-empty img { border-radius: 24px; opacity: .9; }
.chat-empty h2 { font-weight: 300; font-size: 30px; margin: 16px 0 6px; }
.chat-empty p { margin: 2px; color: var(--muted); }
.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat-head { cursor: default; padding-left: 8px; padding-top: var(--safe-t); height: calc(60px + var(--safe-t)); border-left: 1px solid var(--line); }
.chat-head .ch-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 4px 0; }
.ch-titles { min-width: 0; }
.ch-title { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sub.typing { color: var(--badge); }
.back-btn { display: none; }

.messages {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 6% 8px; outline: none;
  background-color: var(--chat-bg);
  background-image: radial-gradient(var(--chat-pattern) 1.5px, transparent 1.6px), radial-gradient(var(--chat-pattern) 1.5px, transparent 1.6px);
  background-size: 28px 28px; background-position: 0 0, 14px 14px;
  overscroll-behavior: contain;
}
.msg-row { display: flex; flex-direction: column; margin-top: 2px; }
.msg-row.first { margin-top: 10px; }
.msg-row.out { align-items: flex-end; }
.msg-row.in { align-items: flex-start; }
.bubble {
  position: relative; max-width: min(65%, 560px); padding: 6px 7px 8px 9px; border-radius: 8px; background: var(--in);
  box-shadow: var(--shadow); word-wrap: break-word; overflow-wrap: anywhere; font-size: 14.6px; line-height: 19px;
}
@media (max-width: 800px) { .bubble { max-width: 85%; } }
.out .bubble { background: var(--out); }
.msg-row.first.in .bubble { border-top-left-radius: 0; }
.msg-row.first.out .bubble { border-top-right-radius: 0; }
.msg-row.first.in .bubble::before, .msg-row.first.out .bubble::before {
  content: ""; position: absolute; top: 0; width: 8px; height: 13px;
}
.msg-row.first.in .bubble::before { left: -8px; background: linear-gradient(to bottom left, var(--in) 50%, transparent 50%); }
.msg-row.first.out .bubble::before { right: -8px; background: linear-gradient(to bottom right, var(--out) 50%, transparent 50%); }
.bubble .sender { font-size: 12.8px; font-weight: 600; margin-bottom: 2px; }
.bubble .text { white-space: pre-wrap; }
.bubble .text code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: rgba(0,0,0,.06); padding: 0 3px; border-radius: 3px; }
.bubble .text.jumbo { font-size: 42px; line-height: 50px; }
.bubble.jumbo-only { background: transparent !important; box-shadow: none; padding: 0; }
.bubble.jumbo-only::before { display: none; }
.bubble .text.faded { color: var(--muted); font-style: italic; display: inline-flex; align-items: center; gap: 4px; }
.bubble .text.faded .ic { width: 16px; height: 16px; }
.meta { float: right; margin: 7px 0 -6px 10px; font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; line-height: 15px; }
.meta .ic { width: 16px; height: 16px; }
.meta .read { color: var(--tick); }
.meta.on-media { position: absolute; right: 8px; bottom: 8px; margin: 0; color: #fff; background: rgba(0,0,0,.35); border-radius: 8px; padding: 1px 6px; float: none; }
.meta.on-media .read { color: #9be3ff; }
.msg-menu-btn { position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: inherit; color: var(--muted); display: none; place-items: center; opacity: .9; }
.msg-menu-btn .ic { width: 20px; height: 20px; }
@media (hover: hover) { .bubble:hover .msg-menu-btn { display: grid; } }
.bubble.highlight { animation: hl 1.4s ease; }
@keyframes hl { 0%, 60% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: var(--shadow); } }

.quote { display: block; border-left: 4px solid var(--accent); background: rgba(0,0,0,.05); border-radius: 6px; padding: 5px 8px; margin: 0 0 5px; font-size: 13px; cursor: pointer; max-height: 70px; overflow: hidden; }
html[data-theme="dark"] .quote { background: rgba(0,0,0,.2); }
.quote b { display: block; font-size: 12.8px; }
.quote span { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.day { align-self: center; margin: 12px auto 6px; background: var(--panel); color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; box-shadow: var(--shadow); text-transform: uppercase; width: fit-content; }
.sys { align-self: center; margin: 8px auto; background: var(--sys); color: var(--text); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; box-shadow: var(--shadow); max-width: 85%; text-align: center; width: fit-content; }
.sys .ic { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.e2e-note { align-self: center; margin: 4px auto 12px; background: var(--sys); font-size: 12.5px; padding: 6px 12px; border-radius: 8px; text-align: center; max-width: 480px; box-shadow: var(--shadow); }
.load-older { display: block; margin: 4px auto 10px; }

.media { position: relative; margin: -3px -4px 4px -6px; border-radius: 6px; overflow: hidden; cursor: pointer; background: rgba(0,0,0,.08); max-width: 330px; }
.media img, .media video { display: block; width: 100%; height: 100%; object-fit: cover; }
.media img.blur { filter: blur(8px); transform: scale(1.05); }
.media .spin { position: absolute; inset: 0; margin: auto; }
.media.only { margin-bottom: -4px; }
.file-box { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.05); border-radius: 6px; padding: 10px; margin: -2px -3px 4px -5px; cursor: pointer; min-width: 220px; }
html[data-theme="dark"] .file-box { background: rgba(0,0,0,.2); }
.file-box .ic { width: 34px; height: 34px; color: var(--accent); }
.file-box .fn { flex: 1; min-width: 0; }
.file-box .fn b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-box .fn small { color: var(--muted); }

.voice { display: flex; align-items: center; gap: 8px; min-width: 230px; padding: 2px 0 0; }
.voice .play { width: 38px; height: 38px; border-radius: 50%; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.voice .play .ic { width: 32px; height: 32px; }
.voice .track { flex: 1; display: grid; gap: 4px; }
.voice .bar-bg { position: relative; height: 4px; border-radius: 2px; background: rgba(0,0,0,.15); cursor: pointer; }
html[data-theme="dark"] .voice .bar-bg { background: rgba(255,255,255,.2); }
.voice .bar-fg { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 2px; width: 0; }
.voice .bar-fg::after { content: ""; position: absolute; right: -6px; top: -4px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.voice .vt { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }
.voice .speed { border: 0; background: rgba(0,0,0,.1); border-radius: 10px; font-size: 11px; padding: 1px 6px; font-weight: 600; }
.voice .avatar { width: 44px; height: 44px; }

.reactions { display: flex; gap: 2px; margin: -6px 8px 4px; z-index: 1; position: relative; }
.reactions button { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 0 6px; font-size: 13px; line-height: 22px; box-shadow: var(--shadow); display: inline-flex; gap: 3px; align-items: center; }
.reactions button.mine { border-color: var(--accent); }
.reactions small { color: var(--muted); font-size: 11px; }

.to-bottom { position: absolute; right: 18px; bottom: 80px; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--panel); box-shadow: 0 1px 4px rgba(0,0,0,.25); color: var(--muted); display: grid; place-items: center; z-index: 3; }
.to-bottom .badge { position: absolute; top: -6px; right: -4px; }

/* ---------- Eingabe */
.composer-wrap { flex: none; background: var(--head); padding-bottom: var(--safe-b); position: relative; }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0 16px; }
.reply-bar .quote { flex: 1; margin: 0; cursor: default; background: var(--panel); }
.edit-bar .quote b { display: flex; align-items: center; gap: 5px; color: var(--accent); }
.edit-bar .quote b .ic { width: 15px; height: 15px; }
.chat-find { display: flex; align-items: center; gap: 6px; padding: 5px 8px 5px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 2; }
.chat-find[hidden] { display: none; }
.chat-find > .ic { width: 18px; height: 18px; color: var(--muted); flex: none; }
.chat-find input { flex: 1; min-width: 0; border: 0; border-radius: 8px; background: var(--panel-2); padding: 7px 12px; outline: none; color: inherit; }
.find-count { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.hit-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-section { padding: 12px 16px 6px; font-size: 13px; font-weight: 600; color: var(--accent); list-style: none; }
.msg-hit .ci-preview mark, .chat-find mark { background: none; color: var(--accent); font-weight: 600; }
.pin-bar { display: flex; align-items: center; gap: 10px; padding: 7px 16px; background: var(--panel); border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13.5px; position: relative; z-index: 2; }
.pin-bar[hidden] { display: none; }
.pin-bar:hover { background: var(--hover); }
.pin-bar > .ic { width: 18px; height: 18px; color: var(--muted); flex: none; transform: rotate(35deg); }
.pin-body { flex: 1; min-width: 0; display: grid; }
.pin-body b { font-size: 12.5px; color: var(--accent); }
.pin-body span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-dots { display: grid; gap: 2px; align-self: stretch; }
.pin-dots span { width: 3px; border-radius: 2px; background: var(--muted); opacity: .35; }
.pin-dots span.on { opacity: 1; background: var(--accent); }
/* Karte */
.map { position: relative; overflow: hidden; background: #dfe6ee; user-select: none; -webkit-user-select: none; }
.map.interactive { touch-action: none; cursor: grab; }
.map.dragging { cursor: grabbing; }
.map-tiles img { position: absolute; left: 0; top: 0; width: 256px; height: 256px; max-width: none; pointer-events: none; }
.map-overlay { position: absolute; inset: 0; pointer-events: none; }
.map-marker { position: absolute; left: 0; top: 0; }
.map-acc { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(47,125,225,.16); border: 1px solid rgba(47,125,225,.55); }
.map-acc[hidden] { display: none; }
.map-pin-inner { position: absolute; left: 0; top: 0; transform: translate(-50%, calc(-100% - 6px)); padding: 3px; background: #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.map-pin-inner::after { content: ''; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); border: 6px solid transparent; border-top-color: #fff; border-bottom: 0; }
.map-attr { position: absolute; right: 0; bottom: 0; font-size: 10px; line-height: 14px; background: rgba(255,255,255,.8); color: #333; padding: 0 4px; border-top-left-radius: 4px; }
/* Standort-Nachricht */
.loc-bubble { padding: 3px !important; }
.loc { cursor: pointer; display: grid; }
.loc .map { border-radius: 8px; }
.loc-info { display: grid; gap: 1px; padding: 6px 6px 2px; font-size: 13.5px; }
.loc-info b { display: flex; align-items: center; gap: 4px; }
.loc-info b .ic { width: 16px; height: 16px; color: var(--accent); }
.loc.live-on .loc-info b .ic { animation: livepulse 1.6s ease-in-out infinite; }
@keyframes livepulse { 50% { opacity: .35; } }
.loc-info span { font-size: 12.5px; color: var(--muted); }
.live-stop { margin: 6px 6px 2px; justify-self: start; }
.loc-bubble .meta { margin-right: 6px; }
.loc-modal .map { border-radius: 10px; width: 100% !important; }
/* Vollbild-Karte */
.map-view { position: fixed; inset: 0; z-index: 60; background: var(--bg, #fff); display: flex; flex-direction: column; }
.map-view .panel-head { flex: none; }
.map-view > .map { flex: 1; }
.mv-title { font-weight: 600; }
.mv-status { font-size: 12.5px; opacity: .85; }
.mv-tools { position: absolute; right: 12px; top: calc(76px + var(--safe-t, 0px)); display: grid; gap: 8px; z-index: 2; }
.mv-tools .icon-btn { background: var(--panel); box-shadow: var(--shadow); border-radius: 50%; }
.mv-bottom { position: absolute; left: 0; right: 0; bottom: calc(18px + var(--safe-b, 0px)); display: flex; justify-content: center; z-index: 2; pointer-events: none; }
.mv-bottom .btn { pointer-events: auto; box-shadow: 0 3px 10px rgba(0,0,0,.25); display: inline-flex; gap: 6px; align-items: center; }
.invite-qr { display: grid; place-items: center; margin: 12px 0 4px; }
.invite-qr svg { border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.18); max-width: 100%; height: auto; }
.poll-bubble { min-width: min(300px, 75vw); }
.poll { display: grid; gap: 6px; padding: 2px 0 4px; }
.poll-q { font-weight: 600; font-size: 15.5px; overflow-wrap: anywhere; }
.poll-sub { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.poll-sub .ic { width: 14px; height: 14px; }
.poll-opt { display: flex; align-items: flex-start; gap: 10px; border: 0; background: none; padding: 6px 0; text-align: left; color: inherit; font: inherit; cursor: pointer; width: 100%; }
.poll-opt:disabled { cursor: default; }
.poll-opt .check.square { border-radius: 5px; }
.poll-main { flex: 1; min-width: 0; display: grid; gap: 5px; }
.poll-row { display: flex; align-items: center; gap: 6px; }
.poll-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.poll-avs { display: flex; }
.poll-avs .avatar { width: 18px; height: 18px; font-size: 9px; margin-left: -5px; box-shadow: 0 0 0 1.5px var(--panel); }
.poll-count { font-size: 13px; color: var(--muted); min-width: 1ch; text-align: right; }
.poll-bar { height: 5px; border-radius: 3px; background: rgba(127,127,127,.2); overflow: hidden; }
.poll-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }
.poll-show { justify-self: center; margin-top: 2px; font-size: 13.5px; }
.poll-edit-opts { display: grid; gap: 6px; }
.poll-multi { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; font-size: 14px; cursor: pointer; }
.poll-result h4 { display: flex; justify-content: space-between; gap: 10px; margin: 10px 0 2px; }
.poll-result h4 small { color: var(--muted); font-weight: normal; }
.fw { display: flex; align-items: center; gap: 4px; font-size: 12.5px; font-style: italic; color: var(--muted); margin: 0 0 3px; }
.fw .ic { width: 15px; height: 15px; }
.meta .edited { font-style: italic; margin-right: 2px; }
.composer { display: flex; align-items: flex-end; gap: 4px; padding: 6px 8px; }
.composer .input-box { flex: 1; display: flex; align-items: flex-end; background: var(--panel); border-radius: 22px; min-height: 44px; padding: 2px 4px; }
.composer textarea { flex: 1; border: 0; outline: none; resize: none; background: none; padding: 10px 6px; max-height: 140px; line-height: 20px; min-height: 40px; font-size: 15px; }
.composer .icon-btn { width: 40px; height: 40px; }
.send-btn { width: 46px !important; height: 46px !important; background: var(--brand) !important; color: #fff !important; }
.send-btn:hover { background: var(--brand-2) !important; }
.readonly-bar { padding: 16px; text-align: center; color: var(--muted); font-size: 14px; }
.rec-bar { display: flex; align-items: center; gap: 12px; padding: 6px 8px 6px 12px; min-height: 58px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.rec-time { font-variant-numeric: tabular-nums; font-size: 17px; }
.rec-bar .icon-btn.del { color: var(--danger); }

.emoji-panel { height: 280px; max-height: 40vh; display: flex; flex-direction: column; border-top: 1px solid var(--line); background: var(--panel); }
.emoji-tabs { display: flex; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; }
.emoji-tabs button { border: 0; background: none; padding: 6px 8px; border-radius: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.emoji-tabs button.on { background: var(--active); color: var(--text); }
.emoji-grid { overflow-y: auto; padding: 6px; display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); }
.emoji-grid button { border: 0; background: none; font-size: 26px; height: 44px; border-radius: 8px; padding: 0; }
.emoji-grid button:hover { background: var(--hover); }

/* ---------- Overlays */
.panel { position: absolute; inset: 0; background: var(--panel); z-index: 20; display: flex; flex-direction: column; animation: slideIn .18s ease-out; }
.panel.right { left: auto; width: min(420px, 100%); border-left: 1px solid var(--line); box-shadow: -4px 0 18px rgba(0,0,0,.08); }
@keyframes slideIn { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
.panel-head { height: calc(60px + var(--safe-t)); padding-top: var(--safe-t); flex: none; display: flex; align-items: center; gap: 12px; padding-left: 8px; padding-right: 8px; background: var(--brand); color: #fff; }
.panel-head .icon-btn { color: #fff; }
.panel-head h2 { font-size: 18px; margin: 0; font-weight: 600; flex: 1; }
.panel-body { flex: 1; overflow-y: auto; padding-bottom: calc(20px + var(--safe-b)); background: var(--panel-2); }
.section { background: var(--panel); padding: 14px 20px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.section h3 { margin: 0 0 10px; font-size: 14px; color: var(--brand-2); font-weight: 600; }
html[data-theme="dark"] .section h3 { color: var(--accent); }
.section .row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.section .row + .row { border-top: 1px solid var(--line); }
.profile-top { display: grid; justify-items: center; gap: 8px; padding: 24px 20px; text-align: center; background: var(--panel); margin-bottom: 10px; }
.profile-top h2 { margin: 6px 0 0; font-size: 22px; font-weight: 500; }
.profile-top .avatar { cursor: pointer; }
.avatar-edit { position: relative; }
.avatar-edit::after { content: "Ändern"; position: absolute; inset: 0; border-radius: 50%; background: rgba(0,0,0,.4); color: #fff; display: grid; place-items: center; font-size: 14px; opacity: 0; transition: .15s; }
.avatar-edit:hover::after { opacity: 1; }
.list-btn { display: flex; align-items: center; gap: 16px; width: 100%; padding: 13px 20px; border: 0; background: var(--panel); text-align: left; font-size: 15.5px; }
.list-btn:hover { background: var(--hover); }
.list-btn .ic { color: var(--muted); }
.list-btn.danger, .list-btn.danger .ic { color: var(--danger); }
.list-btn .sub { display: block; font-size: 13px; color: var(--muted); }
.contact { display: flex; align-items: center; gap: 13px; padding: 9px 16px; cursor: pointer; background: var(--panel); width: 100%; border: 0; text-align: left; }
.contact:hover { background: var(--hover); }
.contact .c-body { flex: 1; min-width: 0; }
.contact .c-name { font-size: 16px; display: flex; gap: 6px; align-items: center; }
.contact .c-sub { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { font-size: 11px; border: 1px solid var(--accent); color: var(--accent); border-radius: 6px; padding: 0 5px; white-space: nowrap; }
.tag.grey { border-color: var(--muted); color: var(--muted); }
.check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); flex: none; display: grid; place-items: center; }
.check.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.check .ic { width: 16px; height: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; background: var(--panel); }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--active); border-radius: 16px; padding: 3px 4px 3px 10px; font-size: 13.5px; }
.chip button { border: 0; background: none; padding: 0; display: grid; color: var(--muted); }
.chip .ic { width: 18px; height: 18px; }
.fab { position: absolute; right: 20px; bottom: calc(20px + var(--safe-b)); width: 56px; height: 56px; border-radius: 16px; border: 0; background: var(--brand); color: #fff; display: grid; place-items: center; box-shadow: 0 3px 10px rgba(0,0,0,.25); z-index: 5; }
.fab:disabled { opacity: .5; }
.safety { font-family: ui-monospace, Menlo, monospace; font-size: 17px; display: grid; grid-template-columns: repeat(4, auto); gap: 6px 14px; justify-content: center; padding: 12px; background: var(--panel-2); border-radius: 8px; margin: 10px 0; letter-spacing: 1px; }
.verified { color: var(--accent); display: inline-flex; gap: 4px; align-items: center; font-size: 14px; }
.verified .ic { width: 18px; height: 18px; }
.invite-link { word-break: break-all; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; background: var(--panel-2); padding: 10px; border-radius: 8px; }

.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--panel); border-radius: 12px; width: min(440px, 100%); max-height: 90vh; overflow: auto; padding: 22px 24px 16px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h3 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
.modal .body { font-size: 15px; color: var(--text); display: grid; gap: 12px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.modal .actions .btn { min-height: 38px; padding: 8px 16px; }
.preview-modal { width: min(560px, 100%); }
.preview-img { max-width: 100%; max-height: 50vh; display: block; margin: 0 auto; border-radius: 8px; }
.preview-thumbs { display: flex; gap: 6px; overflow-x: auto; }
.preview-thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; }

.menu { position: fixed; z-index: 120; background: var(--panel); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); padding: 6px 0; min-width: 200px; animation: fade .1s; }
.menu button.mi { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; background: none; padding: 10px 18px; text-align: left; font-size: 15px; }
.menu button.mi:hover { background: var(--hover); }
.menu button.mi .ic { color: var(--muted); width: 20px; height: 20px; }
.menu button.mi.danger, .menu button.mi.danger .ic { color: var(--danger); }
.menu .react-row { display: flex; gap: 2px; padding: 4px 8px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu .react-row button { border: 0; background: none; font-size: 26px; width: 42px; height: 42px; border-radius: 50%; padding: 0; }
.menu .react-row button:hover, .menu .react-row button.on { background: var(--active); }
.menu-back { position: fixed; inset: 0; z-index: 110; }

.lightbox { position: fixed; inset: 0; z-index: 130; background: rgba(0,0,0,.92); display: flex; flex-direction: column; }
.lightbox .lb-head { display: flex; justify-content: flex-end; gap: 4px; padding: calc(8px + var(--safe-t)) 8px 8px; }
.lightbox .icon-btn { color: #fff; }
.lightbox .lb-body { flex: 1; display: grid; place-items: center; min-height: 0; padding: 8px 8px calc(16px + var(--safe-b)); }
.lightbox img, .lightbox video { max-width: 100%; max-height: 100%; object-fit: contain; }

.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: #323739; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 200; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.spin { width: 28px; height: 28px; border: 3px solid rgba(127,127,127,.3); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.btn .spin { width: 18px; height: 18px; border-width: 2px; border-color: rgba(255,255,255,.4); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mobil */
@media (max-width: 800px) {
  .sidebar { width: 100%; max-width: none; min-width: 0; border-right: 0; }
  .chat { position: absolute; inset: 0; z-index: 10; transform: translateX(100%); transition: transform .22s ease; visibility: hidden; }
  .app.chat-open .chat { transform: none; visibility: visible; }
  .back-btn { display: inline-grid; }
  .chat-head { border-left: 0; padding-left: 2px; }
  .messages { padding: 10px 10px 8px; }
  .chat-empty { display: none; }
  .panel.right { width: 100%; }
}
@media (min-width: 801px) { .fab.mobile-only { display: none; } }
@media (pointer: coarse) { .bubble { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; } }
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- Anrufe */
.call-log { display: flex; align-items: center; gap: 10px; min-width: 200px; cursor: pointer; padding: 2px 0; }
.call-log .cl-ic { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,.06); color: var(--accent); flex: none; }
html[data-theme="dark"] .call-log .cl-ic { background: rgba(255,255,255,.08); }
.call-log .cl-ic .ic { width: 20px; height: 20px; }
.call-log.missed .cl-ic { color: var(--danger); }
.call-log b { display: block; font-weight: 500; }
.call-log small { color: var(--muted); }

body.in-call { overflow: hidden; }
.call { position: fixed; inset: 0; z-index: 140; background: radial-gradient(circle at 50% 30%, #2b4d7d, #0d1b2e 70%); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(40px + var(--safe-t)) 16px calc(28px + var(--safe-b)); animation: fade .2s; }
.call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; opacity: 0; transition: opacity .3s; }
.call.has-remote-video .call-remote { opacity: 1; }
.call-top { position: relative; display: grid; justify-items: center; gap: 8px; text-align: center; z-index: 1; }
.call-name { font-size: 26px; font-weight: 500; }
.call-status { font-size: 16px; opacity: .85; font-variant-numeric: tabular-nums; }
.call-e2e { font-size: 12px; opacity: .65; display: inline-flex; align-items: center; gap: 4px; }
.call-e2e .ic { width: 14px; height: 14px; }
.call.has-remote-video .call-top { justify-items: start; text-align: left; align-self: flex-start; background: linear-gradient(rgba(0,0,0,.45), transparent); margin: calc(-40px - var(--safe-t)) -16px 0; padding: calc(16px + var(--safe-t)) 20px 40px; width: calc(100% + 32px); }
.call.has-remote-video .call-top .avatar { display: none; }
.call.has-remote-video .call-name { font-size: 20px; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.call-local { position: absolute; right: 16px; bottom: calc(130px + var(--safe-b)); width: 110px; aspect-ratio: 3/4; object-fit: cover; border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.4); z-index: 2; background: #000; }
@media (min-width: 801px) { .call-local { width: 220px; aspect-ratio: 4/3; } }
.call-local.mirror { transform: scaleX(-1); }
.call-actions { position: relative; z-index: 2; display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; }
.call-btn { border: 0; background: none; color: #fff; display: grid; justify-items: center; gap: 6px; font-size: 12px; padding: 0; }
.call-btn .ic { width: 62px; height: 62px; padding: 17px; border-radius: 50%; background: rgba(255,255,255,.18); backdrop-filter: blur(6px); }
.call-btn:hover .ic { background: rgba(255,255,255,.28); }
.call-btn.off .ic { background: #fff; color: #1b2b40; }
.call-btn.red .ic { background: #e53935; }
.call-btn.on .ic { background: var(--accent); }
.call-btn.green .ic { background: #2eb85c; }
.call-btn.pulse .ic { animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(46,184,92,.6); } 70% { box-shadow: 0 0 0 18px rgba(46,184,92,0); } 100% { box-shadow: 0 0 0 0 rgba(46,184,92,0); } }
.call .avatar.xl { box-shadow: 0 0 0 8px rgba(255,255,255,.08); }

/* ---------- Gruppenanrufe */
.join-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 18px; background: #2eb85c; color: #fff; font-weight: 600; font-size: 14px; padding: 7px 14px; margin-right: 4px; animation: pulse 1.6s infinite; white-space: nowrap; }
.join-btn .ic { width: 18px; height: 18px; }
.call.gcall { justify-content: flex-start; gap: 12px; padding: calc(14px + var(--safe-t)) 12px calc(22px + var(--safe-b)); }
.gc-head { text-align: center; display: grid; gap: 2px; justify-items: center; }
.gc-head .call-name { font-size: 20px; }
.gc-head .call-status { font-size: 14px; }
.gc-grid { flex: 1; min-height: 0; width: 100%; max-width: 1400px; display: grid; gap: 8px; grid-template-columns: 1fr; grid-auto-rows: 1fr; }
.gc-grid[data-n="2"] { grid-template-columns: 1fr; }
.gc-grid[data-n="3"], .gc-grid[data-n="4"] { grid-template-columns: 1fr 1fr; }
.gc-grid[data-n="5"], .gc-grid[data-n="6"] { grid-template-columns: 1fr 1fr; }
.gc-grid[data-n="7"], .gc-grid[data-n="8"], .gc-grid[data-n="9"] { grid-template-columns: 1fr 1fr 1fr; }
@media (min-width: 801px) {
  .gc-grid[data-n="2"] { grid-template-columns: 1fr 1fr; }
  .gc-grid[data-n="5"], .gc-grid[data-n="6"] { grid-template-columns: 1fr 1fr 1fr; }
}
.tile { position: relative; border-radius: 14px; overflow: hidden; background: rgba(255,255,255,.08); min-height: 0; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
/* Geteilter Bildschirm: vollständig zeigen (nicht beschneiden), bei den anderen groß über die ganze Breite */
.tile.screen video, .call.remote-screen .call-remote, .call-local.screen { object-fit: contain; background: #000; }
.tile.screen:not([data-tile="local"]) { grid-column: 1 / -1; grid-row: span 2; }
.tile.has-video video { opacity: 1; }
.tile.mirror video { transform: scaleX(-1); }
.tile-av { position: absolute; inset: 0; display: grid; place-items: center; }
.tile.has-video .tile-av { display: none; }
.tile-av .avatar.xl { width: min(110px, 40%); height: auto; aspect-ratio: 1; font-size: 40px; }
.tile-name { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.45); border-radius: 8px; padding: 2px 8px; font-size: 13px; }

/* ---------- Chatliste: Archiv, angeheftete Chats, Erwähnungen */
.badge.grey { background: var(--muted); }
.badge.at { background: var(--badge); font-size: 13px; }
.ci-pin { width: 17px; height: 17px; color: var(--muted); flex: none; transform: rotate(35deg); }
.archive-row .ci-name { font-weight: 500; }
.archive-ic { background: transparent !important; color: var(--brand-2); }
.archive-ic .ic { width: 26px; height: 26px; }
.archive-head { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 8px; padding: 8px 16px 10px 6px; border-bottom: 1px solid var(--line); }
.archive-head b { font-size: 16px; }
.archive-head small { grid-column: 2; font-size: 12.5px; }
.ch-timer .ic { width: 15px; height: 15px; margin-left: 5px; vertical-align: -2px; color: var(--muted); }
.radio-list { display: grid; gap: 2px; }
.radio-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; cursor: pointer; font-size: 15px; }
.radio-row input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- Meta-Symbole */
.meta .meta-star, .meta-star { width: 13px !important; height: 13px !important; color: #e5a100; }
.meta .meta-timer { width: 13px; height: 13px; }

/* ---------- Erwähnungen */
.mention { color: var(--brand-2); font-weight: 600; cursor: pointer; }
.mention.me { background: rgba(47, 125, 225, .15); border-radius: 4px; padding: 0 2px; }
.mention-box { position: absolute; left: 8px; right: 8px; bottom: 100%; margin-bottom: 4px; background: var(--panel); border-radius: 10px; box-shadow: 0 4px 18px rgba(0,0,0,.2); padding: 4px 0; z-index: 6; max-height: 260px; overflow: auto; }
.mention-opt { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 8px 14px; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.mention-opt.on, .mention-opt:hover { background: var(--hover); }
.mention-opt span { flex: 1; }

/* ---------- Linkvorschau */
.link-preview { display: flex; flex-direction: column; margin: -3px -4px 6px -6px; border-radius: 6px; overflow: hidden; background: rgba(0,0,0,.05); color: inherit; text-decoration: none; border-left: 3px solid var(--accent); max-width: 330px; }
html[data-theme="dark"] .link-preview { background: rgba(255,255,255,.06); }
.link-preview img { width: 100%; max-height: 170px; object-fit: cover; display: block; }
.lp-body { display: grid; gap: 2px; padding: 6px 9px 7px; font-size: 13px; min-width: 0; }
.lp-body b { font-size: 14px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lp-body span { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lp-body small { color: var(--muted); font-size: 12px; }
.lp-compose { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0 16px; }
.lp-compose .link-preview { flex: 1; margin: 0; flex-direction: row; background: var(--panel); max-width: none; }
.lp-compose .link-preview img { width: 64px; height: 64px; max-height: none; flex: none; }

/* ---------- Album */
.album-bubble { padding: 3px !important; }
.album-bubble .sender, .album-bubble .fw, .album-bubble .quote { margin: 3px 6px; }
.album-bubble > .text { display: block; padding: 4px 6px 0; }
.album-bubble > .meta:not(.on-media) { margin-right: 6px; }
.album { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; width: min(300px, 68vw); border-radius: 7px; overflow: hidden; }
.album.n3 .album-tile:first-child { grid-column: span 2; }
.album-tile { position: relative; aspect-ratio: 1; background: rgba(0,0,0,.1); cursor: pointer; overflow: hidden; }
.album.n3 .album-tile:first-child { aspect-ratio: 2; }
.album-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-tile img.blur { filter: blur(8px); transform: scale(1.05); }
.album-more { position: absolute; inset: 0; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; font-size: 28px; font-weight: 500; }

/* ---------- Galerie */
.lightbox .lb-head { align-items: center; }
.lb-title { flex: 1; color: #fff; display: grid; padding-left: 8px; min-width: 0; }
.lb-title small { opacity: .75; font-size: 12.5px; }
.lb-prev, .lb-next { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.35) !important; width: 46px !important; height: 46px !important; }
.lb-prev { left: 10px; }
.lb-next { right: 10px; }
.lb-next .ic { transform: scaleX(-1); }
.lb-caption { color: #fff; text-align: center; padding: 0 16px calc(14px + var(--safe-b)); white-space: pre-wrap; }
.lightbox .lb-body { position: relative; }

/* ---------- Medienübersicht */
.tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 2; }
.tabs button { flex: 1; border: 0; background: none; padding: 12px 4px; font: inherit; font-size: 14px; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; }
.tabs button.on { color: var(--brand-2); border-bottom-color: var(--brand-2); font-weight: 600; }
.media-month { margin: 14px 12px 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 2px; padding: 0 2px; }
.media-tile { aspect-ratio: 1; border: 0; padding: 0; background: rgba(127,127,127,.15); overflow: hidden; cursor: pointer; display: grid; place-items: center; }
.media-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile img.blur { filter: blur(6px); }
.media-video { display: grid; justify-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px; overflow: hidden; text-align: center; word-break: break-all; }
.media-video .ic { width: 30px; height: 30px; color: var(--text); }
.media-strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; padding: 0 20px 12px; background: var(--panel); }
.media-strip .media-tile { border-radius: 6px; }
.doc-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.doc-row .small { grid-column: 1; }
.doc-row .icon-btn { grid-row: 1 / span 2; grid-column: 2; }
.link-row { padding: 10px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.link-row .link-preview { margin: 0; max-width: none; }
.link-plain { display: flex; gap: 8px; align-items: center; word-break: break-all; color: var(--brand-2); }
.link-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.empty-state { text-align: center; padding: 40px 24px; color: var(--muted); display: grid; justify-items: center; gap: 4px; }
.empty-state > .ic { width: 44px; height: 44px; color: var(--muted); opacity: .6; }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small .ic { width: 18px; height: 18px; }

/* ---------- Termine */
.event { display: grid; gap: 8px; padding: 2px 0 2px; }
.ev-top { display: flex; gap: 12px; align-items: flex-start; }
.ev-date { flex: none; width: 48px; border-radius: 9px; overflow: hidden; text-align: center; background: var(--panel); box-shadow: 0 0 0 1px var(--line); display: grid; }
.ev-date small { background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; text-transform: uppercase; padding: 1px 0; }
.ev-date b { font-size: 21px; line-height: 30px; }
.ev-main { min-width: 0; display: grid; gap: 3px; }
.ev-title { font-weight: 600; font-size: 15.5px; overflow-wrap: anywhere; }
.ev-when, .ev-place { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); text-decoration: none; overflow-wrap: anywhere; }
.ev-place { color: var(--brand-2); }
.ev-when .ic, .ev-place .ic { width: 15px; height: 15px; flex: none; }
.ev-note { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ev-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ev-btn { border: 1px solid var(--line); background: var(--panel); color: var(--brand-2); border-radius: 8px; padding: 7px 4px; font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; }
.ev-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.ev-btn:disabled { opacity: .55; cursor: default; }
.ev-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.ev-foot .link-btn { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.ev-foot .ic { width: 15px; height: 15px; }
.ev-past { font-size: 13px; color: var(--muted); font-style: italic; }
.event.past .ev-date { opacity: .6; }
.ev-times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-modal .field { margin-bottom: 8px; }
.form-modal textarea.input { resize: vertical; font: inherit; }

/* ---------- Listen */
.list-items { display: grid; }
.list-item { display: flex; align-items: center; gap: 2px; border-top: 1px solid rgba(127,127,127,.15); }
.list-check { flex: 1; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 7px 0; text-align: left; color: inherit; font: inherit; cursor: pointer; min-width: 0; }
.list-check:disabled { cursor: default; }
.list-check .check.square { border-radius: 5px; width: 20px; height: 20px; }
.list-text { overflow-wrap: anywhere; min-width: 0; }
.list-item.done .list-text { text-decoration: line-through; color: var(--muted); }
.list-del { opacity: .5; }
.list-del:hover { opacity: 1; }
@media (hover: hover) { .list-del { opacity: 0; } .list-item:hover .list-del { opacity: .7; } }
.list-actions { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 14px; padding-top: 4px; }
.list-actions .link-btn { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.list-actions .ic { width: 17px; height: 17px; }

/* ---------- App-Sperre */
.lock-screen { position: fixed; inset: 0; z-index: 180; background: var(--bg); display: grid; place-items: center; padding: 24px; }
.lock-screen ~ .modal-back { z-index: 190; }
.lock-box { width: min(340px, 100%); display: grid; gap: 14px; justify-items: center; text-align: center; }
.lock-box h2 { display: flex; align-items: center; gap: 8px; font-size: 19px; margin: 0; }
.lock-box h2 .ic { width: 22px; height: 22px; color: var(--brand-2); }
.lock-box img { border-radius: 16px; }
.lock-row { display: flex; gap: 8px; width: 100%; }
.lock-pin { flex: 1; min-width: 0; font-size: 22px; letter-spacing: 6px; text-align: center; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); }
.lock-box .btn.block { display: inline-flex; justify-content: center; gap: 8px; align-items: center; }

/* ================================================================ Paket 3 (v17) */

/* Großschrift: ganze Oberfläche skalieren */
html.scaled .app { zoom: var(--z, 1); height: calc(100dvh / var(--z, 1)); }
html.scaled .modal-back, html.scaled .lightbox, html.scaled .lock-screen, html.scaled .toast { zoom: var(--z, 1); }
html.scaled .menu { font-size: calc(15px * var(--z, 1)); }
html.scaled .menu .mi { padding-top: calc(10px * var(--z, 1)); padding-bottom: calc(10px * var(--z, 1)); }
@media (min-width: 1440px) { html.scaled .app { height: calc((100dvh - 38px) / var(--z, 1)); } }

/* Geburtstage & Kalender */
.hint.bday { background: #fff3e0; }
html[data-theme="dark"] .hint.bday { background: #3a2a14; }
.bday-ic { font-size: 26px; line-height: 1; }
.cal-tools { padding: 10px 16px 0; }
.cal-list { padding: 0 8px 20px; }
.cal-item { display: flex; gap: 12px; align-items: center; width: 100%; border: 0; background: none; text-align: left; padding: 8px; border-radius: 10px; cursor: pointer; color: inherit; font: inherit; }
.cal-item:hover { background: var(--hover); }
.cal-item.declined { opacity: .55; }
.cal-body { display: grid; gap: 1px; min-width: 0; }
.cal-body b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-body small { color: var(--muted); font-size: 12.5px; }
.cal-st.st-y { color: #2e7d32; } .cal-st.st-m { color: #b26a00; } .cal-st.st-n { color: var(--danger); }
.ev-date.today { box-shadow: 0 0 0 2px var(--accent); }

/* Chat-Hintergründe */
.messages[data-wall="sky"] { background: linear-gradient(180deg, #cfe3fb, #eef5ff); }
.messages[data-wall="mint"] { background: linear-gradient(160deg, #d3f2e4, #f1fbf6); }
.messages[data-wall="sand"] { background: linear-gradient(160deg, #f6e7cf, #fdf8ef); }
.messages[data-wall="rose"] { background: linear-gradient(160deg, #f8d9e1, #fff2f5); }
.messages[data-wall="lilac"] { background: linear-gradient(160deg, #e2dcf7, #f6f3ff); }
.messages[data-wall="night"] { background: linear-gradient(180deg, #1c2a44, #2d3f63); }
.messages[data-wall="plain"] { background: var(--chat-bg); }
html[data-theme="dark"] .messages[data-wall="sky"] { background: linear-gradient(180deg, #0f2238, #0b141a); }
html[data-theme="dark"] .messages[data-wall="mint"] { background: linear-gradient(160deg, #0f2a20, #0b141a); }
html[data-theme="dark"] .messages[data-wall="sand"] { background: linear-gradient(160deg, #2c2416, #0b141a); }
html[data-theme="dark"] .messages[data-wall="rose"] { background: linear-gradient(160deg, #2e1820, #0b141a); }
html[data-theme="dark"] .messages[data-wall="lilac"] { background: linear-gradient(160deg, #221c38, #0b141a); }
.messages[data-wall="night"] .day, .messages[data-wall="night"] .e2e-note { opacity: .9; }
.messages[data-wall="img"] { background: var(--chat-bg) var(--wall-img) center / cover no-repeat; background-attachment: local; }
.messages[data-wall="img"] { background-attachment: scroll; }
#chatView { position: relative; }
.wall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.wall-tile { border: 2px solid transparent; background: none; border-radius: 12px; padding: 4px; display: grid; gap: 4px; justify-items: center; cursor: pointer; color: inherit; font: inherit; }
.wall-tile.on { border-color: var(--accent); }
.wall-sw { width: 100%; aspect-ratio: 3/4; border-radius: 8px; display: grid; place-items: center; overflow: hidden; background-color: var(--chat-bg);
  background-image: radial-gradient(var(--chat-pattern) 1.5px, transparent 1.6px); background-size: 10px 10px; box-shadow: inset 0 0 0 1px var(--line); }
.wall-sw[data-wall="sky"] { background: linear-gradient(180deg, #cfe3fb, #eef5ff); }
.wall-sw[data-wall="mint"] { background: linear-gradient(160deg, #d3f2e4, #f1fbf6); }
.wall-sw[data-wall="sand"] { background: linear-gradient(160deg, #f6e7cf, #fdf8ef); }
.wall-sw[data-wall="rose"] { background: linear-gradient(160deg, #f8d9e1, #fff2f5); }
.wall-sw[data-wall="lilac"] { background: linear-gradient(160deg, #e2dcf7, #f6f3ff); }
.wall-sw[data-wall="night"] { background: linear-gradient(180deg, #1c2a44, #2d3f63); }
.wall-sw[data-wall="plain"] { background: var(--chat-bg); }
.wall-sw.img img { width: 100%; height: 100%; object-fit: cover; }
.wall-sw .ic { width: 28px; height: 28px; color: var(--muted); }
.wall-tile small { font-size: 12px; }

/* Videos */
.video-media { background: #000; }
.video-media img { object-fit: cover; }
.video-ph { width: 100%; height: 100%; background: linear-gradient(135deg, #36404a, #1b2228); }
.video-play { position: absolute; inset: 0; margin: auto; width: 52px; height: 52px; border-radius: 50%; background: rgba(0,0,0,.5); display: grid; place-items: center; color: #fff; }
.video-play .ic { width: 30px; height: 30px; }
.video-dur { position: absolute; left: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 3px; background: rgba(0,0,0,.55); color: #fff; font-size: 11.5px; padding: 1px 6px 1px 4px; border-radius: 8px; }
.video-dur .ic { width: 14px; height: 14px; }
.media-tile { position: relative; }
.video-previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 10px; }
.video-prev { position: relative; aspect-ratio: 16/10; border-radius: 8px; overflow: hidden; background: #000; }
.video-prev img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Einmal ansehen */
.vo-box { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 4px; min-width: 200px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.vo-box div { display: grid; }
.vo-box small { color: var(--muted); font-size: 12.5px; }
.vo-box .vo-ic { width: 34px; height: 34px; color: var(--accent); flex: none; }
.vo-box.seen, .vo-box.out { cursor: default; }
.vo-box.seen .vo-ic { color: var(--muted); }
.vo-lb .lb-body img { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; pointer-events: none; }
.vo-toggle { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--line); background: var(--panel); display: grid; place-items: center; color: var(--muted); cursor: pointer; }
.vo-toggle .ic { width: 26px; height: 26px; }
.vo-toggle.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.vo-note { background: var(--hover); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.preview-stage { background: rgba(127,127,127,.12); border-radius: 8px; }
.preview-tools { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.preview-tools .spacer { flex: 1; }
.preview-thumbs { margin: 6px 0 8px; }
.preview-thumbs .pt { border: 2px solid transparent; padding: 0; border-radius: 8px; background: none; cursor: pointer; flex: none; }
.preview-thumbs .pt.on { border-color: var(--accent); }
.preview-thumbs .pt img { display: block; }

/* Foto-Editor */
.editor { position: fixed; inset: 0; z-index: 100; background: #111; color: #fff; display: flex; flex-direction: column; padding: var(--safe-t) 0 var(--safe-b); }
.ed-top { display: flex; align-items: center; gap: 4px; padding: 8px 10px; flex-wrap: wrap; }
.ed-top .spacer { flex: 1; }
.editor .icon-btn { color: #fff; }
.editor .icon-btn.on { background: rgba(255,255,255,.22); }
.editor .icon-btn:disabled { opacity: .35; }
.ed-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px; overflow: hidden; }
.ed-wrap { position: relative; display: inline-block; line-height: 0; max-width: 100%; max-height: 100%; }
.ed-canvas { display: block; max-width: calc(100vw - 16px); max-height: calc(100dvh - 190px); touch-action: none; }
.ed-crop { position: absolute; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); border: 2px solid #fff; touch-action: none; cursor: move; }
.ed-h { position: absolute; width: 26px; height: 26px; border: 4px solid #fff; }
.ed-h[data-h="nw"] { left: -6px; top: -6px; border-right: 0; border-bottom: 0; cursor: nwse-resize; }
.ed-h[data-h="ne"] { right: -6px; top: -6px; border-left: 0; border-bottom: 0; cursor: nesw-resize; }
.ed-h[data-h="sw"] { left: -6px; bottom: -6px; border-right: 0; border-top: 0; cursor: nesw-resize; }
.ed-h[data-h="se"] { right: -6px; bottom: -6px; border-left: 0; border-top: 0; cursor: nwse-resize; }
.ed-wrap { overflow: hidden; }
.ed-hint { text-align: center; font-size: 13px; opacity: .75; padding: 2px 10px; }
.ed-colors { display: flex; justify-content: center; gap: 10px; padding: 10px; }
.ed-color { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); cursor: pointer; padding: 0; }
.ed-color.on { border-color: #fff; transform: scale(1.2); box-shadow: 0 0 0 2px #111, 0 0 0 4px #fff; }
.ed-crop-actions { display: flex; justify-content: center; gap: 10px; padding: 10px; }

/* Kontakt */
.contact-card { display: grid; gap: 4px; min-width: 220px; padding: 2px 0 4px; }
.cc-head { display: flex; align-items: center; gap: 10px; padding-bottom: 6px; border-bottom: 1px solid rgba(127,127,127,.25); margin-bottom: 2px; }
.cc-av { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 17px; flex: none; }
.cc-line { display: flex; align-items: center; gap: 8px; padding: 3px 0; text-decoration: none; overflow-wrap: anywhere; }
.cc-line .ic { width: 18px; height: 18px; flex: none; }
.cc-note { font-size: 13px; color: var(--muted); }
.cc-save { justify-self: start; margin-top: 4px; }
.form-grid { display: grid; gap: 8px; }

/* Später senden */
.sched-bar { display: flex; justify-content: center; padding: 4px 8px 0; background: transparent; }
.sched-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 16px; padding: 5px 12px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); font: inherit; font-size: 13px; cursor: pointer; }
.sched-btn .ic { width: 16px; height: 16px; color: var(--accent); }
.sched-btn .sched-chev { transform: rotate(180deg); color: var(--muted); }
.sched-row { padding: 12px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.sched-when { display: flex; align-items: center; gap: 6px; color: var(--accent); font-size: 13px; font-weight: 600; }
.sched-when .ic { width: 16px; height: 16px; }
.sched-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.sched-actions { display: flex; gap: 8px; justify-content: flex-end; }
.qchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; }
.qchip { border: 1px solid var(--line); background: var(--panel-2); border-radius: 14px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; color: inherit; }

/* Sprachaufnahme */
.send-btn { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.rec-dot.paused { animation: none; opacity: .4; }
.rec-bar .spacer { flex: 1; }
.rec-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-bar.hold .del, .rec-bar.hold .rec-pause, .rec-bar.hold .rec-stop, .rec-bar.hold .send-btn { display: none; }
.rec-stop .stop-sq { width: 14px; height: 14px; border-radius: 3px; background: var(--danger); display: block; }
.rec-bar.preview { gap: 8px; }
.rec-track { flex: 1; min-width: 0; padding: 0; }
.rec-track .track { width: 100%; }
@media (max-width: 420px) { .rec-bar .rec-hint { display: none; } }

/* Auswahl */
.messages.selecting .msg-row[data-id] { cursor: pointer; }
.messages.selecting .msg-row[data-id] * { pointer-events: none; }
.msg-row.selected { background: rgba(47,125,225,.18); box-shadow: 0 0 0 100vmax rgba(47,125,225,.18); clip-path: inset(-2px -100vmax); }
.chat-head.selecting, #chatHead.selecting { gap: 6px; }
.sel-count { font-size: 17px; font-weight: 500; margin-left: 4px; }
#chatHead .spacer { flex: 1; }

/* Wischen zum Antworten */
.msg-row { position: relative; }
.swipe-ic { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 50%; background: var(--panel); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--muted); opacity: 0; pointer-events: none; }
.swipe-ic.ready { color: var(--accent); }
.swipe-ic .ic { width: 18px; height: 18px; }

/* Speicherplatz (Verwaltung) */
.st-total { margin-bottom: 8px; }
.st-total b { font-size: 20px; }
.st-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--hover); margin-bottom: 8px; }
.st-bar span { display: block; height: 100%; }
.st-files { background: var(--accent); } .st-db { background: #43a047; } .st-av { background: #fb8c00; }
.st-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 14px; }
.st-row > span:not(.st-dot) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-row small { flex: none; }
.st-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.st-convs { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
/* Sprachnachricht passt sich schmalen Blasen an (Großschrift, kleine Handys) */
.bubble .voice { min-width: 0; width: 230px; max-width: 100%; }
.voice .track { min-width: 50px; }
html.scaled .bubble .voice .avatar { display: none; }
.rec-track { width: auto; }
.hint.hint-warn { background: #fdecec; }
html[data-theme="dark"] .hint.hint-warn { background: #3a1d1d; }
.hint.hint-warn .ic { color: var(--danger); }
