/* ==========================================================================
   hub v2 · 全站统一样式（里程碑 6 UI 重设计）
   视觉语言：白底 + 靛蓝 #4F46E5 / 青 #06B6D4 双色 + 浅灰分隔
   约定：本文件保持旧 class 兼容（面板/卡片/表单/表格/AI 抽屉等），
         新增部分集中在「设计系统 / 首页 / 认证 / 仪表盘」区块。
   ========================================================================== */

/* ---------- 设计变量 ---------- */
:root {
  --brand: #4f46e5;
  --brand-2: #06b6d4;
  --brand-weak: #eef2ff;
  --brand-ink: #ffffff;
  --bg: #f5f6fa;
  --card: #ffffff;
  --line: #e6e8f0;
  --text: #1f2433;
  --muted: #6b7280;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #b45309;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(31, 36, 51, .06);
  --shadow-sm: 0 2px 8px rgba(31, 36, 51, .05);
  --shadow-lg: 0 18px 48px rgba(31, 36, 51, .14);
  /* 旧变量别名（兼容旧页面内联样式/脚本） */
  --ink: var(--text);
  --panel: var(--card);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { color: var(--text); line-height: 1.25; }
h1 { font-size: 28px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
:focus-visible { outline: 2px solid rgba(79, 70, 229, .45); outline-offset: 2px; }

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding: 10px 22px;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(160%) blur(8px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: .2px;
}
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 9px; }
.brand .brand-name {
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  color: #4b5563;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.nav a:hover { background: #f1f2f8; color: var(--text); text-decoration: none; }
.nav a.active,
.nav a.is-active { background: var(--brand-weak); color: var(--brand); }
.nav-icon { width: 18px; height: 18px; border-radius: 5px; object-fit: cover; flex: 0 0 auto; }
.nav .linklike { color: #4b5563; padding: 7px 12px; border-radius: 999px; font-size: 14px; font-weight: 500; }
.nav .linklike:hover { background: #f1f2f8; color: var(--text); }

/* 移动端折叠（纯 CSS，无 JS 依赖） */
.nav-toggle { display: none; }
.nav-toggle-label {
  display: none;
  margin-left: auto;
  width: 42px;
  height: 38px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
}
.nav-toggle-label span { display: block; width: 18px; height: 2px; border-radius: 2px; background: #4b5563; }
.nav-toggle-label:hover { border-color: #c7d2fe; }

/* ---------- 布局 ---------- */
.container { width: 100%; max-width: 1160px; margin: 26px auto 56px; padding: 0 22px; }
.inline { display: inline; margin: 0; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); }
.banner {
  background: linear-gradient(90deg, var(--warn), #d97706);
  color: #fff;
  padding: 9px 22px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.banner .linklike { color: #fff; text-decoration: underline; }
.linklike {
  background: none;
  border: 0;
  color: var(--brand);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

/* ---------- 通用卡片 / 面板 ---------- */
.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.card:hover {
  border-color: #c7d2fe;
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  text-decoration: none;
}
.card h2 { margin: 0 0 8px; font-size: 18px; }
.card p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin: 18px 0;
  box-shadow: var(--shadow-sm);
}
.panel h2 { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 16px; margin: 22px 0; }
.hero { padding: 10px 0 2px; }
.hero h1 { margin: 6px 0 6px; font-size: 30px; letter-spacing: -.3px; }
.hero p { margin: 0; }

/* ---------- 首页 ---------- */
.home-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 26px 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(680px 200px at 100% 0%, rgba(6, 182, 212, .10), transparent 60%),
    radial-gradient(520px 220px at 0% 0%, rgba(79, 70, 229, .12), transparent 58%),
    var(--card);
  box-shadow: var(--shadow-sm);
}
.home-hero h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: -.4px; }
.home-hero p { margin: 0; color: var(--muted); }
.home-hero .hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.home-hero .hero-icon { width: 64px; height: 64px; border-radius: 18px; box-shadow: var(--shadow-sm); }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 20px 0; }
.home-card { position: relative; padding-top: 18px; }
.home-card .card-icon { width: 46px; height: 46px; border-radius: 13px; display: block; margin-bottom: 10px; }
.home-card .stat { display: inline-block; font-size: 12.5px; color: var(--brand); background: var(--brand-weak); border-radius: 999px; padding: 3px 10px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 18px 0; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-num { display: block; font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-card .stat-label { display: block; font-size: 12.5px; color: var(--muted); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--brand);
  color: var(--brand-ink);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 2px 6px rgba(79, 70, 229, .22);
  transition: background .15s ease, box-shadow .15s ease, transform .15s ease;
}
.btn:hover { background: #4338ca; text-decoration: none; box-shadow: 0 6px 16px rgba(79, 70, 229, .28); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #eef0f6; color: var(--text); box-shadow: none; }
.btn.secondary:hover { background: #e3e6ef; }
.btn.danger { background: var(--danger); color: #fff; box-shadow: 0 2px 6px rgba(220, 38, 38, .22); }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

/* ---------- 徽章 / 提示 / 进度 ---------- */
.badge {
  display: inline-block;
  background: var(--brand-weak);
  color: var(--brand);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 6px;
}
.badge.ok { background: #ecfdf5; color: var(--ok); }
.badge.warn { background: #fffbeb; color: var(--warn); }
.badge.danger { background: #fef2f2; color: var(--danger); }
.stat { font-size: 12.5px; color: var(--ok); }
.notice {
  border-radius: 12px;
  padding: 10px 14px;
  margin: 12px 0;
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
  font-size: 14px;
}
.toast {
  border-radius: 12px;
  padding: 10px 14px;
  margin: 12px 0;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #065f46;
  font-size: 14px;
}
.progress { height: 8px; background: #e8eaf6; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progress span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li { padding: 11px 0; border-bottom: 1px dashed var(--line); }
.task-list li:last-child { border-bottom: 0; }
.entry-list { margin: 0; padding-left: 18px; line-height: 2; }

/* ---------- 空状态 ---------- */
.empty-state {
  border: 1px dashed #d3d7e3;
  border-radius: var(--radius);
  background: #fbfbfe;
  color: var(--muted);
  padding: 28px 20px;
  text-align: center;
}
.empty-state strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ---------- 认证页 / 表单 ---------- */
.auth-page { max-width: 440px; margin: 42px auto 30px; }
.auth-box {
  max-width: 440px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px 28px;
  box-shadow: var(--shadow);
}
.auth-box .auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.auth-box .auth-brand img { width: 40px; height: 40px; border-radius: 12px; }
.auth-box .auth-brand strong { font-size: 16px; }
.auth-box h1 { margin: 0 0 6px; font-size: 24px; }
.auth-box .auth-sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 500; }
.form input,
.form textarea,
.form select {
  width: 100%;
  padding: 11px 13px;
  font-size: 15px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form input:focus,
.form textarea:focus,
.form select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}
.form .checkbox { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.form .checkbox input { width: auto; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { width: 160px; color: var(--muted); font-weight: 500; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); }
table.data th { color: var(--muted); font-weight: 500; background: #fafafe; }
table.data tbody tr:hover { background: #fbfbff; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); }
.table-wrap table { margin: 0; }

/* ---------- 富文本 ---------- */
.prose { line-height: 1.78; }
.prose img { max-width: 100%; border-radius: 10px; }
.prose pre { background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 10px; overflow-x: auto; }
.prose code { background: #f1f3f9; padding: 1px 5px; border-radius: 4px; font-size: 90%; }
.prose pre code { background: transparent; padding: 0; }
.prose table { border-collapse: collapse; }
.prose table th, .prose table td { border: 1px solid var(--line); padding: 6px 10px; }

/* ---------- 页脚 ---------- */
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 22px 0 40px; }

/* ==========================================================================
   AI 助手（悬浮球 + 抽屉；抽屉样式主要在 ai-panel.css，这里保留兼容类）
   ========================================================================== */
.ai-float { position: fixed; right: 20px; bottom: 20px; z-index: 900; font-family: inherit; }
.ai-float-btn {
  width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  font-weight: 700; font-size: 16px; letter-spacing: .5px;
  box-shadow: 0 8px 24px rgba(79, 70, 229, .35);
  transition: transform .15s ease, box-shadow .15s ease;
}
.ai-float-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(79, 70, 229, .45); }
.ai-float.open .ai-float-btn { transform: scale(.96); }
.ai-float-panel {
  position: absolute; right: 0; bottom: 68px; width: 320px;
  max-height: min(62vh, 520px); display: flex; flex-direction: column;
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.ai-float-panel[hidden] { display: none; }
.ai-float-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: #111827; color: #f9fafb; }
.ai-float-head .badge { background: rgba(255, 255, 255, .16); color: #e5e7eb; margin: 0; }
.ai-float-x { margin-left: auto; background: none; border: 0; color: #d1d5db; font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px; }
.ai-float-x:hover { color: #fff; }
.ai-float-log { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.ai-msg { max-width: 86%; padding: 8px 11px; border-radius: 10px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.ai-msg-bot { align-self: flex-start; background: #f3f4f6; color: var(--text); }
.ai-msg-user { align-self: flex-end; background: var(--brand); color: #fff; }
.ai-msg-error { align-self: flex-start; background: #fef2f2; color: #991b1b; }
.ai-float-form { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.ai-float-form input {
  flex: 1; min-width: 0; padding: 9px 11px; font-size: 14px; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; background: #fff; font-family: inherit;
}
.ai-float-form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.ai-float-form .btn.small { padding: 9px 12px; }
.ai-float-form .btn:disabled { opacity: .55; cursor: not-allowed; }
.ai-float-tip { margin: 0; padding: 0 14px 12px; font-size: 11px; }

/* ==========================================================================
   /ai 管理页四页签（对话记录 / 记忆 / 图片 / 设置）
   ========================================================================== */
.page-head { margin: 10px 0 4px; }
.page-head h1 { margin: 6px 0 4px; font-size: 28px; }
.page-head p { margin: 0 0 6px; color: var(--muted); }
.ai-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 6px; }
.ai-tab-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.ai-tab-btn:hover { border-color: #c7d2fe; }
.ai-tab-btn:focus-visible { outline: 2px solid rgba(79, 70, 229, .45); outline-offset: 2px; }
.ai-tab-btn.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.ai-tab-btn .badge { margin: 0; background: var(--brand-weak); color: var(--brand); }
.ai-tab-btn.is-active .badge { background: rgba(255, 255, 255, .22); color: #fff; }
.ai-tab-panel { margin: 14px 0 28px; }
.ai-tab-panel[hidden] { display: none; }
.ai-admin-status {
  margin: 8px 0; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); font-size: 13px;
}
.ai-admin-status.is-ok { border-color: #bbf7d0; background: #f0fdf4; color: #065f46; }
.ai-admin-status.is-err { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.stat-row { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 10px; }
@media (max-width: 720px) { .stat-row { gap: 16px; } }
.ai-layout { display: grid; grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); gap: 16px; align-items: start; margin-top: 16px; }
.ai-conv-list, .ai-conv-view { margin: 0; }
.ai-conv-list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ai-conv-list-head h2 { margin: 0 0 4px; }
.ai-date-group { margin-top: 12px; }
.ai-date-head { margin: 0 0 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.ai-conv-items { list-style: none; margin: 0; padding: 0; }
.ai-conv-item { display: flex; align-items: flex-start; gap: 6px; border-bottom: 1px dashed var(--line); }
.ai-conv-item:last-child { border-bottom: 0; }
.ai-conv-link {
  flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px;
  padding: 8px 6px; border-radius: 10px; color: var(--text);
}
.ai-conv-link:hover { background: #f5f6ff; text-decoration: none; }
.ai-conv-link.active { background: var(--brand-weak); }
.ai-conv-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-conv-del {
  flex: 0 0 auto; margin-top: 7px; padding: 3px 6px; border: 0; border-radius: 6px;
  background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer;
}
.ai-conv-del:hover { color: var(--danger); }
.ai-conv-del[data-confirm="1"] { color: var(--danger); font-weight: 600; }
.ai-conv-del:disabled { opacity: .55; cursor: not-allowed; }
.ai-conv-view-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ai-conv-view-head h2 { margin: 0 0 8px; }
.ai-conv-view-head .ai-conv-del { margin-top: 0; }
.ai-thread { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 14px; max-height: 60vh; overflow-y: auto; }
.ai-thread .ai-msg { max-width: 92%; }
.ai-thread .ai-role { display: block; font-size: 11px; opacity: .7; margin-bottom: 2px; }
.ai-thread .ai-content { white-space: pre-wrap; word-break: break-word; }
.ai-placeholder h2 { margin-top: 0; }
.ai-placeholder p { margin: 8px 0; line-height: 1.7; }
.ai-placeholder .btn { margin-top: 4px; }
@media (max-width: 720px) {
  .ai-layout { grid-template-columns: 1fr; }
  .ai-thread { max-height: none; }
}

/* ==========================================================================
   可视仪表盘（/admin）
   ========================================================================== */
.dash-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 8px 0 14px;
}
.dash-top h1 { margin: 0 0 4px; font-size: 28px; }
.dash-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dash-meta .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 5px; }
.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin: 14px 0; }
.dash-metric {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  min-height: 74px;
}
.dash-metric .dv { display: block; font-size: 23px; font-weight: 700; line-height: 1.25; letter-spacing: -.3px; }
.dash-metric .dl { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.dash-metric .dsub { display: block; font-size: 11.5px; color: var(--muted); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin: 16px 0; }
.dash-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  margin: 0;
}
.dash-card h2 { margin: 0 0 4px; font-size: 16px; }
.dash-card .dash-sub { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }
.dash-canvas-wrap { position: relative; width: 100%; height: 220px; }
.dash-canvas-wrap canvas { display: block; width: 100% !important; height: 100% !important; }
.dash-ring-wrap { position: relative; height: 200px; display: flex; align-items: center; justify-content: center; }
.dash-ring-wrap canvas { position: absolute; inset: 0; margin: auto; }
.dash-ring-center {
  position: relative;
  z-index: 2;
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.4px;
}
.dash-ring-center small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.dash-services { display: flex; flex-direction: column; gap: 8px; }
.service-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfbfe;
}
.service-chip .svc-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.dot.up { background: var(--ok); box-shadow: 0 0 0 3px rgba(5, 150, 105, .16); }
.dot.down { background: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, .14); }
.dot.unknown { background: #9ca3af; }
.dash-system { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 0; }
.dash-system dt { color: var(--muted); font-size: 12.5px; }
.dash-system dd { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.dash-placeholder {
  border: 1px dashed #d3d7e3;
  border-radius: var(--radius);
  background: #fbfbfe;
  color: var(--muted);
  padding: 22px 20px;
  text-align: center;
  margin: 14px 0;
}
.dash-placeholder strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 3px; }
.dash-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.dash-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }
.dash-error { border: 1px solid #fecaca; background: #fef2f2; color: #991b1b; border-radius: var(--radius-sm); padding: 10px 14px; margin: 10px 0; font-size: 14px; }
.dash-foot { font-size: 12px; color: var(--muted); margin: 8px 0 10px; }

/* ==========================================================================
   响应式（手机 375px 起）
   ========================================================================== */
@media (max-width: 820px) {
  .nav-toggle-label { display: inline-flex; }
  .nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 2px; margin-left: 0; padding: 4px 0 10px; order: 5; }
  .nav-toggle:checked ~ .nav { display: flex; }
  .nav a, .nav .linklike { padding: 10px 12px; border-radius: 10px; font-size: 15px; }
  .nav form.inline { display: block; }
  .topbar { padding: 10px 14px; }
  .brand { order: 1; }
  .nav-toggle-label { order: 2; }
  .brand img { width: 28px; height: 28px; }
  .container { padding: 0 14px; margin-top: 18px; }
  .home-hero { padding: 20px 18px; }
  .home-hero h1 { font-size: 24px; }
  .hero h1, .page-head h1, .dash-top h1 { font-size: 24px; }
  .grid, .home-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-canvas-wrap { height: 190px; }
  .prose pre { font-size: 13px; }
  .auth-box { padding: 22px 18px; }
  .panel { padding: 18px 16px; }
  .form input, .form textarea, .form select { font-size: 16px; } /* 避免 iOS 自动放大 */
}
@media (max-width: 400px) {
  .stat-grid, .dash-stats { grid-template-columns: 1fr; }
  .dash-system { grid-template-columns: 1fr; }
  .container { padding: 0 12px; }
}

/* ==========================================================================
   T39 知识库「任务窗口」独立入口（图标按钮 + 侧栏入口 + 任务页头图）
   ========================================================================== */
.nav-ico {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  object-fit: contain;
  vertical-align: -3px;
  flex: 0 0 auto;
}
.kb-task-btn .nav-ico,
.kb-links .nav-ico { margin-right: 6px; vertical-align: -3px; }
.kb-links a {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  line-height: 1.5;
}
.kb-task-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-sm, 12px);
  background: linear-gradient(120deg, #eef2ff, #ecfeff);
  color: var(--text);
  text-decoration: none;
}
.kb-task-banner:hover {
  border-color: #818cf8;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(79, 70, 229, .10);
}
.kb-task-banner img { width: 36px; height: 36px; object-fit: contain; flex: 0 0 auto; }
.kb-task-banner strong { display: block; font-size: 14.5px; line-height: 1.3; }
.kb-task-banner small { display: block; font-size: 12px; color: var(--muted); }
.kb-head {
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
}
.kb-head .kb-head-icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex: 0 0 auto;
  border-radius: 14px;
}
.kb-head h1 { margin: 0; }
@media (max-width: 820px) {
  .kb-head .kb-head-icon { width: 46px; height: 46px; }
}

/* ==== T47：搜索放大镜 / 导航内联 SVG / 已删除收口提示 ==== */
.nav-icon-svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--brand);
}
.nav-ico-svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--muted);
}
.kb-links a .nav-ico,
.kb-links a .nav-ico-svg {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex: 0 0 auto;
}
.search-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-field .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.search-field input {
  padding-left: 36px;
}
.kb-search.search-field input {
  flex: 1 1 auto;
  min-width: 0;
}
.kb-empty .muted,
.kb-recycle-hint {
  font-size: 12.5px;
  color: var(--muted);
}

/* 统一回收站（/recycle-bin）：彻底删除二次确认态。
   仅补样式，不改模板结构；.rc-* 其余规则在 recycle/index.html 内联样式中。 */
.rc-btn.confirming,
.rc-btn[data-confirm-step="1"] {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
}
.rc-btn.confirming:hover,
.rc-btn[data-confirm-step="1"]:hover {
  filter: brightness(0.95);
}
.rc-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ==========================================================================
   v0.7.3 移动端加固（≤860px / ≤420px）
   说明：模块侧栏折叠样式见 templates/kb/_style.html 与 templates/corpus/_style.html；
   本块只补全站公共控件（表格横向滚动、AI 布局、图片/代码块、表单宽度、点击区）。
   ========================================================================== */
@media (max-width: 860px) {
  body { overflow-x: hidden; }
  .container { max-width: 100%; }
  .page-head { flex-wrap: wrap; }
  .page-head .btn, .hero .btn { max-width: 100%; }
  .panel, .card { padding: 14px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table.data, .table-wrap table:not(.rc-table) { min-width: 520px; }
  .prose pre, pre {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .prose img, .home-card img, img { max-width: 100%; height: auto; }
  .ai-layout { grid-template-columns: 1fr; }
  .ai-drawer { width: 100%; max-width: 100vw; }
  .dash-canvas-wrap { height: 200px; }
  .form input, .form textarea, .form select,
  .corpus-panel input, .corpus-panel textarea, .corpus-panel select {
    max-width: 100%;
    box-sizing: border-box;
  }
  .btn { max-width: 100%; }
  .rc-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .rc-table { min-width: 520px; }
  .rc-table th:nth-child(4), .rc-table td:nth-child(4) { display: none; }
}
@media (max-width: 420px) {
  .container { padding: 0 12px; }
  .home-hero { padding: 16px 14px; }
  .home-hero h1, .hero h1, .page-head h1, .dash-top h1 { font-size: 22px; }
  .panel, .card { padding: 12px; }
  .btn.small { padding: 8px 10px; }
  .dash-canvas-wrap { height: 180px; }
}

/* ================= v0.7.5：移动端聚焦回弹与长行换行 ================= */
@media (max-width: 860px) {
  /* 锚点/聚焦元素预留顶部导航高度，避免键盘弹出后被遮挡；移动端输入字号 ≥16px 防止 iOS 聚焦自动放大 */
  html { scroll-padding-top: 76px; }
  :where(input:not([type="checkbox"]):not([type="radio"]), textarea, select) {
    font-size: 16px;
    scroll-margin-top: 84px;
  }
  textarea,
  .msg-content,
  .prose pre,
  .code-output-body pre,
  .ai-drawer-bubble {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
}

/* details 抽屉打开时兜底显示内容（桌面默认 open；与 kb/corpus 内联样式互补） */
details.kb-cat-drawer[open] > .kb-cat-drawer-body { display: block; }
details.corpus-cat-drawer[open] > .corpus-cat-drawer-body { display: block; }

/* ================= v0.7.5：任务/子任务图片、截屏、首页任务卡片 ================= */
.hidden { display: none !important; }

/* 新建任务表单：初始子任务行 */
.task-subtasks-box { display: flex; flex-direction: column; gap: 8px; }
.task-subtasks-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.task-subtask-rows { display: flex; flex-direction: column; gap: 6px; }
.task-subtask-row { display: flex; gap: 8px; align-items: center; }
.task-subtask-row .subtask-input {
  flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink);
}

/* 新建任务表单：截屏/图片附件 */
.task-create-image { display: flex; flex-direction: column; gap: 8px; }
.task-img-preview {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border: 1px dashed var(--line); border-radius: 10px; background: #f8f9ff;
}
.task-img-preview img { max-width: 180px; max-height: 120px; border-radius: 6px; display: block; }
#task-create-image { display: none; }

/* 任务 / 子任务图片区 */
.task-img-zone {
  display: grid; grid-template-columns: 132px 1fr; grid-template-areas:
    "head head"
    "drop drop"
    "actions actions"
    "status status";
  gap: 8px; margin: 10px 0 4px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fbfcff;
}
.task-img-head { grid-area: head; display: flex; align-items: baseline; gap: 8px; }
.task-img-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.task-img-size { font-size: 12px; }
.task-img-drop {
  grid-area: drop; display: flex; align-items: center; justify-content: center;
  min-height: 96px; padding: 10px; border: 1.5px dashed #c7cdf1; border-radius: 10px;
  background: #fff; cursor: pointer; text-align: center; outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.task-img-drop:hover, .task-img-drop:focus-visible { border-color: var(--brand); background: #f6f7ff; }
.task-img-drop.dragover { border-color: var(--brand); background: #eef0ff; }
.task-img-placeholder { font-size: 13px; color: var(--muted); line-height: 1.6; }
.task-img-thumb {
  max-width: 100%; max-height: 220px; border-radius: 8px; object-fit: contain;
  display: block; cursor: zoom-in; background: #fff; box-shadow: 0 1px 6px rgba(31, 41, 90, 0.12);
}
.task-img-thumb.small { max-height: 56px; max-width: 84px; }
.task-img-actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.task-img-status { grid-area: status; font-size: 12.5px; min-height: 16px; }
.task-img-status.error { color: var(--danger, #c0392b); }

/* 子任务内图片区缩窄 */
.subtask-item .task-img-zone { grid-template-columns: 1fr; grid-template-areas: "head" "drop" "actions" "status"; }
.subtask-item .task-img-drop { min-height: 72px; }

/* 看原图对话框 */
.task-img-dialog {
  border: none; border-radius: 14px; padding: 0; max-width: min(92vw, 1120px);
  max-height: 92vh; box-shadow: 0 24px 60px rgba(15, 23, 60, 0.35); background: #fff;
}
.task-img-dialog::backdrop { background: rgba(12, 18, 40, 0.62); }
.task-img-dialog-body { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.task-img-dialog-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink); }
.task-img-dialog-body img { max-width: 100%; max-height: 74vh; object-fit: contain; border-radius: 8px; display: block; }
.task-img-dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* 截屏遮罩层（screenshot.js 动态创建） */
.shot-overlay {
  position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center;
  justify-content: center; padding: 18px; background: rgba(10, 14, 32, 0.72);
}
.shot-panel {
  width: min(94vw, 1280px); max-height: 94vh; overflow: auto; padding: 14px;
  border-radius: 14px; background: #fff; box-shadow: 0 24px 70px rgba(10, 14, 32, 0.45);
}
.shot-tip { margin: 0 0 8px; font-size: 13.5px; color: var(--ink); }
.shot-stage { position: relative; display: flex; justify-content: center; background: #0f1424; border-radius: 10px; overflow: hidden; }
.shot-canvas { display: block; max-width: 100%; cursor: crosshair; user-select: none; }
.shot-select {
  position: absolute; border: 2px solid #4f46e5; background: rgba(79, 70, 229, 0.18);
  pointer-events: none; box-shadow: 0 0 0 9999px rgba(10, 14, 32, 0.35);
}
.shot-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.shot-status { margin: 8px 0 0; font-size: 12.5px; }

/* 首页任务卡片 */
.home-task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.home-task-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  background: #fbfcff; display: flex; flex-direction: column; gap: 8px;
}
.home-task-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.home-task-head strong { font-size: 15px; }
.status-pill.done { background: #e7f7ee; color: #177245; }
.home-task-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.home-task-thumb { max-height: 96px; max-width: 160px; }
.home-subtasks { margin-top: 2px; }
.home-subtasks summary { font-size: 13px; color: var(--muted); cursor: pointer; }
.home-subtask-thumb { max-height: 48px; max-width: 72px; margin-left: 6px; vertical-align: middle; }

/* 首页最近图片 */
.recent-img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
.recent-img {
  border: 1px solid var(--line); border-radius: 10px; padding: 0; overflow: hidden;
  background: #fff; cursor: zoom-in; text-align: left; display: flex; flex-direction: column;
}
.recent-img img { width: 100%; height: 96px; object-fit: cover; display: block; }
.recent-img-title {
  display: block; padding: 6px 8px; font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recent-img:hover, .recent-img:focus-visible { border-color: var(--brand); }

@media (max-width: 720px) {
  .task-img-zone { grid-template-columns: 1fr; }
  .task-img-thumb { max-height: 160px; }
  .home-task-thumb { max-height: 72px; max-width: 120px; }
  .recent-img-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
}

/* ================= v0.7.6 T89：无图紧凑态 + 手机端任务行内布局 ================= */
/* 有图：保持大图/拖入区；无图：不渲染占位块，只保留小号「选择图片 / 截屏」按钮行。 */
.task-img-zone.is-empty {
  padding: 6px 10px;
  margin: 6px 0 2px;
  border-style: dashed;
  background: transparent;
  gap: 4px;
}
.task-img-zone.is-empty .task-img-head,
.task-img-zone.is-empty .task-img-drop { display: none; }
.task-img-zone.is-empty .task-img-actions { grid-area: auto; }
.task-img-zone.is-empty .task-img-status { min-height: 0; }
.task-img-zone.is-empty .task-img-actions .btn { padding: 4px 10px; font-size: 12.5px; }

@media (max-width: 720px) {
  .subtask-list { margin-top: 8px; }
  .subtask-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    padding: 7px 0;
  }
  .subtask-item > input[type="checkbox"] { flex: 0 0 auto; margin: 0; }
  .subtask-item .subtask-title {
    flex: 1 1 96px; min-width: 0; font-size: 14px; line-height: 1.35;
    overflow-wrap: anywhere;
  }
  .subtask-item .subtask-form { flex: 0 0 auto; margin: 0; }
  .subtask-item .subtask-form .btn { padding: 5px 9px; font-size: 12.5px; }
  /* 子任务图片：有图时缩略展示；无图时只占一行小按钮，不再撑出大占位块 */
  .subtask-item .task-img-zone { flex: 1 1 100%; order: 6; margin: 2px 0 0; }
  .subtask-item .task-img-zone.is-empty {
    flex: 1 1 100%; padding: 2px 0; border: 0; background: transparent;
  }
  .subtask-item .task-img-zone.is-empty .task-img-actions { gap: 4px; }
  .subtask-item .task-img-zone:not(.is-empty) .task-img-drop { min-height: 56px; }
  .subtask-item .task-img-zone:not(.is-empty) .task-img-thumb { max-height: 120px; }
  .task-head { row-gap: 4px; }
  .kb-actions { flex-wrap: wrap; gap: 6px; }
}




/* ===== v0.7.6 T98：用户自定义背景 + 全站毛玻璃 ===== */
:root {
  --glass-bg: rgba(255, 255, 255, 0.66);
  --glass-border: rgba(255, 255, 255, 0.58);
  --user-bg: none;
  --user-bg-opacity: 0.55;
  --user-bg-fit: cover;
}
/* 用户背景：固定层铺在内容之后，透明度由 --user-bg-opacity 控制（base.html 注入） */
body[data-bg="1"]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: var(--user-bg);
  background-size: var(--user-bg-fit, cover);
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--user-bg-opacity, 0.55);
  transition: opacity 0.2s ease;
}
/* v0.7.7 T102：修复自定义背景无效——body 自身不透明背景会盖住 z-index:-1 的 ::before；
   让 body 在有背景时透明，html 保留兜底底色，背景层即可透出。 */
html { background-color: var(--bg); }
body[data-bg="1"] { background-color: transparent; }
/* 主要显示框：半透明白 + 磨砂 + 半透明细边框（inset 不改变布局） */
.card, .panel, .topbar, .ai-drawer, .kb-card, .kb-side, .corpus-side,
.home-card, .home-hero, .hero, .auth-box, .stat-card,
.dash-card, .dash-metric, .table-wrap, .admin-danger {
  background-color: var(--glass-bg);
  box-shadow: inset 0 0 0 1px var(--glass-border);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  backdrop-filter: blur(14px) saturate(1.1);
}
.table-wrap table,
.table-wrap table.data { background-color: transparent; }
/* 不支持 backdrop-filter 时降级为高不透明度纯色，保证可读性 */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card, .panel, .topbar, .ai-drawer, .kb-card, .kb-side, .corpus-side,
  .home-card, .home-hero, .hero, .auth-box, .stat-card,
  .dash-card, .dash-metric, .table-wrap, .admin-danger {
    background-color: rgba(255, 255, 255, 0.94);
  }
}
/* 背景设置页预览与控件 */
.theme-preview {
  position: relative;
  min-height: 180px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef2ff;
}
.theme-preview::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--theme-image);
  background-size: var(--theme-fit, cover);
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--theme-opacity, 0.55);
  transition: opacity 0.2s ease;
}
.theme-preview.is-empty::before { opacity: 0; }
.theme-preview > .theme-preview-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  margin: 18px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  backdrop-filter: blur(14px) saturate(1.1);
}
.theme-preview-chip {
  display: inline-block;
  padding: 2px 8px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(79, 70, 229, 0.1);
  border-radius: 999px;
}
.form-range { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.form-range input[type="range"] { max-width: 320px; width: 100%; }
.form-range output { font-weight: 600; min-width: 44px; }
@media (max-width: 560px) {
  .theme-preview { min-height: 140px; }
  .theme-preview > .theme-preview-inner { margin: 10px; padding: 12px; }
}

/* ================= v0.9.0 T119：批量操作折叠 + 「⋯」更多菜单 ================= */
.btn-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.batch-toggle { transition: background-color .15s ease, color .15s ease, border-color .15s ease; }
.batch-toggle[aria-pressed="true"] {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(79, 70, 229, .25);
}
.batch-toggle[aria-pressed="true"]:hover { background: #4338ca; }
.batch-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin: 10px 0 4px;
  background: #f8f9ff;
  border: 1px dashed #c7cdf3;
  border-radius: 12px;
}
.batch-bar[hidden] { display: none !important; }
.batch-bar .muted { font-size: 12.5px; }
.more-menu { position: relative; display: inline-flex; align-items: center; }
.more-toggle { min-width: 36px; justify-content: center; letter-spacing: 1px; line-height: 1; }
.more-toggle[aria-expanded="true"] { background: var(--brand-weak, #eef2ff); border-color: #c7cdf3; }
.more-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 80;
  min-width: 208px;
  max-width: min(300px, 92vw);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, .16);
  animation: hubMenuIn .14s ease;
}
.more-menu-panel[hidden] { display: none !important; }
.more-menu-panel .btn { width: 100%; justify-content: flex-start; text-align: left; }
.more-menu-panel > form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 8px;
  border-radius: 10px;
  background: #f7f8fc;
}
.more-menu-panel > form > .menu-label { font-size: 12px; color: var(--muted); }
.more-menu-panel select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
}
.more-menu-panel .btn.danger { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); }
.menu-sep { height: 1px; margin: 4px 2px; background: var(--line); }
.corpus-select[hidden], th.corpus-select[hidden], td.corpus-select[hidden] { display: none !important; }
@keyframes hubMenuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 720px) {
  .more-menu-panel {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;
    max-height: 62vh;
    overflow: auto;
    min-width: 0;
    max-width: none;
  }
  .more-toggle { min-height: 40px; }
  .batch-bar { padding: 10px; }
  .batch-bar .muted { display: none; }
}

/* ===== v1.1 T181：首页任务卡文字对比度 + 加密媒体加载占位 ===== */
.home-task-card { color: var(--ink, #1f2433); }
.home-task-head strong { color: var(--ink, #1f2433); font-weight: 650; }
.home-task-head .muted,
.home-subtasks summary { color: #4b5563; }
.home-subtask-item .subtask-title,
.subtask-item .subtask-title { color: #374151; }
img[data-kb-media] { background: #eef0f5; }
img[data-kb-media][data-kb-state="loading"] {
  background: linear-gradient(90deg, #eef0f5 25%, #e3e7ef 37%, #eef0f5 63%);
  background-size: 400% 100%;
  animation: hub-media-shimmer 1.2s ease infinite;
}
img[data-kb-media][data-kb-state="locked"] { opacity: .92; }
@keyframes hub-media-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  img[data-kb-media][data-kb-state="loading"] { animation: none; }
}
/* ==== v1.2 T187：UI 主题色系统（背景取色 / 自定义配色 / 对比度） ==== */
:root {
  --accent: var(--brand-2);
  --bg-tint: var(--bg);
}
html[data-hub-theme="background"] body,
html[data-hub-theme="custom"] body {
  background-color: var(--bg-tint);
}
.theme-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.theme-color-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.theme-color-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}
.theme-color-row input[type="color"] {
  width: 48px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
}
.theme-preset-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.theme-preset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: border-color .15s ease, transform .15s ease;
}
.theme-preset:hover { border-color: var(--brand); transform: translateY(-1px); }
.theme-preset i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}
.theme-preview-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: var(--card);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.theme-preview-swatch {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--preview-brand, #4f46e5), var(--preview-accent, #06b6d4));
  border: 1px solid var(--line);
}
.theme-preview-btn {
  background: var(--preview-brand, #4f46e5);
  color: var(--preview-ink, #ffffff);
  border: 0;
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 14px;
}
.theme-preview-text { color: var(--text); font-size: 14px; }
.theme-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 14px;
  color: var(--text);
}
.theme-toggle-row input { width: 18px; height: 18px; accent-color: var(--brand); }
.theme-panel-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
#ui-theme-status { margin-top: 10px; }
#ui-theme-status.is-error { color: var(--danger); }
.tool-card[data-tool-fallback="1"] .tool-icon { background: var(--brand-weak); color: var(--brand); }
.tool-card[data-tool-fallback="1"] .status-pill.done { background: var(--brand-weak); color: var(--brand); }
@media (max-width: 720px) {
  .theme-color-grid { grid-template-columns: 1fr; }
  .theme-preview-card { padding: 12px; }
}
/* v1.2 T187：自定义主题色下的按钮/品牌文字对比度与 hover 一致 */
.btn:not(.secondary):not(.danger):hover {
  background: var(--brand);
  filter: brightness(.93);
  box-shadow: 0 6px 16px rgba(15, 23, 42, .18);
}
.ai-msg-user,
.ai-tab-btn.is-active { color: var(--brand-ink, #fff); }

/* ===== v1.2 T193：动态背景（动图/代码动效）本地播放 + 设置 UI ===== */
#bg-media {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
  display: none;
  opacity: var(--user-bg-opacity, 0.55);
  transition: opacity 0.2s ease;
  background: transparent;
}
#bg-media[data-active="1"] { display: block; }
#bg-media .bg-media-img {
  width: 100%;
  height: 100%;
  object-fit: var(--user-bg-fit, cover);
  object-position: center;
  display: block;
  /* 动图（GIF/WebP/APNG）由浏览器本地解码播放，这里只负责铺满与透明度分层 */
}
#bg-media .bg-media-img[data-kb-state="locked"],
#bg-media .bg-media-img[data-kb-state="loading"] { opacity: 0; }
#bg-media .bg-media-img[data-kb-state="decoded"],
#bg-media .bg-media-img[data-kb-state="legacy"] { opacity: 1; }
#bg-media .bg-code-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: transparent;
  pointer-events: none;
}
/* 引擎接管时关闭旧 ::before 背景层，避免双重渲染 */
body[data-bg-kind="image"]::before,
body[data-bg-kind="code"]::before { background-image: none; }
/* 动态图/代码动效透明度沿用 --user-bg-opacity（设置页滑杆实时预览） */
.bg-kind-switch {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 14px 0 6px;
}
.bg-kind-switch label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 14px;
  cursor: pointer;
}
.bg-kind-switch label input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.bg-kind-switch label.is-selected {
  border-color: var(--brand);
  background: var(--brand-weak);
  color: var(--brand);
  font-weight: 600;
}
.bg-subsection { margin-top: 16px; }
.bg-subsection[hidden] { display: none; }
.bg-dynamic-preview {
  display: block;
  max-width: 100%;
  max-height: 260px;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.bg-code-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.bg-code-editor {
  width: 100%;
  min-height: 240px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0f172a;
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
  box-sizing: border-box;
}
.bg-code-preview {
  position: relative;
  height: 240px;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #0f172a;
}
.bg-code-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  pointer-events: none;
}
.bg-hint { margin: 6px 0; }
.bg-status.is-error { color: var(--danger); }
@media (max-width: 720px) {
  .bg-kind-switch label { padding: 7px 12px; font-size: 13px; }
  .bg-code-preview { height: 200px; }
  .bg-code-editor { min-height: 200px; }
}

/* ===== v1.3 T198：视觉回归修复——沉浸模式背景不被半透明层洗白 ===== */
/* 沉浸态只保留原始背景亮度：#bg-media 与旧 ::before 兜底层都设为满不透明度，
   避免 0.55 透明度叠加在浅色 body 底色上出现「发灰发白」的中间遮罩感。 */
body.home-immersive #bg-media { opacity: 1; }
body.home-immersive[data-bg="1"]::before { opacity: 1; }
