:root, html[data-theme="dark"] {
  --bg: #0f1117;
  --panel: #161a22;
  --panel-2: #1c212b;
  --border: #262c38;
  --text: #e6e9ef;
  --text-dim: #8a91a0;
  --accent: #07c160;
  --accent-dim: #059749;
  --danger: #e5484d;
  --bubble-other: #262c38;
  --hover: #262c38;
  --on-accent: #062;
  --mask: rgba(8,10,14,.55);
  --overlay: rgba(8,10,14,.7);
  --shadow: rgba(0,0,0,.4);
  --scroll-thumb: #2a3140;
  --scroll-thumb-hover: #363f52;
  --glow-a: rgba(7,193,96,.06);
  --glow-b: rgba(59,130,246,.06);
}

html[data-theme="light"] {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #edf1f6;
  --border: #dfe4ec;
  --text: #1f2430;
  --text-dim: #6b7280;
  --accent: #07c160;
  --accent-dim: #05a353;
  --danger: #e5484d;
  --bubble-other: #e8edf4;
  --hover: #e3e8f0;
  --on-accent: #fff;
  --mask: rgba(15,17,23,.35);
  --overlay: rgba(15,17,23,.45);
  --shadow: rgba(31,36,48,.18);
  --scroll-thumb: #c3cad6;
  --scroll-thumb-hover: #aeb6c4;
  --glow-a: rgba(7,193,96,.1);
  --glow-b: rgba(59,130,246,.1);
}

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

button { font-family: inherit; font-size: inherit; }

html, body { height: 100%; }

/* 根字号：按视口宽度自适应，大屏（平板/横屏）自动放大 */
html {
  font-size: clamp(16px, 1vw + 8px, 20px);
}
/* 用户手动覆盖档位 */
html[data-font="sm"] { font-size: 14px; }
html[data-font="md"] { font-size: 16px; }
html[data-font="lg"] { font-size: 18px; }
html[data-font="xl"] { font-size: 20px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.view { height: 100vh; height: 100dvh; }

.hidden { display: none !important; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 0.875rem;
  cursor: pointer;
  background: var(--panel-2);
  color: var(--text);
  transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-dim); }
.btn.block { width: 100%; }
.btn.danger { background: var(--danger); color: #fff; font-weight: 600; }
.btn.danger:hover { background: #b91c1c; }

input, textarea {
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
input { padding: 11px 14px; }

/* ============ 登录注册 ============ */
#view-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 20% -10%, var(--glow-a), transparent 60%),
    radial-gradient(1000px 500px at 90% 110%, var(--glow-b), transparent 60%),
    var(--bg);
  padding: 20px;
}

.auth-wrap { width: 100%; max-width: 380px; }

.auth-logo { font-size: 1.875rem; font-weight: 700; letter-spacing: 2px; text-align: center; }
.auth-sub { text-align: center; color: var(--text-dim); margin-top: 8px; margin-bottom: 28px; }

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}

.auth-tabs {
  display: flex;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.auth-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.938rem;
  padding: 10px 0;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.auth-form { display: flex; flex-direction: column; gap: 12px; }

.auth-msg { min-height: 18px; font-size: 0.813rem; color: var(--danger); }
.auth-msg.ok { color: var(--accent); }

.auth-note {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
  padding: 2px 0 6px;
  line-height: 1.6;
}

.auth-foot { text-align: center; color: var(--text-dim); font-size: 0.75rem; margin-top: 18px; }

/* ============ 聊天主界面（dock 布局） ============ */
#view-chat {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* —— 顶部页面（消息 / 通讯录 / 我的） —— */
.page {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.page-active { display: flex; }

.page-head {
  padding: 16px 16px 10px;
  display: flex;
  align-items: center;
}
.page-title { font-size: 1.375rem; font-weight: 700; }

.page-search { padding: 4px 16px 10px; }
.page-search input { width: 100%; }

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}
.conv-item:hover { background: var(--panel-2); }
.conv-item.active { background: var(--panel-2); }

.conv-avatar {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  overflow: hidden;
}
.global-avatar { background: linear-gradient(135deg, #07c160, #0ea5e9); }
.global-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block; }
.avatar-me { background: linear-gradient(135deg, #f59e0b, #ef4444); cursor: pointer; position: relative; }
.avatar-me:hover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  border-radius: 8px;
}
.avatar-cam {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--panel);
}
.avatar-cam svg {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.conv-info { flex: 1; min-width: 0; }
.conv-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-preview {
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-status { font-size: 0.688rem; flex-shrink: 0; }
.conv-status.on { color: var(--accent); }
.conv-status.off { color: var(--text-dim); }
.conv-unread {
  flex-shrink: 0;
  background: var(--danger);
  color: #fff;
  font-size: 0.688rem;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.conv-section {
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 14px 12px 6px;
}

.friend-item .conv-avatar,
.group-item .conv-avatar {
  width: 38px;
  height: 38px;
  font-size: 0.938rem;
}

/* —— 通讯录页 —— */
.contacts-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
}

.contacts-action {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}
.contacts-action:hover { background: var(--panel-2); }
.contacts-action-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
}
.contacts-action-text { font-weight: 500; }

/* —— 我的页 —— */
.me-body { flex: 1; overflow-y: auto; padding: 0 16px 24px; }
.me-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 16px;
  margin-bottom: 16px;
}
.me-card-info { flex: 1; min-width: 0; }
.me-name-row { display: flex; align-items: center; gap: 6px; }
.me-name { font-weight: 600; font-size: 1.063rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-online { color: var(--accent); font-size: 0.75rem; margin-top: 3px; }
.me-menu { display: flex; flex-direction: column; gap: 10px; }
.me-item {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.938rem;
  cursor: pointer;
  text-align: left;
  transition: background .15s, border-color .15s, color .15s;
}
.me-item:hover { background: var(--panel-2); }
.me-item.admin-btn { background: linear-gradient(135deg, #f59e0b, #ef4444); color: #fff; font-weight: 600; border: none; }
.me-item.admin-btn:hover { opacity: .85; }
.me-item.logout { color: var(--danger); }
.me-item-label { flex: 1; }
.me-item-icon { font-size: 1.125rem; color: var(--muted); }
.me-item-icon.fs-on { color: var(--accent); }

/* —— 底部 dock 栏 —— */
.dock {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 5;
}
.dock-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0 7px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.625rem;
  cursor: pointer;
  transition: color .15s;
}
.dock-item svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dock-item:hover { color: var(--text); }
.dock-item.dock-active { color: var(--accent); }

/* ============ 聊天视图（覆盖层） ============ */
.chat-view {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
#view-chat { position: relative; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.chat-title { flex: 1; min-width: 0; }
.chat-name { font-size: 1rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub { color: var(--text-dim); font-size: 0.75rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.375rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--accent); background: var(--panel-2); }
.back-btn { font-size: 1.75rem; padding: 0 10px; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg-row { display: flex; gap: 10px; align-items: flex-start; }
.msg-row.me { flex-direction: row-reverse; }

.msg-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.msg-row:not(.me) .msg-wrap { align-items: flex-start; }
.msg-row.me .msg-wrap { align-items: flex-end; }

.msg-bubble {
  max-width: 100%;
  padding: 9px 13px;
  border-radius: 10px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg-row.me .msg-bubble { background: var(--accent); color: var(--on-accent); }
.msg-row.other .msg-bubble { background: #fff; color: #000; }

.msg-meta { margin-bottom: 4px; font-size: 0.75rem; }
.msg-row.me .msg-meta { text-align: right; }
.msg-sender { color: var(--text-dim); }
.msg-time { color: var(--text-dim); opacity: .7; margin-left: 6px; }

.system-row { text-align: center; font-size: 0.75rem; color: var(--text-dim); padding: 4px 0; }

/* ============ 输入栏 ============ */
.input-bar {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  align-items: flex-end;
}
.mention-panel {
  border-top: 1px solid var(--border);
  background: var(--panel);
  max-height: 220px;
  overflow-y: auto;
  padding: 6px 8px;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 0.938rem;
}
.mention-item:hover,
.mention-item.active { background: var(--panel-2); }
.msg-bubble .mention { color: var(--accent); font-weight: 600; }
.msg-row.me .msg-bubble.bubble-blue { background: #2563eb; color: #fff; }
.msg-row.me .msg-bubble.bubble-blue .mention {
  color: #fff;
  background: rgba(255, 255, 255, 0.35);
  padding: 0 4px;
  border-radius: 4px;
  font-weight: 700;
}
.msg-row.me .msg-bubble .mention {
  color: var(--on-accent);
  background: rgba(255, 255, 255, 0.35);
  padding: 0 4px;
  border-radius: 4px;
  font-weight: 700;
}

.msg-input {
  flex: 1;
  resize: none;
  padding: 10px 14px;
  max-height: 120px;
  min-height: 42px;
}
.send-btn { height: 42px; padding: 0 22px; }

/* ============ 好友验证 / 站长管理面板 ============ */
.request-panel {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}
.request-panel-head {
  padding: 4px 4px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.request-panel-title { font-size: 1.063rem; font-weight: 600; }
.request-panel-sub { color: var(--text-dim); font-size: 0.75rem; margin-top: 3px; }
.request-panel-list { max-height: none; flex: 1; }

.request-item { border: 1px solid var(--accent); margin: 4px 0; }
.request-avatar { background: linear-gradient(135deg, #07c160, #3b82f6); }

.admin-section { margin-bottom: 16px; }
.admin-sec-title { font-size: 0.813rem; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.admin-row { display: flex; gap: 8px; align-items: center; }
.admin-row .admin-input { flex: 1; min-width: 0; }
.admin-btn-sm { padding: 8px 14px; font-size: 0.813rem; }
.admin-user-list { display: flex; flex-direction: column; gap: 8px; }
.admin-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.admin-user-row .btn { padding: 6px 12px; font-size: 0.813rem; }
.admin-user-row .btn.danger { background: none; border: 1px solid var(--danger); color: var(--danger); }
.admin-user-row .btn.danger:hover { background: var(--danger); color: #fff; }

/* ============ 头衔徽标 ============ */
.role-badge {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}
.role-admin {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  box-shadow: 0 0 6px rgba(245, 158, 11, .4);
}
.role-owner {
  background: linear-gradient(135deg, #07c160, #0ea5e9);
  color: #fff;
}
.role-bot {
  background: #fff;
  color: #2563eb;
  border: 1px solid #2563eb;
}
.conv-name .role-badge, .msg-sender + .role-badge { margin-left: 6px; }

.group-settings-btn { margin-left: auto; }
.delete-friend-btn { margin-left: 8px; color: var(--danger); }
.delete-friend-btn:hover { color: var(--danger); opacity: .85; }

.gs-avatar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.gs-avatar {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  font-weight: 600;
  color: #fff;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}
.gs-avatar-row .auth-msg { min-height: 0; font-size: 0.75rem; }

#gs-member-list { max-height: 260px; overflow-y: auto; }

.request-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
}
.request-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.request-card .r-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.request-card .r-time { color: var(--text-dim); font-size: 0.688rem; }
.request-card .r-actions { display: flex; gap: 8px; flex-shrink: 0; }
.request-card .btn { padding: 6px 12px; font-size: 0.813rem; }
.request-card .btn.accept { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.request-card .btn.accept:hover { background: var(--accent-dim); }
.request-card .btn.deny { background: none; border: 1px solid var(--border); color: var(--text-dim); }
.request-card .btn.deny:hover { color: var(--danger); border-color: var(--danger); }
.request-empty { color: var(--text-dim); text-align: center; padding: 20px 0; }

/* ============ 弹窗 ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-box {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 1rem; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.375rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

.fs-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.fs-opt {
  padding: 10px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.fs-opt.active { border-color: var(--accent); color: var(--accent); background: var(--glow-a); }
.fs-opt:hover { border-color: var(--accent); }

.group-picker-title { color: var(--text-dim); font-size: 0.813rem; margin: 4px 0; }
#group-member-list, #add-member-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.group-member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.group-member-item:hover { background: var(--panel-2); }
.group-member-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}
.group-member-item .g-avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.813rem;
  font-weight: 600;
  color: #fff;
}
.group-empty { color: var(--text-dim); font-size: 0.813rem; text-align: center; padding: 16px 0; }

/* ============ 全局提示 ============ */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.813rem;
  z-index: 100;
  box-shadow: 0 8px 24px var(--shadow);
}

/* ============ 全屏横屏适配 ============ */
:fullscreen #view-chat { max-width: 100vw; }
:fullscreen .messages { max-width: 900px; margin: 0 auto; width: 100%; }
:fullscreen .input-bar { max-width: 900px; margin: 0 auto; width: 100%; }
:fullscreen .chat-header { max-width: 900px; margin: 0 auto; width: 100%; }

/* ============ 滚动条 ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 桌面端加宽 ============ */
@media (min-width: 721px) {
  #view-chat { max-width: 100vw; margin: 0; box-shadow: none; }
  body { display: block; }
  .chat-header, .messages, .input-bar { max-width: 900px; margin: 0 auto; width: 100%; }
}

/* ============ 手机/平板横屏铺满 ============ */
@media (orientation: landscape) and (pointer: coarse) {
  #view-chat { max-width: 100vw; margin: 0; box-shadow: none; }
  body { display: block; }
  .chat-header, .messages, .input-bar { max-width: 900px; margin: 0 auto; width: 100%; }
}

/* ============ 发现页 ============ */
.discover-body { flex: 1; overflow-y: auto; padding: 8px 12px 24px; }
.discover-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; background: var(--panel); border: none; color: var(--text);
  padding: 14px 16px; border-radius: 12px; cursor: pointer; text-align: left;
}
.discover-item:hover { background: var(--panel-2); }
.discover-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6); color: #fff;
  font-weight: 700; font-size: 1.1rem;
}
.discover-label { flex: 1; font-size: 1rem; font-weight: 500; }
.discover-item + .discover-item { margin-top: 8px; }
.discover-arrow { color: var(--text-dim); font-size: 1.4rem; }

/* ============ 朋友圈视图 ============ */
.moments-view {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.moments-view.hidden { display: none; }
.moments-list { flex: 1; overflow-y: auto; padding: 12px 12px 48px; }

/* ============ 番茄小说 ============ */
.tomato-warning { display: flex; flex-direction: column; gap: 10px; color: var(--text); font-size: 0.9rem; line-height: 1.7; }
.tomato-warning p { margin: 0; }
.tomato-warning p:first-child { color: var(--danger); font-weight: 600; }

.moment-card {
  background: var(--panel); border-radius: 12px;
  padding: 14px; margin-bottom: 12px;
}
.moment-head { display: flex; align-items: center; gap: 10px; }
.moment-head .avatar { width: 40px; height: 40px; }
.moment-info { flex: 1; min-width: 0; }
.moment-name { font-weight: 600; font-size: 0.95rem; }
.moment-time { color: var(--text-dim); font-size: 0.72rem; margin-top: 2px; }
.moment-text { margin: 10px 0 0; font-size: 0.95rem; white-space: pre-wrap; word-break: break-word; }
.moment-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 10px; }
.moment-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; cursor: pointer; }
.moment-grid.single { grid-template-columns: 1fr; }
.moment-grid.single img { aspect-ratio: auto; max-height: 260px; }
.moment-actions { display: flex; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.moment-btn {
  flex: 1; background: none; border: none; color: var(--text-dim);
  font-size: 0.8rem; padding: 6px 0; cursor: pointer; border-radius: 6px;
}
.moment-btn:hover { background: var(--panel-2); }
.moment-btn.liked { color: var(--accent); font-weight: 600; }
.moment-btn.del { color: var(--danger); }
.moment-comments { margin-top: 6px; }
.moment-comment { display: flex; gap: 6px; padding: 3px 0; font-size: 0.85rem; align-items: baseline; }
.moment-comment .c-name { font-weight: 600; flex-shrink: 0; color: var(--accent); }
.moment-comment .c-text { flex: 1; word-break: break-word; color: var(--text); }
.moment-comment .c-del {
  color: var(--text-dim); cursor: pointer; flex-shrink: 0;
  background: none; border: none; font-size: 0.78rem; padding: 0 2px;
}
.moment-comment .c-del:hover { color: var(--danger); }
.moment-empty { text-align: center; color: var(--text-dim); padding: 60px 0; font-size: 0.9rem; }

/* ============ 发布朋友圈 ============ */
.moment-text {
  width: 100%; min-height: 80px; resize: none;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-family: inherit; font-size: 0.95rem;
}
.moment-text:focus { outline: none; border-color: var(--accent); }
.moment-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.moment-thumb { position: relative; width: 70px; height: 70px; border-radius: 8px; overflow: hidden; }
.moment-thumb img { width: 100%; height: 100%; object-fit: cover; }
.moment-thumb .rm {
  position: absolute; top: 0; right: 0; width: 20px; height: 20px;
  background: rgba(0, 0, 0, .6); color: #fff; border: none; cursor: pointer;
  font-size: 0.8rem; line-height: 1;
}

/* ============ 聊天图片消息 / 长按撤回 ============ */
.img-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.img-btn:hover { background: var(--hover); }

.draft-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px 0;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.draft-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
}
.draft-thumb img { width: 100%; height: 100%; object-fit: cover; }
.draft-thumb .rm {
  position: absolute; top: 0; right: 0; width: 20px; height: 20px;
  background: rgba(0, 0, 0, .6); color: #fff; border: none; cursor: pointer;
  font-size: 0.8rem; line-height: 1;
}

.msg-bubble .msg-images {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 8px;
  max-width: 260px;
}
.msg-bubble .msg-images.single { grid-template-columns: 1fr; }
.msg-bubble .msg-images img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  display: block;
}
.msg-bubble .msg-images.single img { aspect-ratio: auto; max-width: 240px; max-height: 240px; }

.msg-context-menu {
  position: fixed;
  z-index: 200;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 8px 24px var(--shadow);
  min-width: 90px;
}
.msg-context-item {
  display: block;
  width: 100%;
  text-align: center;
  padding: 9px 16px;
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.875rem;
  cursor: pointer;
  border-radius: 6px;
}
.msg-context-item:hover { background: var(--hover); }

.img-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, .85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.img-preview-overlay img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 8px;
}

/* ============ iOS 长按撤回：禁用消息文本选择 ============ */
.msg-row {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* 搜索群聊结果样式 */
.search-results {
  margin-top: 12px;
  max-height: 300px;
  overflow-y: auto;
}
.search-result-item {
  padding: 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  margin-bottom: 8px;
  position: relative;
}
.search-result-name {
  font-size: 15px;
  font-weight: 600;
  color: #eaeaea;
  margin-bottom: 4px;
}
.search-result-sub {
  font-size: 12px;
  color: #8892b0;
}
.search-apply-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: #0f3460;
  color: white;
  font-size: 13px;
  cursor: pointer;
}
.search-apply-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.search-empty {
  text-align: center;
  color: #8892b0;
  padding: 20px;
  font-size: 14px;
}

/* ===== 搜索群聊弹窗美化 ===== */
.search-group-box {
  width: 90%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
}

.search-group-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-group-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.search-group-input-row input:focus {
  border-color: #07c160;
}

.search-group-input-row .btn {
  padding: 10px 20px;
  white-space: nowrap;
}

/* 搜索结果美化 */
.search-results {
  margin-top: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  padding: 14px;
  border-radius: 12px;
  background: var(--panel-2);
  margin-bottom: 8px;
  position: relative;
  transition: background 0.2s, transform 0.1s;
  border: 1px solid var(--border);
}

.search-result-item:hover {
  background: var(--panel);
}

.search-result-avatar {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #07c160, #0ea5e9);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
  margin-right: 12px;
  flex-shrink: 0;
}

.search-result-info {
  flex: 1;
  min-width: 0;
}

.search-result-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-sub {
  font-size: 12px;
  color: var(--text-dim);
}

.search-apply-btn {
  padding: 7px 16px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #07c160, #06ad56);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 8px;
}

.search-apply-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--text-dim);
}

.search-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 30px 20px;
  font-size: 14px;
}

/* 日间模式适配 */
[data-theme="light"] .search-result-item {
  background: #f5f7fa;
  border-color: #e2e8f0;
}

[data-theme="light"] .search-result-item:hover {
  background: #edf2f7;
}

/* 已加入按钮样式 */
.search-apply-btn.joined-btn {
  background: var(--text-dim);
  cursor: default;
}

/* ===== 表情包 ===== */

/* 表情包消息 */
