/* LiteChat —— 扁平工具风界面
 *
 * 设计取向：像桌面端 IM 客户端，不像营销页。
 *   · 只有浅色一种主题（不跟随系统深色）
 *   · 无渐变、无阴影、无光晕，层次全部靠 1px 描边和中性灰底
 *   · 圆角克制（4-8px），信息密度优先
 *   · 灰一律中性灰（不带蓝紫倾向），彩色只留给主色与状态
 *
 * 设计约束：
 *   1. CSP 是 default-src 'self'，不能用外部字体 → 系统字体栈
 *   2. 零构建，纯 CSS 变量驱动，改色只改下面这一块
 *   3. 对比度按 WCAG AA（4.5:1）核算，见 test/contrast.test.js
 */

/* ==================== 设计令牌 ==================== */
:root {
  color-scheme: light;

  /* 表面：中性灰，不带蓝 */
  --bg: #ffffff;
  --bg-app: #f5f5f5;          /* 聊天区底色 */
  --bg-sidebar: #fafafa;
  --surface: #ffffff;
  --surface-2: #f0f0f0;
  --hover: #ededed;
  --border: #e0e0e0;

  /* 文字 */
  --text: #1a1a1a;
  --muted: #666666;

  /* 主色 */
  --primary: #0f6fce;
  --primary-hover: #0b5dad;
  --primary-soft: #e8f1fb;
  --primary-ink: #0b5dad;
  --on-primary: #ffffff;

  /* 气泡 */
  --bubble-mine: #0f6fce;
  --bubble-mine-ink: #ffffff;
  --bubble-theirs: #ffffff;
  --bubble-theirs-ink: #1a1a1a;

  /* 状态色 */
  --online: #1f9d63;
  --danger: #c8382f;
  --danger-soft: #fdecea;
  --warn-bg: #8a5a12;
  --warn-ink: #ffffff;
  --toast-bg: #333333;
  --toast-ink: #ffffff;

  /* 形状：克制的小圆角 */
  --radius-sm: 3px;
  --radius: 4px;
  --radius-lg: 6px;
  --radius-bubble: 8px;
  --radius-pill: 999px;

  /* 层级 */
  --z-sticky: 10;
  --z-banner: 40;
  --z-modal: 50;
  --z-lightbox: 60;
  --z-toast: 70;

  --dur: 150ms;
  --ease: ease;
}

/* ==================== 基础 ==================== */
* { box-sizing: border-box; }
html, body { height: 100%; }
/* 移动端防「摇晃」：禁止整页橡皮筋回弹与下拉刷新（消息列表自己的滚动不受影响） */
html, body { overscroll-behavior: none; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  /* 去掉触屏点按时的灰色高亮闪块 */
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
/* 可点元素禁用双击缩放：连点发送/图标不再触发页面忽大忽小 */
button, a, [role="button"] { touch-action: manipulation; }
.view[hidden], .modal[hidden], #lightbox[hidden], #toast[hidden], [hidden] { display: none !important; }

/* 键盘可达性：可聚焦元素都有焦点环 */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* 细滚动条 */
.user-list, #msg-list { scrollbar-width: thin; scrollbar-color: #c8c8c8 transparent; }
.user-list::-webkit-scrollbar, #msg-list::-webkit-scrollbar { width: 8px; }
.user-list::-webkit-scrollbar-thumb, #msg-list::-webkit-scrollbar-thumb {
  background: #c8c8c8;
  border-radius: var(--radius-pill);
}
.user-list::-webkit-scrollbar-thumb:hover, #msg-list::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }
.user-list::-webkit-scrollbar-track, #msg-list::-webkit-scrollbar-track { background: transparent; }

/* ==================== 登录 / 注册 ==================== */
#view-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  padding: 16px;
}
.auth-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 22px;
}
.brand {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  margin-bottom: 18px;
}
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px 0;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-ink); border-bottom-color: var(--primary); font-weight: 600; }
form { display: grid; gap: 10px; }
input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 11px;
  font: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--dur) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
/* 焦点环交给全局 :focus-visible 的 outline 处理，这里只加深描边 */
input:focus, textarea:focus {
  border-color: var(--primary);
}
.form-err { color: var(--danger); font-size: 13px; min-height: 18px; }
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 14px;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 13px; transition: color var(--dur) var(--ease); }
.link:hover { color: var(--primary-ink); }

/* ==================== 主布局：PC 双栏 ==================== */
#view-chat { display: flex; height: 100vh; height: 100dvh; }

#sidebar {
  width: 280px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
}

/* 侧栏顶部 */
.side-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.me-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#me-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-actions { display: flex; gap: 10px; align-items: baseline; }
.me-actions a.link { text-decoration: none; }

/* ==================== 会话列表 ==================== */
.user-list { flex: 1; overflow-y: auto; padding: 4px; }
.conv {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  color: inherit;
  transition: background var(--dur) var(--ease);
}
.conv:hover { background: var(--hover); }
.conv.active { background: var(--primary-soft); }
/* 选中态左侧的强调条 */
.conv.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--primary);
}
.conv-main { flex: 1; min-width: 0; }
.conv-name {
  display: flex;
  align-items: center;
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-preview {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: none; }
.conv-time { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.badge {
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-variant-numeric: tabular-nums;
}

/* ==================== 头像 ==================== */
.avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: #d8d8d8;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  flex: none;
  position: relative;
  user-select: none;
}
/* 自定义头像：图片铺满并继承圆角 */
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.avatar.sm { width: 34px; height: 34px; font-size: 14px; }
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }
/* 侧栏自己的头像可点击打开账号设置 */
#me-avatar { cursor: pointer; }
#me-avatar:hover, #me-avatar:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
/* 消息行里的头像 */
.avatar.msg-av { width: 34px; height: 34px; font-size: 14px; margin-top: 1px; }
.dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #b0b0b0;
  border: 2px solid var(--bg-sidebar);
}
.dot.on { background: var(--online); }

/* ==================== 聊天区 ==================== */
#chat-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
}
#chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: var(--z-sticky);
}
.peer-meta { min-width: 0; display: flex; flex-direction: column; }
#peer-name { font-weight: 600; font-size: 14.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { font-size: 12px; color: var(--muted); }
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: 0;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--hover); color: var(--primary-ink); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
#btn-back { display: none; }
/* 搜索按钮贴右侧，与左侧返回按钮形成对称 */
#btn-search { margin-left: auto; }

/* ==================== 消息列表 ==================== */
#msg-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 8px;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
}
.day-chip {
  align-self: center;
  background: #e4e4e4;
  color: var(--muted);
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  margin: 12px 0 4px;
  user-select: none;
}
.empty { margin: auto; color: var(--muted); font-size: 13px; padding: 40px 0; text-align: center; }

.msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
}
.msg.mine { flex-direction: row-reverse; }
/* 连续同一方的消息收紧间距 */
.msg.mine + .msg.mine,
.msg.theirs + .msg.theirs { margin-top: 4px; }

.bubble-wrap { max-width: min(64%, 520px); display: flex; flex-direction: column; min-width: 0; }
.bubble {
  position: relative;
  padding: 8px 11px;
  border-radius: var(--radius-bubble);
  background: var(--bubble-theirs);
  color: var(--bubble-theirs-ink);
  overflow-wrap: anywhere;
  line-height: 1.55;
}
/* 尖角 */
.bubble::before {
  content: '';
  position: absolute;
  top: 10px;
  width: 8px;
  height: 8px;
  background: inherit;
  transform: rotate(45deg);
}
.msg.theirs .bubble { border-top-left-radius: 2px; }
.msg.theirs .bubble::before { left: -3px; }
.msg.mine .bubble {
  background: var(--bubble-mine);
  color: var(--bubble-mine-ink);
  border-top-right-radius: 2px;
}
.msg.mine .bubble::before { right: -3px; }

/* 文本消息：保留换行与连续空格 */
.msg-text { white-space: pre-wrap; }

.msg-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: flex-start;
  padding: 0 2px;
}
.msg.mine .msg-meta { justify-content: flex-end; }
.read-state { font-variant-numeric: tabular-nums; }

/* 新消息入场 */
@keyframes msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.msg.enter { animation: msg-in 150ms var(--ease) both; }

/* 媒体气泡 */
.bubble img.pic {
  display: block;
  max-width: min(260px, 58vw);
  max-height: 260px;
  border-radius: var(--radius);
  cursor: zoom-in;
  background: var(--surface-2);
}
.bubble-video { display: block; max-width: min(320px, 62vw); border-radius: var(--radius); background: #000; }
.bubble:has(img.pic), .bubble:has(.bubble-video) { padding: 3px; }
.bubble:has(img.pic)::before, .bubble:has(.bubble-video)::before { top: 14px; }

.file-card { display: flex; align-items: center; gap: 9px; min-width: 180px; color: inherit; text-decoration: none; }
.file-card svg { flex: none; opacity: .85; }
.file-card .fname { font-weight: 500; overflow-wrap: anywhere; }
.file-card .fsize { font-size: 11.5px; opacity: .8; }
.msg.mine .file-card { color: var(--bubble-mine-ink); }

/* 语音条 */
.audio { display: flex; align-items: center; gap: 9px; min-width: 180px; }
.audio .pbtn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.msg.theirs .audio .pbtn { background: var(--primary-soft); color: var(--primary-ink); }
.msg.mine   .audio .pbtn { background: rgba(255, 255, 255, .24); color: var(--bubble-mine-ink); }
.audio .track { flex: 1; height: 4px; border-radius: var(--radius-pill); background: currentColor; opacity: .22; overflow: hidden; }
.audio .fill { display: block; height: 100%; width: 0; background: currentColor; border-radius: var(--radius-pill); }
.msg.theirs .audio { color: var(--primary-ink); }
.msg.mine   .audio { color: var(--bubble-mine-ink); }
.audio .dur { font-size: 11.5px; font-variant-numeric: tabular-nums; opacity: .85; flex: none; }

/* 「对方正在输入」 */
.typing-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 18px 8px;
  font-size: 12px;
  color: var(--muted);
  min-height: 22px;
}
.typing-dots { display: inline-flex; gap: 3px; align-items: center; }
.typing-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.2s var(--ease) infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* ==================== 输入区（单行式：加号 / 输入框 / 工具 / 发送） ==================== */
#composer {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--surface);
  /* 底部安全区（全面屏手势条）放最外层，内部行高不受影响 */
  padding-bottom: env(safe-area-inset-bottom);
}
/* 主行：输入框占满，工具与发送贴右侧；多行时底对齐 */
.composer-main {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 10px 4px;
}
.composer-main > .icon-btn,
.composer-main > .btn { flex: none; }
#btn-plus { display: none; }   /* 附件工具桌面常驻内联，加号只在手机端出现 */
.composer-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}
.composer-tools .icon-btn { width: 32px; height: 32px; }
#input-msg {
  flex: 1;
  min-width: 0;
  resize: none;
  min-height: 38px;
  max-height: 200px;
  border-radius: var(--radius);
  padding: 8px 10px;
  margin: 0;
  background: var(--surface);
}
.composer-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 12px 5px;
}
.composer-hint { font-size: 11px; color: var(--muted); user-select: none; }
#btn-send {
  border-radius: var(--radius);
  padding: 6px 16px;
  flex: none;
  height: 38px;
}
#composer.is-disabled { opacity: .55; }
#composer.is-disabled textarea,
#composer.is-disabled button { cursor: not-allowed; }

/* 回复条：点「回复」后出现在输入框上方 */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
}
.reply-bar svg { flex: none; }
.reply-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== 弹层 ==================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 16px;
  /* 内容比屏幕高时（手机端账号设置）弹层自己滚动，不让整页跟着晃 */
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.modal-card {
  /* auto margin：内容矮时居中，高时贴边且顶部不被裁掉，配合弹层滚动 */
  margin: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  width: min(92vw, 400px);
  display: grid;
  gap: 12px;
}
.modal-card h3 { margin: 0; display: flex; align-items: center; gap: 7px; font-size: 15px; }
#rec-preview, #rec-stage-done video { width: 100%; border-radius: var(--radius); background: #000; max-height: 46vh; }
#rec-stage-done audio { width: 100%; }
#rec-timer { text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: inline-block; }

#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-lightbox);
  cursor: zoom-out;
}
#lightbox img { max-width: 94vw; max-height: 90vh; border-radius: var(--radius); }
.lightbox-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: var(--radius);
  background: transparent;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .15); }
.lightbox-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ==================== 全局提示 ==================== */
#offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-banner);
  padding: 8px 14px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 12.5px;
  text-align: center;
}
#offline-banner[hidden] { display: none !important; }

#toast {
  position: fixed;
  left: 50%;
  /* 抬高到输入区之上，避免提示条压在输入框上 */
  bottom: 84px;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: var(--toast-ink);
  padding: 9px 14px;
  border-radius: var(--radius);
  z-index: var(--z-toast);
  font-size: 13px;
  max-width: 86vw;
  pointer-events: none; /* 纯提示，不该挡住底下的点击 */
}

/* ==================== 被禁用的账号 ==================== */
.conv.disabled .conv-name { color: var(--muted); }
.conv.disabled .avatar { opacity: .5; }
.tag-disabled {
  margin-left: 5px;
  padding: 0 5px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 11px;
  flex: none;
}

/* ==================== 移动端：单栏切换 ==================== */
@media (max-width: 768px) {
  /* 聊天视图激活时锁死整页：文档不可拖动，彻底消除橡皮筋回弹。
     :has 不支持时只是不锁定，无副作用。 */
  body:has(#view-chat:not([hidden])) { position: fixed; inset: 0; overflow: hidden; }

  #sidebar, #chat-panel { position: fixed; inset: 0; width: 100%; }
  #chat-panel { display: none; }
  body.mobile-chat #sidebar { display: none; }
  body.mobile-chat #chat-panel { display: flex; }
  #btn-back { display: inline-flex; }

  /* 触控目标不小于 44px */
  .icon-btn { width: 44px; height: 44px; }
  .composer-main { gap: 4px; padding: 6px 8px 6px; flex-wrap: wrap; }
  /* 附件工具默认折叠成第二行，点加号展开 */
  #btn-plus { display: inline-flex; }
  .composer-tools { display: none; flex-basis: 100%; gap: 6px; padding: 2px 2px 0; }
  body.tools-open .composer-tools { display: flex; }
  .composer-tools .icon-btn { width: 40px; height: 40px; }
  .composer-foot { display: none; } /* 触屏没有 Ctrl 键，快捷键提示没有意义 */
  .bubble-wrap { max-width: 78%; }
  #msg-list { padding: 10px 10px 6px; }
  #btn-send { height: 40px; padding: 8px 14px; }

  /* 长按消息弹操作按钮时不触发系统文字选择（放大镜/选区/系统菜单），
     与自定义长按菜单打架正是「摇晃感」的主要来源；复制走操作按钮里的「复制」 */
  #msg-list {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  /* 移动端正文不小于 16px，避免 iOS 聚焦输入框时自动放大 */
  #input-msg, .bubble { font-size: 16px; }
  /* 所有输入控件同理（登录页、账号设置弹层、搜索框）：
     iOS 对字号 <16px 的输入框聚焦时会强制放大整页且不自动还原，正是「摇晃感」的来源 */
  input, textarea, select { font-size: 16px; }
  /* 覆盖上面两条 ID 选择器的 13px（ID 优先级高于元素选择器） */
  #conv-filter, #search-input { font-size: 16px; }
}

/* ==================== 降低动效偏好 ==================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ==================== 注册关闭提示 ==================== */
.reg-closed {
  margin: 14px 0 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

/* 注册表单：手机号 + 验证码一行 */
.sms-code-row { display: flex; gap: 8px; align-items: stretch; }
.sms-code-row input { flex: 1; min-width: 0; }
.sms-code-row .btn { flex: none; padding: 8px 12px; font-size: 13px; white-space: nowrap; }
.sms-code-row .btn:disabled { opacity: .6; cursor: not-allowed; }

/* ==================== 会话过滤框 + 添加好友 ==================== */
.conv-filter-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
}
#conv-filter {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  font-size: 13px;
  background: var(--surface);
}
#btn-add-friend { position: relative; flex: none; width: 32px; height: 32px; }
/* 有待处理申请时的红点 */
#btn-add-friend.has-req::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--bg-sidebar);
}

/* 软标签：置顶 / 静音 / 当前设备 */
.tag-soft {
  margin-left: 5px;
  padding: 0 5px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  flex: none;
}
.conv-name .tag-soft { border: 1px solid var(--border); }

/* 免打扰会话的未读角标：灰色而不是红色（#767676 上白字仍满足 4.5:1） */
.badge.muted { background: #767676; color: #fff; }

/* 会话行上的 ⋯ 按钮 */
.conv-more {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex: none;
}
.conv-more:hover, .conv-more:focus-visible { background: var(--border); color: var(--text); }

/* ==================== 右键 / ⋯ 菜单 ==================== */
.ctx-menu {
  position: fixed;
  z-index: var(--z-modal);
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.ctx-item {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.ctx-item:hover, .ctx-item:focus-visible { background: var(--hover); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover, .ctx-item.danger:focus-visible { background: var(--danger-soft); }

/* ==================== 会话内搜索 ==================== */
.search-panel {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  max-height: 46vh;
}
.search-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px 4px;
}
#search-input { font-size: 13px; }
.search-results {
  overflow-y: auto;
  padding: 4px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.search-empty { color: var(--muted); font-size: 12.5px; padding: 10px 8px; text-align: center; }
.search-item {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 7px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.search-item:hover, .search-item:focus-visible { background: var(--hover); }
.search-item-head { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--muted); }
.search-item-who { color: var(--primary-ink); font-weight: 500; }
.search-item-body {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== 消息操作按钮 ==================== */
.msg-actions {
  display: none;
  align-items: center;
  gap: 1px;
  align-self: center;
  flex: none;
}
/* 桌面悬停显示；触屏用长按（JS 加 show-actions）*/
@media (hover: hover) {
  .msg:hover .msg-actions, .msg:focus-within .msg-actions { display: inline-flex; }
}
.msg.show-actions .msg-actions { display: inline-flex; }
.msg-act {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.msg-act:hover, .msg-act:focus-visible { background: var(--hover); color: var(--primary-ink); }
.msg-act svg { width: 14px; height: 14px; }

/* 搜索/跳转命中高亮 */
@keyframes msg-flash {
  0% { background: var(--primary-soft); }
  100% { background: transparent; }
}
.msg.flash { animation: msg-flash 1.6s var(--ease) both; border-radius: var(--radius); }

/* ==================== 引用块（回复） ==================== */
.reply-quote {
  margin: 0 0 5px;
  padding: 4px 8px;
  border-left: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
}
.reply-quote:hover { background: var(--hover); }
.msg.theirs .reply-quote { background: var(--surface-2); }
.msg.theirs .reply-who { color: var(--primary-ink); }
.msg.theirs .reply-snippet { color: var(--muted); }
.msg.mine .reply-quote { background: rgba(255, 255, 255, .18); border-left-color: var(--bubble-mine-ink); }
.msg.mine .reply-who { color: var(--bubble-mine-ink); }
.msg.mine .reply-snippet { color: var(--bubble-mine-ink); opacity: .8; }
.reply-who { font-size: 11.5px; font-weight: 600; }
.reply-snippet {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 已撤回的消息 */
.bubble.is-recalled {
  color: var(--muted);
  font-style: italic;
  font-size: 12.5px;
}

/* ==================== 拖拽发送反馈 ==================== */
#chat-panel.drag-over::after {
  content: '松开以发送文件';
  position: absolute;
  inset: 10px;
  border: 2px dashed var(--primary);
  border-radius: var(--radius-lg);
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: var(--z-sticky);
}
#chat-panel { position: relative; }

/* ==================== 选择列表（转发） ==================== */
.pick-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 46vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
}
.pick-item {
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
}
.pick-item:hover, .pick-item:focus-visible { background: var(--hover); }
.pick-name { color: var(--text); font-size: 13.5px; }
/* 好友申请/搜索结果行：名称 + @用户名 + 右侧操作按钮 */
.pick-item { cursor: default; }
.pick-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pick-sub { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-actions { display: flex; gap: 6px; flex: none; align-items: center; }
.btn.small { padding: 4px 10px; height: 28px; font-size: 12.5px; }

/* ==================== 账号设置弹层 ==================== */
.modal-divider { border-top: 1px solid var(--border); }
.field-label { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.hint-text { margin: 0; font-size: 12px; color: var(--muted); }
.avatar-row { display: flex; align-items: center; gap: 14px; }
.avatar-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.btn.danger {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 600;
}
.btn.danger:hover { background: var(--danger); color: #fff; }

/* ==================== 我的设备 ==================== */
.devices-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 46vh;
  overflow-y: auto;
}
.device-row {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 11px;
}
.device-row.current { border-color: var(--primary); background: var(--primary-soft); }
.device-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.device-name { font-size: 13.5px; color: var(--text); display: flex; align-items: center; }
.device-sub { font-size: 12px; color: var(--muted); }

/* 通知 / 声音开关（侧栏链接式按钮的激活态） */
#btn-notify.on, #btn-sound.on { color: var(--primary-ink); font-weight: 600; }
