/* ==========================================================================
 *  Hush · 设计系统
 * --------------------------------------------------------------------------
 *  质感来自「克制」而不是「装饰」：
 *    · 层次靠多层柔和阴影 + 极淡描边，不靠重分割线
 *    · 中性色带一点冷调，避免死灰
 *    · 统一 4px 间距节奏与圆角梯度
 *    · 动效短促（.18s）且用同一条缓动曲线，不花哨
 * ========================================================================== */

/* ============================ 设计 Token ============================ */
:root {
  /* 品牌 */
  --brand:        #07C160;
  --brand-hover:  #06AD56;
  --brand-press:  #059748;
  --brand-soft:   rgba(7,193,96,.10);
  --brand-softer: rgba(7,193,96,.055);
  --danger:       #F5533D;
  --danger-soft:  rgba(245,83,61,.10);
  --warn:         #E8A33D;

  /* 文字 */
  --ink-1: #14161a;
  --ink-2: #474d57;
  --ink-3: #868d99;
  --ink-4: #b8bdc6;
  --on-brand: #ffffff;

  /* 背景层次 */
  --bg-app:    #f2f3f5;
  --bg-panel:  #ffffff;
  --bg-sunken: #f7f8fa;
  --bg-rail:   #24282e;
  --bg-rail-hi:#32373f;
  --bg-hover:  rgba(16,24,40,.04);
  --bg-active: rgba(7,193,96,.10);
  --bg-mask:   rgba(16,24,40,.42);
  --bg-glass:  rgba(255,255,255,.82);

  /* 气泡 */
  --bubble-me:    #95ec69;
  --bubble-me-ink:#14161a;
  --bubble-other: #ffffff;
  --bubble-sys:   rgba(16,24,40,.055);

  /* 描边 */
  --line:        rgba(16,24,40,.075);
  --line-strong: rgba(16,24,40,.14);

  /* 阴影：多层叠加，越往上越柔 */
  --sh-1: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.05);
  --sh-2: 0 2px 5px rgba(16,24,40,.05), 0 8px 22px rgba(16,24,40,.07);
  --sh-3: 0 6px 18px rgba(16,24,40,.09), 0 24px 56px rgba(16,24,40,.13);
  --sh-brand: 0 4px 14px rgba(7,193,96,.28);

  /* 圆角 */
  --r-xs: 5px; --r-sm: 8px; --r-md: 11px; --r-lg: 15px; --r-xl: 20px; --r-full: 999px;

  /* 间距 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;

  /* 动效 */
  --ease: cubic-bezier(.22,.61,.36,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
  --dur: .18s;
  --dur-slow: .32s;

  /* 尺寸 */
  --rail-w: 64px;
  --list-w: 300px;
  --head-h: 60px;
  --tab-h: 54px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

[data-theme="dark"] {
  --ink-1: #e9ebef;
  --ink-2: #a9b0ba;
  --ink-3: #767d88;
  --ink-4: #565d67;

  --bg-app:    #101216;
  --bg-panel:  #1a1d22;
  --bg-sunken: #15181c;
  --bg-rail:   #0b0d10;
  --bg-rail-hi:#1e2228;
  --bg-hover:  rgba(255,255,255,.055);
  --bg-active: rgba(7,193,96,.16);
  --bg-mask:   rgba(0,0,0,.6);
  --bg-glass:  rgba(26,29,34,.86);

  --bubble-me:    #2c5f3c;
  --bubble-me-ink:#e9ebef;
  --bubble-other: #24282e;
  --bubble-sys:   rgba(255,255,255,.06);

  --line:        rgba(255,255,255,.075);
  --line-strong: rgba(255,255,255,.14);

  --sh-1: 0 1px 2px rgba(0,0,0,.3);
  --sh-2: 0 2px 6px rgba(0,0,0,.36), 0 8px 22px rgba(0,0,0,.4);
  --sh-3: 0 8px 22px rgba(0,0,0,.5), 0 24px 56px rgba(0,0,0,.55);
}

/* ============================ 基础 ============================ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-1);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
}

#root { width: 100%; height: 100%; }

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
a { color: var(--brand); text-decoration: none; }
img { display: block; }

/*
 * 内联 SVG 默认按字号大小渲染。
 * 没有这条兜底，任何「忘了写尺寸」的 svg 在 flex 容器里都会被拉成一大块
 * （安全码弹窗里的盾牌就曾经被撑满整个对话框）。
 * 需要特定尺寸的地方用类选择器覆盖即可 —— 那比元素选择器优先级高。
 */
svg { width: 1em; height: 1em; flex: none; }

/* 滚动条：细、不抢视线 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(16,24,40,.16); border-radius: var(--r-full);
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(16,24,40,.28); background-clip: content-box; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); background-clip: content-box; }

::selection { background: var(--brand-soft); }

/* ============================ 首屏骨架 ============================ */
.boot-splash {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--s4);
  background: var(--bg-app);
}
.boot-logo, .login-logo {
  width: 72px; height: 72px; border-radius: 22px;
  background: linear-gradient(145deg, #0ad168, #05a850);
  box-shadow: var(--sh-brand);
  position: relative;
}
.boot-logo::after, .login-logo::after {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M7 12.2A4.2 4.2 0 0 1 11.2 8h9.6A4.2 4.2 0 0 1 25 12.2v3.6a4.2 4.2 0 0 1-4.2 4.2h-4.3l-4.9 3.6a.55.55 0 0 1-.9-.45V20A4.2 4.2 0 0 1 7 15.8z' fill='white'/%3E%3Ccircle cx='13' cy='14' r='1.4' fill='%2307C160'/%3E%3Ccircle cx='19' cy='14' r='1.4' fill='%2307C160'/%3E%3C/svg%3E") center/56% no-repeat;
}
.boot-name { font-size: 20px; font-weight: 600; letter-spacing: .5px; color: var(--ink-2); }
.boot-tip { font-size: 13px; color: var(--ink-3); }
.boot-splash .boot-logo { animation: pulse 1.6s var(--ease) infinite; }
@keyframes pulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50%     { transform: scale(.94); opacity: .75; }
}

/* ============================ 登录页 ============================ */
.login-wrap {
  height: 100%; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1000px 520px at 12% -10%, rgba(7,193,96,.10), transparent 60%),
    radial-gradient(900px 480px at 92% 108%, rgba(7,193,96,.075), transparent 62%),
    var(--bg-app);
  padding: var(--s5);
  overflow-y: auto;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--bg-panel);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  border: 1px solid var(--line);
  padding: var(--s8) var(--s6) var(--s6);
  animation: rise var(--dur-slow) var(--ease-out);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
.login-head { display: flex; flex-direction: column; align-items: center; gap: var(--s3); margin-bottom: var(--s5); }
.login-logo { width: 64px; height: 64px; border-radius: 20px; }
.login-title { font-size: 22px; font-weight: 650; letter-spacing: .3px; }
.login-sub { font-size: 13px; color: var(--ink-3); text-align: center; margin-top: -6px; }

.field { margin-bottom: var(--s3); position: relative; }
.field-label {
  font-size: 12px; color: var(--ink-3); margin-bottom: 6px;
  font-weight: 500; letter-spacing: .2px;
}
.input {
  width: 100%; height: 44px; padding: 0 var(--s4);
  background: var(--bg-sunken);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  outline: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder { color: var(--ink-4); }
.input:hover { background: var(--bg-hover); }
.input:focus {
  background: var(--bg-panel);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.btn {
  height: 44px; padding: 0 var(--s5);
  border-radius: var(--r-md);
  font-weight: 600; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  user-select: none;
}
.btn:active { transform: scale(.978); }
.btn-primary { width: 100%; background: var(--brand); color: var(--on-brand); box-shadow: var(--sh-brand); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:disabled { background: var(--ink-4); box-shadow: none; cursor: not-allowed; }
.btn-ghost { background: var(--bg-hover); color: var(--ink-2); }
.btn-ghost:hover { background: var(--line); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: rgba(245,83,61,.18); }
.btn-sm { height: 34px; font-size: 13px; padding: 0 var(--s4); }

.login-switch { text-align: center; margin-top: var(--s5); font-size: 13px; color: var(--ink-3); }
.login-switch button { color: var(--brand); font-weight: 600; }

.login-foot {
  margin-top: var(--s5); padding-top: var(--s4);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 12px; color: var(--ink-3);
}
.login-foot .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.login-err {
  margin-bottom: var(--s3); padding: 10px var(--s3);
  background: var(--danger-soft); color: var(--danger);
  border-radius: var(--r-sm); font-size: 13px; display: none;
}
.login-err.show { display: block; animation: shake .32s var(--ease); }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-5px); } 75% { transform: translateX(5px); }
}

/* 加密说明条 */
.e2e-note {
  display: flex; gap: var(--s2); align-items: flex-start;
  padding: 10px var(--s3); margin-bottom: var(--s4);
  background: var(--brand-softer);
  border: 1px solid rgba(7,193,96,.16);
  border-radius: var(--r-sm);
  font-size: 12px; line-height: 1.55; color: var(--ink-2);
}
.e2e-note svg { flex: none; margin-top: 1px; }

/* ============================ 主框架 ============================ */
.app { display: flex; height: 100%; background: var(--bg-app); }

/* ---------- 左侧导航（PC） ---------- */
.rail {
  width: var(--rail-w); flex: none;
  background: var(--bg-rail);
  display: flex; flex-direction: column; align-items: center;
  padding: var(--s4) 0 var(--s3);
  gap: var(--s2);
  user-select: none;
}
.rail-avatar {
  width: 38px; height: 38px; border-radius: var(--r-md);
  margin-bottom: var(--s4); cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  transition: transform var(--dur) var(--ease);
  overflow: hidden; flex: none;
}
.rail-avatar:hover { transform: scale(1.06); }

.rail-btn {
  width: 44px; height: 44px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.5);
  position: relative;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.rail-btn:hover { background: var(--bg-rail-hi); color: rgba(255,255,255,.85); }
.rail-btn.active { color: var(--brand); background: var(--bg-rail-hi); }
.rail-btn.active::before {
  content: ''; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.rail-btn svg { width: 22px; height: 22px; }
.rail-spacer { flex: 1; }

.rail-badge {
  position: absolute; top: 5px; right: 5px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--danger); color: #fff;
  border-radius: var(--r-full);
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg-rail);
}

/* ---------- 中间列表栏 ---------- */
.list-panel {
  width: var(--list-w); flex: none;
  background: var(--bg-panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-width: 0; position: relative;
}
.list-head {
  height: var(--head-h); flex: none;
  display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--s3) 0 var(--s4);
  border-bottom: 1px solid var(--line);
}
.list-head-title { font-size: 16px; font-weight: 650; flex: 1; letter-spacing: .2px; }

.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  flex: none;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--ink-1); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 18px; height: 18px; }

.search-box {
  margin: var(--s3) var(--s3) var(--s2);
  height: 34px; border-radius: var(--r-sm);
  background: var(--bg-sunken);
  display: flex; align-items: center; gap: var(--s2);
  padding: 0 10px;
  transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  flex: none;
}
.search-box:focus-within { background: var(--bg-panel); box-shadow: 0 0 0 3px var(--brand-soft); }
.search-box svg { width: 15px; height: 15px; color: var(--ink-4); flex: none; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 13px; }
.search-box input::placeholder { color: var(--ink-4); }

.list-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: var(--s3); }

/* ---------- 会话行 ---------- */
.conv {
  display: flex; align-items: center; gap: var(--s3);
  padding: 10px var(--s4);
  cursor: pointer; position: relative;
  transition: background var(--dur) var(--ease);
}
.conv:hover { background: var(--bg-hover); }
.conv.active { background: var(--bg-active); }
.conv.active::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.conv.pinned { background: var(--bg-sunken); }
.conv.pinned:hover { background: var(--bg-hover); }

.avatar {
  width: 42px; height: 42px; border-radius: var(--r-md);
  flex: none; overflow: hidden; position: relative;
  background: var(--bg-sunken);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 15px;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar .online-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--brand); border: 2px solid var(--bg-panel);
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; border-radius: var(--r-sm); }
.avatar-xs { width: 24px; height: 24px; font-size: 10px; border-radius: var(--r-xs); }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; border-radius: var(--r-lg); }

.conv-body { flex: 1; min-width: 0; }
.conv-row1 { display: flex; align-items: baseline; gap: var(--s2); }
.conv-name {
  flex: 1; min-width: 0; font-size: 14.5px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-time { font-size: 11.5px; color: var(--ink-3); flex: none; font-variant-numeric: tabular-nums; }
.conv-row2 { display: flex; align-items: center; gap: var(--s2); margin-top: 3px; }
.conv-preview {
  flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-preview .tag { color: var(--danger); }

.badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--danger); color: #fff;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
  flex: none;
}
.badge.dot { min-width: 8px; width: 8px; height: 8px; padding: 0; }
.badge.mute { background: var(--ink-4); }
.pin-flag { color: var(--ink-4); flex: none; }
.pin-flag svg { width: 12px; height: 12px; }

/* ---------- 通讯录 ---------- */
.idx-bar {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 1px;
  font-size: 10px; color: var(--ink-3); font-weight: 600;
  user-select: none; z-index: 5; padding: 2px;
}
.idx-bar span {
  width: 16px; height: 14px; line-height: 14px; text-align: center;
  border-radius: var(--r-xs); cursor: pointer; transition: all var(--dur) var(--ease);
}
.idx-bar span:hover, .idx-bar span.on { background: var(--brand); color: #fff; }
/* 该字母下没有好友：仍然占位，但压暗且不可点，保持索引位置稳定 */
.idx-bar span.off { color: var(--ink-4); opacity: .45; cursor: default; }
.idx-bar span.off:hover { background: none; color: var(--ink-4); }

.sec-head {
  padding: 14px var(--s4) 6px;
  font-size: 12px; font-weight: 600; color: var(--ink-3);
  letter-spacing: .4px;
  position: sticky; top: 0;
  background: var(--bg-panel); z-index: 2;
}

.nav-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: 11px var(--s4); cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.nav-row:hover { background: var(--bg-hover); }
.nav-row .nav-ico {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex: none;
}
.nav-row .nav-ico svg { width: 19px; height: 19px; }
.nav-row .nav-label { flex: 1; font-size: 14.5px; }
.nav-row .nav-count { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- 主内容区 ---------- */
.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--bg-app);
  position: relative;
}
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--s4);
  color: var(--ink-4); user-select: none;
}
.empty-state .glyph {
  width: 96px; height: 96px; border-radius: 30px;
  background: var(--bg-hover);
  display: flex; align-items: center; justify-content: center;
}
.empty-state .glyph svg { width: 46px; height: 46px; opacity: .35; }
.empty-state .txt { font-size: 13.5px; }

/* ---------- 聊天头部 ---------- */
.chat-head {
  height: var(--head-h); flex: none;
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s4);
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
.chat-head .info { flex: 1; min-width: 0; cursor: pointer; }
.chat-head .title {
  font-size: 15.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-head .sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.chat-head .sub.typing { color: var(--brand); }

/* ---------- 消息区 ---------- */
.msgs {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: var(--s4) var(--s4) var(--s3);
  display: flex; flex-direction: column; gap: 2px;
  position: relative;
}
.msgs.drag-over::after {
  content: '松开即可发送文件';
  position: absolute; bottom: var(--s5); left: 50%; transform: translateX(-50%);
  padding: 10px var(--s5);
  background: var(--brand); color: #fff; border-radius: var(--r-md);
  font-size: 13px; font-weight: 600; text-align: center;
  box-shadow: var(--sh-brand); pointer-events: none;
}

.day-sep, .sys-msg {
  align-self: center; margin: var(--s3) 0;
  font-size: 11.5px; color: var(--ink-3);
}
.sys-msg {
  padding: 3px 10px; background: var(--bubble-sys);
  border-radius: var(--r-full); max-width: 78%; text-align: center; line-height: 1.5;
}
.day-sep { padding: 2px 10px; background: rgba(16,24,40,.045); border-radius: var(--r-full); }
[data-theme="dark"] .day-sep { background: rgba(255,255,255,.06); }

.unread-sep {
  align-self: center; margin: var(--s3) 0;
  font-size: 11.5px; color: var(--danger);
  display: flex; align-items: center; gap: var(--s2); width: 100%;
}
.unread-sep::before, .unread-sep::after {
  content: ''; flex: 1; height: 1px; background: rgba(245,83,61,.28);
}

.msg { display: flex; gap: 10px; margin-bottom: 10px; align-items: flex-start; }
.msg.me { flex-direction: row-reverse; }
.msg.grouped { margin-top: -6px; }
.msg.grouped .avatar { visibility: hidden; height: 0; }
.msg-body { max-width: min(64%, 520px); min-width: 0; display: flex; flex-direction: column; }
.msg.me .msg-body { align-items: flex-end; }
.msg-sender { font-size: 11.5px; color: var(--ink-3); margin-bottom: 3px; padding: 0 2px; }

.bubble {
  padding: 9px 13px;
  border-radius: var(--r-md);
  background: var(--bubble-other);
  color: var(--ink-1);
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: var(--sh-1);
  position: relative;
  line-height: 1.52;
}
.msg.me .bubble { background: var(--bubble-me); color: var(--bubble-me-ink); }
/*
 * 图片 / 表情不该套气泡底。
 * 注意权重：`.msg.me .bubble` 是 3 个类，这里必须也写满 3 个类
 * （`.msg .bubble.plain`），否则会被上面那条盖掉、绿色底框照旧。
 */
.msg .bubble.plain,
.msg .bubble.emoji-only {
  background: none; box-shadow: none; padding: 0;
}
.msg .bubble.emoji-only img { width: 96px; height: 96px; }
/* 图片/表情气泡里若带了引用块，仍要给一点内边距，别贴着边 */
.msg .bubble.plain .quote-block,
.msg .bubble.emoji-only .quote-block { margin-bottom: 6px; }
.bubble img.pic {
  max-width: 100%; max-height: 260px; border-radius: var(--r-sm);
  cursor: zoom-in; object-fit: cover;
}

/* 引用块 */
.quote-block {
  border-left: 3px solid rgba(0,0,0,.16);
  padding: 5px 8px; margin-bottom: 6px;
  background: rgba(0,0,0,.045);
  border-radius: 0 var(--r-xs) var(--r-xs) 0;
  font-size: 12.5px; color: var(--ink-2);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.quote-block:hover { background: rgba(0,0,0,.075); }
[data-theme="dark"] .quote-block { background: rgba(255,255,255,.07); }
[data-theme="dark"] .quote-block:hover { background: rgba(255,255,255,.11); }
.msg.me .quote-block { border-left-color: rgba(0,0,0,.2); background: rgba(255,255,255,.35); }
.quote-block .q-from { font-weight: 600; margin-bottom: 1px; }
.quote-block .q-text { opacity: .8; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* 文件卡片 */
.file-card { display: flex; align-items: center; gap: var(--s3); min-width: 220px; max-width: 300px; padding: 2px 0; }
.file-ico {
  width: 42px; height: 42px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 10px; font-weight: 700; flex: none; letter-spacing: .3px;
}
.file-meta { flex: 1; min-width: 0; }
.file-name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.msg.me .file-size { color: rgba(0,0,0,.45); }
[data-theme="dark"] .msg.me .file-size { color: rgba(255,255,255,.55); }
.file-dl {
  width: 30px; height: 30px; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.055); color: var(--ink-2); flex: none;
  transition: background var(--dur) var(--ease);
}
.file-dl svg { width: 16px; height: 16px; }
.file-dl:hover { background: rgba(0,0,0,.11); }

/* 撤回墓碑：居中一行灰字，和微信一致（不做成气泡，也不带时间） */
.msg.revoked { justify-content: center; margin: 6px 0; }
.msg.revoked .msg-body { max-width: 86%; align-items: center; }
.tombstone {
  font-size: 12.5px; color: var(--ink-3);
  padding: 2px 0; display: flex; align-items: center; gap: 6px;
}
.tombstone svg { width: 13px; height: 13px; flex: none; }
.tombstone .redo { color: var(--brand); cursor: pointer; margin-left: 4px; font-weight: 600; }
.tombstone .redo:hover { text-decoration: underline; }

/* 加密标识 */
.lock-tag {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; color: var(--ink-4); margin-top: 3px; padding: 0 2px;
}
.lock-tag svg { width: 10px; height: 10px; }
.lock-tag.warn { color: var(--warn); }

/* @我 */
.bubble.mention-me { box-shadow: 0 0 0 2px var(--danger), var(--sh-1); }
.mention-chip { color: var(--brand); font-weight: 600; }
.msg.me .mention-chip { color: #0a7a3c; }
[data-theme="dark"] .mention-chip { color: #4ade80; }

/* 消息状态 */
.msg-foot {
  display: flex; align-items: center; gap: 6px;
  margin-top: 4px; font-size: 11px; color: var(--ink-4); padding: 0 2px;
}
.msg.me .msg-foot { justify-content: flex-end; }
.msg-foot .read { color: var(--brand); }
.msg-foot .fail { color: var(--danger); cursor: pointer; font-weight: 600; }
.spin {
  width: 11px; height: 11px; border-radius: 50%;
  border: 1.5px solid var(--ink-4); border-top-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 输入区 ---------- */
.composer { flex: none; border-top: 1px solid var(--line); background: var(--bg-panel); display: flex; flex-direction: column; position: relative; }
.composer-tools { display: flex; align-items: center; gap: 2px; padding: 6px var(--s3) 0; }
.tool-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.tool-btn:hover { background: var(--bg-hover); color: var(--brand); }
.tool-btn:active { transform: scale(.92); }
.tool-btn.on { color: var(--brand); background: var(--brand-soft); }
.tool-btn svg { width: 19px; height: 19px; }
.composer-tools .spacer { flex: 1; }

.composer-input { padding: 6px var(--s4) var(--s3); }
.composer-input textarea {
  width: 100%; min-height: 40px; max-height: 140px;
  border: 0; outline: none; resize: none; background: none;
  font-size: 14.5px; line-height: 1.55; font-family: inherit;
}
.composer-input textarea::placeholder { color: var(--ink-4); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.composer-hint { font-size: 11.5px; color: var(--ink-4); }

.send-btn {
  height: 32px; padding: 0 var(--s4); border-radius: var(--r-sm);
  background: var(--brand); color: #fff; font-size: 13.5px; font-weight: 600;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.send-btn:hover { background: var(--brand-hover); }
.send-btn:active { transform: scale(.96); }
.send-btn:disabled { background: var(--ink-4); cursor: not-allowed; }

/* @提及浮层 */
.mention-pop {
  position: absolute; bottom: 100%; left: var(--s4);
  width: 240px; max-height: 260px; overflow-y: auto;
  background: var(--bg-panel); border-radius: var(--r-md);
  box-shadow: var(--sh-3); border: 1px solid var(--line);
  padding: var(--s1); z-index: 60;
  animation: pop var(--dur) var(--ease-out);
}
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.mention-item {
  display: flex; align-items: center; gap: var(--s2);
  padding: 7px var(--s2); border-radius: var(--r-sm); cursor: pointer; font-size: 13.5px;
}
.mention-item:hover, .mention-item.on { background: var(--bg-active); }

/* 表情面板 */
.emoji-panel { height: 0; overflow: hidden; border-top: 1px solid var(--line); transition: height var(--dur-slow) var(--ease-out); }
.emoji-panel.open { height: 236px; }
.emoji-tabs { display: flex; gap: var(--s1); padding: var(--s2) var(--s3) 0; border-bottom: 1px solid var(--line); }
.emoji-tab { padding: 5px 10px; font-size: 12.5px; color: var(--ink-3); border-radius: var(--r-sm) var(--r-sm) 0 0; font-weight: 500; }
.emoji-tab.on { color: var(--brand); background: var(--brand-softer); }
.emoji-grid {
  height: 192px; overflow-y: auto; padding: var(--s3);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: var(--s2); align-content: start;
}
.emoji-cell {
  aspect-ratio: 1; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
  position: relative;
}
.emoji-cell:hover { background: var(--bg-hover); transform: scale(1.08); }
.emoji-cell img { width: 34px; height: 34px; }
.emoji-cell .del {
  position: absolute; top: -3px; right: -3px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--danger); color: #fff; font-size: 10px; line-height: 15px; text-align: center;
  display: none;
}
.emoji-cell:hover .del { display: block; }

/* ---------- 右键菜单 ---------- */
.context-menu {
  position: fixed; z-index: 200;
  min-width: 168px; padding: var(--s1);
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3); border: 1px solid var(--line);
  animation: pop .13s var(--ease-out);
}
.ctx-item {
  display: flex; align-items: center; gap: var(--s2);
  padding: 7px 10px; border-radius: var(--r-xs);
  font-size: 13.5px; cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: var(--danger-soft); }
.ctx-item svg { width: 15px; height: 15px; color: var(--ink-3); }
.ctx-item.danger svg { color: var(--danger); }
.ctx-sep { height: 1px; background: var(--line); margin: var(--s1) 0; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 300;
  background: var(--bg-mask);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s5);
  animation: fade .18s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 400px; max-height: 84vh;
  background: var(--bg-panel); border-radius: var(--r-xl);
  box-shadow: var(--sh-3); border: 1px solid var(--line);
  display: flex; flex-direction: column;
  animation: rise var(--dur-slow) var(--ease-out);
  overflow: hidden;
}
.modal.wide { max-width: 560px; }
.modal-head { padding: var(--s5) var(--s5) var(--s3); font-size: 17px; font-weight: 650; flex: none; }
.modal-body { padding: 0 var(--s5) var(--s4); overflow-y: auto; flex: 1; }
.modal-foot { padding: var(--s3) var(--s5) var(--s5); display: flex; gap: var(--s3); justify-content: flex-end; flex: none; }
.modal-foot .btn { min-width: 84px; }
.modal-desc { font-size: 13px; color: var(--ink-3); margin-bottom: var(--s4); line-height: 1.6; }

.pick-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: 9px var(--s2); border-radius: var(--r-sm); cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.pick-row:hover { background: var(--bg-hover); }
.pick-row.on { background: var(--brand-softer); }
.pick-row .nm { flex: 1; min-width: 0; font-size: 14px; }
.check {
  width: 19px; height: 19px; border-radius: var(--r-full);
  border: 1.5px solid var(--line-strong); flex: none;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--dur) var(--ease);
}
.pick-row.on .check { background: var(--brand); border-color: var(--brand); }
.check svg { width: 12px; height: 12px; color: #fff; opacity: 0; }
.pick-row.on .check svg { opacity: 1; }

.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: var(--s3); margin-bottom: var(--s3); }
.avatar-pick {
  aspect-ratio: 1; border-radius: var(--r-md); cursor: pointer;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  overflow: hidden; position: relative;
}
.avatar-pick:hover { transform: scale(1.07); }
.avatar-pick.on { box-shadow: 0 0 0 3px var(--brand); }
.avatar-pick img { width: 100%; height: 100%; object-fit: cover; }

.res-row { display: flex; align-items: center; gap: var(--s3); padding: 9px var(--s4); cursor: pointer; transition: background var(--dur) var(--ease); }
.res-row:hover { background: var(--bg-hover); }
.res-body { flex: 1; min-width: 0; }
.res-name { font-size: 14px; font-weight: 500; }
.res-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }

.safety-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px; letter-spacing: 1.5px; line-height: 2;
  text-align: center; padding: var(--s4);
  background: var(--bg-sunken); border-radius: var(--r-md);
  white-space: pre-wrap; word-break: break-all;
  color: var(--ink-1); font-weight: 600;
}

/* ---------- Toast ---------- */
.toast-wrap {
  /* 压在标题栏下方，别把会话名挡住 */
  position: fixed; top: calc(var(--head-h) + var(--s3)); left: 50%; transform: translateX(-50%);
  z-index: 500; display: flex; flex-direction: column; gap: var(--s2);
  align-items: center; pointer-events: none;
}
.toast {
  padding: 9px var(--s4); border-radius: var(--r-md);
  background: rgba(20,22,26,.9); color: #fff;
  font-size: 13.5px; box-shadow: var(--sh-2);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  animation: toastIn .22s var(--ease-out);
  max-width: 78vw; text-align: center;
}
.toast.ok { background: rgba(7,193,96,.94); }
.toast.err { background: rgba(245,83,61,.94); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px) scale(.96); } to { opacity: 1; transform: none; } }

/* ---------- 连接状态条 ---------- */
.conn-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 400;
  padding: 7px; text-align: center; font-size: 12.5px; font-weight: 500;
  background: var(--warn); color: #3a2a05;
  transform: translateY(-100%);
  transition: transform var(--dur-slow) var(--ease-out);
}
.conn-bar.show { transform: none; }
.conn-bar.ok { background: var(--brand); color: #fff; }

/* ---------- 更新提示 ---------- */
.update-bar {
  position: fixed; bottom: var(--s5); left: 50%; transform: translateX(-50%);
  z-index: 450;
  display: flex; align-items: center; gap: var(--s3);
  padding: 10px var(--s3) 10px var(--s4);
  background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: var(--r-full); box-shadow: var(--sh-3);
  font-size: 13.5px;
  animation: rise var(--dur-slow) var(--ease-out);
}
.update-bar .dot-live {
  width: 7px; height: 7px; border-radius: 50%; background: var(--brand);
  animation: ping 1.8s var(--ease) infinite;
}
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(7,193,96,.5); }
  100% { box-shadow: 0 0 0 10px rgba(7,193,96,0); }
}

/* ---------- 图片查看器 ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,.9);
  display: flex; align-items: center; justify-content: center;
  animation: fade .18s var(--ease);
}
.viewer img { max-width: 94vw; max-height: 92vh; border-radius: var(--r-sm); }
.viewer .close {
  position: absolute; top: var(--s4); right: var(--s4);
  width: 38px; height: 38px; border-radius: var(--r-full);
  background: rgba(255,255,255,.14); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.viewer .close svg { width: 20px; height: 20px; }
.viewer .close:hover { background: rgba(255,255,255,.24); }

/* ---------- 通话界面 ---------- */
.call-layer {
  position: fixed; inset: 0; z-index: 600;
  background: linear-gradient(170deg, #1b2430, #0d1117 70%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: #fff; gap: var(--s5);
  animation: fade .22s var(--ease);
}
.call-avatar {
  width: 104px; height: 104px; border-radius: var(--r-full);
  overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.5);
  position: relative; background: #2a3038;
  display: flex; align-items: center; justify-content: center; font-size: 36px;
}
.call-avatar img { width: 100%; height: 100%; object-fit: cover; }
/* 通话头像是个大圆，里面套的 .avatar 要撑满，否则只有 42px 一小块 */
.call-avatar .avatar { width: 100%; height: 100%; border-radius: var(--r-full); font-size: 36px; }
.call-avatar.ringing::after {
  content: ''; position: absolute; inset: -12px; border-radius: var(--r-full);
  border: 2px solid rgba(7,193,96,.5);
  animation: ring 1.6s var(--ease) infinite;
}
@keyframes ring {
  0% { transform: scale(1); opacity: .85; }
  100% { transform: scale(1.22); opacity: 0; }
}
.call-name { font-size: 21px; font-weight: 600; }
.call-status { font-size: 14px; opacity: .68; font-variant-numeric: tabular-nums; }
.call-actions { display: flex; gap: var(--s6); margin-top: var(--s6); }
.call-btn {
  width: 62px; height: 62px; border-radius: var(--r-full);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: #fff; font-size: 10px;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.call-btn:active { transform: scale(.93); }
.call-btn svg { width: 24px; height: 24px; }
.call-btn.accept { background: var(--brand); }
.call-btn.reject { background: var(--danger); }
.call-btn.neutral { background: rgba(255,255,255,.14); }
.call-btn.neutral.on { background: #fff; color: #14161a; }

/* ---------- 移动端 ---------- */
.tabbar {
  display: none;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
  flex: none;
}
.tabbar-inner { display: flex; height: var(--tab-h); }
.tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-3); font-size: 10.5px; position: relative;
  transition: color var(--dur) var(--ease);
}
.tab.on { color: var(--brand); }
.tab svg { width: 23px; height: 23px; }
.tab .badge { position: absolute; top: 4px; left: 50%; margin-left: 4px; }

/* 移动端断点 */
@media (max-width: 820px) {
  :root { --head-h: 52px; --list-w: auto; }

  .app { flex-direction: column; position: relative; }
  .rail { display: none; }
  .tabbar {
    display: block;
    position: absolute; left: 0; right: 0; bottom: 0;
    z-index: 40;
  }

  /* 列表与聊天区都要给底部导航栏让出高度（含 iPhone 安全区），
     否则 inset:0 会把 tabbar 完全盖住，手机上没有入口切页 */
  .list-panel {
    width: 100%; border-right: 0;
    position: absolute; top: 0; left: 0; right: 0;
    bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
    z-index: 20;
  }
  .main {
    position: absolute; top: 0; left: 0; right: 0;
    bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
    z-index: 30;
    transform: translateX(100%);
    transition: transform var(--dur-slow) var(--ease-out);
  }
  .main.show { transform: none; }

  /* 进入会话后聊天区铺满整屏，底部导航让位给输入框。
     in-chat 挂在 body 上（renderLogin 也会清掉它） */
  body.in-chat .main { bottom: 0; }
  body.in-chat .tabbar { display: none; }

  .msg-body { max-width: 78%; }
  .msg .bubble.emoji-only img { width: 76px; height: 76px; }
  .list-head { padding-left: var(--s4); }
  .modal-mask { padding: var(--s3); align-items: flex-end; }
  .modal { max-width: 100%; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 88vh; }
  .update-bar { bottom: calc(var(--tab-h) + var(--s4)); }
  .emoji-panel.open { height: 216px; }
  .emoji-grid { height: 172px; }
}

/* 触屏优化 */
@media (hover: none) {
  .conv:hover, .nav-row:hover, .res-row:hover { background: none; }
  .tool-btn:hover { background: none; color: var(--ink-3); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
