:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --line: #e4e7ef;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #3b5bdb;
  --accent-soft: #edf1ff;
  --red: #d92d20;
  --red-soft: #fef3f2;
  --green: #067647;
  --green-soft: #ecfdf3;
  --amber: #b54708;
  --amber-soft: #fffaeb;
  --purple: #6941c6;
  --purple-soft: #f4f3ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.04);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.topbar {
  height: 68px;
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #3b5bdb, #7048e8);
  color: #fff; font-weight: 800; display: grid; place-items: center; letter-spacing: -.5px;
}
.brand h1 { font-size: 16px; margin: 0; letter-spacing: -.2px; }
.brand p { font-size: 11px; margin: 0; color: var(--muted); }
.runtime { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.badge {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid #dce4ff;
  white-space: nowrap;
}
.badge.warn { background: var(--amber-soft); color: var(--amber); border-color: #fedf89; }
.badge.ok { background: var(--green-soft); color: var(--green); border-color: #abefc6; }

.layout {
  display: grid;
  grid-template-columns: 266px minmax(360px, 1fr) 380px;
  gap: 14px;
  padding: 14px;
  height: calc(100vh - 68px);
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.side, .inspect { overflow-y: auto; padding: 16px; }
.block { margin-bottom: 22px; }
.block h2, .inspect h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); margin: 0 0 10px; font-weight: 700;
}
.inspect h3 { margin-top: 18px; }
.field-label { display: block; font-size: 11px; color: var(--muted); margin: 8px 0 4px; }
.input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text); font: inherit; font-size: 13px; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.warning, .hint-block {
  font-size: 11px; color: var(--amber); background: var(--amber-soft);
  border-radius: 8px; padding: 8px 10px; margin: 10px 0 0; line-height: 1.5;
}
.hint-block { color: var(--muted); background: #f8f9fc; }
.hint { font-size: 11px; color: var(--muted); font-weight: 400; }

.scenarios { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.scenario {
  position: relative;
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 8px 9px; text-align: left; cursor: pointer; font: inherit; font-size: 12px;
  color: var(--text); transition: .15s;
}
.scenario:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.scenario small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }

/* 首次访问引导：采用 B 方案（玫红高对比） */
.scenario-tip {
  font-size: 12px; line-height: 1.55; color: #9f1239; font-weight: 800;
  background: linear-gradient(100deg, #fff1f2 0%, #ffe4e6 55%, #eef2ff 100%);
  border: 2px solid #fb7185; border-left: 6px solid #e11d48;
  border-radius: 10px; padding: 9px 10px; margin: 0 0 12px;
  box-shadow: 0 4px 12px rgba(225,29,72,.16);
}
.scenario-tip::before {
  content: "先看这里"; display: inline-block; margin-right: 6px;
  padding: 0 6px; border-radius: 999px; background: #e11d48; color: #fff;
  font-size: 9px; font-weight: 700; vertical-align: 1px;
}
.scenario.recommended {
  border: 2px solid #e11d48; background: linear-gradient(135deg, #fff1f2, #fff);
  transform: scale(1.015); animation: scenario-pulse 1.2s ease-in-out infinite;
}
.start-tag {
  position: absolute; top: -12px; right: -10px;
  background: linear-gradient(135deg, #fb923c, #dc2626 55%, #e11d48); color: #fff;
  border-radius: 999px; font-size: 11px; font-weight: 800; line-height: 1.5;
  padding: 2px 9px; white-space: nowrap; letter-spacing: .2px;
  box-shadow: 0 4px 12px rgba(225,29,72,.5);
  animation: tag-bob 1.2s ease-in-out infinite;
}
@keyframes scenario-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(225,29,72,.55); }
  50% { box-shadow: 0 0 0 9px rgba(225,29,72,0); }
}
@keyframes tag-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.modules { display: flex; flex-direction: column; gap: 6px; }
.module {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 12px;
}
.module b { font-size: 11px; color: #fff; background: var(--accent); border-radius: 5px; padding: 1px 5px; }
.module.active { background: var(--accent-soft); border-color: #c7d2fe; }
.tools { display: flex; flex-direction: column; gap: 5px; }
.tool { font-size: 11px; display: flex; justify-content: space-between; gap: 6px; }
.tool code { font-size: 11px; color: var(--accent); }
.risk { border-radius: 4px; padding: 0 5px; font-size: 10px; background: var(--green-soft); color: var(--green); }
.risk.high { background: var(--amber-soft); color: var(--amber); }
.risk.forbidden { background: var(--red-soft); color: var(--red); }

.chat { position: relative; }
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.chat-head h2 { font-size: 14px; margin: 0; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; border-radius: 10px; padding: 10px 12px; background: #f8f9fc; border: 1px solid var(--line); }
.msg.user { align-self: flex-end; background: var(--accent-soft); border-color: #dce4ff; }
.msg.ai { align-self: flex-start; background: #fff; }
.msg.reject { background: var(--red-soft); border-color: #fecdca; }
.msg-label { font-size: 10px; color: var(--muted); margin-bottom: 4px; font-weight: 700; letter-spacing: .4px; }
.msg-body { white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.msg-body code { background: #eef1f7; padding: 1px 4px; border-radius: 4px; }

.approval {
  margin: 0 16px 10px; padding: 12px; border: 1px solid #fedf89;
  background: var(--amber-soft); border-radius: 10px;
}
.approval h3 { margin: 0 0 6px; font-size: 13px; color: var(--amber); }
.approval pre { font-size: 11px; white-space: pre-wrap; margin: 6px 0 10px; }
.approval .composer-row { justify-content: flex-end; }

.composer { padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.composer textarea {
  width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px; font: inherit; font-size: 13px; outline: none;
}
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.status { font-size: 11px; color: var(--muted); }
.btn {
  border: 0; border-radius: 8px; padding: 8px 16px; font: inherit; font-size: 13px;
  cursor: pointer; background: #eef1f7; color: var(--text);
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #2f4bc0; }
.btn.danger { background: var(--red); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 七个标签强制单行等分：任何面板宽度 / 滚动条占位都不会把「评测」挤到第二行 */
.tabs {
  display: flex; gap: 3px; border-bottom: 1px solid var(--line);
  padding-bottom: 8px; flex-wrap: nowrap;
}
.tab {
  flex: 1 1 0; min-width: 0; white-space: nowrap;
  border: 0; background: #f3f5f9; border-radius: 7px; padding: 5px 3px;
  font: inherit; font-size: 11px; line-height: 1.45; text-align: center;
  color: var(--muted); cursor: pointer;
}
.tab.active { background: var(--accent); color: #fff; }
.tab-panel { padding-top: 6px; }
.empty { color: var(--muted); font-size: 12px; }

/* 读图指南：第一次看页面的人先读这段，再看节点，避免把 L1/L2 当成模型层数 */
.primer {
  border: 1px solid #dce4ff; background: #f8faff; border-radius: 9px;
  padding: 9px 10px; margin-bottom: 10px;
  font-size: 11px; line-height: 1.65; color: #475467;
}
.primer-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 6px;
  color: var(--accent); font-weight: 700; margin-bottom: 4px;
}
.primer-head .hint { color: var(--muted); font-weight: 400; font-size: 10px; white-space: nowrap; }
.primer b { color: var(--text); }

/* 读图说明融入执行链：每段故事一个标题，说明就写在标题后面 */
.flow-group { margin-bottom: 12px; }
.flow-group:last-child { margin-bottom: 0; }
.flow-group-head {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  padding: 3px 0 6px; margin-bottom: 6px;
  border-bottom: 1px dashed var(--line);
}
.phase-no {
  flex: none; width: 17px; height: 17px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.phase-title { font-size: 12px; color: var(--text); }
.phase-sub { flex: 1 1 220px; font-size: 10px; color: var(--muted); }

.flow { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.flow-node {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px;
  font-size: 11px; background: #fbfcfe; min-width: 0;
}
.flow-node.on { border-color: var(--accent); background: var(--accent-soft); }
.flow-node.deny { border-color: #fecdca; background: var(--red-soft); }
.flow-head { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.flow-step {
  flex: none; width: 15px; height: 15px; border-radius: 50%;
  background: #eef1f7; color: var(--muted); font-size: 9px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.flow-node.on .flow-step { background: var(--accent); color: #fff; }
.flow-node.deny .flow-step { background: var(--red); color: #fff; }
.flow-title { font-size: 11px; white-space: nowrap; }
.flow-code {
  font-size: 9px; color: var(--accent); background: #e8edff;
  border-radius: 4px; padding: 0 4px; white-space: nowrap;
}
.flow-node.on .flow-code { background: #fff; }
.flow-desc { color: var(--muted); font-size: 10px; line-height: 1.45; margin-top: 4px; }
.flow-state { margin-left: auto; color: var(--muted); font-size: 9px; white-space: nowrap; }

.audit { display: flex; flex-direction: column; gap: 5px; }
.audit-item {
  border-left: 3px solid var(--accent); background: #f8f9fc; border-radius: 0 7px 7px 0;
  padding: 6px 9px; font-size: 11px; cursor: pointer;
}
.audit-item.deny { border-color: var(--red); background: var(--red-soft); }
.audit-item.degrade { border-color: var(--amber); background: var(--amber-soft); }
.audit-item.approve { border-color: var(--green); background: var(--green-soft); }
.audit-item b { color: var(--text); }
.audit-detail { font-size: 11px; white-space: pre-wrap; word-break: break-all; color: var(--muted); margin-top: 4px; }

.stage-row, .decision-row, .fact, .episode, .evidence-item, .layer {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; font-size: 11px;
}
.stage-row b, .decision-row b { display: inline-block; min-width: 78px; }
.stage-row .num { float: right; color: var(--accent); font-weight: 700; }
.degrade-row { border-left: 3px solid var(--amber); background: var(--amber-soft); border-radius: 0 7px 7px 0; padding: 6px 9px; margin-bottom: 5px; font-size: 11px; }
.evidence-item { background: #fbfcfe; }
.evidence-item .src { color: var(--purple); font-weight: 700; }
.evidence-item .txt { color: var(--muted); margin-top: 4px; max-height: 76px; overflow: auto; white-space: pre-wrap; }

/* 知识库文档入口（侧栏） */
.doc-entry { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.doc-entry .btn { white-space: nowrap; }
.doc-entry .hint { font-size: 10px; }

.fact { background: var(--purple-soft); border-color: #e4d9ff; }
.episode { background: var(--green-soft); border-color: #abefc6; }
.layer { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.layer small { color: var(--muted); font-size: 10px; }
.layer-plain { color: #344054; font-size: 11px; margin: 2px 0 1px; }
.layer .state { flex: none; font-size: 10px; border-radius: 4px; padding: 1px 5px; background: var(--green-soft); color: var(--green); }
.layer .state.deny { background: var(--red-soft); color: var(--red); }

.budget-row { margin-bottom: 9px; }
.budget-row .bar-head { display: flex; justify-content: space-between; font-size: 11px; }
.track { height: 7px; border-radius: 99px; background: #edf0f5; margin-top: 4px; overflow: hidden; }
.fill { height: 100%; background: var(--accent); border-radius: 99px; width: 0; transition: width .3s; }
.fill.memory { background: var(--purple); }
.fill.rag { background: var(--green); }
.fill.headroom { background: #d0d5dd; }
.trimming-item { font-size: 11px; color: var(--amber); margin-bottom: 4px; }

.usage-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.usage-chip {
  flex: 1 1 88px; border: 1px solid var(--line); border-radius: 8px;
  background: #f8f9fc; padding: 6px 8px; display: flex; flex-direction: column; gap: 2px;
}
.usage-chip-label { font-size: 10px; color: var(--muted); }
.usage-chip b { font-size: 12px; color: var(--text); }
.usage-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 7px; }
.usage-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.usage-head b { font-size: 12px; color: var(--accent); }
.usage-tag { font-size: 10px; color: var(--green); background: var(--green-soft); border-radius: 4px; padding: 1px 6px; }
.usage-line { font-size: 11px; color: var(--text); margin-top: 5px; }
.usage-line.muted { color: var(--muted); }
.rerank-item { border-color: #b9c7f5; background: var(--accent-soft); }
.usage-tag-warn { color: var(--amber); background: var(--amber-soft); }
.usage-footnote { font-size: 10px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

.learn h4 { margin: 14px 0 5px; font-size: 12px; color: var(--accent); }
.learn p, .learn li { font-size: 12px; color: #475467; }
.learn ul { padding-left: 18px; margin: 4px 0; }
.learn code { background: #eef1f7; padding: 1px 4px; border-radius: 4px; font-size: 11px; }

/* 评测看板 */
.eval-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.eval-head h3 { margin-top: 0; }
.btn.mini { font-size: 11px; padding: 4px 9px; }
.eval-latest { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; }
.eval-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.eval-latest .state, .eval-run .state {
  font-size: 10px; border-radius: 4px; padding: 1px 6px;
  background: var(--green-soft); color: var(--green); white-space: nowrap;
}
.eval-latest .state.fail, .eval-run .state.fail { background: var(--red-soft); color: var(--red); }
.eval-group {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 9px;
  margin-bottom: 10px; background: #fff;
}
.eval-group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; }
.eval-group-count { font-size: 10px; color: var(--muted); white-space: nowrap; }
.eval-group-hint { font-size: 10px; color: var(--muted); margin: 3px 0 7px; }
.eval-run-track {
  font-size: 11px; font-weight: 600; color: var(--accent);
  padding: 8px 0 3px; border-bottom: 1px solid var(--line);
}
.metric-row {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px;
  margin-bottom: 6px; background: #fbfcfe;
}
.metric-head { display: flex; align-items: baseline; gap: 6px; font-size: 11px; }
.metric-key { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.metric-value { font-variant-numeric: tabular-nums; font-weight: 700; }
.metric-delta { font-size: 10px; font-variant-numeric: tabular-nums; }
.metric-delta.good { color: var(--green); }
.metric-delta.bad { color: var(--red); }
.metric-delta.muted { color: var(--muted); }
.metric-chart { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.metric-chart small { color: var(--muted); font-size: 10px; }
.spark { width: 108px; height: 28px; flex: none; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.spark-dot { fill: var(--accent); }
.spark-base { stroke: #d0d5dd; stroke-width: 1; stroke-dasharray: 3 2; }
.eval-run {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px;
  border-bottom: 1px solid var(--line); padding: 6px 0; font-size: 11px;
}
.eval-run .run-time { color: var(--muted); font-size: 10px; }
.eval-run .run-meta { color: var(--muted); font-size: 10px; }
.eval-run .state { grid-column: 2; grid-row: 1 / span 3; align-self: center; }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 230px 1fr; height: auto; }
  .inspect { grid-column: 1 / -1; max-height: 620px; }
}

/* 独立知识库文档页 */
.docs-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 14px; padding: 14px; height: calc(100vh - 68px); }
.docs-nav { padding: 16px; overflow-y: auto; }
.docs-content { padding: 18px 22px; overflow-y: auto; }
.docs-nav .btn { margin-top: 10px; }
.toc { display: flex; flex-direction: column; gap: 5px; }
.toc-item {
  display: flex; flex-direction: column; gap: 1px; text-align: left;
  border: 1px solid var(--line); background: #f8f9fc; border-radius: 8px;
  padding: 7px 9px; font: inherit; font-size: 12px; color: var(--text); cursor: pointer;
}
.toc-item:hover { background: var(--accent-soft); border-color: #dce4ff; }
.toc-item small { color: var(--muted); font-size: 10px; }
.docs-doc { border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; background: #fff; scroll-margin-top: 14px; }
.docs-doc-head { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 12px; }
.docs-doc-head h2 { margin: 0; font-size: 16px; }
.docs-doc-meta { font-size: 11px; color: var(--muted); margin-top: 4px; word-break: break-all; }
.docs-chunk { border-left: 3px solid var(--purple); background: #fbfcfe; border-radius: 0 7px 7px 0; padding: 9px 12px; margin-bottom: 10px; }
.docs-chunk-head { font-size: 10px; color: var(--purple); font-weight: 700; }
.docs-chunk-text { margin: 5px 0 0; white-space: pre-wrap; word-break: break-word; font: 12px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; color: #344054; }
@media (max-width: 860px) {
  .docs-layout { grid-template-columns: 1fr; height: auto; }
  .docs-nav, .docs-content { max-height: none; }
}
