/* wchat 界面：参考 Telegram Desktop 的浅色 / 深色配色，布局保持轻量 */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --canvas: #e6ebee;
  --canvas-dot: rgba(54, 78, 99, .10);
  --page-bg: #f4f5f6;
  --panel: #ffffff;
  --panel-2: #ffffff;
  --bg-2: #f1f3f5;
  --input-bg: #f1f3f5;
  --text: #000000;
  --text-2: #1a1a1a;
  --muted: #707579;
  --muted-2: #a2acb4;
  --line: #e4e8eb;
  --line-2: #d7dde2;
  --accent: #3390ec;
  --accent-2: #2b82d9;
  --accent-soft: #e7f3ff;
  --accent-ink: #1a73c9;
  --bubble-in: #ffffff;
  --bubble-out: #effdde;
  --bubble-in-text: #000000;
  --bubble-out-text: #000000;
  --bubble-line: rgba(0, 0, 0, .08);
  --meta: #a0acb6;
  --meta-out: #6c9c5e;
  --tick: #9db9c9;
  --tick-read: #4fae4e;
  --sender: #1a73c9;
  --sender-out: #3d7a2c;
  --danger: #e53935;
  --danger-soft: #fff0ef;
  --ok: #4fae4e;
  --gold: #d4a94e;
  --gold-ink: #2b2114;
  --sidebar-bg: #ffffff;
  --sidebar-hover: #f4f4f5;
  --sidebar-active: #e7f3ff;
  --sidebar-text: #000000;
  --sidebar-muted: #707579;
  --sidebar-line: #e4e8eb;
  --sidebar-scroll: #cbd2d8;
  --sidebar-badge: #3390ec;
  --sidebar-badge-text: #ffffff;
  --sidebar-pin: #3390ec;
  --topbar: #ffffff;
  --file-bg: #f7f9fa;
  --drop-bg: rgba(255, 255, 255, .94);
  --lightbox-bg: rgba(0, 0, 0, .88);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .06);
  --shadow-md: 0 16px 44px rgba(0, 0, 0, .16);
  --shadow-lg: 0 32px 80px rgba(0, 0, 0, .24);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0e1621;
  --canvas-dot: rgba(255, 255, 255, .045);
  --page-bg: #0e1621;
  --panel: #17212b;
  --panel-2: #1e2b38;
  --bg-2: #242f3d;
  --input-bg: #242f3d;
  --text: #f5f5f5;
  --text-2: #e9edef;
  --muted: #8b9bab;
  --muted-2: #6c7b8a;
  --line: #253340;
  --line-2: #2f4053;
  --accent: #64b5ef;
  --accent-2: #8cc8f5;
  --accent-soft: #22364a;
  --accent-ink: #8cc8f5;
  --bubble-in: #182533;
  --bubble-out: #2b5278;
  --bubble-in-text: #f5f5f5;
  --bubble-out-text: #ffffff;
  --bubble-line: transparent;
  --meta: #7e91a4;
  --meta-out: #a6c3dc;
  --tick: #7e91a4;
  --tick-read: #6ab2f2;
  --sender: #8cc8f5;
  --sender-out: #a9d3f5;
  --danger: #ff6b6b;
  --danger-soft: #3a2020;
  --ok: #6abf69;
  --sidebar-bg: #17212b;
  --sidebar-hover: #202b36;
  --sidebar-active: #2b5278;
  --sidebar-text: #f5f5f5;
  --sidebar-muted: #8b9bab;
  --sidebar-line: #101921;
  --sidebar-scroll: #3a4a5b;
  --sidebar-badge: #64b5ef;
  --sidebar-badge-text: #0e1621;
  --sidebar-pin: #64b5ef;
  --topbar: #17212b;
  --file-bg: rgba(255, 255, 255, .06);
  --drop-bg: rgba(14, 22, 33, .94);
  --lightbox-bg: rgba(0, 0, 0, .9);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow-md: 0 16px 44px rgba(0, 0, 0, .45);
  --shadow-lg: 0 32px 80px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
img { border: 0; }
::selection { background: rgba(51, 144, 236, .22); }
:focus-visible { outline: 2px solid rgba(51, 144, 236, .55); outline-offset: 2px; }

* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.error { color: var(--danger); font-size: 12.5px; }
.grow { flex: 1; min-width: 0; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.small { font-size: 12px; padding: 5px 9px; }
.wide { width: 100%; }
code, .raw { font-family: "Cascadia Code", Consolas, "SFMono-Regular", monospace; }
code { background: var(--bg-2); border-radius: 4px; padding: 2px 5px; word-break: break-all; }
.raw {
  white-space: pre-wrap; word-break: break-all; background: var(--bg-2);
  padding: 12px; border-radius: 6px; font-size: 12px; line-height: 1.6;
  max-height: 380px; overflow: auto; border: 1px solid var(--line);
}

/* ---------- 基础控件 ---------- */

.ico { width: 20px; height: 20px; flex: none; display: block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--panel); color: var(--text-2); font-size: 13.5px; font-weight: 600;
  line-height: 1; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--bg-2); border-color: var(--line-2); }
.btn .ico { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #ffffff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.btn.recording { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.icon-btn {
  width: 34px; height: 34px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-2); color: var(--text); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent-ink); }
.icon-btn.tiny { width: 26px; height: 26px; }
.icon-btn.tiny .ico { width: 14px; height: 14px; }
.icon-btn.recording { background: var(--danger-soft); color: var(--danger); animation: recPulse 1.1s ease-in-out infinite; }

input, textarea, select {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid transparent; border-radius: 8px;
  background: var(--input-bg); color: var(--text); font-size: 13.5px; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { height: auto; resize: none; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }
input[type=checkbox] { width: 16px; height: 16px; flex: none; padding: 0; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; line-height: 1.5; margin: 8px 0; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 13px; font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.field input, .field textarea { font-weight: 400; letter-spacing: 0; }
.field-input { width: 100%; }

/* ---------- 头像 ---------- */

.avatar {
  width: 42px; height: 42px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; object-fit: cover; color: #ffffff; font-weight: 600; font-size: 16px;
  background: #65aadd; user-select: none;
}
.avatar.ph.av-t0 { background: #e17076; }
.avatar.ph.av-t1 { background: #faa774; }
.avatar.ph.av-t2 { background: #a695e7; }
.avatar.ph.av-t3 { background: #7bc862; }
.avatar.ph.av-t4 { background: #6ec9cb; }
.avatar.ph.av-t5 { background: #65aadd; }
.avatar.ph.av-t6 { background: #ee7aae; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.big { width: 64px; height: 64px; font-size: 23px; }
.avatar.side-avatar { width: 36px; height: 36px; font-size: 13px; }
.avatar.list-avatar { width: 40px; height: 40px; font-size: 14px; }
.avatar.pick-avatar { width: 34px; height: 34px; font-size: 12px; }
.avatar.msg-avatar { width: 28px; height: 28px; font-size: 11px; }
.avatar.official {
  border-radius: 50%; background: var(--gold); color: var(--gold-ink);
}
.avatar.official .ico { width: 20px; height: 20px; }
.avatar.official.self { background: var(--accent-soft); color: var(--accent-ink); }
.avatar.ph.group { border-radius: 50%; font-size: 16px; }

/* ---------- 主框架 ---------- */

.layout { display: flex; height: 100dvh; overflow: hidden; background: var(--canvas); }

.side {
  width: 320px; flex: 0 0 320px; height: 100dvh; display: flex; flex-direction: column;
  background: var(--sidebar-bg); color: var(--sidebar-text); position: relative; z-index: 20;
  border-right: 1px solid var(--sidebar-line);
}
.side * { scrollbar-color: var(--sidebar-scroll) transparent; }
.side ::-webkit-scrollbar-thumb { background: var(--sidebar-scroll); }
.side ::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

.side-top {
  height: 64px; flex: none; padding: 0 14px; display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  background: var(--accent); color: #ffffff;
  display: inline-flex; align-items: center; justify-content: center;
}
.brand-mark .ico { width: 17px; height: 17px; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -.03em; color: var(--sidebar-text); }
.side-top-actions { display: flex; align-items: center; gap: 2px; }
.side .icon-btn { color: var(--sidebar-muted); }
.side .icon-btn:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }

.compose-menu {
  position: absolute; top: 56px; right: 12px; z-index: 60; width: 176px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px; box-shadow: var(--shadow-md);
}
.compose-menu button {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 9px 10px;
  border: 0; border-radius: 6px; background: transparent; text-align: left;
  font-size: 13px; color: var(--text-2);
}
.compose-menu button:hover { background: var(--accent-soft); color: var(--accent-ink); }
.compose-menu .ico { width: 17px; height: 17px; color: var(--accent); }

.side-search { margin: 0 10px 8px; position: relative; display: flex; align-items: center; flex: none; }
.side-search .search-ico { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--sidebar-muted); pointer-events: none; }
.side-search input {
  height: 36px; padding: 0 32px 0 35px; background: var(--input-bg); color: var(--text);
  border: 1px solid transparent; border-radius: 8px; font-size: 13px;
}
.side-search input::placeholder { color: var(--sidebar-muted); }
.side-search input:focus { border-color: var(--accent); box-shadow: none; background: var(--input-bg); }
.side-search .icon-btn { position: absolute; right: 3px; }

.side-nav-item {
  margin: 0 8px 4px; height: 38px; padding: 0 10px; display: flex; align-items: center; gap: 9px;
  border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--sidebar-muted); flex: none;
  transition: background .15s, color .15s;
}
.side-nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.side-nav-item .ico { width: 17px; height: 17px; color: var(--accent); }
.nav-badge {
  margin-left: auto; min-width: 19px; height: 19px; padding: 0 6px; border-radius: 99px;
  background: var(--sidebar-badge); color: var(--sidebar-badge-text); font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

.conv-list { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 7px 8px; }
.conv {
  display: flex; align-items: center; gap: 10px; padding: 8px 9px;
  border-radius: 8px; margin-bottom: 1px; position: relative;
  transition: background .12s;
}
.conv:hover { background: var(--sidebar-hover); }
.conv.on { background: var(--sidebar-active); }
.conv.on .conv-name { color: var(--accent-ink); }
.conv-av { flex: none; display: flex; }
.conv-av .avatar { width: 46px; height: 46px; font-size: 16px; }
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.conv-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; }
.conv-name { font-size: 14px; font-weight: 600; line-height: 1.2; color: var(--sidebar-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-tools { display: flex; align-items: center; gap: 2px; flex: none; }
.conv-time { font-size: 10.5px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.conv-pin {
  width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--sidebar-pin); display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s, background .15s;
}
.conv-pin .ico { width: 12px; height: 12px; }
.conv-pin:hover { background: color-mix(in srgb, var(--sidebar-pin) 14%, transparent); }
.conv-pin.on { opacity: 1; }
.conv:hover .conv-pin { opacity: .65; }
.conv:hover .conv-pin:hover { opacity: 1; }
.conv-row2 { gap: 8px; }
.conv-preview { flex: 1; min-width: 0; font-size: 12px; color: var(--sidebar-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.35; }
.pv-me { color: var(--sidebar-muted); }
.pv-name { color: var(--sidebar-muted); font-weight: 600; }
.unread {
  flex: none; min-width: 19px; height: 19px; padding: 0 6px; border-radius: 99px;
  background: var(--sidebar-badge); color: var(--sidebar-badge-text); font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.conv-empty { padding: 44px 18px; text-align: center; color: var(--sidebar-muted); display: flex; flex-direction: column; align-items: center; gap: 5px; }
.conv-empty-ico {
  width: 48px; height: 48px; border-radius: 50%; background: var(--bg-2); color: var(--muted-2);
  display: flex; align-items: center; justify-content: center; margin-bottom: 8px;
}
.conv-empty-ico .ico { width: 22px; height: 22px; }
.conv-empty b { color: var(--sidebar-text); font-size: 13px; font-weight: 600; }
.conv-empty span { font-size: 11.5px; color: var(--sidebar-muted); }

.side-user {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-top: 1px solid var(--sidebar-line); background: var(--sidebar-bg);
}
.side-user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.side-user-info b { font-size: 13px; font-weight: 600; color: var(--sidebar-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-info small { font-size: 11px; color: var(--sidebar-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user .icon-btn { width: 30px; height: 30px; }

.main { flex: 1; min-width: 0; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: var(--canvas); position: relative; }

/* ---------- 欢迎页 ---------- */

.welcome {
  flex: 1; position: relative; overflow: hidden; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 40px 24px;
  background:
    radial-gradient(var(--canvas-dot) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--canvas);
}
.welcome-glow { display: none; }
.welcome-mark {
  width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #ffffff;
  margin-bottom: 22px; position: relative;
}
.welcome-mark .ico { width: 26px; height: 26px; }
.welcome h1 { margin: 0 0 10px; font-size: 30px; letter-spacing: -.04em; font-weight: 700; position: relative; color: var(--text); }
.welcome p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.9; position: relative; max-width: 420px; }
.welcome-actions { display: flex; gap: 8px; margin-top: 26px; position: relative; flex-wrap: wrap; justify-content: center; }
.welcome-hint { margin-top: 30px; font-size: 11.5px; color: var(--muted-2); position: relative; }

/* ---------- 会话头部 ---------- */

.chat-head {
  flex: none; height: 60px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--topbar); border-bottom: 1px solid var(--line); z-index: 10;
}
.back-btn { display: none; }
.chat-head-av { flex: none; display: flex; }
.chat-head-av .avatar { width: 38px; height: 38px; font-size: 14px; }
.chat-head-av .avatar.official .ico { width: 19px; height: 19px; }
.chat-head-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-head-info b { font-size: 14.5px; font-weight: 600; line-height: 1.2; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-info small { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 1px; flex: none; }
.official-badge {
  margin-left: 6px; padding: 3px 8px; border-radius: 99px; background: var(--accent-soft);
  border: 1px solid transparent; color: var(--accent-ink); font-size: 10px; font-weight: 700; letter-spacing: .04em;
}
.service-strip {
  flex: none; display: flex; align-items: center; gap: 7px; padding: 8px 16px;
  background: var(--accent-soft); border-bottom: 1px solid var(--line); color: var(--accent-ink);
  font-size: 12px; line-height: 1.5;
}
.service-strip .ico { width: 15px; height: 15px; }

/* ---------- 消息区 ---------- */

.chat-body {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; position: relative;
  background:
    radial-gradient(var(--canvas-dot) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--canvas);
}
.msgs {
  width: 100%; max-width: 880px; margin: 0 auto; min-height: 100%;
  padding: 20px clamp(12px, 4vw, 34px) 10px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.bubble-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 4px; position: relative; min-width: 0; }
.bubble-row.mine { flex-direction: row-reverse; }
.bubble-row.grouped { margin-top: 2px; }
.bubble-row.last { margin-bottom: 7px; }
.avatar-gap { width: 28px; flex: none; }
.msg-avatar { align-self: flex-end; }
.bubble {
  position: relative; max-width: min(72%, 600px); min-width: 62px;
  padding: 7px 12px 6px; background: var(--bubble-in); color: var(--bubble-in-text);
  border: 1px solid var(--bubble-line); border-radius: 12px 12px 12px 4px;
  font-size: 14.5px; line-height: 1.5; word-break: break-word; overflow-wrap: anywhere;
}
.bubble.me {
  background: var(--bubble-out); color: var(--bubble-out-text);
  border-color: var(--bubble-out); border-radius: 12px 12px 4px 12px;
}
.bubble.pending { opacity: .55; }
.bubble.failed { box-shadow: inset 0 0 0 1px var(--danger); }
.bubble-row.last .bubble::after {
  content: ""; position: absolute; bottom: -1px; width: 9px; height: 13px; background: inherit; pointer-events: none;
}
.bubble-row.last:not(.mine) .bubble::after {
  left: -5px; clip-path: polygon(100% 0, 100% 100%, 0 100%);
}
.bubble-row.last.mine .bubble::after {
  right: -5px; clip-path: polygon(0 0, 100% 100%, 0 100%);
}
.bubble .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .sender { display: flex; align-items: center; gap: 5px; margin-bottom: 2px; font-size: 12.5px; font-weight: 600; color: var(--sender); }
.sender-role {
  font-size: 9px; font-weight: 700; letter-spacing: .05em; padding: 1px 4px;
  border-radius: 4px; background: var(--accent-soft); color: var(--accent-ink);
}
.bubble.me .sender { color: var(--sender-out); }
.bubble.me .sender-role { background: rgba(255, 255, 255, .18); color: inherit; }
.bubble .meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 4px;
  margin-top: 2px; font-size: 10.5px; line-height: 1; color: var(--meta);
  font-variant-numeric: tabular-nums; user-select: none;
}
.bubble.me .meta { color: var(--meta-out); }
.st { font-size: 11px; letter-spacing: -2px; margin-left: 1px; color: var(--tick); }
.st.read { color: var(--tick-read); }
.st.pending { letter-spacing: 0; display: inline-block; animation: spin 1.2s linear infinite; }
.st.failed { letter-spacing: 0; color: var(--danger); cursor: pointer; text-decoration: underline; }
.msg-broken { color: var(--danger); font-size: 12.5px; }
.msg-more {
  width: 26px; height: 26px; flex: none; border: 0; border-radius: 50%; background: transparent;
  color: var(--muted); display: flex; align-items: center; justify-content: center;
  opacity: 0; align-self: center; transition: opacity .15s, background .15s;
}
.msg-more .ico { width: 16px; height: 16px; }
.bubble-row:hover .msg-more, .msg-more:focus { opacity: 1; }
.msg-more:hover { background: var(--panel); color: var(--text-2); }

.media { display: inline-block; position: relative; max-width: 100%; min-width: 120px; border-radius: 6px; overflow: hidden; line-height: 0; }
.media img, .media video { display: block; max-width: 100%; max-height: 420px; border-radius: 6px; background: var(--bg-2); }
.media audio { width: min(280px, 62vw); line-height: normal; }
.media img[data-open] { cursor: zoom-in; }
.media-dl {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .58); color: #ffffff; display: flex; align-items: center; justify-content: center;
  opacity: .55; transition: opacity .15s, background .15s;
}
.media-dl .ico { width: 16px; height: 16px; }
.media:hover .media-dl, .media-dl:focus { opacity: 1; }
.media-dl:hover { background: rgba(0, 0, 0, .78); }
.media-loading { display: inline-block; padding: 12px 8px; font-size: 12px; color: var(--muted); line-height: 1.4; }

.lightbox {
  position: fixed; inset: 0; z-index: 250; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--lightbox-bg); animation: fadeIn .15s ease-out;
}
.lightbox img {
  max-width: min(1100px, 94vw); max-height: 86vh; object-fit: contain;
  border-radius: 4px; box-shadow: 0 30px 90px rgba(0, 0, 0, .5); background: #0e1621;
}
.lightbox-bar { position: absolute; top: 18px; right: 18px; display: flex; gap: 8px; }
.lightbox-btn {
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255, 255, 255, .18); border-radius: 50%;
  background: rgba(255, 255, 255, .12); color: #ffffff;
}
.lightbox-btn:hover { background: rgba(255, 255, 255, .22); }
.lightbox-btn .ico { width: 18px; height: 18px; }
.lightbox-name {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  max-width: 80vw; color: #cfd8e3; font-size: 12px; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.file-card {
  width: min(320px, 62vw); display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 2px 0; border: 1px solid var(--line);
  border-radius: 8px; background: var(--file-bg); text-align: left; color: inherit;
}
.bubble.me .file-card { border-color: rgba(255, 255, 255, .16); }
.file-card:hover { background: color-mix(in srgb, var(--file-bg) 70%, var(--accent-soft)); }
.file-ico {
  width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--accent);
  color: #ffffff; display: flex; align-items: center; justify-content: center;
}
.bubble.me .file-ico { background: rgba(255, 255, 255, .2); color: inherit; }
.file-ico .ico { width: 18px; height: 18px; }
.file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-info b { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info small { font-size: 11px; color: var(--muted); }
.bubble.me .file-info small { color: var(--meta-out); }
.file-dl { color: var(--muted); display: flex; flex: none; }
.bubble.me .file-dl { color: inherit; }
.file-dl .ico { width: 17px; height: 17px; }

.day-sep { display: flex; align-items: center; gap: 12px; margin: 14px 0 8px; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.day-sep span { color: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: .04em; white-space: nowrap; }
.load-more {
  align-self: center; margin: 4px auto 12px; padding: 5px 12px;
  border: 1px solid var(--line-2); border-radius: 99px; background: var(--panel);
  color: var(--accent-ink); font-size: 11.5px; font-weight: 600;
}
.load-more:hover { background: var(--accent-soft); }

.chat-empty, .chat-error { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 40px 20px; color: var(--muted); }
.chat-empty-ico, .chat-error-ico {
  width: 56px; height: 56px; border-radius: 50%; background: var(--panel);
  color: var(--muted-2); display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px; box-shadow: var(--shadow-sm);
}
.chat-empty-ico .ico, .chat-error-ico .ico { width: 24px; height: 24px; }
.chat-empty b, .chat-error b { color: var(--text-2); font-size: 13.5px; font-weight: 600; }
.chat-empty span, .chat-error p { font-size: 12px; line-height: 1.7; max-width: 320px; margin: 0; }
.chat-error .btn { margin-top: 14px; }
.chat-loading { flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px; }
.chat-loading span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); animation: bounce 1.1s infinite ease-in-out; }
.chat-loading span:nth-child(2) { animation-delay: .15s; }
.chat-loading span:nth-child(3) { animation-delay: .3s; }

.drop-zone {
  position: absolute; top: 60px; left: 12px; right: 12px; bottom: 78px; z-index: 20; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  border: 2px dashed var(--accent); border-radius: 12px;
  background: var(--drop-bg); color: var(--accent-ink); text-align: center;
  pointer-events: none;
}
.drop-zone .ico { width: 30px; height: 30px; color: var(--accent); }
.drop-zone b { font-size: 15px; font-weight: 700; }
.drop-zone span { font-size: 12px; color: var(--muted); }
.main.dragging .drop-zone { display: flex; }
.main.dragging .msgs { opacity: .35; }

/* ---------- 输入区 ---------- */

.composer-wrap {
  flex: none; padding: 8px 16px 12px; position: relative; background: var(--canvas);
}
.composer {
  width: 100%; max-width: 880px; margin: 0 auto; display: flex; align-items: flex-end; gap: 3px;
  padding: 5px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-sm); position: relative;
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 16%, transparent); }
.composer-field { flex: 1; min-width: 0; display: flex; }
.composer-field textarea {
  width: 100%; border: 0; background: transparent; resize: none; box-shadow: none;
  height: auto; padding: 9px 4px; max-height: 150px; font-size: 14px; line-height: 1.5; border-radius: 0;
}
.composer-field textarea:focus { border: 0; box-shadow: none; background: transparent; }
.composer-btn { width: 34px; height: 34px; border-radius: 50%; color: var(--muted); }
.composer-btn .ico { width: 19px; height: 19px; }
.send-btn {
  width: 34px; height: 34px; flex: none; border: 0; border-radius: 50%;
  background: var(--accent); color: #ffffff;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
.send-btn .ico { width: 17px; height: 17px; transform: translateX(-1px); }
.send-btn:hover { background: var(--accent-2); }
.send-btn:active { transform: scale(.95); }
.attach-menu {
  position: absolute; left: 5px; bottom: 54px; z-index: 30; width: 142px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px;
  box-shadow: var(--shadow-md);
}
.attach-menu button {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 8px 9px;
  border: 0; border-radius: 6px; background: transparent; font-size: 12.5px; text-align: left; color: var(--text-2);
}
.attach-menu button:hover { background: var(--accent-soft); color: var(--accent-ink); }
.attach-menu .ico { width: 16px; height: 16px; color: var(--accent); }
.up-status { max-width: 880px; margin: 0 auto; height: 15px; font-size: 11.5px; color: var(--muted); text-align: center; line-height: 15px; }
.composer-wrap.readonly { padding-bottom: 16px; }
.readonly-bar {
  max-width: 880px; margin: 0 auto; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 14px; background: var(--accent-soft); border: 1px solid transparent; border-radius: 8px;
  color: var(--accent-ink); font-size: 12px;
}
.readonly-bar .ico { width: 15px; height: 15px; }

/* ---------- 普通页面 ---------- */

.page {
  flex: 1; min-height: 0; overflow-y: auto; width: 100%;
  padding: 34px clamp(20px, 5vw, 54px) 68px;
  background:
    radial-gradient(var(--canvas-dot) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--page-bg);
}
.page > * { max-width: 960px; margin-left: auto; margin-right: auto; }
.page.wide-page > * { max-width: 1200px; }
.page-back { display: none; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--accent-ink); margin-bottom: 14px; }
.page-back .ico { width: 15px; height: 15px; }
.page-head { margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.page-head h1 { margin: 3px 0 8px; font-size: 26px; letter-spacing: -.03em; font-weight: 700; line-height: 1.15; color: var(--text); }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.75; max-width: 640px; }
.eyebrow { font-size: 10px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 22px; margin-bottom: 16px; box-shadow: none;
}
.card h3 { margin: 0 0 10px; font-size: 14.5px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.card h3 .count-pill { vertical-align: 1px; }
.card p { line-height: 1.7; }
.card > .hint:last-child { margin-bottom: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.card-head h3 { margin: 0; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.settings-grid .card { margin-bottom: 0; }
.profile-card { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; }
.profile-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.profile-info b { font-size: 19px; letter-spacing: -.02em; }
.profile-info span { color: var(--accent-ink); font-size: 12.5px; font-weight: 600; }
.profile-info small { color: var(--muted); font-size: 11.5px; }
.settings-grid .inline input { min-width: 0; }
.devices-card, .theme-card { grid-column: 1 / -1; }
.quota-line { display: flex; align-items: baseline; gap: 6px; margin-bottom: 9px; }
.quota-line b { font-size: 18px; }
.quota-line span { color: var(--muted); font-size: 12px; }
progress {
  appearance: none; -webkit-appearance: none; width: 100%; height: 6px; border: 0;
  border-radius: 99px; overflow: hidden; background: var(--line); display: block;
}
progress::-webkit-progress-bar { background: var(--line); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 99px; }
.setting-note {
  display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px;
  background: var(--accent-soft); border: 1px solid transparent; border-radius: 8px; color: var(--accent-ink);
  font-size: 12.5px; line-height: 1.65; margin-bottom: 8px;
}
.setting-note .ico { width: 16px; height: 16px; color: var(--accent); margin-top: 1px; }

.theme-choices { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.theme-choice {
  height: 32px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 6px;
  background: var(--panel); color: var(--text-2); font-size: 12.5px; font-weight: 600;
  transition: background .15s, border-color .15s, color .15s;
}
.theme-choice:hover { background: var(--bg-2); }
.theme-choice.active { background: var(--accent); border-color: var(--accent); color: #ffffff; }

.device-list { margin-top: 4px; border-top: 1px solid var(--line); }
.device-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.device-row:last-child { border-bottom: 0; padding-bottom: 0; }
.device-ico {
  width: 38px; height: 38px; flex: none; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--bg-2); border-radius: 50%; color: var(--muted);
}
.device-ico .ico { width: 19px; height: 19px; }
.device-row.current .device-ico { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.device-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.device-info b { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.device-info span { font-size: 11.5px; color: var(--muted); }
.device-info small { font-size: 11px; color: var(--muted-2); }
.device-tag {
  font-style: normal; font-size: 9.5px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 6px; border: 1px solid transparent; color: var(--accent-ink);
  border-radius: 99px; background: var(--accent-soft);
}
.device-loading { padding: 14px 0; color: var(--muted); font-size: 12.5px; }

/* ---------- 好友 ---------- */

.search-row { display: flex; align-items: center; gap: 8px; position: relative; }
.search-row .search-ico { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search-row input { flex: 1; min-width: 0; padding-left: 35px; }
.friend-results { margin-top: 6px; }
.friend-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.friend-columns .card { margin-bottom: 16px; }
.person-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.person-row:last-of-type { border-bottom: 0; }
.person-info { display: flex; flex-direction: column; gap: 1px; }
.person-info b { font-size: 13.5px; font-weight: 600; }
.person-info small { font-size: 11.5px; color: var(--muted); }
.row-actions { display: flex; align-items: center; gap: 5px; flex: none; }
.count-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft);
  color: var(--accent-ink); font-size: 10.5px; font-weight: 700;
}
.request-reason {
  margin: -1px 0 10px 51px; padding: 4px 10px; font-size: 12.5px; line-height: 1.6;
  color: var(--text-2); border-left: 2px solid var(--accent); border-radius: 0 4px 4px 0;
}
.request-reason.empty { color: var(--muted-2); font-style: italic; border-color: var(--line-2); padding-left: 10px; }
.empty-line { color: var(--muted-2); font-size: 12.5px; padding: 12px 0 4px; }
.search-result { background: var(--bg-2); border-radius: 8px; padding: 9px 11px; margin-top: 6px; border-bottom: 0; }

/* ---------- 管理后台 ---------- */

.table-wrap { width: 100%; overflow-x: auto; border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 620px; }
th {
  padding: 9px 10px; text-align: left; font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted-2); font-weight: 700;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; line-height: 1.5; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--bg-2); }
td small { color: var(--muted); font-size: 11px; }
td .avatar.sm { vertical-align: middle; margin-right: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.tabs { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0 14px; }
.user-table { min-width: 780px; }
.user-table th, .user-table td { white-space: nowrap; }
.audit-table { min-width: 720px; }
.audit-table th, .audit-table td { white-space: nowrap; }
.conv-table { min-width: 640px; }
.conv-table th, .conv-table td { white-space: nowrap; }
.msg-table { min-width: 760px; }
.review-table { min-width: 1020px; }
.review-table th, .review-table td { white-space: nowrap; }
.review-table td:nth-child(7) { white-space: normal; min-width: 150px; }

/* ---------- 弹窗、菜单、提示 ---------- */

.modal-mask {
  position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(0, 0, 0, .45);
  animation: fadeIn .15s ease-out;
}
.modal {
  width: min(460px, 100%); max-height: 88vh; overflow: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 22px; box-shadow: var(--shadow-lg);
  animation: modalIn .18s cubic-bezier(.16, 1, .3, 1);
}
.modal h3 { margin: 0 0 10px; font-size: 17px; letter-spacing: -.02em; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.warn { font-size: 12.5px; line-height: 1.7; background: var(--accent-soft); border: 1px solid transparent; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; color: var(--accent-ink); }
.warn ul { margin: 6px 0 10px 18px; padding: 0; }
.pick-hint { margin: 0 0 6px; }
.pick-list { display: flex; flex-direction: column; margin: 6px 0; max-height: 330px; overflow: auto; }
.pick-row { display: flex; align-items: center; gap: 9px; padding: 8px 6px; border-radius: 6px; cursor: pointer; }
.pick-row:hover { background: var(--bg-2); }
.pick-row input[type=checkbox] { margin: 0; }
.pick-row label { cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.pick-row b { font-size: 13px; }
.pick-row small { font-size: 11px; color: var(--muted); }
.pick-empty {
  display: flex; flex-direction: column; align-items: flex-start; gap: 5px;
  padding: 16px; background: var(--bg-2); border-radius: 8px; color: var(--muted);
}
.pick-empty b { color: var(--text-2); font-size: 13px; }
.pick-empty span { font-size: 12px; }
.pick-empty .btn { margin-top: 4px; }
.request-target { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; background: var(--bg-2); border-radius: 8px; margin-bottom: 12px; }
.request-target-name { font-size: 13.5px; font-weight: 700; }
.request-target .hint { font-size: 11.5px; }

.msg-menu {
  position: fixed; z-index: 130; min-width: 180px; display: flex; flex-direction: column; padding: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-md);
}
.msg-menu button {
  text-align: left; border: 0; background: transparent; padding: 8px 10px;
  border-radius: 6px; font-size: 12.5px; color: var(--text-2);
}
.msg-menu button:hover { background: var(--bg-2); }
.msg-menu button.danger { color: var(--danger); }
.msg-menu button.danger:hover { background: var(--danger-soft); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 300;
  max-width: 80vw; padding: 9px 14px; border-radius: 8px;
  background: #1e2b38; color: #f5f5f5; font-size: 12.5px; line-height: 1.5;
  border: 1px solid rgba(255, 255, 255, .08); box-shadow: 0 18px 44px rgba(0, 0, 0, .3);
  animation: toastIn .2s cubic-bezier(.16, 1, .3, 1);
}

/* ---------- 首次配置 ---------- */

.center-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 28px;
  background:
    radial-gradient(var(--canvas-dot) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--canvas);
}
.setup { width: 560px; max-width: 100%; max-height: 92vh; overflow: auto; margin: 0; padding: 26px; }
.setup h1 { margin: 0 0 6px; font-size: 23px; letter-spacing: -.03em; }
.setup > .hint { margin: 0 0 14px; }
.setup .btn[type=submit] { width: 100%; margin-top: 8px; height: 40px; font-size: 13.5px; }

/* ---------- 音视频通话 ---------- */

.call-panel { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; background: #0e1621; color: #f5f5f5; }
.call-stage { flex: 1; position: relative; min-height: 0; overflow: hidden; background: #0a1017; }
#rv { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #0a1017; }
#lv {
  position: absolute; right: 18px; bottom: 18px; z-index: 2; width: 180px; height: 120px;
  object-fit: cover; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .18);
  background: #0a1017; box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}
.call-status {
  position: absolute; top: 22px; left: 50%; transform: translateX(-50%); z-index: 3;
  max-width: 80%; padding: 7px 14px; border-radius: 99px; background: rgba(23, 33, 43, .78);
  color: #f5f5f5; font-size: 12.5px; text-align: center;
}
.call-bar { flex: none; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18px; background: #17212b; }
.call-bar .btn { min-width: 90px; background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .12); color: #f5f5f5; }
.call-bar .btn:hover { background: rgba(255, 255, 255, .14); }
.call-bar .btn.primary { background: #3390ec; border-color: #3390ec; color: #ffffff; }
.call-bar .btn.danger { background: #e53935; border-color: #e53935; color: #ffffff; }
.call-bar .btn.danger:hover { background: #d32f2f; }
.incoming { position: fixed; inset: 0; z-index: 240; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(14, 22, 33, .66); }
.incoming-card {
  width: min(360px, 100%); background: #17212b; color: #f5f5f5;
  border: 1px solid rgba(255, 255, 255, .1); border-radius: 10px; padding: 26px;
  box-shadow: 0 40px 100px rgba(0, 0, 0, .55); text-align: center;
}
.in-text { font-size: 14.5px; line-height: 1.6; margin-bottom: 20px; }
.incoming .call-bar { background: transparent; padding: 0; }

/* ---------- 动效 ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes recPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(229, 57, 53, .22); } 50% { box-shadow: 0 0 0 6px rgba(229, 57, 53, 0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 响应式 ---------- */

@media (hover: none) {
  .conv-pin { opacity: .45; }
  .msg-more { opacity: .45; }
  .media-dl { opacity: .72; }
}

@media (max-width: 1100px) {
  .side { width: 300px; flex-basis: 300px; }
  .conv-av .avatar { width: 44px; height: 44px; }
}

@media (max-width: 900px) {
  .layout { display: block; position: relative; }
  .side { width: 100%; height: 100dvh; border-right: 0; }
  .main { display: none; width: 100%; height: 100dvh; }
  .layout.chat-open .side, .layout.page-open .side { display: none; }
  .layout.chat-open .main, .layout.page-open .main { display: flex; }
  .back-btn { display: inline-flex; }
  .page-back { display: inline-flex; }
  .page { padding: 22px 14px 56px; }
  .page-head h1 { font-size: 23px; }
  .settings-grid, .friend-columns { grid-template-columns: 1fr; }
  .profile-card, .devices-card, .theme-card { grid-column: auto; }
  .chat-head { height: 56px; padding: 0 8px; gap: 8px; }
  .drop-zone { top: 56px; bottom: 62px; left: 8px; right: 8px; }
  .chat-head-av .avatar { width: 34px; height: 34px; font-size: 13px; }
  .head-actions { gap: 0; }
  .head-actions .icon-btn { width: 32px; height: 32px; }
  .official-badge { display: none; }
  .msgs { padding: 14px 10px 8px; }
  .bubble { max-width: 82%; }
  .composer-wrap { padding: 8px 8px 10px; }
  .composer { border-radius: 9px; }
  .composer-btn { width: 32px; height: 32px; }
  .send-btn { width: 32px; height: 32px; }
  .service-strip { padding: 8px 12px; font-size: 11.5px; }
  .file-card { width: min(280px, 66vw); }
  .modal { padding: 18px; border-radius: 9px; }
  .setup { padding: 22px 18px; }
  .profile-card { flex-wrap: wrap; }
  .profile-card .btn { margin-left: auto; }
  #lv { width: 130px; height: 92px; right: 12px; bottom: 12px; }
  .call-bar .btn { min-width: 76px; }
}

@media (max-width: 520px) {
  .brand-name { font-size: 18px; }
  .welcome { padding: 28px 18px; }
  .welcome-actions { flex-direction: column; width: 100%; max-width: 250px; }
  .welcome-actions .btn { width: 100%; }
  .page { padding: 16px 12px 48px; }
  .card { padding: 16px; border-radius: 9px; }
  .page-head { margin-bottom: 18px; padding-bottom: 14px; }
  .page-head h1 { font-size: 21px; }
  .profile-card { align-items: flex-start; }
  .profile-info b { font-size: 18px; }
  .settings-grid { gap: 12px; }
  .friend-columns { gap: 12px; }
  .person-row { gap: 9px; }
  .person-row .btn.small { padding: 0 8px; }
  .request-reason { margin-left: 49px; }
  .device-row { gap: 9px; }
  .device-ico { width: 34px; height: 34px; }
  .device-info b { font-size: 12.5px; }
  .card-head { align-items: flex-start; }
  .bubble { max-width: 86%; font-size: 14px; }
  .msg-avatar, .avatar-gap { width: 25px; }
  .bubble-row { gap: 5px; }
  .msg-more { width: 20px; }
  .chat-head-info small { font-size: 11px; }
  .modal-mask { padding: 10px; align-items: flex-end; }
  .modal { width: 100%; max-height: 92dvh; border-radius: 10px 10px 0 0; }
  .toast { bottom: 16px; }
}
