/* ==========================================================================
   聊 · 自建聊天  —  基础样式
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

/* hidden 属性优先于组件自身的 display */
[hidden] { display: none !important; }

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;

  --bg: #eaeef2;
  --panel: #ffffff;
  --panel-2: #f6f8fa;
  --panel-3: #eef1f4;
  --text: #131a20;
  --text-2: #5d6a76;
  --text-3: #8b97a3;
  --line: #e3e8ed;
  --line-strong: #d3dae1;

  --accent: #0f9f8f;
  --accent-2: #0d8b7d;
  --accent-soft: rgba(15, 159, 143, .1);
  --on-accent: #ffffff;
  --danger: #d9534f;

  --bubble-in: #ffffff;
  --bubble-out: linear-gradient(135deg, #12b3a1, #0b8d7f);
  --shadow-sm: 0 1px 2px rgba(16, 24, 32, .06), 0 2px 8px rgba(16, 24, 32, .04);
  --shadow: 0 10px 30px rgba(16, 24, 32, .10);
  --shadow-lg: 0 24px 60px rgba(13, 20, 28, .18);
  --radius: 16px;
  --radius-sm: 12px;
  --sidebar-w: 336px;
}

[data-theme="dark"] {
  --bg: #0b0f14;
  --panel: #141a21;
  --panel-2: #10161c;
  --panel-3: #1b232c;
  --text: #e8edf2;
  --text-2: #9aa7b4;
  --text-3: #6f7d8b;
  --line: #232c36;
  --line-strong: #2f3a46;

  --accent: #1cbfab;
  --accent-2: #17a996;
  --accent-soft: rgba(28, 191, 171, .14);
  --on-accent: #05201d;
  --danger: #ef6b66;

  --bubble-in: #1a222b;
  --bubble-out: linear-gradient(135deg, #14a997, #0b8274);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
}

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--accent); text-decoration: none; }
::selection { background: var(--accent-soft); }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------- 通用组件 ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border-radius: 12px; font-size: 15px; font-weight: 600;
  background: var(--panel-3); color: var(--text);
  transition: transform .12s ease, background .18s ease, box-shadow .18s ease, opacity .18s;
  white-space: nowrap;
}
.btn:hover { background: var(--line); }
.btn:active { transform: scale(.975); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  box-shadow: 0 6px 18px rgba(15, 159, 143, .28);
}
.btn.primary:hover { filter: brightness(1.04); }
.btn.ghost { background: transparent; border: 1px solid var(--line-strong); }
.btn.ghost:hover { background: var(--panel-3); }
.btn.danger { color: var(--danger); background: transparent; }
.btn.danger:hover { background: rgba(217, 83, 79, .1); }
.btn.block { width: 100%; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: background .16s, color .16s, transform .12s;
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.send {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  box-shadow: 0 4px 14px rgba(15, 159, 143, .3);
}
.icon-btn.send:hover { filter: brightness(1.05); color: var(--on-accent); }

/* 主题切换按钮只显示当前可切到的那一个图标 */
[data-theme="light"] .i-sun { display: none; }
[data-theme="dark"] .i-moon { display: none; }

.avatar {
  --c: #0f9f8f;
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: #fff;
  background: linear-gradient(145deg, var(--c), color-mix(in srgb, var(--c) 68%, #000));
  flex: none; user-select: none; overflow: hidden;
  box-shadow: inset 0 -1px 2px rgba(0,0,0,.12);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.avatar.sm { width: 30px; height: 30px; font-size: 13px; }

/* -------------------------------- 启动 -------------------------------- */
.boot {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); z-index: 90;
}
.boot-logo {
  width: 54px; height: 54px; border-radius: 17px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: .9; }
  50% { transform: scale(.86); opacity: .55; }
}

/* ------------------------------ 登录/注册 ------------------------------ */
.auth {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; padding: 24px;
  overflow: auto;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(15,159,143,.18), transparent 60%),
    radial-gradient(900px 500px at 95% 110%, rgba(226,114,91,.16), transparent 60%),
    var(--bg);
}
.auth-blob {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; pointer-events: none;
}
.auth-blob.b1 { width: 320px; height: 320px; background: #0f9f8f; top: 8%; left: 6%; }
.auth-blob.b2 { width: 280px; height: 280px; background: #e2725b; bottom: 6%; right: 8%; opacity: .32; }

.auth-card {
  position: relative; width: 100%; max-width: 404px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 34px 32px 26px;
  box-shadow: var(--shadow-lg);
  animation: authIn .5s cubic-bezier(.22,1,.36,1);
}
@keyframes authIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.brand { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: 0 8px 20px rgba(15,159,143,.3);
}
.logo-mark svg { width: 28px; height: 28px; fill: #fff; stroke: none; }
.logo-mark.sm { width: 32px; height: 32px; border-radius: 10px; box-shadow: none; }
.logo-mark.sm svg { width: 20px; height: 20px; }
.brand-name { font-size: 22px; font-weight: 800; letter-spacing: 2px; }

.auth-sub { margin: 14px 0 22px; color: var(--text-3); font-size: 13px; }

.tabs {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--panel-3); border-radius: 12px; padding: 4px; margin-bottom: 20px;
}
.tab {
  position: relative; z-index: 1; height: 38px; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--text-2); transition: color .2s;
}
.tab.active { color: var(--text); }
.tab-ink {
  position: absolute; top: 4px; left: 4px; width: calc(50% - 4px); height: 38px;
  background: var(--panel); border-radius: 9px; box-shadow: var(--shadow-sm);
  transition: transform .28s cubic-bezier(.4,1.4,.5,1);
}
.tabs[data-mode="register"] .tab-ink { transform: translateX(100%); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.field input {
  width: 100%; height: 46px; padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--panel-2); color: var(--text);
  outline: none; transition: border-color .18s, box-shadow .18s, background .18s;
}
.field input::placeholder { color: var(--text-3); }
.field input:focus {
  border-color: var(--accent); background: var(--panel);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.auth-error {
  min-height: 20px; margin: 2px 0 10px; font-size: 13px; color: var(--danger);
}
.auth-foot { margin: 18px 0 0; text-align: center; font-size: 12px; color: var(--text-3); }
.auth-foot span { font-family: var(--mono); }

/* -------------------------------- 布局 -------------------------------- */
.app {
  display: grid; grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh; height: 100dvh; overflow: hidden;
}
/* 修正：grid / flex 子项默认 min-height:auto 会被内容撑高，导致输入框被顶出可视区 */
.app > * { min-height: 0; min-width: 0; }

/* ------------------------------- 侧边栏 ------------------------------- */
.sidebar {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--panel-2);
  border-right: 1px solid var(--line);
}
.side-head {
  height: 62px; flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px 0 18px;
}
.head-actions { display: flex; align-items: center; gap: 2px; }

.side-search {
  position: relative; flex: none; padding: 0 14px 12px;
}
.side-search .s-ico {
  position: absolute; left: 26px; top: 11px; width: 16px; height: 16px; color: var(--text-3);
}
.side-search input {
  width: 100%; height: 40px; padding: 0 12px 0 38px;
  border-radius: 11px; border: 1px solid transparent;
  background: var(--panel-3); color: var(--text);
  outline: none; font-size: 14px; transition: border-color .18s, background .18s;
}
.side-search input::placeholder { color: var(--text-3); }
.side-search input:focus { border-color: var(--accent); background: var(--panel); }
.side-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.conv-list { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 8px 12px; }
.conv-group-title {
  padding: 12px 10px 6px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .08em; color: var(--text-3); text-transform: uppercase;
}

.conv {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 11px; align-items: center;
  padding: 10px; border-radius: 13px; cursor: pointer;
  transition: background .15s;
  position: relative;
}
.conv:hover { background: var(--panel-3); }
.conv.active { background: var(--panel); box-shadow: var(--shadow-sm); }
.conv.active::before {
  content: ""; position: absolute; left: 0; top: 50%; translate: 0 -50%;
  width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.conv-body { min-width: 0; }
.conv-top { display: flex; align-items: baseline; gap: 8px; }
.conv-title {
  font-size: 14.5px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0;
}
.conv-time { font-size: 11.5px; color: var(--text-3); flex: none; }
.conv-preview {
  margin-top: 2px; font-size: 13px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 4px;
}
.conv-preview svg { width: 13px; height: 13px; }
.conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.badge {
  min-width: 19px; height: 19px; padding: 0 6px; border-radius: 99px;
  background: var(--accent); color: #fff;
  font-size: 11.5px; font-weight: 700; line-height: 19px; text-align: center;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.dot.off { background: var(--line-strong); }
.conv .avatar { position: relative; }
.avatar .presence {
  position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px;
  border-radius: 50%; background: #22c55e; border: 2px solid var(--panel-2);
}
.conv.active .avatar .presence { border-color: var(--panel); }

.side-foot { flex: none; padding: 10px 12px 14px; border-top: 1px solid var(--line); }
.me {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 12px; text-align: left; transition: background .15s;
}
.me:hover { background: var(--panel-3); }
.me-text { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.me-text strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { width: 16px; height: 16px; color: var(--text-3); }

/* -------------------------------- 聊天 -------------------------------- */
.chat {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--panel);
}
.chat::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 20%, var(--accent-soft), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(226,114,91,.05), transparent 40%);
  opacity: .8;
}

.chat-head {
  position: relative; z-index: 2; flex: none;
  height: 62px; display: flex; align-items: center; gap: 6px;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.head-main { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; }
.head-text { min-width: 0; display: flex; flex-direction: column; }
.head-text strong { font-size: 15.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-text small { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-text small.online { color: var(--accent); }
.icon-btn.back { display: none; }

.msg-scroll {
  position: relative; z-index: 1; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  scroll-behavior: smooth;
  padding: 18px 6px 8px;
}
.msg-list {
  max-width: 900px; margin: 0 auto; padding: 0 18px;
  display: flex; flex-direction: column; gap: 3px;
}
.day-sep {
  align-self: center; margin: 16px 0 10px; padding: 3px 12px;
  font-size: 11.5px; color: var(--text-3);
  background: var(--panel-3); border-radius: 99px;
}
.load-more {
  align-self: center; margin: 4px 0 14px; padding: 6px 14px;
  font-size: 12.5px; color: var(--text-2);
  border-radius: 99px; background: var(--panel-3);
}
.load-more:hover { color: var(--accent); }

.chat-empty-hint {
  align-self: center; margin-top: 48px; padding: 8px 16px;
  font-size: 12.5px; color: var(--text-3);
  background: var(--panel-3); border-radius: 99px;
}

.msg {
  display: flex; align-items: flex-end; gap: 9px;
  margin-top: 12px; position: relative;
}
.msg.same { margin-top: 3px; }
.msg .avatar { width: 32px; height: 32px; font-size: 13px; align-self: flex-start; margin-top: 2px; }
.msg.same .avatar { visibility: hidden; height: 0; margin: 0; }
.msg-body { max-width: min(72%, 620px); min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.msg-sender {
  font-size: 11.5px; color: var(--text-3); margin: 0 0 4px 4px; font-weight: 500;
}
.bubble {
  position: relative;
  padding: 9px 13px;
  border-radius: 14px 14px 14px 5px;
  background: var(--bubble-in);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 14.5px; line-height: 1.6;
  word-break: break-word; overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.bubble a { text-decoration: underline; text-underline-offset: 2px; }
.bubble.media { padding: 3px; background: var(--bubble-in); }
.bubble.file { padding: 0; overflow: hidden; }

.msg.self { flex-direction: row-reverse; }
.msg.self .msg-body { align-items: flex-end; }
.msg.self .bubble {
  background: var(--bubble-out); color: #fff;
  border-color: transparent; border-radius: 14px 14px 5px 14px;
}
.msg.self .bubble a { color: #eafaf7; }
.msg.self .msg-sender { display: none; }
.msg.self .bubble.media { background: rgba(15, 159, 143, .16); }

.msg-time {
  font-size: 10.5px; color: var(--text-3); margin: 4px 4px 0;
  opacity: 0; transition: opacity .2s; height: 0; overflow: hidden;
}
.msg:hover .msg-time { opacity: 1; height: auto; }
.msg.deleted .bubble {
  background: transparent; border: 1px dashed var(--line-strong);
  color: var(--text-3); font-style: italic; box-shadow: none;
}

/* 图片 / 视频 */
.bubble.media img, .bubble.media video {
  display: block; max-width: 100%; border-radius: 11px; cursor: zoom-in;
  background: transparent;
}
.bubble.media img {
  max-width: min(320px, 68vw); max-height: 320px;
  width: auto; height: auto; object-fit: contain;
}
.bubble.media video { max-width: min(360px, 72vw); max-height: 340px; cursor: default; }
.media-caption { padding: 4px 8px 3px; font-size: 12.5px; color: var(--text-3); }
.msg.self .media-caption { color: rgba(255,255,255,.75); }

/* 文件卡片 */
.file-row {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; min-width: 210px; max-width: 330px;
}
.file-ico {
  width: 40px; height: 40px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.msg.self .file-ico { background: rgba(255,255,255,.18); color: #fff; }
.file-ico svg { width: 20px; height: 20px; }
.file-meta { min-width: 0; flex: 1; }
.file-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 11.5px; color: var(--text-3); }
.msg.self .file-size { color: rgba(255,255,255,.7); }
.file-dl { color: var(--text-2); }
.msg.self .file-dl { color: #fff; }
.file-dl:hover { color: var(--accent); }

/* 撤回菜单 */
.msg-actions {
  position: absolute; top: -10px; opacity: 0; transition: opacity .15s;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; box-shadow: var(--shadow-sm); padding: 2px;
  display: flex; z-index: 3;
}
.msg.self .msg-actions { right: 42px; }
.msg:not(.self) .msg-actions { left: 42px; }
.msg:hover .msg-actions { opacity: 1; }
.msg-actions button {
  padding: 4px 9px; font-size: 11.5px; border-radius: 7px; color: var(--text-2);
  display: flex; align-items: center; gap: 4px;
}
.msg-actions button:hover { background: var(--panel-3); color: var(--text); }
.msg-actions button svg { width: 13px; height: 13px; }

.typing-bubble {
  align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px;
  background: var(--bubble-in); border: 1px solid var(--line);
  border-radius: 14px 14px 14px 5px; margin: 6px 0 0 41px;
}
.typing-bubble i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-3);
  animation: bounce 1.2s infinite;
}
.typing-bubble i:nth-child(2) { animation-delay: .15s; }
.typing-bubble i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }

/* 空状态 */
.empty-chat {
  position: absolute; inset: 62px 0 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--text-3); text-align: center; padding: 20px;
  background: var(--panel);
}
.empty-art svg { width: 132px; height: 132px; stroke: none; }
.empty-chat p { margin: 10px 0 2px; font-size: 15px; color: var(--text-2); font-weight: 500; }
.empty-chat small { font-size: 12.5px; }

/* ------------------------------- 输入区 ------------------------------- */
.composer {
  position: relative; z-index: 2; flex: none;
  padding: 10px 18px calc(14px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.composer-box {
  max-width: 900px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 16px; padding: 7px 7px 7px 14px;
  transition: border-color .18s, box-shadow .18s;
}
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-box textarea {
  flex: 1; min-height: 32px; max-height: 160px; resize: none;
  border: 0; outline: none; background: transparent;
  padding: 6px 0; font-size: 14.5px; line-height: 1.5;
}
.composer-box textarea::placeholder { color: var(--text-3); }
.composer-actions { display: flex; align-items: center; gap: 1px; }

.upload-progress {
  max-width: 900px; margin: 8px auto 0;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--text-2);
}
.up-text { display: flex; gap: 8px; min-width: 0; }
.up-text span:first-child { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-bar { flex: 1; height: 5px; background: var(--panel-3); border-radius: 99px; overflow: hidden; }
.up-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s; }
.up-cancel { color: var(--text-3); font-size: 12.5px; }
.up-cancel:hover { color: var(--danger); }

/* ------------------------------ 成员面板 ------------------------------ */
.members-panel {
  position: absolute; top: 62px; right: 0; bottom: 0; width: 286px; z-index: 5;
  display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -14px 0 30px rgba(10, 20, 30, .07);
  animation: mp-in .18s ease;
}
@keyframes mp-in { from { opacity: 0; transform: translateX(12px); } }
.mp-head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--line);
}
.mp-title { display: flex; flex-direction: column; min-width: 0; }
.mp-title strong { font-size: 14.5px; font-weight: 700; }
.mp-title small { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.mp-body { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 8px 16px; }
.mp-group {
  padding: 12px 8px 6px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .06em; color: var(--text-3);
}
.mp-row {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 11px; text-align: left; transition: background .15s;
}
.mp-row:hover { background: var(--panel-3); }
.mp-row .avatar { position: relative; width: 34px; height: 34px; font-size: 13px; }
.mp-row .avatar .presence {
  position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px;
  border-radius: 50%; background: #22c55e; border: 2px solid var(--panel);
}
.mp-text { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.mp-text strong {
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mp-text small { font-size: 11.5px; color: var(--text-3); }
.mp-row.offline .mp-text strong { color: var(--text-2); font-weight: 500; }
.mp-state { flex: none; font-size: 11px; color: var(--text-3); }
.mp-row.online .mp-state { color: var(--accent); }
.mp-empty { padding: 26px 12px; text-align: center; font-size: 12.5px; color: var(--text-3); }

/* ------------------------------- 弹层 ------------------------------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 16, 22, .5);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 440px; max-height: min(86vh, 720px);
  display: flex; flex-direction: column;
  background: var(--panel); border-radius: 20px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line);
  animation: modalIn .24s cubic-bezier(.22,1,.36,1);
  overflow: hidden;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.985); } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 12px; flex: none;
}
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.modal-body { padding: 0 20px 4px; overflow-y: auto; }
.modal-foot { padding: 14px 20px 18px; display: flex; gap: 10px; justify-content: flex-end; flex: none; }
.modal-foot .btn { height: 40px; }

.menu-list { padding: 4px 8px 8px; }
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 12px 12px; border-radius: 12px; text-align: left; font-size: 14.5px;
  transition: background .15s;
}
.menu-item:hover { background: var(--panel-3); }
.menu-item svg { width: 18px; height: 18px; color: var(--text-2); }
.menu-item.danger, .menu-item.danger svg { color: var(--danger); }

.picker-search { position: relative; margin-bottom: 12px; }
.picker-search input {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 11px;
  border: 1px solid var(--line-strong); background: var(--panel-2);
  outline: none; font-size: 14px;
}
.picker-search input:focus { border-color: var(--accent); background: var(--panel); }
.picker-list { min-height: 120px; }
.pick-row {
  width: 100%; display: flex; align-items: center; gap: 11px;
  padding: 9px 8px; border-radius: 11px; text-align: left;
}
.pick-row:hover { background: var(--panel-3); }
.pick-row .pick-text { flex: 1; min-width: 0; }
.pick-row strong { display: block; font-size: 14px; font-weight: 600; }
.pick-row small { color: var(--text-3); font-size: 12px; }
.check {
  width: 20px; height: 20px; border-radius: 6px; border: 1.8px solid var(--line-strong);
  display: grid; place-items: center; flex: none; transition: all .15s;
}
.pick-row.on .check { background: var(--accent); border-color: var(--accent); }
.pick-row.on .check svg { width: 12px; height: 12px; stroke: #fff; stroke-width: 3; opacity: 1; }
.check svg { opacity: 0; }
.hint { color: var(--text-3); font-size: 13px; padding: 18px 4px; text-align: center; }

.member-row { display: flex; align-items: center; gap: 11px; padding: 8px 0; }
.member-row .pick-text { flex: 1; }
.member-row strong { font-size: 14px; font-weight: 600; }
.member-row small { color: var(--text-3); font-size: 12px; }
.tag {
  font-size: 11px; padding: 1px 7px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}

.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent;
  transition: transform .15s;
}
.swatch.on { border-color: var(--text); transform: scale(1.08); }

.emoji-panel {
  position: absolute; bottom: calc(100% + 10px); right: 18px;
  width: 296px; padding: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  z-index: 20;
}
.emoji-panel button {
  height: 34px; border-radius: 8px; font-size: 20px; line-height: 1;
  display: grid; place-items: center;
}
.emoji-panel button:hover { background: var(--panel-3); }

/* 输入区在未选中会话时隐藏 */
.chat.no-conv .composer { display: none; }
.chat.no-conv .chat-head { opacity: .55; pointer-events: none; }

.pop-menu {
  min-width: 176px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 13px; box-shadow: var(--shadow);
  z-index: 66; animation: modalIn .16s ease;
}
.pop-menu .menu-item { padding: 10px; font-size: 14px; }

.profile-head {
  display: flex; align-items: center; gap: 14px;
  padding: 6px 0 18px;
}
.profile-head strong { display: block; font-size: 17px; font-weight: 700; }
.profile-head small { color: var(--text-3); font-size: 12.5px; }

.field-label {
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  margin: 18px 0 8px;
}

/* ------------------------------- 灯箱 ------------------------------- */
.lightbox {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(6, 10, 14, .94);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; animation: fade .18s;
}
.lb-stage { max-width: 100%; max-height: calc(100% - 70px); display: grid; place-items: center; }
.lb-stage img { max-width: 100%; max-height: calc(100vh - 130px); border-radius: 8px; object-fit: contain; }
.lb-bar {
  margin-top: 14px; display: flex; align-items: center; gap: 10px;
  color: #cfd8e0; font-size: 13px;
}
.lb-bar .btn.ghost { color: #e7eef4; border-color: rgba(255,255,255,.22); }
.lb-bar .btn.ghost:hover { background: rgba(255,255,255,.12); }
#lb-name { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------- 其他 ------------------------------- */
.drop-hint {
  position: fixed; inset: 0; z-index: 65;
  display: grid; place-items: center;
  background: rgba(15, 159, 143, .14);
  border: 3px dashed var(--accent);
  color: var(--accent); font-size: 18px; font-weight: 700;
  pointer-events: none;
}
.toast {
  position: fixed; left: 50%; bottom: 34px; translate: -50% 0; z-index: 95;
  padding: 9px 16px; border-radius: 11px;
  background: rgba(20, 26, 33, .92); color: #fff; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity .22s, translate .22s;
  max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; translate: -50% -6px; }

.conn-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 75;
  padding: 7px 12px; text-align: center; font-size: 12.5px;
  background: #b4453f; color: #fff;
}

/* ------------------------------- 响应式 ------------------------------- */
@media (max-width: 860px) {
  :root { --sidebar-w: 100%; }
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; height: 100%; }
  .chat {
    position: fixed; inset: 0; z-index: 30;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.22,1,.36,1);
    will-change: transform;
  }
  body.chat-open .chat { transform: translateX(0); }
  body.chat-open { overflow: hidden; }
  .icon-btn.back { display: inline-flex; }
  .chat-head { padding-left: 6px; }
  .msg-list { padding: 0 12px; }
  .msg-body { max-width: 78%; }
  .composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .composer-box { border-radius: 14px; padding: 5px 5px 5px 12px; }
  .side-head { height: 58px; }
  .auth-card { padding: 28px 22px 22px; border-radius: 20px; }
  .emoji-panel { right: 10px; width: 272px; }
  .modal-mask { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%; border-radius: 20px 20px 0 0;
    max-height: 88vh; padding-bottom: env(safe-area-inset-bottom);
    animation: sheetIn .28s cubic-bezier(.22,1,.36,1);
  }
  @keyframes sheetIn { from { transform: translateY(100%); } }
  .modal-head::before {
    content: ""; position: absolute; top: 7px; left: 50%; translate: -50% 0;
    width: 38px; height: 4px; border-radius: 99px; background: var(--line-strong);
  }
  .modal-head { position: relative; padding-top: 20px; }
  .lightbox { padding: 12px; }
  .members-panel { top: 58px; width: 100%; border-left: 0; }
}

@media (min-width: 861px) {
  body.chat-open .chat { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
