:root {
  --wx-green: #07c160;
  --wx-green-dark: #06ad56;
  --sidebar-bg: #ededed;
  --chat-bg: #f5f5f5;
  --header-bg: #f7f7f7;
  --border: #d9d9d9;
  --text: #191919;
  --text-2: #7f7f7f;
  --bubble-me: #95ec69;
  --bubble-other: #ffffff;
  --sidebar-w: 300px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--chat-bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}
button { font-family: inherit; }
input, textarea { font-family: inherit; }

/* ---------------- 整体布局 ---------------- */
/* 登录前主界面不渲染（display:none），避免隐藏的大 DOM 与布局占用低端机内存；登录后由 enterApp 加 .show 显示 */
.app { display: none; height: 100vh; height: 100dvh; overflow: hidden; }
.app.show { display: flex; animation: appIn .32s ease; }

/* ---------------- 侧栏 ---------------- */
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid #d6d6d6;
  display: flex; flex-direction: column; min-width: 0;
}
.side-top { padding: 10px 12px 8px; border-bottom: 1px solid #d6d6d6; background: #e8e8e8; }
.side-title-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.side-title { font-size: 16px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.action-row { display: flex; gap: 8px; }
.btn-action {
  flex: 1; padding: 7px 6px; font-size: 13px; border: 0; border-radius: 5px;
  background: var(--wx-green); color: #fff; cursor: pointer; white-space: nowrap;
}
.btn-action:hover { background: var(--wx-green-dark); }
.btn-action.ghost { background: #fff; color: #333; border: 1px solid #cfcfcf; }
.btn-action.ghost:hover { background: #f2f2f2; }

.me-row {
  margin-top: 9px; display: flex; align-items: center; gap: 8px; font-size: 12px; color: #555;
}
.key-chip {
  background: #fff; border: 1px solid #d0d0d0; border-radius: 4px; padding: 2px 6px;
  font-family: Menlo, Consolas, monospace; letter-spacing: .5px; cursor: pointer; user-select: all;
}
.key-chip:hover { border-color: var(--wx-green); color: var(--wx-green); }

.conv-list { flex: 1; overflow-y: auto; }
.conv {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; cursor: pointer;
  border-bottom: 1px solid #dedede; position: relative;
  transition: background .15s ease;
}
.conv:hover { background: #e3e3e3; }
.conv.active { background: #c9c9c9; }
.conv.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--wx-green); }
.avatar {
  width: 40px; height: 40px; border-radius: 4px; flex: 0 0 40px; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 600;
  position: relative; overflow: hidden;
}
.avatar.group { border-radius: 6px; }
/* 分组消息：组首之外隐藏头像（visibility 保留占位以维持气泡对齐） */
.avatar.ghost { visibility: hidden; }
.avatar .dot-online {
  position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%;
  background: #31d34a; border: 2px solid #ededed;
}
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: baseline; gap: 6px; }
.conv-name { font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 11px; color: #9a9a9a; flex: 0 0 auto; }
.conv-preview { font-size: 12px; color: #9a9a9a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #fa5151; color: #fff;
  font-size: 11px; line-height: 18px; text-align: center; flex: 0 0 auto;
}
.tag { font-size: 10px; padding: 1px 4px; border-radius: 3px; background: #dcdcdc; color: #666; flex: 0 0 auto; }
.tag.public { background: #dff0e5; color: #07a854; }

/* ---------------- 聊天区 ---------------- */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--chat-bg); position: relative; }
.chat-header {
  height: 56px; flex: 0 0 56px; border-bottom: 1px solid #e0e0e0; background: var(--header-bg);
  display: flex; align-items: center; padding: 0 16px; gap: 10px;
}
.back-btn { display: none; border: 0; background: transparent; font-size: 20px; cursor: pointer; padding: 0 6px 0 0; color: #333; }
.chat-title { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub { font-size: 12px; color: var(--text-2); margin-left: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.icon-btn {
  border: 1px solid #d5d5d5; background: #fff; border-radius: 5px; padding: 5px 9px;
  font-size: 12px; color: #555; cursor: pointer;
}
.icon-btn:hover { background: #f0f0f0; }

.messages { flex: 1; overflow-y: auto; padding: 16px 18px 8px; position: relative; }
/* 阅读历史时新消息提示：悬浮在消息区右下角（位于输入栏之上），点击回到底部 */
.jump-bottom {
  position: absolute; right: 18px; bottom: 84px; z-index: 20;
  background: #4257a8; color: #fff; border: 0; border-radius: 18px;
  padding: 7px 14px; font-size: 13px; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.18);
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.jump-bottom.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.jump-bottom:hover { background: #6f4fae; }
/* 拖拽文件到聊天区时的发送提示浮层 */
.drop-overlay {
  position: absolute; inset: 8px; z-index: 30; display: none; align-items: center; justify-content: center;
  background: rgba(66, 87, 168, .12); border: 3px dashed #4257a8; border-radius: 10px;
  color: #4257a8; font-size: 18px; font-weight: 600; pointer-events: none;
}
.msg-day { text-align: center; margin: 10px 0 14px; }
.msg-day span { font-size: 12px; color: #fff; background: #dadada; padding: 2px 8px; border-radius: 3px; }
/* 「以下为新消息」分隔线：标记上次已读位点之后、未读消息之前 */
.msg-divider { text-align: center; margin: 12px 0; }
.msg-divider span { font-size: 11.5px; color: #6b6f8a; background: #eef0f8; padding: 3px 12px; border-radius: 11px; }
.msg-system { text-align: center; font-size: 12px; color: #9a9a9a; margin: 8px 0; }
.msg { display: flex; gap: 10px; margin-bottom: 16px; align-items: flex-start; animation: msgIn .2s ease both; }
/* 虚拟滚动：浏览器对视口外消息跳过布局/绘制，长会话滚动更流畅（保留全部交互/分组/分隔线） */
.msg, .msg-system, .msg-day, .msg-divider {
  content-visibility: auto;
  contain-intrinsic-size: auto 56px;
}
/* 连续消息组：后续条收紧间距，贴近微信风格的紧凑观感 */
.msg.grouped { margin-bottom: 4px; }
.msg.me { flex-direction: row-reverse; }
.msg-body { max-width: min(62%, 520px); min-width: 0; }
.msg-body { transition: transform .12s ease; will-change: transform; touch-action: pan-y; }
.msg-name { font-size: 12px; color: #9a9a9a; margin-bottom: 4px; }
.e2ee-lock { font-size: 11px; opacity: .8; }
.msg.me .msg-name { text-align: right; }
.bubble {
  background: var(--bubble-other); border-radius: 5px; padding: 9px 12px; font-size: 14.5px;
  line-height: 1.5; word-break: break-word; white-space: pre-wrap; position: relative;
  box-shadow: 0 1px 1px rgba(0,0,0,.04);
}
.msg.me .bubble { background: var(--bubble-me); }
.bubble .arrow {
  position: absolute; top: 12px; width: 0; height: 0; border: 6px solid transparent;
}
.bubble .arrow.left { left: -11px; border-right-color: var(--bubble-other); }
.msg.me .bubble .arrow.right { right: -11px; border-left-color: var(--bubble-me); }
.bubble.sticker { background: transparent; box-shadow: none; padding: 0; font-size: 60px; line-height: 1; }
/* 气泡内网址转为可点击链接：继承气泡文字色，白色托盘里用蓝紫色保证可读 */
.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.bubble.has-color a { color: #1657c8; }
/* 彩色字体消息：白底托盘，保证 9 色色板任意颜色在渐变气泡上均可读（两主题通用） */
.bubble.has-color,
.msg.me .bubble.has-color { background: #fff; color: #191919; }
.bubble img.media { max-width: 240px; max-height: 280px; border-radius: 4px; display: block; cursor: zoom-in; background: #ddd; }
.file-card { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.file-icon {
  width: 40px; height: 40px; border-radius: 4px; background: #f0f0f0; display: flex; align-items: center;
  justify-content: center; font-size: 20px; flex: 0 0 40px;
}
.file-meta { min-width: 0; }
.file-name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.file-size { font-size: 11px; color: #888; margin-top: 2px; }
.file-dl { font-size: 12px; color: #576b95; text-decoration: none; }
.typing-tip { font-size: 12px; color: #999; height: 18px; padding: 0 18px; }

/* ---------------- 输入区 ---------------- */
.composer { border-top: 1px solid #e0e0e0; background: #f7f7f7; padding: 6px 12px 10px; position: relative; }
.toolbar { display: flex; gap: 4px; align-items: center; }
.tool {
  border: 0; background: transparent; font-size: 20px; width: 34px; height: 32px; border-radius: 4px;
  cursor: pointer; color: #555; display: flex; align-items: center; justify-content: center;
}
.tool:hover { background: #e6e6e6; }
.tool.active { background: #dfe3f6; color: #4a63d8; }
:root[data-theme="dark"] .tool.active { background: #333335; color: #a8b4f0; }
.input-row { display: flex; gap: 10px; align-items: flex-end; margin-top: 4px; }
#input {
  flex: 1; resize: none; border: 1px solid #e0e0e0; border-radius: 4px; padding: 11px 10px;
  font-size: 16px; line-height: 1.5; max-height: 140px; min-height: 44px; outline: none; background: #fff;
}
#input:focus { border-color: #cfcfcf; }
.send-btn {
  border: 0; background: var(--wx-green); color: #fff; border-radius: 4px; padding: 0 18px;
  height: 42px; font-size: 14px; cursor: pointer; flex: 0 0 auto;
}
.send-btn:hover { background: var(--wx-green-dark); }
.send-btn:disabled { background: #b6e6c8; cursor: default; }

.progress-wrap { margin-top: 6px; font-size: 12px; color: #666; display: none; }
.progress-wrap.show { display: block; }
.bar { height: 4px; background: #e0e0e0; border-radius: 2px; overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--wx-green); transition: width .15s; }

/* ---------------- 弹出面板 / 弹窗 ---------------- */
.panel {
  position: absolute; z-index: 30; background: #fff; border: 1px solid #d9d9d9; border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14); padding: 8px;
}
.emoji-panel { width: 320px; max-width: 90vw; max-height: 240px; overflow-y: auto; display: grid;
  grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-panel button { border: 0; background: transparent; font-size: 22px; padding: 4px; cursor: pointer; border-radius: 4px; }
.emoji-panel button:hover { background: #f0f0f0; }
.sticker-panel { width: 320px; max-width: 90vw; max-height: 260px; overflow-y: auto; display: grid;
  grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sticker-panel button {
  border: 1px solid #eee; background: #fafafa; border-radius: 6px; padding: 6px 0; cursor: pointer; font-size: 34px;
}
.sticker-panel button:hover { background: #f0f9f3; border-color: var(--wx-green); }
.sticker-panel small { display: block; font-size: 11px; color: #888; }

/* 彩色字体色板 */
.color-panel { width: 232px; max-width: 90vw; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.color-panel button {
  border: 1px solid #e6e6e6; background: #fff; border-radius: 6px; padding: 6px 0;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.color-panel button:hover { border-color: #b9b9b9; background: #fafafa; }
.color-panel button.sel { border-color: var(--wx-green); box-shadow: 0 0 0 1px var(--wx-green); }
.color-panel .sw { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .12); display: block; }

.mask {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex;
  align-items: center; justify-content: center; padding: 16px;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .26s ease, visibility .26s ease;
}
.mask.show { opacity: 1; visibility: visible; pointer-events: auto; }
/* 图片灯箱：纯背景放大查看，点击图片外区域或关闭按钮退出 */
.lightbox { background: rgba(0,0,0,.82); }
.lightbox-img { max-width: 92vw; max-height: 86vh; border-radius: 6px; box-shadow: 0 8px 40px rgba(0,0,0,.5); cursor: zoom-out; }
.lightbox .mask-x { position: absolute; top: 16px; right: 18px; background: rgba(255,255,255,.16); color: #fff; font-size: 20px; }
.lightbox .mask-x:hover { background: rgba(255,255,255,.3); }
.dialog {
  background: #fff; border-radius: 8px; width: 380px; max-width: 100%; padding: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.dialog h3 { margin: 0 0 6px; font-size: 17px; }
.dialog .hint { font-size: 12.5px; color: #888; margin-bottom: 14px; line-height: 1.6; }
.dialog label { display: block; font-size: 13px; color: #555; margin-bottom: 5px; }
.dialog input {
  width: 100%; padding: 10px; font-size: 16px; border: 1px solid #ddd; border-radius: 4px; outline: none; margin-bottom: 12px;
}
.dialog input:focus { border-color: var(--wx-green); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn { border: 0; border-radius: 4px; padding: 9px 18px; font-size: 14px; cursor: pointer; }
.btn.primary { background: var(--wx-green); color: #fff; }
.btn.primary:hover { background: var(--wx-green-dark); }
.btn.plain { background: #f2f2f2; color: #333; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab { flex: 1; text-align: center; padding: 7px; font-size: 13px; border: 1px solid #ddd; border-radius: 4px; cursor: pointer; }
.tab.active { background: var(--wx-green); color: #fff; border-color: var(--wx-green); }
.dialog .mykey { font-family: Menlo, Consolas, monospace; background: #f5f5f5; border: 1px dashed #ccc;
  padding: 8px; border-radius: 4px; text-align: center; letter-spacing: 2px; margin-bottom: 12px; cursor: pointer; }
.err-tip { color: #fa5151; font-size: 12.5px; min-height: 18px; margin-bottom: 6px; }

/* ---------------- 登录 / 注册 ---------------- */
.auth-screen {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 60;
  background: linear-gradient(160deg, #4257a8, #6f4fae);
  display: flex; align-items: center; justify-content: center; padding: 20px; overflow: auto;
  opacity: 1;
  transition: opacity .35s ease, visibility .35s ease;
  animation: authIn .5s ease;
}
.auth-screen.hide { opacity: 0; visibility: hidden; pointer-events: none; }
/* 登录界面深色变体：更深的蓝紫渐变 */
:root[data-theme="dark"] .auth-screen { background: linear-gradient(160deg, #2a3260, #3c2b60); }
.auth-box { width: 380px; max-width: 100%; background: #fff; border-radius: 10px; padding: 28px 26px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.auth-head h1 { margin: 0; font-size: 21px; }
.auth-sub { font-size: 13px; color: #888; margin: -10px 0 18px; }
.field { margin-bottom: 14px; }
.field input {
  width: 100%; padding: 12px; font-size: 16px; border: 1px solid #ddd; border-radius: 5px; outline: none;
}
.field input:focus { border-color: var(--wx-green); }
.auth-btn {
  width: 100%; padding: 12px; font-size: 16px; border: 0; border-radius: 5px;
  background: linear-gradient(135deg, #4a63d8, #6f4fd8);
  color: #fff; cursor: pointer;
}
.auth-btn:hover { background: linear-gradient(135deg, #5568e0, #7a58e2); }
:root:not([data-theme="dark"]) .field input:focus { border-color: #6f4fd8; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 14px; color: #666; }
.auth-admin-btn {
  display: block; width: 100%; margin-top: 12px; padding: 9px;
  font-size: 13.5px; color: #e64340; background: #fff5f5;
  border: 1px solid #f3c2c2; border-radius: 6px; cursor: pointer;
}
.auth-admin-btn:hover { background: #ffeaea; }
.link-blue { color: #1677ff; cursor: pointer; text-decoration: none; }
.link-blue:hover { text-decoration: underline; }
.auth-err { color: #fa5151; font-size: 13px; min-height: 20px; margin-bottom: 6px; text-align: center; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 40px; background: rgba(0,0,0,.8);
  color: #fff; padding: 9px 16px; border-radius: 6px; font-size: 13.5px; z-index: 90; opacity: 0;
  pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }

.empty-chat { flex: 1; display: flex; align-items: center; justify-content: center; color: #bbb; font-size: 15px; }

/* ---------------- 竖屏 / 移动端兼容 ---------------- */
@media (max-width: 860px), (max-width: 1024px) and (pointer: coarse) {
  .sidebar { width: 100%; flex-basis: 100%; border-right: 0; }
  .chat {
    position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 20; transform: translateX(100%);
    transition: transform .22s ease; visibility: hidden;
  }
  .app.show-chat .chat { transform: translateX(0); visibility: visible; }
  .back-btn { display: block; }
  .messages { padding: 12px 12px 6px; }
  .msg-body { max-width: 74%; }
  .bubble img.media { max-width: 200px; max-height: 240px; }
  .chat-header { height: 52px; flex-basis: 52px; padding: 0 10px; gap: 6px; }
  .chat-sub { display: none; }
  .composer { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .emoji-panel, .sticker-panel { width: calc(100vw - 24px); }
  .auth-box { padding: 22px 18px 20px; }
}
@media (max-width: 860px) and (orientation: landscape) {
  /* 横屏小屏仍用双栏，压缩侧栏 */
  .sidebar { width: 240px; flex-basis: 240px; }
  .chat { position: static; transform: none; visibility: visible; }
  .back-btn { display: none; }
}

/* ---------------- 群管理面板 ---------------- */
.btn.danger { background: #fa5151; color: #fff; }
.btn.danger:hover { background: #e03b3b; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 14px; }
.mgmt-row { display: flex; gap: 8px; margin-bottom: 14px; }
.mgmt-row input {
  flex: 1; padding: 9px 10px; font-size: 16px; border: 1px solid #ddd; border-radius: 4px; outline: none;
}
.mgmt-row input:focus { border-color: var(--wx-green); }
.mgmt-members { max-height: 240px; overflow: auto; border: 1px solid #eee; border-radius: 4px; margin-bottom: 10px; }
.mgmt-member {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-bottom: 1px solid #f2f2f2; font-size: 14px;
}
.mgmt-member:last-child { border-bottom: 0; }
.mgmt-name { display: flex; align-items: center; gap: 6px; min-width: 0; word-break: break-all; }
.mgmt-member .dot { width: 7px; height: 7px; border-radius: 50%; background: #ccc; flex: 0 0 auto; }
.mgmt-member .dot.on { background: #07a854; }
.tag-owner, .tag-me { font-size: 10px; padding: 1px 5px; border-radius: 3px; }
.tag-owner { background: #dff0e5; color: #07a854; }
.tag-me { background: #eee; color: #888; }

/* ---------------- 游戏中心 ---------------- */
.side-bottom { padding: 8px 12px; border-top: 1px solid #d6d6d6; background: #e8e8e8; }
.btn-game {
  width: 100%; padding: 9px 6px; font-size: 13px; border: 1px solid #cfcfcf; border-radius: 5px;
  background: #fff; color: var(--wx-green); cursor: pointer; white-space: nowrap;
}
.btn-game:hover { background: #f2f2f2; }

.side-toggle {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; margin-bottom: 8px; font-size: 13px; color: #333;
  border: 1px solid #cfcfcf; border-radius: 5px; background: #fff; cursor: pointer;
}
.side-toggle:hover { background: #f2f2f2; }
.side-toggle.on { color: var(--wx-green); border-color: var(--wx-green); }
.side-toggle.disabled { opacity: .5; cursor: not-allowed; }
.toggle-ic { font-size: 15px; line-height: 1; }
.toggle-label { flex: 1; text-align: left; }
.toggle-sw {
  width: 36px; height: 20px; border-radius: 10px; background: #cfcfcf; position: relative;
  flex: 0 0 36px; transition: background .2s;
}
.toggle-sw i {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: left .2s;
}
.toggle-sw.on { background: var(--wx-green); }
.toggle-sw.on i { left: 18px; }

.games-view {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 25;
  background: var(--chat-bg); display: flex; flex-direction: column;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .28s ease, visibility .28s ease;
}
.games-view.show { opacity: 1; visibility: visible; pointer-events: auto; }
.games-header {
  height: 56px; flex: 0 0 56px; border-bottom: 1px solid #e0e0e0; background: var(--header-bg);
  display: flex; align-items: center; padding: 0 16px; gap: 10px;
}
.games-title { font-size: 16px; font-weight: 600; }
.games-header .back-btn { display: block; }
.games-body { flex: 1; overflow-y: auto; padding: 24px; }

.games-empty {
  height: 100%; display: flex; flex-direction: column; align-items: center;
  justify-content: center; color: #bbb; gap: 10px; text-align: center;
}
.games-empty-icon { font-size: 54px; }
.games-empty-title { font-size: 17px; color: #888; }
.games-empty-sub { font-size: 13px; color: #aaa; }

.games-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px; max-width: 880px; margin: 0 auto;
}
.game-card {
  background: #fff; border: 1px solid #ececec; border-radius: 8px; padding: 18px 12px;
  text-align: center; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease;
}
.game-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.game-icon { font-size: 40px; margin-bottom: 8px; }
.game-name { font-size: 14px; font-weight: 600; color: #333; }
.game-desc { font-size: 12px; color: #999; margin-top: 4px; }

/* 移动端：游戏中心返回箭头始终可见 */
@media (max-width: 860px), (max-width: 1024px) and (pointer: coarse) {
  .games-header .back-btn { display: block; }
}

/* 游戏内嵌（iframe） */
.game-frame { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
.games-body.playing { padding: 0; overflow: hidden; }

/* 游戏卡片上的「发送给好友」 */
.game-send {
  margin-top: 10px; width: 100%; padding: 6px 0; font-size: 12.5px; border: 1px solid var(--wx-green);
  border-radius: 5px; background: #fff; color: var(--wx-green); cursor: pointer;
}
.game-send:hover { background: #eef9f1; }

/* 聊天里的游戏卡片 */
.game-msg-card {
  display: flex; align-items: center; gap: 10px; min-width: 200px; max-width: 260px;
  background: #fff; border: 1px solid #ececec; border-radius: 8px; padding: 10px 12px; cursor: pointer;
}
.game-msg-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.game-msg-icon { font-size: 30px; flex: 0 0 auto; }
.game-msg-info { flex: 1; min-width: 0; }
.game-msg-name { font-size: 14px; font-weight: 600; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-msg-sub { font-size: 11.5px; color: #999; margin-top: 2px; }
.game-msg-play { font-size: 18px; color: var(--wx-green); flex: 0 0 auto; }
:root[data-theme="dark"] .game-msg-card { background: #2c2c2e; border-color: #3d3d3f; }
:root[data-theme="dark"] .game-msg-name { color: var(--text); }
:root[data-theme="dark"] .game-send { background: #2c2c2e; color: var(--wx-green); }

/* 发送游戏：选择会话 */
.game-share-list { max-height: 320px; overflow-y: auto; margin: 6px 0 12px; }
.share-row {
  display: flex; flex-direction: column; gap: 2px; padding: 9px 10px; border: 1px solid #eee;
  border-radius: 7px; margin-bottom: 8px; cursor: pointer; background: #fff;
}
.share-row:hover { background: #f4f9f5; border-color: var(--wx-green); }
.share-name { font-size: 14px; color: #333; }
.share-sub { font-size: 11.5px; color: #999; }
:root[data-theme="dark"] .share-row { background: #2c2c2e; border-color: #3d3d3f; }
:root[data-theme="dark"] .share-name { color: var(--text); }

/* ---------------- 语音通话 ---------------- */
.call-overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 30;
  background: rgba(0, 0, 0, .62); display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .3s ease, visibility .3s ease;
}
.call-overlay.show { opacity: 1; visibility: visible; pointer-events: auto; }
.call-card {
  width: 300px; max-width: 88vw; background: #fff; border-radius: 14px;
  padding: 28px 22px 22px; text-align: center; box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
}
.call-avatar {
  width: 72px; height: 72px; border-radius: 50%; background: var(--wx-green); color: #fff;
  font-size: 30px; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px;
}
.call-avatar.ringing { animation: callPulse 1.2s ease-in-out infinite; }
@keyframes callPulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.09); opacity: .82; }
  100% { transform: scale(1); opacity: 1; }
}
.call-name { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.call-status { font-size: 13px; color: #888; min-height: 20px; margin-bottom: 18px; }
.call-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.call-btn {
  border: 0; border-radius: 22px; padding: 10px 18px; font-size: 14px; color: #fff;
  cursor: pointer; min-width: 84px; background: #999;
}
.call-btn.accept { background: var(--wx-green); }
.call-btn.reject, .call-btn.hangup { background: #fa5151; }
.call-btn.mute { background: #576b95; }
.call-btn.muted { background: #b1b1b1; }
.call-btn.mic { background: #576b95; }
.call-btn.mic.on { background: var(--wx-green); }

/* ---------------- 屏幕共享 ---------------- */
.share-overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 31;
  background: rgba(0, 0, 0, .72); display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; pointer-events: none; padding: 16px;
  transition: opacity .3s ease, visibility .3s ease;
}
.share-overlay.show { opacity: 1; visibility: visible; pointer-events: auto; }
.share-card {
  width: min(760px, 94vw); max-height: 92vh; display: flex; flex-direction: column;
  background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 12px 40px rgba(0, 0, 0, .4);
}
.share-head { padding: 16px 18px 12px; text-align: center; }
.share-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.share-sub { font-size: 13px; color: #888; min-height: 20px; }
.share-stage {
  position: relative; flex: 1; min-height: 220px; max-height: 66vh;
  background: #0c0c0e; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.share-stage video#ssRemote { width: 100%; height: 100%; max-height: 66vh; object-fit: contain; background: #000; }
.share-waiting, .share-sharing {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px;
  align-items: center; justify-content: center; color: #cfcfcf; font-size: 14px;
}
.share-sharing { font-size: 18px; }
.share-card.sharer #ssRemote, .share-card.sharer #ssWaiting { display: none; }
.share-card:not(.sharer) #ssSharing { display: none; }
.share-actions { padding: 14px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
:root[data-theme="dark"] .share-card { background: #232326; color: var(--text); }
:root[data-theme="dark"] .share-sub { color: #9a9a9e; }


/* ---------------- 深色模式与字号 ---------------- */
:root[data-theme="dark"] {
  --sidebar-bg: #1c1c1e;
  --chat-bg: #171717;
  --header-bg: #1f1f21;
  --border: #333333;
  --text: #e8e8e8;
  --text-2: #8e8e93;
  --bubble-me: #3eb575;
  --bubble-other: #2c2c2e;
  --wx-green-dark: #06ad56;
}

/* ---------------- 蓝紫渐变主题（浅色）----------------
   仅作用于 :root:not([data-theme="dark"])，深色模式保持原有纯色：
   深色聊天背景 #171717 与深色气泡均不随渐变变化 */
:root:not([data-theme="dark"]) {
  --chat-bg: linear-gradient(180deg, #edf0fb 0%, #f2edfc 100%);
  --header-bg: linear-gradient(180deg, #f3f5fd 0%, #f7f3fc 100%);
  --bubble-other: linear-gradient(135deg, #ffffff 0%, #e7e1fa 100%);
  --bubble-me: linear-gradient(135deg, #4a63d8 0%, #6f4fd8 100%);
}
/* 气泡三角箭头取渐变代表色（border-color 不接受渐变） */
:root:not([data-theme="dark"]) .bubble .arrow.left { border-right-color: #e7e1fa; }
:root:not([data-theme="dark"]) .msg.me .bubble .arrow.right { border-left-color: #6f4fd8; }
/* 自己的气泡：蓝紫渐变底改用白字，并协调内部文件卡片 / 引用配色 */
:root:not([data-theme="dark"]) .msg.me .bubble { color: #fff; }
:root:not([data-theme="dark"]) .msg.me .bubble .file-size { color: rgba(255, 255, 255, .78); }
:root:not([data-theme="dark"]) .msg.me .bubble .file-dl,
:root:not([data-theme="dark"]) .msg.me .bubble .file-pv { color: #ffffff; }
:root:not([data-theme="dark"]) .msg.me .bubble .quote { color: rgba(255, 255, 255, .85); }
/* 日期胶囊：蓝紫灰调 */
:root:not([data-theme="dark"]) .msg-day span { background: #a8afd8; }
/* 输入区与工具栏：淡蓝紫调 */
:root:not([data-theme="dark"]) .composer { background: linear-gradient(180deg, #f4f5fc 0%, #f8f4fc 100%); }
:root:not([data-theme="dark"]) .tool:hover { background: #e2e5f7; }
:root[data-theme="dark"] body { background: var(--chat-bg); color: var(--text); }
:root[data-theme="dark"] .conv:hover { background: #2a2a2c; }
:root[data-theme="dark"] .conv.active { background: #333335; }
:root[data-theme="dark"] .side-bottom { background: #232325; border-top-color: #333; }
:root[data-theme="dark"] .btn-game,
:root[data-theme="dark"] .side-toggle,
:root[data-theme="dark"] .icon-btn { background: #2c2c2e; color: var(--text); border-color: #3d3d3f; }
:root[data-theme="dark"] .btn-game { color: var(--wx-green); }
:root[data-theme="dark"] .composer { background: #1f1f21; border-top-color: #333; }
:root[data-theme="dark"] #input { background: #2c2c2e; color: var(--text); border-color: #3d3d3f; }
:root[data-theme="dark"] .msg-day span { background: #3a3a3c; color: #d0d0d0; }
:root[data-theme="dark"] .msg-divider span { background: #34343a; color: #a9add0; }
:root[data-theme="dark"] .dialog,
:root[data-theme="dark"] .call-card,
:root[data-theme="dark"] .panel { background: #2c2c2e; color: var(--text); }
:root[data-theme="dark"] .key-chip,
:root[data-theme="dark"] .mykey { background: #1f1f21; color: var(--text); border-color: #3d3d3f; }
:root[data-theme="dark"] .search-panel { background: #1f1f21; border-bottom-color: #333; }
:root[data-theme="dark"] .msg-menu { background: #2c2c2e; border-color: #3d3d3f; }

:root[data-font="small"] .bubble { font-size: 13.5px; }
:root[data-font="large"] .bubble { font-size: 17px; }

/* ---------------- 侧栏快捷入口 ---------------- */
.side-actions { display: flex; gap: 8px; margin-top: 8px; }
.btn-side {
  flex: 1; padding: 7px 6px; font-size: 13px; border: 0; border-radius: 5px;
  background: var(--wx-green); color: #fff; cursor: pointer; white-space: nowrap;
  position: relative;
}
.btn-side:hover { filter: brightness(.96); }
.btn-side.admin-only { background: #e64340; }

/* ---------------- 弹窗加宽 ---------------- */
.dialog.wide { width: min(620px, 94vw); max-height: 86vh; display: flex; flex-direction: column; }
.dialog.wide .bc-list, .dialog.wide .admin-list { overflow-y: auto; }

/* 管理后台：全屏展示 + 可上下滚动 */
#maskAdmin { padding: 0; }
#maskAdmin .dialog {
  width: 100%; max-width: 100%; height: 100%; max-height: none;
  border-radius: 0; margin: 0; padding: 0;
  display: flex; flex-direction: column; overflow: hidden;
}
#maskAdmin .dialog > h3 {
  flex: 0 0 auto; margin: 0; padding: 18px 20px 12px; font-size: 18px;
  border-bottom: 1px solid #f0f0f0;
}
#maskAdmin .tabs { flex: 0 0 auto; padding: 0 20px 12px; margin: 0; }
#maskAdmin [id^="pane"] {
  flex: 1 1 auto; min-height: 0; flex-direction: column;
  padding: 12px 20px 0; overflow: hidden;
}
#maskAdmin .admin-toolbar { flex: 0 0 auto; }
#maskAdmin .admin-list,
#maskAdmin .bc-targets,
#maskAdmin #bcList { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#maskAdmin .dialog-actions {
  flex: 0 0 auto; padding: 12px 20px; border-top: 1px solid #f0f0f0;
}
:root[data-theme="dark"] #maskAdmin .dialog > h3 { border-color: #333; }
:root[data-theme="dark"] #maskAdmin .dialog-actions { border-color: #333; }
/* 编辑账号弹窗在管理后台之上打开，需盖过后台遮罩，否则按钮被拦截 */
#maskEditUser { z-index: 55; }

/* ---------------- 系统广播收件箱 ---------------- */
.bc-list { margin: 10px 0; }
.bc-item {
  border: 1px solid #e6e6e6; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px;
  background: #fafafa;
}
.bc-item .bc-meta { font-size: 12px; color: #999; margin-top: 6px; display: flex; gap: 10px; }
.bc-item .bc-content { font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.bc-empty { color: #999; text-align: center; padding: 24px 0; }
.badge {
  display: inline-block; min-width: 16px; height: 16px; line-height: 16px; padding: 0 4px;
  background: #fa5151; color: #fff; border-radius: 8px; font-size: 11px; text-align: center;
  margin-left: 4px; vertical-align: middle;
}

/* ---------------- 管理后台 ---------------- */
.admin-toolbar { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.admin-toolbar input[type=text] { flex: 1; }
.admin-list { margin: 6px 0; }
.admin-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 4px;
  border-bottom: 1px solid #eee;
}
.admin-row .a-avatar {
  width: 34px; height: 34px; border-radius: 6px; color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto; font-size: 15px;
}
.admin-row .a-main { flex: 1; min-width: 0; }
.admin-row .a-name { font-size: 14px; font-weight: 600; }
.admin-row .a-meta { font-size: 12px; color: #999; margin-top: 2px; }
.admin-row .a-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag-role { background: #e64340; color: #fff; font-size: 11px; padding: 1px 5px; border-radius: 4px; margin-left: 6px; }
.tag-muted { background: #fa5151; color: #fff; font-size: 11px; padding: 1px 5px; border-radius: 4px; margin-left: 6px; }
.tag-online { background: #07c160; color: #fff; font-size: 11px; padding: 1px 5px; border-radius: 4px; margin-left: 6px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #ccc; margin-right: 4px; }
.dot.on { background: #07c160; }
.btn.danger { background: #fa5151; color: #fff; }
.btn.danger:hover { filter: brightness(.95); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.primary { background: var(--wx-green); color: #fff; }
.btn.primary.sm { padding: 5px 12px; font-size: 12px; }
.btn.plain.sm { padding: 4px 10px; font-size: 12px; }

/* ---------------- 广播接收对象选择 ---------------- */
.bc-targets-head { display: flex; align-items: center; gap: 10px; margin: 10px 0 6px; }
.bc-targets {
  display: flex; flex-wrap: wrap; gap: 8px; max-height: 220px; overflow-y: auto;
  border: 1px solid #eee; border-radius: 8px; padding: 10px; background: #fafafa;
}
.bc-target {
  display: inline-flex; align-items: center; gap: 5px; font-size: 13px;
  border: 1px solid #d9d9d9; border-radius: 14px; padding: 3px 10px; cursor: pointer;
  background: #fff; user-select: none;
}
.bc-target.sel { background: var(--wx-green); color: #fff; border-color: var(--wx-green); }

/* 深色模式适配 */
:root[data-theme="dark"] .bc-item { background: #232325; border-color: #3d3d3f; }
:root[data-theme="dark"] .admin-row { border-color: #3d3d3f; }
:root[data-theme="dark"] .bc-targets { background: #232325; border-color: #3d3d3f; }
:root[data-theme="dark"] .bc-target { background: #2c2c2e; border-color: #3d3d3f; color: var(--text); }

/* ---------------- 切换账号 ---------------- */
.switch-list { margin: 8px 0; max-height: 50vh; overflow-y: auto; }
:root[data-font="large"] .conv-preview { font-size: 13px; }

/* ---------------- 消息操作（菜单 / 回应 / 引用 / 已读） ---------------- */
.msg-body { position: relative; }
.msg-tools {
  position: absolute; top: 22px; font-size: 13px; color: #a6a6a6; cursor: pointer;
  padding: 0 4px; opacity: 0; transition: opacity .15s; user-select: none;
}
.msg.me .msg-tools { left: -26px; }
.msg:not(.me) .msg-tools { right: -26px; }
.msg:hover .msg-tools { opacity: 1; }
.msg-tools:hover { color: var(--wx-green); }
@media (hover: none) { .msg-tools { opacity: .55; } }

.msg-menu {
  position: fixed; z-index: 40; display: block; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, .18); padding: 6px; min-width: 150px;
  opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.98); transform-origin: top center;
  pointer-events: none;
  transition: opacity .16s ease, visibility .16s ease, transform .16s ease;
}
.msg-menu.show { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
.msg-menu .mm-item {
  display: block; width: 100%; border: 0; background: transparent; text-align: left;
  padding: 7px 10px; font-size: 13px; color: var(--text); cursor: pointer; border-radius: 5px;
}
.msg-menu .mm-item:hover { background: #f0f0f0; }
.msg-menu .mm-item.danger { color: #fa5151; }
.msg-menu .mm-emoji { display: flex; gap: 2px; padding: 4px 6px; }
.msg-menu .mm-emoji button {
  border: 0; background: transparent; font-size: 18px; cursor: pointer; padding: 3px 4px; border-radius: 5px;
}
.msg-menu .mm-emoji button:hover { background: #f0f0f0; }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.reaction {
  border: 1px solid var(--border); background: #fff; border-radius: 11px; padding: 1px 7px;
  font-size: 12px; cursor: pointer; color: #555; display: flex; align-items: center; gap: 3px;
}
.reaction.mine { background: #e7f7ec; border-color: var(--wx-green); color: #06ad56; }
:root[data-theme="dark"] .reaction { background: #3a3a3c; color: var(--text); border-color: #4a4a4c; }
:root[data-theme="dark"] .reaction.mine { background: #2b4a36; border-color: var(--wx-green); color: #7fe0a3; }

.quote {
  border-left: 3px solid var(--wx-green); background: rgba(0, 0, 0, .05); border-radius: 3px;
  padding: 4px 8px; margin-bottom: 5px; font-size: 12.5px; color: var(--text-2);
  max-height: 38px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
:root[data-theme="dark"] .quote { background: rgba(255, 255, 255, .07); }

.msg-recalled, .msg-read {
  font-size: 11.5px; color: #a6a6a6; text-align: right; margin-top: 3px;
}
.msg:not(.me) .msg-recalled { text-align: left; }
.bubble.recalled, .msg.me .bubble.recalled { color: #a6a6a6; font-size: 13px; background: transparent; box-shadow: none; padding: 4px 0; }

/* ---------------- 引用回复条 / 搜索 ---------------- */
.reply-bar {
  display: none; align-items: center; gap: 8px; padding: 6px 10px; margin: 4px 0;
  background: #eef7f0; border-left: 3px solid var(--wx-green); border-radius: 4px; font-size: 12.5px;
}
.reply-bar.show { display: flex; }
.reply-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #555; }
.reply-text b { color: #06ad56; margin-right: 6px; }
:root[data-theme="dark"] .reply-bar { background: #23352a; }
:root[data-theme="dark"] .reply-text { color: var(--text-2); }

.search-panel { display: none; border-bottom: 1px solid var(--border); background: var(--header-bg); padding: 8px 12px; }
.search-panel.show { display: block; }
.search-row { display: flex; gap: 8px; align-items: center; }
.search-row input {
  flex: 1; min-width: 0; padding: 7px 10px; font-size: 16px; border: 1px solid var(--border);
  border-radius: 5px; background: #fff; color: var(--text);
}
.search-scope { display: flex; gap: 6px; margin-top: 6px; }
.scope-btn {
  flex: 1; padding: 5px 0; font-size: 13px; border: 1px solid var(--border); background: #fff;
  color: var(--text-2); border-radius: 5px; cursor: pointer;
}
.scope-btn.active { background: #4257a8; border-color: #4257a8; color: #fff; }
.search-results { max-height: 260px; overflow-y: auto; margin-top: 6px; }
.search-hit {
  padding: 7px 8px; border-radius: 5px; cursor: pointer; font-size: 13px; color: var(--text);
  display: flex; gap: 8px; border-bottom: 1px solid var(--border);
}
.search-hit:hover { background: #f0f0f0; }
.search-hit .hit-time { color: var(--text-2); flex: 0 0 auto; font-size: 11.5px; }
.search-hit .hit-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-hit .hit-room {
  flex: 0 0 auto; font-size: 11px; background: #eef0fa; color: #4257a8; border-radius: 3px;
  padding: 0 5px; margin-right: 2px; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-hit mark { background: #ffe58f; color: inherit; }
.search-empty { font-size: 12.5px; color: var(--text-2); padding: 8px; }

.prefs-row { display: flex; gap: 8px; margin-bottom: 8px; }
.prefs-row .icon-btn { flex: 1; }

/* ---------------- 视频通话画面 ---------------- */
.call-video-wrap { display: none; position: relative; margin: -8px -8px 14px; }
.call-video-wrap.show { display: block; }
#remoteVideo {
  width: 100%; height: 220px; object-fit: cover; border-radius: 10px; background: #000; display: block;
}
#localVideo {
  position: absolute; right: 10px; bottom: 10px; width: 84px; height: 112px;
  object-fit: cover; border-radius: 8px; background: #222; border: 2px solid rgba(255, 255, 255, .7);
}

/* ---------------- 全屏通话模式 ---------------- */
.call-btn.fs { background: #576b95; }
.call-btn.fs:hover { background: #4a5d85; }
.call-overlay.fs {
  background: #000; align-items: stretch; justify-content: stretch; padding: 0;
}
.call-overlay.fs .call-card {
  width: 100vw; max-width: none; height: 100vh; max-height: none;
  border-radius: 0; padding: 0; background: #000; box-shadow: none;
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
/* 视频全屏：远端画面铺满整屏，本地预览作为小窗 */
.call-overlay.fs .call-video-wrap {
  display: block; position: absolute; inset: 0; margin: 0; background: #000;
}
.call-overlay.fs .call-video-wrap:not(.show) { display: none; }
.call-overlay.fs #remoteVideo {
  width: 100%; height: 100%; object-fit: contain; border-radius: 0;
}
.call-overlay.fs #localVideo {
  width: 30vw; max-width: 180px; height: auto; aspect-ratio: 3 / 4;
  right: 16px; bottom: 96px; box-shadow: 0 6px 20px rgba(0, 0, 0, .6);
}
/* 视频全屏时隐藏大头像，名字与状态浮在顶部 */
.call-overlay.fs.video .call-avatar { display: none; }
.call-overlay.fs.video .call-name,
.call-overlay.fs.video .call-status {
  position: absolute; left: 0; right: 0; top: 20px; margin: 0;
  color: #fff; text-shadow: 0 1px 5px rgba(0, 0, 0, .9); text-align: center;
}
.call-overlay.fs.video .call-status { top: 50px; }
/* 语音全屏：大头像居中 */
.call-overlay.fs .call-avatar { width: 140px; height: 140px; font-size: 60px; margin-bottom: 20px; }
.call-overlay.fs .call-name { font-size: 26px; color: #fff; }
.call-overlay.fs .call-status { font-size: 16px; margin-bottom: 0; color: #c8c8c8; }
/* 操作按钮固定在底部 */
.call-overlay.fs .call-actions {
  position: absolute; bottom: 28px; left: 0; right: 0; padding: 0 14px;
  background: transparent;
}
@media (max-width: 520px) {
  .call-overlay.fs #localVideo { width: 38vw; bottom: 92px; }
  .call-overlay.fs .call-name { font-size: 22px; }
}

/* 搜索结果跳转后的高亮闪烁 */
.msg.flash .bubble { animation: msgFlash 1.8s ease-out; }
@keyframes msgFlash {
  0% { box-shadow: 0 0 0 3px var(--wx-green); }
  100% { box-shadow: 0 1px 1px rgba(0, 0, 0, .04); }
}

/* 小屏头部按钮紧凑化，避免按钮过多时溢出 */
@media (max-width: 860px) {
  .header-actions { gap: 5px; }
  .header-actions .icon-btn { padding: 5px 7px; font-size: 12px; }
  .chat-sub { display: none; }
}

/* ---------------- 会话管理：置顶 / 免打扰 / 草稿 / 未读标记 ---------------- */
.conv.pinned { background: #f4f4f4; }
/* 置顶 + 选中时仍要能看出是选中态 */
.conv.pinned.active { background: #c4c4c4; }
.conv.pinned:hover:not(.active) { background: #e4e4e4; }
.pin-mark { font-size: 11px; margin-right: 3px; opacity: .75; }
.mute-mark { margin-right: 3px; opacity: .7; }
.conv-preview.has-draft { color: #e64340; }
.draft-tag { color: #e64340; margin-right: 3px; }
.badge.muted { background: #c8c9cc; min-width: 8px; width: 8px; height: 8px; padding: 0; font-size: 0; }

/* 会话右键菜单（复用 .msg-menu 外观） */
#moreMenu.mm-conv .mm-item { min-width: 168px; }

:root[data-theme="dark"] .conv.pinned { background: #242424; }
:root[data-theme="dark"] .conv.pinned.active { background: #333; }

/* ---------------- 刷屏禁言提示条 ---------------- */
.mute-bar {
  display: none;
  align-items: center;
  gap: 6px;
  margin: 0 10px 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fff4e5;
  color: #b26a00;
  font-size: 13px;
  line-height: 1.4;
  border: 1px solid #ffe0b2;
}
.mute-bar .mute-icon { font-size: 15px; }
#input:disabled, .send-btn:disabled { cursor: not-allowed; }
#input:disabled { background: #f5f5f5; color: #b0b0b0; }

:root[data-theme="dark"] .mute-bar {
  background: #3a2f1c;
  color: #ffc46b;
  border-color: #55452a;
}
:root[data-theme="dark"] #input:disabled { background: #2a2a2a; color: #777; }

/* ---------------- 文件卡片：预览 / 下载 ---------------- */
.file-actions { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.file-pv { font-size: 12px; color: #576b95; text-decoration: none; cursor: pointer; }
.file-pv:hover { opacity: .75; }
:root[data-theme="dark"] .file-pv { color: #8fb3e6; }
:root[data-theme="dark"] .file-dl { color: #8fb3e6; }

/* ---------------- 文件在线预览弹窗 ---------------- */
.fileview {
  background: var(--header-bg); border-radius: 12px; width: min(860px, 96vw);
  height: min(82vh, 760px); display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .3);
}
.fileview-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--header-bg);
}
.fv-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.fileview-acts { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.btn-ghost {
  font-size: 12px; color: #576b95; text-decoration: none; border: 1px solid #c3ccdb;
  padding: 4px 10px; border-radius: 5px; background: #fff; cursor: pointer; white-space: nowrap;
}
.btn-ghost:hover { background: #f0f3f8; }
.mask-x {
  border: 0; background: #e6e6e6; color: #555; width: 26px; height: 26px; border-radius: 50%;
  font-size: 14px; cursor: pointer; line-height: 1; flex: 0 0 auto;
}
.mask-x:hover { background: #d6d6d6; }
.fileview-body { flex: 1; min-height: 0; overflow: auto; background: #fff; position: relative; }
.fv-loading, .fv-err {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  flex-direction: column; color: #888; font-size: 13px; text-align: center; padding: 20px;
}
.fv-text {
  margin: 0; padding: 14px 16px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; color: #222;
}
.fv-media { width: 100%; height: 100%; background: #000; display: block; }
.fv-html { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
:root[data-theme="dark"] .fileview-body { background: #1f1f21; }
:root[data-theme="dark"] .fv-text { color: #e4e4e4; }
:root[data-theme="dark"] .btn-ghost { background: #2c2c2e; color: #8fb3e6; border-color: #3d3d3f; }
:root[data-theme="dark"] .mask-x { background: #3a3a3c; color: #ddd; }

/* ---------------- 动态 / 过渡增强 ---------------- */
/* 弹层内卡片：缩放进场（配合 .mask 的淡入） */
.dialog, .fileview {
  transform: translateY(10px) scale(.965); opacity: 0;
  transition: transform .26s cubic-bezier(.22, .61, .36, 1), opacity .26s ease;
}
.mask.show .dialog, .mask.show .fileview { transform: none; opacity: 1; }

/* 通话卡片：缩放进场 */
.call-card {
  transform: translateY(12px) scale(.96); opacity: 0;
  transition: transform .3s cubic-bezier(.22, .61, .36, 1), opacity .3s ease;
}
.call-overlay.show .call-card { transform: none; opacity: 1; }

/* 动态创建的浮层（emoji / 贴纸面板）：弹出淡入 */
.panel { animation: popIn .18s ease; }

/* 登录卡片：入场弹出 */
.auth-box { animation: popIn .42s cubic-bezier(.22, .61, .36, 1); }

/* 按钮：颜色 / 阴影 / 缩放平滑过渡 + 按压反馈 */
.btn-action, .btn-action.ghost, .send-btn, .auth-btn, .icon-btn, .btn-game, .btn-side,
.tool, .game-send, .auth-admin-btn, .mask-x, .btn, .file-pv, .side-toggle, .btn-ghost {
  transition: background-color .15s ease, color .15s ease, filter .15s ease,
              box-shadow .15s ease, transform .1s ease, border-color .15s ease;
}
.btn-action:active, .btn-action.ghost:active, .send-btn:active, .auth-btn:active,
.icon-btn:active, .btn-game:active, .btn-side:active, .tool:active, .game-send:active,
.auth-admin-btn:active, .mask-x:active, .btn:active, .file-pv:active, .side-toggle:active,
.btn-ghost:active { transform: scale(.96); }
.game-card:active { transform: scale(.97) translateY(-1px); }

/* 内联面板 / 条：入场淡入 */
.search-panel.show, .reply-bar.show, .progress-wrap.show, .call-video-wrap.show {
  animation: fadeIn .2s ease;
}

/* 关键帧 */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to { opacity: 1; transform: none; }
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}
@keyframes appIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes authIn { from { opacity: 0; } to { opacity: 1; } }

/* 尊重系统“减少动态效果”偏好：自动关闭过渡与动画（无障碍 / 低端机友好） */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* 低配模式：为老旧 / 低端设备关闭视觉开销（动画、阴影、模糊、滤镜），降低绘制与合成成本 */
:root[data-lite="1"] *,
:root[data-lite="1"] *::before,
:root[data-lite="1"] *::after {
  animation: none !important;
  transition: none !important;
  transition-property: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  filter: none !important;
}
/* 低配模式进一步收紧：头像用方角、气泡去三角箭头、去掉 will-change 合成层提示，减少重绘 */
:root[data-lite="1"] .avatar { border-radius: 4px; }
:root[data-lite="1"] .bubble .arrow { display: none; }
:root[data-lite="1"] * { will-change: auto !important; }

/* 游戏分享：附带存档勾选 */
.share-save { display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: 13px; color: #333; background: #f6f6f6; border-radius: 8px; margin: 10px 0; cursor: pointer; }
.share-save input { width: 16px; height: 16px; accent-color: var(--wx-green); }
:root[data-theme="dark"] .share-save { background: #2c2c2e; color: #e0e0e0; }
