/* 律调（LiteChat）—— 清爽版界面（参考用户提供的 PC/手机端示例）
 *
 * 设计语言：
 *   · 柔和灰蓝的世界：底 #f2f5f9，白卡片，蓝调浅灰（不再是纯中性灰）
 *   · 对方气泡浅灰蓝、自己气泡淡天蓝，深色文字（不再蓝底白字）
 *   · 圆形头像、药丸输入、圆形图标按钮、大气泡圆角 + 尾部小尖角
 *   · PC 端悬浮圆角卡片居中；手机端全屏单栏
 *   · 允许非常轻的柔和阴影（层次仍以描边为主）
 *   · 只有浅色主题，无渐变
 *
 * 约束：CSP default-src 'self'（系统字体栈）；零构建；
 *       对比度按 WCAG AA 核算，见 test/contrast.test.js
 */

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

  /* 表面：蓝调浅灰 */
  --bg: #f2f5f9;            /* 页面底色（卡片外） */
  --bg-sidebar: #fafcff;    /* 侧栏 */
  --surface: #ffffff;       /* 卡片/头部/输入区 */
  --surface-2: #f0f4fa;     /* 对方气泡 / 软填充 */
  --surface-3: #edf2f8;     /* 图标按钮填充 */
  --hover: #eef3f9;
  --border: #e9eef3;
  --border-soft: #eef2f6;

  /* 文字 */
  --text: #1e2b3a;
  --muted: #526e83;         /* 次要文字（AA 达标，含浅蓝灰底上） */
  --muted-2: #9fb2c2;       /* 仅装饰性（占位符等） */

  /* 主色（按钮/链接用，深一档保证白字对比度；气泡另用浅色系） */
  --primary: #33739f;
  --primary-hover: #2a6288;
  --primary-ink: #2a6288;
  --primary-soft: #e6eef8;
  --on-primary: #ffffff;

  /* 气泡 */
  --bubble-mine: #d9eafb;
  --bubble-mine-ink: #1e2b3a;
  --bubble-theirs: #f0f4fa;
  --bubble-theirs-ink: #1e2b3a;

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

  /* 形状 */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-bubble: 20px;
  --radius-pill: 999px;

  /* 阴影：极轻的柔影，层次仍以描边为主 */
  --shadow-card: 0 12px 40px rgba(30, 43, 58, .06), 0 2px 12px rgba(30, 43, 58, .03);
  --shadow-soft: 0 1px 3px rgba(30, 43, 58, .04);

  /* 层级 */
  --z-sticky: 10;
  --z-banner: 40;
  --z-page: 45;             /* 全屏页面（通讯录/朋友圈/我的）：在弹层之下 */
  --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;
  /* 全页禁双击缩放（连点不放大）；双指缩放由 viewport 声明 + JS gesture 拦截兜底 */
  touch-action: manipulation;
}
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: #d0dce8 transparent; }
.user-list::-webkit-scrollbar, #msg-list::-webkit-scrollbar { width: 6px; }
.user-list::-webkit-scrollbar-thumb, #msg-list::-webkit-scrollbar-thumb {
  background: #d0dce8;
  border-radius: var(--radius-pill);
}
.user-list::-webkit-scrollbar-thumb:hover, #msg-list::-webkit-scrollbar-thumb:hover { background: #b9cadb; }
.user-list::-webkit-scrollbar-track, #msg-list::-webkit-scrollbar-track { background: transparent; }

/* 群头像占位 */
.avatar.group-avatar {
  background: #dbe7f3;
  color: var(--text);
  font-size: 18px;
}
.avatar.group-avatar.sm { font-size: 15px; }

/* 群聊：气泡上方显示发送者昵称 */
.msg-sender {
  font-size: 11.5px;
  color: var(--muted);
  margin: 0 4px 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg.mine .msg-sender { text-align: right; }

/* ==================== 登录 / 注册 ==================== */
#view-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 16px;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 28px 24px;
}
.brand {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  margin-bottom: 18px;
}
/* 登录卡片的品牌 logo（用 logo.jpg 生成的小图，见 app/gen-icons.ps1） */
.brand-logo {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  display: block;
  margin: 0 auto;
}
.tabs { display: flex; border-bottom: 1px solid var(--border-soft); 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-pill);
  padding: 10px 16px;
  font: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
/* 复选框/单选按钮不吃全局 100% 宽和药丸样式（建群勾选好友等场景） */
input[type="checkbox"], input[type="radio"] {
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 0;
  flex: none;
  accent-color: var(--primary);
  cursor: pointer;
}
textarea { border-radius: var(--radius-lg); }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
/* 下拉框（编辑资料里的性别）：原生 select 的默认外观和站内风格完全不搭，
   这里给它套上和输入框同一套药丸样式，并去掉系统箭头、自画一个（跟随主题色，不用图片）。 */
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 10px 40px 10px 16px;   /* 右侧留出箭头的位置 */
  font: inherit;
  background: var(--surface);
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
select option { background: var(--surface); color: var(--text); }
.select-wrap { position: relative; display: block; }
.select-wrap::after {
  content: '';
  position: absolute;
  right: 19px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -5px;
  border-right: 1.8px solid var(--muted);
  border-bottom: 1.8px solid var(--muted);
  transform: rotate(45deg);
  pointer-events: none;   /* 关键：点在箭头区域要落到底下的 select 上，否则点箭头没反应 */
}
/* 输入框焦点：不吃全局焦点环（硬描边叠在输入框上很难看），改为
   「主色描边 + 一圈半透明柔光」的清爽样式；键盘可达性由描边色差（≥3:1）保证。
   复选框/单选仍走全局焦点环。 */
input:not([type="checkbox"]):not([type="radio"]):focus,
textarea:focus, select:focus {
  border-color: var(--primary);
  background: var(--surface);
}
input:not([type="checkbox"]):not([type="radio"]):focus-visible,
textarea:focus-visible, select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(51, 115, 159, 0.12);
}
.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-pill);
  padding: 10px 16px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  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 客户端自绘标题栏 ====================
 * 只在壳里出现：原生侧注入 __LVDIAO_PC__ 后，main.js 给 body 加 pc-shell。
 * 层级 80 高于应用所有层级（最高 --z-toast:70），所以全屏页面/弹层也压不住它。
 * 拖动与窗口按钮全部由壳注入的桥接管（data-shell-drag / data-shell-action），这里只管长相。 */
.pc-titlebar { display: none; }
body.pc-shell {
  --shell-bar: 36px;
  /* 用 body 的 padding 让出标题栏高度，不要用 #view-chat 的 margin-top：
     块级元素的顶部外边距会在父级没有内边距/边框时"穿透"折叠到 html 上，
     文档因此多出 36px 出现一条没用的滚动条（踩过）。 */
  padding-top: var(--shell-bar);
  box-sizing: border-box;
}
body.pc-shell .pc-titlebar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--shell-bar);
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  user-select: none;
  -webkit-user-select: none;
}
.pct-logo { width: 18px; height: 18px; border-radius: 5px; flex: none; }
.pct-title { font-size: 13px; color: var(--muted); }
/* 空白处也是拖动区（撑满中间，别让按钮之间出现"拖不动"的缝） */
.pct-spacer { flex: 1; align-self: stretch; }
.pct-btn {
  width: 46px;
  height: var(--shell-bar);
  flex: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}
.pct-btn:hover { background: var(--hover); color: var(--text); }
.pct-close:hover { background: #e5484d; color: #fff; }
/* 最大化时把「最大化」按钮图标换成"还原"样子（壳会在 resize 时同步 shell-maximized） */
html.shell-maximized .pct-btn[data-shell-action="maximize"] svg { transform: scale(0.82) translate(-1px, 1px); }

/* 标题栏占位：应用主体整体下移，避免被盖住（位移由 body 的 padding 提供） */
body.pc-shell #view-chat {
  height: calc(100vh - var(--shell-bar));
  height: calc(100dvh - var(--shell-bar));
}
@media (min-width: 769px) {
  /* 桌面版的整页卡片也要避开标题栏 */
  body.pc-shell .page {
    top: calc(24px + var(--shell-bar));
    max-height: calc(100dvh - 48px - var(--shell-bar));
  }
}

/* ==================== 主布局：PC 悬浮卡片 ==================== */
#view-chat {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  height: 100dvh;
  padding: 24px;
}

/* 内层卡片：圆角悬浮窗（示例的 1080×720 感觉，纵向自适应） */
#sidebar, #chat-panel {
  height: 100%;
  max-height: 780px;
}
#view-chat > #sidebar { border-radius: var(--radius-lg) 0 0 var(--radius-lg); }
#view-chat > #chat-panel { border-radius: 0 var(--radius-lg) var(--radius-lg) 0; }

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

/* 侧栏顶部 */
.side-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 10px;
}
.me-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#me-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-sub { font-size: 12px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==================== 会话过滤框 + 添加好友 ==================== */
.conv-filter-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 10px;
}
#conv-filter {
  flex: 1;
  min-width: 0;
  padding: 8px 16px;
  font-size: 13px;
  background: var(--surface-2);
  border-color: #e3eaf1;
}
#btn-add-friend { position: relative; flex: none; }
#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);
}

/* ==================== 广告横幅 ==================== */
.ad-banner {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 6px 14px 6px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--primary-soft);
  position: relative;
}
.ad-banner[hidden] { display: none !important; }
.ad-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--primary-ink);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 36px;
}
.ad-link:hover { background: rgba(51, 115, 159, .06); }
.ad-img {
  max-width: 100%;
  max-height: 56px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  display: block;
}
.ad-text {
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  padding: 4px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ad-close {
  position: absolute;
  top: 2px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.ad-close:hover { background: var(--surface-3); color: var(--danger); }

/* ==================== 会话列表 ==================== */
.user-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.conv {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  border-radius: 14px;
  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-main { flex: 1; min-width: 0; }
.conv-name {
  display: flex;
  align-items: center;
  font-weight: 500;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-preview {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.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;
}
.badge.muted { background: #767676; color: #fff; }

/* 会话行上的 ⋯ 按钮 */
.conv-more {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  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: #dce6f0; color: var(--text); }

/* ==================== 头像（圆形） ==================== */
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #cbdae9;
  color: #33506e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 17px;
  flex: none;
  position: relative;
  user-select: none;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-soft);
}
/* 自定义头像：图片铺满并继承圆形 */
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.avatar.sm { width: 40px; height: 40px; font-size: 16px; }
.avatar.lg { width: 52px; height: 52px; font-size: 19px; }
.avatar.msg-av { width: 34px; height: 34px; font-size: 14px; margin-top: 1px; }
.dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #b6c6d4;
  border: 2px solid var(--surface);
}
.dot.on { background: var(--online); }
/* 侧栏自己的头像可点击打开账号设置 */
#me-avatar { cursor: pointer; }
#me-avatar:hover, #me-avatar:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ==================== 聊天区 ==================== */
#chat-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 0;
  position: relative;
}
#chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  z-index: var(--z-sticky);
}
.peer-meta { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
#peer-name { font-weight: 600; font-size: 16px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { font-size: 13px; color: var(--muted); display: flex; align-items: center; }
/* 在线状态只用头像上的那个点表示（status 行不再放第二个点，避免重复） */
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: var(--surface-3);
  color: #6f8da0;
  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: #e0eaf3; color: var(--primary-ink); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
#btn-back { display: none; }
/* 搜索按钮贴右侧，与左侧返回按钮形成对称 */
#btn-search { margin-left: auto; }

/* ==================== 会话内搜索 ==================== */
.search-panel {
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  max-height: 46vh;
}
.search-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px 4px;
}
#search-input {
  font-size: 13.5px;
  background: var(--surface-2);
  border-color: #e3eaf1;
  padding: 8px 16px;
}
.search-results {
  overflow-y: auto;
  padding: 4px 10px 10px;
  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: 8px 10px;
  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-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 8px;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
}
.day-chip {
  align-self: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  padding: 4px 16px;
  border-radius: var(--radius-pill);
  margin: 14px 0 8px;
  user-select: none;
}
.empty { margin: auto; color: var(--muted); font-size: 13px; padding: 40px 0; text-align: center; }

.msg {
  display: flex;
  width: 100%;
  margin-bottom: 6px;
}
.msg.mine { justify-content: flex-end; }
.msg.theirs { justify-content: flex-start; }
/* 连续同一方的消息收紧间距 */
.msg.mine + .msg.mine,
.msg.theirs + .msg.theirs { margin-top: 2px; }

.bubble-wrap { max-width: min(62%, 520px); display: flex; flex-direction: column; min-width: 0; }
.bubble {
  position: relative;
  padding: 10px 16px;
  border-radius: var(--radius-bubble);
  background: var(--bubble-theirs);
  color: var(--bubble-theirs-ink);
  overflow-wrap: anywhere;
  line-height: 1.5;
  font-size: 15px;
  box-shadow: var(--shadow-soft);
}
/* 尾部小尖角（clip-path 三角，贴底角） */
.msg.theirs .bubble { border-bottom-left-radius: 6px; }
.msg.theirs .bubble::before {
  content: '';
  position: absolute;
  left: -7px;
  bottom: 0;
  width: 16px;
  height: 16px;
  background: var(--bubble-theirs);
  clip-path: polygon(100% 0, 0 100%, 100% 100%);
  transform: translateY(1px);
}
.msg.mine .bubble {
  background: var(--bubble-mine);
  color: var(--bubble-mine-ink);
  border-bottom-right-radius: 6px;
}
.msg.mine .bubble::after {
  content: '';
  position: absolute;
  right: -7px;
  bottom: 0;
  width: 16px;
  height: 16px;
  background: var(--bubble-mine);
  clip-path: polygon(0 0, 0 100%, 100% 100%);
  transform: translateY(1px);
}

/* 元信息在气泡内底部（示例风格） */
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 4px;
  font-size: 11px;
  color: #6b8aa8;
  line-height: 1;
}
.msg.theirs .msg-meta { color: #7d96ab; justify-content: flex-start; }
.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; }

/* 文本消息：保留换行与连续空格 */
.msg-text { white-space: pre-wrap; }
/* 消息正文是**直接 append 进 .bubble 的文本节点**（ui.js 的 renderText 没有再用 .msg-text 包一层），
   所以 .bubble 自己也得 pre-wrap —— 否则自动回复话术里的换行会被 CSS 收成一行，
   客户看到的和后台写的就不一样了（踩过：规则里 3 个换行，客户端显示成一行）。
   这里安全的前提是气泡内容全部由 DOM 接口拼出来，标记里没有多余的空白文本节点。 */
.bubble { white-space: pre-wrap; }

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

/* 文件卡片（微信风格：彩色类型图标 + 文件名 + 大小） */
.file-card { display: flex; align-items: center; gap: 12px; min-width: 220px; max-width: 100%; color: inherit; text-decoration: none; }
.file-ic {
  width: 44px; height: 44px; flex: none;
  border-radius: 10px;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
}
.file-ic.pdf { background: #d9483b; }
.file-ic.doc { background: #2b579a; }
.file-ic.xls { background: #217346; }
.file-ic.ppt { background: #c43e1c; }
.file-ic.txt { background: #8a94a6; }
.file-ic.zip { background: #bd8b12; }
.file-ic.apk { background: #3f9166; }
.file-ic.aud { background: #7c5cbf; }
.file-ic.vid { background: #33739f; }
.file-ic.img { background: #b0689d; }
.file-ic.gen { background: #6b7f92; }
.file-meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.file-card .fname { font-weight: 500; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }
.file-card .fsize { font-size: 11.5px; opacity: .75; }
.msg.mine .file-card { color: var(--bubble-mine-ink); }

/* 发送中的本地回显：进度条 + 失败态 */
.send-progress { margin-top: 7px; display: flex; align-items: center; gap: 8px; }
.send-track {
  flex: 1; height: 4px; border-radius: 2px;
  background: rgba(30, 43, 58, .14);
  overflow: hidden;
}
.msg.mine .send-track { background: rgba(30, 43, 58, .12); }
.send-fill { display: block; height: 100%; width: 0%; background: var(--primary); border-radius: 2px; transition: width .2s ease; }
.send-pct { flex: none; font-size: 11px; color: var(--muted); min-width: 34px; text-align: right; }
.msg.local.failed .bubble { border: 1px solid var(--danger); }
.send-fail { margin-top: 7px; font-size: 12px; color: var(--danger); }
.msg.local.failed { cursor: pointer; }

/* 语音条（微信风格：宽度随时长伸缩，播放进度铺底色） */
.audio.vbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 12px;
  border-radius: 20px;
  overflow: hidden;
  color: var(--primary-ink);
}
.audio .vfill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: rgba(42, 98, 136, .16);
  pointer-events: none;
}
.audio .pbtn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  position: relative;
  z-index: 1;
}
.msg.theirs .audio .pbtn { background: var(--surface); color: var(--primary-ink); }
.msg.mine   .audio .pbtn { background: rgba(255, 255, 255, .55); color: #2a6288; }
.audio .vwave {
  display: inline-flex;
  align-items: center;
  gap: 2.5px;
  flex: 1;
  position: relative;
  z-index: 1;
}
.audio .vwave i {
  width: 2.5px;
  border-radius: 2px;
  background: currentColor;
  opacity: .45;
}
.audio .vwave i:nth-child(1) { height: 7px; }
.audio .vwave i:nth-child(2) { height: 13px; }
.audio .vwave i:nth-child(3) { height: 18px; }
.audio .vwave i:nth-child(4) { height: 12px; }
.audio .vwave i:nth-child(5) { height: 6px; }
.audio .dur { font-size: 11.5px; font-variant-numeric: tabular-nums; opacity: .85; flex: none; position: relative; z-index: 1; }

/* 帮助中心 / 关于（后台自定义内容，纯文本展示） */
.sitec-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  max-height: 60vh;
  overflow: auto;
  min-height: 60px;
}

/* 按住说话目标键：彻底禁掉系统长按行为（复制菜单/文字选择/双击放大/滚动接管），手势完全自管 */
#btn-audio {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* 按住说话浮层（触屏长按麦克风） */
.hold-rec-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) + 3);
  background: rgba(30, 43, 58, .35);
  display: flex;
  align-items: center;
  justify-content: center;
}
.hr-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 220px;
}
.hr-mic { font-size: 34px; animation: hr-pulse 1.4s ease-in-out infinite; }
@keyframes hr-pulse {
  0%, 100% { transform: scale(1); opacity: .9; }
  50% { transform: scale(1.12); opacity: 1; }
}
.hr-timer { font-size: 20px; font-variant-numeric: tabular-nums; color: var(--text); }
.hr-hint { font-size: 12.5px; color: var(--muted); }
.hr-hint.cancel { color: var(--danger); font-weight: 600; }

/* 「对方正在输入」 */
.typing-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 28px 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; }
}

/* 消息操作：右键 / 长按菜单（见 index.html #msg-menu），不再有悬停按钮 */

/* 搜索/跳转命中高亮 */
@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-bubble); }

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

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

/* ==================== 快捷指令面板 ==================== */
.quick-panel {
  display: flex;
  gap: 6px;
  padding: 6px 14px 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.quick-panel::-webkit-scrollbar { display: none; }
.quick-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
  user-select: none;
}
.quick-chip:hover { background: var(--surface-2); border-color: var(--primary); }
.quick-chip:active { background: var(--primary-soft); }
.quick-chip svg { flex: none; color: var(--primary); }

/* ==================== 输入区（药丸输入 + 圆形按钮） ==================== */
#composer {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
  /* 底部安全区（全面屏手势条）放最外层，内部行高不受影响 */
  padding-bottom: env(safe-area-inset-bottom);
}
/* 回复条：点「回复」后出现在输入框上方 */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px 0;
  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;
}
/* 主行：输入框占满，工具与发送贴右侧；多行时底对齐 */
.composer-main {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px 12px;
}
.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: 36px; height: 36px; }
/* 附件按钮内部结构：桌面内联时只要图标（tool-label 只在手机端的面板里显示） */
.composer-tools .tool-ic { display: inline-flex; align-items: center; justify-content: center; }
.composer-tools .tool-label { display: none; }
#input-msg {
  flex: 1;
  min-width: 0;
  resize: none;
  min-height: 42px;
  max-height: 200px;
  border-radius: var(--radius-pill);
  padding: 10px 18px;
  background: var(--surface);
  /* 超过 max-height 后会出现滚动条，默认样式在圆角输入框里很突兀：隐藏它，滚动仍然可用
     （与 .quick-panel 同一套写法；三条分别对应 Firefox / 旧 Edge / WebKit 内核） */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#input-msg::-webkit-scrollbar { width: 0; height: 0; display: none; }
#btn-send {
  border-radius: 50%;
  width: 44px;
  height: 44px;
  padding: 0;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#composer.is-disabled { opacity: .55; }
#composer.is-disabled textarea,
#composer.is-disabled button { cursor: not-allowed; }
.composer-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 18px 6px;
}
.composer-hint { font-size: 11px; color: var(--muted); user-select: none; }

/* ==================== 拖拽发送反馈 ==================== */
#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);
}

/* ==================== 右键 / ⋯ 菜单 ==================== */
.ctx-menu {
  position: fixed;
  z-index: var(--z-modal);
  min-width: 148px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.ctx-item {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 9px 14px;
  border-radius: var(--radius);
  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); }

/* ==================== 选择列表（转发 / 好友申请） ==================== */
.pick-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 46vh;
  overflow-y: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 4px;
}
.pick-item {
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: default;
  text-align: left;
}
.pick-item:hover { background: var(--hover); }
.pick-name { color: var(--text); font-size: 13.5px; }
/* 好友申请/搜索结果行：名称 + @用户名 + 右侧操作按钮 */
.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; }
/* 「发送收藏」行：左侧 44px 缩略图（图片收藏）或类型 emoji */
.fav-ic {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  display: grid;
  place-items: center;
  font-size: 20px;
  overflow: hidden;
}
.fav-ic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.btn.small { padding: 5px 12px; height: 30px; font-size: 12.5px; }

/* ==================== 弹层 ==================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(30, 43, 58, .35);
  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);
  box-shadow: var(--shadow-card);
  padding: 20px;
  width: min(92vw, 420px);
  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-live { position: relative; }
.rec-flip {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(0, 0, 0, .45);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .12s ease, background var(--dur) var(--ease);
}
.rec-flip:hover { background: rgba(0, 0, 0, .65); }
.rec-flip:active { transform: scale(.92); }
.rec-flip:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
#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; }
/* 更新说明：保留换行，长文案可滚动 */
.update-notes { white-space: pre-wrap; max-height: 40vh; overflow-y: auto; }

/* 图标用上传图片时（后台可把快捷指令/广告图标设为图片）：与 emoji、内置 SVG 视觉尺寸对齐 */
.cell-icon-img { width: 22px; height: 22px; border-radius: 6px; object-fit: cover; flex: none; }
.qc-icon-img { width: 15px; height: 15px; border-radius: 3px; object-fit: cover; flex: none; }

/* 聊天背景：图贴在 #chat-panel 上（消息滚动时背景保持不动），图片 URL 由 JS 走 CSSOM 设置 */
#chat-panel.has-bg { background-size: cover; background-position: center; background-repeat: no-repeat; }
#chat-panel.has-bg #msg-list { background: transparent; }

/* ==================== 客服工作台侧栏（仅管理员、桌面宽屏） ====================
 * 会话右侧一屏给出：客户资料 / 查档申请 / 话术库。窄屏（<1100px）由 JS 自动收起。 */
.wb-panel {
  width: 300px;
  flex: none;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--bg-sidebar);
  min-height: 0;
}
/* 工作台是 #view-chat 里「侧栏 + 聊天区」卡片的第三块：高度跟卡片一致、右侧接圆角。
   同时把聊天区右侧的圆角抹平，否则拼起来中间会露出一道圆弧。 */
#view-chat > #wb-panel {
  height: 100%;
  max-height: 780px;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  overflow: hidden;
}
#view-chat.has-wb > #chat-panel { border-radius: 0; }
.wb-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.wb-head h2 { flex: 1; margin: 0; font-size: 15px; }
.wb-body { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.wb-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.wb-card h3 { margin: 0 0 8px; font-size: 14px; }
.wb-sub { margin: 0 0 8px; color: var(--muted); font-size: 12.5px; }
.wb-note { color: var(--muted-2); font-size: 11.5px; font-weight: 400; }
.wb-rows { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.wb-row { display: flex; gap: 8px; font-size: 12.5px; }
.wb-k { width: 52px; flex: none; color: var(--muted); }
.wb-v { flex: 1; overflow-wrap: anywhere; }
.wb-actions { display: flex; gap: 8px; }
.wb-actions .btn { flex: 1; }
.wb-reqs { display: flex; flex-direction: column; gap: 8px; }
.wb-req { border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 8px; background: var(--surface-2); }
.wb-req-t { font-size: 13px; font-weight: 600; }
.wb-req-m, .wb-req-o { color: var(--muted); font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; }
.wb-req-f { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.wb-file { font-size: 12px; color: var(--primary-ink); }
.wb-empty { margin: 0; color: var(--muted); font-size: 12.5px; }
#wb-q {
  width: 100%;
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: inherit;
}
.wb-rules { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.wb-rule {
  text-align: left;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 6px 8px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wb-rule:hover { background: var(--primary-soft); }
.wb-rule-k { font-size: 12.5px; font-weight: 600; overflow-wrap: anywhere; }
.wb-rule-t { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
/* 窄屏：入口按钮与三栏都让位 */
@media (max-width: 1099px) {
  .wb-panel { display: none; }
  #wb-toggle { display: none; }
}


/* ==================== 微信内置浏览器拦截层（wxguard.js） ====================
 * 微信 WebView 里长连接易挂起、录音/相机行为不一致、文件下载被拦 —— 与其半残运行，
 * 不如明确引导走「右上角 ⋯ → 在浏览器打开」。只遮罩、不运行应用。 */
body.wx-blocked { overflow: hidden; }
.wx-guard {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-toast) + 1);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  background: var(--bg);
  color: var(--text);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.wx-guard-card { width: 100%; max-width: 340px; text-align: center; }
.wx-guard-logo { display: block; margin: 0 auto 14px; border-radius: 18px; }
.wx-guard h1 { font-size: 19px; margin: 0 0 8px; }
.wx-guard-sub { margin: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.wx-guard-steps {
  margin: 0 0 20px;
  padding: 14px 16px 14px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: left;
  font-size: 14.5px;
  line-height: 1.9;
}
.wx-guard-tip { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
/* 指向右上角微信「⋯」的提示箭头 */
.wx-guard-arrow {
  position: fixed;
  top: 10px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--primary-ink);
  font-size: 13px;
  font-weight: 600;
}
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: inline-block; }

#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(30, 43, 58, .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-lg); }
.lightbox-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 50%;
  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; }

/* 大图底部操作条（保存到相册）：点它不关闭预览，见 main.js 的遮罩点击逻辑 */
.lightbox-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  gap: 10px;
  pointer-events: none; /* 条本身不挡点击，只有按钮可点 */
}
.lightbox-act {
  pointer-events: auto;
  padding: 10px 22px;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
.lightbox-act:hover { background: rgba(255, 255, 255, .24); }
.lightbox-act:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lightbox-act:disabled { opacity: .55; cursor: default; }
.lightbox-act[hidden] { display: none; }

/* ==================== 全局提示 ==================== */
#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: 10px 16px;
  border-radius: var(--radius-pill);
  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 6px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 11px;
  flex: none;
}

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

/* ==================== 账号设置弹层 ==================== */
.modal-divider { border-top: 1px solid var(--border-soft); }
.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-soft);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.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); }

/* ==================== 注册关闭提示 ==================== */
.reg-closed {
  margin: 14px 0 0;
  padding: 8px 12px;
  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 14px; font-size: 13px; white-space: nowrap; }
.sms-code-row .btn:disabled { opacity: .6; cursor: not-allowed; }
/* 找回密码入口与返回链接 */
.forgot-link { display: block; margin-top: 10px; width: 100%; text-align: center; }
#form-reset .link { display: block; margin-top: 10px; width: 100%; text-align: center; }

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

  #view-chat { padding: 0; height: 100vh; height: 100dvh; }
  #sidebar, #chat-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    max-height: none;
    border-radius: 0;
    height: 100%;
  }
  #chat-panel { display: none; }
  body.mobile-chat #sidebar { display: none; }
  body.mobile-chat #chat-panel { display: flex; }
  #btn-back { display: inline-flex; }

  /* 键盘兜底（--kb 由 main.js 的 setupKeyboardInset 写入）：
     聊天面板是固定定位、inset:0 的，键盘只缩小「可视视口」时它不会自己上移，
     底部输入框就被输入法盖住。这里用键盘高度当底边，顺便把定高换成 auto，
     让 top:0 + bottom:--kb 决定高度（与原来的 height:100% 等效，但能跟着 --kb 收缩）。
     原生壳已经把 WebView 缩过时 --kb 恒为 0px，此规则无副作用。 */
  #chat-panel { bottom: var(--kb, 0px); height: auto; }

  /* 触控目标不小于 44px */
  .icon-btn { width: 44px; height: 44px; }
  /* flex-wrap 是关键：不换行时下面那个 flex-basis:100% 的面板会被硬挤在同一行里
     （这正是改版前"加号展开很挤很丑"的原因），换行后面板才落到输入行下方独立一行 */
  .composer-main { gap: 4px; padding: 6px 10px 8px; flex-wrap: wrap; }
  #btn-plus { display: inline-flex; }
  #btn-plus svg { transition: transform .18s ease; }
  body.tools-open #btn-plus svg { transform: rotate(45deg); } /* 加号转成叉，微信同款反馈 */

  /* 附件面板：微信式四列（圆角色块 + 图标 + 文字），点加号在输入区下方展开 */
  .composer-tools {
    display: none;
    flex-basis: 100%;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px 2px;
    padding: 14px 6px 4px;
    margin-top: 2px;
    border-top: 1px solid var(--border-soft);
  }
  body.tools-open .composer-tools { display: grid; }
  .composer-tools .tool-item {
    width: auto;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    border: 0;
    border-radius: 0;
    background: none;
    padding: 0;
    color: var(--text);
    font-size: 12px;
  }
  .composer-tools .tool-item:hover { background: none; }
  .composer-tools .tool-item .tool-ic {
    width: 54px;
    height: 54px;
    border-radius: 15px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    transition: transform .12s ease, background var(--dur) var(--ease);
  }
  .composer-tools .tool-item .tool-ic svg { width: 26px; height: 26px; }
  .composer-tools .tool-item:active .tool-ic { transform: scale(.94); background: var(--primary-soft); }
  .composer-tools .tool-label { display: block; }
  /* 一眼分辨的彩色图标（微信面板的做法）；色值不走主题变量，深浅色模式下都保持可辨识 */
  #btn-image .tool-ic { color: #16a34a; }
  #btn-doc .tool-ic { color: #f59e0b; }
  #btn-capture .tool-ic { color: #0d9488; }
  #btn-fav .tool-ic { color: #eab308; }
  #btn-audio .tool-ic { color: #0ea5e9; }
  #btn-video .tool-ic { color: #ef4444; }
  .composer-foot { display: none; } /* 触屏没有 Ctrl 键，快捷键提示没有意义 */
  .bubble-wrap { max-width: 80%; }
  #msg-list { padding: 14px 12px 6px; }
  #btn-send { width: 44px; height: 44px; }

  /* 长按消息弹操作按钮时不触发系统文字选择（放大镜/选区/系统菜单） */
  #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;
  }
}

/* ==================== 会话筛选 tab（全部/未读/@我） ==================== */
.conv-tabs { display: flex; gap: 6px; padding: 0 14px 8px; flex: none; }
.conv-tab {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius-pill);
  padding: 3px 12px;
  font-size: 12.5px;
  cursor: pointer;
}
.conv-tab.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.tag-at {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-pill);
  padding: 0 8px;
  font-size: 11px;
  line-height: 18px;
}

/* ==================== 我的收藏入口 ==================== */
.fav-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 20px);
  margin: 0 10px 6px;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
}
.fav-entry:hover { background: var(--hover); }
.fav-avatar {
  width: 38px; height: 38px; flex: none;
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.fav-name { font-weight: 600; color: var(--text); }
.fav-hint { margin-left: auto; font-size: 11.5px; color: var(--muted-2); }

/* ==================== 群公告横幅 ==================== */
#group-announce {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: none;
  margin: 8px 14px 0;
  padding: 8px 12px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
}
.ga-icon { flex: none; }
.ga-text {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
  word-break: break-word;
}
#group-announce.expanded .ga-text {
  -webkit-line-clamp: unset;
  max-height: 30vh;
  overflow: auto;
}
.ga-close {
  flex: none;
  border: 0;
  background: none;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  opacity: .85;
}
.gi-announce {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin: 6px 0 10px;
  background: var(--surface-2);
}
.gi-announce-head { display: flex; align-items: center; justify-content: space-between; }
.gi-announce-text { font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; color: var(--text); }

/* ==================== @提及 ==================== */
.mention { color: var(--primary); font-weight: 600; }
.mention.me {
  background: var(--primary-soft);
  border-radius: 4px;
  padding: 0 3px;
}
#composer { position: relative; }
.mention-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 12px;
  right: 12px;
  max-height: 248px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  z-index: calc(var(--z-modal) - 1);
  padding: 4px;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: none;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
}
.mention-item.active, .mention-item:hover { background: var(--hover); }
.mention-name { color: var(--text); font-size: 14px; }

/* ==================== 全屏页面（通讯录/朋友圈/我的） ==================== */
.page {
  position: fixed;
  inset: 0;
  z-index: var(--z-page);
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.page-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
}
.page-head h2 { font-size: 16px; margin: 0; flex: 1; color: var(--text); }
.page-head-spacer { width: 36px; }
.page-head .btn.sm { padding: 5px 14px; font-size: 13px; }
.page-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  /* 滚到头/到底不要把滚动传给底层（桌面卡片式页面尤其明显） */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 14px 24px;
}
@media (min-width: 769px) {
  /* 桌面版把整页改成"从顶部 24px 开始的卡片"，但别忘了保留高度上限：
     .page-body 是 flex:1 + overflow:auto，只有父级高度有限时它才是真正的滚动容器。
     不给 max-height 的话页面会被内容撑高、超出视口的部分被裁掉，
     滚轮找不到可滚的祖先就会冒泡去滚底层（会话列表）——踩过。 */
  .page {
    inset: 24px auto auto 50%;
    transform: translateX(-50%);
    width: min(720px, 94vw);
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-soft);
  }
}

/* 通讯录 */
.cell-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  text-align: left;
}
.cell-entry:hover { background: var(--hover); }
/* 通讯录广告入口（多条）：文字单行截断 + 右侧箭头提示可点 */
.contacts-ad-list { display: flex; flex-direction: column; }
.contacts-ad-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contacts-ad-arrow { flex: none; color: var(--muted-2); font-size: 18px; line-height: 1; }
/* 广告弹窗：文字段落 + 图片纵向排列（点图用聊天页 lightbox 放大） */
.contacts-ad-card { max-width: 420px; }
.cad-text { margin: 0 0 10px; white-space: pre-wrap; word-break: break-word; }
.cad-images { display: flex; flex-direction: column; gap: 8px; }
.cad-images:empty { display: none; }
.cad-images img { display: block; width: 100%; border-radius: 10px; cursor: zoom-in; }
.cell-icon {
  width: 38px; height: 38px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-3);
  border-radius: 50%;
  font-size: 17px;
}
.cell-av { width: 38px; height: 38px; flex: none; }
.cell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cell-name { font-weight: 600; color: var(--text); font-size: 14.5px; }
.cell-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-badge {
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 11px;
  padding: 1px 8px;
}
.contacts-sec-title { font-size: 12.5px; color: var(--muted); margin: 10px 2px 8px; }
.contacts-letter {
  position: sticky;
  top: -12px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  padding: 6px 2px 4px;
  z-index: var(--z-sticky);
}
.contacts-count { text-align: center; color: var(--muted-2); font-size: 12px; padding: 10px 0; }

/* 好友资料卡 */
.fs-body { display: flex; flex-direction: column; gap: 4px; }
.fs-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.fs-name { font-size: 17px; font-weight: 700; color: var(--text); }
.fs-username { font-size: 12.5px; color: var(--muted); }
.fs-row { display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border-soft); font-size: 13.5px; }
.fs-k { color: var(--muted); width: 72px; flex: none; }
.fs-v { color: var(--text); word-break: break-word; }

/* 朋友圈 */
.moments-list { display: flex; flex-direction: column; gap: 10px; }
.moment-item {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.moment-head { display: flex; align-items: center; gap: 10px; }
.moment-head-meta { flex: 1; min-width: 0; }
.moment-author { font-weight: 700; color: var(--primary-ink); font-size: 14.5px; }
.moment-time { font-size: 12px; color: var(--muted-2); }
.moment-del { font-size: 12px; }
.moment-text { margin: 8px 0 0; font-size: 14.5px; line-height: 1.65; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.moment-grid { display: grid; gap: 6px; margin-top: 8px; }
.moment-grid.g1 { grid-template-columns: minmax(0, 62%); }
.moment-grid.g2 { grid-template-columns: 1fr 1fr; }
.moment-grid.g3 { grid-template-columns: repeat(3, 1fr); }
.moment-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: zoom-in;
}
.moment-grid.g1 .moment-img { aspect-ratio: auto; max-height: 340px; }
.moment-acts { display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; }
.moment-act {
  border: 0;
  background: var(--surface-3);
  color: var(--muted);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 12.5px;
  cursor: pointer;
}
.moment-act:hover { background: var(--hover); }
.moment-act.liked { background: var(--danger-soft); color: var(--danger); }
.moment-panel {
  margin-top: 8px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.7;
}
.moment-likes { color: var(--text); }
.moment-likes-heart { color: var(--danger); margin-right: 4px; }
.moment-comment { display: flex; flex-wrap: wrap; align-items: baseline; }
.moment-comment-name {
  border: 0; background: none; padding: 0;
  color: var(--primary-ink);
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}
.moment-comment-arrow { color: var(--muted); font-size: 12.5px; }
.moment-comment-text { color: var(--text); word-break: break-word; }
.moments-more { text-align: center; color: var(--muted-2); font-size: 12px; padding: 6px 0 2px; }
.mc-text {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  resize: vertical;
  min-height: 88px;
  background: var(--surface);
  color: var(--text);
}
.mc-images { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.mc-img-cell { position: relative; aspect-ratio: 1; }
.mc-img-cell img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-sm); }
.mc-img-rm {
  position: absolute;
  top: -6px; right: -6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 0;
  background: rgba(30,43,58,.75);
  color: #fff;
  cursor: pointer;
}
.mc-img-add {
  aspect-ratio: 1;
  border: 1px dashed var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 22px;
  color: var(--muted-2);
  cursor: pointer;
}

/* 我的 */
.me-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 14px;
  margin-bottom: 14px;
}
.me-card-meta { flex: 1; min-width: 0; }
.me-page-name { font-size: 17px; font-weight: 700; color: var(--text); }
.me-page-username { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.me-page-bio { font-size: 13px; color: var(--muted); margin-top: 6px; word-break: break-word; }
.me-rows { display: flex; flex-direction: column; gap: 8px; }
.me-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  font-size: 14.5px;
  color: var(--text);
}
.me-row:hover { background: var(--hover); }
.me-row span { flex: 1; }
.me-row small { color: var(--muted-2); font-size: 12.5px; }
.me-row.danger span { color: var(--danger); }
.me-foot { text-align: center; color: var(--muted-2); font-size: 11.5px; margin-top: 18px; }

/* ==================== 底部 tabbar（移动端） ==================== */
#tabbar { display: none; }
.tab-dot {
  position: absolute;
  top: 4px;
  right: 50%;
  margin-right: -22px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
}
#btn-moments.has-dot { position: relative; color: var(--danger); }
#btn-moments.has-dot::after {
  content: '';
  position: absolute;
  top: 3px; right: 3px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--danger);
}

@media (max-width: 768px) {
  /* tabbar 在页面之上（几何上不重叠，保险起见），但低于弹层：
     弹层（资料卡/评论/编辑资料/加好友）打开时背景连 tabbar 一起罩住，避免误切 */
  #tabbar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: calc(54px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border-soft);
    z-index: calc(var(--z-modal) - 2);
  }
  .tabbar-item {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 10.5px;
    cursor: pointer;
  }
  .tabbar-item.active { color: var(--primary); }

  /* 聊天视图激活时隐藏 tabbar（给输入区让位）；通讯录/朋友圈/我的页面保留，
     页面本身停在 tabbar 上方（bottom 抬高），导航随时可切换 */
  body.mobile-chat #tabbar { display: none; }

  /* 侧栏底部留出 tabbar 高度 */
  #sidebar { padding-bottom: calc(54px + env(safe-area-inset-bottom)); }
  /* 页面只占 tabbar 以上的区域——tabbar 不被覆盖、随时可点 */
  .page { bottom: calc(54px + env(safe-area-inset-bottom)); }
  .page-head { padding-top: calc(10px + env(safe-area-inset-top)); }

  /* 移动端：侧栏不再放通讯录/朋友圈图标（底部 tab 已覆盖） */
  #btn-contacts, #btn-moments { display: none; }

  /* 页面打开时盖住侧栏（ chats 列表） */
  body.page-open #sidebar { display: none; }
}

/* 登录页：记住账号 + 忘记密码同一行；下面「还没有账号？立即注册」 */
.login-opts { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 14px; }
.remember { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); cursor: pointer; user-select: none; }
.remember input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.goto-register { margin: 14px 0 0; text-align: center; font-size: 13.5px; color: var(--muted); }
.goto-register .link { font-size: 13.5px; }
/* 忘记密码原来在按钮下方（block + 居中），现在移到「记住账号」同一行，把旧对齐方式收回 */
.login-opts .forgot-link { display: inline-block; width: auto; margin: 0; text-align: inherit; }
