:root {
  --bg: #f5f7f6;
  --panel: #ffffff;
  --line: #e4e9e6;
  --line-strong: #d7dfda;
  --ink: #1d2622;
  --muted: #7a8580;
  --soft: #f0f4f2;
  --green: #13795b;
  --green-dark: #0c6047;
  --green-soft: #dff4e9;
  --blue: #4671a5;
  --blue-soft: #e8eff8;
  --amber: #a66b1f;
  --amber-soft: #fff1dc;
  --danger: #b55353;
  --danger-soft: #f9e7e7;
  --hover-bg: #eef4f0;
  --active-hover-bg: #d6edde;
  --card-bg: #fafcfb;
  --chat-bg: #fbfcfb;
  --header-bg: rgba(255, 255, 255, .9);
  --banner-bg: #f6fbf8;
  --banner-line: #e0eee6;
  --toast-bg: #1d2622;
  --toast-ink: #ffffff;
  --brand-chip: #1d2622;
  --shadow: 0 16px 44px rgba(29, 38, 34, 0.08);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-width: 320px; min-height: 100%; background: var(--bg); color: var(--ink); }
body { position: relative; }

.app-loading { align-items: center; background: var(--bg); display: flex; flex-direction: column; gap: 16px; inset: 0; justify-content: center; position: fixed; z-index: 999; transition: opacity .35s ease; }
.app-loading.is-hidden { opacity: 0; pointer-events: none; }

/* =================== 登录过场动画 ===================
   登录成功后盖住整屏做一句问候，随后整体散开露出主界面，
   避免「认证页一消失、主界面硬切出来」的突兀感。 */
.enter-transition {
  align-items: center; background: var(--bg); display: flex; inset: 0;
  justify-content: center; position: fixed; z-index: 400;
  opacity: 0; transition: opacity .3s ease;
}
.enter-transition.is-active { opacity: 1; }
/* 散开：整体上浮淡出，交给下面的 .is-done 触发 */
.enter-transition.is-done { opacity: 0; transform: translateY(-14px); transition: opacity .4s ease, transform .4s cubic-bezier(.33, 1, .38, 1); }

.enter-card { align-items: center; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.enter-avatar {
  align-items: center; background: var(--green-soft); border-radius: 50%;
  color: var(--green-dark); display: flex; font-size: 26px; font-weight: 500;
  height: 68px; justify-content: center; width: 68px;
  animation: enterAvatarIn .5s cubic-bezier(.34, 1.56, .64, 1) both;
}
@keyframes enterAvatarIn { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
.enter-card strong { color: var(--ink); font-size: 17px; font-weight: 500; }
.enter-card > span { color: var(--muted); font-size: 12px; }
/* 进度条：初始化耗时不确定，用一条循环扫光表达「正在进行」而非真实进度 */
.enter-bar { background: var(--line); border-radius: 99px; height: 3px; margin-top: 6px; overflow: hidden; width: 132px; }
.enter-bar i { background: var(--green); border-radius: 99px; display: block; height: 100%; width: 40%; animation: enterBar 1.15s ease-in-out infinite; }
@keyframes enterBar { 0% { transform: translateX(-110%); } 100% { transform: translateX(320%); } }

/* 主界面「进入中」：略透明 + 轻微放大，落定时归位 */
.app-shell.is-entering { opacity: 0; transform: scale(.985); }
.app-shell.is-ready { transition: opacity .42s ease, transform .42s cubic-bezier(.33, 1, .38, 1); }

/* 认证页淡出（与 JS 的 220ms 等待对齐） */
.auth-pages.auth-leaving { opacity: 0; transform: scale(.99); transition: opacity .22s ease, transform .22s ease; pointer-events: none; }

/* 尊重「减少动态效果」偏好：全部退化为直接切换 */
@media (prefers-reduced-motion: reduce) {
  .enter-avatar, .enter-bar i { animation: none; }
  .enter-transition, .enter-transition.is-done { transform: none; }
  .app-shell.is-entering { opacity: 1; transform: none; }
  .auth-pages.auth-leaving { transform: none; }
}
.loader { animation: spin .9s linear infinite; border: 3px solid var(--line); border-top-color: var(--green); border-radius: 50%; height: 28px; width: 28px; }
@keyframes spin { to { transform: rotate(360deg); } }
.app-shell { display: none; }
/* 三态自适应布局：
   ≥1181px  桌面三列（通讯录 / 聊天 / 会话详情）
   721-1180 平板双列（通讯录 + 聊天，详情改为浮层抽屉）
   ≤720px   手机单列页面栈（列表页 ↔ 聊天页，用 .is-chat-open 切换）
   高度用 100dvh：移动端浏览器地址栏收起/展开时不会留白或溢出 */
.app-shell.is-ready { --info-col: 0px; display: grid; grid-template-columns: 286px minmax(440px, 1fr) var(--info-col); grid-template-rows: minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; transition: grid-template-columns .38s cubic-bezier(.33, 1, .38, 1); }
/* 第三列宽度用变量驱动：关闭详情是 0px，打开才展开到 330px。
   好处是 .info-panel 的 width 能与栅格列宽共用同一个值，不会各写各的导致不同步。 */
.app-shell.is-ready.is-info-open { --info-col: 330px; }
body { font-size: 14px; }
button, input, textarea, select { font: inherit; }
button { background: transparent; border: 0; color: inherit; cursor: pointer; user-select: none; -webkit-user-select: none; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid rgba(19, 121, 91, .45); outline-offset: 2px; }
a, button, .friend-item, .shared-file, [role="button"], [data-action] { cursor: pointer; }
[disabled] { cursor: not-allowed !important; pointer-events: auto !important; }
* { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.sidebar, .info-panel { background: var(--panel); }
.sidebar { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.brand { align-items: center; display: flex; gap: 11px; padding: 25px 23px 21px; }
.brand strong { display: block; font-size: 16px; letter-spacing: .01em; }
.brand small { color: var(--muted); display: block; font-size: 11px; margin-top: 3px; }
.brand-mark { align-items: center; background: var(--brand-chip); border-radius: 11px; display: flex; gap: 3px; height: 34px; justify-content: center; transform: rotate(-8deg); width: 34px; }
.brand-mark span { background: #a6d9be; border-radius: 5px 5px 2px 2px; display: block; height: 16px; width: 4px; }
.brand-mark span:nth-child(2) { background: #e2b861; height: 21px; }
.brand-mark span:nth-child(3) { background: #83aecf; height: 11px; }
.profile-row { align-items: center; border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); display: flex; gap: 10px; padding: 14px 20px; }
.profile-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.profile-copy strong { font-size: 13px; }
.profile-copy span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.status-dot { background: #27a869; border-radius: 50%; display: inline-block; height: 6px; margin-right: 5px; vertical-align: 1px; width: 6px; }
.avatar { align-items: center; border-radius: 50%; color: #28342e; display: flex; flex: 0 0 auto; font-size: 14px; font-weight: 700; height: 38px; justify-content: center; width: 38px; }
.avatar-self { background: #f1d6ac; }
.avatar-mint { background: #bbdfcd; }
.avatar-blue { background: #bfd1eb; }
.avatar-lilac { background: #dbd0e8; }
.avatar-coral { background: #f0c7bb; }
.avatar-yellow { background: #eedc9f; }
.avatar-xs { font-size: 11px; height: 24px; width: 24px; }
.avatar-lg { font-size: 23px; height: 64px; width: 64px; }
.avatar-status { position: relative; }
.avatar-status::after { background: #27a869; border: 2px solid var(--panel); border-radius: 50%; bottom: 0; content: ""; height: 8px; position: absolute; right: -1px; width: 8px; }
/* 「离开」要能一眼看出来。隐身与离线都不加 avatar-status，自然也就没有这个点。 */
.avatar-status.is-away::after { background: #e8a13c; }
.sidebar-section { padding: 19px 16px 10px; }
.section-heading, .info-section-title { align-items: center; display: flex; justify-content: space-between; }
.section-heading { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.icon-button { align-items: center; background: transparent; border-radius: 8px; color: var(--muted); display: inline-flex; height: 32px; justify-content: center; padding: 0; width: 32px; }
.icon-button:hover, .tool-button:hover { background: var(--soft); color: var(--ink); }
.icon-button.small { height: 26px; width: 26px; }
.search-box { align-items: center; background: var(--soft); border: 1px solid transparent; border-radius: 8px; display: flex; gap: 8px; margin-top: 13px; padding: 0 10px; }
.search-box:focus-within { background: var(--panel); border-color: var(--line-strong); }
.search-box input { background: transparent; border: 0; color: var(--ink); flex: 1; min-width: 0; outline: none; padding: 10px 0; }
.search-box input::placeholder { color: #9ba59f; }
.search-mode { display: flex; gap: 2px; }
.search-mode button { border-radius: 5px; color: var(--muted); font-size: 10px; padding: 3px 8px; transition: background-color .18s ease, color .18s ease; }
.search-mode button:hover { color: var(--ink); }
.search-mode button.is-active { background: var(--green-soft); color: var(--green-dark); font-weight: 700; }
mark { background: #ffe9a8; border-radius: 3px; color: #4a3b12; padding: 0 1px; }
.dark mark { background: #5c4a12; color: #ffe9a8; }
.search-toolbar { align-items: center; background: var(--green-soft); border-radius: 8px; color: var(--green-dark); display: flex; font-size: 11px; gap: 8px; justify-content: space-between; margin-bottom: 14px; padding: 8px 12px; }
.search-toolbar[hidden] { display: none; }
.search-toolbar strong { font-size: 12px; }
.search-toolbar .text-button { color: var(--green-dark); }
.match-count { align-items: center; background: var(--amber-soft); border-radius: 50%; color: var(--amber); display: inline-flex; font-size: 10px; height: 17px; justify-content: center; min-width: 17px; padding: 0 4px; }

/* ── 文件/媒体预览 ── */
.message-file[data-preview], .message-file[data-file-id], .message-media-wrap.clickable { cursor: pointer; }
.message-file .file-icon { transition: transform .2s ease; }
.message-file:hover .file-icon { transform: scale(1.1); }
.preview-modal { background: var(--panel); border-radius: 14px; box-shadow: 0 25px 80px rgba(0, 0, 0, .4); display: flex; flex-direction: column; max-height: calc(100vh - 60px); max-width: min(760px, calc(100vw - 40px)); overflow: hidden; width: 100%; }
.preview-head { align-items: center; border-bottom: 1px solid var(--line); display: flex; gap: 10px; justify-content: space-between; padding: 13px 18px; }
.preview-head strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-body { align-items: center; background: var(--chat-bg); display: flex; flex: 1; justify-content: center; min-height: 200px; overflow: auto; padding: 18px; }
.preview-media { border-radius: 10px; max-height: 56vh; max-width: 100%; object-fit: contain; }
.preview-audio { align-items: center; display: flex; flex-direction: column; gap: 18px; padding: 26px 10px; width: 100%; }
.preview-audio-icon { align-items: center; animation: floaty 3.4s ease-in-out infinite; background: var(--green-soft); border-radius: 50%; color: var(--green); display: flex; height: 86px; justify-content: center; width: 86px; }
.preview-audio-icon .icon { height: 36px; width: 36px; }
.preview-audio-name { font-size: 13px; }
.preview-audio audio { max-width: 420px; width: 100%; }
.preview-empty, .preview-loading { align-items: center; color: var(--muted); display: flex; flex-direction: column; font-size: 12px; gap: 12px; justify-content: center; min-height: 170px; width: 100%; }
.preview-foot { align-items: center; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: space-between; padding: 12px 18px; }
.preview-note { align-items: center; color: var(--muted); display: inline-flex; font-size: 10px; gap: 4px; }
.preview-foot .primary-button { width: auto; }

/* ── 音视频通话 ── */
.call-overlay { align-items: center; background: #0c110f; display: flex; flex-direction: column; inset: 0; height: 100dvh; position: fixed; z-index: 60; }
.call-overlay[hidden] { display: none; }
#call-remote-video { height: 100%; inset: 0; object-fit: cover; position: absolute; width: 100%; }
.call-center { align-items: center; display: flex; flex-direction: column; gap: 20px; left: 0; position: absolute; right: 0; top: 16vh; }
.call-audio-avatar { align-items: center; background: var(--green-soft); border-radius: 50%; color: var(--green-dark); display: flex; font-size: 46px; font-weight: 700; height: 120px; justify-content: center; width: 120px; }
.call-audio-avatar.hidden { display: none; }
.call-info { color: #fff; display: flex; flex-direction: column; gap: 6px; text-align: center; text-shadow: 0 2px 10px rgba(0, 0, 0, .6); }
.call-info strong { font-size: 24px; }
.call-info span { color: rgba(255, 255, 255, .78); font-size: 13px; }
.call-local-video { border: 2px solid rgba(255, 255, 255, .28); border-radius: 12px; bottom: 116px; height: 150px; object-fit: cover; position: absolute; right: 18px; width: 110px; }
.call-local-video.hidden { display: none; }
.call-actions { bottom: 32px; display: flex; gap: 18px; position: absolute; }
.call-actions button { align-items: center; background: rgba(255, 255, 255, .14); border-radius: 50%; color: #fff; cursor: pointer; display: flex; flex-direction: column; font-size: 11px; gap: 4px; height: 64px; justify-content: center; transition: background-color .2s ease, transform .15s ease; width: 64px; }
.call-actions button:hover { background: rgba(255, 255, 255, .24); transform: scale(1.06); }
.call-actions button .icon { height: 20px; width: 20px; }
.call-actions button.is-active { background: rgba(255, 255, 255, .42); }
.call-actions button.is-off-cam { background: rgba(181, 83, 83, .55); }
.call-actions .danger { background: #b55353; }
.call-actions .danger:hover { background: #a03f3f; }
.icon-phone.hangup { transform: rotate(135deg); }
.incoming-call { align-items: center; background: var(--panel); border-radius: 16px; box-shadow: 0 25px 80px rgba(0, 0, 0, .35); display: flex; flex-direction: column; gap: 10px; padding: 32px 38px; text-align: center; }
.incoming-avatar { align-items: center; background: var(--green-soft); border-radius: 50%; color: var(--green-dark); display: flex; font-size: 34px; font-weight: 700; height: 88px; justify-content: center; width: 88px; }
.incoming-call h3 { font-size: 17px; margin: 4px 0 0; }
.incoming-call p { color: var(--muted); font-size: 12px; margin: 0; }
.incoming-actions { display: flex; gap: 14px; margin-top: 12px; }
.incoming-actions button { border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; padding: 10px 24px; transition: transform .12s ease, opacity .2s ease; }
.incoming-actions button:hover { transform: translateY(-1px); }
#incoming-decline { background: var(--danger-soft); color: var(--danger); }
#incoming-accept { background: var(--green); color: #fff; }

/* 通话界面 · 手机适配（安全区、触控尺寸、视频画中画位置） */
@media (max-width: 720px) {
  .call-center { top: 12vh; gap: 14px; }
  .call-info strong { font-size: 17px; }
  .call-actions { bottom: calc(28px + env(safe-area-inset-bottom)); gap: 22px; }
  .call-actions button { height: 68px; width: 68px; font-size: 10px; }
  .call-actions button .icon { height: 22px; width: 22px; }
  .call-local-video { bottom: calc(126px + env(safe-area-inset-bottom)); height: 132px; right: 12px; width: 96px; }
  .call-audio-avatar { height: 96px; width: 96px; font-size: 36px; }
  /* 来电弹窗改为贴底卡片，符合手机来电使用习惯 */
  .incoming-call { border-radius: 20px 20px 0 0; bottom: 0; left: 0; padding: 30px 24px calc(30px + env(safe-area-inset-bottom)); position: fixed; right: 0; width: 100%; }
  .incoming-actions { gap: 16px; margin-top: 18px; width: 100%; }
  .incoming-actions button { flex: 1; font-size: 15px; padding: 15px 0; }
}

kbd { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 11px; padding: 1px 5px; }
.filter-tabs { display: flex; gap: 18px; margin: 16px 4px 0; }
.filter-tab { background: transparent; color: var(--muted); font-size: 12px; padding: 0 0 9px; position: relative; }
.filter-tab span { background: var(--soft); border-radius: 4px; font-size: 10px; margin-left: 3px; padding: 2px 5px; }
.filter-tab.is-active { color: var(--ink); font-weight: 700; }
.filter-tab.is-active::after { background: var(--green); bottom: 0; content: ""; height: 2px; left: 0; position: absolute; right: 0; }
.friend-list { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 10px 16px; }
.friend-list::-webkit-scrollbar { width: 4px; }
.friend-list::-webkit-scrollbar-track { background: transparent; }
.friend-list::-webkit-scrollbar-thumb { background: #d0d8d3; border-radius: 4px; }
.friend-list::-webkit-scrollbar-thumb:hover { background: #b0bcb5; }
.friend-item { align-items: center; border-radius: 10px; display: flex; gap: 10px; margin-bottom: 3px; padding: 11px 10px; transition: background .2s ease; }
.friend-item:hover { background: #f6f8f7; }
.friend-item.is-active { background: var(--green-soft); }
.friend-item.is-active .friend-name { color: var(--green-dark); }
.friend-info { flex: 1; min-width: 0; }
.friend-topline { align-items: center; display: flex; gap: 7px; justify-content: space-between; }
.friend-name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-time, .friend-preview { color: var(--muted); font-size: 11px; }
.friend-preview { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread-count { align-items: center; background: var(--green); border-radius: 50%; color: white; display: inline-flex; font-size: 10px; height: 17px; justify-content: center; min-width: 17px; }
.sidebar-footer { border-top: 1px solid var(--line); padding: 14px 15px 17px; }
.privacy-mini { align-items: center; background: var(--card-bg); border: 1px solid var(--line); border-radius: 9px; display: flex; gap: 8px; padding: 10px; }
.mini-shield { align-items: center; background: var(--green-soft); border-radius: 7px; color: var(--green); display: inline-flex; height: 27px; justify-content: center; width: 27px; }
.privacy-mini div { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.privacy-mini strong { font-size: 11px; }
.privacy-mini div span { color: var(--muted); font-size: 10px; margin-top: 3px; }
.footer-links { align-items: center; color: #a3ada7; display: flex; font-size: 10px; justify-content: space-between; padding: 12px 2px 0; }
.footer-links button { background: transparent; color: var(--green); font-size: 10px; padding: 0; }

.chat-panel { background: var(--chat-bg); display: flex; flex-direction: column; min-width: 0; }
.chat-header { align-items: center; background: var(--header-bg); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; min-height: 83px; padding: 15px 28px; }
.chat-person { align-items: center; display: flex; gap: 12px; min-width: 0; }
.person-name-row { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; }
.person-name-row h1 { font-size: 17px; margin: 0; }
.secure-badge { align-items: center; background: var(--green-soft); border-radius: 4px; color: var(--green-dark); display: inline-flex; font-size: 10px; gap: 4px; padding: 4px 6px; transition: background-color .25s ease, color .25s ease; }
.secure-badge.is-off { background: var(--amber-soft); color: var(--amber); }
.chat-person p { color: var(--muted); font-size: 11px; margin: 5px 0 0; }
.header-actions { display: flex; gap: 3px; }
.encryption-banner { align-items: center; background: var(--banner-bg); border-bottom: 1px solid var(--banner-line); display: flex; gap: 11px; padding: 12px 28px; }
.banner-icon { align-items: center; background: var(--green-soft); border-radius: 7px; color: var(--green); display: flex; height: 29px; justify-content: center; width: 29px; }
.encryption-banner div:nth-child(2) { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.encryption-banner strong { color: #276748; font-size: 11px; }
.encryption-banner div:nth-child(2) span { color: #799184; font-size: 10px; margin-top: 3px; }
.text-button { align-items: center; background: transparent; color: var(--green); display: inline-flex; font-size: 11px; gap: 4px; padding: 4px 0; white-space: nowrap; }
.text-button:hover { color: var(--green-dark); }
.text-button.small { font-size: 10px; }
.message-stage { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 26px 6.5% 18px; scroll-behavior: smooth; }
.message-stage::-webkit-scrollbar { width: 4px; }
.message-stage::-webkit-scrollbar-track { background: transparent; }
.message-stage::-webkit-scrollbar-thumb { background: #d0d8d3; border-radius: 4px; }
.date-divider { align-items: center; color: #9ba59f; display: flex; font-size: 10px; gap: 12px; justify-content: center; margin-bottom: 25px; }
.date-divider::before, .date-divider::after { background: var(--line); content: ""; height: 1px; max-width: 100px; width: 13%; }
.message-list { display: flex; flex-direction: column; gap: 17px; }
.message-row { align-items: flex-end; display: flex; gap: 9px; max-width: 75%; }
.message-row.is-me { align-self: flex-end; flex-direction: row-reverse; }
.message-bubble { background: var(--panel); border: 1px solid var(--line); border-radius: 4px 13px 13px 13px; box-shadow: 0 3px 10px rgba(33, 53, 43, .03); padding: 11px 13px; }
.message-row.is-me .message-bubble { background: #dff1e7; border-color: #d2e9dd; border-radius: 13px 4px 13px 13px; }
.message-text { font-size: 13px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.message-meta { align-items: center; color: #9aa59f; display: flex; font-size: 10px; gap: 7px; justify-content: flex-end; margin-top: 6px; }
.message-row:not(.is-me) .message-meta { justify-content: flex-start; }
.message-status { color: var(--green); display: inline-flex; gap: 1px; transition: color .3s ease; }
/* 已读 / 未读切换的柔和过渡。
   文字**立刻**换掉，随后播一段淡入 + 上移归位的动画 ——
   比直接跳变舒服，又不会让 DOM 在一小段时间里与真实状态不一致。
   配合 app.js 的 updateMessageStatusUI（只动这一个节点，不整页重绘）。 */
.message-status-text { display: inline-block; }
@keyframes messageStatusIn {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: none; }
}
.message-status.is-changing .message-status-text { animation: messageStatusIn .34s ease; }
.message-file { align-items: center; display: flex; gap: 10px; min-width: 210px; }
.file-icon { align-items: center; background: var(--green-soft); border-radius: 8px; color: var(--green); display: flex; height: 36px; justify-content: center; width: 36px; }
.message-file strong { display: block; font-size: 12px; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-file span { color: var(--muted); display: block; font-size: 10px; margin-top: 3px; }
.message-media { border-radius: 9px; display: block; max-height: 220px; max-width: 280px; object-fit: cover; }
.message-media-wrap { position: relative; }
.typing-indicator { align-items: center; color: var(--muted); display: none; font-size: 10px; gap: 7px; margin: 20px 0 0 33px; }
.typing-indicator.is-visible { display: flex; }
.typing-indicator i { animation: blink 1.3s infinite; background: #97aa9e; border-radius: 50%; height: 3px; width: 3px; }
.typing-indicator i:nth-last-child(2) { animation-delay: .2s; }.typing-indicator i:last-child { animation-delay: .4s; }
@keyframes blink { 0%, 70%, 100% { opacity: .35; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }
.composer-wrap { background: var(--header-bg); border-top: 1px solid var(--line); padding: 10px 6.5% 16px; }
/* 一行式输入区：「+」入口 | 输入框 | 发送。功能全部收进「+」面板，输入区只留三件东西。 */
.composer { align-items: flex-end; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 4px 14px rgba(33, 53, 43, .03); display: flex; gap: 8px; padding: 7px 8px; position: relative; }
.composer:focus-within { border-color: #9fcdb5; box-shadow: 0 0 0 3px rgba(19, 121, 91, .08); }
.composer textarea { background: transparent; border: 0; color: var(--ink); display: block; flex: 1; line-height: 1.5; max-height: 110px; min-height: 26px; outline: none; overflow: auto; resize: none; width: 100%; }
.composer textarea::placeholder { color: #a0aaa4; }
.plus-toggle { align-items: center; align-self: flex-end; background: var(--soft); border: 0; border-radius: 50%; color: var(--green-dark); cursor: pointer; display: inline-flex; flex: 0 0 auto; height: 34px; justify-content: center; transition: background-color .18s ease, transform .12s ease; width: 34px; }
.plus-toggle:hover { background: var(--green-soft); }
.plus-toggle:active { transform: scale(.92); }
.plus-toggle .icon { height: 18px; width: 18px; }
.plus-toggle.is-open { background: var(--green); color: white; }
.send-button { align-items: center; align-self: flex-end; background: var(--green); border: 0; border-radius: 50%; color: white; cursor: pointer; display: inline-flex; flex: 0 0 auto; height: 34px; justify-content: center; width: 34px; }
.send-button:hover { background: var(--green-dark); }
.send-button .icon { height: 16px; width: 16px; }

/* 「+」功能面板：展开在输入区上方，条目由 COMPOSER_ACTIONS 数据驱动 */
.attach-panel { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 -6px 22px rgba(33, 53, 43, .08); display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); margin-bottom: 8px; padding: 10px; }
.attach-panel[hidden] { display: none; }
.attach-item { align-items: center; background: transparent; border: 0; border-radius: 10px; color: var(--ink); cursor: pointer; display: flex; flex-direction: column; gap: 6px; padding: 10px 4px; transition: background-color .15s ease; }
.attach-item:hover { background: var(--soft); }
.attach-item:active { transform: scale(.96); }
.attach-item .attach-icon { align-items: center; background: var(--soft); border-radius: 12px; color: var(--green-dark); display: inline-flex; height: 38px; justify-content: center; width: 38px; }
.attach-item .attach-icon .icon { height: 18px; width: 18px; }
.attach-item span.attach-label { font-size: 11px; }
.attach-item.is-disabled { cursor: default; opacity: .45; }
.attach-item.is-disabled:hover { background: transparent; }
.attach-item.is-disabled .attach-icon { color: var(--muted); }

/* 语音录制条：录音期间替换输入区 */
.voice-recording { align-items: center; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 14px; display: flex; gap: 10px; padding: 9px 10px; }
.voice-recording[hidden] { display: none; }
.voice-rec-btn { border: 0; border-radius: 10px; cursor: pointer; flex: 0 0 auto; font-size: 12px; padding: 8px 12px; }
.voice-rec-btn.is-cancel { background: var(--soft); color: var(--ink); }
.voice-rec-btn.is-send { align-items: center; background: var(--green); border-radius: 50%; color: white; display: inline-flex; height: 36px; justify-content: center; width: 36px; }
.voice-rec-btn.is-send .icon { height: 16px; width: 16px; }
.voice-rec-main { flex: 1; min-width: 0; }
.voice-rec-status { align-items: center; color: #c23b3b; display: flex; font-size: 13px; font-weight: 600; gap: 7px; }
.rec-dot { animation: recBlink 1.1s ease infinite; background: #c23b3b; border-radius: 50%; display: inline-block; height: 9px; width: 9px; }
@keyframes recBlink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.voice-rec-hint { color: var(--muted); font-size: 10px; margin-top: 2px; }
.voice-rec-transcript { color: var(--ink); font-size: 11px; margin-top: 5px; max-height: 52px; overflow: hidden; }
/* 识别中：收起按钮，条子只展示进度文字 */
.voice-recording.is-transcribing .voice-rec-btn { display: none; }
.voice-recording.is-transcribing .voice-rec-hint { color: var(--green-dark); }

/* 语音消息气泡：播放键 + 声波条 + 时长，转文字显示在气泡内部下方 */
.voice-message { align-items: center; cursor: pointer; display: flex; gap: 9px; min-width: 128px; }
.voice-play { align-items: center; background: var(--green); border: 0; border-radius: 50%; color: white; cursor: pointer; display: inline-flex; flex: 0 0 auto; height: 32px; justify-content: center; width: 32px; }
.voice-play .icon { height: 15px; width: 15px; }
.is-me .voice-play { background: rgba(255, 255, 255, .92); color: var(--green-dark); }
.voice-bars { align-items: flex-end; display: inline-flex; gap: 2.5px; height: 20px; }
.voice-bars i { background: var(--muted); border-radius: 2px; display: inline-block; height: 8px; width: 2.5px; }
.is-me .voice-bars i { background: rgba(255, 255, 255, .75); }
.voice-message.is-playing .voice-bars i { animation: voiceBar .9s ease-in-out infinite; }
.voice-bars i:nth-child(2) { height: 14px; animation-delay: .15s; }
.voice-bars i:nth-child(3) { height: 20px; animation-delay: .3s; }
.voice-bars i:nth-child(4) { height: 12px; animation-delay: .45s; }
@keyframes voiceBar { 0%, 100% { transform: scaleY(.45); } 50% { transform: scaleY(1); } }
.voice-duration { color: inherit; font-size: 11px; white-space: nowrap; }
.voice-transcript { border-top: 1px dashed var(--line); color: var(--ink); font-size: 12px; line-height: 1.5; margin-top: 7px; padding-top: 6px; white-space: pre-wrap; word-break: break-word; }

.info-panel { border-left: 1px solid var(--line); display: none; opacity: 0; min-width: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: 25px 21px 20px; transition: opacity .28s ease; }
/* 宽度跟栅格第三列（--info-col）对齐。这里用 min-width:0 允许它在 0 列时被压扁，
   不会因为自身内容撑出横向滚动条。 */
.app-shell.is-ready .info-panel { display: block; width: var(--info-col, 0); }
.app-shell.is-info-open .info-panel { opacity: 1; }
.info-panel::-webkit-scrollbar { width: 4px; }
.info-panel::-webkit-scrollbar-track { background: transparent; }
.info-panel::-webkit-scrollbar-thumb { background: #d0d8d3; border-radius: 4px; }
.info-panel::-webkit-scrollbar-thumb:hover { background: #b0bcb5; }
#info-toggle.is-active { background: var(--green-soft); color: var(--green-dark); }
.info-header { align-items: flex-start; display: flex; justify-content: space-between; }
.eyebrow { color: var(--muted); display: block; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.info-header h2 { font-size: 17px; margin: 7px 0 0; }
.close-info { display: inline-flex; }
.contact-card { align-items: center; display: flex; flex-direction: column; padding: 24px 0 23px; }
.contact-card strong { font-size: 15px; margin-top: 10px; }
.contact-card > span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.contact-actions { display: flex; gap: 23px; margin-top: 18px; }
.contact-action { align-items: center; background: transparent; color: var(--muted); display: flex; flex-direction: column; font-size: 10px; gap: 6px; padding: 0; }
.contact-action:hover { color: var(--green); }
.info-section { border-top: 1px solid var(--line); padding: 18px 0; }
.info-section-title { color: var(--ink); font-size: 12px; font-weight: 700; }
.verified-label { align-items: center; color: var(--green); display: flex; font-size: 10px; font-weight: 500; gap: 4px; }
.file-count { color: var(--muted); font-size: 10px; font-weight: 400; }
.security-card { background: var(--card-bg); border: 1px solid var(--line); border-radius: 9px; margin-top: 12px; overflow: hidden; }
.security-row { align-items: center; border-bottom: 1px solid var(--line); display: flex; gap: 9px; padding: 11px 10px; }
.security-row:last-child { border-bottom: 0; }
.security-row > div { flex: 1; min-width: 0; }
.security-row strong { display: block; font-size: 11px; }
.security-row div span { color: var(--muted); display: block; font-size: 10px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.security-icon { align-items: center; border-radius: 7px; display: flex; height: 27px; justify-content: center; width: 27px; }
.security-icon.green { background: var(--green-soft); color: var(--green); }.security-icon.blue { background: var(--blue-soft); color: var(--blue); }.security-icon.amber { background: var(--amber-soft); color: var(--amber); }
.toggle { background: #d6ded9; border-radius: 20px; display: block; height: 18px; padding: 2px; width: 31px; }.toggle span { background: white; border-radius: 50%; display: block; height: 14px; transition: transform .2s; width: 14px; }.toggle.is-on { background: var(--green); }.toggle.is-on span { transform: translateX(13px); }
.media-grid { display: grid; gap: 7px; grid-template-columns: repeat(3, 1fr); margin-top: 12px; }
.media-thumb { aspect-ratio: 1; background: var(--soft); border-radius: 6px; overflow: hidden; position: relative; }
.media-thumb img, .media-thumb video { height: 100%; object-fit: cover; width: 100%; }
.media-thumb.video-thumb::after { align-items: center; background: rgba(0,0,0,.4); border-radius: 50%; color: white; content: "▶"; display: flex; font-size: 9px; height: 25px; justify-content: center; left: calc(50% - 12px); position: absolute; top: calc(50% - 12px); width: 25px; }
.empty-media { color: var(--muted); font-size: 11px; grid-column: 1 / -1; padding: 6px 0; }
.shared-files { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.shared-file { align-items: center; background: transparent; border: 0; color: inherit; cursor: pointer; display: flex; font: inherit; gap: 8px; padding: 0; text-align: left; width: 100%; }
.shared-file:disabled { cursor: default; opacity: .82; }
.shared-file .file-icon { height: 30px; width: 30px; }
.shared-file > div { flex: 1; min-width: 0; }.shared-file strong { display: block; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.shared-file span { color: var(--muted); display: block; font-size: 9px; margin-top: 3px; }
.info-bottom-note { align-items: flex-start; color: #8b9891; display: flex; font-size: 10px; gap: 7px; line-height: 1.5; padding: 9px 2px; }.info-bottom-note p { margin: 0; }

.icon { display: inline-block; height: 16px; position: relative; width: 16px; }
.icon svg { display: block; height: 100%; width: 100%; }
.toast { background: var(--toast-bg); border-radius: 8px; bottom: 25px; box-shadow: var(--shadow); color: var(--toast-ink); font-size: 12px; left: 50%; max-width: calc(100vw - 40px); opacity: 0; padding: 10px 14px; pointer-events: none; position: fixed; transform: translate(-50%, 14px); transition: opacity .2s, transform .2s; z-index: 200; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.modal-backdrop { align-items: center; background: rgba(29, 38, 34, .35); display: flex; inset: 0; justify-content: center; padding: 20px; position: fixed; z-index: 30; }
.modal-backdrop[hidden] { display: none; }
.context-menu { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 28px rgba(29, 38, 34, .15); min-width: 140px; overflow: hidden; padding: 4px; position: fixed; z-index: 40; animation: menuIn .15s ease; }
.context-menu[hidden] { display: none; }
@keyframes menuIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
.context-menu-item { align-items: center; background: transparent; border: 0; border-radius: 5px; color: var(--ink); cursor: pointer; display: flex; font-size: 12px; gap: 8px; padding: 8px 10px; width: 100%; }
.context-menu-item:hover { background: var(--soft); }
.context-menu-item.danger { color: var(--danger); }
.security-modal { background: var(--panel); border-radius: 14px; box-shadow: 0 25px 80px rgba(29, 38, 34, .22); max-width: 430px; padding: 32px; position: relative; width: 100%; }
.modal-close { position: absolute; right: 13px; top: 13px; }.modal-mark { align-items: center; background: var(--green-soft); border-radius: 11px; color: var(--green); display: flex; height: 44px; justify-content: center; margin-bottom: 19px; width: 44px; }.security-modal h2 { font-size: 23px; letter-spacing: -.02em; line-height: 1.25; margin: 8px 0 11px; }.security-modal > p { color: #6e7d75; font-size: 12px; line-height: 1.7; margin: 0; }.security-checklist { background: var(--card-bg); border: 1px solid var(--line); border-radius: 9px; margin: 19px 0; }.security-checklist div { align-items: center; border-bottom: 1px solid var(--line); display: flex; gap: 8px; padding: 11px 12px; }.security-checklist div:last-child { border-bottom: 0; }.security-checklist .icon { color: var(--green); }.security-checklist span:nth-child(2) { flex: 1; font-size: 11px; }.security-checklist strong { color: var(--green); font-size: 10px; font-weight: 600; }.security-checklist div:last-child .icon, .security-checklist div:last-child strong { color: var(--muted); }.primary-button { background: var(--green); border-radius: 7px; color: white; font-size: 12px; padding: 10px 14px; width: 100%; }.primary-button:hover { background: var(--green-dark); }

/* ── 全局悬停反馈 ── */
.brand-mark { transition: transform .25s ease; }
.brand:hover .brand-mark { transform: rotate(0deg) scale(1.08); }
.brand:hover strong { color: var(--green-dark); }

.profile-row { transition: background-color .2s ease; }
.profile-row:hover { background: var(--soft); }
.avatar-self { transition: transform .2s ease; }
.profile-row:hover .avatar-self { transform: scale(1.06); }

.search-box { transition: background-color .2s ease, border-color .2s ease; }
.search-box:hover:not(:focus-within) { background: var(--soft); }

.filter-tab { transition: color .2s ease; }
.filter-tab:hover { color: var(--ink); }
.filter-tab span { transition: background-color .2s ease, color .2s ease; }
.filter-tab:hover span { background: var(--green-soft); color: var(--green-dark); }

.friend-item { transition: background-color .2s ease, transform .18s ease; }
.friend-item:hover { background: var(--hover-bg); transform: translateX(3px); }
.friend-item:hover .friend-name { color: var(--green-dark); }
.friend-item.is-active:hover { background: var(--active-hover-bg); }
.unread-count { transition: transform .2s ease; }
.friend-item:hover .unread-count { transform: scale(1.1); }

.icon-button, .tool-button { transition: background-color .18s ease, color .18s ease, transform .12s ease; }
.icon-button:hover, .tool-button:hover { transform: translateY(-1px); }
.icon-button:active, .tool-button:active { transform: scale(.9); }

.privacy-mini { transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease; }
.privacy-mini:hover { border-color: #cfe3d7; box-shadow: 0 6px 16px rgba(19, 121, 91, .08); transform: translateY(-1px); }
.privacy-mini .icon-chevron-right { transition: transform .2s ease, color .2s ease; }
.privacy-mini:hover .icon-chevron-right { color: var(--green); transform: translateX(3px); }

.footer-links button { transition: opacity .2s ease; }
.footer-links button:hover { text-decoration: underline; }

.chat-person .avatar { transition: box-shadow .2s ease; }
.chat-person:hover .avatar { box-shadow: 0 0 0 3px var(--green-soft); }

.encryption-banner { transition: background-color .2s ease; }
.encryption-banner:hover { background: var(--banner-bg); }
.banner-icon { transition: transform .25s ease; }
.encryption-banner:hover .banner-icon { transform: scale(1.1) rotate(-8deg); }

.text-button .icon { transition: transform .2s ease; }
.text-button:hover .icon { transform: translate(1px, -1px); }

.message-bubble { transition: box-shadow .2s ease; }
.message-row:hover .message-bubble { box-shadow: 0 6px 18px rgba(33, 53, 43, .1); }

.message-delete { align-items: center; align-self: flex-end; background: transparent; border-radius: 50%; color: #b6c0ba; display: inline-flex; flex: 0 0 auto; height: 24px; justify-content: center; margin-bottom: 5px; opacity: 0; pointer-events: none; transform: scale(.8); transition: opacity .18s ease, transform .18s ease, background-color .18s ease, color .18s ease; width: 24px; }
.message-delete .icon { height: 12px; width: 12px; }
.message-row:hover .message-delete { opacity: 1; pointer-events: auto; transform: scale(1); }
.message-delete:hover { background: var(--danger-soft); color: var(--danger); transform: scale(1.12); }

/* ── 消息操作条（引用 / 转发 / 撤回 / 删除） ──
   默认隐藏，悬停出现。触屏没有 hover，所以在手机上常显（见下方媒体查询）。 */
.msg-actions { align-items: center; align-self: flex-end; display: flex; flex: 0 0 auto; gap: 2px; margin-bottom: 4px; opacity: 0; pointer-events: none; transform: translateY(2px); transition: opacity .18s ease, transform .18s ease; }
.message-row:hover .msg-actions, .message-row.is-actions-open .msg-actions { opacity: 1; pointer-events: auto; transform: translateY(0); }
.msg-action { align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 50%; color: var(--muted); display: inline-flex; height: 26px; justify-content: center; width: 26px; transition: background-color .16s ease, color .16s ease, border-color .16s ease, transform .12s ease; }
.msg-action .icon { height: 12px; width: 12px; }
.msg-action:hover { background: var(--hover-bg); border-color: var(--line-strong); color: var(--green); transform: scale(1.1); }
.msg-action.is-danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); color: var(--danger); }
.message-row.is-me .msg-actions { flex-direction: row-reverse; }

/* ── 引用块 ── */
.message-quote { background: var(--soft); border-left: 2px solid var(--green); border-radius: 5px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; margin-bottom: 7px; max-width: 240px; padding: 6px 9px; transition: background-color .16s ease; }
.message-quote:hover { background: var(--green-soft); }
.message-quote strong { color: var(--green-dark); font-size: 10px; font-weight: 600; }
.message-quote span { color: var(--muted); font-size: 11px; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-row.is-me .message-quote { border-left-color: #7fb99b; }

/* ── 已撤回的占位气泡 ── */
.message-bubble.is-recalled-bubble, .message-row.is-recalled .message-bubble { background: transparent; border-style: dashed; box-shadow: none; }
.is-recalled-text { align-items: center; color: var(--muted); display: flex; font-size: 11px; font-style: italic; gap: 5px; }
.is-recalled-text .icon { height: 12px; width: 12px; }
.message-row.is-recalled .message-meta { margin-top: 4px; }

/* ── 引用跳转时的高亮闪烁 ── */
@keyframes flashTarget { 0%, 100% { background: transparent; } 25%, 75% { background: var(--amber-soft); } }
.message-row.is-flash .message-bubble { animation: flashTarget 1.2s ease; }

/* ── 图片「保存到本机」按钮 ── */
.media-save { align-items: center; background: rgba(255,255,255,.9); border-radius: 6px; bottom: 8px; color: var(--green-dark); display: flex; height: 24px; justify-content: center; position: absolute; right: 8px; width: 24px; transition: background-color .16s ease, transform .12s ease; }
.media-save .icon { height: 13px; width: 13px; }
.media-save:hover { background: #ffffff; transform: scale(1.1); }
.dark .media-save { background: rgba(20, 23, 21, .88); color: var(--green-dark); }

/* ── 输入区上方的引用预览条 ── */
.quote-preview { display: none; }
.quote-preview.is-visible { align-items: center; background: var(--soft); border-left: 2px solid var(--green); border-radius: 5px; bottom: calc(100% + 6px); box-shadow: 0 4px 14px rgba(33, 53, 43, .1); display: flex; gap: 8px; justify-content: space-between; left: 8px; padding: 6px 9px; position: absolute; right: 8px; z-index: 6; }
.quote-preview-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.quote-preview-body strong { color: var(--green-dark); font-size: 10px; font-weight: 600; }
.quote-preview-body span { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quote-preview-close { align-items: center; background: transparent; border-radius: 50%; color: var(--muted); display: flex; flex: 0 0 auto; height: 20px; justify-content: center; width: 20px; }
.quote-preview-close .icon { height: 12px; width: 12px; }
.quote-preview-close:hover { background: var(--line); color: var(--ink); }

/* ── 转发面板 ── */
.forward-modal { background: var(--panel); border-radius: 14px; box-shadow: 0 25px 80px rgba(0, 0, 0, .4); display: flex; flex-direction: column; max-height: calc(100vh - 60px); max-width: min(420px, calc(100vw - 40px)); overflow: hidden; width: 100%; }
.forward-preview { border-bottom: 1px solid var(--line); padding: 12px 18px; }
.forward-quote { background: var(--soft); border-left: 2px solid var(--green); border-radius: 5px; display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; }
.forward-quote strong { color: var(--green-dark); font-size: 10px; }
.forward-quote span { color: var(--muted); font-size: 12px; line-height: 1.55; word-break: break-word; }
.forward-list { display: flex; flex-direction: column; gap: 2px; max-height: 46vh; overflow: auto; padding: 8px; }
.forward-item { align-items: center; background: transparent; border-radius: 9px; display: flex; gap: 10px; padding: 9px 10px; text-align: left; width: 100%; transition: background-color .16s ease; }
.forward-item:hover { background: var(--hover-bg); }
.forward-item-name { color: var(--ink); flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.forward-item-status { color: var(--muted); font-size: 10px; }
.forward-empty { color: var(--muted); font-size: 12px; padding: 24px; text-align: center; }

.composer { transition: border-color .2s ease, box-shadow .2s ease; }
.composer:hover:not(:focus-within) { border-color: #c2d8cb; }

.send-button { transition: background-color .18s ease, box-shadow .18s ease, transform .12s ease; }
.send-button:hover { box-shadow: 0 6px 16px rgba(19, 121, 91, .28); transform: translateY(-1px); }
.send-button:active { transform: scale(.96); }

.security-row { transition: background-color .18s ease; }
.security-row:hover { background: var(--soft); }
.security-row .icon-chevron-right { transition: transform .2s ease, color .2s ease; }
.security-row:hover .icon-chevron-right { color: var(--green); transform: translateX(2px); }
.security-icon { transition: transform .2s ease; }
.security-row:hover .security-icon { transform: scale(1.1); }

.toggle { cursor: pointer; transition: background-color .2s ease, box-shadow .2s ease; }
.toggle:hover { box-shadow: 0 0 0 3px rgba(19, 121, 91, .12); }

.media-thumb { cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.media-thumb:hover { box-shadow: 0 8px 20px rgba(29, 38, 34, .16); transform: scale(1.05); z-index: 1; }
.media-thumb img, .media-thumb video { transition: transform .3s ease; }
.media-thumb:hover img { transform: scale(1.1); }

.shared-file { border-radius: 9px; transition: background-color .18s ease, padding .18s ease, margin .18s ease, width .18s ease; }
.shared-file:hover:not(:disabled) { background: var(--soft); margin: -7px -9px; padding: 7px 9px; width: calc(100% + 18px); }
.shared-file .icon-arrow-up-right { transition: transform .2s ease, color .2s ease; }
.shared-file:hover:not(:disabled) .icon-arrow-up-right { color: var(--green); transform: translate(2px, -2px); }

.contact-action .icon { transition: transform .2s ease; }
.contact-action:hover .icon { transform: translateY(-2px) scale(1.12); }

.context-menu-item .icon { transition: transform .15s ease; }
.context-menu-item:hover .icon { transform: scale(1.12); }

.primary-button { transition: background-color .18s ease, box-shadow .18s ease, transform .12s ease; }
.primary-button:hover { box-shadow: 0 6px 16px rgba(19, 121, 91, .25); transform: translateY(-1px); }
.primary-button:active { transform: scale(.97); }

/* ── 空聊天记录状态 ── */
.empty-chat { align-items: center; color: var(--muted); display: flex; flex-direction: column; gap: 7px; padding: 72px 20px 60px; text-align: center; }
.empty-chat-figure { animation: floaty 3.4s ease-in-out infinite; margin: 0 auto 10px; width: 200px; max-width: 72vw; }
.empty-chat-figure svg { display: block; height: auto; width: 100%; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.empty-chat strong { color: var(--ink); font-size: 14px; }
.empty-chat p { font-size: 12px; margin: 0; max-width: 280px; }
.empty-chat .primary-button { margin-top: 12px; padding: 9px 26px; width: auto; }

/* ── 加密提示条收起 ── */
.encryption-banner { max-height: 64px; overflow: hidden; transition: background-color .2s ease, border-color .25s ease, max-height .25s ease, opacity .25s ease, padding .25s ease; }
.encryption-banner.is-dismissed { border-bottom-color: transparent; max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; }
.encryption-banner .banner-close { flex: 0 0 auto; }
.encryption-banner:hover .banner-close { color: var(--green-dark); }

/* ── 内容变动过渡动画 ── */
.message-row:last-child { animation: msgIn .32s cubic-bezier(.33, 1, .38, 1); }
.empty-chat { animation: msgIn .35s ease; }
.filter-tab span { transition: background-color .2s ease, color .2s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── 个人在线状态 ── */
.status-dot { transition: background-color .25s ease; }
.status-dot.is-online { background: #27a869; }
.status-dot.is-away { background: #e8a13c; }
.status-dot.is-invisible { background: #aeb8b2; }
.status-dot.is-offline { background: #aeb8b2; }
.status-switcher { align-items: center; background: transparent; border-radius: 6px; color: var(--muted); display: inline-flex; font-size: 11px; gap: 5px; margin-top: 3px; padding: 2px 5px 2px 2px; transition: background-color .18s ease, color .18s ease; }
.status-switcher:hover { background: var(--soft); color: var(--ink); }
.status-switcher .icon { height: 10px; width: 10px; transition: transform .2s ease; }
.status-switcher:hover .icon { transform: translateY(1px); }

/* 中继连接指示灯：让「有没有真正连上」一眼可见 */
.link-indicator { align-items: center; display: inline-flex; font-size: 10px; gap: 5px; margin-top: 2px; }
.link-indicator i { background: currentColor; border-radius: 50%; display: block; flex: 0 0 auto; height: 6px; width: 6px; }
.link-indicator.is-online { color: var(--green); }
.link-indicator.is-offline { color: var(--danger); }
.link-indicator.is-connecting { color: var(--amber); }
.link-indicator.is-online i { box-shadow: 0 0 0 3px rgba(19, 121, 91, .16); }
/* 连接中呼吸闪烁，避免误以为卡死 */
@media (prefers-reduced-motion: no-preference) {
  .link-indicator.is-connecting i { animation: linkPulse 1.1s ease-in-out infinite; }
  @keyframes linkPulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
}
.sidebar:not(.mobile-list) .link-indicator { font-size: 10px; }
.context-menu-item .status-dot { margin-right: 1px; }

/* ── 会话操作区 ── */
.ops-card { background: var(--card-bg); border: 1px solid var(--line); border-radius: 9px; margin-top: 12px; overflow: hidden; }
.ops-row { align-items: center; background: transparent; border-bottom: 1px solid var(--line); color: inherit; display: flex; font: inherit; gap: 9px; padding: 10px; text-align: left; transition: background-color .18s ease; width: 100%; }
.ops-row:last-child { border-bottom: 0; }
.ops-row:hover { background: var(--soft); }
.ops-row > div { flex: 1; min-width: 0; }
.ops-row strong { display: block; font-size: 11px; }
.ops-row div span { color: var(--muted); display: block; font-size: 10px; margin-top: 3px; }
.ops-row .icon-chevron-right { color: #b3bdb7; flex: 0 0 auto; transition: transform .2s ease, color .2s ease; }
.ops-row:hover .icon-chevron-right { color: var(--green); transform: translateX(2px); }
.ops-icon { align-items: center; background: var(--soft); border-radius: 7px; color: var(--muted); display: flex; flex: 0 0 auto; height: 27px; justify-content: center; transition: transform .2s ease; width: 27px; }
.ops-row:hover .ops-icon { transform: scale(1.08); }
.ops-row.danger, .ops-row.danger strong { color: var(--danger); }
.ops-icon.danger { background: var(--danger-soft); color: var(--danger); }
.ops-row .toggle { flex: 0 0 auto; }

/* ── 清空聊天记录空状态（区别于删除会话） ── */
.empty-chat.is-cleared { animation: msgIn .35s ease; }

/* ── 个人主页弹窗 ── */
.profile-modal { background: var(--panel); border-radius: 14px; box-shadow: 0 25px 80px rgba(0, 0, 0, .3); max-height: calc(100vh - 60px); max-width: 470px; overflow-y: auto; padding: 26px 26px 22px; position: relative; width: 100%; }
.profile-head { align-items: center; display: flex; gap: 14px; }
.profile-head-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.profile-head-copy h2 { font-size: 18px; margin: 0; }
.profile-head-copy span { color: var(--muted); font-size: 11px; margin-top: 4px; }
.status-chip { align-items: center; background: var(--soft); border-radius: 20px; color: var(--ink); display: inline-flex; flex: 0 0 auto; font-size: 11px; gap: 6px; padding: 4px 10px; }
.profile-tabs { border-bottom: 1px solid var(--line); display: flex; gap: 4px; margin: 18px 0 16px; }
.profile-tab { background: transparent; border-radius: 8px 8px 0 0; color: var(--muted); flex: 1; font-size: 12px; padding: 8px 0; transition: color .2s ease, background-color .2s ease, box-shadow .2s ease; }
.profile-tab:hover { background: var(--soft); color: var(--ink); }
.profile-tab.is-active { box-shadow: inset 0 -2px 0 var(--green); color: var(--green-dark); font-weight: 700; }
.ptab[hidden] { display: none; }

/* 手机上个人主页 / 设置 / 隐私 / 关于 / 安全弹窗统一改为全屏页。
   这些弹窗在桌面端是居中卡片（max-width 400~470px），但底部导航的
   「我」「设置」在手机上直接打开它们，若沿用桌面尺寸：
     · 左右各留 20px 内边距后内容区只剩 ~350px
     · 内部按钮 / 开关的触控高度普遍低于 44px 的可点下限
   表现为「点了没反应」或「点不中」。这里统一铺满视口并放大触控目标。
   顶部留安全区，避免刘海屏盖住关闭按钮。 */
@media (max-width: 720px) {
  #profile-backdrop,
  #privacy-backdrop,
  #about-backdrop,
  #modal-backdrop { align-items: stretch; justify-content: stretch; padding: 0; }
  .profile-modal,
  .privacy-modal,
  .about-modal,
  .security-modal {
    border-radius: 0;
    max-height: none;
    max-width: none;
    padding: calc(18px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
    width: 100%;
  }
  /* 弹窗内的行式开关/按钮统一抬高到 44px 可点高度 */
  .profile-modal .ops-row,
  .privacy-modal .ops-row,
  .security-modal .ops-row,
  .about-modal .ops-row { min-height: 52px; }
  .modal-close { height: 44px; width: 44px; }
  /* 输入框 ≥16px，避免 iOS 聚焦时页面自动放大 */
  .profile-modal .field input { font-size: 16px; }
}

/* 手机上个人主页 / 设置弹窗改为全屏页。
   底部导航的「我」「设置」打开的就是这个弹窗，若沿用桌面端的居中卡片
   （max-width 470px + 上下 20px 内边距），在 390px 宽的手机上左右只剩很窄的
   内容区，且四个 tab 挤成一行、字号 12px，触控热区远低于 44px 的可点下限。
   这里直接铺满视口，tab 改成横向可滑动、字号加大。
   注意顶部留出安全区，否则刘海屏会把关闭按钮盖住。 */
@media (max-width: 720px) {
  .profile-head { gap: 12px; padding-right: 44px; } /* 给右上角关闭按钮让位 */
  .profile-tabs {
    gap: 2px;
    margin: 16px 0 14px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .profile-tabs::-webkit-scrollbar { display: none; }
  .profile-tab { flex: 0 0 auto; font-size: 14px; min-height: 44px; padding: 10px 16px; }
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { color: var(--muted); font-size: 11px; font-weight: 600; }
.field input { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); font: inherit; outline: none; padding: 9px 11px; transition: border-color .2s ease, box-shadow .2s ease; width: 100%; }
.field input:focus { border-color: #9fcdb5; box-shadow: 0 0 0 3px rgba(19, 121, 91, .08); }
.avatar-swatches { display: flex; gap: 8px; }
.avatar-img { border-radius: 50%; height: 100%; object-fit: cover; width: 100%; }
.avatar-editor { align-items: center; display: flex; gap: 14px; }
.avatar-edit-wrap { position: relative; }
.avatar-edit { align-items: center; background: var(--green); border: 2px solid var(--panel); border-radius: 50%; bottom: -3px; color: #fff; display: inline-flex; height: 26px; justify-content: center; position: absolute; right: -3px; transition: transform .15s ease, background-color .15s ease; width: 26px; }
.avatar-edit:hover { background: var(--green-dark); transform: scale(1.12); }
.avatar-edit .icon { height: 13px; width: 13px; }
.avatar-editor-actions { display: flex; flex-direction: column; gap: 6px; }
.avatar-editor-actions .text-button { padding: 2px 0; }
.danger-text { color: var(--danger); }
.danger-text:hover { opacity: .8; }
.avatar-swatch { border: 2px solid transparent; border-radius: 50%; height: 30px; transition: border-color .18s ease, transform .15s ease; width: 30px; }
.avatar-swatch:hover { transform: scale(1.12); }
.avatar-swatch.is-active { border-color: var(--green); transform: scale(1.08); }
.setting-note { color: var(--muted); font-size: 10px; line-height: 1.6; margin: 12px 2px 0; }
/* 分节小标题：在同一个 tab 内区分「开关设置」与「表单操作」两类内容 */
.field-group-title { border-top: 1px solid var(--line); color: var(--ink); font-size: 12px; font-weight: 700; letter-spacing: .02em; margin: 20px 0 14px; padding-top: 18px; }
.seg { background: var(--soft); border-radius: 8px; display: flex; gap: 3px; padding: 3px; }
.seg button { background: transparent; border-radius: 6px; color: var(--muted); flex: 1; font-size: 11px; padding: 6px 0; transition: background-color .18s ease, color .18s ease, box-shadow .18s ease; }
.seg button:hover { color: var(--ink); }
.seg button.is-active { background: var(--panel); box-shadow: 0 1px 4px rgba(0, 0, 0, .14); color: var(--ink); font-weight: 600; }
body[data-font="large"] { font-size: 15px; }
body[data-font="large"] .message-text { font-size: 14px; }
body[data-font="large"] .friend-name { font-size: 14px; }
body[data-font="large"] .friend-preview { font-size: 12px; }

/* ── 深色主题（黑色） ── */
.dark {
  --bg: #0a0c0b;
  --panel: #141715;
  --line: #262b28;
  --line-strong: #323834;
  --ink: #e4e9e6;
  --muted: #8d968f;
  --soft: #1c211e;
  --green: #2f9e74;
  --green-dark: #46b98c;
  --green-soft: #17251f;
  --blue-soft: #17222e;
  --amber-soft: #2a2315;
  --card-bg: #131614;
  --chat-bg: #0e100f;
  --header-bg: rgba(17, 20, 18, .92);
  --banner-bg: #111412;
  --banner-line: #212622;
  --shadow: 0 16px 44px rgba(0, 0, 0, .5);
  --brand-chip: #242e29;
  --danger: #d97b7b;
  --danger-soft: #33211f;
  --hover-bg: #1c211e;
  --active-hover-bg: #1e352a;
}
.dark .encryption-banner strong { color: #7cc49b; }
.dark .encryption-banner div:nth-child(2) span { color: #8ba294; }
.dark .message-row.is-me .message-bubble { background: #16281f; border-color: #20402e; }
.dark .toggle { background: #343b36; }
.dark ::-webkit-scrollbar-thumb { background: #3a423d; }
.dark .seg button.is-active { box-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.dark .avatar-swatch { opacity: .92; }

/* ── 加密横幅持久隐藏 ── */
.encryption-banner.is-hidden { display: none; }

/* ── 隐私模式弹窗 ── */
.privacy-modal { background: var(--panel); border-radius: 14px; box-shadow: 0 25px 80px rgba(0, 0, 0, .3); max-height: calc(100vh - 60px); max-width: 430px; overflow-y: auto; padding: 26px; position: relative; width: 100%; }
.privacy-modal h2 { font-size: 20px; margin: 6px 0 8px; }
.privacy-sub { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 0 0 4px; }
.privacy-modal .ops-card { margin-top: 16px; }
.privacy-modal .setting-note { margin-bottom: 0; }

/* ── 空状态形象选择 ── */
.empty-chat-figure { cursor: pointer; }
.empty-chat-figure svg { transition: transform .22s ease; }
.empty-chat-figure:hover svg { transform: scale(1.05); }
.chibi-menu { min-width: 250px; padding: 8px; }
.chibi-menu-title { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 4px 6px 8px; }
.chibi-options { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chibi-option { align-items: center; background: transparent; border: 1.5px solid transparent; border-radius: 10px; color: var(--ink); cursor: pointer; display: flex; flex-direction: column; font: inherit; gap: 2px; padding: 8px 6px; transition: background-color .18s ease, border-color .18s ease, transform .15s ease; }
.chibi-option:hover { background: var(--soft); transform: translateY(-1px); }
.chibi-option.is-active { border-color: var(--green); }
.chibi-option .chibi-mini { width: 54px; }
.chibi-option .chibi-mini svg { display: block; height: auto; width: 100%; }
.chibi-option > span:last-child { font-size: 11px; }

/* ── 关于栖息地 ── */
.about-modal { background: var(--panel); border-radius: 14px; box-shadow: 0 25px 80px rgba(0, 0, 0, .3); max-height: calc(100vh - 60px); max-width: 400px; overflow-y: auto; padding: 28px 26px 20px; position: relative; text-align: center; width: 100%; }
.about-mark { animation: floaty 3.4s ease-in-out infinite; height: 54px; margin: 0 auto 14px; width: 54px; }
.about-mark span { height: 25px; width: 6px; }
.about-mark span:nth-child(2) { height: 33px; }
.about-mark span:nth-child(3) { height: 17px; }
.about-modal h2 { font-size: 22px; letter-spacing: -.01em; margin: 0; }
.about-slogan { color: var(--muted); display: block; font-size: 12px; margin-top: 6px; }
.about-desc { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 14px 0 16px; }
.about-meta { display: flex; gap: 8px; margin-bottom: 14px; }
.about-meta div { background: var(--card-bg); border: 1px solid var(--line); border-radius: 9px; flex: 1; padding: 9px 6px; transition: border-color .2s ease, transform .2s ease; }
.about-meta div:hover { border-color: var(--green); transform: translateY(-1px); }
.about-meta span { color: var(--muted); display: block; font-size: 10px; }
.about-meta strong { font-size: 11px; }
.about-modal .ops-card { text-align: left; }
.about-copy { color: var(--muted); display: block; font-size: 10px; margin-top: 14px; }

/* ── 右侧面板空状态 ── */
.info-panel.is-empty .contact-card,
.info-panel.is-empty .info-section,
.info-panel.is-empty .info-bottom-note { display: none; }
.info-empty { align-items: center; color: var(--muted); display: none; flex-direction: column; gap: 8px; padding: 52px 12px 40px; text-align: center; }
.info-panel.is-empty .info-empty { display: flex; }
.info-empty strong { color: var(--ink); font-size: 14px; }
.info-empty p { font-size: 11px; line-height: 1.6; margin: 0; }
.info-empty .primary-button { margin-top: 10px; padding: 8px 22px; width: auto; }

/* =================== 自适应断点：平板双列 =================== */
/* 收窄通讯录列，并把详情列宽度改小。只改变量，栅格定义不需要重写。 */
@media (max-width: 1180px) {
  .app-shell.is-ready { grid-template-columns: 260px minmax(0, 1fr) var(--info-col); }
  .app-shell.is-ready.is-info-open { --info-col: 300px; }
}

/* =================== 自适应断点：手机单列页面栈 =================== */
@media (max-width: 720px) {
  /* 单列：默认展示会话列表页，进入会话后切到聊天页 */
  .app-shell.is-ready { display: block; height: 100dvh; }
  .app-shell.is-ready .sidebar,
  .app-shell.is-ready .info-panel { display: none !important; }

  /* 会话列表页 = 侧栏内容铺满全屏。
     需覆盖 .drawer 的 translateX(-100%)，否则列表页会被推到屏幕外。 */
  .app-shell.is-ready .sidebar.mobile-list {
    border-right: 0;
    display: flex !important;
    inset: 0;
    overflow-y: auto;
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
    padding-top: env(safe-area-inset-top);
    position: fixed;
    transform: none;
    width: 100%;
    z-index: 20;
  }

  /* 聊天页：默认隐藏，进入会话后显示 */
  .app-shell.is-ready .chat-panel { display: none; }
  .app-shell.is-ready.is-chat-open .chat-panel { display: flex; }
  .app-shell.is-ready.is-chat-open .sidebar.mobile-list { display: none !important; }

  .chat-panel { height: 100dvh; padding-bottom: calc(0px + env(safe-area-inset-bottom)); }
  .chat-header { min-height: 64px; padding: 10px 14px; gap: 10px; }
  .chat-header .header-actions .icon-button { height: 40px; width: 40px; }
  .encryption-banner { padding: 10px 14px; }
  .encryption-banner div:nth-child(2) span { display: none; }
  .encryption-banner .text-button { font-size: 10px; }
  .message-stage, .composer-wrap { padding-left: 14px; padding-right: 14px; }
  .message-stage { padding-bottom: 8px; }
  .message-row { max-width: 86%; }
  .message-media { max-width: min(280px, 72vw); }
  .chat-person p { font-size: 10px; }
  .secure-badge { display: none; }

  /* 手机端返回按钮：只在进入会话后显示 */
  .mobile-back { display: none; align-items: center; background: var(--soft); border-radius: 9px; height: 38px; justify-content: center; width: 38px; flex: 0 0 auto; }
  .app-shell.is-chat-open .mobile-back { display: inline-flex; }
  .chat-person { min-width: 0; flex: 1; }
  .chat-person h1 { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* 详情面板在手机上以抽屉形式覆盖全屏 */
  .app-shell.is-info-open .info-panel {
    animation: drawerIn .25s ease;
    background: var(--panel);
    bottom: 0; display: block !important; opacity: 1;
    position: fixed; right: 0; top: 0;
    width: min(340px, 92vw); z-index: 30;
    box-shadow: -10px 0 30px rgba(29, 38, 34, .12);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  @keyframes drawerIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }

  /* 输入区在手机上的触控优化：整块压缩，把纵向空间还给消息列表 */
  .composer textarea { font-size: 16px; } /* ≥16px 防止 iOS 聚焦时自动放大 */
  .composer-wrap { padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); }
  .composer { border-radius: 20px; gap: 6px; padding: 5px 6px 5px 7px; }
  .plus-toggle, .send-button { height: 38px; width: 38px; }
  .attach-panel { border-radius: 16px; grid-template-columns: repeat(4, 1fr); padding: 8px; }
  .attach-item { padding: 8px 2px; }
  .voice-recording { padding: 7px 8px; }
}

/* =================== 手机横屏：压缩纵向留白 =================== */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .chat-header { min-height: 52px; padding: 6px 12px; }
  .encryption-banner { display: none; }
  .message-stage { padding-top: 8px; }
  .call-overlay .call-actions { bottom: calc(12px + env(safe-area-inset-bottom)); }
  .call-overlay .call-center { top: 16px; transform: none; }
}


/* =================== 移动端优先：认证页、抽屉、底部导航 =================== */

.auth-pages { inset: 0; position: fixed; z-index: 100; background: var(--bg); display: flex; flex-direction: column; overflow: hidden; }
.auth-page { flex: 1; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 24px 0; overflow-y: auto; animation: authIn .4s cubic-bezier(.33, 1, .38, 1); }
@keyframes authIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.auth-page[hidden] { display: none !important; }
.auth-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 16px; }
.auth-back { align-items: center; background: transparent; border-radius: 8px; color: var(--muted); display: inline-flex; height: 36px; justify-content: center; width: 36px; }
.auth-back:hover { background: var(--soft); color: var(--ink); }
.auth-brand { display: flex; align-items: center; gap: 11px; }
.auth-brand .brand-mark { height: 30px; width: 30px; }
.auth-brand strong { font-size: 15px; }
.auth-brand small { font-size: 10px; }
.auth-main { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.auth-title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 6px; }
.auth-subtitle { color: var(--muted); font-size: 13px; margin: 0 0 32px; line-height: 1.5; }
.auth-form { display: flex; flex-direction: column; gap: 18px; }
.auth-field { display: flex; flex-direction: column; gap: 7px; }
.auth-field label { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .03em; }
.auth-field input { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink); font-size: 16px; outline: none; padding: 15px 14px; transition: border-color .2s ease, box-shadow .2s ease; }
.auth-field input:focus { border-color: #9fcdb5; box-shadow: 0 0 0 3px rgba(19, 121, 91, .08); }
.auth-submit { background: var(--green); border-radius: 10px; color: white; font-size: 16px; font-weight: 600; margin-top: 8px; padding: 16px 0; transition: background-color .18s ease, transform .12s ease; }
.auth-submit:hover { background: var(--green-dark); transform: translateY(-1px); }
.auth-submit:active { transform: scale(.98); }
.auth-hint { background: rgba(194, 59, 59, .08); border-radius: 8px; color: #b03030; font-size: 12px; line-height: 1.5; margin: 0; padding: 9px 12px; }
.auth-hint[hidden] { display: none; }
.auth-switch { color: var(--muted); font-size: 13px; margin: 24px 0 0; text-align: center; }
.auth-switch a { color: var(--green); font-weight: 600; text-decoration: none; }
.auth-footer { border-top: 1px solid var(--line); color: var(--muted); display: flex; font-size: 10px; justify-content: space-between; padding: 16px 0; }

/* 移动端底部导航 */
.mobile-nav { background: var(--panel); border-top: 1px solid var(--line); bottom: 0; display: flex; inset-inline: 0; padding: 8px 8px env(safe-area-inset-bottom); position: fixed; z-index: 25; }
.mobile-nav[hidden] { display: none; }
.nav-item { align-items: center; background: transparent; border: 0; border-radius: 10px; color: var(--muted); display: flex; flex: 1; flex-direction: column; font-size: 10px; gap: 3px; padding: 8px 6px; transition: color .18s ease, background-color .18s ease; }
.nav-item:hover { color: var(--ink); background: var(--soft); }
.nav-item:active { background: var(--soft); }
.nav-item.is-active { color: var(--green); }
.nav-item .icon { height: 22px; width: 22px; }
.nav-item.fab { background: var(--green); color: white; margin-top: -22px; }
.nav-item.fab .icon { height: 26px; width: 26px; }
.nav-item.fab:hover { background: var(--green-dark); }
.nav-item.fab:active { transform: scale(.95); }

/* 抽屉动画 */
.drawer-backdrop { background: rgba(29, 38, 34, .3); inset: 0; opacity: 0; pointer-events: none; position: fixed; transition: opacity .25s ease; z-index: 15; }
.drawer-backdrop.is-visible { opacity: 1; pointer-events: auto; }

/* 宽屏下侧栏与详情面板都是普通的栅格列，不是抽屉。
   必须把 .drawer 的 fixed / translateX 撤销掉，否则它们会被推出可视区。
   这条规则曾缺失，导致桌面端进去只能看到一片空白。
   （窄屏的抽屉形态在下方 max-width:720px 的媒体查询里重新赋上。）

   注意两条易踩的坑：
   1) 选择器必须带上 .drawer 类。.drawer-left/.drawer-right 的特异性是 (0,1,0)，
      与 .app-shell.is-ready .sidebar 的 (0,3,0) 相比并不占优，但后者若写成
      .app-shell.is-ready .sidebar 就只匹配「元素带 sidebar 类」；
      真正需要压住的是 .drawer-left，所以这里显式列出 .drawer。
   2) 不要在这里写 overflow-y。移动端抽屉靠它自己滚动，宽屏下栅格列
      由 .sidebar/.info-panel 各自的原生规则决定溢出行为，写死会破坏滚动。 */
@media (min-width: 721px) {
  .app-shell.is-ready .sidebar.drawer,
  .app-shell.is-ready .info-panel.drawer {
    position: relative;
    inset: auto;
    transform: none;
    box-shadow: none;
    z-index: auto;
    transition: none;
  }
  /* 宽度交给 grid-template-columns 决定。
     写死 width 会在栅格列为 0px（详情关闭）时撑出滚动条。 */
  .app-shell.is-ready .sidebar.drawer { width: auto; }
  .app-shell.is-ready .info-panel.drawer { width: auto; }
  /* 抽屉专用的「关闭」按钮在宽屏隐藏（窄屏才需要）。 */
  .app-shell.is-ready .drawer-close { display: none; }
}

.drawer { position: fixed; top: 0; bottom: 0; background: var(--panel); z-index: 20; display: flex; flex-direction: column; overflow-y: auto; transition: transform .3s cubic-bezier(.33, 1, .38, 1); }
.drawer-left { left: 0; width: min(300px, 88vw); box-shadow: 10px 0 30px rgba(29,38,34,.08); transform: translateX(-100%); }
.drawer-right { right: 0; width: min(330px, 92vw); box-shadow: -10px 0 30px rgba(29,38,34,.08); transform: translateX(100%); }
.drawer.is-open { transform: translateX(0); }
.drawer-close { align-items: center; background: var(--soft); border-radius: 8px; bottom: 16px; color: var(--muted); display: inline-flex; height: 36px; justify-content: center; margin: 0 auto; opacity: 0; pointer-events: none; position: sticky; width: 36px; transition: opacity .2s, background-color .18s; }
.drawer-close:hover { background: var(--green-soft); color: var(--green); }
@media (max-width: 720px) { .drawer-close { opacity: 1; pointer-events: auto; } }

/* 锚点容器：用来给移动端详情抽屉的「关闭」按钮一个定位挂点。
   它自己不参与布局，宽屏下直接隐藏（按钮也在宽屏被隐藏）。 */
.panel-close-anchor { display: contents; }
@media (min-width: 721px) { .panel-close-anchor { display: none; } }

/* 移动端聊天头部菜单按钮 */
.header-menu { display: none; }
@media (max-width: 720px) { .header-menu { display: inline-flex; } }

/* 移动端聊天面板内边距（底部导航只在列表页出现，聊天页不留底部空隙） */
@media (max-width: 720px) {
  .app-shell.is-chat-open .chat-panel { padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav { display: flex; }
  /* 列表页需要为底部导航预留空间 */
  .app-shell:not(.is-chat-open) .mobile-nav { display: flex; }
  .app-shell.is-chat-open .mobile-nav { display: none; }

  /* 提示条要抬到底部导航栏之上。
     .toast 的定位是 bottom: 25px，而导航栏固定占着屏幕底部约 65px（+安全区），
     两者重叠 —— 提示条会正好压在导航栏上。聊天页没有导航栏，保持原位。 */
  .app-shell:not(.is-chat-open) .toast { bottom: calc(78px + env(safe-area-inset-bottom)); }
}

/* 更窄的小屏（如 iPhone SE 375px）：进一步压缩 */
@media (max-width: 400px) {
  .chat-header { padding: 8px 10px; }
  .message-stage, .composer-wrap { padding-left: 10px; padding-right: 10px; }
  .message-row { max-width: 92%; }
  .header-actions .icon-button:not(#info-toggle) { display: none; }
  .nav-item { font-size: 9px; }
}

/* =================== 手机端会话列表页（原生 App 观感） =================== */
@media (max-width: 720px) {
  /* 品牌栏改为紧凑标题栏，省出纵向空间给会话列表 */
  .sidebar.mobile-list .brand { padding: 14px 16px 10px; }
  .sidebar.mobile-list .brand small { display: none; }
  .sidebar.mobile-list .profile-row { padding: 8px 16px 12px; }
  .sidebar.mobile-list .sidebar-section { padding-left: 14px; padding-right: 14px; }
  .sidebar.mobile-list .friend-list { padding: 0 8px; }
  .sidebar.mobile-list .friend-item { border-radius: 12px; margin-bottom: 2px; padding: 12px 10px; }
  .sidebar.mobile-list .friend-name { font-size: 15px; }
  .sidebar.mobile-list .sidebar-footer { padding: 10px 16px 4px; }

  /* 列表页隐藏桌面端专用的「关闭」按钮 */
  .sidebar.mobile-list .drawer-close { display: none !important; }

  /* 搜索框加大触控高度 */
  .sidebar.mobile-list .search-box input { padding: 12px 14px; }
  .sidebar.mobile-list .filter-tab { padding: 8px 14px; }
  .sidebar.mobile-list .section-heading button.icon-button { height: 38px; width: 38px; }
}



/* 触摸优化 */
@media (hover: none) and (pointer: coarse) {
  .icon-button, .auth-submit, .primary-button, .send-button, .nav-item { min-height: 44px; }
  .friend-item { padding: 14px 10px; }
  .auth-field input { font-size: 16px; }
  .composer textarea { min-height: 44px; }

  /* 触屏没有 hover，操作条必须常显 —— 否则引用 / 撤回在手机上根本点不到。
     同时把按钮放大到能可靠点中的尺寸（Apple HIG 建议 ≥44px 触达区，
     视觉可以小，但热区要靠 padding 补足）。 */
  .msg-actions { gap: 6px; opacity: 1; pointer-events: auto; transform: none; }
  .msg-action { height: 34px; width: 34px; }
  .msg-action .icon { height: 15px; width: 15px; }
  /* 常显会让每条消息都挂着四个圆钮，密度太高；改成小一号、低对比度，
     点按下时才提亮，靠「触达即出」而不是「一直抢眼」。 */
  .msg-action { background: var(--soft); border-color: transparent; color: var(--muted); }
  .msg-action:active { background: var(--green-soft); color: var(--green); }
  .media-save { height: 34px; width: 34px; }
  .media-save .icon { height: 16px; width: 16px; }

  /* 操作条常显后，一行里同时挤着「头像 + 气泡 + 4 个按钮」会被压得很窄。
     窄屏上把操作条换到气泡下方单独一行，给消息内容留出完整宽度。 */
  .message-row { flex-wrap: wrap; }
  .msg-actions { flex-basis: 100%; justify-content: flex-end; margin: 2px 0 0; }
  .message-row:not(.is-me) .msg-actions { justify-content: flex-start; }
  .message-row.is-me .msg-actions { flex-direction: row; }
}

/* 认证页加载动画 */
.auth-page-enter { animation: authIn .4s cubic-bezier(.33, 1, .38, 1); }
.auth-page-exit { animation: authOut .3s ease forwards; }
@keyframes authOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-16px); } }
