/* ================= Farben ================= */
:root {
  --bg: #0f1014; --side: #16171c; --panel: #1c1d23; --panel-2: #24262e; --panel-3: #2d2f39;
  --chat-bg: #111217; --line: #2a2c35; --text: #e9eaf0; --muted: #8b8fa0; --faint: #5d6070;
  --accent: #6c7cff; --accent-2: #8a5cff; --accent-text: #fff; --accent-soft: rgba(108, 124, 255, .16);
  --own: linear-gradient(135deg, #5f6ff5, #7b5cf0); --own-text: #fff; --own-meta: rgba(255, 255, 255, .72);
  --other: #22242c; --other-text: #e9eaf0; --mention: rgba(250, 190, 60, .14);
  --danger: #ff5d6e; --ok: #35c46a; --idle: #f0b232; --dnd: #f04444; --off: #6b6f7e;
  --name-l: 70%; --shadow: 0 10px 34px rgba(0, 0, 0, .5); --radius: 18px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef0f5; --side: #ffffff; --panel: #ffffff; --panel-2: #f1f2f6; --panel-3: #e6e8ef;
    --chat-bg: #e9ecf3; --line: #e1e3ea; --text: #16181f; --muted: #6b7080; --faint: #a0a4b2;
    --accent: #5865f2; --accent-2: #7a4cf0; --accent-soft: rgba(88, 101, 242, .12);
    --own: linear-gradient(135deg, #5865f2, #7a52ee); --other: #ffffff; --other-text: #16181f; --mention: rgba(250, 180, 40, .18);
    --danger: #e0374a; --name-l: 40%; --shadow: 0 10px 30px rgba(20, 25, 40, .14);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eef0f5; --side: #ffffff; --panel: #ffffff; --panel-2: #f1f2f6; --panel-3: #e6e8ef;
  --chat-bg: #e9ecf3; --line: #e1e3ea; --text: #16181f; --muted: #6b7080; --faint: #a0a4b2;
  --accent: #5865f2; --accent-2: #7a4cf0; --accent-soft: rgba(88, 101, 242, .12);
  --own: linear-gradient(135deg, #5865f2, #7a52ee); --other: #ffffff; --other-text: #16181f; --mention: rgba(250, 180, 40, .18);
  --danger: #e0374a; --name-l: 40%; --shadow: 0 10px 30px rgba(20, 25, 40, .14);
  color-scheme: light;
}

/* ================= Grundlagen ================= */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 7px 13px; transition: background .15s, border-color .15s, transform .1s; }
button:hover { background: var(--panel-3); }
button:active { transform: scale(.97); }
button:disabled { opacity: .6; cursor: default; }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0; color: var(--accent-text); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 4px; }
.icon-btn { border: 0; background: transparent; border-radius: 10px; padding: 7px 9px; line-height: 1; font-size: 17px; position: relative; color: var(--muted); }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.small { font-size: 13px; padding: 5px 7px; }
input, select, textarea { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 12px; }
.error { color: var(--danger); min-height: 1.2em; margin: 6px 0; font-size: 14px; }
.grow { flex: 1; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
.pill { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; }

/* ================= Avatare ================= */
.av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; user-select: none; overflow: hidden; cursor: pointer; font-size: 16px; }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av.sm { width: 26px; height: 26px; font-size: 12px; }
.av.xl { width: 84px; height: 84px; font-size: 34px; }
.av.group { background: linear-gradient(135deg, var(--accent), var(--accent-2)); font-size: 19px; cursor: default; }
.av.group.xl { font-size: 38px; }
.av-wrap { position: relative; display: inline-flex; flex: none; }
.av-wrap.xl .dot { width: 20px; height: 20px; border-width: 4px; right: 2px; bottom: 2px; }
.dot { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; border: 3px solid var(--side); background: var(--off); }
.dot.online { background: var(--ok); }
.dot.idle { background: var(--idle); }
.dot.dnd { background: var(--dnd); }
.dot.offline { background: var(--off); }
.status-menu .dot, .dot.inline { position: static; display: inline-block; border: 0; width: 10px; height: 10px; margin-right: 10px; }

/* ================= Einladung / Sperrseite ================= */
body.center { display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 20% 0%, rgba(108, 124, 255, .18), transparent 60%), radial-gradient(900px 500px at 100% 100%, rgba(138, 92, 255, .15), transparent 60%), var(--bg); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 32px; width: 100%; max-width: 420px; box-shadow: var(--shadow); text-align: center; }
.card h1 { margin: 8px 0; font-size: 23px; }
.card form { text-align: left; margin-top: 18px; }
.card label { display: block; font-weight: 600; margin-bottom: 6px; }
.card input { width: 100%; padding: 12px 13px; }
.card button.primary { width: 100%; padding: 12px; margin-top: 6px; }
.logo { font-size: 44px; }

/* ================= App-Raster ================= */
body.app { display: grid; grid-template-columns: 320px minmax(0, 1fr) 280px; height: 100dvh; overflow: hidden; }
body.app.hide-info { grid-template-columns: 320px minmax(0, 1fr); }
body.app.hide-info .info { display: none; }

/* ---- Links ---- */
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; position: relative; }
.side-head { display: flex; align-items: center; gap: 4px; padding: 14px 12px 8px 18px; }
.brand { font-size: 21px; flex: 1; letter-spacing: -.01em; }
.search { padding: 4px 12px 10px; }
.search input { width: 100%; border-radius: 12px; padding: 9px 12px 9px 34px; background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238b8fa0' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E") no-repeat 11px center; border-color: transparent; }
.conv-list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; }
.conv { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: transparent; border-radius: 14px; padding: 9px 10px; margin-bottom: 2px; }
.conv:hover { background: var(--panel-2); }
.conv.active { background: var(--accent-soft); }
.conv.active .conv-name { color: var(--text); }
.conv .av { width: 48px; height: 48px; font-size: 19px; }
.conv .dot { border-color: var(--side); }
.conv:hover .dot { border-color: var(--panel-2); }
.conv-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-top, .conv-bottom { display: flex; align-items: center; gap: 8px; }
.conv-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 12px; color: var(--faint); }
.conv.unread .conv-time { color: var(--accent); }
.conv-prev { flex: 1; min-width: 0; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-who { color: var(--text); opacity: .85; }
.conv.unread .conv-prev { color: var(--text); }
.typing-txt { color: var(--accent) !important; font-style: italic; }

.me-panel { display: flex; align-items: center; gap: 2px; padding: 10px; margin: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; position: relative; }
.me-card { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 4px 6px; border-radius: 10px; text-align: left; }
.me-card:hover { background: var(--panel-2); }
.me-card .av { width: 36px; height: 36px; }
.me-card .dot { border-color: var(--panel); }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-status { font-size: 12px; color: var(--muted); }
.me-panel .status-menu { left: 0; right: 0; bottom: calc(100% + 6px); top: auto; position: absolute; }

/* ---- Mitte ---- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; background: var(--chat-bg); }
.ch-head { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--side); border-bottom: 1px solid var(--line); min-height: 62px; }
.ch-who { display: flex; align-items: center; gap: 12px; border: 0; background: transparent; padding: 4px 8px; border-radius: 12px; min-width: 0; text-align: left; }
.ch-who:hover { background: var(--panel-2); }
.ch-who .dot { border-color: var(--side); }
.ch-title { display: flex; flex-direction: column; min-width: 0; }
.ch-title strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-only { display: none; }
.back { font-size: 30px; padding: 0 10px 4px; }
.back .pill { position: absolute; top: 4px; right: -4px; font-size: 11px; min-width: 18px; height: 18px; }
.conn { background: var(--danger); color: #fff; text-align: center; font-size: 13px; padding: 4px; }

.pin-bar { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: var(--side); padding: 7px 16px; }
.pin-bar:hover { background: var(--panel); }
.pin-line { width: 3px; align-self: stretch; border-radius: 3px; background: var(--accent); }
.pin-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pin-title { color: var(--accent); font-weight: 600; font-size: 13px; }
.pin-text { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 10px 0 6px;
  background-image: radial-gradient(circle at 1px 1px, rgba(127, 127, 160, .09) 1px, transparent 0); background-size: 22px 22px; }
.messages { max-width: 900px; margin: 0 auto; padding: 0 14px; }
.load-older { text-align: center; padding: 6px; }
.loading { text-align: center; padding: 40px; }
.empty { text-align: center; padding: 60px 20px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.empty .av { cursor: default; }
.empty h2 { margin: 12px 0 0; }
.empty-ic { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-size: 38px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.day { display: flex; justify-content: center; margin: 14px 0 8px; position: sticky; top: 4px; z-index: 3; pointer-events: none; }
.day span { background: color-mix(in srgb, var(--panel) 85%, transparent); backdrop-filter: blur(6px); color: var(--muted); font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 12px; box-shadow: 0 1px 4px rgba(0, 0, 0, .15); }
.unread-div { display: flex; justify-content: center; margin: 10px 0; }
.unread-div span { background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; padding: 4px 14px; border-radius: 12px; }

/* Sprechblasen */
.msg { position: relative; display: flex; align-items: flex-end; gap: 8px; padding: 1px 0; transition: transform .15s; }
.msg.first { margin-top: 8px; }
.msg.own { flex-direction: row-reverse; }
.msg.dm .av-slot { display: none; }
.msg.own .av-slot { display: none; }
.av-slot { width: 36px; flex: none; }
.av-slot .av { width: 36px; height: 36px; font-size: 14px; }
.bubble { position: relative; max-width: min(560px, 78%); background: var(--other); color: var(--other-text); padding: 7px 11px 6px; border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0, 0, 0, .18); min-width: 0; }
.msg.own .bubble { background: var(--own); color: var(--own-text); }
.msg:not(.own).first .bubble { border-top-left-radius: var(--radius); }
.msg:not(.own):not(.last) .bubble { border-bottom-left-radius: 6px; }
.msg:not(.own):not(.first) .bubble { border-top-left-radius: 6px; }
.msg:not(.own).last .bubble { border-bottom-left-radius: 4px; }
.msg.own:not(.last) .bubble { border-bottom-right-radius: 6px; }
.msg.own:not(.first) .bubble { border-top-right-radius: 6px; }
.msg.own.last .bubble { border-bottom-right-radius: 4px; }
.msg.mentioned .bubble { box-shadow: 0 0 0 2px #f0b232 inset, 0 1px 2px rgba(0, 0, 0, .18); }
.msg.deleted .bubble { background: transparent; border: 1px dashed var(--line); box-shadow: none; color: var(--muted); font-style: italic; }
.msg.flash .bubble { animation: flash 1.6s; }
@keyframes flash { 0%, 50% { box-shadow: 0 0 0 3px var(--accent); } }
.msg.menu-open .bubble { filter: brightness(1.1); }
.name { display: block; border: 0; background: none; padding: 0; font-weight: 700; font-size: 13.5px; margin-bottom: 1px; }
.name:hover { text-decoration: underline; background: none; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.big .bubble { background: transparent !important; box-shadow: none; padding: 0 4px; }
.msg.big .text { font-size: 44px; line-height: 1.15; }
.msg.big .meta { float: none; display: flex; width: fit-content; margin: 2px 0 0 auto; top: 0; background: var(--panel); color: var(--muted); padding: 1px 7px; border-radius: 10px; font-size: 11px; line-height: 1.6; }
.text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.msg:not(.own) .text a { color: var(--accent); }
.text code { background: rgba(127, 127, 160, .2); border-radius: 5px; padding: 1px 5px; font: 13px ui-monospace, Consolas, monospace; }
.mention { font-weight: 700; }
.msg:not(.own) .mention { color: var(--accent); }
.meta { float: right; display: inline-flex; align-items: center; gap: 4px; margin: 6px 0 -4px 12px; font-size: 11.5px; color: var(--muted); white-space: nowrap; user-select: none; position: relative; top: 2px; }
.msg.own .meta { color: var(--own-meta); }
.meta.over { position: absolute; right: 10px; bottom: 8px; top: auto; float: none; margin: 0; background: rgba(0, 0, 0, .5); color: #fff !important; padding: 1px 7px; border-radius: 10px; }
.ticks { letter-spacing: -3px; margin-right: 2px; }
.ticks.read { color: #9ef0ff; }
:root[data-theme="light"] .msg:not(.own) .ticks.read { color: var(--accent); }
.edited { font-style: italic; }
.quote { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--q, var(--accent)); background: rgba(127, 127, 160, .14); border-radius: 8px; padding: 4px 9px; margin: 2px 0 5px; font-size: 13px; }
.msg.own .quote { background: rgba(255, 255, 255, .16); border-left-color: #fff; }
.quote:hover { filter: brightness(1.1); }
.quote-name { display: block; font-weight: 700; color: var(--q, var(--accent)); }
.msg.own .quote-name { color: #fff; }
.quote-text { display: block; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media { display: block; max-width: 100%; height: auto; border-radius: 12px; margin: 2px 0 4px; cursor: zoom-in; background: rgba(127, 127, 160, .15); object-fit: cover; }
.bubble.media-only { padding: 3px; }
.bubble.media-only .media { margin: 0; border-radius: 15px; }
.bubble.has-media { max-width: min(372px, 82%); }
.file-card { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; padding: 6px 4px; min-width: 200px; }
.file-ic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: rgba(127, 127, 160, .22); flex: none; }
.msg.own .file-ic { background: rgba(255, 255, 255, .22); }
.file-meta { display: flex; flex-direction: column; min-width: 0; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 12px; opacity: .75; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; clear: both; }
.react { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 14px; font-size: 13px; border: 1px solid transparent; background: rgba(127, 127, 160, .18); }
.msg.own .react { background: rgba(255, 255, 255, .18); color: #fff; }
.react.mine { border-color: var(--accent); background: var(--accent-soft); }
.msg.own .react.mine { border-color: #fff; background: rgba(255, 255, 255, .32); }
.r-n { font-weight: 700; font-size: 12px; }
.tools { display: none; align-self: center; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 2px; z-index: 4; }
.tools button { border: 0; background: transparent; padding: 4px 7px; border-radius: 8px; font-size: 15px; }
.tools button:hover { background: var(--panel-2); }
@media (hover: hover) { .msg:hover .tools { display: flex; } }
@media (hover: none) { .msg { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; } }
.msg.swiping { transition: none; }
.msg.swiping::after { content: "↩"; position: absolute; right: -36px; top: 50%; transform: translateY(-50%); font-size: 20px; color: var(--muted); }
.msg.swipe-ok::after { color: var(--accent); }

.to-bottom { position: absolute; right: 18px; bottom: 96px; width: 46px; height: 46px; border-radius: 50%; padding: 0; box-shadow: var(--shadow); background: var(--panel); border: 1px solid var(--line); z-index: 6; font-size: 22px; line-height: 1; }
.to-bottom .pill { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); }
.typing { min-height: 20px; font-size: 12.5px; padding: 0 22px; color: var(--muted); display: flex; align-items: center; gap: 8px; max-width: 900px; margin: 0 auto; width: 100%; }
.dots { width: 22px; height: 6px; background: radial-gradient(circle, var(--muted) 2.5px, transparent 3px) 0 0 / 8px 6px repeat-x; animation: dots 1s infinite steps(3); }
@keyframes dots { to { background-position: 8px 0; } }

/* Eingabe */
.composer { padding: 0 14px 14px; position: relative; max-width: 900px; margin: 0 auto; width: 100%; }
.ctx { display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 16px 16px 0 0; padding: 7px 8px 7px 14px; border-bottom: 1px solid var(--line); }
.ctx-icon { color: var(--accent); font-size: 18px; }
.ctx.edit .ctx-icon { color: var(--idle); }
.ctx-body { flex: 1; min-width: 0; font-size: 13px; border-left: 3px solid var(--accent); padding-left: 9px; }
.ctx.edit .ctx-body { border-left-color: var(--idle); }
.ctx-title { font-weight: 700; color: var(--accent); }
.ctx.edit .ctx-title { color: var(--idle); }
.ctx-text { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-bar { display: flex; gap: 8px; overflow-x: auto; background: var(--panel); padding: 8px; border-bottom: 1px solid var(--line); border-radius: 16px 16px 0 0; }
.ctx:not([hidden]) + .attach-bar { border-radius: 0; }
.att { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border-radius: 12px; padding: 6px; min-width: 210px; max-width: 280px; }
.att.err { outline: 1px solid var(--danger); }
.att img, .att-ic { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; display: grid; place-items: center; font-size: 22px; background: var(--panel-3); }
.att-meta { flex: 1; min-width: 0; font-size: 13px; }
.att-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-sub { color: var(--muted); font-size: 12px; }
.att.err .att-sub { color: var(--danger); }
.att-prog { height: 4px; background: var(--panel-3); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.att-prog i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.input-row { display: flex; gap: 4px; align-items: flex-end; background: var(--panel); border-radius: 18px; padding: 6px; box-shadow: 0 2px 10px rgba(0, 0, 0, .12); }
.ctx:not([hidden]) ~ .input-row, .attach-bar:not([hidden]) ~ .input-row { border-top-left-radius: 0; border-top-right-radius: 0; }
.input-row textarea { flex: 1; border: 0; resize: none; max-height: 200px; padding: 9px 6px; background: transparent; line-height: 1.4; }
.input-row textarea:focus { outline: none; }
.input-row .icon-btn { font-size: 20px; padding: 8px; }
.send { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: 0; border-radius: 50%; width: 42px; height: 42px; padding: 0 0 0 3px; font-size: 18px; flex: none; }
.send:hover { filter: brightness(1.1); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.drop-zone { position: absolute; inset: 12px; z-index: 20; border: 3px dashed var(--accent); border-radius: 22px; background: color-mix(in srgb, var(--chat-bg) 85%, transparent); display: grid; place-items: center; font-size: 22px; font-weight: 700; color: var(--accent); pointer-events: none; }

/* ---- Rechts ---- */
.info { background: var(--side); border-left: 1px solid var(--line); overflow-y: auto; padding: 10px 10px 16px; }
.info.is-profile { padding: 0; }
.m-head { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 8px 6px; }
.m-list { list-style: none; margin: 0; padding: 0; }
.member { display: flex; gap: 11px; align-items: center; padding: 6px 8px; border-radius: 10px; cursor: pointer; }
.member:hover { background: var(--panel-2); }
.member:hover .dot { border-color: var(--panel-2); }
.member .av { width: 34px; height: 34px; font-size: 14px; }
.member.off .av { opacity: .45; }
.member.off .m-name { color: var(--muted); }
.m-text { min-width: 0; }
.m-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.profile-block { position: relative; }
.pc-banner { height: 96px; }
.pc-head { margin: -44px 0 0 16px; }
.pc-head .av { border: 6px solid var(--side); width: 96px; height: 96px; cursor: default; }
.pc-head .dot { right: 6px; bottom: 6px; width: 22px; height: 22px; border: 4px solid var(--side); }
.pc-body { padding: 8px 18px 18px; }
.pc-name { font-size: 20px; font-weight: 800; }
.pc-status { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.pc-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 14px 0 3px; }
.pc-bio { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.pc-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.pc-actions button { flex: 1; }

/* ================= Popups ================= */
.pop { position: fixed; z-index: 40; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.ctx-menu { padding: 6px; min-width: 230px; }
.ctx-reacts { display: flex; gap: 2px; padding: 2px 2px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.ctx-reacts button { border: 0; background: transparent; font-size: 20px; padding: 4px; border-radius: 10px; }
.ctx-reacts button:hover { background: var(--panel-2); transform: scale(1.15); }
.ctx-reacts .more { font-size: 16px; color: var(--muted); }
.ctx-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 10px; border-radius: 9px; }
.ctx-item:hover { background: var(--panel-2); }
.ctx-item .ci { width: 18px; text-align: center; }
.ctx-item.danger { color: var(--danger); }
.emoji-panel { width: 332px; max-width: calc(100vw - 16px); padding: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 280px; overflow-y: auto; }
.emoji-grid button { border: 0; background: transparent; font-size: 22px; padding: 4px 0; border-radius: 8px; }
.emoji-grid button:hover { background: var(--panel-2); }
.profile-card { width: 320px; max-width: calc(100vw - 16px); overflow: hidden; }
.profile-card .pc-head .av, .profile-card .pc-head .dot { border-color: var(--panel); }
.status-menu { padding: 6px; }
.status-menu button { display: flex; align-items: center; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 10px; border-radius: 9px; }
.status-menu button:hover { background: var(--panel-2); }
.status-menu small { display: block; color: var(--muted); font-size: 12px; }
.status-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.mention-box { position: absolute; left: 14px; right: 14px; bottom: calc(100% - 6px); padding: 6px; max-width: 360px; }
.pop-head { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 4px 8px 6px; }
.mention-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 6px 8px; border-radius: 9px; text-align: left; }
.mention-item.sel, .mention-item:hover { background: var(--accent-soft); }
.people-pop { width: 300px; padding: 8px; }
.people-pop input { width: 100%; margin-bottom: 6px; }
.people-list { max-height: 340px; overflow-y: auto; }
.person { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 7px 8px; border-radius: 10px; text-align: left; }
.person:hover { background: var(--panel-2); }
.person .av { width: 38px; height: 38px; }
.person .dot { border-color: var(--panel); }
.p-text { display: flex; flex-direction: column; min-width: 0; }
.p-name { font-weight: 600; }
.p-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 22px; z-index: 60; box-shadow: var(--shadow); max-width: calc(100% - 32px); font-weight: 600; font-size: 14px; }
.banner { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 65; display: flex; align-items: center; gap: 12px; width: min(420px, calc(100% - 24px)); text-align: left; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 16px; padding: 10px 14px; box-shadow: var(--shadow); }
.banner:hover { background: var(--panel-2); }
.banner .av { width: 40px; height: 40px; }
.bn-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bn-title { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bn-msg { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bn-go { font-size: 24px; color: var(--muted); }
.banner.bn-in { animation: bnIn .25s ease-out; }
.banner.bn-out { animation: bnOut .25s ease-in forwards; }
@keyframes bnIn { from { transform: translate(-50%, -140%); opacity: 0; } }
@keyframes bnOut { to { transform: translate(-50%, -140%); opacity: 0; } }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(5, 6, 10, .92); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; gap: 12px; }
.lightbox img { max-width: 100%; max-height: calc(100dvh - 90px); border-radius: 10px; object-fit: contain; }
.lb-bar { display: flex; gap: 10px; }
.lb-btn { background: rgba(255, 255, 255, .14); color: #fff; border: 0; border-radius: 12px; padding: 9px 16px; text-decoration: none; font-weight: 600; }
.lb-btn:hover { background: rgba(255, 255, 255, .24); }
.scrim { display: none; }

/* ================= Dialoge ================= */
.dlg { border: 1px solid var(--line); border-radius: 22px; background: var(--panel); color: var(--text); width: min(680px, calc(100% - 24px)); max-height: calc(100dvh - 40px); padding: 22px; box-shadow: var(--shadow); }
.dlg::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(3px); }
.dlg h2 { font-size: 20px; margin: 0; }
.dlg h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.invite-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 14px; }
.invite-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.invite-form .grow { min-width: 160px; }
.new-link { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.new-link input { flex: 1; min-width: 200px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.rows li .grow { min-width: 0; }
.rows li.inactive { opacity: .55; }
.profile-edit { display: flex; gap: 22px; flex-wrap: wrap; }
.pe-avatar { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 120px; }
.pe-avatar .av { cursor: default; }
.pe-fields { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 10px; }
.pe-fields label, .field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 600; }
.pe-fields input, .pe-fields textarea, .pe-fields select { color: var(--text); font-weight: 400; }
.pe-fields textarea { resize: vertical; }
.pe-fields .primary { align-self: flex-start; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; }
.set-row span { font-size: 14px; }
.switch { appearance: none; width: 42px; height: 24px; border-radius: 12px; background: var(--panel-3); position: relative; cursor: pointer; border: 0; padding: 0; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .2s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 21px; }

/* ================= Handy ================= */
@media (max-width: 1150px) {
  body.app { grid-template-columns: 290px minmax(0, 1fr) 250px; }
}
@media (max-width: 900px) {
  body.app, body.app.hide-info { grid-template-columns: 1fr; }
  .mobile-only { display: inline-flex; }
  .side { border-right: 0; }
  .main { display: none; }
  body.in-chat .side { display: none; }
  body.in-chat .main { display: flex; }
  .info, body.app.hide-info .info { display: block; position: fixed; right: 0; top: 0; bottom: 0; width: min(320px, 88vw); z-index: 30; transform: translateX(100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.show-info .info { transform: none; }
  body.show-info .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 25; }
  .bubble { max-width: 84%; }
  .messages { padding: 0 8px; }
  .composer { padding: 0 8px 8px; }
  .to-bottom { bottom: 86px; right: 12px; }
  .ch-head { padding: 6px 8px; min-height: 56px; }
  .ch-who { padding: 2px 4px; gap: 10px; }
  .ch-who .av { width: 38px; height: 38px; }
}
