/* ==================== 聊天模块样式 ==================== */

/* --- 聊天按钮未读角标 --- */
.chat-mode-badge {
  position: absolute; top: -4px; right: -6px;
  background: #ef4444; color: white; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; line-height: 16px;
  border-radius: 8px; text-align: center; padding: 0 4px;
  display: none; z-index: 10;
}

/* --- Telegram风格已读双勾 --- */
.chat-msg-check {
  font-size: 12px; color: #999; margin-left: 4px; letter-spacing: -3px;
}
.chat-msg-check.read {
  color: #34b7f1;
}

/* --- 待发送附件预览 --- */
.chat-pending-files {
  display: flex; gap: 8px; padding: 8px 12px; overflow-x: auto;
  border-bottom: 1px solid var(--border, #e5e7eb); background: #f9fafb;
  flex-wrap: wrap;
}
.chat-pending-item {
  position: relative; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border, #e5e7eb); background: white;
  flex-shrink: 0;
}
.chat-pending-thumb {
  width: 80px; height: 80px; object-fit: cover; display: block;
}
.chat-pending-item.video {
  position: relative;
  background: #0f172a;
}
.chat-pending-video-badge {
  position: absolute; left: 6px; bottom: 6px; padding: 2px 6px;
  border-radius: 999px; background: rgba(15, 23, 42, 0.72); color: #fff;
  font-size: 10px; font-weight: 700;
}
.chat-pending-item.file {
  display: flex; align-items: center; gap: 6px; padding: 8px 28px 8px 10px;
  max-width: 200px;
}
.chat-pending-file-icon {
  width: 36px; height: 36px; border-radius: 6px;
  background: var(--primary, #6366f1); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.chat-pending-file-name {
  font-size: 12px; color: #333; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.chat-pending-remove {
  position: absolute; top: 2px; right: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,0.5); color: white; border: none;
  font-size: 14px; line-height: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.chat-pending-remove:hover { background: rgba(0,0,0,0.7); }

/* --- 聊天侧边栏 --- */
.chat-sidebar-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-sidebar-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-sidebar-header .chat-search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.82rem;
  background: var(--bg-body);
  outline: none;
  transition: border-color 0.2s;
}
.chat-sidebar-header .chat-search-input:focus {
  border-color: var(--primary);
}

.chat-new-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
.chat-new-btn:hover { background: var(--primary-hover); transform: scale(1.05); }
.chat-new-btn svg { width: 18px; height: 18px; }

.chat-user-bar {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-hover);
  flex-shrink: 0;
}
.chat-user-bar .chat-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.chat-user-bar .chat-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-user-bar .chat-user-name { flex: 1; font-size: 0.82rem; font-weight: 600; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-logout-btn {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: white; color: var(--text-secondary); font-size: 0.72rem;
  cursor: pointer; font-weight: 500; transition: all 0.2s;
}
.chat-logout-btn:hover { border-color: #ef4444; color: #ef4444; }

/* --- 会话列表 --- */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active {
  background: var(--primary-light);
}

.chat-item-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white; display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.chat-item-avatar.group {
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  border-radius: 14px;
}
.chat-item-avatar img { width: 100%; height: 100%; object-fit: cover; }

.chat-item-info {
  flex: 1; min-width: 0;
}
.chat-item-name {
  font-size: 0.88rem; font-weight: 600; color: var(--text-main);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.chat-item-preview {
  font-size: 0.76rem; color: var(--text-light);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 3px;
}

.chat-item-meta {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0;
}
.chat-item-time {
  font-size: 0.68rem; color: var(--text-light); white-space: nowrap;
}
.chat-unread-badge {
  min-width: 18px; height: 18px; border-radius: 10px;
  background: #ef4444; color: white; font-size: 0.65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}

.chat-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; color: var(--text-light); gap: 12px; padding: 40px 20px;
}
.chat-empty svg { width: 48px; height: 48px; opacity: 0.3; }
.chat-empty p { font-size: 0.85rem; text-align: center; }

/* --- 聊天室 --- */
.chat-room {
  display: flex; flex-direction: column; height: 100%; min-height: 0; background: white;
  position: relative;
}
/* 全屏拖拽覆盖层 */
.chat-drop-overlay {
  display: none; position: fixed; inset: 0; z-index: 9999;
  align-items: center; justify-content: center;
  background: rgba(99,102,241,0.12);
  backdrop-filter: blur(2px);
}
.chat-drop-overlay-content {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 40px 60px; border-radius: 20px;
  border: 3px dashed var(--primary, #6366f1);
  background: rgba(255,255,255,0.95); color: var(--primary, #6366f1);
  font-size: 18px; font-weight: 600;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

/* --- 上传进度覆盖层 --- */
.chat-upload-overlay {
  position: absolute; inset: 0; display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: rgba(0,0,0,0.4); border-radius: 12px;
}
.chat-upload-progress-ring { width: 44px; height: 44px; }
.chat-upload-progress-ring svg { width: 100%; height: 100%; }
.chat-upload-progress-ring circle:last-child {
  transition: stroke-dasharray 0.3s ease;
}
.chat-upload-pct { color: white; font-size: 12px; font-weight: 600; }
.chat-bubble-image { position: relative; }
.chat-message.pending { opacity: 0.9; }
.chat-msg-sending { color: var(--text-secondary); font-style: italic; }

.chat-room-header {
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  background: white;
}
.chat-room-header .chat-room-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white; display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem; font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.chat-room-header .chat-room-avatar.group { border-radius: 12px; background: linear-gradient(135deg, #3b82f6, #06b6d4); }
.chat-room-header .chat-room-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-room-title { flex: 1; }
.chat-room-name { font-size: 1rem; font-weight: 700; }
.chat-room-subtitle { font-size: 0.75rem; color: var(--text-light); margin-top: 1px; }
.chat-room-actions { display: flex; gap: 6px; }
.chat-room-actions button {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: white; color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.chat-room-actions button:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.chat-room-actions button svg { width: 18px; height: 18px; }

/* 消息列表 */
.chat-messages {
  flex: 1; min-height: 0; overflow-y: auto; padding: 16px 24px;
  display: flex; flex-direction: column; gap: 4px;
}

.chat-msg-date {
  text-align: center; padding: 12px 0; font-size: 0.72rem; color: var(--text-light);
}
.chat-msg-date span {
  background: var(--bg-body); padding: 4px 14px; border-radius: 12px;
}

.chat-message {
  display: flex; gap: 10px; max-width: 80%; padding: 3px 0;
  animation: msgIn 0.2s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.chat-messages.no-animate .chat-message {
  animation: none;
}

.chat-message.own { flex-direction: row-reverse; margin-left: auto; }
.chat-message.system {
  max-width: 100%; justify-content: center; padding: 8px 0;
}

.chat-msg-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white; display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; flex-shrink: 0; overflow: hidden; margin-top: 2px;
}
.chat-msg-avatar-spacer {
  width: 36px; flex-shrink: 0;
}
.chat-msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.chat-msg-body { min-width: 0; }

.chat-msg-sender {
  font-size: 0.72rem; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 3px; padding: 0 4px;
}
.chat-message.own .chat-msg-sender { text-align: right; }

.chat-bubble {
  padding: 10px 14px; border-radius: 16px; font-size: 0.88rem;
  line-height: 1.55; word-break: break-word; position: relative;
  background: var(--bg-body); color: var(--text-main);
}
.chat-message.own .chat-bubble {
  background: var(--primary); color: white;
  border-bottom-right-radius: 6px;
}
.chat-message:not(.own) .chat-bubble {
  border-bottom-left-radius: 6px;
}

.chat-bubble-image {
  max-width: 300px; border-radius: 12px; overflow: hidden; cursor: pointer;
}
.chat-bubble-image img { width: 100%; display: block; border-radius: 12px; }
.chat-bubble-video {
  max-width: 320px; border-radius: 12px; overflow: hidden; position: relative;
  background: rgba(15, 23, 42, 0.9);
}
.chat-bubble-video video {
  width: 100%; display: block; border-radius: 12px; background: #000;
  max-height: 320px;
}
.chat-video-preview-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 32px; height: 32px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.18);
  background: rgba(15, 23, 42, 0.72); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); transition: all 0.15s ease;
}
.chat-video-preview-btn:hover {
  background: rgba(30, 41, 59, 0.9); transform: scale(1.04);
}
.chat-video-preview-btn svg {
  width: 16px; height: 16px;
}

.chat-bubble-file {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-radius: 12px; background: var(--bg-body); border: 1px solid var(--border);
  cursor: pointer; min-width: 200px; transition: border-color 0.2s;
}
.chat-message.own .chat-bubble-file { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.2); }
.chat-bubble-file:hover { border-color: var(--primary); }
.chat-bubble-file-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.chat-message.own .chat-bubble-file-icon { background: rgba(255,255,255,0.2); color: white; }
.chat-bubble-file-icon svg { width: 18px; height: 18px; }
.chat-bubble-file-info { flex: 1; min-width: 0; }
.chat-bubble-file-name { font-size: 0.82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-bubble-file-size { font-size: 0.7rem; color: var(--text-light); margin-top: 1px; }
.chat-message.own .chat-bubble-file-name { color: white; }
.chat-message.own .chat-bubble-file-size { color: rgba(255,255,255,0.7); }
.chat-file-dl-btn {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary); background: var(--primary-light);
  transition: all 0.2s; text-decoration: none;
}
.chat-file-dl-btn:hover { background: var(--primary); color: white; }
.chat-file-dl-btn svg { width: 18px; height: 18px; }
.chat-message.own .chat-file-dl-btn { color: white; background: rgba(255,255,255,0.2); }
.chat-message.own .chat-file-dl-btn:hover { background: rgba(255,255,255,0.4); }

.chat-requirement-card {
  position: relative;
  overflow: hidden;
  width: min(380px, 74vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 22px;
  cursor: pointer;
  background:
    radial-gradient(circle at top right, rgba(99, 102, 241, 0.14), transparent 32%),
    linear-gradient(160deg, #ffffff 0%, #eef2ff 52%, #f8fafc 100%);
  border: 1px solid rgba(99, 102, 241, 0.18);
  box-shadow: 0 20px 40px rgba(79, 70, 229, 0.14);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.chat-requirement-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: 22px 0 0 22px;
  background: linear-gradient(180deg, #6366f1 0%, #38bdf8 100%);
  opacity: 0.9;
}
.chat-requirement-card:hover {
  transform: translateY(-2px);
  border-color: rgba(79, 70, 229, 0.34);
  box-shadow: 0 24px 44px rgba(79, 70, 229, 0.18);
}
.chat-message.own .chat-requirement-card {
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.16), transparent 34%),
    linear-gradient(160deg, rgba(255,255,255,0.24) 0%, rgba(255,255,255,0.14) 100%);
  border-color: rgba(255,255,255,0.22);
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.16);
}
.chat-requirement-card-top,
.chat-requirement-card-status-row,
.chat-requirement-card-meta,
.chat-requirement-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.chat-requirement-card-top {
  justify-content: space-between;
  padding-right: 44px;
}
.chat-requirement-card-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(79, 70, 229, 0.12);
  color: #4338ca;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.chat-message.own .chat-requirement-card-kicker {
  background: rgba(255,255,255,0.18);
  color: #fff;
}
.chat-requirement-card-link {
  font-size: 0.76rem;
  font-weight: 800;
  color: #6366f1;
}
.chat-message.own .chat-requirement-card-link { color: rgba(255,255,255,0.92); }
.chat-requirement-card-enter {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(79, 70, 229, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.18);
  color: #4f46e5;
  font-size: 1rem;
  font-weight: 900;
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.12);
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.chat-requirement-card:hover .chat-requirement-card-enter {
  transform: translate(2px, -2px);
  background: rgba(79, 70, 229, 0.18);
}
.chat-message.own .chat-requirement-card-enter {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.18);
  color: #fff;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.14);
}
.chat-requirement-card-title {
  font-size: 1.08rem;
  line-height: 1.32;
  font-weight: 800;
  color: #0f172a;
}
.chat-message.own .chat-requirement-card-title { color: #fff; }
.chat-requirement-card-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  color: #475569;
  font-size: 0.74rem;
  font-weight: 700;
}
.chat-requirement-card-chip.project {
  background: rgba(79, 70, 229, 0.1);
  color: #4338ca;
}
.chat-requirement-card-chip.module {
  background: rgba(14, 165, 233, 0.1);
  color: #0369a1;
}
.chat-message.own .chat-requirement-card-chip,
.chat-message.own .chat-requirement-card-chip.project,
.chat-message.own .chat-requirement-card-chip.module {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.92);
}
.chat-requirement-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  border: 1px solid transparent;
}
.chat-requirement-badge.status-pending { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.chat-requirement-badge.status-in_progress { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
.chat-requirement-badge.status-testing { background: #faf5ff; color: #9333ea; border-color: #e9d5ff; }
.chat-requirement-badge.status-completed { background: #ecfdf5; color: #059669; border-color: #a7f3d0; }
.chat-requirement-badge.priority-high { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.chat-requirement-badge.priority-medium { background: #fff7ed; color: #d97706; border-color: #fed7aa; }
.chat-requirement-badge.priority-low { background: #f0fdf4; color: #16a34a; border-color: #bbf7d0; }
.chat-message.own .chat-requirement-badge {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.18);
  color: #fff;
}
.chat-requirement-card-assignees {
  font-size: 0.78rem;
  font-weight: 700;
  color: #4f46e5;
}
.chat-message.own .chat-requirement-card-assignees { color: rgba(255,255,255,0.9); }
.chat-requirement-card-desc {
  font-size: 0.82rem;
  line-height: 1.6;
  color: #475569;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.chat-message.own .chat-requirement-card-desc { color: rgba(255,255,255,0.88); }
.chat-requirement-card-cover {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255,255,255,0.74);
}
.chat-requirement-card-cover img {
  display: block;
  width: 100%;
  max-height: 184px;
  object-fit: cover;
}
.chat-requirement-card-footer {
  justify-content: space-between;
  margin-top: 2px;
  padding: 11px 14px;
  border-radius: 16px;
  background: rgba(79, 70, 229, 0.08);
  color: #4f46e5;
  font-weight: 800;
}
.chat-message.own .chat-requirement-card-footer {
  color: rgba(255,255,255,0.94);
  background: rgba(255,255,255,0.14);
}
.chat-requirement-card-footer-text { font-size: 0.78rem; }
.chat-requirement-card-footer-arrow { font-size: 1rem; line-height: 1; }

/* 引用回复 */
/* 引用回复 */
.chat-bubble-reply {
  padding: 6px 10px; margin-bottom: 6px;
  border-left: 3px solid var(--primary);
  background: rgba(0,0,0,0.04); border-radius: 0 8px 8px 0;
  font-size: 0.78rem; color: var(--text-secondary);
  cursor: pointer; transition: background 0.15s;
}
.chat-bubble-reply:hover { background: rgba(0,0,0,0.08); }
.chat-message.own .chat-bubble-reply:hover { background: rgba(255,255,255,0.25); }

/* 引用定位高亮动画 */
@keyframes msgHighlight {
  0% { background: rgba(99,102,241,0.2); }
  100% { background: transparent; }
}
.chat-message.highlight .chat-bubble {
  animation: msgHighlight 2s ease-out;
}
.chat-message.own .chat-bubble-reply {
  border-left-color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.85);
}
.chat-bubble-reply-name { font-weight: 600; margin-bottom: 2px; }
.chat-bubble-reply-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 250px; }

/* @提及 */
.chat-mention { color: var(--primary); font-weight: 600; cursor: pointer; }
.chat-message.own .chat-mention { color: rgba(255,255,255,0.9); text-decoration: underline; }

/* 消息元信息 */
.chat-msg-meta {
  display: flex; align-items: center; gap: 6px; padding: 2px 4px;
  font-size: 0.68rem; color: var(--text-light);
}
.chat-message.own .chat-msg-meta { justify-content: flex-end; }
.chat-msg-edited { font-style: italic; }

/* 消息操作（hover显示） */
.chat-msg-actions {
  display: flex; position: absolute; bottom: calc(100% + 6px);
  background: white; border: 1px solid var(--border);
  border-radius: 10px; padding: 2px; box-shadow: var(--shadow-md);
  z-index: 5; gap: 2px; opacity: 0; visibility: hidden;
  pointer-events: none; transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}
.chat-message:not(.own) .chat-msg-actions { right: -4px; }
.chat-message.own .chat-msg-actions { left: -4px; }
.chat-bubble { position: relative; }
.chat-bubble::before {
  content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: 12px;
}
.chat-bubble:hover .chat-msg-actions,
.chat-bubble.show-actions .chat-msg-actions {
  opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0);
}

.chat-msg-action-btn {
  width: 28px; height: 28px; border: none; border-radius: 8px;
  background: transparent; cursor: pointer; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.chat-msg-action-btn:hover { background: var(--bg-body); color: var(--primary); }
.chat-msg-action-btn svg { width: 14px; height: 14px; }

.chat-msg-recalled {
  font-style: italic; color: var(--text-light); font-size: 0.82rem;
  padding: 8px 14px; background: var(--bg-body); border-radius: 12px;
}
.chat-message.system .chat-msg-system {
  font-size: 0.76rem; color: var(--text-light); background: var(--bg-body);
  padding: 4px 14px; border-radius: 12px;
}

/* 加载更多 */
.chat-load-more {
  text-align: center; padding: 12px 0;
}
.chat-load-more-hint {
  color: var(--text-secondary); font-size: 0.78rem;
}
.chat-load-more-btn {
  border: none; background: var(--bg-body); color: var(--text-secondary);
  padding: 6px 16px; border-radius: 12px; font-size: 0.78rem; cursor: pointer;
  transition: all 0.2s;
}
.chat-load-more-btn:hover { background: var(--primary-light); color: var(--primary); }

/* --- 输入区域 --- */
.chat-input-area {
  padding: 12px 24px 16px; border-top: 1px solid var(--border);
  background: white; flex-shrink: 0;
}

.chat-reply-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin-bottom: 8px;
  background: var(--bg-body); border-radius: 10px;
  border-left: 3px solid var(--primary); font-size: 0.8rem;
}
.chat-reply-bar-content { flex: 1; min-width: 0; }
.chat-reply-bar-name { font-weight: 600; color: var(--primary); }
.chat-reply-bar-text { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-reply-bar-close {
  width: 24px; height: 24px; border: none; background: transparent;
  cursor: pointer; color: var(--text-light); display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: all 0.15s;
}
.chat-reply-bar-close:hover { background: var(--border); color: var(--text-main); }

.chat-edit-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin-bottom: 8px;
  background: #fef3c7; border-radius: 10px;
  border-left: 3px solid #f59e0b; font-size: 0.8rem;
}
.chat-edit-bar-text { flex: 1; color: #92400e; font-weight: 500; }

.chat-input-row {
  display: flex; gap: 8px; align-items: flex-end; min-height: 40px;
}

.chat-input-wrapper {
  flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--bg-body); transition: border-color 0.2s;
}
.chat-input-wrapper:focus-within { border-color: var(--primary); }

.chat-input {
  width: 100%; height: 40px; padding: 10px 14px; border: none; background: transparent;
  font-size: 0.88rem; resize: none; outline: none; font-family: inherit;
  line-height: 1.5; max-height: 120px; min-height: 40px;
  box-sizing: border-box; overflow-y: auto;
}

.chat-input-toolbar {
  display: flex; align-items: center; padding: 4px 8px; gap: 2px;
}
.chat-toolbar-btn {
  width: 32px; height: 32px; border: none; background: transparent;
  border-radius: 8px; cursor: pointer; color: var(--text-light);
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.chat-toolbar-btn:hover { background: var(--bg-hover); color: var(--primary); }
.chat-toolbar-btn svg { width: 18px; height: 18px; }

.chat-send-btn {
  width: 44px; height: 44px; border-radius: 14px; border: none;
  background: var(--primary); color: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.2s;
}
.chat-send-btn:hover { background: var(--primary-hover); transform: scale(1.05); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.chat-send-btn svg { width: 20px; height: 20px; }

/* @提及下拉 */
.chat-mention-dropdown {
  position: absolute; bottom: 100%; left: 0; right: 0;
  background: white; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 200px; overflow-y: auto;
  margin-bottom: 4px; z-index: 20; display: none;
}
.chat-mention-dropdown.show { display: block; }
.chat-mention-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; cursor: pointer; transition: background 0.15s;
}
.chat-mention-item:hover, .chat-mention-item.active { background: var(--primary-light); }
.chat-mention-item-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 700; overflow: hidden;
}
.chat-mention-item-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-mention-item-name { font-size: 0.82rem; font-weight: 500; }

/* --- 新建聊天弹窗 --- */
.chat-type-toggle {
  display: flex; background: var(--bg-body); border-radius: 10px; padding: 3px; gap: 2px;
}
.chat-type-toggle .mode-btn { flex: 1; justify-content: center; }

.user-search-results {
  max-height: 200px; overflow-y: auto; margin-top: 8px;
}
.user-search-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  transition: background 0.15s;
}
.user-search-item:hover { background: var(--bg-hover); }
.user-search-item.selected { background: var(--primary-light); }
.user-search-item-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white; display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.user-search-item-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-search-item-info { flex: 1; }
.user-search-item-name { font-size: 0.88rem; font-weight: 600; }
.user-search-item-username { font-size: 0.75rem; color: var(--text-light); }

.selected-user-list {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px;
}
.selected-user-tag {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 8px 4px 4px; border-radius: 20px;
  background: var(--primary-light); font-size: 0.78rem; color: var(--primary); font-weight: 500;
}
.selected-user-tag-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; font-weight: 700; overflow: hidden;
}
.selected-user-tag-avatar img { width: 100%; height: 100%; object-fit: cover; }
.selected-user-tag-remove {
  width: 16px; height: 16px; border: none; background: transparent;
  cursor: pointer; color: var(--text-light); display: flex;
  align-items: center; justify-content: center; border-radius: 50%;
  font-size: 0.7rem; margin-left: 2px;
}
.selected-user-tag-remove:hover { color: #ef4444; }

.chat-forward-preview {
  padding: 10px 12px; border-radius: 12px; background: var(--bg-body);
  border: 1px solid var(--border); margin-bottom: 12px;
}
.chat-forward-preview-label {
  font-size: 0.72rem; color: var(--text-light); margin-bottom: 6px;
}
.chat-forward-preview-text {
  font-size: 0.84rem; color: var(--text-main); line-height: 1.5;
  word-break: break-word;
}
.chat-forward-list {
  display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto;
}
.chat-forward-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 12px; cursor: pointer;
  transition: all 0.15s ease; background: white;
}
.chat-forward-item:hover {
  border-color: var(--primary); background: var(--primary-light);
}
.chat-forward-item.active {
  border-color: var(--primary); background: var(--primary-light);
  box-shadow: 0 0 0 1px rgba(99,102,241,0.12);
}
.chat-forward-item-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  overflow: hidden; background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white; display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700;
}
.chat-forward-item-avatar.group { border-radius: 12px; }
.chat-forward-item-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-forward-item-info { min-width: 0; flex: 1; }
.chat-forward-item-name {
  font-size: 0.86rem; font-weight: 600; color: var(--text-main);
}
.chat-forward-item-meta {
  font-size: 0.74rem; color: var(--text-light); margin-top: 2px;
}
.chat-forward-empty {
  padding: 18px 12px; text-align: center; color: var(--text-light); font-size: 0.82rem;
}

.chat-toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(12px);
  background: rgba(15, 23, 42, 0.9); color: white; padding: 10px 14px; border-radius: 999px;
  font-size: 0.8rem; box-shadow: 0 10px 28px rgba(15, 23, 42, 0.24);
  z-index: 120; opacity: 0; pointer-events: none; transition: all 0.18s ease;
  max-width: calc(100vw - 32px); text-align: center;
}
.chat-toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* --- 群设置 --- */
.group-member-list {
  display: flex; flex-direction: column; gap: 4px; margin-top: 8px; max-height: 200px; overflow-y: auto;
}
.group-member-item {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border-radius: 10px; background: var(--bg-hover);
}
.group-member-item-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white; display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; overflow: hidden;
}
.group-member-item-avatar img { width: 100%; height: 100%; object-fit: cover; }
.group-member-item-name { flex: 1; font-size: 0.85rem; font-weight: 500; }
.group-member-item-role { font-size: 0.7rem; color: var(--primary); font-weight: 600; }
.group-member-remove-btn {
  width: 24px; height: 24px; border: none; border-radius: 50%;
  background: transparent; color: var(--text-light); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.group-member-remove-btn:hover { background: #fef2f2; color: #ef4444; }

/* --- 聊天室空状态 --- */
.chat-room-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; color: var(--text-light); gap: 16px; padding: 40px;
}
.chat-room-empty svg { width: 64px; height: 64px; opacity: 0.2; }
.chat-room-empty p { font-size: 0.92rem; }

/* --- 响应式 --- */
@media (min-width: 769px) {
  .chat-room-back-btn { display: none; }
}

@media (max-width: 768px) {
  /* 禁止横向滚动 */
  body.chat-mode {
    overflow-x: hidden;
    overflow-y: hidden;
    width: 100%;
    max-width: 100vw;
  }
  body.chat-mode .app-container {
    overflow: hidden;
    max-width: 100vw;
  }

  /* ===== 聊天模式：侧边栏变全屏会话列表 ===== */
  body.chat-mode .sidebar {
    width: 100%;
    height: var(--chat-app-height, 100svh);
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 80;
    border: none;
    flex-direction: column;
  }
  body.chat-mode .sidebar-header {
    height: 56px;
    padding: 0 12px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
  }
  body.chat-mode .sidebar-content {
    position: static;
    flex: 1;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    box-shadow: none;
    max-height: none;
    padding: 0;
    background: white;
    overflow: hidden;
  }
  body.chat-mode .mobile-project-btn { display: none !important; }
  body.chat-mode #reqSidebarSection { display: none !important; }
  body.chat-mode #chatSidebarContent {
    display: flex !important;
    height: 100%;
  }

  /* 聊天模式下隐藏主内容（无选中会话时） */
  body.chat-mode .main-content {
    display: none;
  }
  /* 有会话打开时：聊天室全屏，隐藏侧边栏 */
  body.chat-mode.chat-room-open .sidebar {
    display: none;
  }
  body.chat-mode.chat-room-open {
    width: 100%;
    overflow: hidden;
  }
  body.chat-mode.chat-room-open .main-content {
    display: flex;
    position: fixed;
    top: var(--chat-app-offset-top, 0px);
    left: 0;
    right: 0;
    bottom: auto;
    z-index: 90;
    background: white;
    flex-direction: column;
    height: var(--chat-app-height, 100svh);
    min-height: var(--chat-app-height, 100svh);
    overflow: hidden;
    overscroll-behavior: none;
  }

  /* ===== 聊天室内部 ===== */
  .chat-room {
    height: 100%;
    max-width: 100vw;
    overflow: hidden;
    min-height: 0;
    overscroll-behavior: none;
  }
  .chat-room-header {
    padding: 10px 12px;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 5;
    max-width: 100vw;
    box-sizing: border-box;
  }
  .chat-room-header .chat-room-avatar {
    width: 36px; height: 36px; font-size: 0.75rem;
  }
  .chat-room-header .chat-room-avatar.group { border-radius: 10px; }
  .chat-room-name { font-size: 0.92rem; }
  .chat-room-subtitle { font-size: 0.7rem; }
  .chat-room-actions button {
    width: 32px; height: 32px; border-radius: 8px;
  }

  /* 返回按钮 */
  .chat-room-back-btn {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border: none; background: transparent;
    color: var(--text-secondary); cursor: pointer; border-radius: 8px;
    flex-shrink: 0;
  }
  .chat-room-back-btn:active { background: var(--bg-hover); }

  /* 消息区 */
  .chat-messages {
    padding: 10px 12px;
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
    max-width: 100vw;
    box-sizing: border-box;
    min-height: 0;
  }
  .chat-msg-avatar { width: 32px; height: 32px; font-size: 0.65rem; }
  .chat-msg-avatar-spacer { width: 32px; }
  .chat-msg-body { min-width: 0; max-width: calc(100vw - 72px); }
  .chat-bubble { padding: 9px 12px; font-size: 0.84rem; border-radius: 14px; max-width: 100%; }
  .chat-message.own .chat-bubble { border-bottom-right-radius: 5px; }
  .chat-message:not(.own) .chat-bubble { border-bottom-left-radius: 5px; }
  .chat-bubble-file { min-width: 0; max-width: 100%; padding: 8px 10px; gap: 8px; }
  .chat-bubble-file-icon { width: 32px; height: 32px; }
  .chat-bubble-file-info { flex: 1; min-width: 0; }
  .chat-bubble-reply-text { max-width: 60vw; }
  .chat-bubble-image { max-width: min(220px, 65vw); }
  .chat-bubble-image img { max-width: 100%; }
  .chat-bubble-video { max-width: min(240px, 70vw); }
  .chat-bubble-video video { max-height: 220px; }
  .chat-video-preview-btn { width: 28px; height: 28px; top: 6px; right: 6px; }
  .chat-requirement-card {
    width: min(292px, 76vw);
    padding: 13px;
    border-radius: 18px;
    gap: 10px;
  }
  .chat-requirement-card-title { font-size: 0.96rem; }
  .chat-requirement-card-enter {
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    font-size: 0.92rem;
  }
  .chat-requirement-card-link,
  .chat-requirement-card-footer-text { font-size: 0.74rem; }
  .chat-requirement-card-desc { font-size: 0.78rem; -webkit-line-clamp: 2; }
  .chat-requirement-card-cover img { max-height: 136px; }

  /* 消息/气泡不溢出 */
  .chat-message { width: auto; max-width: 100%; overflow: visible; }
  .chat-message.own { justify-content: flex-end; }
  .chat-bubble { max-width: 100%; overflow-wrap: break-word; word-break: break-word; }
  .chat-bubble-file-name {
    max-width: none;
    white-space: normal;
    line-height: 1.28;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  /* 输入区 */
  .chat-input-area {
    padding: 6px 10px calc(env(safe-area-inset-bottom, 8px) + 6px);
    max-width: 100vw;
    box-sizing: border-box;
    flex-shrink: 0;
  }
  .chat-input { height: 38px; font-size: 16px; padding: 8px 12px; min-height: 38px; max-height: 96px; } /* 16px 防止 iOS 缩放 */
  .chat-input-toolbar { padding: 2px 6px; }
  .chat-toolbar-btn { width: 28px; height: 28px; }
  .chat-toolbar-btn svg { width: 16px; height: 16px; }
  .chat-send-btn { width: 40px; height: 40px; border-radius: 12px; }
  .chat-send-btn svg { width: 18px; height: 18px; }

  /* 回复/编辑栏 */
  .chat-reply-bar { padding: 6px 10px; font-size: 0.76rem; }
  .chat-edit-bar { padding: 6px 10px; font-size: 0.76rem; }

  /* 待发送附件 */
  .chat-pending-files { padding: 6px 10px; }
  .chat-pending-thumb { width: 64px; height: 64px; }
  .chat-toast { bottom: calc(env(safe-area-inset-bottom, 0px) + 82px); }

  /* 操作按钮 - 移动端长按替代 hover */
  .chat-bubble:hover .chat-msg-actions {
    opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(4px);
  }
  .chat-bubble.show-actions .chat-msg-actions {
    opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0);
  }

  /* 会话列表 */
  .chat-item { padding: 10px 14px; gap: 10px; }
  .chat-item-avatar { width: 40px; height: 40px; font-size: 0.8rem; }
  .chat-item-name { font-size: 0.85rem; }
  .chat-item-preview { font-size: 0.74rem; }

  /* 搜索栏 */
  .chat-sidebar-header { padding: 10px 12px; }
  .chat-search-input { font-size: 0.8rem; padding: 8px 10px; }
  .chat-new-btn { width: 34px; height: 34px; border-radius: 8px; }

  /* 底部用户栏 */
  .chat-user-bar { padding: 8px 14px; }

  /* 提及下拉 */
  .chat-mention-dropdown { border-radius: 10px; }
  .chat-mention-item { padding: 8px 12px; }

  /* 拖拽覆盖层 */
  .chat-drop-overlay-content { padding: 30px 40px; font-size: 16px; }

  /* 空状态 */
  .chat-room-empty { padding: 30px 20px; }
  .chat-room-empty svg { width: 48px; height: 48px; }
  .chat-room-empty p { font-size: 0.85rem; }
  .chat-empty { padding: 30px 16px; }
  .chat-empty svg { width: 40px; height: 40px; }
  .chat-empty p { font-size: 0.8rem; }
}
