/* ==========================================================================
   云平聊天平台 — 设计系统
   深色 · 抽屉式导航 · 分层表面
   ========================================================================== */

:root {
  --bg: #080b10;
  --bg-deep: #05070a;
  --surface: #111721;
  --surface-2: #161e2a;
  --surface-3: #1d2735;
  --surface-hi: #24303f;
  --border: #26313f;
  --border-soft: #1b2431;
  --text: #e8eef6;
  --text-dim: #9aa9bc;
  --text-mute: #67788d;
  --accent: #3b82f6;
  --accent-2: #6366f1;
  --accent-strong: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.13);
  --success: #2ea86a;
  --success-soft: rgba(46, 168, 106, 0.13);
  --danger: #e5534b;
  --danger-soft: rgba(229, 83, 75, 0.13);
  --warn: #d29922;
  --warn-soft: rgba(210, 153, 34, 0.13);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  --appbar-h: 60px;
  --drawer-w: 276px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

/* ---- 主题：默认深色，支持「白天模式」切换 ---- */
:root { color-scheme: dark; }
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f8fa;
  --bg-deep: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --surface-3: #eceff4;
  --surface-hi: #e2e6ec;
  --border: #d8dde4;
  --border-soft: #e5e9ef;
  --text: #1f2329;
  --text-dim: #3f4750;
  --text-mute: #6b7280;
  --accent: #1677ff;
  --accent-2: #4096ff;
  --accent-strong: #0958d9;
  --accent-soft: rgba(22, 119, 255, 0.08);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.1);
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.1);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { overflow-x: hidden; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(59, 130, 246, 0.09), transparent 65%),
    radial-gradient(760px 460px at 96% 4%, rgba(99, 102, 241, 0.07), transparent 62%);
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: #7caeff; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.012em; }
p { margin: 0; }
.ico { flex: 0 0 auto; display: block; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #293546;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #3a4b60; background-clip: content-box; }
::selection { background: rgba(59, 130, 246, .32); }

/* ==========================================================================
   骨架
   ========================================================================== */
.app { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

.appbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: rgba(8, 11, 16, 0.72);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(16px) saturate(140%);
}
.appbar-context { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.appbar-context h1 { font-size: 15.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-context .sub { font-size: 11.5px; color: var(--text-mute); line-height: 1.35; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background .16s, color .16s, border-color .16s;
  flex: 0 0 auto;
  padding: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-soft); }

.hamburger {
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text-dim);
  width: 36px; height: 36px;
  box-shadow: var(--shadow-sm);
}
.hamburger:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }

/* 内容区 */
.content {
  flex: 1;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 28px 56px;
  animation: fade-up .28s var(--ease) both;
}
.content-plain {
  flex: 1;
  min-height: 0;
  height: calc(100vh - var(--appbar-h));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fade-in .2s ease both;
}
.padded {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 28px 48px;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ==========================================================================
   抽屉
   ========================================================================== */
.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 190;
  background: rgba(4, 6, 9, 0.62);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .26s var(--ease);
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  width: var(--drawer-w);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #111925 0%, #0c1219 100%);
  border-right: 1px solid #2b3647;
  box-shadow: var(--shadow-lg), inset -1px 0 0 rgba(255, 255, 255, 0.045);
  transform: translateX(calc(-100% - 24px));
  transition: transform .3s var(--ease);
  will-change: transform;
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.drawer-close { margin-left: auto; }

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #4f8dfb, #6d5cf6);
  box-shadow: 0 4px 14px rgba(79, 141, 251, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.brand-mark.admin { background: linear-gradient(135deg, #f0635b, #d29922); box-shadow: 0 4px 14px rgba(240, 99, 91, 0.28), inset 0 1px 0 rgba(255,255,255,.22); }
/* 后台上传了站点图标时，品牌位直接显示图标，不再套渐变色块 */
.brand-mark.has-img,
.auth-brand .brand-dot.has-img {
  background: transparent;
  box-shadow: none;
  overflow: hidden;
  padding: 0;
}
.brand-mark.has-img img,
.auth-brand .brand-dot.has-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-text strong { font-size: 14px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: 10.5px; color: var(--text-mute); letter-spacing: .02em; }

.drawer-nav { flex: 1; overflow-y: auto; padding: 10px 12px 8px; }
.nav-section + .nav-section { margin-top: 8px; }
.nav-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding: 8px 12px 5px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 450;
  transition: background .16s, color .16s;
  margin-bottom: 2px;
}
.nav-item .ico { color: var(--text-mute); transition: color .16s; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover .ico { color: var(--text-dim); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, .16), rgba(59, 130, 246, .03));
  color: #cfe0ff;
  font-weight: 500;
}
.nav-item.active .ico { color: #7caeff; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 17px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #60a5fa, #4f46e5);
  box-shadow: 0 0 12px rgba(96, 165, 250, .55);
}
.nav-item .badge-count {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}

.drawer-foot { padding: 12px; border-top: 1px solid var(--border-soft); }
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}
.avatar {
  width: 32px; height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
  color: #cfe0ff;
  background: linear-gradient(135deg, rgba(59,130,246,.3), rgba(99,102,241,.24));
  border: 1px solid rgba(59,130,246,.25);
}
.user-meta { min-width: 0; flex: 1; line-height: 1.3; }
.user-name { font-size: 12.8px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10.5px; color: var(--text-mute); }

/* 抽屉内的主题切换（左下角，打开侧边栏可见） */
.drawer-theme {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
  padding: 9px 11px;
  border-radius: 11px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12.8px;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s, border-color .15s;
}
.drawer-theme:hover { color: var(--accent); border-color: var(--accent); background: var(--surface-2); }
.drawer-theme .ico { flex: 0 0 auto; }
.drawer-theme .theme-label { flex: 1; }

@media (max-width: 959px) {
  body.drawer-open { overflow: hidden; }
}

/* ==========================================================================
   卡片 / 网格
   ========================================================================== */
.card {
  position: relative;
  min-width: 0;
  background: linear-gradient(180deg, rgba(20, 28, 39, .92), rgba(16, 22, 31, .92));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .025) inset;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { font-size: 14.5px; }
.card-desc { font-size: 12.5px; color: var(--text-mute); margin-top: 3px; }

.grid { display: grid; gap: 14px; }
.grid > * { min-width: 0; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.stat {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(22, 30, 42, .95), rgba(16, 22, 31, .95));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 17px 18px;
  transition: transform .2s var(--ease), border-color .2s;
}
.stat::after {
  content: "";
  position: absolute;
  top: 0; left: 18px; right: 18px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(96, 165, 250, .4), transparent);
}
.stat:hover { transform: translateY(-2px); border-color: var(--border); }
.stat .label { font-size: 12px; color: var(--text-mute); letter-spacing: .01em; }
.stat .value { font-size: 27px; font-weight: 650; margin-top: 7px; letter-spacing: -0.03em; line-height: 1.1; }
.stat .foot { font-size: 11.5px; color: var(--text-mute); margin-top: 5px; }

/* ==========================================================================
   按钮
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 450;
  font-family: inherit;
  line-height: 1.45;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, opacity .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-3); border-color: var(--surface-hi); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 2px solid rgba(59,130,246,.55); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(180deg, #4a8bfb, #2f6fe0);
  border-color: #3b7cea;
  color: #fff;
  box-shadow: 0 2px 10px rgba(59, 130, 246, .28), inset 0 1px 0 rgba(255,255,255,.16);
}
.btn-primary:hover { background: linear-gradient(180deg, #5b96fb, #3479ea); border-color: #5b96fb; }
.btn-danger { background: var(--danger-soft); border-color: rgba(229, 83, 75, .38); color: #ff8f88; }
.btn-danger:hover { background: rgba(229, 83, 75, .22); border-color: rgba(229, 83, 75, .55); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-soft); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 7px; gap: 5px; }
.btn-block { width: 100%; }

/* ==========================================================================
   表单
   ========================================================================== */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; font-weight: 450; }
.field .hint { font-size: 11.5px; color: var(--text-mute); margin-top: 5px; line-height: 1.5; }

input[type="text"], input[type="password"], input[type="email"], input[type="tel"], input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  padding: 8px 11px;
  background: #0c111a;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: #4d5c6e; }
input:focus, select:focus, textarea:focus {
  border-color: rgba(59, 130, 246, .7);
  background: #0a0f17;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .14);
}
textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
select { cursor: pointer; }

.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-dim); cursor: pointer; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

/* 网站信息卡片里的图标设置 */
.icon-editor { display: flex; gap: 16px; align-items: flex-start; }
.icon-preview {
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0c111a;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.icon-preview img { width: 100%; height: 100%; object-fit: contain; }
.icon-preview-empty { font-size: 12px; color: var(--text-mute); }

/* 后台「网站信息」：QQ / 微信 分享卡片预览 */
.share-preview { padding: 4px 0 2px; }
.share-preview-card {
  display: flex; gap: 12px; align-items: flex-start;
  max-width: 420px;
  padding: 12px;
  background: #f2f3f5;
  border-radius: 10px;
}
.share-thumb {
  flex: 0 0 64px; width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  background: #dfe3e8; border-radius: 6px; overflow: hidden;
}
.share-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.share-thumb-empty { font-size: 11px; color: #8a94a6; }
.share-meta { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.share-meta strong { font-size: 13.5px; color: #1a1f27; line-height: 1.4; }
.share-meta p {
  font-size: 12px; color: #6b7280; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.share-meta small { font-size: 11px; color: #9aa3af; word-break: break-all; }

.icon-fields { flex: 1; min-width: 0; }
.icon-fields input[type="file"] {
  width: 100%;
  padding: 6px 9px;
  background: #0c111a;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
}
.icon-fields input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 4px 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.icon-or {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 8px;
  color: var(--text-mute);
  font-size: 11.5px;
}
.icon-or::before, .icon-or::after { content: ""; height: 1px; background: var(--border-soft); flex: 1; }
.icon-fields .checkbox-row { margin-top: 10px; }

/* ==========================================================================
   表格
   ========================================================================== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border-soft); max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: .03em;
  color: var(--text-mute);
  padding: 10px 13px;
  background: rgba(12, 17, 26, .7);
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
td { padding: 12px 13px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr { transition: background .13s; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, .022); }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.code-cell { color: #8fb8ff; word-break: break-all; }

/* ==========================================================================
   徽章 / 提示
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: #5fd98c; border-color: rgba(46, 168, 106, .28); }
.badge-danger { background: var(--danger-soft); color: #ff8f88; border-color: rgba(229, 83, 75, .28); }
.badge-warn { background: var(--warn-soft); color: #e6bb4a; border-color: rgba(210, 153, 34, .28); }
.badge-muted { background: var(--surface-3); color: var(--text-dim); border-color: var(--border); }
.badge-info { background: var(--accent-soft); color: #8fb8ff; border-color: rgba(59, 130, 246, .3); }
.admin-tag { font-weight: 500; }

.alert {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: fade-up .22s var(--ease) both;
}
.alert-error { background: var(--danger-soft); border-color: rgba(229, 83, 75, .28); color: #ffa39d; }
.alert-ok { background: var(--success-soft); border-color: rgba(46, 168, 106, .28); color: #72e0a0; }
.alert-warn { background: var(--warn-soft); border-color: rgba(210, 153, 34, .28); color: #e6bb4a; }

/* ==========================================================================
   空状态
   ========================================================================== */
.empty { text-align: center; padding: 46px 20px; color: var(--text-mute); }
.empty .empty-title { font-size: 14px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.empty .empty-hint { font-size: 12.5px; line-height: 1.7; }

/* ==========================================================================
   弹窗
   ========================================================================== */
dialog {
  background: linear-gradient(180deg, #141c27, #10161f);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  color: var(--text);
  width: min(520px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg);
  animation: dialog-in .22s var(--ease) both;
}
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: none; }
}
dialog::backdrop { background: rgba(3, 5, 8, .68); backdrop-filter: blur(4px); }
.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.dialog-head h3 { font-size: 15px; }
.dialog-head p { font-size: 12px; color: var(--text-mute); margin-top: 3px; }
.dialog-close {
  background: none; border: none; color: var(--text-mute);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 5px;
  border-radius: 6px; transition: background .15s, color .15s;
}
.dialog-close:hover { color: var(--text); background: var(--surface-2); }
.dialog-body { padding: 18px 20px; }
.dialog-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
  background: rgba(10, 14, 20, .4);
}

/* ==========================================================================
   登录 / 注册
   ========================================================================== */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  z-index: 1;
  background:
    radial-gradient(760px 460px at 50% -12%, rgba(59, 130, 246, .18), transparent 62%),
    radial-gradient(520px 380px at 88% 108%, rgba(99, 102, 241, .12), transparent 65%);
}
.auth-card {
  width: min(404px, 100%);
  background: linear-gradient(180deg, rgba(20, 28, 39, .96), rgba(14, 20, 28, .96));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 30px;
  box-shadow: var(--shadow-lg);
  animation: fade-up .34s var(--ease) both;
}
.auth-brand { display: flex; align-items: center; gap: 11px; justify-content: center; margin-bottom: 22px; }
.auth-brand .brand-dot {
  width: 36px; height: 36px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #4f8dfb, #6d5cf6);
  box-shadow: 0 6px 18px rgba(79, 141, 251, .34), inset 0 1px 0 rgba(255,255,255,.24);
}
.auth-brand strong { font-size: 16px; letter-spacing: -0.01em; }
.auth-title { font-size: 19px; text-align: center; margin-bottom: 5px; letter-spacing: -0.02em; }
.auth-sub { text-align: center; font-size: 12.5px; color: var(--text-mute); margin-bottom: 24px; }
.auth-foot { text-align: center; font-size: 12.5px; color: var(--text-mute); margin-top: 18px; }

/* ==========================================================================
   机器人卡片
   ========================================================================== */
.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(352px, 1fr)); gap: 15px; min-width: 0; }
.bot-card {
  min-width: 0;
  background: linear-gradient(180deg, rgba(20, 28, 39, .94), rgba(16, 22, 31, .94));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 17px 18px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  transition: border-color .2s, transform .2s var(--ease), box-shadow .2s;
}
.bot-card:hover {
  border-color: rgba(59, 130, 246, .3);
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .3);
}
.bot-head { display: flex; align-items: center; gap: 11px; }
.bot-avatar {
  width: 42px; height: 42px;
  border-radius: 12px;
  flex: 0 0 42px;
  background: var(--surface-3);
  object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px;
  color: #cfe0ff;
  border: 1px solid var(--border);
  overflow: hidden;
}
.bot-name { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.bot-meta { font-size: 11.8px; color: var(--text-mute); margin-top: 2px; }
.bot-info { display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; }
.bot-info .row { display: flex; gap: 8px; align-items: baseline; }
.bot-info .k { color: var(--text-mute); flex: 0 0 68px; }
.bot-info .v { color: var(--text-dim); word-break: break-all; }

.webhook-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  background: #0a0f17;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 7px 8px 7px 11px;
}
.webhook-box code {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  color: #8fb8ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.bot-actions {
  display: flex;
  gap: 7px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  margin-top: auto;
  flex-wrap: wrap;
  align-items: center;
}

/* ==========================================================================
   消息中心
   ========================================================================== */
.chat-shell {
  display: grid;
  grid-template-columns: 312px 1fr;
  flex: 1;
  min-height: 0;
  height: 100%;
  background: var(--surface);
  overflow: hidden;
}
.chat-side {
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(12, 17, 24, .5);
}
.chat-side-head {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-search {
  padding: 8px 11px;
  background: #0a0f17;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  width: 100%;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.chat-search:focus { border-color: rgba(59,130,246,.7); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.conv-list { flex: 1; overflow-y: auto; }
.conv-item {
  position: relative;
  display: flex;
  gap: 11px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(27, 36, 49, .6);
  cursor: pointer;
  transition: background .13s;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: linear-gradient(90deg, rgba(59,130,246,.14), rgba(59,130,246,.02)); }
.conv-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, #60a5fa, #6366f1);
}
.conv-avatar {
  width: 36px; height: 36px;
  border-radius: 11px;
  flex: 0 0 36px;
  background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #a9c8ff; font-weight: 600;
  border: 1px solid var(--border-soft);
}
.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.conv-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 10.5px; color: var(--text-mute); flex: 0 0 auto; }
.conv-preview { font-size: 12px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.conv-unread {
  background: linear-gradient(180deg, #ef5b52, #d9453d);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  border-radius: 999px;
  padding: 0 6px;
  min-width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  box-shadow: 0 2px 6px rgba(229, 83, 75, .4);
}

.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: linear-gradient(180deg, rgba(17,23,33,.4), transparent); }
.chat-main-head {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  background: rgba(11, 15, 20, .4);
}
.chat-main-head .title { font-size: 13.5px; font-weight: 600; }
.chat-main-head .sub { font-size: 11.5px; color: var(--text-mute); margin-top: 1px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 13px; }
.msg-row { display: flex; gap: 9px; max-width: 74%; animation: fade-up .18s ease both; }
.msg-row.out { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  border-top-left-radius: 4px;
  padding: 9px 13px;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-row.out .msg-bubble {
  background: linear-gradient(180deg, rgba(59,130,246,.19), rgba(59,130,246,.12));
  border-color: rgba(59, 130, 246, .3);
  border-top-left-radius: 12px;
  border-top-right-radius: 4px;
}
.msg-meta { font-size: 10.5px; color: var(--text-mute); margin-top: 5px; }
.msg-row.out .msg-meta { text-align: right; }

.chat-input {
  border-top: 1px solid var(--border-soft);
  padding: 13px 18px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: rgba(10, 14, 20, .55);
}
.chat-input textarea { min-height: 42px; max-height: 140px; flex: 1; }

.chat-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-mute);
  gap: 8px;
  font-size: 13px;
}

/* ==========================================================================
   趋势图
   ========================================================================== */
.trend-plot {
  display: flex;
  gap: 10px;
  height: 200px;
  padding: 10px 6px 0;
  border-radius: 10px;
  background:
    repeating-linear-gradient(to top, transparent 0, transparent 49px, rgba(255, 255, 255, .035) 49px, rgba(255, 255, 255, .035) 50px);
}
.trend-col {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}
.trend-val { font-size: 11px; color: var(--text-mute); height: 14px; }
.trend-bar-wrap { width: 100%; flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.trend-bar {
  width: 100%;
  max-width: 56px;
  min-height: 2px;
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, #6aa8fc, #3b82f6 52%, #2563eb);
  box-shadow: 0 0 18px rgba(59, 130, 246, .28), inset 0 1px 0 rgba(255, 255, 255, .2);
  transition: height .4s var(--ease);
}
.trend-day { font-size: 11px; color: var(--text-mute); }

/* ==========================================================================
   分页
   ========================================================================== */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--text-mute);
}
.pager .pages { display: flex; gap: 6px; }

/* ==========================================================================
   工具类
   ========================================================================== */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0 !important; }
.muted { color: var(--text-mute); }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.form-inline { display: inline; }

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 959px) {
  :root { --appbar-h: 56px; --drawer-w: 288px; }
  .appbar { padding: 0 12px; gap: 8px; }
  .appbar-context h1 { font-size: 14.5px; }
  .appbar-context .sub { display: none; }
  .content { padding: 16px 14px 40px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .bot-grid { grid-template-columns: 1fr; }
  .chat-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .appbar { padding: 0 12px; gap: 8px; }
  .appbar-actions { min-width: 0; gap: 6px; }
  #bot-select { max-width: 122px; }
  .chat-shell { width: 100%; }
  .chat-side { max-height: 40vh; border-right: none; border-bottom: 1px solid var(--border-soft); }
  .chat-messages { padding: 14px; }
  .msg-row { max-width: 86%; }
  .content-plain { height: calc(100dvh - var(--appbar-h)); }
  .bot-card:hover, .stat:hover { transform: none; }
  .appbar-actions select { min-width: 0; width: 132px; }
}

@media (max-width: 560px) {
  .stat { padding: 13px 14px; border-radius: 12px; }
  .stat .value { font-size: 22px; margin-top: 4px; }
  .stat .foot { font-size: 10.5px; }
  .grid-3 { grid-template-columns: 1fr; }
  .card { padding: 15px 14px; border-radius: 12px; }
}

@media (max-width: 640px) {
  .dialog-foot { flex-direction: column-reverse; }
  .dialog-foot .btn { width: 100%; }
  .pager { flex-direction: column; align-items: stretch; }
  .appbar-actions .badge.admin-tag { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   消息中心 · QQ 风格（群名称 / 群人数 / OpenID / 头像 / 气泡分期）
   ========================================================================== */
.chat-side-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 16px;
}
.sync-hint { font-size: 11px; color: #7fb2ff; }
.sync-hint.warn { color: #ff8f88; }

/* 头像：字母兜底 + 图片覆盖 */
.avatar-slot {
  position: relative;
  flex: 0 0 auto;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #22303f, #161e28);
  border: 1px solid var(--border-soft);
  font-weight: 600;
  color: #a9c8ff;
  user-select: none;
}
.avatar-slot.group { background: linear-gradient(160deg, #2a3f66, #1a2740); color: #bcd6ff; }
.avatar-slot.person { background: linear-gradient(160deg, #2f3a4d, #1b232e); color: #cfe0ff; }
.avatar-slot.bot { background: linear-gradient(160deg, #3a2f52, #221c31); color: #d9c9ff; }
.avatar-slot .avatar-letter { font-size: 14px; line-height: 1; }
.avatar-slot img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-36 { width: 36px; height: 36px; border-radius: 11px; }
.avatar-36 .avatar-letter { font-size: 14px; }
.avatar-40 { width: 40px; height: 40px; border-radius: 12px; }
.avatar-40 .avatar-letter { font-size: 15px; }
.avatar-44 { width: 44px; height: 44px; border-radius: 13px; }
.avatar-64 { width: 64px; height: 64px; border-radius: 18px; }
.avatar-64 .avatar-letter { font-size: 22px; }

.conv-item .avatar-slot { margin-top: 1px; }
.conv-tag {
  font-size: 10px;
  color: #8fb8ff;
  background: rgba(59, 130, 246, .13);
  border: 1px solid rgba(59, 130, 246, .24);
  border-radius: 999px;
  padding: 0 6px;
  line-height: 15px;
  margin-left: 6px;
  flex: 0 0 auto;
  font-weight: 500;
}
.conv-name { flex: 1 1 auto; }
.conv-warn {
  align-self: center;
  width: 15px; height: 15px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #0b0f14;
  background: #e6bb4a;
  flex: 0 0 auto;
}

/* 会话头部：头像 + 名称 + OpenID + 人数 */
.chat-main-head { min-height: 64px; padding: 10px 18px; }
.chat-peer { display: flex; align-items: center; gap: 12px; min-width: 0; }
.peer-text { min-width: 0; }
.peer-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.peer-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--text-mute);
  flex-wrap: wrap;
}
.peer-openid {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  color: #8fb8ff;
  background: rgba(59, 130, 246, .1);
  border: 1px solid rgba(59, 130, 246, .2);
  border-radius: 5px;
  padding: 0 5px;
  cursor: pointer;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.peer-openid:hover { background: rgba(59, 130, 246, .18); }
.peer-sep { opacity: .5; }
.peer-actions { display: flex; gap: 7px; flex: 0 0 auto; }

/* 消息行 */
/* 消息页占满「视口 - 顶栏」，否则 flex:1 + 内容高度会把输入框顶出屏幕 */
.content-plain { flex: 0 0 auto; }
.chat-shell { grid-template-rows: minmax(0, 1fr); }
.chat-side { overflow: hidden; }
.chat-messages { gap: 4px; padding: 18px 20px 22px; min-height: 0; }
/* 消息不足一屏时贴着输入框排列（QQ 习惯） */
.msg-stack { display: flex; flex-direction: column; gap: 4px; margin-top: auto; }
.msg-row {
  display: flex;
  gap: 10px;
  max-width: 78%;
  align-items: flex-start;
  animation: fade-up .16s ease both;
  padding: 4px 0;
}
.msg-row.out { align-self: flex-end; flex-direction: row-reverse; }
.msg-body { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.msg-row.out .msg-body { align-items: flex-end; }
.msg-sender {
  font-size: 11px;
  color: var(--text-mute);
  margin: 0 2px 4px;
  font-weight: 500;
}
.msg-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 4px 12px 12px 12px;
  padding: 8px 12px;
  font-size: 13.5px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100%;
}
.msg-row.out .msg-bubble {
  background: linear-gradient(180deg, rgba(59, 130, 246, .22), rgba(59, 130, 246, .14));
  border-color: rgba(59, 130, 246, .32);
  border-radius: 12px 4px 12px 12px;
}
.msg-time {
  font-size: 10px;
  color: var(--text-mute);
  margin: 3px 2px 0;
  opacity: 0;
  transition: opacity .15s;
}
.msg-row:hover .msg-time { opacity: .85; }
.msg-row.cont { margin-top: -2px; }
/* 连发消息的头像也保留：面板里靠头像认人，隐藏/变淡之后「有些用户头像不见了」，
   连发的那几条根本看不出是谁说的（昵称在 .cont 里也是收起的）。 */
.msg-row.cont .avatar-slot { opacity: 1; }
.msg-row.cont .msg-sender { display: none; }

/* 可点击头像（打开用户资料卡） */
.avatar-btn {
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 12px;
  line-height: 0;
  flex: 0 0 auto;
}
.avatar-btn .avatar-slot { transition: box-shadow .15s, transform .15s; }
.avatar-btn:hover .avatar-slot { box-shadow: 0 0 0 2px rgba(96, 165, 250, .55); }
.avatar-btn:active .avatar-slot { transform: scale(.96); }
.avatar-btn:focus-visible { outline: 2px solid #7fb2ff; outline-offset: 2px; }
#peer-avatar { cursor: pointer; }
.msg-divider {
  display: flex;
  justify-content: center;
  margin: 12px 0 6px;
}
.msg-divider span {
  font-size: 10.5px;
  color: var(--text-mute);
  background: rgba(255, 255, 255, .04);
  border-radius: 999px;
  padding: 2px 10px;
}
/* 系统提示：禁言 / 解禁这类群事件，居中一行灰字（和 QQ 的样式对齐） */
.msg-system {
  display: flex;
  justify-content: center;
  margin: 10px 0 2px;
}
.msg-system span {
  max-width: 78%;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-mute);
  text-align: center;
  word-break: break-word;
}

/* 资料弹窗 */
.pd-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
}
.pd-name { font-size: 16px; font-weight: 600; }
.pd-sub { font-size: 11.5px; color: var(--text-mute); margin-top: 4px; }
.pd-rows { margin-top: 6px; }
.pd-row {
  display: flex;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px dashed rgba(27, 36, 49, .9);
  font-size: 12.5px;
}
.pd-row:last-child { border-bottom: none; }
.pd-key { flex: 0 0 108px; color: var(--text-mute); }
.pd-val { flex: 1; min-width: 0; word-break: break-all; }
.pd-code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px;
  background: rgba(59, 130, 246, .1);
  border: 1px solid rgba(59, 130, 246, .2);
  border-radius: 5px;
  padding: 1px 5px;
  color: #9fc3ff;
}
.link-btn {
  background: none;
  border: none;
  color: #7fb2ff;
  font-size: 11.5px;
  cursor: pointer;
  padding: 0 2px;
  font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }

/* 用户资料卡 */
.ud-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-mute);
}
.ud-spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .16);
  border-top-color: #7fb2ff;
  animation: ud-spin .7s linear infinite;
}
@keyframes ud-spin { to { transform: rotate(360deg); } }
.ud-note { margin-top: 8px; line-height: 1.6; }

@media (max-width: 960px) {
  .peer-openid { max-width: 150px; }
  .chat-main-head { min-height: 58px; }
  .msg-row { max-width: 88%; }
  .peer-actions .btn { padding: 4px 8px; font-size: 11.5px; }
}
@media (max-width: 560px) {
  .hide-sm { display: none !important; }
  .peer-name { font-size: 14px; }
  .avatar-44 { width: 38px; height: 38px; border-radius: 11px; }
  .pd-row { flex-direction: column; gap: 3px; }
  .pd-key { flex: none; }
  .chat-main-head { flex-wrap: wrap; gap: 8px; padding-bottom: 10px; }
  .peer-actions { margin-left: auto; }
  .peer-text { flex: 1 1 auto; }
}

/* ==========================================================================
   手机端会话双视图：一屏看列表，点开一屏聊天（带返回）
   —— 解决「进了群聊之后要重新点一次群聊管理才能换群」的来回折腾
   ========================================================================== */
.chat-back { display: none; }

@media (max-width: 959px) {
  /* 列表与聊天叠在同一格里，用位移切换，避免上下堆叠挤压 */
  .chat-shell {
    position: relative;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
  }
  .chat-shell > .chat-side,
  .chat-shell > .chat-main {
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
    max-height: none;
    border-right: none;
    border-bottom: none;
    transition: transform .24s var(--ease), opacity .18s linear;
    will-change: transform;
  }
  .chat-shell > .chat-side { width: 100%; background: #0c1118; }

  /* 列表视图：聊天面板滑到屏幕右侧 */
  .chat-shell[data-view="list"] > .chat-main {
    transform: translate3d(100%, 0, 0);
    opacity: 0;
    pointer-events: none;
  }
  /* 聊天视图：会话列表滑出左侧 */
  .chat-shell[data-view="chat"] > .chat-side {
    transform: translate3d(-24%, 0, 0);
    opacity: 0;
    pointer-events: none;
  }

  .chat-back {
    display: inline-flex;
    margin: 0 0 0 -6px;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    color: var(--text-dim);
  }
  .chat-back:active { background: var(--surface-2); }
  .chat-main-head { gap: 8px; }
  .chat-peer { flex: 1 1 auto; min-width: 0; }

  /* 列表项更好点、留出安全区 */
  .chat-side-head { padding: 12px 14px; }
  .conv-item { padding: 12px 14px; }
  .conv-item:active { background: var(--surface-2); }
  .conv-list { padding-bottom: 6px; overscroll-behavior: contain; }
}

@media (max-width: 560px) {
  /* 手机上「刷新资料」放进会话资料弹窗里，头部只留返回 + 群名 + 资料 */
  #btn-refresh-one { display: none; }
  .chat-main-head { flex-wrap: nowrap; padding: 8px 12px; min-height: 54px; align-items: center; }
  .peer-actions { margin-left: 0; flex: 0 0 auto; }
  .chat-messages { padding: 12px 12px 16px; }
  /* 窄屏头部放不下 OpenID，收进「会话资料」里看与复制，避免换行错位 */
  .peer-openid, .peer-sep { display: none; }
  .peer-meta { margin-top: 2px; font-size: 11px; }
  .peer-name { font-size: 14.5px; }
}

/* ==========================================================================
   消息附件：图片 / 视频 / 语音 / 文件，以及文本里的可点链接
   —— QQ 用户发来的附件都走 /api/media 读服务端缓存，链接过期也能看
   ========================================================================== */
.msg-bubble.has-media { padding: 7px 10px 8px; }
.msg-bubble.media-only,
.msg-row.out .msg-bubble.media-only,
.msg-row.cont .msg-bubble.media-only {
  padding: 0;
  background: none;
  border-color: transparent;
}
.msg-bubble.media-only .msg-images { margin-top: 0; }
.msg-bubble.media-only .msg-video,
.msg-bubble.media-only .msg-voice,
.msg-bubble.media-only .msg-file { margin-top: 0; }

.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg-text.muted { color: var(--text-mute); }
.msg-link {
  color: #7fb2ff;
  text-decoration: none;
  word-break: break-all;
  border-bottom: 1px dotted rgba(127, 178, 255, .55);
}
.msg-link:hover { border-bottom-style: solid; color: #a8c9ff; }

/* ---- @ 提及：QQ 里是蓝色可点的名字标签，这里保持一致 ---- */
.msg-text .msg-mention {
  color: #7fb2ff;
  font-weight: 500;
  padding: 0 3px;
  margin: 0 1px;
  border-radius: 6px;
  background: rgba(59, 130, 246, .14);
  white-space: nowrap;
}
.msg-text .msg-mention[data-openid] { cursor: pointer; }
.msg-text .msg-mention[data-openid]:hover { background: rgba(59, 130, 246, .3); }
.msg-row.out .msg-text .msg-mention { color: #d8e7ff; background: rgba(255, 255, 255, .14); }

/* ---- 原生 markdown 消息（QQ 机器人 markdown 类型：状态卡 / 公告 / 订阅推送）----
   QQ 客户端会把 #标题、**加粗**、列表、![图 #30px #30px](url) 排版出来，
   面板用服务端渲染好的 HTML 还原同样的效果。 */
.msg-text.md { white-space: normal; }
.msg-text.md > :first-child { margin-top: 0; }
.msg-text.md > :last-child { margin-bottom: 0; }
.msg-text.md p { margin: 0 0 5px; }
.msg-text.md h1,
.msg-text.md h2,
.msg-text.md h3 { margin: 2px 0 6px; line-height: 1.4; }
.msg-text.md h1 { font-size: 16px; }
.msg-text.md h2 { font-size: 15px; }
.msg-text.md h3 { font-size: 14px; }
.msg-text.md ul,
.msg-text.md ol { margin: 4px 0; padding-left: 18px; }
.msg-text.md li { margin: 1px 0; }
.msg-text.md blockquote {
  margin: 5px 0;
  padding: 2px 0 2px 9px;
  border-left: 3px solid var(--border);
  color: var(--text-dim);
}
.msg-text.md hr { border: none; border-top: 1px solid var(--border-soft); margin: 8px 0; }
.msg-text.md strong { font-weight: 600; }
.msg-text.md del { color: var(--text-mute); }
/* 尺寸提示（如 #30px #30px）写成行内 style，其余情况按气泡宽度自适应 */
.msg-text.md .md-img {
  display: inline-block;
  max-width: 100%;
  vertical-align: middle;
  border-radius: 8px;
  background: rgba(255, 255, 255, .05);
  cursor: zoom-in;
  transition: box-shadow .15s;
}
.msg-text.md .md-img:hover { box-shadow: 0 0 0 2px rgba(96, 165, 250, .45); }

/* 图片：单图最大 220px，多图自动变小排成一行，点击开灯箱 */
.msg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  max-width: 100%;
}
.msg-image {
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  line-height: 0;
  cursor: zoom-in;
  border-radius: 10px;
  overflow: hidden;
  display: block;
  min-width: 76px;
  min-height: 76px;
  transition: box-shadow .15s, transform .12s;
}
.msg-image:hover { box-shadow: 0 0 0 2px rgba(96, 165, 250, .45); }
.msg-image:active { transform: scale(.985); }
.msg-image:focus-visible { outline: 2px solid #7fb2ff; outline-offset: 2px; }
.msg-image img {
  display: block;
  max-width: 220px;
  max-height: 220px;
  width: auto;
  height: auto;
  border-radius: 10px;
  background: rgba(255, 255, 255, .04);
  opacity: 0;
  transition: opacity .18s ease;
}
.msg-image img.is-loaded { opacity: 1; }
.msg-images.n2 .msg-image img,
.msg-images.n3 .msg-image img,
.msg-images.n4 .msg-image img {
  width: 132px;
  height: 132px;
  max-width: 132px;
  max-height: 132px;
  object-fit: cover;
}
/* 失效图片：卡片比图片高一点，行高得恢复，否则父级 line-height:0 会把「点此再试一次」压成 0 高 */
.msg-image.failed { cursor: pointer; line-height: 1.5; }
.msg-image-fail {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  justify-content: center;
  min-width: 152px;
  min-height: 88px;
  padding: 12px 16px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-mute);
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.msg-image-hint { font-size: 11px; opacity: .72; }
/* 失效图片下方的「点此再试一次」：整块都能点，这里只是给个视觉提示 */
.msg-image-retry {
  display: inline-block;
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.5;
  color: #8ab6ff;
  text-decoration: underline;
}
.msg-image.failed:hover .msg-image-retry { color: #b9d4ff; }

/* 视频 / 语音 */
.msg-video {
  display: block;
  margin-top: 6px;
  max-width: 300px;
  width: 100%;
  border-radius: 10px;
  background: #05080c;
}
.msg-voice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.msg-voice-ico { color: #8fb8ff; flex: 0 0 auto; }
.msg-voice audio { height: 32px; max-width: 250px; color-scheme: dark; }
.msg-voice-fail {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-mute);
  background: var(--surface-3);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}
.msg-voice-dl { color: #7fb2ff; text-decoration: none; }
.msg-voice-dl:hover { text-decoration: underline; }

/* 文件卡片 */
.msg-file {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  padding: 9px 11px;
  min-width: 208px;
  max-width: 320px;
  background: var(--surface-3);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
  transition: border-color .15s, background .15s;
}
.msg-file:hover { border-color: rgba(96, 165, 250, .5); background: var(--surface-hi); }
.msg-file-ico {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(96, 165, 250, .14);
  color: #8fb8ff;
}
.msg-file-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.msg-file-name {
  font-size: 12.5px;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-file-meta { font-size: 11px; color: var(--text-mute); }
.msg-file-dl { margin-left: auto; font-size: 11.5px; color: #8fb8ff; flex: 0 0 auto; }

/* 图片灯箱 */
dialog.media-viewer {
  width: auto;
  max-width: 94vw;
  max-height: 94vh;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}
.media-viewer[open] { display: flex; flex-direction: column; gap: 10px; }
.media-viewer::backdrop { background: rgba(2, 4, 7, .86); }
.viewer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 10px;
  background: rgba(14, 20, 28, .9);
  border: 1px solid var(--border-soft);
}
.viewer-name {
  font-size: 12.5px;
  color: var(--text-dim);
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-actions { margin-left: auto; display: flex; gap: 6px; }
.viewer-stage { display: flex; align-items: center; justify-content: center; }
.viewer-stage img {
  display: block;
  max-width: 90vw;
  max-height: calc(92vh - 74px);
  border-radius: 10px;
  background: #0a0e14;
}
.viewer-note {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  padding: 40px 26px;
  font-size: 13px;
  color: var(--text-mute);
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.viewer-note-hint { font-size: 11.5px; opacity: .72; }

@media (max-width: 560px) {
  .msg-bubble.has-media { padding: 6px 8px 7px; }
  .msg-image img { max-width: 168px; max-height: 168px; }
  .msg-images.n2 .msg-image img,
  .msg-images.n3 .msg-image img,
  .msg-images.n4 .msg-image img {
    width: 104px;
    height: 104px;
    max-width: 104px;
    max-height: 104px;
  }
  .msg-video { max-width: 100%; }
  .msg-voice audio { max-width: 190px; }
  .msg-file { min-width: 0; max-width: 100%; }
  .msg-file-name { max-width: 150px; }
  .viewer-name { display: none; }
  .viewer-bar { justify-content: flex-end; }
}

/* ==========================================================================
   群管理：成员名单 / 禁言 / 撤回 / 引用回复
   ========================================================================== */

/* 输入区外壳：引用条与 @ 标签都在输入框上方 */
.chat-compose {
  border-top: 1px solid var(--border-soft);
  background: rgba(10, 14, 20, .55);
}
.chat-compose .chat-input { border-top: none; background: transparent; }
/* hidden 属性要压过 #quote-bar / .mention-bar 上的 display，否则引用条会一直占位 */
.compose-extra[hidden],
#quote-bar[hidden],
.mention-bar[hidden] { display: none; }

/* 引用条 */
#quote-bar {
  margin: 9px 18px 0;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 2px solid rgba(59, 130, 246, .85);
  background: rgba(59, 130, 246, .1);
  border-radius: 8px;
  font-size: 12px;
}
.quote-ico { flex: 0 0 auto; color: #8fb8ff; font-weight: 600; font-size: 11px; }
.quote-body { flex: 1; min-width: 0; display: flex; gap: 6px; align-items: baseline; color: var(--text-mute); }
.quote-body b { color: #cfe0ff; font-weight: 600; flex: 0 0 auto; }
#quote-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.quote-close {
  flex: 0 0 auto; background: none; border: none; color: var(--text-mute);
  cursor: pointer; font-size: 12px; padding: 2px 4px; border-radius: 5px; font-family: inherit;
}
.quote-close:hover { color: var(--text); background: rgba(255, 255, 255, .08); }

/* 待发送的 @ 成员 */
.mention-bar { flex-wrap: wrap; padding: 8px 18px 0; gap: 6px; }
.mention-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(59, 130, 246, .16);
  border: 1px solid rgba(59, 130, 246, .35);
  color: #a8c9ff; border-radius: 999px; padding: 2px 8px; font-size: 11.5px;
}
.mention-chip button {
  background: none; border: none; color: inherit; opacity: .7;
  cursor: pointer; font-size: 10px; padding: 0; line-height: 1; font-family: inherit;
}
.mention-chip button:hover { opacity: 1; }

/* 消息旁边的红色「撤回」方框 */
.msg-tools {
  display: flex;
  align-items: center;
  align-self: center;
  flex: 0 0 auto;
  opacity: .85;
  transition: opacity .15s;
}
.msg-row:hover .msg-tools { opacity: 1; }
.msg-recall {
  border: 1px solid rgba(239, 98, 88, .85);
  background: rgba(229, 83, 75, .14);
  color: #ff8a82;
  border-radius: 7px;
  padding: 3px 9px;
  font-size: 11.5px;
  line-height: 1.5;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.msg-recall:hover { background: rgba(229, 83, 75, .22); border-color: #e5534b; }
.msg-recall.expired { opacity: .4; }
.msg-recall.expired:hover { background: rgba(229, 83, 75, .08); border-color: rgba(229, 83, 75, .62); }

/* 撤回后的占位 */
.msg-row.recalled .msg-bubble,
.msg-row.recalled .msg-bubble.has-media {
  background: transparent;
  border: none;
  padding: 0;
}
.msg-recalled {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px dashed rgba(229, 83, 75, .45);
  border-radius: 8px;
  background: rgba(229, 83, 75, .05);
  color: var(--text-mute);
  font-size: 12px;
  font-style: italic;
}

/* 气泡里的被引用消息 */
.msg-quote {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 100%;
  margin-bottom: 5px;
  padding: 4px 8px;
  border-left: 2px solid rgba(59, 130, 246, .75);
  border-radius: 0 8px 8px 0;
  background: rgba(255, 255, 255, .05);
  font-size: 11.5px;
  color: var(--text-mute);
  cursor: pointer;
}
.msg-quote:hover { background: rgba(255, 255, 255, .09); }
.msg-quote-name { color: #8fb8ff; font-weight: 600; }
.msg-quote-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.msg-quote.is-recalled .msg-quote-text { font-style: italic; opacity: .8; }

/* 发送者旁的「已禁言」标记 */
.msg-muted {
  margin-left: 6px;
  padding: 0 4px;
  border: 1px solid rgba(229, 83, 75, .35);
  border-radius: 5px;
  color: #ffb0a8;
  font-size: 10px;
  font-weight: 400;
}

.msg-row.pressing { background: rgba(59, 130, 246, .08); border-radius: 10px; }
.msg-row.msg-flash .msg-bubble { box-shadow: 0 0 0 2px rgba(96, 165, 250, .65); }

/* 群成员弹窗 */
.members-dialog { width: min(580px, 94vw); }
.members-toolbar { display: flex; gap: 8px; padding: 12px 18px 0; }
.members-toolbar .chat-search { flex: 1; margin: 0; }
.members-body { padding: 8px 10px 6px; max-height: 54vh; overflow-y: auto; }
.members-dialog .dialog-foot { justify-content: space-between; align-items: center; }
.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 10px;
}
.member-row:hover { background: var(--surface-2); }
.member-row.is-muted { background: rgba(229, 83, 75, .06); }
.member-main { flex: 1; min-width: 0; }
.member-name {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 13px; font-weight: 500;
}
.member-role, .member-mute {
  font-size: 10px; font-weight: 400; padding: 0 4px; border-radius: 5px;
}
.member-role { color: #ffd48a; border: 1px solid rgba(210, 153, 34, .4); }
.member-mute { color: #ffb0a8; border: 1px solid rgba(229, 83, 75, .4); }
.member-sub {
  margin-top: 2px; font-size: 11px; color: var(--text-mute);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.member-actions { display: flex; gap: 5px; flex: 0 0 auto; }
.btn-xs { padding: 2px 8px; font-size: 11.5px; border-radius: 6px; }
.btn-warn {
  color: #ffd8a0;
  border-color: rgba(210, 153, 34, .45);
  background: rgba(210, 153, 34, .1);
}
.btn-warn:hover { background: rgba(210, 153, 34, .2); }

/* 浮层菜单（禁言时长 / 长按操作） */
.popmenu {
  position: fixed;
  z-index: 95;
  min-width: 148px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #141b25;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
}
.popmenu[hidden] { display: none; }
.popmenu-title { padding: 2px 8px 6px; font-size: 11px; color: var(--text-mute); }
.popmenu button {
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
}
.popmenu button:hover { background: var(--surface-2); }
.popmenu button:disabled { opacity: .35; cursor: not-allowed; }
.popmenu button.danger { color: #ff9d96; }
.popmenu button.danger:hover { background: rgba(229, 83, 75, .14); }

/* 轻提示 */
.chat-toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  z-index: 120;
  max-width: 80vw;
  padding: 8px 14px;
  transform: translate(-50%, 12px);
  background: rgba(20, 27, 37, .97);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12.5px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}
.chat-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 959px) {
  .msg-tools { opacity: .9; }
  .msg-recall { padding: 2px 6px; font-size: 10.5px; }
  #quote-bar { margin: 8px 12px 0; }
  .mention-bar { padding: 8px 12px 0; }
  .member-actions .btn-xs { padding: 2px 6px; }
  .members-body { max-height: 58vh; }
}

/* ==========================================================================
   主题切换按钮
   ========================================================================== */
.theme-toggle .ico-moon { display: none; }
html[data-theme="light"] .theme-toggle .ico-sun { display: none; }
html[data-theme="light"] .theme-toggle .ico-moon { display: inline-block; }

/* 登录 / 注册等独立页右下角的悬浮切换按钮 */
.theme-float {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 300;
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.theme-float:hover { color: var(--accent); border-color: var(--accent); background: var(--surface-2); }
.theme-float:active { transform: scale(.95); }

/* ==========================================================================
   白天模式（亮色主题）覆盖
   参考 Ant Design 亮色面板：白卡片 + 浅灰背景 + 蓝色强调
   ========================================================================== */
html[data-theme="light"] body::before {
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(22, 119, 255, 0.06), transparent 65%),
    radial-gradient(760px 460px at 96% 4%, rgba(64, 150, 255, 0.05), transparent 62%);
}
html[data-theme="light"] a:hover { color: var(--accent-strong); }
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c6ccd4; background-clip: content-box; }
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #aab2bd; background-clip: content-box; }
html[data-theme="light"] ::selection { background: rgba(22, 119, 255, .18); }

/* 顶栏 / 抽屉 */
html[data-theme="light"] .appbar { background: rgba(255, 255, 255, 0.72); }
html[data-theme="light"] .drawer-scrim { background: rgba(15, 23, 42, 0.36); }
html[data-theme="light"] .drawer {
  background: linear-gradient(180deg, #ffffff 0%, #f7f8fa 100%);
  border-right: 1px solid #e5e9ef;
  box-shadow: var(--shadow-lg), inset -1px 0 0 rgba(0, 0, 0, 0.03);
}
html[data-theme="light"] .nav-item.active {
  background: linear-gradient(90deg, rgba(22, 119, 255, .12), rgba(22, 119, 255, .02));
  color: var(--accent-strong);
}
html[data-theme="light"] .nav-item.active .ico { color: var(--accent); }
html[data-theme="light"] .nav-item.active::before {
  background: linear-gradient(180deg, #4096ff, #1677ff);
  box-shadow: 0 0 12px rgba(22, 119, 255, .35);
}
html[data-theme="light"] .avatar {
  color: var(--accent);
  background: linear-gradient(135deg, rgba(22, 119, 255, .16), rgba(64, 150, 255, .1));
  border: 1px solid rgba(22, 119, 255, .2);
}

/* 卡片 / 统计 */
html[data-theme="light"] .card {
  background: #ffffff;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03) inset, var(--shadow-sm);
}
html[data-theme="light"] .stat { background: #ffffff; }
html[data-theme="light"] .stat::after {
  background: linear-gradient(90deg, transparent, rgba(22, 119, 255, .25), transparent);
}
html[data-theme="light"] .stat:hover { box-shadow: var(--shadow); }

/* 按钮 / 表单 */
html[data-theme="light"] .btn-primary {
  background: linear-gradient(180deg, #2f88ff, #0958d9);
  border-color: #0958d9;
  box-shadow: 0 2px 8px rgba(22, 119, 255, .24), inset 0 1px 0 rgba(255, 255, 255, .22);
}
html[data-theme="light"] .btn-primary:hover { background: linear-gradient(180deg, #4096ff, #1677ff); border-color: #2f88ff; }
html[data-theme="light"] .btn-danger { color: #d9363e; }
html[data-theme="light"] input[type="text"],
html[data-theme="light"] input[type="password"],
html[data-theme="light"] input[type="email"],
html[data-theme="light"] input[type="tel"],
html[data-theme="light"] input[type="number"],
html[data-theme="light"] input[type="search"],
html[data-theme="light"] select,
html[data-theme="light"] textarea { background: #ffffff; }
html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder { color: #9aa3af; }
html[data-theme="light"] input:focus,
html[data-theme="light"] select:focus,
html[data-theme="light"] textarea:focus { background: #ffffff; box-shadow: 0 0 0 3px rgba(22, 119, 255, .12); }
html[data-theme="light"] .icon-preview,
html[data-theme="light"] .icon-fields input[type="file"] { background: #fafbfc; }

/* 表格 */
html[data-theme="light"] th { background: #f4f6f9; }
html[data-theme="light"] tbody tr:hover { background: rgba(15, 23, 42, .03); }
html[data-theme="light"] .code-cell { color: var(--accent-strong); }

/* 徽章 / 提示 */
html[data-theme="light"] .badge-success { color: #16a34a; border-color: rgba(22, 163, 74, .3); }
html[data-theme="light"] .badge-danger { color: #d9363e; border-color: rgba(229, 72, 77, .3); }
html[data-theme="light"] .badge-warn { color: #b45309; border-color: rgba(217, 119, 6, .3); }
html[data-theme="light"] .badge-info { color: var(--accent); border-color: rgba(22, 119, 255, .3); }
html[data-theme="light"] .alert-error { color: #c0392b; }
html[data-theme="light"] .alert-ok { color: #16a34a; }
html[data-theme="light"] .alert-warn { color: #b45309; }

/* 弹窗 */
html[data-theme="light"] dialog { background: #ffffff; }
html[data-theme="light"] dialog::backdrop { background: rgba(15, 23, 42, .4); }
html[data-theme="light"] .dialog-foot { background: #f7f8fa; }

/* 登录 / 注册 */
html[data-theme="light"] .auth-wrap {
  background:
    radial-gradient(760px 460px at 50% -12%, rgba(22, 119, 255, .1), transparent 62%),
    radial-gradient(520px 380px at 88% 108%, rgba(64, 150, 255, .08), transparent 65%);
}
html[data-theme="light"] .auth-card { background: #ffffff; }

/* 机器人卡片 */
html[data-theme="light"] .bot-card { background: #ffffff; }
html[data-theme="light"] .bot-card:hover { box-shadow: var(--shadow); }
html[data-theme="light"] .bot-avatar { color: var(--accent); }
html[data-theme="light"] .webhook-box { background: #f7f8fa; }
html[data-theme="light"] .webhook-box code { color: var(--accent-strong); }

/* 消息中心 */
html[data-theme="light"] .chat-side { background: rgba(247, 248, 250, .7); }
html[data-theme="light"] .chat-search { background: #ffffff; }
html[data-theme="light"] .conv-item { border-bottom: 1px solid rgba(15, 23, 42, .06); }
html[data-theme="light"] .conv-item.active {
  background: linear-gradient(90deg, rgba(22, 119, 255, .1), rgba(22, 119, 255, .02));
}
html[data-theme="light"] .conv-item.active::before { background: linear-gradient(180deg, #4096ff, #1677ff); }
html[data-theme="light"] .conv-avatar { color: var(--accent); }
html[data-theme="light"] .chat-main { background: #ffffff; }
html[data-theme="light"] .chat-main-head { background: rgba(247, 248, 250, .6); }
html[data-theme="light"] .chat-input { background: #f7f8fa; }
html[data-theme="light"] .msg-row.out .msg-bubble {
  background: linear-gradient(180deg, #e8f1ff, #e0ecff);
  border-color: rgba(22, 119, 255, .28);
}
html[data-theme="light"] .msg-divider span { background: rgba(15, 23, 42, .05); }

/* 趋势图 */
html[data-theme="light"] .trend-plot {
  background: repeating-linear-gradient(to top, transparent 0, transparent 49px, rgba(15, 23, 42, .05) 49px, rgba(15, 23, 42, .05) 50px);
}
html[data-theme="light"] .trend-bar {
  background: linear-gradient(180deg, #4096ff, #1677ff 52%, #0958d9);
  box-shadow: 0 0 18px rgba(22, 119, 255, .22), inset 0 1px 0 rgba(255, 255, 255, .25);
}

/* QQ 风格扩展 */
html[data-theme="light"] .sync-hint { color: var(--accent); }
html[data-theme="light"] .sync-hint.warn { color: #d9363e; }
html[data-theme="light"] .avatar-slot { background: linear-gradient(160deg, #e9eef5, #dde3ea); color: #4b5563; }
html[data-theme="light"] .avatar-slot.group { background: linear-gradient(160deg, #dbeafe, #c7dcff); color: #1d4ed8; }
html[data-theme="light"] .avatar-slot.person { background: linear-gradient(160deg, #e6e9ef, #d6dbe2); color: #334155; }
html[data-theme="light"] .avatar-slot.bot { background: linear-gradient(160deg, #ece7fb, #ddd2f7); color: #6d28d9; }
html[data-theme="light"] .conv-tag { color: var(--accent); background: rgba(22, 119, 255, .1); border-color: rgba(22, 119, 255, .3); }
html[data-theme="light"] .peer-openid { color: var(--accent-strong); background: rgba(22, 119, 255, .08); border-color: rgba(22, 119, 255, .22); }
html[data-theme="light"] .peer-openid:hover { background: rgba(22, 119, 255, .14); }
html[data-theme="light"] .pd-row { border-bottom: 1px dashed rgba(15, 23, 42, .12); }
html[data-theme="light"] .pd-code { color: var(--accent-strong); background: rgba(22, 119, 255, .08); }
html[data-theme="light"] .link-btn { color: var(--accent); }
html[data-theme="light"] .ud-spinner { border-color: rgba(15, 23, 42, .12); border-top-color: var(--accent); }
html[data-theme="light"] .chat-shell > .chat-side { background: #ffffff; }
html[data-theme="light"] .msg-link { color: var(--accent); border-bottom-color: rgba(22, 119, 255, .4); }
html[data-theme="light"] .msg-link:hover { color: var(--accent-strong); }
html[data-theme="light"] .msg-text .msg-mention { color: var(--accent); background: rgba(22, 119, 255, .12); }
html[data-theme="light"] .msg-text .msg-mention[data-openid]:hover { background: rgba(22, 119, 255, .22); }
html[data-theme="light"] .msg-row.out .msg-text .msg-mention { color: var(--accent-strong); background: rgba(22, 119, 255, .16); }
html[data-theme="light"] .msg-text.md .md-img { background: rgba(15, 23, 42, .04); }
html[data-theme="light"] .msg-image img { background: rgba(15, 23, 42, .04); }
html[data-theme="light"] .msg-image-retry { color: var(--accent); }
html[data-theme="light"] .msg-image.failed:hover .msg-image-retry { color: var(--accent-strong); }
html[data-theme="light"] .msg-voice-ico { color: var(--accent); }
html[data-theme="light"] .msg-voice audio { color-scheme: light; }
html[data-theme="light"] .msg-voice-dl { color: var(--accent); }
html[data-theme="light"] .msg-file-ico { background: rgba(22, 119, 255, .1); color: var(--accent); }
html[data-theme="light"] .msg-file-dl { color: var(--accent); }

/* 灯箱 */
html[data-theme="light"] .viewer-bar { background: rgba(255, 255, 255, .95); }
html[data-theme="light"] .viewer-stage img { background: #eef1f5; }

/* 群管理 */
html[data-theme="light"] .chat-compose { background: #f7f8fa; }
html[data-theme="light"] #quote-bar { border-left-color: rgba(22, 119, 255, .7); background: rgba(22, 119, 255, .08); }
html[data-theme="light"] .quote-ico { color: var(--accent); }
html[data-theme="light"] .quote-body b { color: #1f2329; }
html[data-theme="light"] .quote-close:hover { background: rgba(15, 23, 42, .06); }
html[data-theme="light"] .mention-chip { background: rgba(22, 119, 255, .12); border-color: rgba(22, 119, 255, .35); color: var(--accent-strong); }
html[data-theme="light"] .msg-recall { color: #d9363e; border-color: rgba(229, 72, 77, .5); }
html[data-theme="light"] .msg-quote { background: rgba(15, 23, 42, .04); }
html[data-theme="light"] .msg-quote:hover { background: rgba(15, 23, 42, .07); }
html[data-theme="light"] .msg-quote-name { color: var(--accent); }
html[data-theme="light"] .msg-muted { color: #d9363e; }
html[data-theme="light"] .member-role { color: #b45309; }
html[data-theme="light"] .member-mute { color: #d9363e; }
html[data-theme="light"] .btn-warn { color: #b45309; }

/* 浮层 / 轻提示 */
html[data-theme="light"] .popmenu { background: #ffffff; }
html[data-theme="light"] .popmenu button.danger { color: #d9363e; }
html[data-theme="light"] .chat-toast { background: rgba(20, 24, 30, .95); color: #f3f4f6; }

/* ==========================================================================
   QQ 风格输入工具栏 / 附件面板（图片 · 拍摄 · 文件 · 八宫格）
   ========================================================================== */
.chat-compose .chat-input { display: block; padding: 10px 16px 6px; }
.compose-field { display: flex; align-items: flex-end; gap: 10px; }
.compose-field textarea { flex: 1; min-width: 0; min-height: 40px; max-height: 140px; }
.compose-field .btn-primary { flex: 0 0 auto; }

.attach-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 6px;
}
.attach-btn {
  width: 40px;
  height: 38px;
  flex: 0 0 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 9px;
  cursor: pointer;
  transition: background .16s, color .16s, transform .16s;
}
.attach-btn svg { width: 25px; height: 25px; display: block; }
.attach-btn:hover { background: var(--surface-3); color: var(--accent); }
.attach-btn:active { transform: scale(.92); }
.attach-btn.attach-toggle { color: var(--accent); }
.attach-toggle .toggle-close { display: none; }
.attach-toggle.is-open .toggle-plus { display: none; }
.attach-toggle.is-open .toggle-close { display: block; }

.attach-panel {
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
  padding: 14px 12px 12px;
}
.attach-panel[hidden],
.attach-preview[hidden] { display: none; }
.attach-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px 8px;
  max-width: 560px;
  margin: 0 auto;
}
.attach-item {
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 5px 2px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 11.5px;
  line-height: 1.3;
  white-space: nowrap;
  transition: background .16s, color .16s;
}
.attach-item:hover { background: var(--surface-3); color: var(--accent); }
.attach-ico {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: rgba(127, 140, 160, .11);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .16s, transform .16s;
}
.attach-ico svg { width: 26px; height: 26px; color: inherit; }
.attach-item:hover .attach-ico { background: var(--accent-soft); transform: translateY(-1px); }

.attach-preview {
  display: flex;
  gap: 8px;
  padding: 8px 16px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.attach-chip {
  flex: 0 0 auto;
  max-width: 210px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 11.5px;
  color: var(--text-dim);
}
.attach-chip-ico { color: var(--accent); font-size: 15px; line-height: 1; }
.attach-chip-name {
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.attach-chip-size { color: var(--text-mute); font-size: 10.5px; white-space: nowrap; }
.attach-chip-del {
  border: none;
  background: transparent;
  color: var(--text-mute);
  cursor: pointer;
  padding: 0 2px;
  font-size: 11px;
  font-family: inherit;
  line-height: 1;
}
.attach-chip-del:hover { color: var(--danger); }

html[data-theme="light"] .attach-panel { background: #f7f8fa; }
html[data-theme="light"] .attach-ico { background: #ffffff; border: 1px solid #e5e9ef; }
html[data-theme="light"] .attach-item:hover .attach-ico { border-color: rgba(22, 119, 255, .5); }
html[data-theme="light"] .attach-chip { background: #ffffff; }

@media (max-width: 560px) {
  .chat-compose .chat-input { padding: 8px 10px 4px; }
  .attach-toolbar { justify-content: space-around; }
  .attach-btn { width: 44px; flex-basis: 44px; }
  .attach-btn svg { width: 27px; height: 27px; }
  .attach-panel { padding: 12px 8px 10px; }
  .attach-grid { gap: 4px 2px; }
  .attach-ico { width: 44px; height: 44px; border-radius: 12px; }
  .attach-item { font-size: 11px; }
  .attach-preview { padding: 8px 10px 0; }
}

/* ==========================================================================
   注册 / 账号管理（QQ 头像同步）
   ========================================================================== */
.auth-card-wide { max-width: 464px; }

.input-suffix { display: flex; align-items: stretch; }
.input-suffix input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
  min-width: 0;
}
.input-suffix .suffix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-mute);
  font-size: 12.5px;
  white-space: nowrap;
}
.email-preview {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
}

.code-row { display: flex; gap: 8px; align-items: stretch; }
.code-row input { flex: 1 1 auto; min-width: 0; }
.btn-code { flex: 0 0 auto; white-space: nowrap; }
.btn-code:disabled { opacity: .65; cursor: not-allowed; }

.avatar-img { object-fit: cover; padding: 0; }

.acct-hero { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.acct-avatar-wrap { position: relative; flex: 0 0 auto; }
.acct-avatar {
  width: 76px; height: 76px;
  border-radius: 24px;
  object-fit: cover;
  display: block;
  border: 1px solid var(--border);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}
.acct-avatar-letter {
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 650;
  color: #cfe0ff;
  background: linear-gradient(135deg, rgba(59, 130, 246, .35), rgba(99, 102, 241, .28));
}
.acct-avatar-dot {
  position: absolute; right: -3px; bottom: -3px;
  width: 23px; height: 23px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--success);
  color: #fff;
  border: 2px solid var(--surface);
}
.acct-info { flex: 1 1 230px; min-width: 0; }
.acct-name { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 650; letter-spacing: -.02em; }
.acct-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.acct-tags .badge { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
.acct-meta { margin-top: 9px; }
.acct-sync {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  white-space: nowrap;
}
.acct-grid { margin-top: 16px; }
.acct-span-2 { grid-column: 1 / -1; }
.acct-email-grid { margin-bottom: 2px; }

html[data-theme="light"] .acct-avatar-letter { color: #1d4ed8; background: linear-gradient(135deg, #dbeafe, #e4e8ff); }
html[data-theme="light"] .acct-avatar-dot { border-color: #fff; }

@media (max-width: 860px) {
  .acct-grid { grid-template-columns: 1fr; }
  .acct-sync { display: none; }
}

/* 表单里的隐藏提示条：.alert 自带 display，需要显式压掉 [hidden] */
.alert[hidden] { display: none !important; }

.user-card a.user-meta { color: inherit; min-width: 0; }
.user-card a.user-meta:hover { color: var(--text); }
.user-card a.user-meta .user-name { color: inherit; }
