/* ============================================================
   频道页样式完整版（含头像尺寸修复 + 个人主页弹窗）
   ============================================================ */

/* ============ 主布局 ============ */
.forum-layout {
  height: calc(100vh - 94px - var(--safe-top));
  margin-top: calc(64px + var(--safe-top));
  padding: 1rem max(1.5rem, var(--safe-right)) 1rem max(1.5rem, var(--safe-left));
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.25rem;
  overflow: hidden;
}

/* ============ 左侧频道列表 ============ */
.channel-sidebar {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: 1rem 0.8rem;
  box-shadow: var(--shadow-sm), var(--shadow-md);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.channel-sidebar-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.6rem; padding: 0 0.4rem; flex-shrink: 0;
}
.channel-sidebar-head h3 { font-size: 1rem; }
#createChannelBtn {
  width: 28px; height: 28px; border-radius: 50%;
  border: none; background: var(--accent); color: #fff;
  font-size: 1rem; cursor: pointer; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
#createChannelBtn:hover { background: #1d4ed8; transform: scale(1.05); }

.channel-tabs {
  display: flex; gap: 0.3rem; margin-bottom: 0.5rem;
  padding: 0 0.2rem; flex-shrink: 0;
}
.channel-tabs button {
  flex: 1; padding: 0.35rem; border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-app); color: var(--text-secondary);
  font-size: 0.75rem; cursor: pointer; transition: all 0.15s;
}
.channel-tabs button.active {
  background: var(--accent-light); color: var(--accent);
  border-color: var(--accent); font-weight: 600;
}

#channelList {
  flex: 1; overflow-y: auto;
  padding-right: 4px; min-height: 0;
}
.channel-group-header {
  font-size: 0.65rem; font-weight: 700;
  color: var(--text-muted); padding: 0.6rem 0.6rem 0.3rem;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.channel-item {
  padding: 0.55rem 0.7rem; border-radius: 10px;
  cursor: pointer; margin-bottom: 2px;
  display: flex; gap: 0.5rem; align-items: center;
  transition: background 0.15s; position: relative;
}
.channel-item:hover { background: var(--bg-app); }
.channel-item.active { background: var(--accent-light); }
.channel-item.active .ch-name { color: var(--accent); font-weight: 700; }
.channel-item .ch-icon { font-size: 1.1rem; flex-shrink: 0; }
.channel-item .ch-info { flex: 1; min-width: 0; }
.channel-item .ch-name {
  font-size: 0.85rem; font-weight: 500;
  display: flex; align-items: center; gap: 0.3rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.channel-item .ch-meta { font-size: 0.65rem; color: var(--text-muted); }

/* 频道图标：图片 */
.ch-icon-img {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

.ch-role {
  font-size: 0.55rem; font-weight: 700;
  padding: 1px 5px; border-radius: 20px; flex-shrink: 0;
}
.ch-role.owner { background: linear-gradient(135deg, #f59e0b, #ef4444); color: #fff; }
.ch-role.admin { background: linear-gradient(135deg, #06b6d4, #2563eb); color: #fff; }

.unread-badge {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff; font-size: 0.6rem; font-weight: 700;
  padding: 2px 7px; border-radius: 20px; min-width: 20px;
  text-align: center; line-height: 1.4; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
  animation: unread-pulse 2s infinite;
}
@keyframes unread-pulse {
  0%, 100% { box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 2px 10px rgba(239, 68, 68, 0.7); }
}
.channel-mute-icon { font-size: 0.6rem; color: var(--text-muted); margin-left: 2px; }
.channel-push-icon { font-size: 0.6rem; color: #f59e0b; margin-left: 2px; }
.empty-tip { padding: 1rem; text-align: center; color: var(--text-muted); font-size: 0.8rem; }

/* ============ 右侧聊天区 ============ */
.chat-main {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm), var(--shadow-md);
  display: flex; flex-direction: column;
  overflow: hidden; min-height: 0;
}
#chatHeader {
  padding: 0.7rem 1.2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--bg-nav); backdrop-filter: blur(10px);
  flex-shrink: 0;
}
#chatHeader h3 {
  font-size: 0.95rem; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer; transition: color 0.15s;
}
#chatHeader h3:hover { color: var(--accent); }
#chatHeader #chatMemberCount { font-size: 0.7rem; color: var(--text-muted); flex-shrink: 0; }
#chatHeader button {
  padding: 0.35rem 0.8rem; border-radius: 20px;
  border: 1px solid var(--accent); background: var(--accent);
  color: #fff; font-size: 0.72rem; cursor: pointer; font-weight: 500;
  transition: background 0.15s;
  display: inline-flex; align-items: center; gap: 0.3rem;
  white-space: nowrap; flex-shrink: 0;
}
#chatHeader button:hover { background: #1d4ed8; }
#searchBtn, #settingsBtn {
  padding: 0.35rem 0.6rem !important;
  background: var(--bg-app) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-color) !important;
}
#searchBtn:hover, #settingsBtn:hover { background: var(--border-color) !important; }
#leaveChannelBtn {
  background: var(--bg-app) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-color) !important;
}
#leaveChannelBtn:hover { background: var(--border-color) !important; }

.announcement-bar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 1rem; margin: 0.6rem 1rem 0;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-left: 3px solid #f59e0b;
  border-radius: 8px; font-size: 0.78rem; color: #78350f;
  flex-shrink: 0;
}
[data-theme="dark"] .announcement-bar {
  background: linear-gradient(135deg, #422006, #1e293b);
  color: #fcd34d;
}
.announcement-bar i { color: #f59e0b; flex-shrink: 0; }
.announcement-bar span { flex: 1; word-break: break-word; }
.announcement-edit {
  background: rgba(0, 0, 0, 0.1); border: none;
  padding: 2px 8px; border-radius: 6px;
  font-size: 0.65rem; cursor: pointer; color: inherit;
}
.announcement-edit:hover { background: rgba(0, 0, 0, 0.2); }

/* ============================================================
   消息流
   ============================================================ */
.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* 时间分隔线 */
.msg-time-divider {
  text-align: center;
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 0.5rem 0;
  margin: 0.3rem 0;
  position: relative;
}
.msg-time-divider::before,
.msg-time-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 32%;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border-color), transparent);
}
.msg-time-divider::before { left: 0; }
.msg-time-divider::after { right: 0; }

/* 消息条目 */
.msg {
  display: flex;
  gap: 0.55rem;
  max-width: 60%;
  align-items: flex-start;
  animation: msg-in 0.25s ease;
  position: relative;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 自己发的：整体靠右 */
.msg.msg-self {
  flex-direction: row-reverse;
  margin-left: auto;
  margin-right: 0;
}

/* 消息主体 */
.msg-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  max-width: 100%;
  flex: 0 1 auto;
}
.msg.msg-self .msg-body {
  align-items: flex-end;
}

/* ============================================================
   ★ 消息头像（严格约束尺寸，防止图片撑破）
   ============================================================ */
.msg-avatar {
  width: 38px;
  height: 38px;
  min-width: 38px;
  max-width: 38px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
  user-select: none;
  position: relative;
  box-sizing: border-box;
}

.msg-avatar img {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.msg-avatar.avatar-bot {
  background: linear-gradient(135deg, #06b6d4, #2563eb);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.25),
              0 0 12px rgba(6, 182, 212, 0.35);
  font-size: 1.15rem;
}

.msg-avatar.avatar-bot::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1px dashed rgba(6, 182, 212, 0.6);
  animation: orbit 6s linear infinite;
  pointer-events: none;
}
@keyframes orbit { to { transform: rotate(360deg); } }

/* 消息头（用户名 + 徽章 + 时间）*/
.msg-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
  padding: 0 0.3rem;
  flex-wrap: wrap;
}
.msg.msg-self .msg-head {
  flex-direction: row-reverse;
  justify-content: flex-start;
}
.msg-user {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
}
.msg-user:hover { color: var(--accent); }
.msg-bot .msg-user { color: #0891b2; font-weight: 700; }

/* 角色徽章（纯文字）*/
.msg-head .role-badge,
.member-name .role-badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0 4px;
  line-height: 1.4;
  flex-shrink: 0;
  background: transparent;
  border: none;
  letter-spacing: 0.5px;
}
.msg-head .role-badge.owner,
.member-name .role-badge.owner { color: #ef4444; }
.msg-head .role-badge.admin,
.member-name .role-badge.admin { color: #f59e0b; }

.bot-badge {
  background: linear-gradient(135deg, #06b6d4, #2563eb);
  color: #fff;
  font-size: 0.5rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}
.msg-time {
  font-size: 0.62rem;
  color: var(--text-muted);
}

/* 消息气泡 */
.msg-text {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-primary);
  background: #ffffff;
  padding: 0.55rem 0.85rem;
  border-radius: 18px 18px 18px 4px;
  word-break: break-word;
  white-space: pre-wrap;
  text-align: left;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  border: none;
}
[data-theme="dark"] .msg-text {
  background: #1e293b;
  color: var(--text-primary);
}

/* 自己发的：蓝色 + 右下小尖 */
.msg.msg-self .msg-text {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.2);
}
[data-theme="dark"] .msg.msg-self .msg-text {
  background: linear-gradient(135deg, #0369a1, #075985);
  color: #e0f2fe;
}

/* 机器人：淡青 */
.msg-bot .msg-text {
  background: linear-gradient(135deg, #ecfeff, #cffafe);
  color: #0e7490;
  border: none;
  border-radius: 18px 18px 18px 4px;
}
[data-theme="dark"] .msg-bot .msg-text {
  background: linear-gradient(135deg, #164e63, #0e7490);
  color: #cffafe;
}

/* 撤回 / 系统提示 */
.msg-recalled {
  color: var(--text-muted) !important;
  background: transparent !important;
  font-style: italic;
}
.msg-system {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0.45rem 0.9rem;
  background: rgba(148, 163, 184, 0.12);
  border-radius: 20px;
  align-self: center;
  max-width: 70%;
  margin: 0.3rem auto;
  animation: fadeIn 0.3s ease;
}

/* 消息发送中 */
.msg.msg-local { opacity: 0.7; }
.msg-sending { font-size: 0.65rem; color: var(--text-muted); margin-left: 4px; }
.msg.msg-error { opacity: 0.6; }

/* 高亮被定位的消息 */
.msg.msg-highlight .msg-text {
  background: linear-gradient(135deg, #fef3c7, #fde68a) !important;
  border-color: #f59e0b !important;
  animation: highlight-pulse 1.8s ease;
}
@keyframes highlight-pulse {
  0% { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.35); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* @提及高亮 */
.mention {
  color: #0891b2;
  font-weight: 600;
  background: rgba(6, 182, 212, 0.12);
  padding: 0 4px;
  border-radius: 4px;
}
.msg.msg-self .mention {
  color: #fef9c3;
  background: rgba(254, 249, 195, 0.2);
}

/* 引用预览 */
.msg-reply-preview {
  background: rgba(148, 163, 184, 0.1);
  border-left: 3px solid var(--accent);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  cursor: pointer;
  transition: background 0.15s;
  max-width: 100%;
}
.msg-reply-preview:hover { background: rgba(148, 163, 184, 0.2); }
.msg-reply-preview i { font-size: 0.6rem; margin-right: 0.3rem; }

/* hover 操作按钮 */
.msg-hover-actions {
  position: absolute;
  top: -10px;
  right: 8px;
  display: none;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 3px 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 10;
}
.msg:hover .msg-hover-actions { display: flex; }
.msg.msg-self .msg-hover-actions { right: auto; left: 8px; }
.msg-action-btn {
  background: none;
  border: none;
  padding: 3px 6px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.7rem;
  transition: all 0.15s;
}
.msg-action-btn:hover { background: var(--bg-app); color: var(--accent); }
.msg-action-btn.danger:hover { background: rgba(239, 68, 68, 0.1); color: #ef4444; }

.cite { color: #0891b2; font-weight: 700; padding: 0 2px; font-size: 0.8rem; }
.msg.msg-self .cite { color: #fef9c3; }
.msg-text.typing { color: var(--text-muted); font-style: italic; }
.typing-dots { display: inline-flex; gap: 3px; margin-left: 4px; vertical-align: middle; }
.typing-dots i {
  width: 5px; height: 5px; border-radius: 50%;
  background: #06b6d4;
  animation: dot-bounce 1.2s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* 引用卡片 */
.msg-refs {
  margin-top: 0.55rem;
  border-top: 1px dashed rgba(6, 182, 212, 0.3);
  padding-top: 0.5rem;
  width: 100%;
  max-width: 100%;
}
.refs-title {
  font-size: 0.68rem;
  color: #0891b2;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.refs-list { display: flex; flex-direction: column; gap: 0.35rem; }
.ref-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  font-size: 0.78rem;
  transition: all 0.15s ease;
  cursor: pointer;
}
.ref-item:hover {
  background: rgba(6, 182, 212, 0.1);
  border-color: #06b6d4;
  transform: translateX(2px);
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.15);
}
[data-theme="dark"] .ref-item {
  background: rgba(6, 182, 212, 0.06);
  border-color: rgba(6, 182, 212, 0.3);
}
[data-theme="dark"] .ref-item:hover { background: rgba(6, 182, 212, 0.15); }
.ref-idx {
  color: #0891b2;
  font-weight: 700;
  flex-shrink: 0;
  font-size: 0.72rem;
  padding-top: 1px;
}
.ref-content { flex: 1; min-width: 0; }
.ref-title {
  color: var(--text-primary);
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  margin-bottom: 2px;
}
.ref-meta { color: var(--text-muted); font-size: 0.62rem; }
.msg-error-tip { font-size: 0.65rem; color: #ef4444; margin-top: 4px; }

/* ============ 输入区 ============ */
.message-input {
  position: relative;
  display: flex;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  align-items: flex-end;
  flex-shrink: 0;
}
.bot-mention-btn {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.12), rgba(37, 99, 235, 0.12));
  border: 1px solid rgba(6, 182, 212, 0.4);
  color: #0891b2;
  padding: 0.5rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.bot-mention-btn:hover {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(37, 99, 235, 0.2));
}
#msgInput {
  flex: 1;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--border-color);
  background: var(--bg-app);
  border-radius: 20px;
  font-size: 0.88rem;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  resize: none;
  line-height: 1.5;
  min-height: 38px;
  max-height: 120px;
  overflow-y: auto;
  transition: border 0.15s;
}
#msgInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
#msgInput:disabled { opacity: 0.5; cursor: not-allowed; }

#sendMsgBtn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.55rem 1.3rem;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.82rem;
  transition: background 0.15s;
  flex-shrink: 0;
  min-height: 38px;
}
#sendMsgBtn:hover { background: #1d4ed8; }
#sendMsgBtn:disabled { opacity: 0.5; cursor: not-allowed; }

.mention-dropdown {
  position: absolute;
  bottom: calc(100% - 4px);
  left: 1rem;
  width: 240px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 200;
  padding: 4px;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}
.mention-item:hover { background: var(--bg-app); }
.mention-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 600; flex-shrink: 0;
  overflow: hidden;
}
.mention-info { flex: 1; min-width: 0; }
.mention-name { font-size: 0.78rem; font-weight: 500; }
.mention-uid { font-size: 0.6rem; color: var(--text-muted); }

.reply-preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  margin: 0 1rem;
  background: rgba(37, 99, 235, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.reply-preview i { color: var(--accent); flex-shrink: 0; }
.reply-preview-user { font-weight: 600; color: var(--accent); }
.reply-preview-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reply-preview-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 4px;
}
.reply-preview-close:hover { color: var(--text-primary); }

/* ============ 抽屉面板 ============ */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2500;
  justify-content: flex-end;
}
.drawer-overlay.active { display: flex; }
.drawer {
  width: 360px;
  max-width: 90%;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.25s ease;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
}
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.drawer-head {
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.drawer-head h3 {
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.drawer-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0 0.4rem;
}
.drawer-close:hover { color: var(--text-primary); }
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem 1rem;
  min-height: 0;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  border-radius: 6px;
  transition: background 0.15s;
  flex-wrap: wrap;
}
.member-row:hover { background: var(--bg-app); }
.member-row:last-child { border-bottom: none; }
.member-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.member-info { flex: 1; min-width: 0; }
.member-name {
  font-size: 0.83rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.member-uid { font-size: 0.65rem; color: var(--text-muted); margin-top: 2px; }
.muted-badge {
  font-size: 0.6rem;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  padding: 1px 6px;
  border-radius: 20px;
}
.member-actions {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-top: 0.3rem;
  width: 100%;
}
.mini-btn {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 0.2rem 0.6rem;
  font-size: 0.65rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.mini-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
.mini-btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
}

/* 表单 */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.form-group input[type="text"],
.form-group textarea {
  width: 100%;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border-color);
  background: var(--bg-app);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}
.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.checkbox-line input[type="checkbox"] { width: auto; cursor: pointer; }

.btn-save {
  width: 100%;
  padding: 0.6rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 40px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: background 0.15s;
}
.btn-save:hover { background: #1d4ed8; }

.btn-danger {
  width: 100%;
  padding: 0.6rem;
  background: transparent;
  color: #ef4444;
  border: 1px solid #ef4444;
  border-radius: 40px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 0.6rem;
  transition: all 0.15s;
}
.btn-danger:hover { background: #ef4444; color: #fff; }

.loading-tip {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ============ 频道信息 ============ */
.info-hero {
  text-align: center;
  padding: 1.5rem 1rem;
  border-bottom: 1px solid var(--border-color);
}
.info-icon {
  width: 90px;
  height: 90px;
  margin: 0 auto 0.5rem;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: var(--bg-app);
}
.info-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.info-name { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.3rem; }
.info-role {
  display: inline-block;
  font-size: 0.65rem;
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}
.info-section {
  padding: 0.8rem 0.4rem;
  border-bottom: 1px solid var(--border-color);
}
.info-section:last-child { border-bottom: none; }
.info-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.82rem;
}
.info-row span { color: var(--text-secondary); }
.info-row b { color: var(--text-primary); font-weight: 600; }
.info-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
}
.info-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  font-size: 0.85rem;
}
.info-toggle-row > span {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  font-weight: 500;
}
.info-toggle-row > span i {
  width: 16px;
  text-align: center;
  color: var(--text-secondary);
}
.info-hint {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  padding-left: 0.4rem;
}
.toggle-switch {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 26px;
  background: #cbd5e1;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.25s ease;
  flex-shrink: 0;
  outline: none;
}
.toggle-switch:hover { opacity: 0.9; }
.toggle-switch:disabled { opacity: 0.5; cursor: not-allowed; }
.toggle-switch.on { background: #22c55e; }
.toggle-switch .toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.toggle-switch.on .toggle-knob { transform: translateX(20px); }
[data-theme="dark"] .toggle-switch { background: #334155; }
[data-theme="dark"] .toggle-switch.on { background: #16a34a; }

/* ============ 搜索 ============ */
.search-input-wrap {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}
.search-input-wrap input {
  flex: 1;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border-color);
  background: var(--bg-app);
  border-radius: 8px;
  font-size: 0.85rem;
  outline: none;
  color: var(--text-primary);
}
.search-input-wrap input:focus { border-color: var(--accent); }
.search-input-wrap button {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
}
.search-result {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}
.search-result:hover { background: var(--bg-app); }
.search-result-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  margin-bottom: 0.2rem;
}
.search-result-head b { color: var(--text-primary); }
.search-result-head span { color: var(--text-muted); }
.search-result-body {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
}
.search-result-body mark {
  background: #fef08a;
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}
[data-theme="dark"] .search-result-body mark {
  background: #a16207;
  color: #fff;
}

/* ============ B站订阅行 ============ */
.bili-sub-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.75rem;
}
.bili-sub-row:last-child { border-bottom: none; }
.bili-sub-type {
  font-size: 0.65rem;
  color: var(--accent);
  background: var(--accent-light);
  padding: 1px 6px;
  border-radius: 20px;
  flex-shrink: 0;
  font-weight: 600;
}
.bili-sub-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}
.bili-sub-row .mini-btn {
  padding: 0.15rem 0.4rem;
  font-size: 0.7rem;
}

/* ============================================================
   频道图标选择器
   ============================================================ */
.channel-icon-picker {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0;
}
.channel-icon-preview {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--border-color);
}
.channel-icon-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.channel-icon-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* 上传按钮 */
.upload-label,
.btn-sm {
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-app);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s;
}
.upload-label:hover,
.btn-sm:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================================================
   个人主页弹窗（频道内点击头像触发）
   ============================================================ */
#profileModal .modal-box {
  max-width: 520px !important;
  padding: 1.5rem 1.8rem 1.2rem !important;
}

.pm-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.pm-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.8rem;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.25);
}
.pm-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.pm-info { flex: 1; min-width: 0; }
.pm-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}
.pm-username {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.pm-signature {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 0.4rem;
}
.pm-signature:empty { display: none; }
.pm-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.pm-meta span { display: inline-flex; align-items: center; gap: 0.25rem; }

.pm-stats {
  display: flex;
  justify-content: space-around;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border-color);
}
.pm-stat-item { text-align: center; }
.pm-stat-num {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.15rem;
}
.pm-stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.pm-section {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border-color);
}
.pm-section:last-child { border-bottom: none; }
.pm-section h4 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.pm-section h4 i { color: var(--accent); }

.pm-detail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem 1rem;
}
.pm-detail .detail-item {
  display: flex;
  gap: 0.4rem;
  font-size: 0.8rem;
}
.pm-detail .detail-label {
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 50px;
}
.pm-detail .detail-value {
  color: var(--text-primary);
  word-break: break-word;
}
.pm-detail .detail-value a {
  color: var(--accent);
  text-decoration: none;
}
.pm-detail .detail-value a:hover { text-decoration: underline; }

.pm-bio {
  font-size: 0.83rem;
  color: var(--text-secondary);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.pm-channels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pm-actions {
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: center;
}
.pm-actions .btn {
  padding: 0.45rem 1.2rem;
  border-radius: 40px;
  font-size: 0.8rem;
  border: 1px solid var(--border-color);
  background: var(--bg-app);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s;
}
.pm-actions .btn.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.pm-actions .btn.btn-primary:hover { background: #1d4ed8; }

.empty-tip-small {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.3rem 0;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1024px) {
  .forum-layout {
    height: auto;
    min-height: calc(100vh - 50px - var(--safe-top));
    margin-top: calc(50px + var(--safe-top));
    padding: 0.4rem;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    overflow: visible;
    gap: 0.4rem;
  }
  .channel-sidebar { max-height: 200px; }
  #channelList { display: flex; gap: 0.4rem; overflow-x: auto; }
  .channel-group-header { display: none; }
  .channel-item { flex: 0 0 auto; min-width: 140px; }
  .chat-main { min-height: 60vh; }
  .drawer { width: 100%; max-width: 100%; }
  .msg { max-width: 72%; }
}

@media (max-width: 640px) {
  .msg { max-width: 82%; }

  /* ★ 移动端头像也严格约束 */
  .msg-avatar {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    font-size: 0.78rem !important;
  }
  .msg-avatar img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: cover;
    border-radius: 50%;
    display: block;
  }

  .msg-text {
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    line-height: 1.45;
  }
  .msg-head { gap: 0.3rem; margin-bottom: 0.2rem; }
  .msg-user { font-size: 0.72rem; }
  .msg-time { font-size: 0.58rem; }
  .msg-head .role-badge { font-size: 0.55rem; padding: 0 3px; }

  .message-input { padding: 0.5rem 0.6rem; gap: 0.3rem; }
  .bot-mention-btn { padding: 0.4rem 0.6rem; font-size: 0.68rem; }
  #msgInput { font-size: 0.82rem; padding: 0.5rem 0.7rem; }
  #sendMsgBtn { padding: 0.5rem 0.9rem; font-size: 0.75rem; }

  #chatHeader { padding: 0.5rem 0.7rem; gap: 0.3rem; }
  #chatHeader button { padding: 0.28rem 0.5rem; font-size: 0.62rem; }
  #chatHeader button i { font-size: 0.65rem; }
  #chatHeader #chatMemberCount { display: none; }

  .channel-item { padding: 0.45rem 0.55rem; }
  .channel-item .ch-name { font-size: 0.8rem; }

  .mention-dropdown {
    left: 0.5rem;
    width: calc(100% - 1rem);
    max-width: 260px;
  }

  /* 个人主页弹窗 */
  #profileModal .modal-box { padding: 1rem !important; }
  .pm-avatar { width: 60px; height: 60px; font-size: 1.5rem; }
  .pm-name { font-size: 1rem; }
  .pm-detail { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .msg { max-width: 86%; }
  .msg-text { font-size: 0.82rem; }
  #chatHeader button { padding: 0.25rem 0.4rem; }
  #chatHeader button span { display: none; }
}