/* ============================================================
   密盾空间 · 全站样式（蓝色轻快主题，与已确认的原型一致）
   登录页 / 主应用（聊天 + AI）共用
   ============================================================ */
:root {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --line: #eceef4;
  --text: #1e2230;
  --text-2: #6b7280;
  --text-3: #9aa1b0;
  --primary: #4d90e9;
  --grad: linear-gradient(135deg, #4f93e8 0%, #5fb0f2 55%, #7ed0f9 100%);
  --grad-soft: linear-gradient(135deg, #eef6ff, #e9f7ff);
  --shadow-s: 0 1px 2px rgba(30,34,48,.05);
  --shadow-m: 0 6px 24px rgba(30,34,48,.08);
  --shadow-l: 0 18px 60px rgba(70,120,190,.14);
  --r-l: 20px; --r-m: 14px; --r-s: 10px;
  --ok: #22c55e; --warn: #f59e0b;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }
a { color: var(--primary); }
.hidden { display: none !important; }

/* ============ 登录页 ============ */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 32px 16px;
  background:
    radial-gradient(720px 420px at 12% 8%, rgba(95,160,235,.12), transparent 60%),
    radial-gradient(720px 420px at 88% 92%, rgba(126,208,249,.12), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 880px; display: grid; grid-template-columns: 1fr 1.05fr;
  background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-l); overflow: hidden;
}
.login-brand {
  background: var(--grad); color: #fff; padding: 44px 40px; display: flex; flex-direction: column; gap: 26px;
}
.login-brand .logo { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.2);
  display: grid; place-items: center; font-size: 17px; backdrop-filter: blur(4px);
}
.login-brand h2 { font-size: 26px; line-height: 1.45; font-weight: 700; margin-top: 6px; }
.login-brand p { opacity: .85; line-height: 1.7; }
.brand-feats { display: flex; flex-direction: column; gap: 14px; margin-top: auto; }
.brand-feat { display: flex; align-items: center; gap: 10px; font-size: 13.5px; opacity: .95; }
.brand-feat .ico {
  width: 30px; height: 30px; border-radius: 9px; background: rgba(255,255,255,.16);
  display: grid; place-items: center;
}
.login-form { padding: 44px 44px 36px; display: flex; flex-direction: column; }
.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 26px; }
.seg button {
  flex: 1; padding: 9px 0; border-radius: 9px; font-size: 14px; color: var(--text-2); font-weight: 500;
  transition: all .18s;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-s); }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 7px; }
.field input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r-m);
  font-size: 14px; outline: none; background: #fafbfd; transition: border .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(95,160,235,.15); background: #fff; }
.login-opts { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 20px; font-size: 13px; color: var(--text-2); }
.login-opts label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.btn-primary {
  width: 100%; padding: 13px 0; border-radius: var(--r-m); color: #fff; font-size: 15px; font-weight: 600;
  background: var(--grad); box-shadow: 0 6px 18px rgba(95,160,238,.30); transition: transform .12s, box-shadow .12s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 9px 24px rgba(95,160,238,.38); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .6; cursor: default; transform: none; }
.login-foot { text-align: center; font-size: 12.5px; color: var(--text-3); margin-top: auto; padding-top: 22px; }
.login-err {
  display: none; background: #fdf2f2; border: 1px solid #fecaca; color: #dc2626;
  font-size: 13px; padding: 10px 14px; border-radius: var(--r-s); margin-bottom: 16px; line-height: 1.5;
}
.login-err.show { display: block; }

/* ============ 主应用骨架 ============ */
.app { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 60px; flex: none; display: flex; align-items: center; gap: 18px;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: relative; z-index: 40;
}
.topbar .logo { font-size: 16.5px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.topbar .logo-mark { width: 30px; height: 30px; font-size: 15px; background: var(--grad); color: #fff; }
.nav { display: flex; gap: 4px; background: var(--bg); border-radius: 12px; padding: 4px; }
.nav button {
  padding: 7px 18px; border-radius: 9px; font-size: 13.5px; color: var(--text-2); font-weight: 500;
  display: flex; align-items: center; gap: 6px; transition: all .18s; position: relative;
}
.nav button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-s); }
.nav .ndot {
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 700; display: grid; place-items: center;
}
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 16px;
  color: var(--text-2); position: relative; transition: background .15s;
}
.icon-btn:hover { background: var(--bg); }
.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 5px 12px 5px 6px; border-radius: 99px;
  border: 1px solid var(--line); transition: background .15s; cursor: pointer; font-size: 13.5px;
  color: var(--text); position: relative;
}
.user-chip:hover { background: var(--bg); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; color: #fff; font-size: 13px; font-weight: 600;
  display: grid; place-items: center; flex: none; overflow: hidden; background: #94a3b8;
}
.avatar.has-img { background: var(--grad-soft); }
.avatar .avatar-pic { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-chip .avatar { width: 26px; height: 26px; font-size: 12px; }
.av-a { background: linear-gradient(135deg,#4f93e8,#38b6f5); }

/* 用户下拉菜单 */
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 172px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow-l); padding: 6px; z-index: 60;
}
.menu button {
  width: 100%; text-align: left; padding: 9px 12px; border-radius: 9px; font-size: 13.5px; color: var(--text);
  display: flex; align-items: center; gap: 9px;
}
.menu button:hover { background: var(--bg); }
.menu button.danger { color: #dc2626; }
.menu .sep { height: 1px; background: var(--line); margin: 5px 8px; }

.main { flex: 1; display: flex; min-height: 0; }

/* ============ 通用侧栏（会话列表） ============ */
.side {
  width: 292px; flex: none; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.side-head { padding: 18px 16px 12px; display: flex; align-items: center; justify-content: space-between; }
.side-head h3 { font-size: 15.5px; font-weight: 700; }
.side-sub { padding: 0 16px 10px; font-size: 12px; color: var(--text-3); }
.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.conv {
  display: flex; gap: 11px; padding: 11px 10px; border-radius: var(--r-m); cursor: pointer;
  transition: background .13s; position: relative;
}
.conv:hover { background: var(--bg); }
.conv.on { background: var(--grad-soft); }
.conv.offline { opacity: .55; }
.conv .avatar { width: 42px; height: 42px; font-size: 16px; }
.conv .av-wrap { position: relative; flex: none; }
.online-dot {
  position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--ok); border: 2.5px solid var(--surface);
}
.conv-mid { flex: 1; min-width: 0; }
.conv-row { display: flex; justify-content: space-between; align-items: baseline; }
.conv-name { font-weight: 600; font-size: 13.8px; }
.conv-time { font-size: 11.5px; color: var(--text-3); flex: none; }
.conv-prev { font-size: 12.5px; color: var(--text-2); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  position: absolute; right: 8px; bottom: 10px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 99px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 600;
  display: grid; place-items: center; box-shadow: 0 2px 6px rgba(239,68,68,.4);
}
.side-empty { padding: 26px 20px; text-align: center; color: var(--text-3); font-size: 12.8px; line-height: 1.8; }

/* ============ 聊天窗口 ============ */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  height: 62px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 22px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.chat-head .avatar { width: 38px; height: 38px; font-size: 15px; }
.chat-head .who b { font-size: 14.5px; display: block; }
.chat-head .who span { font-size: 12px; color: var(--ok); }
.chat-head .who span.wait { color: var(--text-3); }
.chat-head .ops { margin-left: auto; display: flex; gap: 4px; }
.msgs { flex: 1; overflow-y: auto; padding: 24px 26px 10px; display: flex; flex-direction: column; gap: 16px; }
.day { align-self: center; font-size: 12px; color: var(--text-3); background: rgba(0,0,0,.045); padding: 4px 12px; border-radius: 99px; }
.sys { align-self: center; font-size: 12px; color: #b45309; background: #fef3c7; padding: 4px 12px; border-radius: 99px; }
.msg { display: flex; gap: 10px; max-width: 72%; align-self: flex-start; }
.msg .avatar { width: 34px; height: 34px; font-size: 13px; margin-top: 2px; }
.msg .col { min-width: 0; }
.msg .sender { font-size: 11.5px; color: var(--text-3); margin: 0 0 4px 2px; }
.bubble {
  padding: 11px 15px; border-radius: 4px 16px 16px 16px; background: var(--surface);
  box-shadow: var(--shadow-s); line-height: 1.65; font-size: 13.8px;
  white-space: pre-wrap; word-break: break-word;
}
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg.me .bubble {
  border-radius: 16px 4px 16px 16px; background: var(--grad); color: #fff;
  box-shadow: 0 4px 14px rgba(95,160,238,.25);
}
.msg .meta { font-size: 11px; color: var(--text-3); margin-top: 5px; }
.msg.me .meta { text-align: right; }
/* 图片消息 */
.bubble.img { padding: 5px; }
.bubble.img img {
  width: 210px; max-width: 100%; border-radius: 12px; display: block; cursor: zoom-in;
}
/* 文件消息 */
.bubble.file { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.bubble.file .f-ico {
  width: 36px; height: 36px; border-radius: 9px; background: var(--grad-soft); color: var(--primary);
  display: grid; place-items: center; font-size: 16px; flex: none;
}
.bubble.file .f-name { font-weight: 600; font-size: 13px; word-break: break-all; }
.bubble.file .f-size { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.msg.me .bubble.file .f-size { color: rgba(255,255,255,.8); }
.msg.me .bubble.file .f-ico { background: rgba(255,255,255,.22); color: #fff; }
/* 正在输入小圆点 */
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; background: var(--surface); border-radius: 4px 16px 16px 16px; box-shadow: var(--shadow-s); }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #b6bac7; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,60%,100% { opacity: .3; transform: translateY(0);} 30% { opacity: 1; transform: translateY(-3px);} }

.composer { padding: 14px 22px 20px; background: transparent; }
.attach-row { padding: 0 22px; }
.attach-tip {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 7px 14px;
  box-shadow: var(--shadow-s);
}
.attach-tip .spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid #cbd5e1; border-top-color: var(--primary);
  animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.composer-box {
  display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 16px;
  padding: 8px 8px 8px 12px; box-shadow: var(--shadow-m); border: 1.5px solid transparent; transition: border .15s;
}
.composer-box:focus-within { border-color: rgba(95,160,238,.5); }
.composer-box input { flex: 1; border: none; outline: none; font-size: 14px; background: none; min-width: 0; }
.tool { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 16px; color: var(--text-2); transition: background .15s; flex: none; }
.tool:hover { background: var(--bg); }
.send {
  width: 38px; height: 38px; border-radius: 12px; background: var(--grad); color: #fff; font-size: 15px;
  display: grid; place-items: center; box-shadow: 0 4px 12px rgba(95,160,238,.30); flex: none;
}
.send:disabled { opacity: .5; cursor: default; }
/* 表情小面板 */
.emoji-pop {
  position: absolute; bottom: calc(100% + 8px); left: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-m); box-shadow: var(--shadow-l); padding: 8px; display: grid;
  grid-template-columns: repeat(8, 34px); gap: 2px; z-index: 50;
}
.emoji-pop button { width: 34px; height: 34px; border-radius: 8px; font-size: 17px; }
.emoji-pop button:hover { background: var(--bg); }

/* ============ AI 页 ============ */
.ai-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ai-msgs { flex: 1; overflow-y: auto; }
.ai-inner { max-width: 780px; margin: 0 auto; padding: 30px 24px 12px; display: flex; flex-direction: column; gap: 22px; }
.ai-q { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.ai-q .b {
  background: var(--grad-soft); border: 1px solid #dceafb; padding: 10px 16px; border-radius: 16px 16px 4px 16px;
  font-size: 14px; max-width: 80%; white-space: pre-wrap; word-break: break-word;
}
.ai-q .meta { font-size: 11.5px; color: var(--text-3); }
.ai-a { display: flex; gap: 12px; }
.ai-a .avatar { width: 34px; height: 34px; font-size: 15px; background: var(--grad); }
.ai-a .body { flex: 1; min-width: 0; padding-top: 4px; }
.ai-a .body .txt { font-size: 14px; line-height: 1.85; white-space: pre-wrap; word-break: break-word; }
.ai-a .body .warn {
  font-size: 12.5px; color: #b45309; background: #fef3c7; border-radius: var(--r-s);
  padding: 7px 12px; margin-bottom: 8px;
}
.ai-search-warn { font-size: 12.5px; color: #b45309; background: #fef3c7; border-radius: var(--r-s); padding: 7px 12px; margin-bottom: 8px; }
details.refs { border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); overflow: hidden; margin-top: 10px; }
details.refs summary {
  cursor: pointer; list-style: none; padding: 10px 14px; font-size: 13px; color: var(--text-2); font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
details.refs summary::-webkit-details-marker { display: none; }
details.refs summary::after { content: "▾"; margin-left: auto; color: var(--text-3); transition: transform .2s; }
details.refs[open] summary::after { transform: rotate(180deg); }
.ref {
  display: flex; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 12.8px;
  align-items: center; color: var(--text-2);
}
.ref .n { width: 20px; height: 20px; border-radius: 6px; background: var(--bg); color: var(--text-2); display: grid; place-items: center; font-size: 11px; flex: none; }
.ref b { color: var(--text); font-weight: 600; }
.ref a { color: var(--primary); text-decoration: none; word-break: break-all; }

.ai-composer { padding: 12px 24px 24px; }
.ai-composer-inner { max-width: 780px; margin: 0 auto; position: relative; }
.ai-box {
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-m); padding: 12px 14px 10px;
  border: 1.5px solid transparent; transition: border .15s;
}
.ai-box:focus-within { border-color: rgba(95,160,238,.5); }
.ai-box textarea {
  width: 100%; border: none; outline: none; resize: none; font-size: 14.5px; line-height: 1.6;
  min-height: 46px; max-height: 180px; background: none; font-family: inherit; color: var(--text);
}
.ai-box-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 99px;
  border: 1px solid var(--line); font-size: 12.8px; color: var(--text-2); background: var(--surface);
  transition: all .16s; user-select: none;
}
.pill:hover { border-color: #d4d7e3; }
.pill.on {
  color: #fff; border-color: transparent; background: linear-gradient(135deg, #f59e0b, #f97316);
  box-shadow: 0 3px 10px rgba(245,158,11,.35);
}
.ai-box-row .send { margin-left: auto; width: 36px; height: 36px; }
.ai-tip { text-align: center; font-size: 11.8px; color: var(--text-3); margin-top: 10px; }

.ai-side .new-chat {
  margin: 14px 14px 6px; padding: 11px 0; border-radius: var(--r-m); font-size: 13.5px; font-weight: 600;
  background: var(--grad); color: #fff; box-shadow: 0 5px 14px rgba(95,160,238,.28);
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.ai-side .group-t { font-size: 11.5px; color: var(--text-3); font-weight: 600; padding: 14px 18px 6px; letter-spacing: .4px; }
.hist { display: flex; align-items: center; gap: 6px; }
.hist .t {
  flex: 1; padding: 9px 8px 9px 16px; border-radius: 11px; margin: 0 0 0 8px; cursor: pointer; font-size: 13.2px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background .13s;
  display: block; min-width: 0;
}
.hist:hover { background: var(--bg); }
.hist .x {
  display: none; width: 22px; height: 22px; border-radius: 7px; margin-right: 10px; flex: none;
  place-items: center; color: var(--text-3); font-size: 13px;
}
.hist:hover .x { display: grid; }
.hist .x:hover { background: #fee2e2; color: #dc2626; }
.hist .t.on, .hist.on .t { background: var(--grad-soft); color: var(--text); font-weight: 600; }

/* 空状态（新会话） */
.ai-hero { text-align: center; padding: 7vh 24px 0; }
.ai-hero .big { font-size: 40px; }
.ai-hero h2 { font-size: 22px; margin: 14px 0 8px; }
.ai-hero p { color: var(--text-2); font-size: 13.5px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 780px; margin: 30px auto 0; padding: 0 24px; }
.card {
  background: var(--surface); border-radius: var(--r-m); box-shadow: var(--shadow-s); padding: 16px;
  text-align: left; cursor: pointer; border: 1.5px solid transparent; transition: all .15s;
}
.card:hover { border-color: rgba(95,160,238,.45); transform: translateY(-2px); box-shadow: var(--shadow-m); }
.card .ic { font-size: 20px; }
.card b { display: block; margin: 9px 0 5px; font-size: 13.5px; }
.card span { font-size: 12.3px; color: var(--text-2); line-height: 1.6; display: block; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d7dae4; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #c3c7d4; }

/* ============ 弹窗 / 提示 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20,20,40,.42); z-index: 100;
  display: grid; place-items: center; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-l);
  width: 100%; max-width: 420px; padding: 24px;
}
.modal h3 { font-size: 16px; margin-bottom: 4px; }
.modal .sub { font-size: 12.5px; color: var(--text-3); margin-bottom: 18px; }
.modal .m-close { position: absolute; }
.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 8px; }
.avatar-grid .avatar {
  width: 100%; aspect-ratio: 1; font-size: 22px; cursor: pointer; border: 2.5px solid transparent;
  transition: transform .12s, border .12s;
}
.avatar-grid .avatar:hover { transform: scale(1.06); }
.avatar-grid .avatar.sel { border-color: var(--primary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.btn-ghost { padding: 10px 18px; border-radius: var(--r-s); font-size: 13.5px; color: var(--text-2); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-go { padding: 10px 18px; border-radius: var(--r-s); font-size: 13.5px; color: #fff; background: var(--grad); font-weight: 600; }
.btn-go:disabled { opacity: .55; }
.modal-err { font-size: 12.8px; color: #dc2626; margin-top: 10px; min-height: 17px; }

#toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 20px); z-index: 200;
  background: rgba(30,34,48,.92); color: #fff; font-size: 13px; padding: 11px 18px; border-radius: 99px;
  opacity: 0; pointer-events: none; transition: all .25s; max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 图片灯箱 */
#lightbox {
  position: fixed; inset: 0; z-index: 300; background: rgba(10,12,20,.85); display: grid; place-items: center;
  cursor: zoom-out; padding: 24px;
}
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

/* ============ 移动端（≤720px）============ */
.mob-head, .backbtn, .tabbar, .scrim { display: none; }
@keyframes slideR { from { transform: translateX(-18px); } to { transform: none; } }
@media (max-width: 900px) {
  .login-card { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}
@media (max-width: 720px) {
  .app { height: 100dvh; }
  .topbar { padding: 0 12px; gap: 10px; }
  .topbar .nav, .topbar .icon-btn { display: none; }
  .user-chip { padding: 4px 8px 4px 5px; }
  .user-chip .uname { display: none; }
  /* 标签栏移到顶栏下方后，main 不再给底部留空间（键盘弹出时也不会被标签栏挤占） */
  .main { position: relative; margin-top: 46px; margin-bottom: 0; min-height: 0; }
  /* 手机端输入框不需要表情/附件/拍照按钮 */
  .composer-box .tool { display: none; }

  /* 视图栈：列表 → 详情 整屏推进 */
  .side { width: 100%; border-right: none; }
  .chat, .ai-main { position: absolute; inset: 0; z-index: 6; background: var(--bg); }
  #paneChat { display: none !important; }               /* 聊天页默认停在会话列表 */
  .app.detail #paneChat { display: flex !important; animation: slideR .2s ease; }
  .backbtn { display: grid !important; }
  .mob-head { display: flex; height: 54px; flex: none; align-items: center; gap: 6px;
    padding: 0 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .mob-head b { font-size: 15px; }

  /* AI 历史 = 抽屉 + 遮罩 */
  .app.drawer #sideAi { display: flex !important; position: absolute; inset: 0 auto 0 0;
    width: 84%; max-width: 320px; z-index: 22; box-shadow: var(--shadow-l); animation: slideR .2s ease; }
  .app.drawer .scrim { display: block; position: absolute; inset: 0; z-index: 21;
    background: rgba(20,20,40,.38); }

  /* 触控友好 */
  .conv { padding: 13px 10px; }
  .msgs { padding: 16px 12px 6px; }
  .msg { max-width: 88%; }
  .bubble.img img { width: 100%; min-width: 0; }
  .composer { padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); }
  .attach-row { padding: 0 12px; }
  .ai-composer { padding: 8px 12px calc(14px + env(safe-area-inset-bottom)); }
  .composer-box input, #aiInput { font-size: 16px; }    /* ≥16px 防 iOS 聚焦自动放大 */
  .ai-inner { padding: 18px 12px 8px; }
  .cards { grid-template-columns: 1fr; margin-top: 20px; }
  .ai-hero { padding-top: 5vh; }
  .emoji-pop { grid-template-columns: repeat(6, 40px); }
  .emoji-pop button { width: 40px; height: 40px; }

  /* 顶部标签栏：贴在 60px 顶栏下方，横向胶囊样式（不占键盘空间） */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; top: 60px; bottom: auto; z-index: 30;
    height: 46px; justify-content: center; align-items: center; gap: 8px;
    background: rgba(255,255,255,.95); backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line); padding: 0 10px;
  }
  .tabbar button { position: relative; flex: 0 1 auto; display: flex; flex-direction: row;
    align-items: center; justify-content: center; gap: 5px;
    padding: 7px 16px; border-radius: 99px; font-size: 13px; color: var(--text-2); }
  .tabbar button.on { color: var(--primary); background: var(--grad-soft); font-weight: 600; }
  .tabbar .ti { font-size: 15px; line-height: 1; position: relative; }
  .tabbar .tbadge { position: absolute; top: -5px; right: -7px; min-width: 16px; height: 16px;
    padding: 0 4px; border-radius: 99px; background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
    display: grid; place-items: center; }
}
