/* ============================================================
   MetaMem 学伴 · 记忆增强学生咨询 Agent
   跨平台 Web UI 样式（PC / 平板 / 手机自适应）
   ============================================================ */

:root {
  --brand-1: #6366f1;
  --brand-2: #8b5cf6;
  --brand-3: #a855f7;
  --brand-soft: #eef2ff;
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #fafbff;
  --border: #e8eaf3;
  --text: #1f2333;
  --text-2: #5b6178;
  --text-3: #8e94a8;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(24, 28, 50, .06), 0 1px 3px rgba(24, 28, 50, .04);
  --shadow: 0 4px 16px rgba(24, 28, 50, .08);
  --shadow-lg: 0 12px 40px rgba(24, 28, 50, .14);
  --sidebar-w: 232px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* hidden 属性优先级最高：作者样式里的 display:flex 会覆盖浏览器默认的
   [hidden]{display:none}，导致「空图片预览条 / 空的引用条」这类元素藏不住。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--brand-1); text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d6d9e6; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #c2c6d8; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------- 启动屏 */
.loading-screen { display: flex; align-items: center; justify-content: center; height: 100%; }
.boot { text-align: center; }
.boot-logo {
  width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 18px;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  color: #fff; font-size: 28px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg);
  animation: pulse 1.6s ease-in-out infinite;
}
.boot-text { color: var(--text-2); font-size: 13px; letter-spacing: .5px; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1 } 50% { transform: scale(.94); opacity: .8 } }

/* ---------------------------------------------- 主框架 */
.app-shell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; color: #fff; font-weight: 700;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, .35);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--text-3); }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius-sm); color: var(--text-2); cursor: pointer;
  border: none; background: transparent; text-align: left; width: 100%;
  transition: background .15s, color .15s; font-size: 13.5px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(99,102,241,.12), rgba(139,92,246,.1));
  color: var(--brand-1); font-weight: 600;
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; flex: 0 0 20px; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10px; padding: 1px 6px; border-radius: 999px; font-weight: 600;
}

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-sm); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px; color: #fff;
  background: linear-gradient(135deg, var(--brand-2), var(--brand-3));
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px;
}
.user-meta { min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-3); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar {
  height: 58px; flex: 0 0 58px; display: flex; align-items: center; gap: 12px;
  padding: 0 20px; background: rgba(255,255,255,.86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); position: relative; z-index: 5;
}
.topbar h2 { font-size: 16px; font-weight: 650; }
.topbar .sub { font-size: 12px; color: var(--text-3); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.view { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 20px; }
.view.no-pad { padding: 0; }

/* ---------------------------------------------- 通用组件 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 13px;
  transition: all .15s; white-space: nowrap; font-weight: 500;
}
.btn:hover { border-color: #cfd4e6; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 3px 10px rgba(99,102,241,.28);
}
.btn-primary:hover { background: linear-gradient(135deg, #585ff0, #8247f0); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: #f5c9c9; background: #fff5f5; }
.btn-danger:hover { background: #ffecec; border-color: #f0a8a8; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-icon { padding: 7px; width: 34px; height: 34px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px;
}
.card-title { font-size: 13px; font-weight: 650; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-title .hint { font-weight: 400; color: var(--text-3); font-size: 11.5px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat-label { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.stat-foot { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.stat.accent::after {
  content: ''; position: absolute; right: -20px; top: -20px; width: 80px; height: 80px;
  border-radius: 50%; background: linear-gradient(135deg, rgba(99,102,241,.14), rgba(139,92,246,.05));
}

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; font-weight: 500; }
.input, .textarea, .select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brand-1); box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
.textarea { resize: vertical; min-height: 72px; line-height: 1.6; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--brand-soft); color: var(--brand-1);
}
.badge.gray { background: #f1f2f7; color: var(--text-2); }
.badge.ok { background: #e7f8f1; color: #0d9668; }
.badge.warn { background: #fef5e7; color: #b45309; }
.badge.danger { background: #fdeeee; color: #c53030; }
.badge.info { background: #eaf2ff; color: #2563eb; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-size: 12.5px; cursor: pointer; color: var(--text-2);
  transition: all .15s;
}
.chip:hover { border-color: #cfd4e6; }
.chip.active {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  border-color: transparent; color: #fff; font-weight: 600;
}

.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty-icon { font-size: 40px; opacity: .35; margin-bottom: 10px; }
.empty-title { font-size: 14px; color: var(--text-2); font-weight: 600; margin-bottom: 4px; }
.empty-desc { font-size: 12.5px; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(99,102,241,.25);
  border-top-color: var(--brand-1); animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg) } }

.skeleton {
  background: linear-gradient(90deg, #eef0f7 25%, #f6f7fb 37%, #eef0f7 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }

/* ---------------------------------------------- Toast */
.toast-wrap {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  background: #24283c; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13px; box-shadow: var(--shadow-lg); animation: toastIn .22s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast.ok { background: #0f9d6d; }
.toast.err { background: #dc4343; }
.toast.warn { background: #d97706; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) } to { opacity: 1; transform: none } }

/* ---------------------------------------------- 模态框 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 24, 40, .45);
  display: flex; align-items: center; justify-content: center; z-index: 9000;
  padding: 20px; animation: fadeIn .16s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 560px;
  max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: modalIn .2s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98) } to { opacity: 1; transform: none } }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--border); font-weight: 650; display: flex; align-items: center; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------------------------------------- 登录页 */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 15% 0%, #e8ebff 0%, transparent 60%),
              radial-gradient(900px 500px at 100% 100%, #f3e9ff 0%, transparent 55%), var(--bg);
}
.login-card {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: 20px;
  box-shadow: var(--shadow-lg); padding: 30px 28px; border: 1px solid var(--border);
}
.login-logo {
  width: 54px; height: 54px; border-radius: 16px; margin-bottom: 16px;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700;
  box-shadow: 0 8px 22px rgba(99,102,241,.32);
}
.login-card h1 { font-size: 21px; font-weight: 700; letter-spacing: -.3px; }
.login-card .lead { color: var(--text-3); font-size: 12.5px; margin-top: 4px; margin-bottom: 20px; }
.login-tabs { display: flex; gap: 6px; background: #f2f3f9; padding: 4px; border-radius: 10px; margin-bottom: 18px; }
.login-tabs button {
  flex: 1; border: none; background: transparent; padding: 7px; border-radius: 8px;
  cursor: pointer; font-size: 13px; color: var(--text-2); font-weight: 500;
}
.login-tabs button.active { background: #fff; color: var(--brand-1); font-weight: 650; box-shadow: var(--shadow-sm); }


/* ---------------------------------------------- 对话页 */
.chat-layout { display: flex; height: 100%; min-height: 0; }
.conv-panel {
  width: 250px; flex: 0 0 250px; border-right: 1px solid var(--border);
  background: var(--surface); display: flex; flex-direction: column; min-height: 0;
}
.conv-head { padding: 12px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.conv-list { flex: 1; overflow-y: auto; padding: 8px; }
.conv-item {
  padding: 10px 11px; border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 3px;
  border: 1px solid transparent; transition: all .15s; position: relative;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--brand-soft); border-color: #dfe3fb; }
.conv-item .t { font-size: 13px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .m { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.conv-item .del {
  position: absolute; right: 6px; top: 8px; opacity: 0; border: none; background: transparent;
  cursor: pointer; color: var(--text-3); font-size: 13px; padding: 2px 4px; border-radius: 6px;
}
.conv-item:hover .del { opacity: 1; }
.conv-item .del:hover { background: #fdeeee; color: var(--danger); }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head {
  padding: 10px 16px; border-bottom: 1px solid var(--border); display: flex;
  align-items: center; gap: 10px; background: var(--surface); flex-wrap: wrap;
}
.chat-scroll { flex: 1; overflow-y: auto; padding: 20px 16px 8px; }
.msg-row { display: flex; gap: 10px; margin-bottom: 18px; max-width: 860px; margin-left: auto; margin-right: auto; }
.msg-row.user { flex-direction: row-reverse; }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 32px; display: flex;
  align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
}
.msg-row.user .msg-avatar { background: linear-gradient(135deg, #0ea5e9, #22c55e); }
.msg-body { min-width: 0; max-width: 78%; }
.msg-bubble {
  padding: 10px 14px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  word-break: break-word; overflow-wrap: anywhere;
}
.msg-row.user .msg-bubble {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff;
  border-color: transparent; box-shadow: 0 3px 12px rgba(99,102,241,.25);
}
.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: 6px 0; padding-left: 20px; }
.msg-bubble li { margin: 2px 0; }
.msg-bubble strong { font-weight: 650; }
.msg-bubble code {
  background: rgba(99,102,241,.1); padding: 1px 5px; border-radius: 5px;
  font-family: ui-monospace, Consolas, monospace; font-size: 12.5px;
}
.msg-meta { font-size: 11px; color: var(--text-3); margin-top: 5px; display: flex; gap: 8px; align-items: center; }
.msg-row.user .msg-meta { justify-content: flex-end; }
.msg-actions { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }

.trace-box {
  margin-top: 10px; border: 1px dashed #d8dcee; border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 12.5px; overflow: hidden;
}
.trace-head {
  padding: 8px 12px; cursor: pointer; display: flex; align-items: center; gap: 8px;
  color: var(--text-2); font-weight: 600; user-select: none;
}
.trace-head:hover { background: #f3f4fa; }
.trace-body { padding: 4px 12px 12px; display: none; }
.trace-box.open .trace-body { display: block; }
.trace-sec { margin-top: 10px; }
.trace-sec h5 { font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .4px; margin: 0 0 6px; }
.trace-item {
  padding: 6px 10px; border-radius: 8px; background: #fff; border: 1px solid var(--border);
  margin-bottom: 5px; font-size: 12px; display: flex; gap: 8px; align-items: flex-start;
}
.trace-item .sc {
  margin-left: auto; font-size: 11px; color: var(--brand-1); font-weight: 700;
  background: var(--brand-soft); padding: 0 6px; border-radius: 6px; white-space: nowrap;
}
.trace-empty { font-size: 12px; color: var(--text-3); font-style: italic; }

.conflict-card {
  margin-top: 10px; border: 1px solid #f6d9a8; background: #fffbf3;
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.conflict-card .hd { font-size: 13px; font-weight: 650; color: #b45309; display: flex; align-items: center; gap: 6px; }
.conflict-row { display: flex; gap: 8px; margin-top: 8px; font-size: 12.5px; }
.conflict-row .k { color: var(--text-3); flex: 0 0 52px; }
.conflict-row .v { color: var(--text); }
.conflict-actions { display: flex; gap: 8px; margin-top: 12px; }

.composer { border-top: 1px solid var(--border); background: var(--surface); padding: 12px 16px 14px; }
.composer-inner { max-width: 860px; margin: 0 auto; }
.composer-box {
  display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--border);
  border-radius: 16px; padding: 8px 8px 8px 14px; background: var(--surface); transition: all .15s;
}
.composer-box:focus-within { border-color: var(--brand-1); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.composer-box textarea {
  flex: 1; border: none; outline: none; resize: none; background: transparent;
  max-height: 140px; min-height: 24px; line-height: 1.5; padding: 6px 0;
}
.composer-tools { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.mic-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 16px; transition: all .18s; flex: 0 0 38px;
}
.mic-btn:hover { border-color: var(--brand-1); color: var(--brand-1); }
.mic-btn.recording {
  background: linear-gradient(135deg, #ef4444, #f97316); color: #fff; border-color: transparent;
  animation: recPulse 1.3s infinite;
}
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.5) }
  50% { box-shadow: 0 0 0 10px rgba(239,68,68,0) }
}
/* 联网搜索开关（输入框旁） */
.web-toggle {
  position: relative;
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 38px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  transition: all .18s;
}
.web-toggle:hover:not(:disabled) { border-color: var(--brand-1); color: var(--brand-1); }
.web-toggle.active {
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(14, 165, 233, .34);
}
.web-toggle.active::after {
  content: '';
  position: absolute; right: 6px; top: 6px; width: 6px; height: 6px;
  border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 2px #fff;
}
.web-toggle:disabled { opacity: .45; cursor: not-allowed; }

.web-hint { font-size: 11.5px; color: var(--brand-1); }
.web-hint:empty { display: none; }
.web-warn { color: var(--warn); margin-left: 4px; }

.trace-url {
  display: block; font-size: 11px; color: var(--text-3);
  word-break: break-all; line-height: 1.5;
}

.web-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10.5px; padding: 1px 7px; border-radius: 999px;
  background: #eaf2ff; color: #2563eb; font-weight: 600; white-space: nowrap;
}

.send-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer; flex: 0 0 38px;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  transition: all .15s; box-shadow: 0 3px 10px rgba(99,102,241,.3);
}
.send-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.interim {
  font-size: 12px; color: var(--brand-1); margin-top: 6px; min-height: 17px;
  display: flex; align-items: center; gap: 6px;
}

.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--brand-1);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .2s }
.typing i:nth-child(3) { animation-delay: .4s }
@keyframes blink { 0%, 60%, 100% { opacity: .25; transform: translateY(0) } 30% { opacity: 1; transform: translateY(-3px) } }

/* ---------------------------------------------- 记忆管理 */
.mem-list { display: flex; flex-direction: column; gap: 10px; }
.mem-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm); transition: all .15s;
}
.mem-item:hover { border-color: #d9ddf0; box-shadow: var(--shadow); }
.mem-item.error-marked { border-left: 3px solid var(--warn); }
.mem-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.mem-content { font-size: 13.5px; line-height: 1.65; color: var(--text); word-break: break-word; }
.mem-metrics { display: flex; gap: 14px; margin-top: 10px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-3); }
.mem-metrics b { color: var(--text-2); font-weight: 600; }
.mem-actions { display: flex; gap: 8px; margin-top: 11px; flex-wrap: wrap; }
.conf-bar { height: 4px; border-radius: 3px; background: #eef0f7; overflow: hidden; width: 76px; }
.conf-bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--ok), #34d399); }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: #e6e9f5; }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-dot {
  position: absolute; left: -22px; top: 5px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--brand-1);
}
.tl-dot.ok { border-color: var(--ok) }
.tl-dot.warn { border-color: var(--warn) }
.tl-time { font-size: 11.5px; color: var(--text-3); }
.tl-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 4px; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 10px 12px; background: var(--surface-2); color: var(--text-2);
  font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:hover td { background: var(--surface-2); }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow-sm); }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-3); }
.kv .v { font-weight: 600; }

/* --- 关于我们 --- */
.about-hero {
  display: flex; align-items: center; gap: 20px; padding: 22px;
  border-color: rgba(99, 102, 241, .28);
  background: linear-gradient(135deg, rgba(99, 102, 241, .10), rgba(168, 85, 247, .07));
}
.about-hero-mark {
  width: 76px; height: 76px; flex: 0 0 76px;
  border-radius: 22px; overflow: hidden;
  box-shadow: 0 6px 20px rgba(99, 102, 241, .22);
}
.about-hero-mark .mascot-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.about-hero-text { min-width: 0; }
.about-hero-name { font-size: 21px; font-weight: 800; letter-spacing: -.4px; }
.about-hero-desc { font-size: 13px; color: var(--text-2); line-height: 1.7; margin: 7px 0 11px; max-width: 640px; }
.about-hero-tags { display: flex; flex-wrap: wrap; gap: 8px; }
/* 中性标签：跟随主题变量，深色模式下不会残留浅底 */
.about-tag { background: var(--surface-2); color: var(--text-2); }

.about-grid { margin-top: 16px; }

.about-people { display: flex; flex-direction: column; gap: 12px; padding-bottom: 14px; }
.about-person { display: flex; align-items: center; gap: 12px; }
.about-avatar {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
}
.about-person-meta { min-width: 0; }
.about-person-name { font-size: 14px; font-weight: 650; }
.about-person-role { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

.about-contact-list {
  border-top: 1px dashed var(--border); padding-top: 12px;
  display: flex; flex-direction: column; gap: 9px;
}
.about-contact { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.about-contact-icon { font-size: 14px; flex: 0 0 auto; }
.about-contact-label { color: var(--text-3); flex: 0 0 62px; }
.about-contact-value { font-weight: 600; min-width: 0; word-break: break-word; }
.about-link { color: var(--brand-1); font-weight: 600; text-decoration: none; word-break: break-all; }
.about-link:hover { text-decoration: underline; }

.about-group { margin-bottom: 15px; }
.about-group:last-of-type { margin-bottom: 0; }
.about-group-label {
  font-size: 12px; font-weight: 650; color: var(--text-3);
  letter-spacing: .2px; margin-bottom: 8px;
}
.about-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.about-chip { cursor: default; }
.about-chip:hover { border-color: var(--border); }
.about-note { margin-top: 13px; font-size: 12.5px; color: var(--text-3); line-height: 1.65; }

.about-affil-main { font-size: 15px; font-weight: 700; }
.about-affil-sub { font-size: 12.5px; color: var(--text-3); margin-top: 5px; line-height: 1.6; }

.about-foot {
  margin-top: 18px; padding: 14px 18px; text-align: center;
  font-size: 12px; color: var(--text-3); line-height: 1.7;
  border: 1px dashed var(--border); border-radius: var(--radius);
}

/* --- 个人中心 · 回答风格切换（专业 / 温情） --- */
.tone-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tone-option {
  display: flex; flex-direction: column; gap: 5px; text-align: left;
  padding: 14px 16px; border-radius: var(--radius);
  border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; font-family: inherit; color: inherit;
  transition: border-color .18s, background .18s, box-shadow .18s, transform .18s;
}
.tone-option:hover { border-color: #cfd4e6; transform: translateY(-1px); }
.tone-option.active {
  border-color: var(--brand-1); background: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .10);
}
.tone-icon { font-size: 20px; line-height: 1.2; }
.tone-name { font-size: 14px; font-weight: 700; }
.tone-option.active .tone-name { color: var(--brand-1); }
.tone-desc { font-size: 12px; color: var(--text-3); line-height: 1.55; }

@media (max-width: 560px) {
  .tone-picker { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .about-hero { flex-direction: column; align-items: flex-start; gap: 14px; padding: 18px; }
  .about-hero-mark { width: 62px; height: 62px; flex-basis: 62px; border-radius: 18px; }
  .about-hero-name { font-size: 19px; }
}

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 44px; height: 24px; border-radius: 999px; background: #d7dbe9; position: relative; transition: background .2s;
}
.switch .track::after {
  content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .track { background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); }
.switch input:checked + .track::after { transform: translateX(20px); }

.innov-list { display: flex; flex-direction: column; gap: 8px; }
.innov-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}
.innov-item .idx {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 8px; font-size: 11px; font-weight: 700;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.innov-item .nm { font-size: 13px; font-weight: 600; }
.innov-item .md { font-size: 11px; color: var(--text-3); font-family: ui-monospace, Consolas, monospace; }

/* ---------------------------------------------- 移动端 */
.tabbar { display: none; }
.mobile-only { display: none; }

@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar { display: none; }
  .app-shell { flex-direction: column; }
  .main { padding-bottom: 62px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: rgba(255,255,255,.96); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    overflow-x: auto;  /* 管理员可见的页面更多，窄屏下允许横向滚动 */
  }
  .tabbar button {
    flex: 1; min-width: 56px; border: none; background: transparent; padding: 5px 2px;
    border-radius: 10px; display: flex; flex-direction: column; align-items: center;
    gap: 2px; cursor: pointer; color: var(--text-3); font-size: 10.5px; position: relative;
  }
  .tabbar button .i { font-size: 18px; }
  .tabbar button.active { color: var(--brand-1); font-weight: 650; }
  .tabbar button .nav-badge { position: absolute; top: 0; right: 18%; margin: 0; }
  .view { padding: 14px; }
  .topbar { padding: 0 14px; height: 54px; flex: 0 0 54px; }
  .topbar h2 { font-size: 15px; }
  .conv-panel {
    position: absolute; z-index: 40; height: calc(100% - 0px); width: 82%; max-width: 300px;
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  .conv-panel.open { transform: none; }
  .chat-layout { position: relative; }
  .msg-body { max-width: 86%; }
  .mobile-only { display: inline-flex; }
  .desktop-only { display: none; }
}

@media (max-width: 560px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .view { padding: 12px; }
  .stat-value { font-size: 21px; }
  .login-card { padding: 24px 20px; }
}

/* ============================================================
   形象资源（DeepSeek 形象，原图 1080×620 横版）
   唯一资源：/static/assets/deepseek-mascot.png
   图片未放入时元素隐藏并保留深色底，不会出现破图图标。
   ============================================================ */
.mascot-img {
  display: block;
  object-fit: cover;
  /* 原图人脸位于画面中部偏上（约 y=45%），圆形头像以此定位保证人脸居中 */
  object-position: center 40%;
  background: #0b1020;
}

/* --- 对话页 AI 头像 --- */
.msg-avatar.is-mascot {
  padding: 0;
  overflow: hidden;
  background: #0b1020;
  box-shadow: 0 0 0 1.5px rgba(124, 157, 255, .45), 0 2px 8px rgba(76, 91, 212, .34);
}
.msg-avatar.is-mascot .mascot-img { width: 100%; height: 100%; border-radius: 50%; }

/* --- 对话页「我」的头像（自定义头像 / 姓名首字回退） --- */
.msg-avatar.is-self { position: relative; }
/* 首字作为底层内容：未设置头像、或头像图片加载失败被移除时显示 */
.msg-avatar.is-self[data-initial]::before { content: attr(data-initial); }
.msg-avatar.is-self img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%; display: block;
}

/* 思考中：呼吸光环 */
.msg-avatar.is-mascot.thinking { animation: mascotBreathe 1.6s ease-in-out infinite; }
@keyframes mascotBreathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 1.5px rgba(124, 157, 255, .45), 0 2px 8px rgba(76, 91, 212, .34); }
  50% { transform: scale(1.07); box-shadow: 0 0 0 5px rgba(124, 157, 255, .16), 0 2px 8px rgba(76, 91, 212, .34); }
}

/* 本轮召回了个人记忆：紫色脉冲提示 */
.msg-avatar.is-mascot.memory-hit { animation: memoryHit 1.15s ease-out 1; }
@keyframes memoryHit {
  0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, .66); }
  60% { box-shadow: 0 0 0 11px rgba(139, 92, 246, 0); }
  100% { box-shadow: 0 0 0 1.5px rgba(124, 157, 255, .45), 0 2px 8px rgba(76, 91, 212, .34); }
}

/* --- 侧边栏 / 启动页品牌标识 --- */
.brand-mark.is-mascot,
.boot-logo.is-mascot {
  padding: 0;
  overflow: hidden;
  background: #0b1020;
  box-shadow: 0 4px 14px rgba(76, 91, 212, .42);
}
.brand-mark.is-mascot .mascot-img,
.boot-logo.is-mascot .mascot-img { width: 100%; height: 100%; }

/* --- 对话空状态主视觉 --- */
.ai-hero {
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  background: #0b1020;
  box-shadow: 0 0 0 1px rgba(124, 157, 255, .38), 0 12px 34px rgba(76, 91, 212, .3);
  animation: mascotBreathe 3.6s ease-in-out infinite;
}
.ai-hero .mascot-img { width: 100%; height: 100%; border-radius: 50%; }
.ai-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle at 50% 118%, rgba(124, 157, 255, .5), transparent 62%);
}

/* --- 登录页主视觉 ---
   高度由图片自身比例决定（width:100% + height:auto），整幅图完整呈现、
   零裁切，换任何比例的图都自适应；仅在超过 max-height 时才做 cover 裁切。
   不叠任何自己的文字或特效层。 */
.login-hero {
  position: relative;
  margin: -30px -28px 20px;
  overflow: hidden;
  border-radius: 20px 20px 16px 16px;
  background: #0b1020;
  line-height: 0;  /* 消除 img 底部基线间隙 */
  box-shadow: inset 0 0 0 1px rgba(124, 157, 255, .16);
}
.login-hero .mascot-img {
  width: 100%;
  height: auto;
  max-height: min(46vh, 300px);
  object-fit: cover;
  object-position: center 45%;
}

@media (max-width: 560px) {
  .login-hero { margin: -24px -20px 16px; }
  .login-hero .mascot-img { max-height: 34vh; }
}

/* ============================================================
   开发者通道（灰度测试专用 · 深色控制台主题）
   ============================================================ */
.dev-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid #f0a83c;
  background: #2a1f05;
  color: #ffc061;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  cursor: pointer;
  font-family: ui-monospace, Consolas, monospace;
}
.dev-chip::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffb43c;
  animation: devBlink 1.6s ease-in-out infinite;
}
.dev-chip:hover { background: #3a2a06; }
@keyframes devBlink { 0%, 100% { opacity: 1 } 50% { opacity: .25 } }

/* 全局悬浮入口：对话页隐藏顶栏时也能一键进入开发者通道 */
.dev-fab {
  position: fixed;
  right: 18px;
  bottom: 74px;   /* 右下角让给客服入口，两者同时出现时也不重叠 */
  z-index: 80;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid #f0a83c;
  background: linear-gradient(135deg, #3a2a06, #241b04);
  color: #ffc061;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .3);
  transition: transform .15s, box-shadow .15s;
}
.dev-fab[hidden] { display: none; }
.dev-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0, 0, 0, .36); }
.dev-fab.has-error {
  border-color: #ef4444;
  color: #ff9b9b;
  background: linear-gradient(135deg, #3a0d0d, #241004);
}
.dev-fab-badge {
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  padding: 0 6px;
  border-radius: 999px;
}

@media (max-width: 900px) {
  .dev-fab { right: 12px; bottom: calc(128px + env(safe-area-inset-bottom)); }
}

/* ============================================================
   客服反馈：学生侧悬浮入口 + 对话面板 / 管理员侧工作台
   ============================================================ */

/* --- 学生侧入口 --- */
.support-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 82;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 15px; border-radius: 999px; cursor: pointer;
  border: 1px solid transparent; color: #fff;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  font-size: 13.5px; font-weight: 600; font-family: inherit;
  box-shadow: 0 6px 22px rgba(99, 102, 241, .42);
  transition: transform .15s, box-shadow .15s;
}
.support-fab[hidden] { display: none; }
.support-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(99, 102, 241, .5); }
.support-fab.active { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.support-fab.has-unread { animation: supportPulse 2.4s ease-in-out infinite; }
@keyframes supportPulse {
  0%, 100% { box-shadow: 0 6px 22px rgba(99, 102, 241, .42), 0 0 0 0 rgba(99, 102, 241, .3); }
  50% { box-shadow: 0 6px 22px rgba(99, 102, 241, .42), 0 0 0 9px rgba(99, 102, 241, 0); }
}
.support-fab-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.support-fab-badge[hidden] { display: none; }

/* --- 学生侧对话面板 --- */
.support-panel {
  position: fixed; right: 18px; bottom: 78px; z-index: 90;
  width: 360px; max-width: calc(100vw - 24px);
  height: 470px; max-height: calc(100vh - 140px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.support-panel[hidden] { display: none; }
.support-head {
  display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(99, 102, 241, .09), rgba(139, 92, 246, .09));
}
.support-head-text { flex: 1; min-width: 0; }
.support-title { font-size: 14.5px; font-weight: 700; }
.support-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.support-close {
  border: none; background: transparent; color: var(--text-3); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 3px 5px; border-radius: 6px;
}
.support-close:hover { color: var(--danger); background: var(--surface-2); }
.support-body {
  flex: 1; min-height: 0; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.support-foot {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border); background: var(--surface-2);
}
.support-input {
  flex: 1; min-height: 42px; max-height: 116px; resize: none;
  padding: 9px 11px; border-radius: var(--radius-sm); font-size: 13px;
  line-height: 1.5; color: var(--text); background: var(--surface);
  border: 1px solid var(--border);
}
.support-input:focus { outline: none; border-color: var(--brand-1); }
.support-msg { display: flex; flex-direction: column; gap: 3px; max-width: 88%; }
.support-msg.own { align-self: flex-end; align-items: flex-end; }
.support-msg.other { align-self: flex-start; align-items: flex-start; }
.support-bubble {
  padding: 9px 12px; border-radius: 13px; font-size: 13px; line-height: 1.62;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  background: var(--surface-2); border: 1px solid var(--border);
}
.support-msg.own .support-bubble {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  color: #fff; border-color: transparent;
}
.support-time { font-size: 10.5px; color: var(--text-3); padding: 0 3px; }

/* --- 附件：选择按钮、待发送预览条、消息内渲染 --- */
.attach-btn {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font-size: 15px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s;
}
.attach-btn:hover { color: var(--brand-1); border-color: var(--brand-1); }
.attach-btn:disabled { opacity: .5; cursor: default; }
.attach-btn.is-uploading { animation: supportPulse 1.2s ease-in-out infinite; }

.attach-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-top: 1px solid var(--border); background: var(--surface-2);
}
.attach-bar[hidden] { display: none; }
.attach-chip {
  flex: 1; min-width: 0; font-size: 12px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attach-remove {
  flex: 0 0 auto; border: none; background: transparent; color: var(--text-3);
  cursor: pointer; font-size: 12px; padding: 2px 5px; border-radius: 6px;
}
.attach-remove:hover { color: var(--danger); background: var(--surface); }

.attach-image { display: block; max-width: 100%; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.attach-image img { display: block; max-width: 100%; max-height: 220px; object-fit: cover; }
.attach-file {
  display: flex; align-items: center; gap: 9px; max-width: 260px;
  padding: 9px 12px; border-radius: 12px; text-decoration: none;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.attach-file:hover { border-color: var(--brand-1); }
.attach-file-icon { font-size: 18px; flex: 0 0 auto; }
.attach-file-meta { min-width: 0; display: flex; flex-direction: column; }
.attach-file-name {
  font-size: 12.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attach-file-size { font-size: 11px; color: var(--text-3); }
/* 注意：文件卡片渲染在气泡「外面」，背景仍是面板底色，
   因此不能沿用气泡内文字的白字样式，否则在浅色主题下会看不见。 */
.support-empty, .support-loading {
  margin: auto; text-align: center; color: var(--text-3); font-size: 12.5px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.support-loading { flex-direction: row; gap: 8px; }
.support-empty-icon { font-size: 26px; }
.support-empty-desc { font-size: 11.5px; max-width: 230px; line-height: 1.6; }

/* --- 管理员工作台 --- */
.support-work { display: flex; height: 100%; min-height: 0; }
.ticket-panel {
  width: 320px; flex: 0 0 320px; min-height: 0;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--surface);
}
.ticket-head {
  padding: 12px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 9px;
}
.ticket-list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; }
.ticket-item {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 10px 11px; margin-bottom: 4px; cursor: pointer;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  background: transparent; font-family: inherit; color: inherit;
  transition: background .15s, border-color .15s;
}
.ticket-item:hover { background: var(--surface-2); }
.ticket-item.active { background: var(--brand-soft); border-color: rgba(99, 102, 241, .42); }
.ticket-item.is-closed .ticket-name { color: var(--text-3); }
.ticket-avatar { width: 34px; height: 34px; flex: 0 0 34px; font-size: 13px; }
.ticket-main { flex: 1; min-width: 0; }
.ticket-top { display: flex; align-items: baseline; gap: 8px; }
.ticket-name {
  font-size: 13.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ticket-time { margin-left: auto; flex: 0 0 auto; font-size: 10.5px; color: var(--text-3); }
.ticket-preview {
  font-size: 12px; color: var(--text-3); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ticket-tag { color: var(--brand-1); }
.ticket-unread {
  flex: 0 0 auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.ticket-dot { flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.ticket-dot.closed { background: var(--ok); }
.ticket-chat { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.ticket-chat-head {
  display: flex; align-items: center; gap: 11px; padding: 11px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap;
}
.tc-meta { flex: 1; min-width: 0; }
.tc-name { font-size: 14.5px; font-weight: 650; }
.tc-sub { font-size: 11.5px; color: var(--text-3); }
.tc-actions { display: flex; gap: 8px; }
.ticket-chat-body {
  flex: 1; min-height: 0; overflow-y: auto; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.ticket-chat-foot {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px;
  border-top: 1px solid var(--border); background: var(--surface-2);
}

@media (max-width: 900px) {
  .support-fab { right: 12px; bottom: calc(74px + env(safe-area-inset-bottom)); }
  .support-fab-text { display: none; }   /* 手机上只留图标，避免遮挡内容 */
  .support-panel {
    left: 12px; right: 12px; width: auto;
    bottom: calc(130px + env(safe-area-inset-bottom));
    max-height: calc(100vh - 200px);
  }
  .support-work { flex-direction: column; }
  .ticket-panel {
    width: 100%; flex: 0 0 auto; max-height: 44%;
    border-right: none; border-bottom: 1px solid var(--border);
  }
}

.nav-item.nav-dev { color: #b45309; }
.nav-item.nav-dev.active { color: #b45309; background: #fdf3e3; }
.dev-pill {
  margin-left: auto;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 1px 5px;
  border-radius: 5px;
  background: #f59e0b;
  color: #1a1204;
}

.dev-console {
  background: #0f1320;
  border: 1px solid #222941;
  border-radius: 16px;
  padding: 16px;
  min-height: calc(100vh - 130px);
  color: #c3cade;
  font-size: 13px;
}
.dev-console code {
  font-family: ui-monospace, Consolas, monospace;
  background: #1b2135;
  padding: 1px 5px;
  border-radius: 5px;
  color: #9db7ff;
}

.dev-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 14px;
  border-radius: 10px;
  background: #241b04;
  border: 1px solid #4a3608;
  color: #e8c98a;
  font-size: 12.5px;
  margin-bottom: 14px;
}
.dev-banner b { color: #ffc061; }
.dev-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #ffb43c;
  animation: devBlink 1.6s ease-in-out infinite; flex: 0 0 8px;
}

.dev-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.dev-stat {
  background: #151b2c;
  border: 1px solid #232b45;
  border-radius: 11px;
  padding: 10px 12px;
}
.dev-stat-label { font-size: 11.5px; color: #7d86a3; }
.dev-stat-value {
  font-size: 20px; font-weight: 700; color: #e8ecf8; margin-top: 2px;
  font-family: ui-monospace, Consolas, monospace; letter-spacing: -.02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dev-stat-foot { font-size: 10.5px; color: #5f6885; margin-top: 1px; }

.dev-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.dev-tab {
  padding: 7px 16px; border-radius: 9px; border: 1px solid #232b45;
  background: #151b2c; color: #96a0bd; cursor: pointer; font-size: 13px;
}
.dev-tab.active {
  background: linear-gradient(135deg, #2c3a72, #3c2f6b);
  border-color: #46549a; color: #e8ecf8; font-weight: 600;
}

.dev-toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 11px 12px; border-radius: 11px; background: #151b2c;
  border: 1px solid #232b45; margin-bottom: 14px;
}
.dev-toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.dev-console .chip {
  background: #1b2135; border-color: #29314c; color: #96a0bd;
}
.dev-console .chip:hover { border-color: #3d4870; }
.dev-console .chip.active {
  background: linear-gradient(135deg, #3b4a94, #4c3a86);
  border-color: transparent; color: #fff;
}
.dev-console .input,
.dev-console .select {
  background: #1b2135; border-color: #29314c; color: #d5dbee; font-size: 12.5px;
}
.dev-console .input::placeholder { color: #5f6885; }
.dev-console .input:focus,
.dev-console .select:focus { border-color: #4c5bd4; box-shadow: 0 0 0 3px rgba(76, 91, 212, .18); }
.dev-select { width: auto; padding: 6px 9px; }
.dev-input { width: 200px; padding: 6px 9px; }
.dev-input-sm { width: 90px; }
.dev-console .btn {
  background: #1b2135; border-color: #29314c; color: #c3cade; font-size: 12.5px;
}
.dev-console .btn:hover { background: #222a42; border-color: #3d4870; }
.dev-console .btn-danger { background: #2a1418; border-color: #5c2229; color: #f08a8a; }

.dev-stream { display: flex; flex-direction: column; gap: 6px; }
.dev-row {
  background: #141a2b; border: 1px solid #212942; border-left: 3px solid #33405f;
  border-radius: 9px; overflow: hidden;
}
.dev-row.warn { border-left-color: #d9a13b; }
.dev-row.error { border-left-color: #d9534f; background: #1e1418; }
.dev-row-head {
  display: flex; align-items: center; gap: 9px; padding: 8px 12px;
  cursor: pointer; flex-wrap: wrap;
}
.dev-row-head:hover { background: #192035; }
.dev-time {
  font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; color: #6d769a; flex: 0 0 auto;
}
.dev-kind {
  font-size: 11px; padding: 1px 7px; border-radius: 6px; font-weight: 600;
  background: #222b45; color: #9db7ff; flex: 0 0 auto;
}
.dev-kind-http { background: #1d2b3d; color: #6fb3f0; }
.dev-kind-llm { background: #2a2246; color: #b79dff; }
.dev-kind-conversation { background: #1b2e2a; color: #5fd6a8; }
.dev-kind-op { background: #2b2620; color: #e0b070; }
.dev-title {
  color: #dfe4f2; font-weight: 550; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46%;
}
.dev-user { font-size: 11.5px; color: #7d86a3; }
.dev-ms {
  margin-left: auto; font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px; color: #6fb3f0; flex: 0 0 auto;
}
.dev-arrow { color: #5f6885; font-size: 11px; flex: 0 0 auto; }
.dev-row-sum {
  padding: 0 12px 8px 12px; font-size: 11.5px; color: #6d769a;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dev-row.open .dev-row-sum { white-space: normal; }

.dev-detail {
  padding: 12px; border-top: 1px solid #212942; background: #0f1420;
}
.dev-sec-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: #6d769a; margin: 12px 0 6px;
}
.dev-sec-title:first-child { margin-top: 0; }
.dev-pre {
  background: #0a0e18; border: 1px solid #1d2438; border-radius: 8px;
  padding: 10px 12px; margin: 0; max-height: 260px; overflow: auto;
  font-family: ui-monospace, Consolas, monospace; font-size: 11.5px;
  line-height: 1.65; color: #b6c2dd; white-space: pre-wrap; word-break: break-word;
}
.dev-pre-full { max-height: 340px; color: #8b96b5; }
.dev-meta-line { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: #96a0bd; }
.dev-meta-line b { color: #dfe4f2; }
.dev-good { color: #5fd6a8; }
.dev-bad { color: #f08a8a; }
.dev-err {
  margin-top: 8px; padding: 8px 11px; border-radius: 8px;
  background: #2a1418; border: 1px solid #5c2229; color: #f0a0a0;
  font-family: ui-monospace, Consolas, monospace; font-size: 11.5px;
}
.dev-line {
  display: flex; gap: 10px; align-items: baseline; padding: 5px 9px;
  background: #151b2c; border: 1px solid #212942; border-radius: 7px;
  margin-bottom: 4px; font-size: 12px;
}
.dev-line span { min-width: 0; word-break: break-word; }
.dev-line b {
  margin-left: auto; font-family: ui-monospace, Consolas, monospace;
  font-size: 11px; color: #6fb3f0; white-space: nowrap;
}
.dev-line.warn { border-color: #4a3608; background: #241b04; }
.dev-line.warn b { color: #e0b070; }
.dev-none { font-size: 12px; color: #5f6885; font-style: italic; }
.dev-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.dev-q, .dev-a { margin-top: 10px; }
.dev-q-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: #6d769a; margin-bottom: 4px;
}
.dev-q-text {
  padding: 9px 12px; border-radius: 9px; background: #1b2135;
  border-left: 3px solid #4c5bd4; color: #dfe4f2; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}
.dev-a-text {
  padding: 10px 12px; border-radius: 9px; background: #12192a;
  border-left: 3px solid #5fd6a8; color: #c3cade; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto;
}

.dev-timing { margin-top: 10px; }
.dev-timing-bar {
  display: flex; height: 7px; border-radius: 4px; overflow: hidden;
  background: #1b2135; gap: 1px;
}
.dev-timing-bar span { display: block; height: 100%; }
.dev-timing-legend {
  display: flex; gap: 14px; flex-wrap: wrap; margin-top: 5px;
  font-size: 11px; color: #7d86a3; font-family: ui-monospace, Consolas, monospace;
}
.dev-timing-legend .strong { color: #dfe4f2; margin-left: auto; }

.dev-convs { display: flex; flex-direction: column; gap: 12px; }
.dev-conv {
  background: #141a2b; border: 1px solid #212942; border-radius: 11px; padding: 13px;
}
.dev-conv-head {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding-bottom: 9px; margin-bottom: 4px; border-bottom: 1px dashed #212942;
}
.dev-turn { padding: 10px 0; border-bottom: 1px dashed #1b2135; }
.dev-turn:last-child { border-bottom: none; padding-bottom: 0; }
.dev-turn-time {
  font-size: 11px; color: #5f6885; font-family: ui-monospace, Consolas, monospace;
}
.dev-turn-meta {
  display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px;
  font-size: 11px; color: #7d86a3;
}

@media (max-width: 1100px) {
  .dev-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dev-grid2 { grid-template-columns: 1fr; }
  .dev-title { max-width: 100%; }
}
@media (max-width: 640px) {
  .dev-console { padding: 12px; border-radius: 12px; }
  .dev-input { width: 100%; }
  .dev-toolbar-right { margin-left: 0; width: 100%; }
}

/* ============================================================
   消息操作条 / 引用 / 反馈
   ============================================================ */
.act-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-3);
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 7px;
  line-height: 1.7;
  transition: background .15s, color .15s;
}
.act-btn:hover { background: var(--surface-2); color: var(--text); }
.act-btn:disabled { opacity: .5; cursor: not-allowed; }
.act-btn.on { background: #e7f8f1; color: #0d9668; font-weight: 600; }
.act-btn.on-down { background: #fdeeee; color: #c53030; font-weight: 600; }

.fb-done { font-size: 11px; padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.fb-done.up { background: #e7f8f1; color: #0d9668; }
.fb-done.down { background: #fdeeee; color: #c53030; }

.quote-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: var(--surface-2);
  border-left: 3px solid var(--brand-1);
  font-size: 12.5px;
}
.quote-label { color: var(--brand-1); font-weight: 600; white-space: nowrap; }
.quote-text {
  color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0; flex: 1;
}
.quote-close {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-3); font-size: 13px; padding: 2px 5px; border-radius: 6px;
}
.quote-close:hover { background: var(--border); color: var(--danger); }

.quote-block {
  font-size: 11.5px;
  color: var(--text-3);
  padding: 5px 10px;
  margin-bottom: 6px;
  border-radius: 8px;
  background: var(--surface-2);
  border-left: 2px solid var(--border);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-row.user .quote-block { margin-left: auto; }

/* 播报中提示（点击即打断播报） */
.speaking-pill {
  position: fixed;
  left: 50%; bottom: 96px;
  transform: translateX(-50%);
  z-index: 70;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  color: #fff; font-size: 12.5px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(99, 102, 241, .42);
  animation: pulseSoft 1.6s ease-in-out infinite;
}
.speaking-pill[hidden] { display: none; }
@keyframes pulseSoft { 0%, 100% { opacity: 1 } 50% { opacity: .82 } }

/* ============================================================
   快捷键面板
   ============================================================ */
.shortcut-list { display: flex; flex-direction: column; gap: 2px; }
.shortcut-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; border-radius: 9px;
}
.shortcut-row:nth-child(odd) { background: var(--surface-2); }
.shortcut-row .desc { font-size: 13px; color: var(--text); }
.shortcut-row .keys { margin-left: auto; display: flex; gap: 5px; }
kbd {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px; padding: 2px 7px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border); color: var(--text-2); white-space: nowrap;
}

/* ============================================================
   深色模式（覆盖变量 + 少量硬编码色值）
   ============================================================ */
[data-theme="dark"] {
  --brand-1: #7c8cff;
  --brand-2: #a78bfa;
  --brand-soft: #232a4d;
  --bg: #0d1117;
  --surface: #161b26;
  --surface-2: #1b2130;
  --border: #2a3145;
  --text: #e7eaf3;
  --text-2: #a9b2c9;
  --text-3: #79839c;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 4px 16px rgba(0, 0, 0, .4);
  --shadow-lg: 0 14px 44px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
[data-theme="dark"] body { background: var(--bg); }
[data-theme="dark"] .topbar { background: rgba(22, 27, 38, .88); }
[data-theme="dark"] .tabbar { background: rgba(22, 27, 38, .96); }
[data-theme="dark"] .trace-item { background: var(--surface); }
[data-theme="dark"] .trace-head:hover,
[data-theme="dark"] .btn-ghost:hover,
[data-theme="dark"] .nav-item:hover { background: var(--surface-2); }
[data-theme="dark"] .badge.gray { background: #232a3d; color: var(--text-2); }
[data-theme="dark"] .badge.ok { background: #12362a; color: #6ee7b7; }
[data-theme="dark"] .badge.warn { background: #3a2c0d; color: #fcd34d; }
[data-theme="dark"] .badge.danger { background: #3b1a1d; color: #fca5a5; }
[data-theme="dark"] .badge.info { background: #17263f; color: #93c5fd; }
[data-theme="dark"] .conflict-card,
[data-theme="dark"] .conflict-card[style] { background: #2a2110 !important; border-color: #4a3608 !important; }
[data-theme="dark"] .mem-item[style],
[data-theme="dark"] .card[style*="fffbf3"] { background: var(--surface) !important; }
[data-theme="dark"] .trace-box { background: var(--surface-2); border-color: var(--border); }
[data-theme="dark"] .login-tabs { background: #1b2130; }
[data-theme="dark"] .login-tabs button.active { background: var(--surface); }
[data-theme="dark"] .login-wrap {
  background:
    radial-gradient(1200px 600px at 15% 0%, #1a2138 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 100%, #241d38 0%, transparent 55%),
    var(--bg);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #2f3750; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #3d4665; }
[data-theme="dark"] .act-btn.on { background: #12362a; color: #6ee7b7; }
[data-theme="dark"] .act-btn.on-down { background: #3b1a1d; color: #fca5a5; }
[data-theme="dark"] .fb-done.up { background: #12362a; color: #6ee7b7; }
[data-theme="dark"] .fb-done.down { background: #3b1a1d; color: #fca5a5; }
[data-theme="dark"] .web-badge { background: #17263f; color: #93c5fd; }
[data-theme="dark"] .skeleton { background: linear-gradient(90deg, #1b2130 25%, #232a3d 37%, #1b2130 63%); }

/* 主题切换按钮 */
.theme-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer; font-size: 12.5px; width: 100%;
  transition: all .15s;
}
.theme-btn:hover { border-color: var(--brand-1); color: var(--brand-1); }

@media print {
  .sidebar, .tabbar, .composer, .topbar-actions { display: none !important; }
}

/* ============================================================
   数据洞察（仅管理员）：记忆图谱 / 画像雷达 / 质量趋势 / 手机壳演示
   ============================================================ */
.ig-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; padding: 14px 16px;
}
.ig-toolbar-left, .ig-toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ig-field { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.ig-field .select { min-width: 240px; }

.ig-stat-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.ig-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}
.ig-chip b { color: var(--brand-1); font-size: 13px; }

.ig-svg { width: 100%; height: auto; display: block; }
.ig-svg-radar { max-width: 360px; margin: 0 auto; }
.ig-svg-trend { max-height: 330px; }
.ig-grid { stroke: var(--border); }
.ig-lbl { fill: var(--text-2); }
.ig-lbl-dim { fill: var(--text-3); }
.ig-lbl-strong { fill: var(--text); }
.ig-value { fill: var(--brand-1); }

.ig-node circle { transition: stroke-width .15s, filter .15s; }
.ig-node:hover circle { filter: brightness(1.12); }

.ig-legend-row { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; align-items: center; }
.ig-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-3); }
.ig-legend i { width: 16px; height: 3px; border-radius: 2px; display: inline-block; }

.ig-legend-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px; cursor: pointer; font-size: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-3);
  opacity: .5; transition: all .15s;
}
.ig-legend-btn.on { opacity: 1; color: var(--text); border-color: var(--brand-1); }
.ig-legend-btn i { width: 14px; height: 3px; border-radius: 2px; }
.ig-legend-btn b { font-size: 12px; color: var(--brand-1); }

.ig-detail, .ig-detail-empty {
  margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-2);
}
.ig-detail-empty { color: var(--text-3); }
.ig-detail { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.ig-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: 0 0 auto; }
.ig-detail pre {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-family: var(--font); font-size: 12.5px; color: var(--text-2); flex: 1 1 100%;
}

.ig-dim-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.ig-dim-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-2); }
.ig-dim-value { font-weight: 700; color: var(--brand-1); }
.ig-bar { height: 6px; border-radius: 4px; background: var(--border); margin: 5px 0 6px; overflow: hidden; }
.ig-bar i {
  display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--brand-1), var(--brand-2));
}
.ig-dim-ev { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--text-3); }
.ig-dim-ev span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ig-device-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.phone-stage { display: flex; justify-content: center; overflow: hidden; }
.phone-shell {
  position: relative; flex: 0 0 auto; box-sizing: border-box; padding: 12px;
  background: #111621; border-radius: 42px; transform-origin: top center;
  box-shadow: 0 18px 50px rgba(20, 24, 45, .28);
}
.phone-notch {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 108px; height: 18px; background: #111621; border-radius: 0 0 12px 12px; z-index: 2;
}
.phone-screen-wrap { border-radius: 30px; overflow: hidden; background: #fff; }
.phone-screen { width: 100%; height: 100%; border: 0; display: block; }
.ig-phone-meta {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; margin-top: 12px; flex-wrap: wrap;
}

@media (max-width: 900px) {
  .ig-toolbar { flex-direction: column; align-items: stretch; }
  .ig-field { justify-content: space-between; }
  .ig-field .select { min-width: 0; flex: 1; }
}

.ig-svg-funnel { max-height: 430px; }
.fn-notes {
  margin: 10px 0 0; padding-left: 18px; font-size: 11.5px; color: var(--text-3);
  display: flex; flex-direction: column; gap: 4px;
}
.fn-notes b { color: var(--text-2); }

/* ============================================================
   对话配图（手机拍照 / 相册上传）
   ============================================================ */
.pic-btn {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 38px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  transition: all .18s;
}
.pic-btn:hover { border-color: var(--brand-1); color: var(--brand-1); }

.img-bar {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
  border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 8px;
}
.img-thumb {
  width: 52px; height: 52px; object-fit: cover; border-radius: 9px;
  border: 1px solid var(--border); flex: 0 0 52px; background: var(--surface);
}
.img-meta { min-width: 0; flex: 1; }
.img-name {
  font-size: 12.5px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.img-state { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.img-state.is-warn { color: var(--danger); }
.img-remove {
  border: none; background: transparent; cursor: pointer; color: var(--text-3);
  font-size: 14px; padding: 4px 7px; border-radius: 7px; flex: 0 0 auto;
}
.img-remove:hover { background: var(--border); color: var(--danger); }

.msg-image { margin-bottom: 8px; }
.msg-image img {
  max-width: min(320px, 100%); max-height: 320px; border-radius: 12px;
  border: 1px solid var(--border); display: block;
}
.msg-row.user .msg-image { display: flex; justify-content: flex-end; }

/* ============================================================
   咨询报告（浏览器打印 / 另存为 PDF）
   ============================================================ */
.report-picker { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.report-picker .select { flex: 1; min-width: 220px; }

.report-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px;
}

.report-page {
  max-width: 820px; margin: 0 auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 34px 40px 40px; box-shadow: var(--shadow-sm);
  color: var(--text); font-size: 13px; line-height: 1.75;
}
.report-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  border-bottom: 2px solid var(--brand-1); padding-bottom: 14px; margin-bottom: 22px;
}
.report-brand { font-size: 12.5px; font-weight: 700; color: var(--brand-1); letter-spacing: 1px; }
.report-doc-title { font-size: 22px; font-weight: 800; margin-top: 4px; }
.report-head-meta { text-align: right; font-size: 11.5px; color: var(--text-3); line-height: 1.9; }

.report-sec { margin-bottom: 26px; }
.report-sec h3 {
  font-size: 14.5px; font-weight: 700; margin-bottom: 12px;
  padding-left: 10px; border-left: 3px solid var(--brand-1);
}
.report-sub { font-size: 12px; color: var(--text-3); margin: 14px 0 8px; }

.report-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.report-table th {
  width: 92px; text-align: left; font-weight: 600; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border); padding: 7px 10px;
}
.report-table td { border: 1px solid var(--border); padding: 7px 10px; }

.report-kv {
  display: flex; gap: 10px; padding: 6px 0; font-size: 12.5px;
  border-bottom: 1px dashed var(--border);
}
.report-kv span { color: var(--text-3); flex: 0 0 78px; }
.report-kv b { font-weight: 600; }

.report-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.report-stat {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; background: var(--surface-2);
}
.report-stat .k { font-size: 11.5px; color: var(--text-3); }
.report-stat .v { font-size: 19px; font-weight: 700; color: var(--brand-1); }

.report-turn { margin-bottom: 14px; page-break-inside: avoid; }
.report-turn-head { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.report-role { font-size: 12px; font-weight: 700; }
.report-turn.is-user .report-role { color: var(--brand-1); }
.report-turn.is-ai .report-role { color: var(--ok); }
.report-time { font-size: 11px; color: var(--text-3); }
.report-turn-body {
  border: 1px solid var(--border); border-left: 3px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 12.5px;
  background: var(--surface-2);
}
.report-turn.is-user .report-turn-body { border-left-color: var(--brand-1); }
.report-turn.is-ai .report-turn-body { border-left-color: var(--ok); }
.report-turn-body p { margin: 0 0 6px; }
.report-turn-body p:last-child { margin-bottom: 0; }
.report-img img {
  max-width: 240px; border-radius: 10px; border: 1px solid var(--border); margin: 6px 0;
}

.report-mem {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; margin-bottom: 8px; page-break-inside: avoid;
}
.report-mem-tag {
  display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 7px;
  border-radius: 999px; margin-right: 6px;
}
.report-mem-tag.written { background: #e8f7f0; color: #0f766e; }
.report-mem-tag.recalled { background: #eef2ff; color: #4338ca; }
.report-mem-cat { font-size: 11px; color: var(--text-3); }
.report-mem-text { font-size: 12.5px; margin-top: 4px; }
.report-mem-meta { font-size: 11px; color: var(--text-3); margin-top: 3px; }

.report-conflict {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; margin-bottom: 8px; page-break-inside: avoid;
}
.report-empty { font-size: 12.5px; color: var(--text-3); }

.report-foot {
  border-top: 1px solid var(--border); margin-top: 26px; padding-top: 12px;
  font-size: 11px; color: var(--text-3); line-height: 1.8;
}

/* ============================================================
   头像与显示名称（个人中心 · 学生结构化档案）
   ============================================================ */
.avatar-img { overflow: hidden; padding: 0; background: var(--surface-2); }
.avatar-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar-editor {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 14px; margin-bottom: 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.avatar-edit-box {
  position: relative; width: 76px; height: 76px; flex: 0 0 76px;
  border-radius: 50%; overflow: hidden; cursor: pointer;
  border: 2px solid var(--border); background: var(--surface);
}
.avatar-edit-box .avatar {
  width: 100%; height: 100%; border-radius: 0; font-size: 30px; margin: 0;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff;
}
.avatar-edit-box .avatar-img { background: var(--surface-2); }
.avatar-edit-mask {
  position: absolute; left: 0; right: 0; bottom: 0; text-align: center;
  font-size: 11px; padding: 3px 0; color: #fff;
  background: rgba(20, 24, 45, .62); opacity: 0; transition: opacity .15s;
}
.avatar-edit-box:hover .avatar-edit-mask { opacity: 1; }
.avatar-edit-box.is-uploading { opacity: .55; }
.avatar-edit-side { flex: 1; min-width: 240px; }

/* ============================================================
   账号安全：登录设备列表
   ============================================================ */
.device-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 8px;
  background: var(--surface-2);
}
.device-name { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; }
.device-meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* ============================================================
   只读分享页
   ============================================================ */
.share-shell { max-width: 900px; margin: 0 auto; padding: 22px 18px 40px; }
.share-brand { font-size: 13px; font-weight: 700; color: var(--brand-1); letter-spacing: .5px; }
.report-shared-tag {
  display: inline-block; margin-left: 10px; padding: 1px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; vertical-align: middle;
  background: #eef2ff; color: #4338ca;
}
[data-theme="dark"] .report-shared-tag { background: #232a4d; color: #a5b4fc; }

/* ============================================================
   记忆贡献条 / 低置信度警示
   ============================================================ */
.contrib-bar { margin-top: 8px; }
.contrib-text { font-size: 11.5px; color: var(--text-3); margin-bottom: 4px; }
.contrib-track {
  display: flex; height: 7px; border-radius: 999px; overflow: hidden;
  background: var(--border); max-width: 320px;
}
.contrib-track span { display: block; height: 100%; transition: width .3s; }

.low-conf-hint {
  margin-top: 8px; padding: 8px 11px; font-size: 12px; line-height: 1.65;
  border-radius: var(--radius-sm); border: 1px solid #f0dcb6; background: #fffbf3; color: #92400e;
  max-width: 560px;
}
.low-conf-hint .lch-note { display: block; font-size: 11.5px; color: #a16207; margin-top: 2px; }
[data-theme="dark"] .low-conf-hint { background: #2a2110; border-color: #4a3608; color: #fcd34d; }
[data-theme="dark"] .low-conf-hint .lch-note { color: #d9b23c; }

/* ============================================================
   记忆写入实时动画
   ============================================================ */
.mem-flow-layer {
  position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden;
}
.mem-node {
  position: absolute; display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 11.5px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow); color: var(--text-2);
  transform-origin: left center;
  transition: transform 780ms cubic-bezier(.22, .61, .36, 1), opacity 780ms ease;
}
.mem-node .mn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: 0 0 7px; }
.mem-node.keep {
  color: var(--brand-1); border-color: var(--brand-1); background: var(--brand-soft);
}
.mem-node.keep .mn-dot { background: var(--brand-1); }
.badge.mem-pulse { animation: memPulse .95s ease; }
@keyframes memPulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.34); box-shadow: 0 0 0 7px rgba(99, 102, 241, .22); }
  100% { transform: scale(1); }
}

/* ============================================================
   检索向量空间散点图
   ============================================================ */
.vm-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.vm-controls .input { flex: 1; min-width: 220px; }
.ig-svg-vmap { max-height: 460px; }
.vm-dot circle { transition: r .15s, opacity .15s; }
.vm-dot:hover circle { r: 8; opacity: 1; }
.vm-hits { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.vm-hit {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2); font-size: 12.5px;
}
.vm-hit-kind {
  flex: 0 0 auto; font-size: 10.5px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
}
.vm-hit-kind.memory { background: #f3e8ff; color: #7c3aed; }
.vm-hit-kind.knowledge { background: #e0f2fe; color: #0369a1; }
[data-theme="dark"] .vm-hit-kind.memory { background: #2b2340; color: #c4b5fd; }
[data-theme="dark"] .vm-hit-kind.knowledge { background: #14293b; color: #7dd3fc; }
.vm-hit-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vm-hit-score { flex: 0 0 auto; font-weight: 700; color: var(--brand-1); font-variant-numeric: tabular-nums; }

/* ============================================================
   答辩演示模式（大屏 / 投屏）
   ============================================================ */
.stage-chip.off { opacity: .75; }
.stage-chip.on { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; border-color: transparent; }

html[data-stage="on"] { font-size: 17px; }
html[data-stage="on"] .sidebar { display: none; }
html[data-stage="on"] .tabbar { display: none !important; }
html[data-stage="on"] .dev-fab { display: none !important; }
html[data-stage="on"] .main { flex: 1 1 auto; width: 100%; }
html[data-stage="on"] .view { padding: 26px 30px 46px; }
html[data-stage="on"] .topbar h2 { font-size: 21px; }
html[data-stage="on"] .topbar .sub { font-size: 13px; }
html[data-stage="on"] .card-title { font-size: 15.5px; }
html[data-stage="on"] .msg-bubble { font-size: 15px; }
html[data-stage="on"] .msg-row { max-width: 1000px; }
html[data-stage="on"] .composer-inner { max-width: 1000px; }
html[data-stage="on"] .chat-scroll > * { max-width: 1000px; }

/* 打印：只留报告正文，并强制浅色（深色主题下打印同样清晰） */
@media print {
  .sidebar, .tabbar, .topbar, .topbar-actions, .composer, .no-print,
  .dev-fab, .speaking-pill, .toast-wrap { display: none !important; }
  :root, [data-theme="dark"] {
    --bg: #ffffff; --surface: #ffffff; --surface-2: #fafbff; --border: #d8dbe6;
    --text: #1f2333; --text-2: #444a5e; --text-3: #6b7189; --brand-1: #4f46e5;
  }
  html, body { background: #fff !important; height: auto !important; overflow: visible !important; }
  .app-shell, .main, .view, .view.no-pad {
    display: block !important; height: auto !important; overflow: visible !important;
    padding: 0 !important; background: #fff !important;
  }
  .report-page {
    max-width: none; margin: 0; border: 0; border-radius: 0;
    box-shadow: none; padding: 0;
  }
  .report-turn, .report-mem, .report-conflict { page-break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: A4; margin: 16mm 14mm; }
}
