/* =====================================================================
   邻里社区 · 第一阶段 即时聊天
   浅色拟态（Neumorphic）设计系统：所有颜色 / 阴影 / 间距集中在 :root
   ===================================================================== */
:root {
  --surface:        #eef1f7;
  --surface-raised: #f4f6fb;
  --surface-sunk:   #e7ebf3;
  --text:           #3a4560;
  --text-muted:     #7c879f;
  --text-faint:     #a7b0c3;
  --accent:         #6c7ce0;
  --accent-2:       #8e9bf0;
  --success:        #4fb79a;
  --danger:         #e0625b;
  --shadow-dark:    #cdd5e4;
  --shadow-light:   #ffffff;

  --shadow-sm:  4px 4px 9px var(--shadow-dark), -4px -4px 9px var(--shadow-light);
  --shadow-md:  7px 7px 15px var(--shadow-dark), -7px -7px 15px var(--shadow-light);
  --shadow-lg:  12px 12px 26px var(--shadow-dark), -12px -12px 26px var(--shadow-light);
  --shadow-inset: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);

  --radius:      18px;
  --radius-sm:   12px;

  /* ---------- 底部区域统一变量（遮挡源建模） ---------- */
  /* 移动端 Tab 栏高度（含 padding）。密度紧凑时变矮，dock 模式也变矮 */
  --tabbar-h:       62px;
  --tabbar-h-dock:  56px;
  --tabbar-h-compact: 54px;
  /* Tab 栏 bottom: calc(10px + safe-area) 里的 10px 外层间距 */
  --tabbar-bottom-gap: 10px;
  /* Tab 栏 z-index（需高于内容，低于 modal） */
  --tabbar-z:       80;
  /* 聊天 composer + typing-bar 完整高度（移动端） */
  --composer-h:     76px;   /* 输入区 padding 10+14 + textarea ~46px */
  /* 聊天 chat-head 高度 */
  --chat-head-h:    58px;

  /* ---------- 统一安全区与总底部占位 ---------- */
  /* safe-area-inset-bottom：iOS 动态岛 / 全面屏底部手势区 */
  --safe-bottom:    env(safe-area-inset-bottom, 0px);
  /* 普通页面底部占位 = tabbar-h + tabbar-bottom-gap + safe-bottom + 额外内容喘息 */
  --page-bottom-pad: calc(var(--tabbar-h) + var(--tabbar-bottom-gap) + var(--safe-bottom) + 12px);
  /* 聊天页：composer 固定底部，不需要 tabbar 占位（composer 在 tabbar 之上） */
  --chat-visible-h:  calc(100dvh - var(--tabbar-h) - var(--tabbar-bottom-gap) - var(--safe-bottom));

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
button, input, textarea { font-family: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--shadow-dark, #cdd5e4); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint, #b9c3d7); }

/* ------------------------------- 骨架 ------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  height: 100vh;
  max-width: 1560px;
  margin: 0 auto;
  background: var(--surface);
  overflow: hidden;
}
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 22px 18px 12px;
  border-right: 1px solid color-mix(in srgb, var(--text-faint) 16%, transparent);
  box-shadow: 6px 0 18px rgba(0,0,0,.06);
  z-index: 2;
}
.chat-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-width: 0;
  min-height: 0;
  /* 默认不画自己的底色，透出 theme.css 的 body 主题渐变 —— 深色/主题切换即时生效 */
  background: transparent;
}

/* ------------------------------- 侧栏顶部 ------------------------------- */
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center;
  font-size: 20px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.35; }
.brand-text strong { font-size: 16px; letter-spacing: .5px; }
.brand-text small  { font-size: 10px; color: var(--text-faint); letter-spacing: 1.2px; text-transform: uppercase; }

.icon-btn {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 12px;
  background: var(--surface); color: var(--text-muted);
  font-size: 20px; line-height: 1;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, color .15s;
}
.icon-btn svg, .search-icon svg { display: block; }
.search-icon { display: flex; align-items: center; }
.icon-btn:hover { color: var(--accent); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(1px); box-shadow: var(--shadow-inset); }
.icon-link { font-size: 16px; }

/* ------------------------------- 我的名片 ------------------------------- */
.me-card {
  display: flex; align-items: center; gap: 11px;
  padding: 12px; margin-bottom: 18px;
  border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.me-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.me-info strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-info small  { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--text-faint); }
.dot-online { background: var(--success); box-shadow: 0 0 0 3px rgba(79,183,154,.16); }

/* ------------------------------- 头像 ------------------------------- */
.avatar {
  width: 42px; height: 42px; flex: none;
  border-radius: 50%; overflow: hidden;
  display: grid; place-items: center;
  font-weight: 700; font-size: 16px; color: #fff;
  background: var(--accent);
  box-shadow: 3px 3px 7px var(--shadow-dark), -3px -3px 7px var(--shadow-light);
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-head .avatar { width: 40px; height: 40px; font-size: 15px; }
.conv-item .avatar { width: 46px; height: 46px; font-size: 17px; }
/* 会话列表里点对方头像进主页（点其余区域仍是打开会话） */
.conv-item .avatar.avatar-linkable { cursor: pointer; transition: transform .16s ease, box-shadow .16s ease; }
.conv-item .avatar.avatar-linkable:hover { transform: scale(1.05); box-shadow: 0 0 0 2px var(--accent); }

/* ------------------------------- 搜索 ------------------------------- */
.search-wrap { position: relative; margin-bottom: 16px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px; border-radius: 8px;
  background: transparent; box-shadow: none;
  border: 1px solid color-mix(in srgb, var(--text-faint) 26%, transparent);
}
.search-icon { font-size: 20px; color: var(--text-faint); line-height: 1; }
.search-box input {
  flex: 1; min-width: 0; padding: 11px 0;
  border: 0; outline: none; background: transparent;
  color: var(--text); font-size: 13px;
}
.search-box input::placeholder { color: var(--text-faint); }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  max-height: 290px; overflow-y: auto; z-index: 20;
  padding: 7px; border-radius: 16px;
  background: var(--surface-raised); box-shadow: var(--shadow-lg);
}
.search-result {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 11px;
  background: transparent; text-align: left; color: var(--text);
}
.search-result:hover { background: rgba(108,124,224,.10); }
.search-result .sr-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; }
.search-result .sr-sub  { font-size: 11px; color: var(--text-faint); }
.search-result .avatar { width: 32px; height: 32px; font-size: 13px; }
.search-empty { padding: 16px; text-align: center; font-size: 12px; color: var(--text-faint); }

/* ------------------------------- 会话列表 ------------------------------- */
.conv-list { flex: 1; min-height: 0; overflow-y: auto; padding: 3px 4px 10px 2px; }
.list-loading, .list-empty { padding: 40px 12px; text-align: center; font-size: 12px; color: var(--text-faint); line-height: 1.8; }
.conv-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 11px 12px; margin-bottom: 9px;
  border: 0; border-radius: 16px; text-align: left;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform .16s, box-shadow .16s;
}
.conv-item:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.conv-item.active { box-shadow: var(--shadow-inset); background: var(--surface-sunk); }
.conv-item .ci-main { flex: 1; min-width: 0; }
.conv-item .ci-top { display: flex; align-items: baseline; gap: 6px; }
.conv-item .ci-name {
  flex: 1; min-width: 0; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-item .ci-time { font-size: 10px; color: var(--text-faint); flex: none; }
.conv-item .ci-bottom { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.conv-item .ci-preview {
  flex: 1; min-width: 0; font-size: 11.5px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ci-badge {
  flex: none; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 18px; text-align: center;
}
.ci-online { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: none; }

.side-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 6px 4px; font-size: 10.5px; color: var(--text-faint);
  border-top: 1px solid rgba(205,213,228,.55);
}
.conn { display: flex; align-items: center; gap: 6px; }
.conn i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.conn-ok i   { background: var(--success); box-shadow: 0 0 0 3px rgba(79,183,154,.15); }
.conn-wait i { background: #e0a94f; }
.conn-err i  { background: var(--danger); }

/* ------------------------------- 聊天头部 ------------------------------- */
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px;
  background: var(--glass-strong, var(--surface));
  backdrop-filter: blur(14px) saturate(var(--glass-sat, 160%));
  border-bottom: 1px solid color-mix(in srgb, var(--text-faint) 20%, transparent);
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
  z-index: 3;
}
.conv-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.conv-meta strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-meta small  { font-size: 11px; color: var(--text-muted); }
.head-typing { font-size: 11px; color: var(--accent); white-space: nowrap; }
.back-btn { display: none; }

/* ------------------------------- 消息区 ------------------------------- */
.message-scroll { overflow-y: auto; padding: 22px 26px 8px; min-height: 0; }
.empty-state { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--text-muted); }
.empty-state .empty-logo {
  width: 74px; height: 74px; margin-bottom: 20px; border-radius: 24px;
  display: grid; place-items: center; font-size: 32px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow-md);
}
.empty-state strong { font-size: 17px; color: var(--text); }
.empty-state p { margin: 10px 0 0; font-size: 12.5px; line-height: 2; max-width: 420px; }
.load-more {
  display: block; margin: 0 auto 16px; padding: 7px 16px;
  border: 0; border-radius: 20px; font-size: 11px; color: var(--text-muted);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.load-more:hover { color: var(--accent); }

.message-list { display: flex; flex-direction: column; }
.day-divider { align-self: center; margin: 18px 0 10px; padding: 4px 13px; border-radius: 12px; font-size: 10.5px; color: var(--text-faint); background: var(--glass, var(--surface)); box-shadow: var(--shadow-sm); }
.msg-row { display: flex; align-items: flex-end; gap: 9px; margin: 13px 0; }
.msg-row.mine { flex-direction: row-reverse; }
.msg-row .avatar { width: 32px; height: 32px; font-size: 12px; box-shadow: none; }
/* 对方头像 → 个人主页：链接本身不参与 flex 伸缩，避免被消息气泡挤压 */
.msg-avatar-link { display: inline-flex; flex: none; text-decoration: none; line-height: 0; }
.msg-avatar-link .avatar { transition: transform .16s ease, box-shadow .16s ease; }
.msg-avatar-link:hover .avatar { transform: scale(1.06); box-shadow: 0 0 0 2px var(--accent); }
.msg-body { display: flex; flex-direction: column; max-width: min(68%, 560px); min-width: 0; }
.msg-row.mine .msg-body { align-items: flex-end; }
.msg-sender { font-size: 10.5px; color: var(--text-faint); margin: 0 0 4px 6px; }
.bubble {
  padding: 10px 15px; border-radius: 18px;
  font-size: 13.5px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm);
  border-bottom-left-radius: 6px;
}
.msg-row.mine .bubble {
  color: #fff; border-bottom-left-radius: 18px; border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 4px 4px 10px rgba(108,124,224,.28);
}
.bubble.pending { opacity: .72; }
.bubble.failed { outline: 2px solid var(--danger); outline-offset: 2px; cursor: pointer; }
.msg-meta { font-size: 10px; color: var(--text-faint); margin: 5px 6px 0; }
.msg-row.system { justify-content: center; }
.msg-row.system .bubble { padding: 4px 12px; font-size: 11px; color: var(--text-faint); background: transparent; box-shadow: none; }

.typing-bar { padding: 0 26px 8px; font-size: 11px; color: var(--accent); min-height: 0; }
.typing-dots i { display: inline-block; width: 5px; height: 5px; margin-right: 3px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ------------------------------- 输入区 ------------------------------- */
.composer {
  display: flex; align-items: flex-end; gap: 14px;
  padding: 14px 24px 20px;
}
.composer textarea {
  flex: 1; min-width: 0; resize: none;
  max-height: 130px; padding: 13px 16px;
  /* 扁平单层：透明底 + 单层细边框 + 一点点圆角，不使用内凹拟态 */
  border: 1px solid var(--glass-border); outline: none; border-radius: 8px;
  background: transparent; color: var(--text); font-size: 13.5px; line-height: 1.6;
  box-shadow: none;
}
.composer textarea::placeholder { color: var(--text-faint); }
.composer textarea:disabled { opacity: .6; }
.send-btn {
  flex: none; width: 92px; height: 46px;
  border: 0; border-radius: 15px; color: #fff; font-size: 14px; font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 5px 5px 12px var(--shadow-dark), -5px -5px 12px var(--shadow-light);
  transition: transform .15s, box-shadow .15s, opacity .15s;
}
.send-btn:hover:not(:disabled) { transform: translateY(-1px); }
.send-btn:active:not(:disabled) { transform: translateY(1px); box-shadow: var(--shadow-inset); }
.send-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ------------------------------- 弹窗 / Toast ------------------------------- */
.modal-mask { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; padding: 20px; background: rgba(58,69,96,.28); backdrop-filter: blur(3px); }
.modal-card { width: 100%; max-width: 430px; padding: 26px; border-radius: 24px; background: var(--surface-raised); box-shadow: var(--shadow-lg); }
.modal-card h3 { margin: 0 0 20px; font-size: 17px; }
/* 输入框保持扁平单层：不加内凹拟态阴影（全站交互组件约定） */
.neu-input { width: 100%; padding: 12px 15px; margin-bottom: 12px; border: 1px solid color-mix(in srgb, var(--text-faint) 28%, transparent); outline: none; border-radius: 8px; background: transparent; color: var(--text); font-size: 13px; box-shadow: none; }
.neu-input:focus { border-color: var(--accent); box-shadow: none; }
.modal-users { max-height: 220px; overflow-y: auto; margin: 6px 0 14px; padding: 6px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-inset); }
.modal-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; font-size: 13px; }
.modal-user:hover { background: rgba(108,124,224,.10); }
.modal-user input { accent-color: var(--accent); width: 15px; height: 15px; }
.modal-user .avatar { width: 28px; height: 28px; font-size: 11px; box-shadow: none; }
.modal-selected { min-height: 20px; font-size: 11.5px; color: var(--text-muted); line-height: 1.7; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px; }
.btn-ghost, .btn-primary { padding: 10px 20px; border: 0; border-radius: 12px; font-size: 13px; font-weight: 600; }
.btn-ghost { background: var(--surface); color: var(--text-muted); box-shadow: var(--shadow-sm); }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 4px 4px 10px rgba(108,124,224,.25); }
.btn-ghost:active, .btn-primary:active { box-shadow: var(--shadow-inset); }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  z-index: 80; max-width: 80vw; padding: 11px 20px; border-radius: 14px;
  font-size: 13px; color: #fff; background: rgba(58,69,96,.92);
  box-shadow: var(--shadow-md); animation: toast-in .2s ease-out;
}
.toast.error { background: rgba(200,80,72,.94); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ------------------------------- 响应式 ------------------------------- */
@media (max-width: 860px) {
  html, body { height: 100%; margin: 0; padding: 0; }
  body {
    /* 阻止页面级滚动；聊天打开时 .chat-main 成为全屏 flex 容器 */
    overscroll-behavior: none;
  }
  .app-shell {
    /* 移动端整个 shell 占满视口，聊天打开时 chat-main 覆盖 */
    display: flex;
    flex-direction: column;
    /* 兼容：先 100vh，再 100dvh 覆盖（iOS Safari 支持 dvh，老浏览器回退 vh） */
    height: 100vh;
    height: 100dvh;
    max-width: none;
    overflow: hidden;
    /* 底栏是 fixed 悬浮层，内容区必须铺满整个视口，滚动时内容才能从导航栏
       背后穿过。早期在这里留 72px 底部占位会把主内容硬裁在 tabbar 顶部，
       导航栏背后永远是空白，视觉上变成「内容 / 空白 / 导航」三段拼接。
       各主内容区自行用 --page-bottom-pad 保证滚到底时末条内容仍完整可读；
       聊天会话列表由 theme.css 的 .conv-list 单独补占位。 */
    padding-bottom: 0;
  }

  /* ---------- 侧栏（会话列表） ---------- */
  .sidebar {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    padding: 16px 14px 10px;
    border-right: 0;
    overflow: hidden;  /* 侧栏内部 .conv-list 自己滚 */
  }

  /* ---------- 聊天主区：固定全屏 flex column（兼容不支持 dvh 的浏览器） ---------- */
  .chat-main {
    /* 固定定位覆盖整个视口，兼容所有浏览器 */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: calc(var(--tabbar-z, 80) + 20);   /* 100，高于 tabbar */
    display: none;
    flex-direction: column;
    /* 回退链：100% → 100vh → 100dvh */
    height: 100%;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    /* 透出 body 主题渐变，跟随系统主题；自定义背景由 .chat-main / .x-bg-layer 叠加 */
    background: transparent;
    padding-bottom: calc(var(--safe-bottom, env(safe-area-inset-bottom, 0px)) + 4px);
    overflow: hidden;  /* 聊天主区自身不滚，只让 message-scroll 滚 */
  }
  body.chat-open .chat-main { display: flex; }
  /* chat-main 是 fixed 全屏 overlay 且自身 transparent（透出 body 主题渐变）。
     若不隐藏下层会话列表，其 me-card / 搜索框 / 会话项会从透明的消息区透出来，
     表现为「打开聊天后侧栏内容还挂在窗口里」。visibility 而非 display：
     保留布局流，返回会话列表时不重置滚动位置，也不影响 conv-list 的 JS 逻辑。 */
  body.chat-open .sidebar { visibility: hidden; }

  /* 聊天头部：不收缩、固定高度 */
  .chat-head {
    flex-shrink: 0;
    padding: 12px 14px;
    min-height: var(--chat-head-h, 58px);
    background: var(--glass-strong, var(--surface));
    backdrop-filter: blur(14px) saturate(var(--glass-sat, 160%));
    border-bottom: 1px solid color-mix(in srgb, var(--text-faint) 18%, transparent);
  }

  /* 消息滚动区：flex:1 min-height:0 才会真正滚 */
  .message-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 14px 6px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* typing-bar：不收缩 */
  .typing-bar {
    flex-shrink: 0;
    padding: 0 26px 8px;
  }

  /* composer：固定在聊天主区底部 */
  .composer {
    flex-shrink: 0;
    padding: 10px 14px 14px;
    background: var(--glass, transparent);
    backdrop-filter: blur(14px) saturate(var(--glass-sat, 160%));
    border-top: 1px solid color-mix(in srgb, var(--text-faint) 18%, transparent);
  }

  /* 移动端调整 */
  .back-btn { display: grid; }
  .msg-body { max-width: 78%; }
  .send-btn { width: 74px; height: 42px; }
  .composer textarea { padding: 11px 14px; font-size: 14px; }
}

/* ------------------------------- 模块导航（聊天 / 贴吧 / 通讯录 / 友友圈） ------------------------------- */
.app-nav {
  display: flex; flex-direction: column; gap: 5px;
  padding: 5px; margin-bottom: 14px;
  border-radius: 15px; background: var(--surface);
  box-shadow: var(--shadow-inset);
}
.app-nav-home { font-weight: 700; }
.app-nav-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px;
}
.app-nav-item {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 4px; border-radius: 11px;
  color: var(--text-muted); font-size: 12px; font-weight: 600;
  white-space: nowrap;
  transition: color .16s, background .16s, box-shadow .16s;
}
.app-nav-item:hover { color: var(--accent); }
.app-nav-item.active {
  color: var(--accent); background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}
.app-nav-item svg { display: block; flex: none; }

/* =====================================================================
   聊天升级：时间居中 / 三点按钮 / 抽屉面板 / emoji picker 贴底
   ===================================================================== */

/* ------- 2. 聊天时间戳：day-divider 和系统消息统一居中 ------- */
.day-divider {
  align-self: center;
  text-align: center;
  margin: 18px 0 10px;
  padding: 4px 13px;
  border-radius: 12px;
  font-size: 10.5px;
  color: var(--text-faint);
  background: rgba(255, 255, 255, .55);
  box-shadow: var(--shadow-sm);
  letter-spacing: .3px;
}
.msg-row.system { justify-content: center; }
.msg-row.system .bubble {
  padding: 4px 12px;
  font-size: 11px;
  color: var(--text-faint);
  background: transparent;
  box-shadow: none;
  text-align: center;
}

/* ------- 3. 三点按钮（聊天信息入口） ------- */
.chat-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}
.chat-head-more {
  display: flex;
  align-items: center;
  flex: none;
}
#btn-more {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, color .15s;
}
#btn-more:hover { color: var(--accent); transform: translateY(-1px); }
#btn-more:active { transform: translateY(1px); box-shadow: var(--shadow-inset); }
#btn-more svg { display: block; }

/* ------- 聊天信息抽屉（slide-in from right） ------- */
.chat-info-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 56, .35);
  backdrop-filter: blur(2px);
  z-index: 150;                   /* 高于 chat-main (100) 和 tabbar (80) */
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.chat-info-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.chat-info-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 340px;
  max-width: 90vw;
  background: var(--surface-raised);
  z-index: 160;
  box-shadow: -16px 0 48px -16px rgba(28, 36, 64, .35);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.22, 1, .36, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-info-drawer.visible { transform: translateX(0); }

.drawer-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(124, 135, 159, .12);
}
.drawer-head strong { font-size: 15px; }
.drawer-head .icon-btn { width: 32px; height: 32px; }

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px 24px;
}

/* 头像组 */
.drawer-avatar-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 0 18px;
}
.drawer-avatar-group .avatar {
  width: 56px; height: 56px;
  font-size: 22px;
  cursor: pointer;
  transition: transform .18s;
}
.drawer-avatar-group .avatar:hover { transform: scale(1.05); }
.drawer-add-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px dashed rgba(108, 124, 224, .5);
  background: var(--surface);
  color: var(--accent);
  display: grid; place-items: center;
  cursor: pointer;
  flex: none;
  transition: background .15s, border-color .15s;
}
.drawer-add-btn:hover {
  background: rgba(108, 124, 224, .08);
  border-color: var(--accent);
}

/* 功能列表 section */
.drawer-section {
  background: var(--surface);
  border-radius: 14px;
  padding: 4px 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.drawer-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 10px 6px 4px;
}
.drawer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 6px;
  border-bottom: 1px solid rgba(124, 135, 159, .08);
  cursor: pointer;
  transition: background .12s;
  gap: 10px;
}
.drawer-row:last-child { border-bottom: 0; }
.drawer-row:hover { background: rgba(108, 124, 224, .05); }
.drawer-row-label {
  font-size: 14px;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-row-arrow {
  color: var(--text-faint);
  flex: none;
  opacity: .7;
}

/* iOS 风格开关 */
.drawer-switch {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  flex: none;
  background: var(--surface-sunk);
  box-shadow: var(--shadow-inset);
  cursor: pointer;
  transition: background .2s;
}
.drawer-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
  transition: left .2s cubic-bezier(.22, 1, .36, 1);
}
.drawer-switch.on {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.drawer-switch.on::after { left: 22px; }

.drawer-danger { color: var(--danger); }
.drawer-danger:hover { background: rgba(224, 98, 91, .08); }

/* ------- emoji picker 贴底：覆盖通用 reposition ------- */
/* 聊天场景下，让 picker 贴在 composer 上方、覆盖 tabbar */
.ep-root.ep-chat-bottom {
  position: fixed !important;
  bottom: calc(var(--composer-h) + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  top: auto !important;
  width: min(360px, calc(100vw - 16px)) !important;
  z-index: calc(var(--tabbar-z) + 10);
}
.ep-root.ep-chat-bottom.visible {
  transform: translateX(-50%) translateY(0);
}
.ep-root.ep-chat-bottom .ep-grid {
  max-height: 280px;
}

/* ------- 消息 emoji 添加收藏的小菜单 ------- */
.emoji-fav-menu {
  position: fixed;
  z-index: 200;
  background: var(--surface-raised);
  border-radius: 12px;
  padding: 6px 0;
  min-width: 160px;
  box-shadow: 0 10px 30px rgba(28, 36, 64, .25), 0 2px 6px rgba(28, 36, 64, .08);
  animation: emoji-fav-menu-in .15s ease-out;
}
@keyframes emoji-fav-menu-in {
  from { opacity: 0; transform: translateY(4px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.emoji-fav-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 16px;
  border: 0;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background .1s;
}
.emoji-fav-menu button:hover { background: rgba(108, 124, 224, .08); }
.emoji-fav-menu .efm-icon {
  font-size: 18px;
  flex: none;
}

/* ------- 移动端抽屉全宽 ------- */
@media (max-width: 860px) {
  .chat-info-drawer { width: 100vw; max-width: 100vw; }
  /* 移动端 day-divider 更紧凑 */
  .day-divider { font-size: 10px; padding: 3px 10px; }
}
