* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #fff8ed;
  --primary: #ff8a3d;
  --primary-dark: #f06b12;
  --primary-light: #ffb77a;
  --ai-bg: #fff1d6;
  --ai-border: #ffd9a8;
  --user-bg: #e3f2ff;
  --user-border: #b3d9ff;
  --text: #2b2b2b;
  --muted: #8a8a8a;
  --border: #ffd9a8;
  --shadow-sm: 0 2px 8px rgba(255, 138, 61, 0.08);
  --shadow-md: 0 4px 16px rgba(255, 138, 61, 0.12);
  --shadow-lg: 0 8px 32px rgba(255, 138, 61, 0.16);
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(255, 183, 122, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 85% 60%, rgba(255, 138, 61, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 50% 90%, rgba(255, 217, 168, 0.12) 0%, transparent 40%);
}

/* ============ 登录/注册页 ============ */
.auth-page {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: linear-gradient(135deg, #fff8ed 0%, #ffe8d0 50%, #ffd4a8 100%);
  z-index: 100;
  padding: 24px 20px;
  overflow-y: auto;
}

.auth-container {
  background: #fff;
  border-radius: 18px;
  padding: 36px 34px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(255, 138, 61, 0.28);
  animation: fadeInUp 0.5s ease-out;
  margin: auto;
  flex-shrink: 0;
}

.auth-logo {
  font-size: 56px;
  text-align: center;
  margin-bottom: 8px;
  animation: logoBounce 2s infinite ease-in-out;
}

@keyframes logoBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.auth-title {
  text-align: center;
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: 1px;
}

.auth-subtitle {
  text-align: center;
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
}

.auth-tabs {
  display: flex;
  background: #fff8ed;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.auth-tab.active {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 138, 61, 0.3);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
  animation: fadeInUp 0.3s ease-out;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #5a4a3a;
  margin-bottom: 6px;
}

.form-group .req {
  color: #e74c3c;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"] {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  background: #fffdf7;
  transition: all 0.3s ease;
  outline: none;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255, 138, 61, 0.15);
  background: #fff;
}

.radio-group {
  display: flex;
  gap: 10px;
  padding: 6px 0;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 10px;
  border: 2px solid var(--border);
  transition: all 0.2s ease;
}

.radio-label:hover {
  border-color: var(--primary);
}

.radio-label input {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
}

.form-error {
  color: #e74c3c;
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 8px;
  font-weight: 500;
}

.auth-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 4px;
  transition: all 0.3s ease;
  box-shadow: 0 6px 20px rgba(255, 138, 61, 0.35);
  margin-top: 4px;
}

.auth-btn:hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(255, 138, 61, 0.45);
}

.auth-btn:active {
  transform: translateY(0) scale(0.98);
}

/* ============ 主应用 ============ */
.main-app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: linear-gradient(135deg, #ffb77a 0%, #ff8a3d 50%, #f06b12 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(240, 107, 18, 0.25);
  position: sticky;
  top: 0;
  z-index: 10;
  animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.logo {
  font-size: 38px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
  animation: logoBounce 3s infinite ease-in-out;
}

.title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
  letter-spacing: 0.5px;
}

.subtitle {
  margin: 3px 0 0;
  font-size: 13px;
  opacity: 0.95;
  letter-spacing: 0.3px;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  background: rgba(255,255,255,0.25);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.user-info:hover {
  background: rgba(255,255,255,0.4);
  transform: scale(1.05);
}

.user-avatar {
  font-size: 19px;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.3);
}

.user-badge.admin {
  background: #ff4757;
  font-weight: 700;
}

.clear-btn {
  border: none;
  background: rgba(255,255,255,0.25);
  color: #fff;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 12px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
}

.clear-btn:hover {
  background: rgba(255,255,255,0.4);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.clear-btn:active { transform: scale(0.96); }

/* ============ 语音朗读开关 ============ */
.tts-toggle-btn {
  border: none;
  background: rgba(255,255,255,0.25);
  color: #fff;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 12px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
}

.tts-toggle-btn:hover {
  background: rgba(255,255,255,0.4);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.tts-toggle-btn:active { transform: scale(0.96); }

.tts-toggle-btn.active {
  background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
  color: #2d5a3d;
  box-shadow: 0 4px 16px rgba(132, 250, 176, 0.5);
  animation: ttsPulse 2s infinite;
}

@keyframes ttsPulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(132, 250, 176, 0.5); }
  50% { box-shadow: 0 4px 28px rgba(132, 250, 176, 0.8); }
}

.tts-toggle-btn .tts-icon {
  font-size: 17px;
  line-height: 1;
}

/* ============ 聊天区 ============ */
.chat-box {
  flex: 1;
  overflow-y: auto;
  padding: 26px 22px 210px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
  position: relative;
  z-index: 1;
}

.chat-box::-webkit-scrollbar { width: 6px; }
.chat-box::-webkit-scrollbar-track { background: transparent; }
.chat-box::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, var(--primary-light), var(--primary));
  border-radius: 3px;
}

.message {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  max-width: 100%;
  animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message .avatar {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: transform 0.3s ease;
}

.message:hover .avatar { transform: scale(1.08); }

.message .bubble {
  max-width: 80%;
  padding: 13px 17px;
  border-radius: 22px;
  font-size: 15px;
  line-height: 1.75;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  transition: box-shadow 0.3s ease;
}

.message:hover .bubble {
  box-shadow: 0 4px 18px rgba(0,0,0,0.08);
}

.message.ai { justify-content: flex-start; }
.message.ai .bubble {
  background: linear-gradient(135deg, #fff8ed 0%, #fff1d6 100%);
  color: var(--text);
  border-bottom-left-radius: 6px;
  border: 1.5px solid var(--ai-border);
}

.message.ai .bubble strong {
  color: var(--primary-dark);
  font-weight: 700;
}

.message.ai .bubble::before {
  content: '';
  position: absolute;
  bottom: 5px;
  left: -7px;
  width: 12px;
  height: 12px;
  background: #fff1d6;
  border-left: 1.5px solid var(--ai-border);
  border-bottom: 1.5px solid var(--ai-border);
  transform: rotate(45deg);
  border-bottom-left-radius: 3px;
}

.message.user { flex-direction: row-reverse; justify-content: flex-start; }
.message.user .avatar { background: linear-gradient(135deg, #d0e8ff, #b3d9ff); }
.message.user .bubble {
  background: linear-gradient(135deg, #f0f8ff 0%, #dceeff 100%);
  color: #123;
  border-bottom-right-radius: 6px;
  border: 1.5px solid var(--user-border);
}

.message.user .bubble::before {
  content: '';
  position: absolute;
  bottom: 5px;
  right: -7px;
  width: 12px;
  height: 12px;
  background: #dceeff;
  border-right: 1.5px solid var(--user-border);
  border-bottom: 1.5px solid var(--user-border);
  transform: rotate(45deg);
  border-bottom-right-radius: 3px;
}

/* ============ 快捷问题 ============ */
.quick-questions {
  position: fixed;
  bottom: 72px;
  left: 0;
  right: 0;
  display: flex;
  gap: 10px;
  padding: 12px 22px 14px;
  overflow-x: auto;
  z-index: 15;
  scroll-behavior: smooth;
  background: linear-gradient(to top, rgba(255,248,237,0.9) 0%, rgba(255,248,237,0) 100%);
}

.quick-questions::-webkit-scrollbar { display: none; }

.quick-questions .chip {
  flex: 0 0 auto;
  background: #fff;
  border: 2px solid var(--primary);
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(255, 138, 61, 0.12);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-questions .chip .chip-icon {
  font-size: 16px;
  line-height: 1;
  transition: transform 0.3s ease;
}

.quick-questions .chip:hover .chip-icon {
  transform: scale(1.2);
}

.quick-questions .chip:hover {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(255, 138, 61, 0.25);
  border-color: transparent;
}

.quick-questions .chip:active {
  transform: translateY(-1px) scale(0.98);
}

/* ============ 输入栏 ============ */
.input-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: linear-gradient(to top, #fff8ed 70%, rgba(255,248,237,0));
  z-index: 20;
}

.voice-btn {
  font-size: 24px;
  padding: 6px;
  cursor: pointer;
  user-select: none;
  border-radius: 50%;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
}

.voice-btn:hover {
  background: rgba(255, 138, 61, 0.1);
  transform: scale(1.1);
}

.voice-btn.recording {
  background: linear-gradient(135deg, #ff5f6d, #ffc371);
  color: #fff;
  animation: pulse-recording 1.2s infinite;
}

@keyframes pulse-recording {
  0% { box-shadow: 0 0 0 0 rgba(255, 95, 109, 0.7); transform: scale(1); }
  50% { box-shadow: 0 0 0 12px rgba(255, 95, 109, 0); transform: scale(1.05); }
  100% { box-shadow: 0 0 0 0 rgba(255, 95, 109, 0); transform: scale(1); }
}

#userInput {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 11px 16px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  background: #fffdf7;
  max-height: 130px;
  min-height: 46px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  line-height: 1.5;
}

#userInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255, 138, 61, 0.15);
  background: #fff;
}

.send-btn {
  border: none;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 11px 22px;
  border-radius: 20px;
  cursor: pointer;
  min-width: 86px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 16px rgba(255, 138, 61, 0.35);
  letter-spacing: 0.5px;
}

.send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(255, 138, 61, 0.45);
}

.send-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
}

.send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.7;
}

/* ============ 加载动画 ============ */
.loading {
  position: fixed;
  bottom: 166px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  font-size: 20px;
  color: var(--primary-dark);
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  padding: 10px 22px;
  border-radius: 28px;
  box-shadow: 0 6px 24px rgba(255, 138, 61, 0.22);
  backdrop-filter: blur(10px);
  animation: fadeInUp 0.3s ease-out;
}

.loading span {
  animation: loadingBounce 1.2s infinite ease-in-out;
  display: inline-block;
  font-weight: bold;
}

.loading span:nth-child(2) { animation-delay: 0.2s; }
.loading span:nth-child(3) { animation-delay: 0.4s; }

.loading .loading-text {
  font-size: 14px;
  margin-left: 6px;
  color: var(--primary-dark);
  font-weight: 500;
  letter-spacing: 0.5px;
  animation: none;
}

@keyframes loadingBounce {
  0%, 80%, 100% { transform: translateY(0) scale(1); opacity: 0.4; }
  40% { transform: translateY(-10px) scale(1.2); opacity: 1; }
}

.hidden { display: none !important; }

/* ============ 滚动按钮 ============ */
.scroll-down {
  position: fixed;
  right: 22px;
  bottom: 240px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 138, 61, 0.35);
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: fadeInUp 0.3s ease-out;
}

.scroll-down:hover {
  transform: translateY(-3px) scale(1.08);
  box-shadow: 0 8px 28px rgba(255, 138, 61, 0.5);
}

.scroll-down:active {
  transform: translateY(0) scale(1);
}

/* ============ 模态框 ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: #fff;
  border-radius: 22px;
  padding: 30px;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  animation: modalSlideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(25px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-content h2 {
  margin: 0 0 20px;
  font-size: 21px;
  color: var(--primary-dark);
  font-weight: 700;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #fff3e6;
  color: var(--primary-dark);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--primary);
  color: #fff;
  transform: rotate(90deg);
}

/* ============ 个人中心 ============ */
.profile-section {
  margin-bottom: 20px;
}

.profile-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px dashed #ffe4c4;
  font-size: 14px;
}

.profile-field span {
  color: var(--muted);
}

.profile-field strong {
  color: var(--primary-dark);
  font-weight: 700;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.profile-btn {
  padding: 11px 16px;
  border: 2px solid var(--primary);
  background: #fff;
  color: var(--primary-dark);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}

.profile-btn:hover {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(255, 138, 61, 0.3);
}

.profile-btn:active {
  transform: translateY(0) scale(0.98);
}

.profile-btn.admin-btn {
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: #fff;
  border-color: transparent;
}

.profile-btn.admin-btn:hover {
  background: linear-gradient(135deg, #ee5a24, #c44569);
}

.profile-btn.danger {
  background: #fff;
  color: #e74c3c;
  border-color: #e74c3c;
}

.profile-btn.danger:hover {
  background: #e74c3c;
  color: #fff;
  box-shadow: 0 6px 18px rgba(231, 76, 60, 0.3);
}

/* ============ 管理员后台 ============ */
.admin-modal {
  max-width: 880px;
}

.admin-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  background: #fff8ed;
  border-radius: 12px;
  padding: 4px;
}

.admin-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.admin-tab.active {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
}

.admin-panel {
  display: none;
}

.admin-panel.active {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

.admin-summary {
  padding: 14px 18px;
  background: linear-gradient(135deg, #fff8ed, #fff1d6);
  border-radius: 14px;
  font-size: 14px;
  color: #5a4a3a;
  font-weight: 600;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.user-table {
  border: 2px solid #ffe4c4;
  border-radius: 14px;
  overflow: hidden;
}

.user-table-header {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr 1fr 1fr 2fr;
  gap: 8px;
  padding: 13px 16px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.user-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr 1fr 1fr 2fr;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #fff0e0;
  align-items: center;
  font-size: 14px;
  transition: background 0.2s ease;
}

.user-row:last-child {
  border-bottom: none;
}

.user-row:hover {
  background: #fffaf2;
}

.user-cell {
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-cell.small {
  font-size: 12px;
  color: var(--muted);
}

.user-cell.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}

.badge.admin {
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: #fff;
}

.badge.user {
  background: #e3f2ff;
  color: #2980b9;
}

.action-btn {
  padding: 5px 10px;
  border: 1.5px solid var(--primary);
  background: #fff;
  color: var(--primary-dark);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.action-btn:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-1px);
}

.action-btn.danger {
  border-color: #e74c3c;
  color: #e74c3c;
}

.action-btn.danger:hover {
  background: #e74c3c;
  color: #fff;
}

/* ============ 统计面板 ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: linear-gradient(135deg, #fff8ed, #fff1d6);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 18px 14px;
  text-align: center;
}

.stat-card.admin {
  background: linear-gradient(135deg, #ffe4e4, #ffd4d4);
  border-color: #ffb3b3;
}

.stat-card.user {
  background: linear-gradient(135deg, #e3f2ff, #d0e8ff);
  border-color: #b3d9ff;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1;
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  font-weight: 500;
}

.stats-section {
  margin-bottom: 22px;
}

.stats-section h3 {
  margin: 0 0 12px;
  font-size: 15px;
  color: #5a4a3a;
  font-weight: 700;
}

.stat-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-label {
  width: 60px;
  color: #5a4a3a;
  font-weight: 500;
}

.bar-track {
  flex: 1;
  height: 20px;
  background: #fff3e6;
  border-radius: 10px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
  border-radius: 10px;
  transition: width 0.5s ease;
  min-width: 4px;
}

.bar-value {
  width: 32px;
  text-align: right;
  color: var(--primary-dark);
  font-weight: 700;
}

.error-msg {
  padding: 16px;
  text-align: center;
  color: #e74c3c;
  background: #ffe4e4;
  border-radius: 10px;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 11px 22px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  animation: toastSlideDown 0.35s ease-out;
  max-width: 90%;
}

@keyframes toastSlideDown {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.toast.success {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  color: #fff;
}

.toast.error {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
}

.toast.info {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
}

/* ============ 天气卡片 ============ */
.weather-card-wrap .bubble {
  max-width: 92%;
  padding: 0;
  overflow: hidden;
}

.weather-card {
  background: linear-gradient(135deg, #fff8ed 0%, #fff1d6 50%, #ffe4c4 100%);
  border: 2px solid #ffb77a;
  border-radius: 22px;
  padding: 0 !important;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 6px 24px rgba(255, 138, 61, 0.18);
  overflow: hidden;
}

.weather-card::before {
  display: none;
}

.weather-header {
  background: linear-gradient(135deg, #ffb77a 0%, #ff8a3d 100%);
  padding: 14px 20px;
  color: #fff;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.weather-city {
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.weather-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px 14px;
  gap: 4px;
  background: linear-gradient(180deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0.1) 100%);
}

.weather-emoji {
  font-size: 56px;
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.1));
  animation: weatherFloat 3s ease-in-out infinite;
}

@keyframes weatherFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.weather-temp {
  font-size: 48px;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1;
  letter-spacing: -2px;
  text-shadow: 0 2px 4px rgba(255, 138, 61, 0.25);
}

.weather-desc {
  font-size: 16px;
  color: #5a4a3a;
  font-weight: 500;
  margin-top: 2px;
}

.weather-details {
  display: flex;
  justify-content: space-around;
  padding: 14px 10px;
  background: rgba(255, 255, 255, 0.5);
  border-top: 1px solid rgba(255, 183, 122, 0.4);
}

.detail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  font-size: 13px;
  color: #6b5a4a;
}

.detail-icon {
  font-size: 20px;
}

.detail-label {
  font-size: 12px;
  color: #9a8a7a;
}

.detail-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-dark);
}

.forecast-title {
  text-align: center;
  font-size: 14px;
  color: #6b5a4a;
  padding: 8px 12px 4px;
  font-weight: 500;
}

.forecast {
  display: flex;
  justify-content: space-around;
  padding: 0 10px 12px;
  gap: 6px;
}

.forecast-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  min-width: 0;
  transition: transform 0.2s ease;
}

.forecast-day:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.85);
}

.forecast-date {
  font-size: 12px;
  color: #9a8a7a;
  font-weight: 500;
}

.forecast-emoji {
  font-size: 24px;
  line-height: 1;
}

.forecast-desc {
  font-size: 12px;
  color: #6b5a4a;
}

.forecast-temp {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
}

/* ============ 历史对话按钮 ============ */
.history-btn {
  background: linear-gradient(135deg, #ffb77a 0%, #ff8a3d 100%);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.history-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 138, 61, 0.3);
}

/* ============ 历史对话弹窗 ============ */
.history-modal {
  max-width: 600px;
}

.history-actions {
  margin-bottom: 16px;
  text-align: right;
}

.history-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  background: #fff8ed;
  border: 2px solid #ffd9a8;
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.history-item:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(255, 138, 61, 0.15);
  transform: translateX(4px);
}

.history-item-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  font-size: 14px;
}

.history-item-meta {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}

.history-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: #ff6b6b;
  cursor: pointer;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 3px 6px;
  border-radius: 5px;
}

.history-item:hover .history-delete {
  opacity: 1;
}

.history-delete:hover {
  background: #ffe5e5;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 30px 20px;
  font-size: 14px;
}

/* ============ 对话详情 ============ */
.session-modal {
  max-width: 700px;
}

.session-content {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.session-content .message {
  margin-bottom: 8px;
}

.session-content .bubble {
  font-size: 14px;
  padding: 9px 13px;
  border-radius: 10px;
  display: inline-block;
  max-width: 80%;
  word-break: break-word;
}

.session-content .message.user .bubble {
  background: var(--user-bg);
  border: 1px solid var(--user-border);
}

.session-content .message.ai .bubble {
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
}

.session-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ============ 场景化服务芯片 ============ */
.scenario-chips {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
}

.quick-questions .chip.scenario-chip {
  background: linear-gradient(135deg, #fff3e0, #ffe0b2);
  border-color: var(--primary-dark);
  border-width: 2px;
  position: relative;
}

.quick-questions .chip.scenario-chip:hover {
  background: linear-gradient(135deg, var(--primary-dark), #e65100);
}

.chip-badge {
  display: inline-block;
  margin-left: 3px;
  font-size: 10px;
  line-height: 1;
  color: #ff9800;
  background: #fff;
  border-radius: 5px;
  padding: 1px 3px;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.quick-questions .chip.scenario-chip:hover .chip-badge {
  color: var(--primary-dark);
}

/* ============ 紧急求助按钮 ============ */
.emergency-btn {
  position: fixed;
  right: 22px;
  bottom: 100px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #ff5252, #c62828);
  color: #fff;
  border: none;
  border-radius: 22px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(198, 40, 40, 0.4);
  transition: all 0.3s ease;
  animation: emergencyPulse 2s infinite;
}

.emergency-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 28px rgba(198, 40, 40, 0.6);
}

@keyframes emergencyPulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(198, 40, 40, 0.4); }
  50% { box-shadow: 0 6px 20px rgba(198, 40, 40, 0.7), 0 0 0 6px rgba(255, 82, 82, 0.15); }
}

.emergency-icon {
  font-size: 20px;
}

.emergency-text {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ============ 记忆管理弹窗 ============ */
.memory-modal {
  max-width: 600px;
}

.modal-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.6;
}

.memory-content {
  max-height: 60vh;
  overflow-y: auto;
}

.loading-text {
  text-align: center;
  color: var(--muted);
  padding: 20px;
  font-size: 13px;
}

.memory-category {
  margin-bottom: 18px;
}

.memory-category h4 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 3px solid;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.memory-count {
  background: #f0f0f0;
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.memory-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memory-item {
  background: #fff8ed;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  transition: all 0.2s ease;
}

.memory-item:hover {
  background: #fff1d6;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(255, 138, 61, 0.12);
}

.memory-content {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
  word-break: break-word;
}

.memory-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.memory-delete {
  margin-left: auto;
  background: none;
  border: 1px solid #e74c3c;
  color: #e74c3c;
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.memory-delete:hover {
  background: #e74c3c;
  color: #fff;
}

/* ============ 数据隐私弹窗 ============ */
.privacy-modal {
  max-width: 580px;
}

.privacy-section {
  margin-bottom: 20px;
}

.privacy-section h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0 0 10px;
}

.privacy-section p {
  font-size: 13px;
  color: #6b5a4a;
  line-height: 1.6;
  margin: 0 0 12px;
}

.privacy-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.privacy-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.privacy-list li {
  padding: 8px 0;
  font-size: 13px;
  color: #5a4a3a;
  border-bottom: 1px dashed #ffe4c4;
  padding-left: 22px;
  position: relative;
}

.privacy-list li:last-child {
  border-bottom: none;
}

.privacy-list li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}

/* ============ 响应式 ============ */
@media (max-width: 600px) {
  body { font-size: 14px; }

  .auth-container {
    padding: 28px 22px 24px;
  }

  .auth-title { font-size: 22px; }

  .app-header {
    padding: 12px 14px;
    gap: 8px;
  }

  .title h1 { font-size: 18px; }
  .subtitle { font-size: 12px; }
  .logo { font-size: 30px; }
  .user-name { max-width: 60px; font-size: 13px; }
  .user-info { padding: 5px 9px; }

  .chat-box { padding: 20px 12px 180px; }
  .message .bubble { font-size: 14px; padding: 11px 14px; max-width: 85%; }
  .message .avatar { width: 36px; height: 36px; font-size: 22px; }
  #userInput { font-size: 14px; }
  .send-btn { font-size: 14px; padding: 9px 16px; }
  .input-bar { padding: 8px 12px; }
  .quick-questions { padding: 10px 12px 12px; bottom: 62px; }
  .quick-questions .chip { font-size: 13px; padding: 9px 14px; }
  .loading { bottom: 140px; }
  .scroll-down { bottom: 220px; right: 12px; }

  .modal-content {
    padding: 22px 18px;
    margin: 8px;
  }

  .modal-content h2 { font-size: 18px; }

  .user-table-header, .user-row {
    grid-template-columns: 1.2fr 0.7fr 0.7fr 0.8fr 1.6fr;
  }
  .user-table-header > div:nth-child(5),
  .user-row > .user-cell.small {
    display: none;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .weather-card { max-width: 100%; }
  .weather-emoji { font-size: 46px; }
  .weather-temp { font-size: 38px; }
  .weather-desc { font-size: 15px; }
  .forecast { gap: 5px; }
  .forecast-emoji { font-size: 20px; }

  .emergency-btn {
    right: 12px;
    bottom: 90px;
    padding: 7px 10px;
  }

  .emergency-icon {
    font-size: 18px;
  }

  .privacy-actions {
    grid-template-columns: 1fr;
  }

  .memory-category h4 {
    font-size: 14px;
  }
}