/* ========== 聊天室 ========== */
.chat-main { padding: 40px 0 60px; }
.chat-container {
  max-width: 720px; margin: 0 auto;
  background: var(--dark-card);
  border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden;
  display: flex; flex-direction: column;
  height: calc(100vh - 360px); min-height: 480px; max-height: 720px;
}

/* Header */
.chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.02);
}
.chat-header-left { display: flex; align-items: center; gap: 12px; }
.chat-header-name { font-weight: 700; font-size: 15px; color: #fff; }
.chat-header-sub { font-size: 12px; color: rgba(255,255,255,.7); }
.chat-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  text-transform: uppercase; overflow: hidden;
  flex-shrink: 0;
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-settings-btn {
  background: transparent; border: 1px solid var(--border);
  color: #fff; border-radius: 8px; padding: 6px 12px;
  cursor: pointer; font-size: 13px; transition: all .15s;
}
.chat-settings-btn:hover { background: rgba(255,255,255,.05); border-color: var(--primary); }

/* Messages */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 18px 20px;
  display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth;
}
.chat-system {
  text-align: center; font-size: 12px; color: var(--text-light);
  padding: 6px 12px; background: rgba(255,255,255,.04);
  border-radius: 12px; align-self: center; max-width: 80%;
}
.chat-bubble { display: flex; gap: 10px; max-width: 80%; }
.chat-bubble.self { align-self: flex-end; flex-direction: row-reverse; }
.chat-bubble .chat-avatar { width: 36px; height: 36px; font-size: 14px; }
.chat-bubble-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chat-bubble.self .chat-bubble-body { align-items: flex-end; }
.chat-bubble-meta { font-size: 11px; color: var(--text-light); display: flex; gap: 6px; align-items: center; }
.chat-bubble-name { font-weight: 600; color: var(--primary-light); }
.chat-bubble-text {
  padding: 10px 14px; border-radius: 14px; font-size: 14px;
  line-height: 1.55; word-break: break-word; white-space: pre-wrap;
}
.chat-bubble:not(.self) .chat-bubble-text {
  background: rgba(255,255,255,.06); color: #fff;
  border-top-left-radius: 4px;
}
.chat-bubble.self .chat-bubble-text {
  background: #fff; color: #111; border-top-right-radius: 4px;
}

/* Input */
.chat-input-wrap { border-top: 1px solid var(--border); padding: 12px 16px; background: rgba(0,0,0,.15); }
.chat-input-row { display: flex; gap: 8px; }
.chat-input {
  flex: 1; background: rgba(255,255,255,.06);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; color: #fff; font-size: 14px;
  outline: none; transition: border-color .15s;
}
.chat-input:focus { border-color: var(--primary); }
.chat-input:disabled { opacity: .5; cursor: not-allowed; }
.chat-send {
  background: var(--primary); color: #fff; border: none;
  border-radius: 10px; padding: 10px 20px; font-weight: 600;
  cursor: pointer; font-size: 14px; transition: opacity .15s;
}
.chat-send:hover { opacity: .85; }
.chat-send:disabled { opacity: .4; cursor: not-allowed; }

/* Modal Tabs */
.chat-modal-tabs {
  display: flex; gap: 6px; margin-bottom: 16px;
  background: rgba(255,255,255,.04); border-radius: 8px; padding: 4px;
}
.chat-modal-tab {
  flex: 1; padding: 8px 12px; font-size: 14px; font-weight: 600;
  background: transparent; border: none; border-radius: 6px;
  color: rgba(255,255,255,.6); cursor: pointer; transition: all .15s;
}
.chat-modal-tab.active {
  background: rgba(255,255,255,.12); color: #fff;
}
.chat-modal-tab:hover:not(.active) { color: #fff; }

/* Modal */
.chat-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.chat-modal-bg { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.chat-modal-box {
  position: relative; z-index: 1;
  background: var(--dark-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px; width: 92%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.chat-modal-title { font-size: 20px; font-weight: 800; margin-bottom: 6px; color: #fff; }
.chat-modal-desc { color: var(--text-light); font-size: 13px; margin-bottom: 18px; }
.chat-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.chat-field span { font-size: 13px; color: var(--text-light); }
.chat-field span em { color: #ef5350; font-style: normal; margin-left: 2px; }
.chat-field input {
  background: rgba(255,255,255,.06); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; color: #fff;
  font-size: 14px; outline: none; transition: border-color .15s;
}
.chat-field input:focus { border-color: var(--primary); }
.chat-modal-preview {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: rgba(255,255,255,.03); border-radius: 10px; margin: 14px 0 18px;
}
.chat-modal-preview-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.chat-modal-preview-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-modal-preview-name { font-weight: 600; font-size: 14px; color: #fff; }
.chat-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.chat-btn { border: none; border-radius: 8px; padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity .15s; }
.chat-btn-primary { background: var(--primary); color: #fff; }
.chat-btn-primary:hover { opacity: .85; }
.chat-btn-ghost { background: transparent; color: #fff; border: 1px solid var(--border); }
.chat-btn-ghost:hover { background: rgba(255,255,255,.05); }
.chat-btn-danger { background: #ef5350; color: #fff; }
.chat-btn-danger:hover { background: #d32f2f; opacity: 1; }
.chat-modal-error { color: #ef5350; font-size: 12px; margin-top: 10px; min-height: 16px; }

/* Mobile */
@media (max-width: 620px) {
  .chat-main { padding: 20px 12px 40px; }
  .chat-container { height: calc(100vh - 320px); min-height: 520px; border-radius: 12px; }
  .chat-bubble { max-width: 90%; }
  .chat-header { padding: 12px 16px; }
  .chat-messages { padding: 14px 16px; }
}
