/* Hearth: one stylesheet, system fonts, no external resources. */

:root {
  --rail: #121317;
  --side: #1a1b20;
  --main: #222329;
  --elev: #2b2d34;
  --elev-2: #33353d;
  --input: #2c2e35;
  --hover: rgba(255, 255, 255, 0.05);
  --active: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e9e9ee;
  --text-2: #b4b6c2;
  --muted: #8d909e;
  --faint: #656877;
  --accent: #e8803a;
  --accent-hover: #f08f4b;
  --accent-text: #ffffff;
  --accent-soft: rgba(232, 128, 58, 0.16);
  --link: #6fb0f5;
  --danger: #ef5a5f;
  --danger-soft: rgba(239, 90, 95, 0.14);
  --success: #3dbb7d;
  --warning: #e7a83a;
  --mention: rgba(231, 168, 58, 0.09);
  --mention-bar: #e7a83a;
  --online: #3dbb7d;
  --idle: #e7a83a;
  --dnd: #ef5a5f;
  --offline: #7d808d;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, Menlo, monospace;
  color-scheme: dark;
}

[data-theme="light"] {
  --rail: #e3e4e8;
  --side: #f1f2f4;
  --main: #ffffff;
  --elev: #ffffff;
  --elev-2: #f3f4f6;
  --input: #ebecef;
  --hover: rgba(0, 0, 0, 0.04);
  --active: rgba(0, 0, 0, 0.08);
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);
  --text: #1d1f24;
  --text-2: #3d404a;
  --muted: #646875;
  --faint: #8d909c;
  --accent: #d96d24;
  --accent-hover: #c45f1b;
  --accent-soft: rgba(217, 109, 36, 0.12);
  --link: #1f6fc4;
  --danger: #d63c42;
  --danger-soft: rgba(214, 60, 66, 0.1);
  --success: #23955c;
  --mention: rgba(231, 168, 58, 0.14);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--main);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 20px; }
h3 { font-size: 16px; margin-bottom: 8px; }
p { margin: 0 0 10px; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--elev-2); padding: 1px 5px; border-radius: 4px; }
pre { margin: 6px 0; padding: 10px 12px; background: var(--rail); border: 1px solid var(--border); border-radius: 6px; overflow-x: auto; max-width: 100%; }
pre code { background: none; padding: 0; font-size: 13px; line-height: 1.5; white-space: pre; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.icon { flex: none; display: block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 12px 16px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; margin: 10px 0; }
.row.wrap { flex-wrap: wrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.notice { background: var(--accent-soft); border-radius: var(--radius); padding: 10px 12px; color: var(--text); }

/* ---------- controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 16px; border-radius: 6px;
  background: var(--elev-2); color: var(--text); font-weight: 500; white-space: nowrap;
  border: 1px solid var(--border);
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--active); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.success { background: var(--success); border-color: transparent; color: #fff; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.large { min-height: 44px; padding: 0 24px; font-size: 16px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }
.link-btn { color: var(--link); padding: 0; }
.link-btn:hover { text-decoration: underline; }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 6px;
  color: var(--muted); flex: none;
}
.icon-btn:hover { color: var(--text); background: var(--hover); }
.icon-btn.on { color: var(--text); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.tiny { width: 22px; height: 22px; }
.icon-btn.round { border-radius: 50%; background: var(--elev-2); width: 36px; height: 36px; }
.icon-btn.round.success:hover { color: var(--success); }
.icon-btn.round.danger { color: var(--muted); }
.icon-btn.round.danger:hover { color: var(--danger); }

.input {
  width: 100%; min-height: 38px; padding: 8px 10px; border-radius: 6px;
  background: var(--input); border: 1px solid var(--border); color: var(--text); outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; }
select.input { appearance: auto; }
.field { display: block; margin: 0 0 14px; }
.field-label { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); margin: 0 0 6px; }
.field-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 5px; }
.field-hint.warn { color: var(--danger); font-weight: 600; }
.form-error { background: var(--danger-soft); color: var(--danger); border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; font-size: 14px; }

.toggle-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.toggle-text { flex: 1; display: flex; flex-direction: column; }
.switch {
  appearance: none; width: 40px; height: 24px; border-radius: 12px; background: var(--faint); position: relative; flex: none; cursor: pointer; transition: background 0.15s;
}
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch:checked { background: var(--success); }
.switch:checked::after { transform: translateX(16px); }
.check-row { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; cursor: pointer; }

.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; flex: none;
}
.role-pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; margin-left: 6px; background: var(--elev-2); color: var(--text-2); vertical-align: 1px; }
.role-pill.owner { background: rgba(231, 168, 58, 0.18); color: var(--warning); }
.role-pill.admin { background: var(--accent-soft); color: var(--accent); }
.role-pill.friend { background: rgba(61, 187, 125, 0.15); color: var(--success); }
.role-icon { display: inline-flex; margin-left: 4px; }
.role-icon.owner { color: var(--warning); }
.role-icon.admin { color: var(--accent); }
.live-badge { background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 5px; border-radius: 4px; flex: none; }

.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 24px; }
.loading.top { padding: 16px; }
.boot-loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--main); z-index: 100; }

/* ---------- avatars and status ---------- */

.avatar { position: relative; flex: none; border-radius: 50%; }
.avatar img, .avatar-face { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: grid; place-items: center; color: #fff; font-weight: 600; user-select: none; }
.group-avatar { display: grid; place-items: center; background: var(--accent); color: #fff; }
.status-dot {
  position: absolute; right: -2px; bottom: -2px; width: 34%; height: 34%; min-width: 10px; min-height: 10px; max-width: 16px; max-height: 16px;
  border-radius: 50%; border: 3px solid var(--side); background: var(--offline);
}
.status-dot.online { background: var(--online); }
.status-dot.idle { background: var(--idle); }
.status-dot.dnd { background: var(--dnd); }
.status-dot.offline { background: var(--offline); }
.status-dot.inline { position: static; display: inline-block; width: 10px; height: 10px; min-width: 0; min-height: 0; border: 0; margin-right: 2px; }
.speaking > .avatar, .voice-user.speaking .avatar, .me-avatar.speaking .avatar { box-shadow: 0 0 0 2px var(--success); }

/* ---------- auth ---------- */

.auth { min-height: 100%; height: 100dvh; display: grid; place-items: center; padding: 20px; overflow: auto; background: var(--rail); }
.auth-card { width: 100%; max-width: 420px; background: var(--main); border-radius: 12px; padding: 32px 28px; box-shadow: var(--shadow); text-align: center; }
.auth-card h1 { font-size: 24px; margin: 12px 0 4px; }
.auth-logo { width: 56px; height: 56px; }
.auth-form { text-align: left; margin-top: 20px; }
.auth-switch { margin-top: 14px; font-size: 14px; }

/* ---------- layout ---------- */

.app { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; height: 100vh; height: 100dvh; }
.nav-wrap { display: flex; min-height: 0; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--main); }
.members { width: 248px; background: var(--side); border-left: 1px solid var(--border); display: none; flex-direction: column; min-height: 0; }
.app.has-members .members { display: flex; }
.scrim { display: none; }
.conn-banner { position: fixed; top: 0; left: 50%; transform: translateX(-50%); background: var(--warning); color: #1d1f24; font-weight: 600; font-size: 13px; padding: 4px 14px; border-radius: 0 0 8px 8px; z-index: 60; }

/* rail */
.rail { width: 72px; background: var(--rail); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0; overflow-y: auto; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail-item { position: relative; width: 72px; display: flex; justify-content: center; }
.rail-btn {
  width: 48px; height: 48px; border-radius: 50%; background: var(--side); color: var(--text); display: grid; place-items: center; overflow: hidden;
  transition: border-radius 0.15s, background 0.15s;
}
.rail-btn img { width: 100%; height: 100%; object-fit: cover; }
.rail-item.home .rail-btn { background: transparent; }
.rail-item:hover .rail-btn, .rail-item.active .rail-btn { border-radius: 16px; }
.rail-item:hover .rail-btn { background: var(--accent); color: #fff; }
.rail-item.home:hover .rail-btn { background: transparent; }
.rail-item.active:not(.home) .rail-btn { background: var(--accent); color: #fff; }
.rail-item.add .rail-btn { color: var(--success); }
.rail-item.add:hover .rail-btn { background: var(--success); color: #fff; }
.rail-pill { position: absolute; left: 0; top: 50%; width: 4px; height: 0; background: var(--text); border-radius: 0 4px 4px 0; transform: translateY(-50%); transition: height 0.15s; }
.rail-item.unread .rail-pill { height: 8px; }
.rail-item:hover .rail-pill { height: 20px; }
.rail-item.active .rail-pill { height: 40px; }
.rail-item .badge { position: absolute; right: 10px; bottom: -2px; border: 3px solid var(--rail); height: 22px; border-radius: 11px; }
.rail-sep { width: 32px; height: 2px; background: var(--border-strong); border-radius: 1px; flex: none; }
.guild-initials { font-weight: 600; font-size: 15px; }

/* sidebar */
.sidebar { width: 248px; background: var(--side); display: flex; flex-direction: column; min-height: 0; }
.side-header { height: 52px; flex: none; display: flex; align-items: center; padding: 0 10px; border-bottom: 1px solid var(--border); }
.side-title { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 6px; height: 36px; padding: 0 8px; border-radius: 6px; font-weight: 600; font-size: 15px; min-width: 0; }
.side-title:hover { background: var(--hover); }
.side-search { flex: 1; height: 30px; border-radius: 6px; background: var(--rail); color: var(--muted); font-size: 13px; text-align: left; padding: 0 10px; }
.side-body { flex: 1; overflow-y: auto; padding: 8px 8px 12px; min-height: 0; }
.category { display: flex; align-items: center; gap: 4px; margin: 16px 0 4px; padding-right: 4px; }
.category:first-child { margin-top: 4px; }
.category-toggle, .category.static > span { flex: 1; display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); min-width: 0; padding: 2px 4px; }
.category-toggle:hover { color: var(--text); }
.category.static { padding-left: 8px; }
.channel {
  display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 4px 8px; border-radius: 6px; color: var(--muted); margin: 1px 0; position: relative;
}
.channel:hover { background: var(--hover); color: var(--text-2); text-decoration: none; }
.channel.active { background: var(--active); color: var(--text); }
.channel.unread { color: var(--text); font-weight: 600; }
.channel.unread::before { content: ""; position: absolute; left: -8px; width: 4px; height: 8px; border-radius: 0 4px 4px 0; background: var(--text); }
.channel-gear { opacity: 0; }
.channel:hover .channel-gear, .channel.active .channel-gear { opacity: 1; }
.channel.dm { min-height: 44px; }
.dm-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.dm-name { color: inherit; }
.dm-sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.dm-close { opacity: 0; }
.channel.dm:hover .dm-close { opacity: 1; }
.in-call { color: var(--success); }
.friends-link { min-height: 42px; font-weight: 500; }
.voice-users { padding: 2px 0 6px 30px; }
.voice-user { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 6px; font-size: 14px; color: var(--muted); cursor: pointer; }
.voice-user:hover { background: var(--hover); color: var(--text); }
.voice-user .icon { color: var(--muted); }

.voice-panel { flex: none; border-top: 1px solid var(--border); padding: 8px 10px; background: var(--side); }
.vp-row { display: flex; align-items: center; gap: 6px; }
.vp-info { flex: 1; min-width: 0; text-align: left; display: flex; flex-direction: column; padding: 2px 4px; border-radius: 6px; }
.vp-info:hover { background: var(--hover); }
.vp-status { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; }
.vp-status.ok { color: var(--success); }
.vp-status.wait { color: var(--warning); }
.vp-where { font-size: 12px; color: var(--muted); }
.vp-row .icon-btn { color: var(--danger); }
.vp-actions { display: flex; gap: 6px; margin-top: 6px; }
.vp-actions .icon-btn { flex: 1; background: var(--elev-2); height: 32px; color: var(--text-2); }
.vp-actions .icon-btn.on { background: var(--accent-soft); color: var(--accent); }

.user-panel { flex: none; display: flex; align-items: center; gap: 2px; padding: 8px; background: var(--rail); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.me-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 6px; text-align: left; }
.me-btn:hover { background: var(--hover); }
.me-btn .status-dot { border-color: var(--rail); }
.me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.me-name { font-weight: 600; font-size: 14px; }
.me-sub { font-size: 12px; color: var(--muted); }
.me-avatar { display: block; border-radius: 50%; }

/* main header */
.main-header { height: 52px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--border); min-width: 0; }
.header-left { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.header-icon { color: var(--muted); display: flex; }
.header-title { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-title.clickable { cursor: pointer; }
.header-title.clickable:hover { text-decoration: underline; }
.header-divider { width: 1px; height: 22px; background: var(--border-strong); margin: 0 4px; flex: none; }
.header-topic { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.header-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.header-btn.on { color: var(--text); }
.nav-toggle { display: none; margin-left: -8px; }
.search-box { display: flex; align-items: center; gap: 6px; background: var(--rail); border-radius: 6px; padding: 0 8px; height: 30px; margin-left: 6px; color: var(--muted); }
.search-input { width: 140px; border: 0; background: transparent; outline: none; font-size: 13px; transition: width 0.2s; }
.search-box:focus-within .search-input { width: 220px; }
.e2e-badge { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; color: var(--success); background: rgba(61, 187, 125, 0.12); flex: none; }
.e2e-badge:hover { background: rgba(61, 187, 125, 0.2); }
.e2e-notice { display: flex; align-items: center; gap: 8px; padding: 6px 16px; font-size: 13px; border-bottom: 1px solid var(--border); flex: none; }
.e2e-notice span { flex: 1; min-width: 0; }
.e2e-notice.warn { background: rgba(231, 168, 58, 0.12); color: var(--text); }
.e2e-notice.warn .icon { color: var(--warning); }
.e2e-notice.info { background: var(--elev-2); color: var(--muted); }
.enc-error { display: flex; align-items: center; gap: 6px; color: var(--muted); font-style: italic; font-size: 14px; }
.att-image.loading { min-width: 160px; min-height: 100px; }
.att-image.loading img { opacity: 0; }
.recovery-code, .transfer-code { font-family: var(--mono); font-size: 18px; font-weight: 600; letter-spacing: 0.05em; text-align: center; padding: 14px; margin: 12px 0; border-radius: 8px; background: var(--elev-2); user-select: all; word-break: break-all; }
.transfer-code { font-size: 26px; letter-spacing: 0.15em; }
.transfer-wait { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.safety-code { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 12px; padding: 14px; margin: 12px 0; border-radius: 8px; background: var(--elev-2); font-family: var(--mono); font-size: 16px; text-align: center; }
.retention-notice { display: flex; align-items: center; gap: 6px; padding: 6px 16px; font-size: 13px; color: var(--muted); background: var(--elev-2); border-bottom: 1px solid var(--border); flex: none; }
.tabs { display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tab { padding: 4px 10px; border-radius: 6px; color: var(--muted); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tab:hover { background: var(--hover); color: var(--text); }
.tab.active { background: var(--active); color: var(--text); }
.tab.add-friend { background: var(--success); color: #fff; }
.tab.add-friend.active { background: transparent; color: var(--success); }

/* ---------- chat ---------- */

.chat { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroller { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.msg-list { padding: 8px 0 16px; min-height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.intro { padding: 16px 16px 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.intro h2 { font-size: 26px; }
.intro-icon { width: 68px; height: 68px; border-radius: 50%; background: var(--elev-2); display: grid; place-items: center; color: var(--text); }
.day-divider, .new-divider { display: flex; align-items: center; margin: 14px 16px 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.day-divider::before, .day-divider::after, .new-divider::before, .new-divider::after { content: ""; flex: 1; height: 1px; background: var(--border-strong); }
.day-divider span { padding: 0 8px; }
.new-divider { color: var(--danger); margin: 8px 16px; }
.new-divider::before, .new-divider::after { background: var(--danger); }
.new-divider span { padding: 0 8px; }

.msg { position: relative; display: grid; grid-template-columns: 56px minmax(0, 1fr); padding: 2px 48px 2px 16px; }
.msg.start { margin-top: 14px; }
.msg:hover { background: var(--hover); }
.msg.mentioned { background: var(--mention); box-shadow: inset 2px 0 0 var(--mention-bar); }
.msg.flash { animation: flash 2s ease-out; }
@keyframes flash { 0%, 30% { background: var(--accent-soft); } 100% { background: transparent; } }
.msg.pending { opacity: 0.6; }
.msg.failed { opacity: 1; }
.msg.blocked .msg-body { font-size: 14px; padding: 2px 0; }
.msg-gutter { display: flex; justify-content: flex-start; }
.msg-avatar { border-radius: 50%; height: 40px; margin-top: 2px; }
.msg-hover-time { visibility: hidden; font-size: 11px; color: var(--faint); line-height: 22px; width: 44px; text-align: right; padding-right: 10px; }
.msg:hover .msg-hover-time { visibility: visible; }
.msg-head { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.msg-author { font-weight: 600; color: var(--text); font-size: 15px; }
.msg-author:hover { text-decoration: underline; }
.msg-time { font-size: 12px; color: var(--faint); white-space: nowrap; }
.msg-body { min-width: 0; }
.msg-content { color: var(--text); overflow-wrap: anywhere; word-break: break-word; }
.msg-content blockquote { margin: 2px 0; padding: 0 0 0 10px; border-left: 4px solid var(--border-strong); }
.msg-content .jumbo { font-size: 44px; line-height: 1.2; }
.edited { font-size: 11px; color: var(--faint); margin-left: 4px; }
.mention { background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 0 2px; font-weight: 500; cursor: pointer; }
.mention.me { background: rgba(231, 168, 58, 0.25); color: var(--warning); }
.spoiler { background: var(--text); color: transparent; border-radius: 4px; cursor: pointer; transition: background 0.1s; }
.spoiler.revealed { background: var(--elev-2); color: inherit; cursor: auto; }
.spoiler.revealed * { visibility: visible; }
.spoiler:not(.revealed) * { visibility: hidden; }
.reply-ref { display: flex; align-items: center; gap: 6px; grid-column: 1 / -1; padding-left: 20px; font-size: 13px; color: var(--muted); cursor: pointer; min-width: 0; margin-bottom: 2px; }
.reply-ref.missing { cursor: default; font-style: italic; }
.reply-spine { width: 30px; height: 10px; margin-top: 8px; border-left: 2px solid var(--border-strong); border-top: 2px solid var(--border-strong); border-top-left-radius: 6px; flex: none; }
.reply-name { font-weight: 600; color: var(--text-2); flex: none; }
.reply-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-ref:hover .reply-text { color: var(--text); }

.msg-actions {
  position: absolute; right: 16px; top: -16px; display: none; align-items: center; gap: 0; padding: 2px;
  background: var(--elev); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); z-index: 2;
}
.msg:hover .msg-actions { display: flex; }
.msg-actions .icon-btn { width: 30px; height: 30px; }
.quick-react { font-size: 17px; }

.attachments { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 4px; max-width: 100%; }
.att-image { border-radius: 8px; overflow: hidden; max-width: min(420px, 100%); display: block; background: var(--elev-2); }
.att-image img { display: block; max-width: 100%; height: auto; max-height: 320px; object-fit: contain; }
.att-video { max-width: min(480px, 100%); max-height: 360px; border-radius: 8px; background: #000; }
.att-file { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; background: var(--elev); border: 1px solid var(--border); width: min(420px, 100%); }
.att-file audio { grid-column: 1 / -1; width: 100%; height: 36px; }
.att-icon { color: var(--accent); }
.att-meta { min-width: 0; }
.att-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.att-size { font-size: 12px; color: var(--muted); }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 8px; border-radius: 8px; background: var(--elev-2); border: 1px solid transparent; font-size: 14px; }
.reaction:hover { border-color: var(--border-strong); }
.reaction.me { background: var(--accent-soft); border-color: var(--accent); }
.reaction-count { font-size: 13px; font-weight: 600; color: var(--text-2); }
.reaction.me .reaction-count { color: var(--accent); }
.reaction.add { color: var(--muted); opacity: 0; }
.msg:hover .reaction.add { opacity: 1; }

.edit-wrap { margin: 4px 0; }
.edit-box { width: 100%; resize: none; background: var(--input); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; outline: none; color: var(--text); max-height: 320px; }
.edit-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.ghost-error { color: var(--danger); font-size: 13px; }

.jump-bar { position: absolute; left: 16px; right: 16px; bottom: 6px; display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 500; box-shadow: var(--shadow); z-index: 3; }
.jump-cta { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }

.composer-wrap { position: relative; padding: 0 16px; flex: none; }
.composer { background: var(--input); border-radius: 10px; }
.composer-row { display: flex; align-items: flex-end; gap: 2px; padding: 4px 6px; }
.composer-input {
  flex: 1; min-height: 44px; max-height: 320px; padding: 11px 6px; resize: none; border: 0; outline: none; background: transparent; color: var(--text); line-height: 1.4;
}
.composer-input:disabled { cursor: not-allowed; }
.composer-btn { width: 40px; height: 40px; margin-bottom: 2px; }
.send-btn { display: none; color: var(--accent); }
.reply-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 14px; margin-bottom: -6px; padding-bottom: 12px; background: var(--elev-2); border-radius: 10px 10px 0 0; font-size: 13px; color: var(--muted); }
.reply-bar strong { color: var(--text); }
.pending-files { display: flex; gap: 10px; padding: 12px 12px 4px; overflow-x: auto; }
.file-chip { position: relative; flex: none; width: 150px; padding: 8px; border-radius: 8px; background: var(--elev); border: 1px solid var(--border); }
.file-chip.error { border-color: var(--danger); }
.chip-thumb { width: 100%; height: 90px; border-radius: 6px; object-fit: cover; background: var(--elev-2); display: grid; place-items: center; color: var(--accent); }
.chip-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 6px; }
.chip-size, .chip-note { font-size: 11px; color: var(--muted); }
.file-chip.error .chip-note { color: var(--danger); }
.chip-bar { height: 4px; border-radius: 2px; background: var(--elev-2); margin-top: 4px; overflow: hidden; }
.chip-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.chip-remove { position: absolute; top: 2px; right: 2px; background: var(--elev); border-radius: 50%; width: 24px; height: 24px; color: var(--danger); }
.typing { height: 24px; padding: 2px 18px 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex: none; padding-bottom: max(2px, env(safe-area-inset-bottom)); box-sizing: content-box; }
.typing strong { color: var(--text-2); }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }
.drop-hint { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; z-index: 20; pointer-events: none; }
.drop-card { background: var(--accent); color: #fff; border-radius: 16px; padding: 28px 40px; display: flex; flex-direction: column; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; }

.autocomplete { position: absolute; left: 16px; right: 16px; bottom: calc(100% + 6px); background: var(--elev); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; z-index: 10; }
.auto-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: 6px; text-align: left; }
.auto-item.active, .auto-item:hover { background: var(--active); }
.auto-label { font-weight: 500; }
.auto-sub { color: var(--muted); font-size: 13px; margin-left: auto; }

.call-bar { flex: none; background: var(--rail); padding: 12px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--border); }
.call-stage { height: clamp(160px, 32vh, 340px); }
.call-faces { height: 100%; display: flex; align-items: center; justify-content: center; gap: 18px; }
.call-status { text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- side panel and members ---------- */

.panel-head { height: 52px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.panel-body { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }
.members-group { font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); padding: 14px 8px 4px; }
.members-group:first-child { padding-top: 6px; }
.member { display: flex; align-items: center; gap: 10px; width: 100%; padding: 5px 8px; border-radius: 6px; text-align: left; }
.member:hover { background: var(--hover); }
.member.offline { opacity: 0.45; }
.member.offline:hover { opacity: 1; }
.member-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.member-name { display: flex; align-items: center; font-weight: 500; min-width: 0; }
.member-sub { font-size: 12px; color: var(--muted); }
.search-results { display: flex; flex-direction: column; gap: 8px; }
.preview { background: var(--main); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; position: relative; }
.preview-head { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 4px; flex-wrap: wrap; }
.preview-body { font-size: 14px; overflow-wrap: anywhere; max-height: 140px; overflow: hidden; }
.preview-jump { position: absolute; right: 8px; top: 6px; opacity: 0; }
.preview:hover .preview-jump, .preview:focus-within .preview-jump { opacity: 1; }
.empty-small { color: var(--muted); padding: 16px; text-align: center; font-size: 14px; }

/* ---------- friends ---------- */

.friends-body { flex: 1; overflow-y: auto; padding: 8px 20px 20px; min-height: 0; }
.friend-list { max-width: 900px; }
.friend-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-top: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.friend-row:hover { background: var(--hover); }
.friend-name { font-weight: 600; }
.friend-actions { display: flex; gap: 8px; }
.add-friend-form { max-width: 640px; padding: 12px 0; }
.add-friend-form h2 { margin-bottom: 6px; }
.copy-row { display: flex; gap: 8px; margin: 10px 0 16px; }
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 20px; gap: 8px; }
.empty-icon { width: 80px; height: 80px; border-radius: 50%; background: var(--elev-2); display: grid; place-items: center; color: var(--muted); margin-bottom: 6px; }

/* ---------- voice ---------- */

.voice-view { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--rail); }
.stage { flex: 1; min-height: 0; padding: 12px; display: flex; }
.stage > * { flex: 1; min-height: 0; }
.stage-join { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; }
.stage-join-icon { width: 76px; height: 76px; border-radius: 50%; background: var(--elev-2); display: grid; place-items: center; }
.stage-faces { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 4px 0 8px; }
.stage-grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 10px; height: 100%; }
.stage-focus { display: flex; flex-direction: column; gap: 10px; height: 100%; }
.focus-main { flex: 1; min-height: 0; display: flex; }
.focus-main > .tile { flex: 1; }
.focus-strip { height: 120px; flex: none; display: flex; gap: 10px; overflow-x: auto; }
.focus-strip > .tile { width: 200px; flex: none; }
.focus-strip:empty { display: none; }
.tile {
  position: relative; background: var(--elev-2); border-radius: 10px; overflow: hidden; display: grid; place-items: center; min-height: 0; cursor: pointer;
  box-shadow: inset 0 0 0 2px transparent; transition: box-shadow 0.12s;
}
.tile.speaking { box-shadow: inset 0 0 0 3px var(--success); }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile.user video { object-fit: cover; }
.tile video.mirror { transform: scaleX(-1); }
.tile:fullscreen video { object-fit: contain; }
/* Shrinks to fit, but never grows past the video's real pixel size (--vw/--vh, set in voiceui.js). */
.tile.screen.actual-size { background: #000; }
.tile.screen.actual-size video {
  margin: auto; width: auto; height: auto;
  max-width: min(100%, var(--vw, 100%)); max-height: min(100%, var(--vh, 100%));
}
.tile-label { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 13px; font-weight: 500; }
.tile-flag { display: flex; color: var(--danger); }
.tile-full, .tile-fit { position: absolute; top: 6px; right: 6px; background: rgba(0, 0, 0, 0.55); color: #fff; opacity: 0; }
.tile-fit { right: 44px; }
.tile-mode {
  position: absolute; top: 6px; left: 6px; padding: 4px 10px; border: 0; border-radius: 6px; cursor: pointer;
  background: rgba(0, 0, 0, 0.55); color: #fff; font: inherit; font-size: 12px; font-weight: 600; opacity: 0;
}
.tile-mode:hover { background: rgba(0, 0, 0, 0.75); }
.tile:hover .tile-full, .tile:focus-within .tile-full, .tile:hover .tile-fit, .tile:focus-within .tile-fit,
.tile:hover .tile-mode, .tile:focus-within .tile-mode { opacity: 1; }
.tile-wait { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.tile-conn { position: absolute; top: 8px; left: 8px; right: 8px; text-align: center; font-size: 12px; background: rgba(0, 0, 0, 0.6); color: #fff; border-radius: 6px; padding: 3px 6px; }
.stage, .call-stage { position: relative; }
.call-info {
  position: absolute; top: 10px; right: 10px; z-index: 5; width: min(300px, calc(100% - 20px)); max-height: calc(100% - 20px); overflow-y: auto;
  background: var(--elev); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 12px; font-size: 13px;
  display: flex; flex-direction: column; gap: 6px; cursor: default;
}
.info-head { display: flex; align-items: center; justify-content: space-between; }
.info-row { display: flex; align-items: center; gap: 10px; }
.info-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-meter { width: 110px; height: 8px; border-radius: 4px; background: var(--elev-2); overflow: hidden; flex: none; }
.info-meter-fill { display: block; height: 100%; background: var(--success); transition: width 0.15s; }
.info-note { color: var(--muted); font-size: 12px; }
.info-warn { color: var(--danger); font-size: 12px; font-weight: 600; }
.info-ok { color: var(--success); font-size: 12px; font-weight: 600; }
.info-peer { border-top: 1px solid var(--border); padding-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.stage-controls { flex: none; display: flex; justify-content: center; gap: 10px; padding: 10px 12px 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.ctl { width: 52px; height: 52px; border-radius: 50%; background: var(--elev-2); color: var(--text); display: grid; place-items: center; transition: background 0.12s; }
.ctl:hover { background: var(--active); }
.ctl.on { background: var(--text); color: var(--main); }
.ctl.danger { background: var(--danger-soft); color: var(--danger); }
.ctl.hangup { background: var(--danger); color: #fff; width: 64px; border-radius: 26px; }

/* ---------- popovers, menus, modals, toasts ---------- */

.popover { position: fixed; z-index: 80; background: var(--elev); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow: auto; }
.menu { min-width: 200px; padding: 6px; display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: 6px; text-align: left; font-size: 14px; color: var(--text-2); }
.menu-item:hover, .menu-item:focus-visible { background: var(--accent); color: #fff; outline: none; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger); color: #fff; }
.menu-item.checked .menu-label::after { content: " ✓"; }
.menu-label { flex: 1; }
.menu-hint { font-size: 12px; opacity: 0.7; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.menu-title { padding: 6px 10px 8px; font-weight: 600; }
.menu-quick { display: flex; justify-content: space-between; padding: 2px 4px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-slider { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 13px; }
.menu-slider input { flex: 1; }

.profile-pop { width: 300px; overflow: hidden; }
.profile-banner { height: 64px; }
.profile-avatar { margin: -40px 0 0 16px; width: max-content; border-radius: 50%; border: 6px solid var(--elev); background: var(--elev); }
.profile-avatar .status-dot { border-color: var(--elev); }
.profile-body { padding: 8px 16px 16px; }
.profile-name { font-size: 20px; font-weight: 700; }
.profile-username { color: var(--muted); font-size: 14px; }
.profile-status { margin-top: 8px; font-size: 14px; }
.profile-section { margin: 12px 0; padding-top: 10px; border-top: 1px solid var(--border); display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 13px; }
.profile-label { color: var(--muted); font-weight: 600; font-size: 12px; }
.profile-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pins-pop { width: 420px; padding: 8px; max-height: 70vh; }
.pins { display: flex; flex-direction: column; gap: 8px; }
.pop-title { font-weight: 700; padding: 4px 4px 2px; }

.emoji-pop { width: 352px; }
.emoji-picker { display: flex; flex-direction: column; height: 380px; }
.emoji-search { margin: 8px; width: auto; min-height: 34px; }
.emoji-grid { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.emoji-section { font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 2px 4px; }
.emoji-row { display: grid; grid-template-columns: repeat(8, 1fr); }
.emoji-btn { font-size: 24px; width: 38px; height: 38px; border-radius: 6px; display: grid; place-items: center; line-height: 1; }
.emoji-btn:hover { background: var(--active); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; padding: 16px; z-index: 70; }
.modal { width: 100%; max-width: 480px; max-height: calc(100dvh - 32px); background: var(--main); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.modal-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 20px; }
.modal-head h2 { font-size: 19px; }
.modal-body { padding: 8px 20px 16px; overflow-y: auto; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; background: var(--side); }
.card { background: var(--side); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.danger-card { border-color: var(--danger); }
.danger-zone { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.add-server .card { margin: 0; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 12px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border-strong); }
.image-pick { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.image-pick-preview { width: 72px; height: 72px; flex: none; border-radius: 12px; background: var(--elev-2); display: grid; place-items: center; overflow: hidden; color: var(--muted); border: 2px dashed var(--border-strong); }
.image-pick-preview.round { border-radius: 50%; }
.image-pick-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-pick-preview .avatar { width: 100% !important; height: 100% !important; }
.image-pick-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.image-pick-actions .field-hint { flex-basis: 100%; margin: 0; }
.swatches { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; }
.swatch.active { border-color: var(--text); }
.type-cards { display: grid; gap: 8px; margin-bottom: 14px; }
.type-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; background: var(--side); border: 1px solid var(--border); text-align: left; }
.type-card span { display: flex; flex-direction: column; }
.type-card.active { border-color: var(--accent); background: var(--accent-soft); }
.invite-preview { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.guild-icon.big { width: 72px; height: 72px; border-radius: 22px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 24px; font-weight: 700; overflow: hidden; margin-bottom: 8px; }
.guild-icon.big img { width: 100%; height: 100%; object-fit: cover; }
.invite-counts { display: flex; gap: 14px; color: var(--muted); font-size: 13px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--offline); margin-right: 5px; }
.dot.online { background: var(--online); }
.meter { height: 8px; border-radius: 4px; background: var(--elev-2); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--success); transition: width 0.06s; }
.keycap { font-family: var(--mono); min-width: 60px; }
.radio-cards { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px; border-radius: 10px; border: 2px solid var(--border); font-size: 13px; font-weight: 500; }
.radio-card.active { border-color: var(--accent); }
.theme-swatch { width: 96px; height: 60px; border-radius: 6px; border: 1px solid var(--border-strong); }
.theme-dark .theme-swatch { background: linear-gradient(90deg, #121317 20%, #1a1b20 20% 45%, #222329 45%); }
.theme-light .theme-swatch { background: linear-gradient(90deg, #e3e4e8 20%, #f1f2f4 20% 45%, #ffffff 45%); }
.theme-system .theme-swatch { background: linear-gradient(135deg, #222329 50%, #ffffff 50%); }

.settings-modal { max-width: 920px; height: min(680px, calc(100dvh - 32px)); }
.settings-modal .modal-body { padding: 0; flex: 1; display: flex; }
.settings { display: flex; flex: 1; min-height: 0; width: 100%; }
.settings-nav { width: 200px; flex: none; background: var(--side); padding: 12px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.settings-nav-title { font-size: 12px; font-weight: 700; color: var(--muted); padding: 6px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-tab { text-align: left; padding: 7px 10px; border-radius: 6px; color: var(--text-2); font-weight: 500; }
.settings-tab:hover { background: var(--hover); color: var(--text); }
.settings-tab.active { background: var(--active); color: var(--text); }
.settings-tab.danger { color: var(--danger); }
.settings-content { flex: 1; min-width: 0; overflow-y: auto; padding: 16px 24px 24px; }
.settings-heading { margin-bottom: 14px; }
.settings-list { display: flex; flex-direction: column; margin-top: 10px; }
.settings-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.picker-list { max-height: 320px; overflow-y: auto; margin-top: 10px; }
.picker-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.picker-row:hover { background: var(--hover); }
.picker-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.qs-modal { max-width: 560px; }
.qs-list { margin-top: 8px; display: flex; flex-direction: column; }
.qs-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; text-align: left; }
.qs-item.active, .qs-item:hover { background: var(--active); }

.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, 0.88); 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); object-fit: contain; border-radius: 6px; cursor: zoom-out; }
.lightbox-bar { display: flex; align-items: center; gap: 16px; color: #ddd; font-size: 14px; max-width: 100%; }
.lightbox-bar a { color: #fff; }
.lightbox-bar .icon-btn { color: #fff; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 95; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; background: var(--elev); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; padding: 8px 8px 8px 14px; box-shadow: var(--shadow); font-size: 14px; animation: rise 0.18s ease-out; }
.toast.error { border-left-color: var(--danger); }
.toast-text { flex: 1; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- touch and phones ---------- */

@media (hover: none) {
  .msg:hover { background: transparent; }
  .msg-actions { display: none !important; }
  .channel-gear, .dm-close, .reaction.add, .tile-full, .preview-jump { opacity: 1; }
  .msg { -webkit-touch-callout: none; }
}

@media (max-width: 800px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .nav-wrap { position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; transform: translateX(-102%); transition: transform 0.22s ease; box-shadow: var(--shadow); }
  .app.nav-open .nav-wrap { transform: none; }
  .sidebar { width: min(280px, calc(100vw - 72px - 40px)); }
  .members { position: fixed; top: 0; bottom: 0; right: 0; z-index: 40; width: min(300px, 86vw); display: flex !important; transform: translateX(102%); transition: transform 0.22s ease; box-shadow: var(--shadow); }
  .app.members-open .members { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 35; }
  .app.nav-open .scrim, .app.members-open .scrim { display: block; }
  .nav-toggle { display: inline-grid; }
  .main-header { padding: 0 4px 0 12px; }
  .header-topic, .header-divider { display: none; }
  .search-box { padding: 0 6px; }
  .search-input { width: 0; }
  .search-box:focus-within .search-input { width: 120px; }
  .search-box:focus-within ~ * { display: none; }
  .msg { grid-template-columns: 48px minmax(0, 1fr); padding: 2px 12px; }
  .msg-avatar .avatar { width: 36px !important; height: 36px !important; }
  .msg-hover-time { display: none; }
  .composer-wrap { padding: 0 8px; }
  .send-btn { display: inline-grid; }
  .composer-input { font-size: 16px; }
  .input { font-size: 16px; }
  .typing { padding-left: 12px; }
  .friends-body { padding: 8px 12px 16px; }
  .tabs { flex: 1; min-width: 0; }
  .main-header:has(.tabs) .header-title { display: none; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { max-width: none; max-height: 92dvh; border-radius: 14px 14px 0 0; }
  .modal-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .settings-modal { height: 92dvh; }
  .settings { flex-direction: column; }
  .settings-nav { width: auto; flex-direction: row; overflow-x: auto; padding: 8px; }
  .settings-nav-title { display: none; }
  .settings-tab { white-space: nowrap; }
  .settings-content { padding: 12px 16px 20px; }
  .two-col { grid-template-columns: 1fr; }
  .pins-pop { width: calc(100vw - 16px); }
  .emoji-pop { width: calc(100vw - 16px); max-width: 352px; }
  .stage-grid { grid-template-columns: repeat(min(var(--cols), 2), minmax(0, 1fr)); }
  .ctl { width: 48px; height: 48px; }
  .toasts { left: 16px; right: 16px; align-items: stretch; bottom: max(16px, env(safe-area-inset-bottom)); }
}
