:root {
  --bg: #0b0f1a;
  --bg-soft: #111827;
  --panel: #141c2b;
  --panel-2: #1a2333;
  --line: #22304a;
  --text: #e6edf7;
  --muted: #8b9ab1;
  --accent: #3b82f6;
  --accent-2: #22d3ee;
  --ok: #10b981;
  --warn: #f59e0b;
  --mine: linear-gradient(135deg, #2563eb, #1d4ed8);
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(59, 130, 246, 0.18), transparent 60%),
    radial-gradient(700px 400px at 95% 100%, rgba(34, 211, 238, 0.12), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ============ 登录 ============ */
.login {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.brand { text-align: center; margin-bottom: 24px; }

.logo {
  font-size: 40px;
  line-height: 1;
  filter: drop-shadow(0 0 18px rgba(59, 130, 246, 0.5));
}

.brand h1 {
  margin: 12px 0 4px;
  font-size: 24px;
  letter-spacing: 4px;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

label {
  display: block;
  margin: 14px 0 6px;
  font-size: 13px;
  color: var(--muted);
}

input, textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 13px;
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  transition: transform .12s, filter .15s, background .15s;
}

button:active { transform: scale(0.97); }

.primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  font-weight: 600;
  padding: 12px 18px;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.primary:hover { filter: brightness(1.08); }

#btn-join { width: 100%; margin-top: 24px; }

.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 12px;
  font-size: 13px;
}

.ghost:hover { color: var(--text); border-color: var(--accent); }

.icon {
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 9px;
}

.icon:hover { background: var(--panel-2); color: var(--text); }

/* 一键关闭：红一点点，但别太吵 */
.icon.danger { color: #f87171; }
.icon.danger:hover { background: rgba(248, 113, 113, 0.14); color: #fca5a5; }

.hint {
  margin: 18px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  text-align: left;
}

.hint b { color: #cbd5e1; }

/* ============ 会话 ============ */
.app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  background: rgba(17, 24, 39, 0.75);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.room-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

.room-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  font-size: 12px;
  color: #a7f3d0;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

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

/* 消息区 */
.messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 22px 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb {
  background: #2a3a55;
  border-radius: 4px;
}

.sys {
  align-self: center;
  max-width: 80%;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  background: rgba(139, 154, 177, 0.09);
  border-radius: 999px;
  padding: 5px 12px;
}

.msg {
  display: flex;
  gap: 10px;
  max-width: min(680px, 86%);
}

.msg.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #dbeafe;
  background: linear-gradient(135deg, #334155, #1e293b);
  border: 1px solid var(--line);
}

.msg.mine .avatar {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  border-color: #3b82f6;
  color: #fff;
}

.bubble-wrap { min-width: 0; }

.who {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg.mine .who { justify-content: flex-end; }

.bubble {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.65;
}

.msg.mine .bubble {
  background: var(--mine);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.28);
}

.bubble img {
  display: block;
  max-width: 260px;
  border-radius: 10px;
  cursor: zoom-in;
}

.msg-foot {
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.msg.mine .msg-foot { justify-content: flex-end; }

.lock {
  cursor: pointer;
  color: #93c5fd;
  border: 1px dashed rgba(147, 197, 253, 0.4);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 11px;
}

.lock:hover { background: rgba(147, 197, 253, 0.12); }

/* 已读 / 未读回执 */
.msg-status {
  font-size: 11px;
  color: #7d8a9c;
  cursor: help;
  transition: color 0.2s ease;
}

.msg-status.read { color: #5aa9ff; }

.msg-status.failed { color: #e0806f; }

/* 双端删除：悬停出现的删除键 */
.del-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 2px 3px;
  border-radius: 6px;
  color: transparent;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}

/* 手机上不存在 hover，所以删除键常显（颜色压低，不抢视线），点得到才算数 */
.msg .del-btn { opacity: 1; color: rgba(139, 154, 177, 0.5); padding: 4px 5px; }

.msg:hover .del-btn,
.msg:focus-within .del-btn { opacity: 1; color: var(--muted); }

.del-btn:hover { color: #f87171; background: rgba(248, 113, 113, 0.12); }

/* 被删除的消息：留一条灰色占位，内容不再可见 */
.bubble.deleted {
  background: transparent !important;
  border: 1px dashed rgba(139, 154, 177, 0.35) !important;
  color: var(--muted) !important;
  font-size: 12px;
  font-style: italic;
  box-shadow: none !important;
}

.is-deleted .avatar { opacity: 0.45; }

/* ===== 文件消息卡片 ===== */
.bubble:has(.file-card) {
  padding: 10px 12px;
  white-space: normal;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
}

.file-icon {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 18px;
  background: rgba(59, 130, 246, 0.15);
}

.msg.mine .file-icon { background: rgba(255, 255, 255, 0.18); }

.file-meta { flex: 1 1 auto; min-width: 0; }

.file-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  word-break: break-all;
  white-space: normal;
}

.file-size { font-size: 11px; opacity: 0.72; margin-top: 2px; }

.file-btn {
  flex: 0 0 auto;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #93c5fd;
  cursor: pointer;
  white-space: nowrap;
}

.file-btn:hover { background: rgba(59, 130, 246, 0.26); }

.msg.mine .file-btn {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}

.file-btn[disabled] { opacity: 0.6; cursor: not-allowed; }

.uploading .bubble { border-style: dashed; }

/* ===== 语音通话面板 ===== */
.call-panel {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 330px;
  padding: 12px 16px;
  background: rgba(17, 24, 39, 0.96);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  z-index: 40;
}

.call-avatar {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  color: #fff;
}

.call-body { flex: 1 1 auto; min-width: 0; }
.call-name { font-size: 13px; font-weight: 600; }
.call-state { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.call-timer { font-family: "Cascadia Mono", Consolas, monospace; font-size: 13px; color: #93c5fd; }
.call-btns { display: flex; gap: 8px; }

.danger-ghost {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 8px 14px;
  border-radius: 10px;
}

.danger-ghost:hover { background: rgba(239, 68, 68, 0.24); }

.call-panel .primary { padding: 8px 16px; }

.verified { color: #6ee7b7; }

.unverified { color: var(--warn); }

/* 侧栏 */
.sidebar {
  flex: 0 0 250px;
  border-left: 1px solid var(--line);
  background: rgba(20, 28, 43, 0.6);
  padding: 18px 16px;
  overflow-y: auto;
}

.sidebar h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.count {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--text);
}

.members { list-style: none; margin: 0; padding: 0; }

.members li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s;
}

.members li:hover { background: var(--panel-2); }

/* ---------- 最近会话 / 通讯录 ---------- */

.recent { margin-top: 18px; }
.recent.hidden { display: none; }

.recent-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 8px 8px 0;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.recent-chip:active { border-color: var(--accent); }

.contact-tools { display: flex; gap: 8px; margin-bottom: 14px; }

.invite-input {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.contact-room {
  font-size: 12px;
  color: var(--accent);
  margin: 14px 0 6px;
}

.contact {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.contact .c-main { flex: 1 1 auto; min-width: 0; }

.contact .c-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact .c-sub {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact .c-actions { display: flex; gap: 6px; flex: 0 0 auto; }

.mini {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.mini.danger { color: #f87171; border-color: rgba(248, 113, 113, 0.35); }

.empty-note { color: var(--muted); font-size: 12px; line-height: 1.7; }

.members .m-avatar {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  background: linear-gradient(135deg, #334155, #1e293b);
  border: 1px solid var(--line);
}

.members .m-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.members .m-key {
  font-size: 10px;
  color: var(--muted);
}

.members .m-state {
  font-size: 12px;
}

.aside-note {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.75;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}

.aside-note b { color: #cbd5e1; }

/* 输入区 */
.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 18px 16px;
  background: rgba(17, 24, 39, 0.8);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.tools { display: flex; align-items: center; }

#input {
  resize: none;
  max-height: 140px;
  min-height: 44px;
  padding: 11px 14px;
  border-radius: 12px;
}

.send { padding: 11px 22px; height: 44px; }

.typing {
  position: fixed;
  left: 24px;
  bottom: 84px;
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
}

/* ============ 弹窗 ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.7);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
}

.modal-card {
  width: min(560px, 100%);
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 { margin: 0; font-size: 15px; }

.modal-body {
  padding: 16px;
  overflow-y: auto;
  font-size: 13px;
}

.cipher {
  background: #0a1020;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.7;
  color: #7dd3fc;
  word-break: break-all;
  white-space: pre-wrap;
  max-height: 40vh;
  overflow: auto;
}

.safety {
  text-align: center;
  padding: 8px 0 4px;
}

.safety .digits {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 20px;
  letter-spacing: 3px;
  line-height: 1.9;
  color: #93c5fd;
  margin: 10px 0;
}

.note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 18px;
}

.modal-actions .ghost { padding: 10px 20px; }

.primary.danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  box-shadow: 0 8px 20px rgba(185, 28, 28, 0.3);
  padding: 10px 20px;
}

.kv { display: flex; gap: 8px; margin: 6px 0; font-size: 12px; }
.kv .k { color: var(--muted); flex: 0 0 92px; }
.kv .v { color: var(--text); word-break: break-all; }

/* 窄屏 */
@media (max-width: 720px) {
  .sidebar { display: none; }
  .badge { display: none; }
  .messages { padding: 16px 12px; }
}

/* 好友 & 群组面板 */
.hub-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.hub-tab {
  flex: 1;
  padding: 9px 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.18s;
}
.hub-tab.active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
}
.hub-label {
  margin: 16px 0 8px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.hub-pane .contact { margin-bottom: 8px; }

/* ===== Telegram 式交互（日期分隔 / 引用 / 表情 / 菜单 / 置顶） ===== */
.day-sep {
  text-align: center;
  margin: 14px 0 10px;
  font-size: 12px;
  color: var(--muted);
}
.day-sep span, .day-sep {
  letter-spacing: 0.04em;
}

.bubble .forwarded {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.quote {
  border-left: 3px solid var(--accent);
  padding: 4px 8px;
  margin: -2px 0 6px;
  background: rgba(56, 189, 248, 0.08);
  border-radius: 6px;
  cursor: pointer;
  max-height: 64px;
  overflow: hidden;
}
.quote .q-name { font-size: 11px; color: var(--accent); margin-bottom: 2px; }
.quote .q-text { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.reacts.hidden { display: none; }
.react {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 999px;
  font-size: 12px;
  padding: 2px 8px;
  cursor: pointer;
  line-height: 1.6;
}
.react.mine { border-color: var(--accent); background: rgba(56, 189, 248, 0.16); }

.edited { font-size: 11px; color: var(--muted); margin-left: 6px; }

.msg.flash .bubble { box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.55); transition: box-shadow 0.2s; }
.msg.pinned .bubble { box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.45); }

/* 长按菜单 */
.m-menu { display: flex; flex-direction: column; gap: 4px; }
.m-item {
  text-align: left;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.m-item:hover { background: rgba(56, 189, 248, 0.1); }
.m-item.danger { color: #f87171; border-color: rgba(248, 113, 113, 0.35); }
.m-emoji { display: flex; gap: 6px; justify-content: space-between; margin: 4px 0; }
.emoji-btn {
  flex: 1;
  font-size: 20px;
  padding: 6px 0;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}
.emoji-btn.mine { border-color: var(--accent); background: rgba(56, 189, 248, 0.16); }

/* 回复条（输入框上方） */
.composer { flex-wrap: wrap; }
.reply-bar {
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
  border-left: 3px solid var(--accent);
  background: rgba(56, 189, 248, 0.1);
  border-radius: 8px;
}
.reply-bar.hidden { display: none; }
.rb-info { min-width: 0; flex: 1; }
.rb-name { font-size: 11px; color: var(--accent); }
.rb-text {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rb-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}

/* ================= 界面规整（v1.5） ================= */

.topbar {
  height: 60px;
  padding: 0 16px;
  gap: 12px;
}
.room-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
}
.room-meta { font-size: 12px; margin-top: 2px; }
.top-actions { gap: 8px; flex-shrink: 0; }
.top-actions .ghost {
  height: 32px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 12px;
}
.top-actions .icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}
.badge { height: 26px; padding: 0 10px; font-size: 11px; }

.messages { padding: 18px 20px 6px; gap: 10px; }
.messages::-webkit-scrollbar { width: 6px; }
.messages > .msg { align-self: flex-start; }
.msg { max-width: min(620px, 78%); gap: 10px; }
.msg .who { margin-bottom: 3px; font-size: 11px; opacity: 0.85; }
.bubble { padding: 9px 13px; font-size: 14px; border-radius: 13px; }
.msg-foot { gap: 8px; opacity: 0.72; }
.msg-foot .lock { font-size: 10px; padding: 0 5px; }
.msg .del-btn { font-size: 12px; padding: 2px 4px; opacity: 0.5; }
.msg:hover .del-btn { opacity: 1; }
.msg .avatar { border-radius: 11px; }

.sys {
  max-width: min(520px, 92%);
  padding: 5px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  font-size: 12px;
  line-height: 1.5;
}

.day-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 6px;
  font-size: 12px;
  color: var(--muted);
}
.day-sep::before,
.day-sep::after {
  content: '';
  height: 1px;
  flex: 1;
  background: var(--line);
}

.chat-empty {
  margin: auto;
  max-width: 340px;
  padding: 24px 10px;
  text-align: center;
  color: var(--muted);
}
.chat-empty .ce-icon { font-size: 28px; opacity: 0.75; margin-bottom: 10px; }
.chat-empty .ce-title { font-size: 14px; color: var(--text); margin-bottom: 4px; }
.chat-empty .ce-sub { font-size: 12px; line-height: 1.7; }

.sidebar { padding: 16px 16px 20px; background: rgba(255, 255, 255, 0.02); }
.sidebar h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.members { display: flex; flex-direction: column; gap: 6px; }
.aside-note {
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 11px;
  line-height: 1.7;
}

.composer {
  padding: 10px 16px 14px;
  align-items: center;
  gap: 8px;
}
.composer .tools { gap: 4px; }
.composer .icon { width: 34px; height: 34px; border-radius: 9px; }
#input { min-height: 40px; max-height: 120px; padding: 9px 12px; border-radius: 11px; }
.composer .send { height: 40px; padding: 0 18px; border-radius: 11px; }
.reply-bar { margin-bottom: 0; }

@media (max-width: 720px) {
  .messages { padding: 14px 12px 4px; }
  .msg { max-width: 84%; }
  .topbar { padding: 0 12px; height: 56px; }
  .top-actions { gap: 6px; }
  .top-actions .ghost { padding: 0 9px; font-size: 11px; }
  .composer { padding: 8px 10px 10px; }
}

/* 输入区：回复条一行、输入控件一行，避免换行错位 */
.composer {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 8px;
}
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.composer-row #input {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}
.composer-row .tools {
  display: flex;
  gap: 4px;
  padding-bottom: 3px;
}
.composer-row .send { flex: 0 0 auto; }
.reply-bar { flex: 0 0 auto; }

/* 气泡：自己的靠右、引用块限宽 */
.messages > .msg.mine { align-self: flex-end; }
.msg.mine .who { text-align: right; }
.quote { max-width: 100%; }
.quote .q-text { max-width: 360px; }
.msg.mine .bubble { border-bottom-right-radius: 6px; }
.msg:not(.mine) .bubble { border-bottom-left-radius: 6px; }

/* 自己气泡里的引用块：浅底，保证在蓝色气泡上有对比 */
.msg.mine .quote {
  background: rgba(255, 255, 255, 0.16);
  border-left-color: #bfdbfe;
}
.msg.mine .quote .q-name { color: #dbeafe; }
.msg.mine .quote .q-text { color: rgba(255, 255, 255, 0.82); }

/* ================= 首页（微信式） ================= */
.home { height: 100%; display: flex; flex-direction: column; background: var(--bg); }
.home-head {
  height: 64px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
}
.hh-left { display: flex; align-items: center; gap: 10px; }
.hh-logo {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  font-size: 18px;
}
.hh-title { font-size: 17px; font-weight: 600; letter-spacing: 0.06em; }
.hh-sub { font-size: 11px; color: var(--muted); }
.home-add { width: 34px; height: 34px; font-size: 18px; border-radius: 10px; }

.home-body { flex: 1 1 auto; overflow-y: auto; }
.pane { min-height: 100%; }
.chat-list { display: flex; flex-direction: column; }
.chat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid rgba(34, 48, 74, 0.55);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.chat-row:hover { background: rgba(255, 255, 255, 0.04); }
.chat-avatar {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 10px;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, #334155, #1e293b);
}
.chat-main { flex: 1 1 auto; min-width: 0; }
.chat-name { font-size: 15px; font-weight: 600; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-prev { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.chat-time { font-size: 11px; color: var(--muted); }
.chat-unread {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #ef4444; color: #fff; font-size: 11px;
  display: grid; place-items: center;
}
.home-empty { margin: auto; padding: 64px 20px; text-align: center; color: var(--muted); }
.he-icon { font-size: 34px; opacity: 0.7; margin-bottom: 10px; }
.he-title { font-size: 14px; color: var(--text); margin-bottom: 4px; }
.he-sub { font-size: 12px; line-height: 1.7; }

.home-tabs {
  flex: 0 0 auto;
  display: flex;
  padding: 6px 0 8px;
  border-top: 1px solid var(--line);
  background: rgba(17, 24, 39, 0.92);
}
.htab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0;
  border: 0; background: transparent;
  color: var(--muted); font-size: 12px; cursor: pointer;
}
.htab.active { color: #93c5fd; }
.ht-ico { font-size: 20px; line-height: 1; }

#tab-contacts, #tab-me { padding: 14px 16px 24px; }
.me-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}
.me-avatar {
  width: 52px; height: 52px; border-radius: 12px;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}
.me-name { font-size: 16px; font-weight: 600; }
.me-code { font-size: 12px; color: var(--muted); margin-top: 2px; }

.sheet-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; padding: 12px 14px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text); text-align: left; cursor: pointer;
}
.sheet-item:hover { background: rgba(56, 189, 248, 0.1); }
.si-label { font-size: 14px; font-weight: 600; }
.si-sub { font-size: 12px; color: var(--muted); }

/* 首页细节：底部图标去彩、内容区底色 */
.ht-ico { filter: grayscale(1); opacity: 0.75; }
.htab.active .ht-ico { filter: none; opacity: 1; }
.home-body { background: linear-gradient(180deg, rgba(20, 28, 43, 0.35), rgba(11, 15, 26, 0)); }

/* 顶栏返回按钮 */
.topbar .back {
  width: 34px;
  height: 34px;
  font-size: 16px;
  border-radius: 9px;
  margin-right: 2px;
}

/* 私聊：隐藏右侧成员栏 */
body.dm-mode .body { grid-template-columns: minmax(0, 1fr); }
body.dm-mode .sidebar { display: none; }

/* 昵称行按钮不被挤压 */
.contact-tools { align-items: center; }
.contact-tools > button,
.contact-tools > .mini-btn { flex: 0 0 auto; white-space: nowrap; padding: 0 16px; }
.contact-tools > input { flex: 1 1 auto; min-width: 0; }
