/* ═══════════════════════════════════════
   Kyro 商业级设计系统 · 黑白灰主题
   ═══════════════════════════════════════ */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f0f0f2;
  --border: #e5e5e8;
  --border-2: #d4d4d8;
  --text: #17171a;
  --text-2: #52525b;
  --text-3: #a1a1aa;
  --accent: #17171a;
  --accent-hover: #000000;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --online: #22c55e;
  --offline: #a1a1aa;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

.hidden { display: none !important; }

/* ───────── 滚动条 ───────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 4px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b8b8bd; background-clip: content-box; }

/* ═════════════ 登录页 ═════════════ */
#login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(23,23,26,.04) 0%, transparent 55%),
    radial-gradient(ellipse at 70% 80%, rgba(23,23,26,.04) 0%, transparent 55%),
    var(--bg);
}

.login-box {
  width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px 40px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -1px;
}

.login-box h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text);
  margin-bottom: 6px;
}

.login-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 36px;
  letter-spacing: .5px;
}

.login-box input {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.login-box input::placeholder { color: var(--text-3); }

.login-box input:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(23,23,26,.08);
  background: var(--surface);
}

.login-box button {
  width: 100%;
  height: 44px;
  margin-top: 16px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .05s;
}

.login-box button:hover { background: var(--accent-hover); }
.login-box button:active { transform: scale(.98); }

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 14px;
}

/* ═════════════ 聊天布局 ═════════════ */
.chat-layout {
  display: flex;
  height: 100vh;
}

/* ───────── 侧边栏 ───────── */
.sidebar {
  width: 264px;
  min-width: 264px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

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

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .3px;
}

#status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  transition: background .2s;
}

.status-online { background: var(--online); box-shadow: 0 0 0 3px rgba(34,197,94,.15); }
.status-offline { background: var(--offline); }

.sidebar-sec {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-3);
  padding: 0 8px 10px;
}

.count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface-3);
  border-radius: 10px;
  padding: 1px 8px;
  letter-spacing: 0;
}

#user-list { list-style: none; }

.user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-2);
  transition: background .15s;
}

.user-item:hover { background: var(--surface-3); }

.user-item.me { color: var(--text); font-weight: 500; }

.user-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-item.me .user-avatar {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.user-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-tag {
  font-size: 10px;
  color: var(--text-3);
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: 4px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lock {
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.sidebar-btn {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}

.sidebar-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(220,38,38,.04);
}

/* ───────── 主区域 ───────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
}

.chat-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.chat-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-left: 12px;
  letter-spacing: .3px;
}

/* ───────── 消息区 ───────── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface-2);
}

.msg-system {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  padding: 8px 0;
  user-select: none;
}

.msg {
  max-width: 68%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  box-shadow: var(--shadow);
}

.msg-other {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.msg-self {
  background: var(--accent);
  color: var(--accent-text);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11px;
}

.msg-author {
  font-weight: 600;
  color: var(--text-2);
}

.msg-self .msg-author { color: rgba(255,255,255,.7); }
.msg-self .msg-time { color: rgba(255,255,255,.5); }

.msg-time { color: var(--text-3); }

/* 私聊徽标 */
.dm-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .5px;
  color: #fff;
  background: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.msg-self .dm-badge {
  background: rgba(255,255,255,.25);
  color: #fff;
}

.msg-content { white-space: pre-wrap; }

/* ───────── 输入区 ───────── */
.input-area {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: flex-end;
  position: relative;
}

.input-area textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 11px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  line-height: 1.5;
}

.input-area textarea::placeholder { color: var(--text-3); }

.input-area textarea:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(23,23,26,.08);
  background: var(--surface);
}

.input-area button {
  height: 44px;
  padding: 0 26px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .05s;
}

.input-area button:hover { background: var(--accent-hover); }
.input-area button:active { transform: scale(.97); }
.input-area button:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }

/* ───────── 移动端侧边栏（抽屉）基础样式 ───────── */
.menu-btn { display: none; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 299;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}

.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* ───────── 响应式：手机端单栏 + 侧边栏抽屉 ───────── */
@media (max-width: 768px) {
  /* 顶栏：汉堡 + 标题 + 搜索 */
  .menu-btn { display: flex; }
  .chat-header { padding: 12px 14px; gap: 6px; }
  .chat-header > div { flex: 1; text-align: center; }
  .chat-sub { display: none; }

  /* 侧边栏改为抽屉，默认滑出屏幕 */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open { transform: translateX(0); }

  /* 主区域占满全屏 */
  .chat-layout { height: 100dvh; }

  /* 消息区更紧凑 */
  .messages { padding: 14px 12px; gap: 8px; }
  .msg { max-width: 85%; }

  /* 触屏无 hover：隐藏工具栏，点击消息气泡弹出操作面板 */
  .msg-toolbar { display: none; }

  /* 消息菜单 / 表情回应面板：底部弹出 action sheet */
  .msg-menu, .emoji-panel {
    position: fixed;
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    width: auto;
    min-width: 0;
    border-radius: 16px;
    overflow: hidden;
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .msg-menu-item { padding: 14px 16px; font-size: 15px; }
  .emoji-panel { justify-content: center; padding: 12px; }
  .emoji-btn { width: 44px; height: 44px; font-size: 24px; }

  /* 输入区紧凑 + iOS 底部安全区 */
  .input-area { padding: 10px 10px max(10px, env(safe-area-inset-bottom)); gap: 8px; }
  .input-area button { padding: 0 18px; }
  .input-icon-btn { width: 40px; min-height: 40px; font-size: 18px; }
  .input-area textarea { min-height: 40px; }

  /* 表情选择器铺满底部 */
  .emoji-picker-panel { left: 8px; right: 8px; width: auto; margin-bottom: 8px; }
  .emoji-grid { grid-template-columns: repeat(8, 1fr); }

  /* 弹窗/资料卡适配 */
  .user-profile-card { width: calc(100vw - 40px); max-width: 320px; }
  .login-box { width: calc(100vw - 40px); padding: 40px 24px 32px; }

  /* 顶部工具条统一内边距 */
  .reply-preview, .edit-bar, .search-bar, .pinned-bar, .typing-indicator {
    padding-left: 14px;
    padding-right: 14px;
  }
}

/* ═════════════ 消息工具栏 & 菜单 ═════════════ */
.msg-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
}

.msg-wrapper:hover .msg-toolbar {
  opacity: 1;
  pointer-events: auto;
}

.msg-toolbar {
  position: absolute;
  top: -6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  z-index: 10;
}

.msg-self .msg-toolbar { left: -32px; }
.msg-other .msg-toolbar { right: -32px; }

.msg-toolbar-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: background .15s;
}

.msg-toolbar-btn:hover { background: var(--surface-3); }

.msg-menu {
  position: absolute;
  top: -4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  min-width: 160px;
  padding: 4px 0;
  display: none;
}

.msg-menu.show { display: block; }

.msg-self .msg-menu { right: 100%; margin-right: 8px; }
.msg-other .msg-menu { left: 100%; margin-left: 8px; }

.msg-menu-item {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background .1s;
}

.msg-menu-item:hover { background: var(--surface-3); color: var(--text); }
.msg-menu-item.danger { color: var(--danger); }
.msg-menu-item.danger:hover { background: rgba(220,38,38,.06); }

.msg-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ═════════════ 引用回复块 ═════════════ */
.msg-reply-block {
  border-left: 3px solid var(--border-2);
  background: rgba(0,0,0,.03);
  padding: 6px 10px;
  margin-bottom: 6px;
  border-radius: 0 6px 6px 0;
  font-size: 12px;
  color: var(--text-3);
  max-width: 100%;
  overflow: hidden;
  cursor: pointer;
}

.msg-self .msg-reply-block {
  background: rgba(255,255,255,.1);
  border-left-color: rgba(255,255,255,.3);
}

.msg-reply-author {
  font-weight: 600;
  color: var(--text-2);
  font-size: 11px;
  display: block;
  margin-bottom: 2px;
}

.msg-self .msg-reply-author { color: rgba(255,255,255,.7); }

/* ═════════════ 引用预览条 ═════════════ */
.reply-preview, .edit-bar {
  display: flex;
  align-items: center;
  padding: 8px 24px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  gap: 8px;
}

.reply-preview-info {
  flex: 1;
  min-width: 0;
  border-left: 3px solid var(--border-2);
  padding-left: 10px;
  font-size: 12px;
  color: var(--text-3);
}

.reply-preview-info span:first-child {
  font-weight: 600;
  color: var(--text-2);
  display: block;
  font-size: 11px;
  margin-bottom: 1px;
}

.reply-cancel {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reply-cancel:hover { background: var(--surface-3); color: var(--text); }

.edit-bar span { flex: 1; font-size: 13px; color: var(--text-2); font-weight: 500; }

/* ═════════════ 表情回应面板 ═════════════ */
.emoji-panel {
  position: absolute;
  top: -4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 101;
  padding: 8px;
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  width: 220px;
}

.emoji-panel.show { display: flex; }

.msg-self .emoji-panel { right: 100%; margin-right: 8px; }
.msg-other .emoji-panel { left: 100%; margin-left: 8px; }

.emoji-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s;
}

.emoji-btn:hover { background: var(--surface-3); }

/* ═════════════ 反应条 ═════════════ */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

/* 反应条跟随消息方向 */
.msg-self ~ .msg-reactions { align-self: flex-end; }
.msg-other ~ .msg-reactions { align-self: flex-start; }

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  line-height: 1.4;
}

.reaction-pill:hover { background: var(--surface-3); border-color: var(--border-2); }
.reaction-pill.mine { border-color: var(--accent); background: rgba(23,23,26,.05); }
.reaction-count { font-size: 11px; color: var(--text-3); }

/* ═════════════ 消息状态 ═════════════ */
.msg-status {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.msg-status.sent { color: var(--text-3); }
.msg-status.delivered { color: var(--text-3); }
.msg-status.read { color: #3b82f6; }

/* ═════════════ 已编辑标签 ═════════════ */
.msg-edited-tag {
  font-size: 11px;
  color: var(--text-3);
  font-style: italic;
  margin-left: 4px;
}

.msg-self .msg-edited-tag { color: rgba(255,255,255,.5); }

/* ═════════════ 撤回消息提示 ═════════════ */
.msg-recalled {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  padding: 6px 14px;
  font-style: italic;
}

/* ═════════════ 搜索栏 ═════════════ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.search-bar input {
  flex: 1;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color .2s;
}

.search-bar input:focus { border-color: var(--text); }

.search-count {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}

.search-nav {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.search-nav:hover { background: var(--surface-3); }

.search-highlight {
  background: rgba(255, 230, 0, .35);
  border-radius: 2px;
  padding: 0 1px;
}

.search-highlight.search-active, .search-highlight.active {
  background: rgba(255, 180, 0, .5);
  outline: 2px solid rgba(255, 180, 0, .6);
}

/* ═════════════ 消息闪烁定位 ═════════════ */
@keyframes msgFlash {
  0%, 100% { background: transparent; }
  50% { background: rgba(59,130,246,.12); }
}
.msg-flash { animation: msgFlash 1.5s ease; }

.header-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--text-3);
  font-size: 16px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}

.header-btn:hover { background: var(--surface-3); color: var(--text); }

/* ═════════════ 置顶区域 ═════════════ */
.pinned-bar {
  display: flex;
  align-items: center;
  padding: 10px 24px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.pinned-content {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 12px;
  border-left: 3px solid var(--accent);
}

.pinned-content:hover { color: var(--text); }

.pinned-content .pinned-author {
  font-weight: 600;
  margin-right: 6px;
}

.pinned-close {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pinned-close:hover { background: var(--surface-3); color: var(--text); }

/* ═════════════ 正在输入 ═════════════ */
.typing-indicator {
  padding: 4px 24px 8px;
  font-size: 12px;
  color: var(--text-3);
  font-style: italic;
  animation: typingFade 1.5s ease-in-out infinite;
}

@keyframes typingFade {
  0%, 100% { opacity: .5; }
  50% { opacity: 1; }
}

/* ═════════════ 阅后即焚倒计时 ═════════════ */
.burn-badge, .burn-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  margin-right: 6px;
  vertical-align: middle;
}

/* ═════════════ 在线状态标识 ═════════════ */
.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-indicator.online { background: var(--online); box-shadow: 0 0 0 2px rgba(34,197,94,.15); }
.status-indicator.busy { background: #eab308; box-shadow: 0 0 0 2px rgba(234,179,8,.15); }
.status-indicator.away { background: var(--offline); }

/* ═════════════ 快捷回复 ═════════════ */
.quick-reply-panel {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  min-width: 120px;
  padding: 4px 0;
}

.quick-reply-item, .qr-item {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: background .1s;
}

.quick-reply-item:hover, .qr-item:hover { background: var(--surface-3); color: var(--text); }

/* ═════════════ 收藏侧边栏 ═════════════ */
.favorites-sec {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  max-height: 200px;
}

.favorites-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fav-item {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: background .1s;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.fav-item:hover { background: var(--surface-3); }

.fav-item .fav-author {
  font-weight: 600;
  color: var(--text);
  font-size: 11px;
}

.fav-item .fav-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-empty {
  font-size: 12px;
  color: var(--text-3);
  padding: 4px 10px;
}

/* ═════════════ 暗色模式 ═════════════ */
[data-theme="dark"] {
  --bg: #111114;
  --surface: #1c1c20;
  --surface-2: #161619;
  --surface-3: #252529;
  --border: #2a2a2f;
  --border-2: #3a3a40;
  --text: #f5f5f7;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --accent: #f5f5f7;
  --accent-hover: #ffffff;
  --accent-text: #17171a;
  --danger: #ef4444;
  --online: #22c55e;
  --offline: #52525b;
  --shadow: 0 1px 2px rgba(0,0,0,.2), 0 4px 16px rgba(0,0,0,.3);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.5);
}

/* ═════════════ 侧边栏底部按钮 ═════════════ */
.sidebar-footer-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}

.sidebar-icon-btn:hover {
  background: var(--surface-3);
  border-color: var(--border-2);
}

/* ═════════════ 在线状态选择 ═════════════ */
.my-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.status-select {
  flex: 1;
  height: 32px;
  padding: 0 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.status-select:focus {
  border-color: var(--text);
}

/* ═════════════ 表情选择器 ═════════════ */
.input-icon-btn {
  width: 44px;
  min-height: 44px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}

.input-icon-btn:hover {
  border-color: var(--border-2);
  background: var(--surface-3);
}

.emoji-picker-panel {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  width: 340px;
  overflow: hidden;
}

.emoji-picker-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 8px 8px 0;
  gap: 2px;
}

.emoji-tab {
  flex: 1;
  height: 36px;
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  transition: background .15s;
  opacity: .6;
}

.emoji-tab:hover,
.emoji-tab.active {
  background: var(--surface-3);
  opacity: 1;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 2px;
  padding: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.emoji-item {
  width: 34px;
  height: 34px;
  border: none;
  background: none;
  font-size: 22px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s;
}

.emoji-item:hover {
  background: var(--surface-3);
  transform: scale(1.15);
}

/* ═════════════ 文件消息 ═════════════ */
.msg-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-top: 6px;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  color: inherit;
}

.msg-file:hover {
  background: var(--surface-3);
}

.msg-file-icon {
  width: 40px;
  height: 40px;
  background: var(--surface-3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.msg-file-info {
  flex: 1;
  min-width: 0;
}

.msg-file-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-file-size {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

.msg-self .msg-file {
  background: rgba(255,255,255,.1);
}

.msg-self .msg-file-icon {
  background: rgba(255,255,255,.15);
}

.msg-self .msg-file-name {
  color: var(--accent-text);
}

.msg-self .msg-file-size {
  color: rgba(255,255,255,.6);
}

.msg-img {
  max-width: 280px;
  max-height: 280px;
  border-radius: var(--radius-sm);
  margin-top: 6px;
  cursor: pointer;
  transition: transform .2s;
}

.msg-img:hover {
  transform: scale(1.02);
}

/* ═════════════ 图片预览模态框 ═════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  max-width: 90%;
  max-height: 90vh;
  object-fit: contain;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,.2);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: rgba(255,255,255,.3);
}

/* ═════════════ 文件上传进度 ═════════════ */
.upload-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.upload-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width .2s;
}

.upload-progress-text {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}

/* ═════════════ 通知设置弹窗 ═════════════ */
.notify-popup {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  width: 260px;
  padding: 16px;
}

.notify-popup.hidden {
  display: none;
}

.notify-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.notify-option label {
  font-size: 13px;
  color: var(--text-2);
}

.notify-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--surface-3);
  border-radius: 12px;
  cursor: pointer;
  transition: background .2s;
}

.notify-toggle.active {
  background: var(--accent);
}

.notify-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform .2s;
}

.notify-toggle.active::after {
  transform: translateX(20px);
}

/* ═════════════ 用户资料卡 ═════════════ */
.user-profile-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 320px;
  overflow: hidden;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 24px 20px;
  background: var(--surface-2);
  position: relative;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-info {
  flex: 1;
}

.profile-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.profile-status {
  font-size: 13px;
  color: var(--text-3);
}

.profile-status .status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.profile-status .status-dot.online { background: var(--online); }
.profile-status .status-dot.busy { background: #eab308; }
.profile-status .status-dot.away { background: var(--offline); }

.modal-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 18px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}

.modal-close-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.profile-actions {
  padding: 16px 20px;
  display: flex;
  gap: 10px;
}

.profile-action-btn {
  flex: 1;
  height: 38px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}

.profile-action-btn:hover {
  background: var(--accent-hover);
}

.profile-action-btn:active {
  transform: scale(.98);
}

/* ═════════════ 管理员操作 ═════════════ */
.admin-actions {
  padding: 0 20px 16px;
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.admin-btn {
  flex: 1;
  height: 34px;
  border: 1px solid;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}

.kick-btn {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.kick-btn:hover {
  background: rgba(220,38,38,.06);
}

.mute-btn {
  background: transparent;
  border-color: #eab308;
  color: #eab308;
}

.mute-btn:hover {
  background: rgba(234,179,8,.06);
}
