/* ==========================================================
   聚聊 JuChat · 样式
   ========================================================== */
:root {
  --brand: #0aa2f0;
  --brand-2: #2ec4ff;
  --brand-deep: #0a84ff;
  --bg: #eef2f8;
  --panel: #ffffff;
  --panel-soft: #f7f9fc;
  --ink: #16212d;
  --ink-2: #5c6d80;
  --ink-3: #93a3b5;
  --line: #e7edf5;
  --danger: #f04452;
  --ok: #22c55e;
  --shadow-sm: 0 1px 2px rgba(18, 42, 74, .06), 0 6px 18px rgba(18, 42, 74, .05);
  --shadow-md: 0 14px 34px rgba(20, 50, 90, .10);
  --shadow-lg: 0 30px 70px rgba(10, 30, 60, .28);
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Source Han Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--brand-deep); }
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
svg { display: block; }

.icon-btn {
  width: 38px; height: 38px; border: 0; border-radius: 11px;
  background: transparent; color: var(--ink-2);
  display: grid; place-items: center; transition: background .16s, color .16s;
}

.avatar {
  display: grid; place-items: center;
  border-radius: 50%; flex: none;
  color: #fff; font-weight: 700;
  letter-spacing: .5px; user-select: none;
  box-shadow: inset 0 -8px 14px rgba(0, 0, 0, .14), 0 3px 8px rgba(20, 50, 90, .12);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}

input[type="checkbox"] {
  width: 18px; height: 18px; flex: none;
  accent-color: var(--brand-deep); cursor: pointer;
}

.modal-sub code {
  display: inline-block; margin-top: 6px; padding: 6px 8px;
  border-radius: 8px; background: #f3f7fc; color: var(--ink-2);
  font-size: 11.5px; word-break: break-all;
}

a.bubble { text-decoration: none; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: #eef5fd; color: var(--brand-deep); }

.btn-primary {
  border: 0; border-radius: 12px; padding: 11px 18px;
  background: linear-gradient(135deg, var(--brand-2), var(--brand-deep));
  color: #fff; font-weight: 600; letter-spacing: .3px;
  box-shadow: 0 10px 22px rgba(10, 132, 255, .28);
  transition: transform .12s, box-shadow .18s, filter .18s;
}
.btn-primary:hover { filter: brightness(1.04); box-shadow: 0 12px 26px rgba(10, 132, 255, .34); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .55; box-shadow: none; cursor: default; }
.btn-ghost {
  border: 1.5px solid var(--line); background: #fff; border-radius: 11px;
  padding: 9px 15px; color: var(--ink-2); font-weight: 600;
}
.btn-ghost:hover { border-color: #cfe2f5; color: var(--brand-deep); background: #f7fbff; }
.btn-danger { border: 0; background: #fff0f1; color: var(--danger); border-radius: 11px; padding: 9px 15px; font-weight: 600; }
.btn-danger:hover { background: #ffe3e6; }

/* ============================ 登录页 ============================ */
.auth {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 28px;
  overflow: auto;
  background:
    radial-gradient(900px 520px at 8% -10%, rgba(28, 108, 255, .38), transparent 62%),
    radial-gradient(820px 520px at 105% 110%, rgba(18, 183, 245, .30), transparent 62%),
    linear-gradient(150deg, #070d1b, #0b1830 55%, #060f22);
}
.auth-shell {
  width: min(1040px, 100%);
  display: grid; grid-template-columns: 1.06fr .94fr;
  border-radius: 30px; overflow: hidden;
  background: #0b1830;
  border: 1px solid rgba(255, 255, 255, .09);
  box-shadow: 0 44px 110px rgba(0, 8, 24, .6);
}
.auth-hero {
  position: relative; overflow: hidden;
  padding: 50px 46px;
  color: #e9f4ff;
  display: flex; flex-direction: column; gap: 30px;
  background:
    radial-gradient(620px 320px at 84% -4%, rgba(46, 196, 255, .22), transparent 62%),
    linear-gradient(158deg, #0e2344, #0a1a31 58%, #091425);
}
.hero-glow {
  position: absolute; width: 460px; height: 460px; right: -170px; top: -190px;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(46, 196, 255, .5), transparent 66%);
  filter: blur(14px);
}
.hero-brand { display: flex; align-items: center; gap: 16px; position: relative; }
.hero-logo {
  width: 58px; height: 58px; flex: none;
  display: grid; place-items: center;
  border-radius: 19px; font-size: 27px; font-weight: 800; color: #fff;
  background: linear-gradient(140deg, #3fd0ff, #0a7bff);
  box-shadow: 0 16px 30px rgba(10, 132, 255, .45), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.hero-brand h1 { font-size: 25px; letter-spacing: 1px; display: flex; align-items: baseline; gap: 9px; }
.hero-brand h1 em { font-style: normal; font-size: 13px; letter-spacing: 2.4px; color: #7fb6e8; font-weight: 600; text-transform: uppercase; }
.hero-brand p { font-size: 13px; color: #8fb2d4; margin-top: 6px; }
.hero-points { display: flex; flex-direction: column; gap: 14px; font-size: 14px; color: #b9d3ea; position: relative; }
.hero-points li { display: flex; align-items: flex-start; gap: 10px; line-height: 1.5; }
.hero-points .dot {
  width: 7px; height: 7px; margin-top: 7px; flex: none; border-radius: 50%;
  background: linear-gradient(135deg, #4fd7ff, #0a84ff);
  box-shadow: 0 0 0 4px rgba(46, 196, 255, .14);
}
.hero-preview {
  margin-top: auto; display: flex; flex-direction: column; gap: 12px;
  padding: 20px; border-radius: 20px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .09);
  backdrop-filter: blur(6px);
}
.bubble-row { display: flex; align-items: center; gap: 10px; }
.bubble-row.right { justify-content: flex-end; }
.mini-avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff;
}
.mini-avatar.a1 { background: linear-gradient(135deg, #ffb36b, #ff7a59); }
.mini-avatar.a2 { background: linear-gradient(135deg, #7f8cff, #4c5cff); }
.mini-avatar.a3 { background: linear-gradient(135deg, #3fd0ff, #0a84ff); }
.mini-bubble {
  font-size: 13px; line-height: 1.5; padding: 9px 13px; border-radius: 13px;
  background: rgba(255, 255, 255, .10); color: #dbeaff; max-width: 76%;
}
.mini-bubble.me { background: linear-gradient(135deg, #2ec4ff, #0a84ff); color: #fff; }

.auth-card {
  background: #fff; padding: 46px 42px;
  display: flex; flex-direction: column; justify-content: center;
}
.auth-tabs {
  display: flex; gap: 5px; padding: 5px; border-radius: 14px;
  background: #eef3f9; margin-bottom: 28px;
}
.auth-tab {
  flex: 1; border: 0; background: transparent; padding: 10px;
  border-radius: 10px; color: #64778c; font-weight: 600; font-size: 14px;
  transition: .18s;
}
.auth-tab.active { background: #fff; color: var(--brand-deep); box-shadow: 0 3px 10px rgba(15, 60, 120, .1); }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.field input {
  width: 100%; padding: 13px 14px; font-size: 15px;
  border: 1.5px solid #e3eaf3; border-radius: 12px;
  background: #f8fafd; outline: none;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.field input:focus { border-color: #63c6ff; background: #fff; box-shadow: 0 0 0 4px rgba(46, 196, 255, .14); }
.field input::placeholder { color: #a9b7c7; }
.auth-error { min-height: 21px; margin: 0 0 10px; font-size: 13px; color: var(--danger); }
.auth-submit { width: 100%; padding: 13px; font-size: 15px; }
.auth-tip { margin-top: 20px; font-size: 12px; line-height: 1.75; color: var(--ink-3); }

/* ============================ 主框架 ============================ */
.app {
  display: grid;
  grid-template-columns: 76px 322px minmax(0, 1fr);
  height: 100dvh; overflow: hidden;
  background: var(--bg);
}

/* 左侧导航 */
.rail {
  display: flex; flex-direction: column; align-items: center;
  padding: 18px 0 16px; gap: 14px;
  background: linear-gradient(180deg, #0d1a2c, #12233c 60%, #0d1a2c);
  border-right: 1px solid rgba(255, 255, 255, .04);
}
.rail-avatar {
  width: 46px; height: 46px; border: 0; border-radius: 16px;
  background-color: #22344f;
  color: #fff; font-weight: 800; font-size: 18px;
  overflow: hidden;
  box-shadow: 0 10px 22px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .16s;
}
.rail-avatar:hover { transform: scale(1.05); }
.rail-nav { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.rail-btn {
  position: relative; width: 46px; height: 46px;
  border: 0; border-radius: 14px; background: transparent;
  color: #8ba3c2; display: grid; place-items: center;
  transition: background .16s, color .16s, transform .16s;
}
.rail-btn svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rail-btn:hover { background: rgba(255, 255, 255, .07); color: #dbe9ff; }
.rail-btn.active {
  background: linear-gradient(135deg, #2ec4ff, #0a84ff); color: #fff;
  box-shadow: 0 10px 22px rgba(10, 132, 255, .42);
}
.rail-spacer { flex: 1; }
.rail-badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: #ff4d61; color: #fff;
  font-size: 11px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid #0d1a2c;
}

/* 会话列表栏 */
.sidebar {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--panel); border-right: 1px solid var(--line);
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px 12px 20px;
}
.me-block { display: flex; flex-direction: column; gap: 5px; min-width: 0; cursor: pointer; }
.me-block:hover .me-name { color: var(--brand-deep); }
.me-name { font-size: 17px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-state { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #c3cedb; flex: none; }
.status-dot.online { background: var(--ok); box-shadow: 0 0 0 3px rgba(34, 197, 94, .16); }
.side-actions { display: flex; gap: 2px; }

.search-wrap { position: relative; margin: 4px 14px 10px; }
.search-wrap input {
  width: 100%; padding: 10px 12px 10px 36px;
  border: 1.5px solid transparent; border-radius: 11px;
  background: #f2f6fb; font-size: 13px; outline: none;
  transition: border-color .16s, background .16s;
}
.search-wrap input:focus { background: #fff; border-color: #bfe4ff; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; fill: none; stroke: #9db0c4; stroke-width: 1.9; stroke-linecap: round;
}

.side-body { flex: 1; overflow-y: auto; padding-bottom: 12px; }

.conv-list { padding: 0 8px; }
.conv {
  position: relative;
  display: grid; grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center; gap: 11px;
  padding: 10px 11px; border-radius: 13px;
  cursor: pointer; transition: background .14s;
  margin-bottom: 2px;
}
.conv:hover { background: #f5f9ff; }
.conv.active { background: linear-gradient(135deg, #e9f6ff, #e2f0ff); }
.conv.active::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 26px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #2ec4ff, #0a84ff);
}
.conv-avatar { position: relative; }
.conv-avatar .avatar { width: 46px; height: 46px; font-size: 17px; }
.conv-avatar .status-dot {
  position: absolute; right: -1px; bottom: -1px;
  border: 2.5px solid #fff;
}
.conv-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.conv-title { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-preview {
  font-size: 12.5px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.conv-time { font-size: 11px; color: #a7b5c5; white-space: nowrap; }
.unread {
  min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 10px; background: linear-gradient(135deg, #ff6b7a, #f04452);
  color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 3px 9px rgba(240, 68, 82, .32);
}

.empty-tip { text-align: center; padding: 60px 24px; color: var(--ink-3); }
.empty-tip .empty-art { font-size: 38px; margin-bottom: 12px; opacity: .8; }
.empty-tip p { font-size: 14px; color: var(--ink-2); font-weight: 600; margin-bottom: 6px; }
.empty-tip small { font-size: 12px; line-height: 1.6; }

/* 移动端视图切换 */
.mobile-tabs { display: none; }
.tab-badge {
  display: inline-grid; place-items: center;
  min-width: 16px; height: 16px; padding: 0 4px; margin-left: 4px;
  border-radius: 8px; background: #f04452; color: #fff;
  font-size: 10px; font-style: normal; font-weight: 700;
  vertical-align: 1px;
}

/* 联系人面板 */
.contact-group { padding: 6px 10px 0; }
.contact-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 10px 6px; font-size: 12px; font-weight: 700;
  color: var(--ink-3); letter-spacing: .4px;
}
.contact-head .count { font-weight: 600; color: #b7c3d1; }
.contact-head .badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: #f04452; color: #fff;
  font-size: 11px; display: grid; place-items: center;
}
.contact-item {
  display: grid; grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 12px; cursor: pointer;
  transition: background .14s;
}
.contact-item:hover { background: #f5f9ff; }
.contact-item .avatar { width: 38px; height: 38px; font-size: 15px; }
.contact-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.contact-name { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-sub { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-actions { display: flex; gap: 6px; }
.mini-btn {
  border: 0; border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 600;
  background: #eaf5ff; color: var(--brand-deep);
}
.mini-btn:hover { background: #dcf0ff; }
.mini-btn.muted { background: #f2f5f9; color: var(--ink-2); }
.mini-btn.danger { background: #fff0f1; color: var(--danger); }
.mini-btn:disabled { opacity: .6; cursor: default; }
.contact-note { padding: 6px 20px 14px; font-size: 12px; color: var(--ink-3); }

/* ============================ 聊天区 ============================ */
.chat {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background:
    radial-gradient(900px 440px at 0% 0%, rgba(46, 196, 255, .075), transparent 60%),
    radial-gradient(820px 520px at 100% 100%, rgba(122, 92, 255, .06), transparent 58%),
    var(--bg);
}
.chat-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  color: var(--ink-3); text-align: center; padding: 30px;
}
.chat-empty-art { width: 86px; height: 86px; color: #c3d6ea; margin-bottom: 8px; }
.chat-empty-art svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chat-empty h2 { font-size: 19px; color: var(--ink-2); font-weight: 700; letter-spacing: .5px; }
.chat-empty p { font-size: 13px; color: var(--ink-3); }

.chat-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(226, 235, 245, .9);
}
.chat-avatar .avatar { width: 44px; height: 44px; font-size: 17px; }
.chat-title { flex: 1; min-width: 0; }
.chat-title h2 { font-size: 16.5px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title p { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.chat-actions { display: flex; gap: 2px; }
.back-btn { display: none; }

.messages {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 22px clamp(16px, 3vw, 42px) 10px;
  display: flex; flex-direction: column;
}
.messages::-webkit-scrollbar, .side-body::-webkit-scrollbar, .modal-card::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb, .side-body::-webkit-scrollbar-thumb, .modal-card::-webkit-scrollbar-thumb {
  background: rgba(120, 150, 180, .28); border-radius: 8px;
}
.messages::-webkit-scrollbar-thumb:hover { background: rgba(120, 150, 180, .45); }

.day {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0 12px; font-size: 11.5px; color: #9fadbd;
}
.day::before, .day::after {
  content: ""; height: 1px; flex: 1;
  background: linear-gradient(90deg, transparent, #dde6f0, transparent);
}

.msg {
  display: flex; align-items: flex-start; gap: 10px;
  max-width: min(660px, 84%); margin: 5px 0;
  animation: msg-in .18s ease;
}
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg .avatar { width: 36px; height: 36px; font-size: 14px; }
.msg-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.msg.mine .msg-body { align-items: flex-end; }
.sender { font-size: 11.5px; color: #8ea3b8; padding: 0 3px; }
.bubble {
  position: relative;
  padding: 10px 14px; border-radius: 15px; border-top-left-radius: 5px;
  background: #fff; color: var(--ink);
  font-size: 14.5px; line-height: 1.62;
  white-space: pre-wrap; word-break: break-word;
  box-shadow: var(--shadow-sm);
}
.msg.mine .bubble {
  border-radius: 15px; border-top-right-radius: 5px; border-top-left-radius: 15px;
  background: linear-gradient(135deg, #34c6ff, #0a84ff);
  color: #fff;
  box-shadow: 0 6px 18px rgba(10, 132, 255, .26);
}
.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.msg.mine .bubble a { color: #eaf7ff; }
.bubble.image { padding: 4px; background: #fff; box-shadow: var(--shadow-sm); }
.msg.mine .bubble.image { background: #fff; }
.msg-image {
  display: block; max-width: 260px; max-height: 220px;
  width: auto; border-radius: 12px; cursor: zoom-in;
}
.bubble.failed { background: #fff0f1; color: var(--danger); box-shadow: none; border: 1px dashed #ffc9cf; }

.sys {
  align-self: center; max-width: 80%;
  margin: 9px 0; padding: 5px 13px;
  font-size: 11.5px; color: #7d8fa3; text-align: center;
  background: rgba(255, 255, 255, .72);
  border: 1px solid #e6edf6; border-radius: 999px;
}
.sys.shake-note { color: #b26a00; background: #fff8e8; border-color: #ffe6bb; }

.typing-line {
  height: 22px; padding: 0 34px; font-size: 12px; color: var(--ink-3);
  opacity: 0; transition: opacity .2s; overflow: hidden;
}
.typing-line.show { opacity: 1; }

/* 输入区 */
.composer {
  position: relative; margin: 0 16px 16px;
  background: #fff; border-radius: 20px;
  border: 1px solid rgba(226, 235, 245, .95);
  box-shadow: var(--shadow-md);
  padding: 6px 12px 10px;
}
.composer-tools { display: flex; align-items: center; gap: 2px; }
.tool-btn {
  width: 34px; height: 34px; border: 0; border-radius: 10px;
  background: transparent; color: #6c8098; font-size: 17px;
  display: grid; place-items: center; transition: background .14s;
}
.tool-btn:hover { background: #f0f6fd; }
.tool-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool-spacer { flex: 1; }
.hint { font-size: 11px; color: #adbbca; }
#input {
  width: 100%; border: 0; outline: none; resize: none;
  background: transparent; padding: 6px 6px 4px;
  font-size: 15px; line-height: 1.65; max-height: 160px;
}
#input::placeholder { color: #a9b7c7; }
.composer-bottom { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.char-count { font-size: 11px; color: #b3c0ce; }
.send-btn { padding: 8px 22px; border-radius: 11px; font-size: 13.5px; }

.emoji-panel {
  position: absolute; left: 10px; bottom: calc(100% + 10px);
  width: 316px; max-height: 232px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  padding: 10px; background: #fff; border-radius: 16px;
  border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  z-index: 20;
}
.emoji-btn {
  width: 100%; aspect-ratio: 1; border: 0; border-radius: 9px;
  background: transparent; font-size: 19px; line-height: 1;
  display: grid; place-items: center;
}
.emoji-btn:hover { background: #f1f7ff; }

/* ============================ 弹窗 ============================ */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 20px;
  background: rgba(10, 22, 38, .46);
  backdrop-filter: blur(4px);
  animation: fade-in .16s ease;
}
.modal-card {
  width: min(480px, 100%); max-height: 84vh; overflow-y: auto;
  background: #fff; border-radius: 22px; padding: 22px 24px;
  box-shadow: var(--shadow-lg);
  animation: pop-in .2s cubic-bezier(.2, .9, .3, 1.2);
}
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.modal-head h3 { flex: 1; font-size: 17px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px; border: 0; border-radius: 9px;
  background: #f3f6fa; color: var(--ink-2); font-size: 18px; line-height: 1;
}
.modal-close:hover { background: #eaeff7; }
.modal-body { display: flex; flex-direction: column; gap: 14px; }
.modal-sub { font-size: 12.5px; color: var(--ink-3); line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.user-row {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 4px; border-bottom: 1px solid #f2f6fb;
}
.user-row:last-child { border-bottom: 0; }
.user-row .avatar { width: 40px; height: 40px; font-size: 15px; }
.user-row .grow { flex: 1; min-width: 0; }
.user-row .name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.user-row .sub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .tag {
  font-size: 10.5px; padding: 1px 6px; border-radius: 6px;
  background: #eef5ff; color: #3d8fd6; font-weight: 600;
}
.searching { padding: 18px 4px; font-size: 13px; color: var(--ink-3); text-align: center; }

.member-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; }
.member-row .avatar { width: 38px; height: 38px; font-size: 14px; }
.member-row .grow { flex: 1; min-width: 0; }
.member-row .name { font-size: 13.5px; font-weight: 600; }
.member-row .sub { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.owner-tag { font-size: 10px; background: #fff4dd; color: #b26a00; padding: 2px 6px; border-radius: 6px; margin-left: 6px; }

.profile-hero { display: flex; align-items: center; gap: 14px; padding-bottom: 6px; }
.profile-hero .avatar { width: 58px; height: 58px; font-size: 22px; }
.profile-hero h4 { font-size: 17px; margin-bottom: 4px; }
.profile-hero p { font-size: 12px; color: var(--ink-3); }

.list-section { display: flex; flex-direction: column; }
.list-title { font-size: 12px; font-weight: 700; color: var(--ink-3); margin: 4px 0 2px; }

/* ============================ 提示 ============================ */
.toasts {
  position: fixed; top: 18px; right: 18px; z-index: 80;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  max-width: 330px; padding: 10px 15px; border-radius: 12px;
  background: #101d2f; color: #eaf3ff; font-size: 13px;
  box-shadow: 0 16px 36px rgba(4, 14, 28, .35);
  animation: toast-in .22s ease;
}
.toast.error { background: #3b1218; color: #ffd7db; }
.toast.success { background: #0d2b1d; color: #c9f6dd; }

/* ============================ 动画 ============================ */
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }

.shake-hit { animation: window-shake .55s cubic-bezier(.36, .07, .19, .97); }
@keyframes window-shake {
  10%, 90% { transform: translate(-1px, 0); }
  20%, 80% { transform: translate(3px, -1px); }
  30%, 50%, 70% { transform: translate(-5px, 1px); }
  40%, 60% { transform: translate(5px, -1px); }
}

/* ============================ 会员标识 ============================ */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  height: 18px; padding: 0 6px; border-radius: 6px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .3px;
  color: #fff; vertical-align: 1px; white-space: nowrap;
  background: linear-gradient(135deg, #8fb8ff, #4f7cf7);
  box-shadow: 0 2px 6px rgba(60, 90, 200, .22);
}
.badge.lv-1 { background: linear-gradient(135deg, #a9c3e8, #7c9bc4); }
.badge.lv-2 { background: linear-gradient(135deg, #8fd3ff, #4aa8ef); }
.badge.lv-3 { background: linear-gradient(135deg, #7ee0c3, #2bb98c); }
.badge.lv-4 { background: linear-gradient(135deg, #b8e986, #68b32e); }
.badge.lv-5 { background: linear-gradient(135deg, #ffd76e, #f5a623); color: #5a3900; }
.badge.lv-6 { background: linear-gradient(135deg, #ffb36b, #f07c2b); }
.badge.lv-7 { background: linear-gradient(135deg, #ff9ec4, #ef5f97); }
.badge.lv-8 { background: linear-gradient(135deg, #c9a8ff, #8a5cf6); }
.badge.lv-9 { background: linear-gradient(135deg, #8ff0ff, #37a7d8); }
.badge.lv-10 {
  background: linear-gradient(90deg, #ffd76e, #ff7ab8, #7c4dff, #2ec4ff, #ffd76e);
  background-size: 300% 100%;
  animation: badge-flow 3.2s linear infinite;
  color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.badge.vip {
  background: linear-gradient(90deg, #ffe08a, #ffb43f, #ff6b9d, #ffe08a);
  background-size: 300% 100%;
  animation: badge-flow 2.8s linear infinite;
  color: #5a2d00; text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
  box-shadow: 0 2px 10px rgba(255, 150, 40, .45);
}
.badge.svip {
  background: linear-gradient(90deg, #b388ff, #7c4dff, #ff6bd6, #b388ff);
  background-size: 300% 100%;
  animation: badge-flow 2.2s linear infinite;
  color: #fff;
  box-shadow: 0 0 14px rgba(150, 90, 255, .65);
}
.badge .crown { font-size: 11px; line-height: 1; }

@keyframes badge-flow { to { background-position: 300% 0; } }

.avatar { position: relative; }
.avatar.vip {
  box-shadow: inset 0 -8px 14px rgba(0, 0, 0, .14),
              0 0 0 2px #ffd76e, 0 0 14px rgba(255, 190, 70, .75);
  animation: vip-glow 2.6s ease-in-out infinite;
}
.avatar.svip {
  box-shadow: inset 0 -8px 14px rgba(0, 0, 0, .14),
              0 0 0 2px #b388ff, 0 0 18px rgba(150, 90, 255, .8);
  animation: vip-glow 2.2s ease-in-out infinite;
}
.avatar.vip::before, .avatar.svip::before {
  content: "👑"; position: absolute; top: -9px; right: -7px;
  font-size: 12px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .25));
}
@keyframes vip-glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}

/* ============================ 公告 / 文件 / 语音 ============================ */
.notice-bar {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 18px 0; padding: 9px 12px;
  border-radius: 12px; border: 1px solid #ffe2a8;
  background: linear-gradient(90deg, #fff8e6, #fffdf8);
  color: #8a5b00; font-size: 12.5px;
}
.notice-icon { font-size: 14px; }
.notice-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice-close { border: 0; background: transparent; color: #c29236; font-size: 17px; line-height: 1; padding: 0 2px; }

.file-bubble { padding: 6px; background: #fff !important; box-shadow: var(--shadow-sm); white-space: normal; }
.file-card { display: flex; align-items: center; gap: 10px; min-width: 210px; max-width: 300px; }
.file-icon {
  width: 38px; height: 38px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #eaf2ff, #dce9ff); color: #3c7bf6;
  font-size: 10px; font-weight: 800; letter-spacing: .3px;
}
.file-meta { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.file-dl {
  width: 32px; height: 32px; flex: none; border-radius: 9px;
  display: grid; place-items: center; color: #3c7bf6; background: #f0f6ff;
  text-decoration: none;
}
.file-dl svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.voice-bubble {
  display: flex; align-items: center; gap: 9px;
  min-width: 148px; max-width: 230px; padding: 7px 10px;
  border-radius: 14px; background: #fff; box-shadow: var(--shadow-sm);
  cursor: pointer; user-select: none;
}
.msg.mine .voice-bubble { background: linear-gradient(135deg, #34c6ff, #0a84ff); color: #fff; }
.voice-play {
  width: 28px; height: 28px; flex: none; border-radius: 50%;
  display: grid; place-items: center; border: 0;
  background: #eaf3ff; color: #0a84ff;
}
.msg.mine .voice-play { background: rgba(255, 255, 255, .22); color: #fff; }
.voice-play svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.voice-bars { display: flex; align-items: center; gap: 2px; height: 20px; flex: 1; }
.voice-bars i { width: 3px; border-radius: 2px; background: currentColor; opacity: .45; }
.voice-bubble.playing .voice-bars i { animation: voice-wave .7s ease-in-out infinite alternate; opacity: .9; }
@keyframes voice-wave { from { transform: scaleY(.5); } to { transform: scaleY(1.25); } }
.voice-dur { font-size: 11px; opacity: .65; flex: none; }

.recording {
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 6px; padding: 8px 10px;
  border-radius: 12px; border: 1px solid #ffd6d6; background: #fff4f4;
  color: #c03636; font-size: 13px;
}
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: #f04452; animation: rec-pulse 1s infinite; flex: none; }
.rec-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.rec-hint { color: #d47777; font-size: 12px; }
.rec-spacer { flex: 1; }
@keyframes rec-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.85); } }

.upload-bar {
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 6px; padding: 7px 10px;
  border-radius: 10px; background: #f4f9ff; color: var(--ink-2); font-size: 12px;
}
.upload-name { max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-track { flex: 1; height: 6px; border-radius: 4px; background: #dfeaf7; overflow: hidden; }
.upload-track i { display: block; height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, #2ec4ff, #0a84ff); transition: width .15s; }
.upload-pct { width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

.msg { position: relative; }
.recall-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  right: -46px; border: 0; border-radius: 8px;
  background: #f1f5fb; color: var(--ink-3);
  font-size: 11px; padding: 4px 7px;
  opacity: 0; transition: opacity .15s; cursor: pointer;
}
.msg.mine .recall-btn { right: auto; left: -46px; }
.msg:hover .recall-btn { opacity: 1; }
.recall-btn:hover { background: #e3ecf8; color: var(--ink-2); }
.sys.recall { color: #9aa8b8; background: #f4f7fb; border-color: #e9eef5; }

/* ============================ 个人资料增强 ============================ */
.exp-row { display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--ink-3); }
.exp-bar { flex: 1; height: 8px; border-radius: 6px; background: #edf2f9; overflow: hidden; }
.exp-bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #2ec4ff, #7c4dff); transition: width .4s; }
.profile-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-chip {
  padding: 4px 9px; border-radius: 8px; background: #f3f7fd;
  font-size: 11.5px; color: var(--ink-2);
}
.stat-chip b { color: var(--ink); }

/* ============================ 响应式 ============================ */
@media (max-width: 1080px) {
  .app { grid-template-columns: 68px 300px minmax(0, 1fr); }
  .msg { max-width: 90%; }
}
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { padding: 30px 30px 22px; gap: 16px; }
  .hero-points, .hero-preview { display: none; }
  .auth-card { padding: 30px 26px 34px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .sidebar { display: flex; }
  .chat { display: none; }
  .app.chat-open .sidebar { display: none; }
  .app.chat-open .chat { display: flex; }
  .back-btn { display: grid; }
  .mobile-tabs {
    display: flex; gap: 4px; margin: 0 14px 8px;
    padding: 4px; border-radius: 11px; background: #f0f5fb;
  }
  .mobile-tab {
    flex: 1; border: 0; background: transparent; padding: 8px;
    border-radius: 8px; font-size: 13px; font-weight: 600; color: #64778c;
  }
  .mobile-tab.active {
    background: #fff; color: var(--brand-deep);
    box-shadow: 0 2px 8px rgba(15, 60, 120, .10);
  }
  .chat-head { padding: 10px 12px; gap: 8px; }
  .messages { padding: 16px 12px 8px; }
  .composer { margin: 0 10px 10px; }
  .msg { max-width: 92%; }
  .hint { display: none; }
  .toasts { left: 12px; right: 12px; align-items: flex-end; }
}
@media (max-width: 520px) {
  .auth { padding: 12px; }
  .auth-shell { border-radius: 22px; }
  .auth-card { padding: 26px 20px 30px; }
  .msg-image { max-width: 210px; }
  .emoji-panel { width: min(316px, calc(100vw - 44px)); }
}

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