/* ===================== 基础 ===================== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --wx-green: #07C160;
  --wx-green-dark: #06ad56;
  --bubble-self: #95EC69;
  --bubble-other: #ffffff;
  --rail-bg: #2e2e2e;
  --panel-bg: #ededed;
  --panel-hover: #e7e7e7;
  --panel-active: #d6d6d6;
  --chat-bg: #f5f5f5;
  --text-main: #181818;
  --text-sub: #999;
  --border: #e2e2e2;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-main);
  background: #dcdcdc;
  font-size: 14px;
  overflow: hidden;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; outline: none; border: none; }

/* ===================== 登录 ===================== */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto;              /* 内容超高时可滚动，不再被裁切 */
  -webkit-overflow-scrolling: touch;
  padding: 28px 12px;            /* 上下留白，短内容依然居中 */
  box-sizing: border-box;
  background: linear-gradient(135deg, #0a9d54 0%, #07C160 50%, #0bbf6a 100%);
}
.login-card {
  width: 360px; max-width: 90vw;
  margin: auto;                  /* 配合 align-items:flex-start：内容少则垂直居中，内容多则从顶部完整展开 */
  background: #fff; border-radius: 16px; padding: 34px 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,.28);
}
.login-logo { text-align: center; margin-bottom: 18px; }
.logo-badge {
  width: 58px; height: 58px; border-radius: 16px; background: var(--wx-green);
  color: #fff; font-size: 30px; font-weight: 700; line-height: 58px; margin: 0 auto 12px;
  box-shadow: 0 6px 18px rgba(7,193,96,.35);
}
.login-logo h1 { font-size: 22px; font-weight: 700; }
.login-sub { color: var(--text-sub); font-size: 13px; margin-top: 4px; }
.tabs { display: flex; margin: 18px 0; border-bottom: 1px solid var(--border); }
.tab { flex: 1; text-align: center; padding: 10px 0; color: #999; cursor: pointer; position: relative; }
.tab.active { color: var(--wx-green); font-weight: 600; }
.tab.active::after { content: ""; position: absolute; left: 50%; transform: translateX(-50%); bottom: -1px; width: 42px; height: 3px; background: var(--wx-green); border-radius: 3px; }

#auth-form > div { margin-bottom: 12px; }
.phone-row, .code-row { display: flex; align-items: center; background: #f6f6f6; border-radius: 10px; padding: 0 14px; height: 48px; border: 1px solid #eee; }
.cc { color: #666; margin-right: 8px; font-size: 15px; }
.phone-row input, .code-row input { flex: 1; height: 100%; background: transparent; font-size: 15px; }
.code-row { padding-right: 6px; }
.code-btn { color: var(--wx-green); font-size: 13px; white-space: nowrap; padding: 6px 8px; }
.code-btn:disabled { color: #c0c0c0; }
.reg-only input { width: 100%; height: 48px; background: #f6f6f6; border-radius: 10px; padding: 0 14px; font-size: 15px; border: 1px solid #eee; }
.primary-btn {
  width: 100%; height: 48px; background: var(--wx-green); color: #fff;
  border-radius: 10px; font-size: 16px; font-weight: 600; letter-spacing: 4px; margin-top: 6px;
  box-shadow: 0 6px 16px rgba(7,193,96,.25);
}
.primary-btn:active { background: var(--wx-green-dark); }
.auth-msg { color: #e54d42; font-size: 13px; min-height: 18px; margin-top: 8px; text-align: center; }
.login-tip { color: #b9bec6; font-size: 11px; margin-top: 14px; text-align: center; line-height: 1.55; }
body.night .login-tip { color: #79828f; }

/* 手机扫码打开（仅宽屏/电脑端显示，手机自身无需扫）—— 默认折叠省空间 */
.phone-open {
  margin-top: 12px; border-top: 1px dashed #eee; text-align: center;
}
.phone-open-toggle {
  list-style: none; cursor: pointer; user-select: none;
  color: #9aa0aa; font-size: 12px; line-height: 34px;
}
.phone-open-toggle::-webkit-details-marker { display: none; }
.phone-open-toggle::before { content: "▸ "; font-size: 11px; }
.phone-open[open] .phone-open-toggle::before { content: "▾ "; }
.phone-open-body { padding: 2px 0 4px; }
.phone-open-title { color: var(--text-sub); font-size: 12px; margin-bottom: 8px; }
.phone-qr {
  width: 118px; height: 118px; margin: 0 auto; display: block;
  border: 1px solid #eee; border-radius: 10px; padding: 6px; background: #fff;
}
.phone-open-url {
  margin-top: 10px; color: #07C160; font-size: 12px; word-break: break-all;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
@media (max-width: 600px) {
  .phone-open { display: none; }   /* 手机端自己打开时无需显示二维码 */
}

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

/* 左侧深色导航条 */
.left-rail { width: 64px; background: var(--rail-bg); display: flex; flex-direction: column; align-items: center; padding-top: 28px; flex-shrink: 0; }
.rail-avatar {
  width: 40px; height: 40px; border-radius: 9px; background: var(--wx-green); color: #fff;
  font-size: 18px; font-weight: 700; line-height: 40px; text-align: center; margin-bottom: 24px;
  overflow: hidden; cursor: pointer;
}
.rail-icons { display: flex; flex-direction: column; gap: 4px; width: 100%; align-items: center; }
.rail-icon { width: 100%; text-align: center; padding: 12px 0; position: relative; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.rail-icon svg { width: 24px; height: 24px; fill: #7d7d7d; transition: fill .15s; }
.rail-icon.active { background: rgba(255,255,255,.10); }
.rail-icon.active::before { content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 24px; background: var(--wx-green); border-radius: 0 3px 3px 0; }
.rail-icon.active svg { fill: #fff; }
.rail-label { display: none; font-size: 11px; color: #7d7d7d; line-height: 1; }
.rail-icon.active .rail-label { color: #fff; }
.rail-badge {
  position: absolute; top: 6px; right: 14px; background: #fa5151; color: #fff;
  font-size: 11px; min-width: 16px; height: 16px; line-height: 16px; border-radius: 8px; padding: 0 4px;
  box-shadow: 0 0 0 2px var(--rail-bg);
}

/* 中间面板（宽度可拖动调节） */
.panel { width: 300px; min-width: 200px; max-width: 60vw; background: var(--panel-bg); display: flex; flex-direction: column; flex-shrink: 0; border-right: 1px solid #dcdcdc; }

/* 会话列表 / 聊天区 之间的可拖动分隔条：像微信桌面端一样调整两栏宽度 */
.splitter { width: 6px; flex-shrink: 0; cursor: col-resize; background: transparent; position: relative; z-index: 6; }
.splitter::after { content: ""; position: absolute; left: 2px; top: 0; bottom: 0; width: 2px; background: #dcdcdc; transition: background .15s; }
.splitter:hover::after, .splitter.dragging::after { background: var(--wx-green); }
.panel-head { padding: 12px 14px; }
.chat-head { display: flex; align-items: center; gap: 8px; }
.search-input { width: 100%; height: 32px; background: #dcdcdc; border-radius: 7px; padding: 0 12px; font-size: 13px; color: #333; }
.chat-head .search-input { flex: 1; }
.search-input::placeholder { color: #999; }
.head-add { width: 32px; height: 32px; flex-shrink: 0; border-radius: 7px; background: #dcdcdc; color: #555; font-size: 22px; line-height: 30px; text-align: center; }
.head-add:active { background: #cfcfcf; }
/* 搜索按钮：用小号放大镜，避免与「＋」视觉失衡 */
.head-add.search-add { font-size: 15px; line-height: 32px; }
body.night .head-add.search-add { background: #3a3a3a; }
.view { flex: 1; overflow-y: auto; }
.conv-list, .contact-list { overflow-y: auto; }
.list-empty { text-align: center; color: #aaa; padding: 50px 20px; }
.list-empty-icon { font-size: 44px; margin-bottom: 10px; }
.list-empty-sub { font-size: 12px; color: #bbb; margin-top: 6px; }

/* 会话项 */
.conv-item { display: flex; align-items: center; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid #e0e0e0; transition: background .12s; }
.conv-item:hover { background: var(--panel-hover); }
.conv-item.active { background: var(--panel-active); }
.avatar {
  width: 44px; height: 44px; border-radius: 9px; color: #fff; font-size: 19px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.conv-mid { flex: 1; margin-left: 12px; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: center; }
.conv-name { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.conv-name-wrap { display: flex; align-items: center; flex: 1; min-width: 0; gap: 6px; }
.conv-tag { flex-shrink: 0; font-size: 10px; line-height: 1; color: #07C160; background: rgba(7,193,96,.12); border-radius: 4px; padding: 2px 5px; font-weight: 600; }
.chat-tag { font-size: 11px; line-height: 1; color: #07C160; background: rgba(7,193,96,.12); border-radius: 4px; padding: 3px 6px; font-weight: 600; vertical-align: middle; margin-left: 6px; }
.conv-time { font-size: 11px; color: #b2b2b2; flex-shrink: 0; margin-left: 8px; }
.conv-preview { font-size: 13px; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 5px; }
.unread-badge { background: #fa5151; color: #fff; font-size: 11px; min-width: 18px; height: 18px; line-height: 18px; border-radius: 9px; padding: 0 5px; text-align: center; margin-left: 8px; }

/* 通讯录 */
.contact-section-title { padding: 8px 14px; font-size: 12px; color: #999; background: #e3e3e3; display: flex; justify-content: space-between; align-items: center; }
.mini-btn { background: var(--wx-green); color: #fff; border-radius: 6px; padding: 5px 12px; font-size: 12px; }
.mini-btn.ghost { background: #fff; color: var(--wx-green); border: 1px solid var(--wx-green); }
.contact-item { display: flex; align-items: center; padding: 11px 14px; cursor: pointer; border-bottom: 1px solid #e6e6e6; transition: background .12s; }
.contact-item:hover { background: var(--panel-hover); }
.contact-item .conv-mid { margin-left: 12px; }
.contact-item .conv-name { font-size: 15px; }
.contact-item .conv-preview { font-size: 12px; color: #aaa; }
.contact-actions { display: flex; gap: 8px; margin-left: auto; }
.chev { color: #c8c8c8; font-size: 20px; margin-left: 6px; }

/* 我 */
.me-card { display: flex; align-items: center; padding: 24px 16px; background: #ededed; }
.me-avatar { width: 62px; height: 62px; border-radius: 12px; background: var(--wx-green); color: #fff; font-size: 28px; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.me-info { margin-left: 14px; }
.me-name { font-size: 19px; font-weight: 600; }
.me-status { font-size: 13px; color: #999; margin-top: 4px; }
.me-section { margin-top: 12px; background: #fff; border-radius: 9px; overflow: hidden; }
.me-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid #f0f0f0; font-size: 14px; }
.me-row:last-child { border-bottom: none; }
.me-row.clickable { cursor: pointer; }
.me-row.clickable:active { background: #f7f7f7; }
.me-row .danger { color: #fa5151; }
.me-footer { text-align: center; color: #bbb; font-size: 12px; margin-top: 18px; }

/* ===================== 聊天区 ===================== */
.chat-area { flex: 1; background: var(--chat-bg); background-image:
  radial-gradient(rgba(0,0,0,.012) 1px, transparent 1px); background-size: 22px 22px;
  display: flex; flex-direction: column; min-width: 0; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #b6b6b6; text-align: center; padding: 20px; }
.chat-empty-icon { font-size: 60px; margin-bottom: 10px; }
.chat-empty-title { font-size: 16px; color: #888; }
.chat-empty-sub { font-size: 13px; color: #aaa; margin-top: 6px; }
.empty-cta { margin-top: 18px; background: var(--wx-green); color: #fff; border-radius: 8px; padding: 10px 22px; font-size: 14px; font-weight: 600; box-shadow: 0 4px 14px rgba(7,193,96,.3); }
.empty-cta:active { background: var(--wx-green-dark); }
.chat-active { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.chat-header { height: 60px; border-bottom: 1px solid #e6e6e6; display: flex; align-items: center; padding: 0 18px; background: var(--chat-bg); flex-shrink: 0; }
.back-btn { font-size: 28px; color: #444; margin-right: 8px; line-height: 1; }
.chat-title { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50%; }
.chat-sub { font-size: 12px; color: #999; margin-left: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.hdr-icon { width: 34px; height: 34px; border-radius: 7px; font-size: 18px; color: #444; display: flex; align-items: center; justify-content: center; }
.hdr-icon:active { background: #e3e3e3; }
.more-btn { font-size: 24px; color: #444; width: 34px; height: 34px; border-radius: 7px; display: flex; align-items: center; justify-content: center; }
.more-btn:active { background: #e3e3e3; }

.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; }
.date-sep { text-align: center; margin: 6px 0; }
.date-sep span { background: rgba(0,0,0,.04); color: #9a9a9a; font-size: 10px; padding: 3px 11px; border-radius: 20px; letter-spacing: .3px; }

.msg-row { display: flex; align-items: flex-start; gap: 10px; max-width: 100%; }
.msg-row.self { flex-direction: row-reverse; }
.msg-avatar { width: 40px; height: 40px; border-radius: 8px; color: #fff; font-size: 17px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
/* 内容包裹层：负责占满剩余宽度，气泡在其中按左右对齐并自适应文字宽度 */
.msg-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.msg-body.other { align-items: flex-start; }
.msg-body.self { align-items: flex-end; }
.bubble { max-width: 100%; padding: 10px 13px; border-radius: 8px; font-size: 15px; line-height: 1.5; word-break: break-word; overflow-wrap: anywhere; position: relative; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.msg-row.other .bubble { background: var(--bubble-other); }
.msg-row.self .bubble { background: var(--bubble-self); }
/* 微信风格小三角：指向头像 */
.msg-row.other .bubble::after {
  content: ""; position: absolute; top: 13px; left: -5px;
  border-width: 6px 6px 6px 0; border-style: solid;
  border-color: transparent #ffffff transparent transparent;
}
.msg-row.self .bubble::after {
  content: ""; position: absolute; top: 13px; right: -5px;
  border-width: 6px 0 6px 6px; border-style: solid;
  border-color: transparent transparent transparent #95EC69;
}
.msg-name { font-size: 12px; color: #999; margin-bottom: 4px; display: flex; align-items: center; gap: 5px; }
/* 群主标识：低调的小胶囊，群聊中可辨认但不喧宾夺主 */
.owner-tag {
  flex-shrink: 0;
  font-size: 9px;
  line-height: 1;
  color: #07C160;
  background: rgba(7,193,96,.10);
  border: 1px solid rgba(7,193,96,.28);
  border-radius: 4px;
  padding: 2px 4px;
  font-weight: 600;
  letter-spacing: .3px;
}
.owner-tag.self { align-self: flex-end; margin-bottom: 3px; }
.sys-msg { align-self: center; background: rgba(0,0,0,.04); color: #9a9a9a; font-size: 11px; padding: 4px 12px; border-radius: 20px; margin: 2px 0; letter-spacing: .3px; line-height: 1.4; }
/* 系统消息（入群/退群/转让群主/改密码等）：整行居中，不带头像气泡 */
.msg-row.sys-row { justify-content: center; }
.msg-row.sys-row .sys-msg { background: rgba(0,0,0,.04); color: #9a9a9a; max-width: 86%; text-align: center; }
body.night .msg-row.sys-row .sys-msg { background: rgba(255,255,255,.07); color: #8c8c8c; }

/* 语音消息气泡 */
.voice-bubble { display: flex; align-items: center; gap: 8px; cursor: pointer; min-width: 64px; }
.voice-bubble .voice-icon { font-size: 14px; line-height: 1; }
.voice-bubble .voice-dur { font-size: 13px; }
.voice-bubble.voice-self { flex-direction: row-reverse; }
.voice-bubble.playing .voice-icon { color: var(--wx-green); }

/* 输入区：白卡片化，更像微信输入框 */
.composer { border-top: 1px solid #e6e6e6; background: var(--chat-bg); padding: 10px 14px 14px; flex-shrink: 0; }
.composer-tools { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; position: relative; }
.tool-btn { width: 34px; height: 34px; border-radius: 7px; font-size: 20px; display: flex; align-items: center; justify-content: center; position: relative; }
.tool-btn:active { background: #e3e3e3; }
.tool-btn.recording { background: #fa5151; }
.tool-btn.recording::after { content: ""; position: absolute; inset: 0; border-radius: 7px; border: 2px solid #fa5151; animation: recpulse 1s infinite; }
@keyframes recpulse { 0% { opacity: .9; } 50% { opacity: .3; } 100% { opacity: .9; } }
.emoji-pop { position: absolute; bottom: 42px; left: 0; width: 264px; background: #fff; border: 1px solid #e0e0e0; border-radius: 10px; padding: 8px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 5; }
.emoji-pop span { font-size: 20px; text-align: center; cursor: pointer; padding: 2px; border-radius: 4px; }
.emoji-pop span:active { background: #eee; }
.composer textarea { width: 100%; min-height: 44px; max-height: 130px; resize: none; font-size: 15px; line-height: 1.5; background: #fff; border: 1px solid #e2e2e2; border-radius: 9px; padding: 11px 13px; box-shadow: inset 0 1px 2px rgba(0,0,0,.02); }
.composer-bottom { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.composer-hint { margin-right: auto; font-size: 12px; color: #999; }
.send-btn { background: var(--wx-green); color: #fff; padding: 8px 24px; border-radius: 7px; font-size: 14px; font-weight: 600; box-shadow: 0 3px 8px rgba(7,193,96,.22); }
.send-btn:active { background: var(--wx-green-dark); }

/* “新消息”悬浮提示：滚动到顶部看历史时，下方有新消息则提示，点击回到最新 */
.scroll-pill {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 122px; z-index: 7;
  background: var(--wx-green); color: #fff;
  font-size: 12px; padding: 6px 14px; border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,.22); cursor: pointer;
  display: flex; align-items: center; gap: 4px; white-space: nowrap;
}
.scroll-pill.hidden { display: none; }
.scroll-pill .pill-count { background: #fff; color: var(--wx-green); border-radius: 9px; padding: 0 6px; font-weight: 700; }

/* ===================== 弹层 / Toast ===================== */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { width: 340px; max-width: 92vw; background: #fff; border-radius: 14px; padding: 22px; }
.modal h3 { font-size: 17px; margin-bottom: 14px; }
.modal .field { margin-bottom: 12px; }
.modal label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }
.modal input, .modal textarea { width: 100%; height: 42px; background: #f4f4f4; border-radius: 8px; padding: 0 12px; font-size: 15px; border: none; }
.modal .modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal .modal-actions button { flex: 1; height: 42px; border-radius: 8px; font-size: 15px; }
.btn-primary { background: var(--wx-green); color: #fff; }
.btn-ghost { background: #f0f0f0; color: #333; }
.modal .hint { color: #e54d42; font-size: 12px; min-height: 16px; margin-top: 4px; }

.toast { position: fixed; left: 50%; top: 40px; transform: translateX(-50%); background: rgba(0,0,0,.8); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; z-index: 200; }

/* 通话悬浮窗 */
.call-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.8); display: flex; align-items: center; justify-content: center; z-index: 300; }
.call-card { position: relative; width: 300px; max-width: 88vw; background: #2b2b2b; border-radius: 18px; padding: 28px 22px; text-align: center; color: #fff; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.call-avatar { width: 72px; height: 72px; border-radius: 16px; background: var(--wx-green); color: #fff; font-size: 30px; font-weight: 700; line-height: 72px; margin: 0 auto 14px; }
.call-name { font-size: 20px; font-weight: 600; }
.call-state { font-size: 13px; color: #bbb; margin-top: 6px; min-height: 18px; }
.call-remote { width: 100%; max-height: 240px; border-radius: 12px; margin-top: 14px; background: #000; }
.call-local { position: absolute; right: 16px; bottom: 16px; width: 92px; height: 124px; border-radius: 10px; object-fit: cover; background: #000; border: 2px solid rgba(255,255,255,.3); z-index: 1; }
.call-actions { display: flex; gap: 18px; justify-content: center; margin-top: 24px; }
.call-btn { width: 60px; height: 60px; border-radius: 50%; font-size: 14px; font-weight: 600; color: #fff; }
.call-btn.accept { background: var(--wx-green); }
.call-btn.reject, .call-btn.hangup { background: #fa5151; }
.call-btn:active { opacity: .85; }

/* ===================== 响应式：手机 ===================== */
@media (max-width: 820px) {
  .left-rail { position: fixed; bottom: 0; left: 0; right: 0; top: auto; width: 100%; height: 56px; flex-direction: row; padding: 0; justify-content: space-around; align-items: center; z-index: 40; }
  .rail-avatar { display: none; }
  .rail-icons { flex-direction: row; width: 100%; justify-content: space-around; gap: 0; }
  .rail-icon { flex-direction: column; gap: 2px; padding: 6px 0; flex: 1; }
  .rail-icon.active::before { display: none; }
  .rail-label { display: block; }
  .rail-badge { right: 50%; transform: translateX(20px); top: 2px; box-shadow: 0 0 0 2px var(--rail-bg); }
  .panel { width: 100% !important; height: calc(100vh - 56px); border-right: none; }
  .splitter { display: none; }
  .chat-area { position: fixed; inset: 0; z-index: 50; }
  .chat-area:not(.open) { display: none; }
  .back-btn { display: inline-block; }
  .panel-head { padding-top: 14px; }
  .bubble { max-width: 72%; }
  /* 聊天头部按钮变多后，标题让出空间 */
  .chat-title { max-width: 34%; }
  .chat-sub { display: none; }
  .msp-head { padding: 10px 14px; }
  .msp-results { padding: 0 14px 10px; }
}

/* 夜间模式 */
body.night { --panel-bg: #2a2a2a; --panel-hover: #333; --panel-active: #3a3a3a; --chat-bg: #1e1e1e; --text-main: #e6e6e6; --text-sub: #999; --border: #333; }
body.night .left-rail { background: #1f1f1f; }
body.night .rail-icon.active::before { box-shadow: 0 0 0 0 transparent; }
body.night .conv-item { border-bottom-color: #333; }
body.night .conv-preview, body.night .conv-time { color: #888; }
body.night .search-input, body.night .head-add { background: #3a3a3a; color: #ddd; }
body.night .msg-row.other .bubble { background: #2c2c2c; color: #e6e6e6; }
body.night .msg-row.other .bubble::after { border-color: transparent #2c2c2c transparent transparent; }
body.night .composer, body.night .chat-header { background: #1e1e1e; }
body.night .composer textarea { background: #2b2b2b; color: #e6e6e6; border-color: #3a3a3a; }
body.night .me-section, body.night .modal { background: #2a2a2a; color: #e6e6e6; }
body.night .me-row { border-bottom-color: #333; }
body.night .primary-btn, body.night .mini-btn, body.night .send-btn, body.night .btn-primary, body.night .empty-cta { background: var(--wx-green); color: #fff; }
body.night .date-sep span { background: rgba(255,255,255,.08); color: #888; }

/* 右键/长按菜单：危险项（彻底删除） */
.ctx-item.ctx-danger { color: #e64340; }
.ctx-item.ctx-danger:hover { background: #e64340; color: #fff; }

/* 通讯录：添加好友引导 */
.contact-hint {
  padding: 14px 16px;
  margin: 8px 12px;
  border-radius: 10px;
  background: rgba(7, 193, 96, .08);
  color: #07c160;
  font-size: 13px;
  line-height: 1.5;
}
body.night .contact-hint { background: rgba(7, 193, 96, .14); color: #3ddc84; }
.contact-add-title { cursor: pointer; }
.contact-add-title:hover { color: #07c160; }
#contact-add-btn { white-space: nowrap; flex: 0 0 auto; }

/* ===================== 已读回执 / 撤回 / 分页 / 右键菜单 ===================== */
.load-more {
  text-align: center;
  color: #576b95;
  font-size: 13px;
  padding: 8px 0;
  cursor: pointer;
  user-select: none;
}
.load-more:hover { text-decoration: underline; }
.read-tick {
  font-size: 10px;
  color: #c4c4c4;
  text-align: right;
  margin-top: 3px;
  letter-spacing: .3px;
}
.read-tick::before { content: "\2713"; margin-right: 3px; color: #b6d09a; }
.msg-row.recall-row { justify-content: center; }
/* 从搜索结果跳转定位到消息时的高亮 */
.msg-row.msg-hit .bubble {
  animation: msgHit 2.4s ease-out;
  box-shadow: 0 0 0 2px #ffcc00;
}
@keyframes msgHit {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 204, 0, 0); }
  15%, 60% { box-shadow: 0 0 0 2px rgba(255, 204, 0, .95); }
}
.recall-msg {
  align-self: center;
  background: rgba(0,0,0,.04);
  color: #9a9a9a;
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 20px;
  max-width: 80%;
  text-align: center;
  letter-spacing: .3px;
  line-height: 1.4;
}
body.night .recall-msg { background: rgba(255,255,255,.06); color: #8c8c8c; }
#ctx-menu {
  position: fixed;
  z-index: 9999;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0,0,0,.18);
  padding: 4px;
  min-width: 132px;
}
body.night #ctx-menu { background: #2a2a2a; color: #e6e6e6; box-shadow: 0 4px 18px rgba(0,0,0,.5); }
.ctx-item {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.ctx-item:hover { background: #07C160; color: #fff; }

/* ===================== 消息搜索 ===================== */
.msg-search-panel {
  background: var(--chat-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  max-height: 60%;
  display: flex;
  flex-direction: column;
}
.msp-head { display: flex; align-items: center; gap: 8px; padding: 10px 18px; }
.msp-head .search-input { flex: 1; height: 34px; }
.msp-close {
  width: 30px; height: 30px; border-radius: 7px; color: #666; font-size: 17px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.msp-close:active { background: #e3e3e3; }
.msp-results { overflow-y: auto; padding: 0 18px 10px; }
.msp-empty { text-align: center; color: var(--text-sub); font-size: 13px; padding: 26px 0; }
.msp-item {
  padding: 9px 10px; border-radius: 7px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.msp-item:hover { background: var(--panel-hover); }
.msp-item:last-child { border-bottom: none; }
.msp-sender { font-size: 12px; color: var(--text-sub); margin-bottom: 3px; }
.msp-text { font-size: 14px; line-height: 1.45; word-break: break-word; overflow-wrap: anywhere; }
.msp-text mark { background: #ffe08a; color: inherit; border-radius: 2px; padding: 0 1px; }
.msp-time { font-size: 11px; color: var(--text-sub); margin-top: 3px; }

/* 全局搜索（会话列表顶部） */
.gs-item {
  padding: 10px 12px; border-radius: 8px; cursor: pointer; margin-bottom: 6px;
  background: #f7f7f7; border: 1px solid var(--border);
}
.gs-item:hover { background: var(--panel-hover); }
.gs-conv { font-size: 11px; color: var(--wx-green); font-weight: 600; margin-bottom: 4px; }
.gs-text { font-size: 13px; line-height: 1.45; color: var(--text-main); word-break: break-word; overflow-wrap: anywhere; }
.gs-text mark { background: #ffe08a; border-radius: 2px; padding: 0 1px; }
.gs-meta { font-size: 11px; color: var(--text-sub); margin-top: 4px; }
.gs-results { max-height: 46vh; overflow-y: auto; margin-top: 8px; }

/* ===================== 群成员列表 / 群管理 ===================== */
.gm-list { max-height: 52vh; overflow-y: auto; margin: 0 -6px; }
.gm-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 6px;
  border-bottom: 1px solid var(--border);
}
.gm-item:last-child { border-bottom: none; }
.gm-avatar {
  width: 38px; height: 38px; border-radius: 8px; color: #fff; font-size: 16px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.gm-mid { flex: 1; min-width: 0; }
.gm-name { font-size: 14px; display: flex; align-items: center; gap: 6px; }
.gm-phone { font-size: 11px; color: var(--text-sub); margin-top: 2px; }
.gm-badge {
  font-size: 10px; background: var(--wx-green); color: #fff; border-radius: 3px; padding: 1px 5px; font-weight: 500;
}
.gm-badge.gray { background: #b0b0b0; }
.gm-act { font-size: 12px; color: #576b95; padding: 5px 9px; border-radius: 6px; flex-shrink: 0; }
.gm-act:active { background: var(--panel-hover); }
.gm-act.danger { color: #e54d42; }
.gm-footer {
  border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.gm-foot-btn {
  width: 100%; height: 40px; border-radius: 8px; font-size: 14px;
  background: #f0f0f0; color: #333;
}
.gm-foot-btn.primary { background: var(--wx-green); color: #fff; }
.gm-foot-btn.danger { background: #fff; color: #e54d42; border: 1px solid #e54d42; }
.gm-foot-btn:active { opacity: .8; }
.gm-note {
  font-size: 12px; color: var(--text-sub); background: #f7f7f7; border-radius: 7px;
  padding: 8px 10px; margin-bottom: 10px; line-height: 1.5;
}
body.night .msg-search-panel { background: var(--chat-bg); }
body.night .msp-item:hover { background: var(--panel-hover); }
body.night .msp-text mark, body.night .gs-text mark { background: #6b5a1f; color: #ffe9a8; }
body.night .gs-item { background: #2a2a2a; }
body.night .gm-item { border-bottom-color: #333; }
body.night .gm-note { background: #2a2a2a; }
body.night .gm-foot-btn { background: #333; color: #e6e6e6; }
body.night .gm-foot-btn.danger { background: transparent; color: #e54d42; }

/* ===================== 消息时间标签 ===================== */
.msg-time-label { text-align: center; font-size: 10px; color: #b0b0b0; margin: 10px 0 4px; letter-spacing: .4px; }

/* 图片大图预览（lightbox） */
.img-preview { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 400; cursor: zoom-out; }
.img-preview img { max-width: 96vw; max-height: 96vh; object-fit: contain; border-radius: 6px; }

/* 正在输入提示 */
.typing-tip { text-align: center; color: var(--wx-green); font-size: 11px; padding: 4px 0 2px; flex-shrink: 0; letter-spacing: .3px; }
/* 正在输入：三颗跳动的圆点 */
.t-dots { display: inline-flex; gap: 3px; margin-left: 2px; vertical-align: middle; }
.t-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--wx-green); opacity: .4; animation: tBounce 1.2s infinite ease-in-out; }
.t-dots i:nth-child(2) { animation-delay: .2s; }
.t-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes tBounce { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }
/* 系统提示出现时的柔和淡入 */
.sys-msg, .recall-msg, .typing-tip, .msg-time-label, .date-sep span { animation: hintFade .25s ease both; }
@keyframes hintFade { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }

/* 引用回复：发送态的引用条（composer 上方） */
.quote-bar { display: flex; align-items: center; gap: 6px; margin: 0 10px 8px; padding: 8px 10px; background: rgba(0,0,0,.04); border-left: 3px solid var(--wx-green); border-radius: 6px; font-size: 13px; color: #666; }
.quote-bar .qb-name { color: var(--wx-green); flex-shrink: 0; }
.quote-bar .qb-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quote-bar .qb-close { flex-shrink: 0; cursor: pointer; color: #999; padding: 0 2px; font-size: 13px; }
.quote-bar .qb-close:active { color: #fa5151; }

/* 引用回复：气泡内的引用预览小条 */
.bubble-quote { max-width: 100%; margin-bottom: 4px; padding: 5px 8px; background: rgba(0,0,0,.04); border-radius: 6px; font-size: 12px; color: #888; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bubble-quote .bq-name { color: var(--wx-green); margin-right: 4px; }

/* 夜间模式补充 */
body.night .quote-bar { background: rgba(255,255,255,.06); color: #aaa; }
body.night .bubble-quote { background: rgba(255,255,255,.07); color: #999; }

/* PWA 安装到桌面按钮 */
.pwa-install {
  position: fixed; right: 14px; bottom: 18px; z-index: 9999;
  padding: 10px 16px; border: 0; border-radius: 24px;
  background: var(--wx-green, #07C160); color: #fff;
  font-size: 14px; font-weight: 600; box-shadow: 0 6px 20px rgba(7,193,96,.4);
  cursor: pointer;
}
.pwa-install[hidden] { display: none !important; }

/* 下载中心入口 */
.download-link { display: inline-block; margin-top: 10px; color: #07C160; font-size: 12px; text-decoration: none; border-bottom: 1px dashed #07C160; }
.download-link:hover { color: #06a853; }

/* ===== 账号体系：临时/正式注册 ===== */
.temp-notice {
  background: #FFF7E6; border: 1px solid #FFE0A3; color: #8a6100;
  border-radius: 8px; padding: 10px 12px; font-size: 12px; line-height: 1.6;
  margin-bottom: 12px;
}
.temp-notice b { color: #c0392b; }
body.night .temp-notice { background: #3a2f18; border-color: #6b5320; color: #e8c884; }
.pane-temp input, .pane-register input {
  width: 100%; margin-bottom: 10px; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; box-sizing: border-box;
}
.pane-login input:not([type=checkbox]) {
  width: 100%; margin-bottom: 10px; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; box-sizing: border-box;
}
/* 手机号/验证码是灰底圆角容器里的“裸 input”，必须去掉内层描边，否则出现“框中框” */
.pane-login .phone-row input, .pane-login .code-row input,
.pane-register .phone-row input, .pane-register .code-row input {
  width: auto; flex: 1; margin-bottom: 0; border: 0; padding: 0; height: 100%; box-shadow: none;
  background: transparent; outline: none;
}
.pane-register .code-row input:focus, .pane-login .code-row input:focus { box-shadow: none; }
.temp-restore { text-align: center; font-size: 12px; color: #999; margin: 6px 0; }
.temp-restore a { color: var(--wx-green); text-decoration: none; }

/* ===== 服务连接状态提示（服务未启动时明确告知，不再“Failed to fetch”） ===== */
.conn-status {
  margin: 10px 0; padding: 9px 11px; border-radius: 8px; font-size: 12px; line-height: 1.6;
  background: #FFF1F0; border: 1px solid #FFCCC7; color: #cf1322;
}
.conn-status.ok { background: #F6FFED; border-color: #B7EB8F; color: #389e0d; }
body.night .conn-status { background: #3a1c1c; border-color: #6b2b2b; color: #ff9c9c; }
body.night .conn-status.ok { background: #1f2e18; border-color: #3f6b2b; color: #9fd77a; }

/* ===== 二维码失败时的文字兜底 ===== */
.qr-fallback {
  width: 150px; min-height: 150px; margin: 0 auto; padding: 14px 10px; box-sizing: border-box;
  border: 1px dashed #ccc; border-radius: 10px; background: #fafafa;
  font-size: 12px; color: #666; line-height: 1.6; word-break: break-all; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}

/* ===== 邮箱自助注册：方式切换 + 说明 ===== */
.reg-mode { display: flex; gap: 6px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.reg-mode-tab {
  flex: 1; text-align: center; padding: 8px 0; font-size: 12px; color: #999; cursor: pointer;
  position: relative; white-space: nowrap;
}
.reg-mode-tab.active { color: var(--wx-green); font-weight: 600; }
.reg-mode-tab.active::after {
  content: ""; position: absolute; left: 50%; transform: translateX(-50%); bottom: -1px;
  width: 60%; height: 2px; background: var(--wx-green); border-radius: 2px;
}
/* 注册页说明文字：小字 + 淡化，不抢视觉重点 */
.reg-note { color: #b7bcc4; font-size: 11px; line-height: 1.55; margin: 12px 2px 0; text-align: center; }
body.night .reg-note { color: #7f8792; }

/* 邮箱账号说明：更淡的小字，仅作轻提示 */
.reg-acct-hint {
  color: #9aa0aa; font-size: 11px; line-height: 1.5;
  margin: 0 2px 12px; text-align: center; font-weight: 400;
}
body.night .reg-acct-hint { color: #79828f; }
.reg-acct-hint b { color: #6fbf95; font-weight: 500; }
/* 登录/注册页顶部的账号输入框（非手机号）保持统一圆角 */
.pane-login > input, .pane-register > input {
  width: 100%; height: 44px; box-sizing: border-box;
}
/* 注册页输入框：聚焦柔和高光，整体更精致 */
.pane-register input:focus, .pane-login input:focus {
  border-color: var(--wx-green); outline: none;
  box-shadow: 0 0 0 3px rgba(7,193,96,.10);
  transition: border-color .15s, box-shadow .15s;
}
/* 注册方式切换：弱化分割线，标签更轻 */
.reg-mode { border-bottom-color: #eef0f2; margin-bottom: 14px; }
.reg-mode-tab { color: #a8adb5; font-size: 12px; }

/* ===== 验证码框：始终只有外层一个框，内层 input 彻底裸着（含聚焦态） =====
   原因：.pane-register input:focus 会给 input 加 border-color + box-shadow，
   和外层 .code-row 的灰底边框叠成“两层框”。这里用高优先级覆盖，
   并把焦点高光移到外层容器上，视觉上永远只有一层。 */
.pane-register .code-row input,
.pane-register .code-row input:focus,
.pane-login .code-row input,
.pane-login .code-row input:focus {
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  background: transparent !important;
}
.pane-register .code-row:focus-within,
.pane-login .code-row:focus-within {
  border-color: var(--wx-green);
  box-shadow: 0 0 0 3px rgba(7,193,96,.10);
}
