* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
}
.hidden { display: none !important; }

/* 认证弹窗 */
.auth-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
.auth-box {
  background: white; padding: 2.5rem; border-radius: 16px;
  width: 90%; max-width: 420px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.auth-box h2 { text-align: center; color: #333; margin-bottom: 1.5rem; }
.auth-tabs { display: flex; margin-bottom: 1.5rem; border-bottom: 2px solid #eee; }
.auth-tab {
  flex: 1; padding: 0.75rem; border: none; background: transparent;
  font-size: 1rem; cursor: pointer; color: #666; border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.auth-tab.active { color: #667eea; border-bottom-color: #667eea; font-weight: 600; }
.auth-form { display: none; flex-direction: column; gap: 1rem; }
.auth-form.active { display: flex; }
.auth-form input {
  padding: 0.875rem 1rem; border: 1px solid #e5e7eb; border-radius: 8px;
  font-size: 1rem;
}
.btn-primary {
  padding: 0.875rem; border: none; border-radius: 8px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white; font-weight: 600; cursor: pointer; font-size: 1rem;
  transition: transform .2s;
}
.btn-primary:hover { transform: translateY(-1px); }
.error-msg { color: #ef4444; font-size: 0.875rem; text-align: center; min-height: 1.25rem; }

/* 聊天界面 */
.chat-app {
  display: flex; flex-direction: column; height: 100vh; max-width: 100%; margin: 0 auto;
  background: white;
}
.chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.5rem; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}
.chat-header h1 { font-size: 1.25rem; font-weight: 600; }
.chat-header-left { display: flex; align-items: center; gap: 1rem; }
.chat-header-right { display: flex; align-items: center; gap: 0.75rem; }
.online-badge { font-size: 0.875rem; opacity: 0.9; }
.header-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: white; }
.admin-badge {
  background: #f59e0b; color: white; font-size: 0.75rem; padding: 2px 8px;
  border-radius: 999px; font-weight: 600;
}
.nav-btn, .btn-logout {
  background: rgba(255,255,255,.15); border: none; color: white;
  padding: 0.5rem 0.75rem; border-radius: 6px; cursor: pointer; font-size: 0.875rem;
}
.btn-logout:hover { background: rgba(255,255,255,.25); }

.message-list {
  flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem;
  background: #f7f8fa;
}
.message {
  display: flex; flex-direction: row; align-items: flex-end; gap: 8px; max-width: 70%;
}
.message.own { align-self: flex-end; flex-direction: row-reverse; }
.message-avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; cursor: pointer;
  background: #e5e7eb;
}
.message-content { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.message-bubble {
  padding: 0.75rem 1rem; border-radius: 18px; background: white; color: #1f2937; word-break: break-word;
}
.message.own .message-bubble { background: #667eea; color: white; }
.message-meta { font-size: 0.75rem; opacity: 0.6; padding: 0 4px; display: flex; gap: 0.5rem; align-items: center; }
.message.own .message-meta { justify-content: flex-end; }
.system-message { align-self: center; color: white; background: rgba(0,0,0,0.4); padding: 0.375rem 0.75rem; border-radius: 999px; font-size: 0.75rem; }

.chat-input-area {
  display: flex; gap: 0.75rem; padding: 1rem; border-top: 1px solid #e5e7eb; background: white;
}
#messageInput {
  flex: 1; padding: 0.75rem 1rem; border: 1px solid #e5e7eb; border-radius: 12px;
  resize: none; font-size: 1rem;
}
.btn-send {
  padding: 0 1.5rem; border: none; border-radius: 12px; background: #667eea;
  color: white; font-weight: 600; cursor: pointer;
}

.notification {
  position: fixed; top: 1rem; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.8); color: white; padding: 0.75rem 1.5rem;
  border-radius: 8px; z-index: 9999;
}

@media (max-width: 640px) {
  .chat-header { padding: 0.75rem 1rem; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
  .chat-header-right { flex-wrap: wrap; }
  .message { max-width: 85%; }
}