/* ============================================
   XXPBot — 现代聊天界面
   玻璃态 · 流畅动画 · 暗色主题
   ============================================ */

:root {
  /* 品牌色 */
  --brand: #6366f1;
  --brand-2: #8b5cf6;
  --brand-3: #a78bfa;
  --brand-glow: rgba(99, 102, 241, 0.25);
  --brand-glow-strong: rgba(99, 102, 241, 0.45);

  /* 亮色主题 */
  --bg-root: #f0f2f5;
  --bg-surface: #ffffff;
  --bg-sidebar: #f8f9fc;
  --bg-hover: #f0f2f9;
  --bg-input: #f4f5f9;
  --bg-bubble-bot: #f3f4f8;
  --bg-bubble-bot-hover: #ebeef5;
  --bg-tooltip: #1e293b;

  --text-1: #111827;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --text-inverse: #ffffff;

  --border-1: #e5e7f0;
  --border-2: #f0f1f5;
  --border-input: #e0e3ed;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.10);
  --shadow-brand: 0 4px 14px rgba(99, 102, 241, 0.35);

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --sidebar-w: 270px;
  --header-h: 58px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* 暗色主题 */
[data-theme="dark"] {
  --bg-root: #0f1117;
  --bg-surface: #15171e;
  --bg-sidebar: #111318;
  --bg-hover: #1c1f2a;
  --bg-input: #1a1d27;
  --bg-bubble-bot: #1a1d27;
  --bg-bubble-bot-hover: #202430;
  --bg-tooltip: #e4e7f0;

  --text-1: #e8ebf2;
  --text-2: #9ca3b5;
  --text-3: #5c6070;
  --text-inverse: #0f1117;

  --border-1: #252838;
  --border-2: #1c1f2a;
  --border-input: #252838;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
  --shadow-brand: 0 4px 18px rgba(99, 102, 241, 0.3);
}

/* ============================================ */
/* Reset & Base */
/* ============================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg-root);
  color: var(--text-1);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
  display: flex;
}

/* ============================================ */
/* 侧边栏 */
/* ============================================ */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-1);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s var(--ease), background 0.3s var(--ease);
  z-index: 100;
  user-select: none;
}

.sidebar-brand {
  padding: 22px 20px 14px;
  display: flex;
  align-items: center;
}
.sidebar-brand>*{margin-right:11px;}
.sidebar-brand>*:last-child{margin-right:0;}

.sidebar-logo {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center;
  font-size: 19px;
  box-shadow: 0 4px 12px var(--brand-glow);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 17px; font-weight: 750;
  color: var(--text-1);
  letter-spacing: -0.3px;
}

.sidebar-ver {
  font-size: 10px; font-weight: 600;
  color: var(--text-3);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-status {
  margin: 0 20px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  display: flex; align-items: center;
  font-size: 12px; font-weight: 500;
  color: var(--text-2);
  transition: background 0.2s var(--ease);
}
.sidebar-status>*{margin-right:8px;}
.sidebar-status>*:last-child{margin-right:0;}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
  transition: background 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.status-dot.offline {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.sidebar-model {
  margin: 4px 20px 0;
  font-size: 11px; font-weight: 600;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 0 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex; flex-direction: column;
}
.sidebar-nav>*{margin-bottom:3px;}
.sidebar-nav>*:last-child{margin-bottom:0;}

.nav-item {
  display: flex; align-items: center;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px; font-weight: 550;
  cursor: pointer;
  transition: all 0.18s var(--ease);
  width: 100%; text-align: left;
  font-family: inherit;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}
.nav-item>*{margin-right:10px;}
.nav-item>*:last-child{margin-right:0;}

.nav-item .nav-icon {
  width: 22px; text-align: center;
  font-size: 16px; flex-shrink: 0;
}

.nav-divider {
  height: 1px;
  background: var(--border-1);
  margin: 10px 2px;
}

.sidebar-footer {
  padding: 12px 16px 20px;
  border-top: 1px solid var(--border-1);
}

.theme-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 2px;
  color: var(--text-2);
  font-size: 13px; font-weight: 550;
}

.theme-toggle {
  width: 44px; height: 24px;
  border-radius: 12px;
  background: var(--border-1);
  border: none;
  cursor: pointer;
  position: relative;
  transition: background 0.25s var(--ease);
}
.theme-toggle.active { background: var(--brand); }

.theme-knob {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  position: absolute; top: 2px; left: 2px;
  transition: transform 0.25s var(--ease);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.theme-toggle.active .theme-knob { transform: translateX(20px); }

/* ============================================ */
/* 主区域 */
/* ============================================ */
.main {
  flex: 1;
  display: flex; flex-direction: column;
  min-width: 0;
  height: 100vh;
  position: relative;
  background: var(--bg-root);
  transition: background 0.3s var(--ease);
}

/* 头部 */
.header {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-2);
  flex-shrink: 0;
  transition: background 0.3s var(--ease);
  z-index: 10;
}

.header-left { display: flex; align-items: center; }
.header-left>*{margin-right:10px;}
.header-left>*:last-child{margin-right:0;}

.menu-btn {
  display: none;
  width: 36px; height: 36px;
  border: none;
  background: var(--bg-hover);
  border-radius: 9px;
  font-size: 17px; cursor: pointer;
  color: var(--text-2);
  transition: background 0.18s var(--ease);
  align-items: center; justify-content: center;
}
.menu-btn:hover { background: var(--border-1); }

.header-model {
  font-size: 11px; font-weight: 700;
  padding: 3px 10px;
  border-radius: 7px;
  background: rgba(99, 102, 241, 0.08);
  color: var(--brand);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.header-title {
  font-size: 13.5px; font-weight: 550;
  color: var(--text-2);
}

.header-right { display: flex; align-items: center; }
.header-right>*{margin-right:2px;}
.header-right>*:last-child{margin-right:0;}

.icon-btn {
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  font-size: 16px; cursor: pointer;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: all 0.18s var(--ease);
  text-decoration: none;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-1); }

.header-user {
  display: flex; align-items: center;
  padding: 4px 12px; border-radius: 16px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  margin-right: 4px;
  cursor: pointer; position: relative;
  transition: background 0.18s var(--ease);
}
.header-user>*{margin-right:6px;}
.header-user>*:last-child{margin-right:0;}
.header-user:hover { background: var(--bg-hover); }
.header-user-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: #4f46e5; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}

/* 用户下拉菜单 */
.user-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 180px;
  background: var(--bg-surface);
  border: 1px solid var(--border-1);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 500;
  animation: dropIn 0.18s var(--ease);
  display: none;
}
.user-dropdown.show { display: block; }

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item {
  display: flex; align-items: center;
  width: 100%; padding: 9px 12px;
  border: none; border-radius: 8px;
  background: transparent;
  font-size: 13px; font-weight: 550;
  color: var(--text-2);
  cursor: pointer; font-family: inherit;
  transition: all 0.15s var(--ease);
  text-align: left;
}
.dropdown-item>*{margin-right:8px;}
.dropdown-item>*:last-child{margin-right:0;}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-1); }
.dropdown-item.logout { color: #ef4444; }
.dropdown-item.logout:hover { background: #fef2f2; color: #dc2626; }

.dropdown-divider {
  height: 1px; background: var(--border-1);
  margin: 4px 0;
}

.dropdown-info {
  padding: 8px 12px 6px;
  font-size: 11px; color: var(--text-3);
  line-height: 1.5;
  pointer-events: none;
}
.dropdown-info strong {
  display: block; font-size: 13px; color: var(--text-1);
  font-weight: 650;
}

/* ============================================ */
/* 消息区 */
/* ============================================ */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 20px;
  scroll-behavior: smooth;
  display: flex; flex-direction: column;
}
.messages>*{margin-bottom:24px;}
.messages>*:last-child{margin-bottom:0;}

.messages:empty {
  justify-content: center; align-items: center;
}

.welcome {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-2);
  animation: fadeSlideIn 0.5s var(--ease);
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.welcome-avatar {
  width: 68px; height: 68px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center;
  font-size: 32px;
  margin: 0 auto 18px;
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.25);
}

.welcome h2 {
  font-size: 22px; font-weight: 750;
  color: var(--text-1);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.welcome p {
  font-size: 13.5px;
  color: var(--text-3);
  max-width: 280px;
  margin: 0 auto;
}

/* 消息行 */
.msg-row {
  display: flex;
  max-width: 78%;
  animation: msgIn 0.3s var(--ease);
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.msg-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-row.bot { align-self: flex-start; }
.msg-row.bot .msg-avatar { margin-right: 10px; }
.msg-row.user .msg-avatar { margin-left: 10px; }

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 15px;
  flex-shrink: 0;
}

.msg-row.user .msg-avatar {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}

.msg-row.bot .msg-avatar {
  background: var(--bg-bubble-bot);
}

/* 气泡 */
.msg-bubble {
  padding: 12px 16px;
  border-radius: 15px;
  font-size: 14px; line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
  transition: background 0.2s var(--ease);
  position: relative;
}

.msg-row.user .msg-bubble {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px var(--brand-glow);
}

.msg-row.bot .msg-bubble {
  background: var(--bg-bubble-bot);
  color: var(--text-1);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-xs);
}

/* 流式光标 */
.streaming .msg-bubble::after {
  content: '▍';
  animation: blink 1s step-end infinite;
  color: var(--brand);
  margin-left: 1px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* 朗读按钮 */
.speak-btn {
  width: 28px; height: 28px;
  border: none;
  background: var(--bg-hover);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.18s var(--ease);
  opacity: 0;
  align-self: flex-end;
  margin-bottom: 2px;
}

.msg-row.bot:hover .speak-btn,
.speak-btn.playing { opacity: 1; }

.speak-btn:hover {
  background: rgba(99, 102, 241, 0.12);
  transform: scale(1.08);
}

.speak-btn.playing {
  background: rgba(99, 102, 241, 0.15);
  color: var(--brand);
}

/* 加载动画 */
.typing-dots {
  display: flex;
  padding: 4px 0;
}
.typing-dots>*{margin-right:4px;}
.typing-dots>*:last-child{margin-right:0;}

.typing-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  animation: dotBounce 1.3s infinite var(--ease);
}
.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ============================================ */
/* 输入区 */
/* ============================================ */
.input-zone {
  padding: 14px 20px 20px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-2);
  flex-shrink: 0;
  transition: background 0.3s var(--ease);
}

.input-wrap {
  display: flex; align-items: flex-end;
  background: var(--bg-input);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  padding: 5px 5px 5px 18px;
  transition: all 0.25s var(--ease);
}
.input-wrap:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
  background: var(--bg-surface);
}

#messageInput {
  flex: 1;
  border: none; background: none;
  font-size: 14.5px; line-height: 1.55;
  outline: none; resize: none;
  max-height: 130px;
  font-family: inherit;
  color: var(--text-1);
  padding: 5px 0;
}

#messageInput::placeholder { color: var(--text-3); }
.input-wrap>*{margin-right:8px;}
.input-wrap>*:last-child{margin-right:0;}

.send-btn {
  width: 38px; height: 38px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s var(--ease);
}
.send-btn:hover { transform: scale(1.06); box-shadow: var(--shadow-brand); }
.send-btn:active { transform: scale(0.94); }

.send-btn:disabled {
  background: var(--bg-hover);
  color: var(--text-3);
  cursor: not-allowed;
  box-shadow: none;
}
.send-btn:disabled:hover { transform: none; }

.send-btn svg { width: 18px; height: 18px; }

.input-hint {
  font-size: 11px; color: var(--text-3);
  text-align: center; margin-top: 8px;
}

/* 上传图片按钮 */
.upload-btn {
  width: 36px; height: 36px;
  border: 2px dashed var(--border-1);
  border-radius: 10px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s var(--ease);
}
.upload-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-glow);
}
.upload-btn.has-image {
  border-color: var(--brand);
  border-style: solid;
  color: var(--brand);
  background: var(--brand-glow);
}
.upload-btn svg { width: 18px; height: 18px; }

/* 图片预览条 */
.image-preview-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  margin-bottom: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-1);
  border-radius: 10px;
  font-size: 12px; color: var(--text-2);
}
.image-preview-bar img {
  width: 44px; height: 44px;
  border-radius: 8px;
  object-fit: cover;
}
#imagePreviewName {
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#imagePreviewRemove {
  width: 24px; height: 24px;
  border: none; border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-2);
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
#imagePreviewRemove:hover {
  background: #fecaca;
  color: #dc2626;
}

/* ============================================ */
/* Toast */
/* ============================================ */
.toast {
  position: fixed; top: 20px; left: 50%;
  transform: translateX(-50%);
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600;
  z-index: 999;
  animation: toastIn 0.35s var(--ease);
  box-shadow: var(--shadow-md);
  pointer-events: none;
}

.toast.success { background: #dcfce7; color: #166534; }
.toast.error   { background: #fee2e2; color: #dc2626; }
.toast.info    { background: #dbeafe; color: #1e40af; }

[data-theme="dark"] .toast.success { background: #052e16; color: #86efac; }
[data-theme="dark"] .toast.error   { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .toast.info    { background: #172554; color: #93c5fd; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================ */
/* 弹窗（修改密码等） */
/* ============================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000;
  animation: fadeIn .25s ease;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: var(--bg-surface);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  max-width: 360px; width: 90%;
}
.modal-card h3 {
  margin: 0 0 16px; font-size: 16px; color: var(--text-1);
}
.modal-card input {
  width: 100%; padding: 10px 12px;
  border: 2px solid var(--border-input);
  border-radius: 10px; font-size: 14px; outline: none;
  font-family: inherit; background: var(--bg-input);
  color: var(--text-1); margin-bottom: 10px;
  box-sizing: border-box;
  transition: border-color .2s;
}
.modal-card input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.modal-btns { display: flex; margin-top: 4px; }
.modal-btns>*{margin-right:8px;}
.modal-btns>*:last-child{margin-right:0;}
.modal-btns button {
  flex: 1; padding: 10px; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all .2s;
}
.modal-btns .btn-cancel {
  border: 1px solid var(--border-1);
  background: transparent; color: var(--text-2);
}
.modal-btns .btn-cancel:hover { background: var(--bg-hover); }
.modal-btns .btn-primary {
  border: none; background: var(--brand); color: #fff;
}
.modal-btns .btn-primary:hover { background: var(--brand-2); }
.modal-btns .btn-primary:disabled { opacity: .6; cursor: not-allowed; }

/* ============================================ */
/* 侧边栏遮罩 */
/* ============================================ */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ============================================ */
/* 滚动条 */
/* ============================================ */
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb {
  background: var(--border-1);
  border-radius: 2px;
}
.messages::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ============================================ */
/* 响应式 */
/* ============================================ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    border-right: none;
  }
  .sidebar.open { transform: translateX(0); }

  .menu-btn { display: flex; }

  .msg-row { max-width: 90%; }

  .header { padding: 0 14px; }
  .messages { padding: 20px 14px; }
  .input-zone { padding: 12px 14px 18px; }
}

@media (max-width: 480px) {
  .msg-row { max-width: 93%; }
  .header-model { display: none; }
}

/* ============================================ */
/* 登录面板 */
/* ============================================ */
.login-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  animation: fadeIn .3s ease;
}
.login-overlay.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.login-card {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  width: 360px;
  max-width: 90vw;
  animation: loginPop .35s var(--ease);
}
@keyframes loginPop {
  from { opacity: 0; transform: scale(0.92) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.login-logo {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center;
  font-size: 28px;
  margin: 0 auto 16px;
  box-shadow: var(--shadow-brand);
}

.login-card h2 {
  font-size: 22px; font-weight: 750;
  color: var(--text-1);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.login-desc {
  font-size: 13px; color: var(--text-3);
  margin-bottom: 16px;
}

/* 标签切换 */
.login-tabs {
  display: flex;
  background: var(--bg-hover);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 20px;
}
.login-tab {
  flex: 1;
  padding: 8px 0; margin: 0 1px;
  border: none; border-radius: 8px;
  background: transparent;
  font-size: 13px; font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: all .2s;
}
.login-tab.active {
  background: var(--bg-surface);
  color: var(--brand);
  box-shadow: var(--shadow-xs);
}
.login-tab:hover:not(.active) { color: var(--text-1); }

/* 表单切换 */
.login-form {
  display: none;
  flex-direction: column;
}
.login-form>*{margin-bottom:10px;}
.login-form>*:last-child{margin-bottom:0;}
.login-form.active { display: flex; }

.login-card input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-input);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  background: var(--bg-input);
  color: var(--text-1);
  transition: border-color .25s;
}
.login-card input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.login-error {
  color: #ef4444; font-size: 12px;
  margin-top: 8px; min-height: 18px;
}

.login-hint {
  font-size: 11px; color: var(--text-3);
  margin-top: 4px; line-height: 1.4;
}

.login-btn {
  margin-top: 16px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 15px; font-weight: 650;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s var(--ease);
}
.login-btn:hover { box-shadow: var(--shadow-brand); transform: translateY(-1px); }
.login-btn:active { transform: scale(0.97); }
.login-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* ============================================ */
/* 日志面板 */
/* ============================================ */
.logs-overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(0,0,0,0.5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9998;
  animation: fadeIn .25s ease;
}
.logs-overlay.hidden { display: none; }

.logs-panel {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 800px; max-width: 95vw; max-height: 85vh;
  display: flex; flex-direction: column;
  animation: loginPop .3s var(--ease);
}

.logs-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-1);
}
.logs-header h2 {
  font-size: 17px; font-weight: 750;
  color: var(--text-1);
  display: flex; align-items: center;
}
.logs-header h2>*{margin-right:8px;}
.logs-header h2>*:last-child{margin-right:0;}
.logs-close {
  width: 32px; height: 32px;
  border: none; background: var(--bg-hover);
  border-radius: 8px; font-size: 16px;
  cursor: pointer; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.logs-close:hover { background: var(--border-1); color: var(--text-1); }

.logs-stats {
  display: flex;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-2);
  flex-wrap: wrap;
}
.logs-stats>*{margin-right:10px;margin-bottom:6px;}
.logs-stats>*:last-child{margin-right:0;}
.logs-stat-item {
  padding: 8px 14px; background: var(--bg-hover);
  border-radius: 10px; font-size: 12px; color: var(--text-2);
}
.logs-stat-item strong {
  color: var(--brand); font-size: 16px; display: block;
}

.logs-search-row {
  display: flex;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-2);
}
.logs-search-row>*{margin-right:8px;}
.logs-search-row>*:last-child{margin-right:0;}
.logs-search-row input {
  flex: 1; padding: 9px 14px;
  border: 2px solid var(--border-input); border-radius: 10px;
  font-size: 13px; outline: none; font-family: inherit;
  background: var(--bg-input); color: var(--text-1);
  transition: border-color .2s;
}
.logs-search-row input:focus { border-color: var(--brand); }
.logs-search-row select {
  padding: 9px 14px; border: 2px solid var(--border-input);
  border-radius: 10px; font-size: 13px; outline: none;
  font-family: inherit; background: var(--bg-input); color: var(--text-1);
}
.logs-search-row button {
  padding: 9px 18px; border: none; border-radius: 10px;
  background: var(--brand); color: #fff; font-size: 13px;
  font-weight: 600; cursor: pointer; font-family: inherit;
  transition: background .2s;
}
.logs-search-row button:hover { background: var(--brand-2); }

.logs-list-wrap {
  flex: 1; overflow-y: auto; padding: 16px 24px;
  max-height: 400px;
}
.logs-list { display: flex; flex-direction: column; }
.logs-list>*{margin-bottom:10px;}
.logs-list>*:last-child{margin-bottom:0;}

.log-entry {
  padding: 14px 16px; border: 1px solid var(--border-1);
  border-radius: 12px; transition: background .15s;
}
.log-entry:hover { background: var(--bg-hover); }

.log-entry-meta {
  display: flex; align-items: center;
  margin-bottom: 8px; font-size: 11px; color: var(--text-3);
}
.log-entry-meta>*{margin-right:10px;}
.log-entry-meta>*:last-child{margin-right:0;}
.log-entry-platform {
  padding: 2px 8px; border-radius: 6px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
}
.log-entry-platform.web { background: #dbeafe; color: #1e40af; }
.log-entry-platform.qq { background: #d1fae5; color: #065f46; }
.log-entry-platform.wechat { background: #fef3c7; color: #92400e; }
[data-theme="dark"] .log-entry-platform.web { background: #172554; color: #93c5fd; }
[data-theme="dark"] .log-entry-platform.qq { background: #052e16; color: #86efac; }
[data-theme="dark"] .log-entry-platform.wechat { background: #422006; color: #fde68a; }

.log-entry-user { font-family: monospace; }
.log-entry-label {
  font-size: 10px; font-weight: 700; color: var(--text-3);
  margin-bottom: 3px; text-transform: uppercase;
}
.log-entry-msg, .log-entry-reply {
  padding: 8px 12px; border-radius: 8px; font-size: 13px;
  line-height: 1.5; margin-bottom: 6px; word-break: break-word;
}
.log-entry-msg { background: var(--bg-bubble-bot); }
.log-entry-reply { background: rgba(99,102,241,.06); }
.log-entry-del {
  text-align: right; margin-top: 4px;
}
.log-entry-del button {
  padding: 3px 10px; border: 1px solid #fecaca;
  border-radius: 6px; background: transparent;
  color: #ef4444; font-size: 11px; cursor: pointer;
  font-family: inherit; transition: all .15s;
}
.log-entry-del button:hover { background: #fee2e2; }

.logs-pager {
  display: flex; justify-content: center; align-items: center;
  padding: 12px 24px; border-top: 1px solid var(--border-2);
  font-size: 13px; color: var(--text-2);
}
.logs-pager>*{margin-right:6px;}
.logs-pager>*:last-child{margin-right:0;}
.logs-pager button {
  padding: 6px 14px; border: 1px solid var(--border-1);
  border-radius: 8px; background: var(--bg-surface);
  cursor: pointer; font-family: inherit; font-size: 12px;
  color: var(--text-2); transition: all .15s;
}
.logs-pager button:hover { background: var(--bg-hover); }
.logs-pager button:disabled { opacity: .4; cursor: not-allowed; }

.logs-actions {
  padding: 12px 24px 20px; border-top: 1px solid var(--border-2);
}
.logs-clear-btn {
  padding: 8px 18px; border: 2px solid #fecaca;
  border-radius: 10px; background: transparent;
  color: #ef4444; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all .15s;
}
.logs-clear-btn:hover { background: #fee2e2; }
