:root {
  --bg: #f5f6f8;
  --sidebar-bg: #ffffff;
  --sidebar-w: 248px;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --primary: #4f46e5;
  --primary-light: #eef2ff;
  --primary-hover: #4338ca;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --success: #10b981;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---- 布局 ---- */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin-left .25s;
}

.sidebar-brand {
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; font-weight: 700;
}
.sidebar-brand .brand-text { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.sidebar-brand .brand-sub { font-size: 11px; color: var(--text-muted); }

.nav { padding: 8px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 11px; color: var(--text-light); text-transform: uppercase; letter-spacing: .5px; padding: 12px 10px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-muted);
  font-size: 14px; font-weight: 500;
  transition: all .15s; user-select: none;
}
.nav-item:hover { background: #f3f4f6; color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-item .badge { margin-left: auto; font-size: 11px; background: var(--primary); color: #fff; border-radius: 10px; padding: 1px 7px; }

.sidebar-footer { padding: 10px 14px; border-top: 1px solid var(--border); }
.llm-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.llm-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex-shrink: 0; }
.llm-dot.ready { background: var(--success); }
.llm-status .llm-name { font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- 主区域 ---- */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 56px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  display: flex; align-items: center;
  padding: 0 20px; gap: 12px;
}
.topbar .menu-btn { display: none; font-size: 20px; cursor: pointer; color: var(--text-muted); background: none; border: none; }
.topbar h1 { font-size: 16px; font-weight: 600; }
.topbar .spacer { flex: 1; }

.topbar-profile {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 5px; border-radius: 20px;
  cursor: pointer; transition: background .15s;
  user-select: none;
}
.topbar-profile:hover { background: #f3f4f6; }
.profile-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff; flex-shrink: 0;
}
.profile-name {
  font-size: 13px; font-weight: 500; color: var(--text);
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 768px) {
  .profile-name { display: none; }
}

.content { flex: 1; overflow-y: auto; padding: 20px; }
.content.narrow { max-width: 860px; margin: 0 auto; }

/* ---- 通用组件 ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card);
  color: var(--text); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { background: #f9fafb; border-color: #d1d5db; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger-light); }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-icon { padding: 7px; width: 34px; height: 34px; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input, .textarea, .select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card);
  font-size: 14px; color: var(--text); font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field { margin-bottom: 16px; }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

/* ---- 卡片网格 ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  transition: all .15s; position: relative;
}
.card:hover { box-shadow: var(--shadow-md); border-color: #d1d5db; }
.card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79,70,229,.2); }

.card-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.card-icon { font-size: 22px; line-height: 1; flex-shrink: 0; }
.card-title { font-weight: 600; font-size: 14px; flex: 1; }
.card-desc { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.card-actions { display: flex; gap: 6px; margin-top: 10px; }
.card-badge { position: absolute; top: 10px; right: 10px; font-size: 10px; color: var(--text-light); }
.card-toggle { position: absolute; top: 14px; right: 14px; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: #d1d5db; border-radius: 11px; transition: .2s; }
.switch .slider:before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(18px); }

/* ---- 专家/资料库 页面 ---- */
.esc-layout { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.esc-panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.esc-panel-head { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.esc-panel-head .panel-count { margin-left: auto; font-size: 12px; color: var(--text-muted); font-weight: 400; }
.esc-panel-body { padding: 12px; max-height: 320px; overflow-y: auto; }

.mini-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); margin-bottom: 8px;
  cursor: pointer; transition: all .15s;
}
.mini-card:hover { background: #f9fafb; }
.mini-card.active { border-color: var(--primary); background: var(--primary-light); }
.mini-card .mc-icon { font-size: 18px; flex-shrink: 0; }
.mini-card .mc-info { flex: 1; min-width: 0; }
.mini-card .mc-name { font-size: 13px; font-weight: 600; }
.mini-card .mc-desc { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-card .mc-check { color: var(--primary); font-size: 16px; }

/* ---- 对话区 ---- */
.chat-container { display: flex; flex-direction: column; height: 100%; max-width: 900px; margin: 0 auto; }
.chat-messages { flex: 1; overflow-y: auto; padding: 8px 0; }
.msg { display: flex; gap: 12px; margin-bottom: 20px; padding: 0 4px; }
.msg-avatar { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.msg.user .msg-avatar { background: #e0e7ff; }
.msg.assistant .msg-avatar { background: var(--primary); color: #fff; }
.msg-body { flex: 1; min-width: 0; }
.msg-role { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; font-weight: 600; }
.msg-content { font-size: 14px; line-height: 1.7; word-break: break-word; }
.msg-content p { margin-bottom: 8px; }
.msg-content pre { background: #1e293b; color: #e2e8f0; padding: 12px 14px; border-radius: var(--radius-sm); overflow-x: auto; font-family: var(--mono); font-size: 13px; margin: 8px 0; }
.msg-content code { font-family: var(--mono); font-size: 13px; background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }
.msg-content pre code { background: none; padding: 0; }
/* 降级提示：所选模型调不通时如实告知，别让用户以为 AI 突然变笨 */
.msg-notice { display: flex; gap: 9px; margin-top: 10px; padding: 9px 12px; border-radius: var(--radius-sm); background: #fffbeb; border: 1px solid #fcd34d; font-size: 12.5px; line-height: 1.6; color: #92400e; }
.msg-notice .mn-icon { flex: none; font-size: 13px; line-height: 1.5; }
.msg-notice .mn-detail { margin-top: 3px; color: #b45309; opacity: .85; word-break: break-all; font-family: var(--mono); font-size: 11.5px; }
.msg-content table { border-collapse: collapse; margin: 8px 0; width: 100%; }
.msg-content th, .msg-content td { border: 1px solid var(--border); padding: 6px 10px; font-size: 13px; }
.msg-content th { background: #f9fafb; }
.msg-content ul, .msg-content ol { margin: 8px 0; padding-left: 22px; }
.msg-content h1, .msg-content h2, .msg-content h3 { margin: 12px 0 6px; font-weight: 600; }
.msg-content h1 { font-size: 17px; } .msg-content h2 { font-size: 15px; } .msg-content h3 { font-size: 14px; }
.msg-content blockquote { border-left: 3px solid var(--primary); margin: 8px 0; padding: 4px 12px; color: var(--text-muted); }
.msg.error .msg-content { color: var(--danger); }

.typing-indicator span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--text-light); margin: 0 2px; animation: blink 1.2s infinite; }
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,60%,100% { opacity: .3; } 30% { opacity: 1; } }

.chat-input-area { padding: 12px 0 4px; border-top: 1px solid var(--border); }
.chat-input-wrap { display: flex; gap: 10px; align-items: flex-end; }
.chat-input { flex: 1; resize: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 14px; font-size: 14px; font-family: inherit; line-height: 1.5; max-height: 140px; min-height: 44px; }
.chat-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.chat-send { width: 44px; height: 44px; border-radius: var(--radius); border: none; background: var(--primary); color: #fff; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: .15s; flex-shrink: 0; }
.chat-send:hover { background: var(--primary-hover); }
.chat-send:disabled { opacity: .4; cursor: not-allowed; }

.chat-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 9px; border-radius: 12px; background: var(--primary-light); color: var(--primary); font-weight: 500; }
.toolbar-chip.muted { background: #f3f4f6; color: var(--text-muted); }
.toolbar-hint { font-size: 12px; color: var(--text-muted); margin-left: auto; }

/* ---- 空状态 ---- */
.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty h3 { font-size: 16px; color: var(--text); margin-bottom: 6px; font-weight: 600; }
.empty p { font-size: 13px; }

/* ---- 模态框 ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal {
  background: var(--card); border-radius: var(--radius);
  width: 100%; max-width: 520px; max-height: 88vh;
  display: flex; flex-direction: column;
  overflow: hidden;              /* 只让 body 滚，头尾固定 */
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-head, .modal-foot { flex-shrink: 0; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head h3 { font-size: 16px; font-weight: 600; flex: 1; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); padding: 4px; line-height: 1; }
.modal-body { padding: 20px; flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- 资料库 ---- */
.doc-list { display: flex; flex-direction: column; gap: 10px; }
.doc-item { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 12px; transition: .15s; }
.doc-item:hover { box-shadow: var(--shadow); border-color: #d1d5db; }
.doc-item .doc-icon { font-size: 20px; flex-shrink: 0; }
.doc-item .doc-meta { flex: 1; min-width: 0; }
.doc-item .doc-title { font-weight: 600; font-size: 14px; }
.doc-item .doc-info { font-size: 12px; color: var(--text-muted); }
.doc-item .doc-cat { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #f3f4f6; color: var(--text-muted); }

.section-head { display: flex; align-items: center; margin-bottom: 16px; gap: 12px; }
.section-head h2 { font-size: 18px; font-weight: 600; }
.section-head .spacer { flex: 1; }

/* ---- Toast ---- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 10px 20px; border-radius: var(--radius-sm); font-size: 14px; z-index: 200; box-shadow: var(--shadow-md); animation: slideUp .25s; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideUp { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---- 设置 ---- */
.settings-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; max-width: 640px; }
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.preset-btn { padding: 6px 14px; border-radius: 18px; border: 1px solid var(--border); background: var(--card); font-size: 13px; cursor: pointer; transition: .15s; color: var(--text-muted); }
.preset-btn:hover { border-color: var(--primary); color: var(--primary); }
.preset-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.test-result { margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; }
.test-result.ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.test-result.fail { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }

.danger-zone { border: 1px solid #fecaca; border-radius: var(--radius); padding: 16px; margin-top: 24px; background: #fffafa; }
.danger-zone h3 { color: var(--danger); font-size: 14px; margin-bottom: 8px; }

/* ---- 响应式 ---- */
@media (max-width: 768px) {
  .sidebar { position: fixed; z-index: 50; height: 100%; margin-left: calc(-1 * var(--sidebar-w)); }
  .sidebar.open { margin-left: 0; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  .topbar .menu-btn { display: block; }
  .content { padding: 14px; }
}

/* 滚动条美化 */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
.sidebar-backdrop.show { display: block; }

@media (max-width: 1024px) and (min-width: 769px) {
  :root { --sidebar-w: 200px; }
  .esc-layout { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 16px; }
}

@media (max-width: 768px) {
  .esc-layout { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .topbar { height: calc(56px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); padding-left: 12px; padding-right: 12px; }
  .topbar h1 { font-size: 15px; }
  .modal { max-width: calc(100vw - 24px); max-height: 80vh; }
  .modal-body { padding: 16px; }
  .nav-item { padding: 12px 10px; }
  .btn { padding: 10px 16px; }
  .btn-sm { padding: 8px 12px; }
  .chat-send { width: 48px; height: 48px; }
  .chat-input { min-height: 48px; }
  .esc-panel-body { max-height: 240px; }
  .row { flex-direction: column; }
  .row > * { width: 100%; }
  .section-head { flex-wrap: wrap; gap: 8px; }
  .doc-item { flex-wrap: wrap; }
}

/* ============================================================
   登录 / 注册
   ============================================================ */
.auth-screen {
  position: fixed; inset: 0; z-index: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px;
  gap: 14px;
}
.auth-card {
  width: 100%; max-width: 392px; background: var(--card);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-md); padding: 28px;
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth-logo {
  width: 40px; height: 40px; border-radius: 11px; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 19px; flex-shrink: 0;
}
.auth-title { font-size: 16px; font-weight: 600; line-height: 1.3; }
.auth-sub { font-size: 12px; color: var(--text-muted); }
.auth-tabs {
  display: flex; gap: 4px; background: #f3f4f6; padding: 4px;
  border-radius: 9px; margin-bottom: 18px;
}
.auth-tab {
  flex: 1; padding: 7px; font-size: 13px; border-radius: 6px; cursor: pointer;
  color: var(--text-muted); border: none; background: none; font-family: inherit;
  transition: background .15s, color .15s;
}
.auth-tab.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.auth-error {
  display: none; background: var(--danger-light); color: var(--danger);
  font-size: 13px; padding: 9px 12px; border-radius: 8px; margin-bottom: 12px;
}
.auth-error.show { display: block; }
.auth-notice {
  background: var(--primary-light); color: var(--primary);
  font-size: 12px; padding: 9px 12px; border-radius: 8px; margin-bottom: 14px;
  line-height: 1.5;
}
.auth-foot { font-size: 12px; color: var(--text-light); text-align: center; margin-top: 14px; line-height: 1.6; }
.auth-card .btn { width: 100%; justify-content: center; padding: 9px; }

/* 额度进度条 */
.quota-wrap { margin-top: 10px; }
.quota-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }
.quota-bar { height: 6px; background: #eef0f3; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.quota-bar > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .25s; }
.quota-bar.warn > i { background: #f59e0b; }
.quota-bar.danger > i { background: var(--danger); }

/* 顶栏用户信息 */
.profile-meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.profile-sub { font-size: 11px; color: var(--text-light); }

/* ============================================================
   管理后台
   ============================================================ */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-num { font-size: 22px; font-weight: 600; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.admin-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.admin-toolbar .input { flex: 1; min-width: 180px; }

.admin-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.admin-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); padding: 10px 14px; background: #fafbfc; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table td { padding: 11px 14px; font-size: 13px; border-bottom: 1px solid #f1f3f5; vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #fcfcfd; }
.admin-table .mono { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }

.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; line-height: 1.6; }
.badge-admin { background: #eef2ff; color: var(--primary); }
.badge-user { background: #f3f4f6; color: var(--text-muted); }
.badge-active { background: #ecfdf5; color: #059669; }
.badge-banned { background: var(--danger-light); color: var(--danger); }

.admin-pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; font-size: 13px; color: var(--text-muted); }
.admin-empty { text-align: center; padding: 40px; color: var(--text-light); font-size: 13px; }

/* Logo 支持图片形式（站点设置里上传） */
.logo-img { background: transparent !important; padding: 0 !important; overflow: hidden; }
.logo-img img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }

.logo-preview {
  width: 56px; height: 56px; border-radius: 12px; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; overflow: hidden; flex-shrink: 0;
}
.logo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.logo-row { display: flex; align-items: center; gap: 12px; }

/* ============================================================
   侧边栏历史会话
   ============================================================ */
.nav { flex: 0 0 auto; overflow: visible; }

.conv-panel {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  border-top: 1px solid var(--border);
}
.conv-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 6px; flex-shrink: 0;
}
.conv-title { font-size: 11px; color: var(--text-light); letter-spacing: .5px; font-weight: 600; }
.conv-new {
  border: none; background: none; color: var(--primary);
  font-size: 12px; cursor: pointer; padding: 2px 6px;
  border-radius: 5px; font-family: inherit; font-weight: 500;
}
.conv-new:hover { background: var(--primary-light); }

.conv-list { flex: 1 1 auto; overflow-y: auto; padding: 0 8px 8px; }
.conv-item {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  font-size: 13px; color: var(--text-muted);
  transition: background .12s, color .12s;
}
.conv-item:hover { background: #f3f4f6; }
.conv-item.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }
.conv-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-del {
  flex-shrink: 0; opacity: 0; border: none; background: none;
  color: var(--text-light); cursor: pointer; font-size: 15px;
  line-height: 1; padding: 0 3px; border-radius: 4px;
  transition: opacity .12s, color .12s;
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: var(--danger); background: var(--danger-light); }
.conv-empty { padding: 18px 12px; font-size: 12px; color: var(--text-light); text-align: center; line-height: 1.7; }

/* 管理后台标签页 */
.admin-tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.admin-tab {
  padding: 7px 15px; font-size: 13px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card);
  color: var(--text-muted); cursor: pointer; font-family: inherit;
  transition: all .15s;
}
.admin-tab:hover { border-color: #d1d5db; }
.admin-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 500; }

/* 会话详情查看 */
.cv-meta {
  font-size: 12px; color: var(--text-muted); line-height: 1.9;
  background: #f8f9fb; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px;
}
.conv-viewer { max-height: 54vh; overflow-y: auto; padding-right: 4px; }
.cv-msg { display: flex; gap: 10px; margin-bottom: 12px; }
.cv-role { flex-shrink: 0; width: 34px; font-size: 12px; color: var(--text-light); padding-top: 3px; }
.cv-text {
  flex: 1 1 auto; font-size: 13px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  background: #f6f7f9; border-radius: 8px; padding: 8px 12px;
}
.cv-msg.assistant .cv-text { background: var(--primary-light); }

/* 头像：图片模式 */
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }

.avatar-row { display: flex; align-items: center; gap: 14px; }
.avatar-preview {
  width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 600; overflow: hidden;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ============================================================
   会话首页（空会话欢迎页）
   ============================================================ */
.esc-config-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; margin-bottom: 10px; user-select: none; }

/* 首页容器
   关键：flex-shrink 必须是 0 —— 面板展开、窗口变矮时，首页保持内容高度，
   整块超出部分交给 .content 滚动；否则会被压扁，内容上下溢出盖住面板。 */
.chat-home {
  flex: 1 0 auto;
  display: flex; flex-direction: column; justify-content: center;
  text-align: center;
}
.home-inner {
  width: 100%; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 16px 36px;
}
.home-inner > * { flex-shrink: 0; max-width: 100%; }

/* 首页模式下输入区不参与压缩，保证始终在首页内容之后 */
.home-mode .chat-input-area { flex-shrink: 0; }

.home-title {
  font-size: 34px; font-weight: 700; line-height: 1.35;
  letter-spacing: -.5px; color: var(--text);
  margin-bottom: 26px; max-width: 92%;
}

/* 分类切换（办公 / 开发 / 设计） */
.home-tabs {
  display: inline-flex; align-items: center; gap: 2px;
  background: #f1f2f4; border-radius: 999px; padding: 4px;
  margin-bottom: 22px;
}
.home-tab {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; background: transparent; cursor: pointer;
  padding: 8px 16px; border-radius: 999px;
  font-size: 13.5px; font-family: inherit; color: var(--text-muted);
  transition: background .15s, color .15s, box-shadow .15s;
}
.home-tab:hover { color: var(--text); }
.home-tab.active {
  background: #fff; color: var(--text); font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .10);
}
.ht-icon { font-size: 12px; opacity: .85; }

/* 建议问题胶囊 */
.home-chip-bar { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 680px; }
.home-chip-scroll { flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
.home-chip-scroll::-webkit-scrollbar { display: none; }
.home-chips { display: flex; gap: 8px; width: max-content; margin: 0 auto; padding: 2px; }
.home-chip {
  flex: 0 0 auto; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: #fff;
  font-size: 13px; font-family: inherit; color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.home-chip:hover { background: #fafafa; border-color: #d1d5db; }
.home-chip:active { transform: scale(.97); }

.home-chip-nav { display: flex; gap: 4px; flex-shrink: 0; }
.chip-arrow {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--border); background: #fff;
  color: var(--text-light); cursor: pointer;
  font-size: 15px; line-height: 1; font-family: inherit;
  display: flex; align-items: center; justify-content: center;
}
.chip-arrow:hover { color: var(--text); border-color: #d1d5db; }

/* 首页的大输入卡片 */
.home-mode .chat-input-area { border-top: none; padding: 0 4px 8px; }
.home-mode .chat-input-wrap {
  display: block; background: #fff;
  border: 1px solid var(--border); border-radius: 20px;
  padding: 14px 14px 10px; box-shadow: 0 4px 18px rgba(0, 0, 0, .05);
}
.home-mode .chat-input {
  width: 100%; border: none; background: transparent;
  padding: 0; border-radius: 0;
  font-size: 15px; min-height: 58px; max-height: 160px;
}
.home-mode .chat-input:focus { box-shadow: none; border: none; }
.home-mode .composer-tools { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.home-mode .chat-send { width: 34px; height: 34px; border-radius: 50%; background: #d8dae0; font-size: 14px; }
.home-mode .chat-send span { display: block; transform: rotate(-45deg); }
.home-mode .chat-send.ready { background: var(--primary); }
.home-mode .chat-send.ready:hover { background: var(--primary-hover); }

/* 输入框里的模型选择 */
/* 对话进行中也要能切模型/配自己的 Key，所以不隐藏 */
.composer-model {
  display: inline-flex; align-items: center; gap: 5px;
  border: none; background: transparent; cursor: pointer;
  font-size: 13px; font-family: inherit; color: var(--text-muted);
  padding: 5px 8px; border-radius: 8px; max-width: 220px;
}
.composer-model:hover { background: #f4f5f7; color: var(--text); }
.cm-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-caret { font-size: 12px; opacity: .7; }
.home-mode .composer-model { display: inline-flex; }
.chat-input-wrap .composer-model { flex-shrink: 0; max-width: 170px; font-size: 12px; }
@media (max-width: 640px) { .chat-input-wrap .composer-model { max-width: 110px; } }

/* 模型下拉 */
.model-menu {
  position: fixed; z-index: 1200; min-width: 190px; max-width: 260px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12); padding: 5px;
}
.mm-item {
  width: 100%; display: flex; align-items: center; gap: 6px;
  border: none; background: none; cursor: pointer;
  padding: 8px 10px; border-radius: 7px;
  font-size: 13px; font-family: inherit; color: var(--text); text-align: left;
}
.mm-item:hover { background: #f4f5f7; }
.mm-item.active { color: var(--primary); font-weight: 600; }
.mm-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mm-tag { font-size: 10px; padding: 1px 5px; border-radius: 99px; background: #f1f2f4; color: var(--text-muted); }
.mm-check { color: var(--primary); }
.mm-empty { padding: 8px 10px; font-size: 12px; color: var(--text-light); line-height: 1.6; }

@media (max-width: 640px) {
  .home-title { font-size: 23px; margin-bottom: 20px; }
  /* 窄屏用触摸横滑，箭头占地方且点不准 */
  .home-chip-nav { display: none; }
  .home-tab { padding: 7px 12px; font-size: 13px; }
  .home-chip { padding: 7px 13px; font-size: 12.5px; }
  .home-mode .chat-input-area { padding: 0 0 8px; }
}

/* 侧边栏品牌区：管理员可点击进入站点设置 */
.sidebar-brand.brand-clickable { cursor: pointer; border-radius: 10px; transition: background .15s; }
.sidebar-brand.brand-clickable:hover { background: #f6f7f9; }
.sidebar-brand.brand-clickable:active { background: #eef0f3; }

/* ============================================================
   侧边栏折叠（桌面端）
   ============================================================ */
.collapse-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 7px;
  background: #fff; color: var(--text-muted);
  cursor: pointer; padding: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.collapse-btn:hover { background: #f3f4f6; color: var(--text); border-color: #d1d5db; }
.collapse-btn:active { transform: scale(.94); }
.collapse-btn svg { transition: transform .25s; display: block; }
.app.sidebar-collapsed .collapse-btn svg { transform: rotate(180deg); }

/* 只影响桌面；移动端侧边栏本来就是抽屉式 */
@media (min-width: 769px) {
  .sidebar { overflow: hidden; }
  .app.sidebar-collapsed .sidebar {
    /* flex 子项默认 min-width:auto，会被内容最小宽度顶住，必须显式归零 */
    width: 0; min-width: 0; flex-basis: 0; padding: 0;
    border-right-width: 0;
    opacity: 0; transform: translateX(-10px);
    pointer-events: none;
  }
  .sidebar { transition: width .22s ease, opacity .16s ease, transform .22s ease; }
}

@media (max-width: 768px) {
  .collapse-btn { display: none; }
}

/* 模型下拉里的分隔线与自带 Key 项 */
.mm-sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* 设置页「我的模型」一行 */
.model-now {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #f8f9fb; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px 14px;
}
.mn-name { font-size: 14px; font-weight: 600; }
.mn-hint { font-size: 12px; color: var(--text-muted); }

/* 下拉框里的「默认」标签 */
.mm-tag.mm-def { background: var(--primary-light); color: var(--primary); }

/* 文字按钮（用于「更多设置」这类轻量入口） */
.link-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--primary); font-size: 13px; font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }

/* ---- 视频生成 ---- */
.video-quota { font-size: 13px; color: var(--primary); background: var(--primary-light); padding: 4px 12px; border-radius: 999px; }
.video-form { margin-bottom: 22px; }
.video-opt { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.video-opt .vo-label { font-size: 13px; color: var(--text-muted); min-width: 60px; }
.video-opt .preset-row { margin-bottom: 0; flex-wrap: wrap; }
.video-submit { display: flex; align-items: center; gap: 16px; margin-top: 18px; flex-wrap: wrap; }
.video-submit .hint { flex: 1; min-width: 220px; margin: 0; }

.video-list-head { font-size: 13px; color: var(--text-muted); margin: 4px 0 10px; }
.video-item { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.vi-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.vi-badge { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: #f1f5f9; color: var(--text-muted); white-space: nowrap; }
.video-item.st-queued .vi-badge, .video-item.st-processing .vi-badge, .video-item.st-running .vi-badge { background: #fef3c7; color: #92400e; }
.video-item.st-succeeded .vi-badge { background: #d1fae5; color: #065f46; }
.video-item.st-failed .vi-badge, .video-item.st-cancelled .vi-badge { background: var(--danger-light); color: var(--danger); }
.vi-meta { font-size: 12px; color: var(--text-light); margin-left: auto; }
.vi-prompt { font-size: 14px; line-height: 1.6; margin-bottom: 10px; word-break: break-word; }
.vi-video { width: 100%; max-width: 640px; border-radius: var(--radius-sm); background: #000; display: block; }
.vi-error { font-size: 12.5px; color: var(--danger); background: var(--danger-light); padding: 9px 12px; border-radius: var(--radius-sm); word-break: break-word; }
.vi-progress { font-size: 12.5px; color: var(--text-muted); display: flex; align-items: center; gap: 9px; }
.vi-dot { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; flex: none; animation: vi-pulse 1.2s ease-in-out infinite; }
@keyframes vi-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }
.vi-actions { display: flex; gap: 8px; margin-top: 12px; }
.vi-actions a.btn { text-decoration: none; }

/* ---- 桌面助手 ---- */
.agent-badge { font-size: 12.5px; padding: 4px 11px; border-radius: 999px; background: #f1f5f9; color: var(--text-muted); }
.agent-badge.on { background: #d1fae5; color: #065f46; }
.agent-connect { padding: 22px 24px; }
.agent-steps { display: flex; flex-direction: column; gap: 16px; }
.as-item { display: flex; gap: 12px; align-items: flex-start; }
.as-num { width: 22px; height: 22px; flex: none; border-radius: 50%; background: var(--primary-light); color: var(--primary); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.as-item b { font-size: 14px; font-weight: 600; }
.agent-code { font-family: var(--mono); font-size: 34px; letter-spacing: 8px; color: var(--primary); background: var(--primary-light); border-radius: var(--radius-sm); padding: 10px 16px; text-align: center; margin-top: 6px; }
.agent-host { font-family: var(--mono); font-size: 14px; background: #f1f5f9; border-radius: var(--radius-sm); padding: 9px 12px; margin-top: 6px; word-break: break-all; }

.agent-stage { position: relative; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #0f172a; cursor: crosshair; line-height: 0; }
.agent-shot { width: 100%; display: block; }
/* 还没截图时的占位：给个明确的引导，避免看起来像坏了 */
.agent-stage.empty { min-height: 240px; display: flex; align-items: center; justify-content: center; cursor: default; background: #f8fafc; }
.agent-empty { text-align: center; padding: 24px 20px; line-height: 1.6; }
.agent-empty .ae-icon { font-size: 30px; opacity: .55; margin-bottom: 10px; }
.agent-empty .ae-t { font-size: 14.5px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.agent-empty .ae-h { font-size: 12.5px; color: var(--text-muted); }
.agent-mark { display: none; position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; border: 2px solid #ef4444; background: rgba(239,68,68,.35); pointer-events: none; }
.agent-tools { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.agent-result { margin-top: 14px; font-size: 12.5px; color: var(--text-muted); padding: 9px 12px; background: #f8fafc; border-radius: var(--radius-sm); }
.agent-result.ok { background: #ecfdf5; color: #065f46; }
.agent-result.fail { background: var(--danger-light); color: var(--danger); }

/* ---- AI 自主执行 ---- */
.agent-auto { padding: 16px 18px; margin-bottom: 18px; }
.aa-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.aa-title { font-size: 15px; font-weight: 600; }
.auto-log { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.aa-status { font-size: 13px; padding: 8px 12px; border-radius: var(--radius-sm); background: #f1f5f9; color: var(--text-muted); }
.aa-status.ok { background: #ecfdf5; color: #065f46; }
.aa-status.fail { background: var(--danger-light); color: var(--danger); }
.aa-step { display: grid; grid-template-columns: 22px 190px 1fr; grid-template-rows: auto auto; gap: 2px 10px; font-size: 12.5px; padding: 7px 10px; border-radius: var(--radius-sm); background: #f8fafc; }
.aa-step.bad { background: #fef2f2; }
.aa-n { grid-row: 1 / span 2; width: 20px; height: 20px; border-radius: 50%; background: var(--primary-light); color: var(--primary); font-size: 11.5px; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.aa-step.bad .aa-n { background: var(--danger-light); color: var(--danger); }
.aa-act { font-family: var(--mono); font-size: 12px; color: var(--text); }
.aa-msg { color: var(--danger); font-size: 12px; }
.aa-msg.ok { color: var(--text-muted); }
.aa-thought { grid-column: 2 / span 2; color: var(--text-light); font-size: 11.5px; }

/* ---- 高危确认与配额 ---- */
.aa-confirm { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding: 11px 13px; border-radius: var(--radius-sm); background: #fffbeb; border: 1px solid #fcd34d; }
.aa-confirm .ac-text { flex: 1; min-width: 220px; font-size: 12.5px; color: #92400e; line-height: 1.6; }
.aa-confirm .ac-text b { font-weight: 600; }
.aa-chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); cursor: pointer; }

/* ---- 使用须知（免责声明） ---- */
.notice-modal { max-width: 620px; }
.notice-lead { font-size: 14px; color: var(--text); line-height: 1.7; margin: 0 0 16px; }
.notice-sec { margin-bottom: 15px; }
.notice-h { font-size: 13.5px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.notice-p { font-size: 13px; line-height: 1.75; color: var(--text-muted); }
.notice-foot { font-size: 12.5px; line-height: 1.7; color: var(--text-light); margin: 18px 0 0; padding-top: 14px; border-top: 1px dashed var(--border); }
.notice-agree { flex-shrink: 0; padding: 12px 20px; background: #fffbeb; border-top: 1px solid var(--border); }
.notice-chk { display: flex; align-items: center; gap: 9px; font-size: 13px; color: #92400e; cursor: pointer; line-height: 1.5; }
.notice-chk input { width: 16px; height: 16px; flex: none; cursor: pointer; accent-color: var(--primary); }
.notice-lock { z-index: 300; background: rgba(15,23,42,.55); }

/* ---- 桌面助手：常驻风险提示 ---- */
.agent-notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; margin-bottom: 16px; border-radius: var(--radius-sm); background: #fffbeb; border: 1px solid #fcd34d; flex-wrap: wrap; }
.agent-notice .an-icon { color: #d97706; font-size: 14px; line-height: 1.5; flex: none; }
.agent-notice .an-text { flex: 1; min-width: 240px; font-size: 12.5px; line-height: 1.7; color: #92400e; }

/* ---- 后台：注册开关卡片 ---- */
.signup-card { margin-bottom: 16px; padding: 16px 18px; }
.sc-row { display: flex; align-items: flex-start; gap: 18px; }
.sc-main { flex: 1; min-width: 0; }
.sc-title { font-size: 14.5px; font-weight: 600; margin-bottom: 5px; }
.sc-desc { font-size: 12.5px; line-height: 1.7; color: var(--text-muted); }
.sc-row .switch { flex: none; margin-top: 2px; }
.sc-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 11px; border-top: 1px dashed var(--border); flex-wrap: wrap; }
.sc-state { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.sc-state.on { color: #b45309; }
.sc-src { font-size: 12px; color: var(--text-light); }

/* ---- 安装到桌面的提示条（登录页） ---- */
#install-slot { width: 100%; max-width: 392px; display: flex; flex-direction: column; }
.pwa-bar { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,.06); box-sizing: border-box; }
.pwa-bar .pb-icon { width: 30px; height: 30px; flex: none; border-radius: 8px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 15px; }
.pwa-bar .pb-text { flex: 1; min-width: 0; }
.pwa-bar .pb-t { font-size: 13.5px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.pwa-bar .pb-h { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.pwa-bar .pb-close { flex: none; width: 24px; height: 24px; border: none; background: none; color: var(--text-light); font-size: 18px; line-height: 1; cursor: pointer; border-radius: 6px; }
.pwa-bar .pb-close:hover { background: #f1f5f9; color: var(--text); }
