:root {
  --bg: #f7f4ee;
  --panel: #fffcf7;
  --ink: #1a1916;
  --muted: #6f6a63;
  --line: #e5dfd4;
  --accent: #0e4b3c;
  --accent-soft: #e8f2ee;
  --accent-2: #9a3412;
  --danger: #b91c1c;
  --host: #0e4b3c;
  --researcher: #1e4e8c;
  --retriever: #7c2d12;
  --lawyer: #9a3412;
  --system: #57534e;
  --kb: #0e4b3c;
  --mg: #9a3412;
  --uv: #7f1d1d;
  font-family: "PingFang SC", "Source Han Sans SC", "Noto Sans SC", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at top left, #efe6d5 0%, transparent 45%),
    linear-gradient(180deg, #f7f3eb, var(--bg));
  min-height: 100vh;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 247, 0.96);
  position: sticky;
  top: 0;
  z-index: 120;
  flex-wrap: wrap;
}
.brand { display: flex; gap: 0.9rem; align-items: center; }
.brand p, .meta, .hint, .disclaimer, .side-hint { margin: 0; color: var(--muted); font-size: 0.85rem; }
.brand strong { font-size: 1.15rem; }
.mark {
  display: grid; place-items: center;
  width: 3rem; height: 3rem; border-radius: 0.4rem;
  background: var(--accent); color: #f8faf7;
  font-family: "DIN Alternate", "Helvetica Neue", sans-serif;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.06em;
}
.top-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.disclaimer {
  border: 1px solid #edd8b0; background: #fff8eb; color: #92400e;
  padding: 0.35rem 0.7rem; border-radius: 999px;
}

.shell {
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
  align-items: stretch;
}
.rail {
  background: #122820;
  color: #e7f2ee;
  padding: 1rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
}
.rail-btn {
  text-align: left;
  border: 0;
  background: transparent;
  color: #d7ebe4;
  border-radius: 12px;
  padding: .85rem .8rem;
  cursor: pointer;
  font: inherit;
}
.rail-btn strong { display: block; font-size: 1rem; font-weight: 700; }
.rail-btn small { display: block; margin-top: .2rem; opacity: .62; font-size: .72rem; font-weight: 400; }
.rail-btn.on { background: #f7f4ee; color: #0e4b3c; }
.rail-btn.on small { color: #3f6f62; opacity: 1; }
.layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 1rem;
  max-width: none;
  padding: 1rem 1rem 1.4rem;
}
.group-label {
  list-style: none; font-size: .75rem; color: var(--muted); letter-spacing: .04em;
  margin: .7rem 0 .25rem; padding: 0 .2rem;
}
.form-err {
  margin: 0 0 .7rem;
  padding: .55rem .7rem;
  border-radius: 8px;
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #f0b4b4;
  font-size: .86rem;
  line-height: 1.45;
}
.new-file-list { list-style: none; margin: .4rem 0 0; padding: 0; display: grid; gap: .3rem; }
.new-file-list li {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .45rem .55rem;
  font-size: .84rem;
}
.new-file-list .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.new-file-list .hint { border: 0; background: transparent; padding: 0; color: var(--muted); }
.material-list { list-style: none; margin: .4rem 0 0; padding: 0; }
.material-list li {
  display: flex; justify-content: space-between; gap: .5rem;
  padding: .35rem 0; border-top: 1px dashed var(--line); font-size: .84rem;
}
.materials .btn input { display: none; }
.view-kb { padding: 1.1rem 1.25rem 1.6rem; min-width: 0; background: transparent; }
.kb-page-h { display: flex; align-items: center; gap: .85rem; flex-wrap: wrap; margin-bottom: .9rem; }
.kb-page-h h1 { margin: 0; font-size: 1.35rem; }
.kb-page { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: .9rem; align-items: start; }
.filters {
  padding: 1rem .95rem;
  background: #fffcf7;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(26,25,22,.05);
}
.kb-main {
  min-height: 68vh;
  padding: 1rem 1.05rem 1.2rem;
  background: #fffcf7;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(26,25,22,.05);
}
.kb-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem;
  padding: 0 0 .85rem;
  border: 0;
}
.kb-toolbar input {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 .85rem;
  font: inherit;
  background: #fff;
}
.kb-body {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: .75rem;
  min-height: 520px;
  max-height: none;
  border: 0;
}
.kb-doc-list { list-style: none; margin: 0; padding: 0; }
.kb-doc-list li {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .7rem .8rem;
  margin: 0 0 .45rem;
  cursor: pointer;
}
.kb-doc-list li.active, .kb-doc-list li:hover { border-color: #9dcec0; background: #f4faf7; }
.kb-doc-list .t { font-weight: 680; display: block; margin-bottom: .28rem; }
.kb-doc-list .s { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; color: var(--muted); font-size: .75rem; }
.kb-row { display: flex; gap: .5rem; align-items: flex-start; justify-content: space-between; }
.kb-row-main { min-width: 0; flex: 1; }
.kb-del {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 .55rem;
  font-size: .75rem;
  color: var(--danger);
  border-color: #f0c2c2;
}
.kb-detail-h {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: .35rem;
}
.kb-detail-h h3 { margin: 0 0 .25rem; }
.kb-detail-h .meta { margin: 0; }
.kb-detail {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .9rem 1rem;
  min-height: 280px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  box-shadow: 0 10px 30px rgba(28, 25, 23, 0.04);
}
.list-panel { padding: 0.9rem; height: calc(100vh - 6.5rem); overflow: auto; }
.detail-panel { padding: 1.1rem 1.2rem 1.4rem; min-height: calc(100vh - 6.5rem); }
.panel-h { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.panel-h-actions { display: inline-flex; align-items: center; gap: 0.45rem; }
.panel-h h2, .panel-h h3, .card h3 { margin: 0; font-size: 1rem; }
.side-hint { margin: 0.5rem 0 0.2rem; }

.btn {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 0.4rem; height: 36px; padding: 0 0.75rem; font: inherit; font-size: 0.85rem;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 0.3rem;
}
.btn:hover { border-color: #c4b9a8; }
.btn.primary { background: var(--accent); color: #f5faf7; border-color: transparent; }
.btn.danger { background: #fff; color: var(--danger); border-color: #f0b4b4; }
.btn.danger:hover:not(:disabled) { background: #fef2f2; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.busy { pointer-events: none; opacity: 0.65; }

.board-list { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.board-list li {
  padding: 0.75rem 0.7rem; border: 1px solid transparent; border-radius: 0.55rem; cursor: pointer;
}
.board-list li:hover, .board-list li.active { background: #f3efe6; border-color: var(--line); }
.board-list .t { font-weight: 600; display: block; }
.board-list .s { color: var(--muted); font-size: 0.8rem; }
.board-row { display: flex; gap: .45rem; align-items: flex-start; justify-content: space-between; }
.board-row-main { min-width: 0; flex: 1; }
.board-del { flex: 0 0 auto; height: 28px; padding: 0 .5rem; font-size: .75rem; }
.legend { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 1rem; }
.tag {
  font-size: 0.75rem; padding: 0.15rem 0.45rem; border-radius: 999px; border: 1px solid;
}
.tag.kb { color: var(--kb); border-color: #a7c4b8; background: #eef6f2; }
.tag.mg { color: var(--mg); border-color: #f0d2a8; background: #fff7ed; }
.tag.uv { color: var(--uv); border-color: #f0b4b4; background: #fef2f2; }

.hidden { display: none !important; }
.empty {
  display: grid; place-items: center; min-height: 50vh; color: var(--muted); font-size: 1.05rem; text-align: center;
}
.empty h2 { margin: 0 0 0.5rem; color: var(--ink); }

.detail-h {
  display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.detail-h h1 { margin: 0 0 0.35rem; font-size: 1.35rem; }
.demo-tag { margin: 0 0 0.25rem; color: var(--accent); font-size: 0.82rem; font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pill {
  display: inline-block; padding: 0.12rem 0.5rem; border-radius: 999px; background: #ece7dc; font-size: 0.78rem;
}
.pill.discussing { background: var(--accent-soft); color: var(--accent); }
.pill.awaiting_confirm { background: #fff7ed; color: var(--accent-2); }
.pill.confirmed { background: var(--accent-soft); color: var(--accent); }
.pill.failed { background: #fef2f2; color: var(--danger); }
.pill.stopped { background: #f5f5f4; color: var(--system); }
.pill.draft { background: #ece7dc; color: var(--system); }

.grid {
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 0.8rem; margin-bottom: 0.8rem;
}
.card {
  border: 1px solid var(--line); border-radius: 0.65rem; padding: 0.9rem 1rem; background: #fffefb;
}
.summary { white-space: pre-wrap; line-height: 1.55; margin: 0.6rem 0 0; }
.quote {
  margin: 0.7rem 0 0; padding: 0.55rem 0.7rem; border-left: 3px solid var(--accent-2);
  background: #fff8eb; color: #7c2d12; font-style: italic;
}
.insight-row { margin: 0.45rem 0; line-height: 1.45; }

.timeline { margin-top: 0.8rem; display: flex; flex-direction: column; gap: 0.75rem; max-height: 48vh; overflow: auto; }
.timeline-wrap { position: relative; }
.discuss-card.is-fullscreen {
  position: fixed;
  top: var(--topbar, 72px);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  margin: 0;
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
  padding: 1rem 0.65rem 1.1rem 1.25rem;
  background: #fffcf7;
  box-shadow: none;
  overflow: hidden;
}
.discuss-card.is-fullscreen > .panel-h {
  position: relative;
  z-index: 95;
  flex-shrink: 0;
  overflow: visible;
  padding-right: 0.6rem;
}
.discuss-card.is-fullscreen .fs-model-pick {
  display: inline-flex;
}
.discuss-card.is-fullscreen .fs-model-pick select {
  background: #fff;
  color: var(--ink);
  position: relative;
  z-index: 96;
}
.discuss-card.is-fullscreen .timeline-wrap {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-right: 14px;
}
.discuss-card.is-fullscreen .timeline {
  flex: 1;
  max-height: none;
  min-height: 0;
  margin-top: 0.5rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none; /* 用自定义右侧导航条，隐藏系统条 */
}
.discuss-card.is-fullscreen .timeline::-webkit-scrollbar {
  width: 0;
  height: 0;
}
.timeline-rail {
  position: absolute;
  top: 0.5rem;
  right: 2px;
  bottom: 0.35rem;
  width: 10px;
  border-radius: 999px;
  background: #efe8db;
  z-index: 5;
  cursor: pointer;
}
.timeline-rail.hidden { display: none !important; }
.discuss-card.is-fullscreen .timeline-rail:not(.hidden) {
  display: block;
}
.timeline-thumb {
  position: absolute;
  left: 1px;
  right: 1px;
  top: 0;
  height: 48px;
  border-radius: 999px;
  background: #b7aa96;
  cursor: grab;
  transition: background 0.15s;
}
.timeline-thumb:hover,
.timeline-thumb.is-dragging {
  background: #8f816c;
}
.timeline-thumb.is-dragging { cursor: grabbing; }
.discuss-card.is-fullscreen .intervene {
  flex-shrink: 0;
  margin-top: 0.65rem;
  padding-right: 0.6rem;
}
body.fs-lock { overflow: hidden; }

.msg {
  border-left: 3px solid var(--system); padding: 0.65rem 0.85rem; background: #faf7f1;
  border-radius: 0 0.5rem 0.5rem 0;
}
.msg.msg-enter { animation: rise 0.35s ease; }
.msg.host { border-color: var(--host); }
.msg.researcher { border-color: var(--researcher); }
.msg.retriever { border-color: var(--retriever); }
.msg.lawyer { border-color: var(--lawyer); background: #fff7ed; }
.msg.failed { background: #fef2f2; border-color: var(--uv); }
.msg-h {
  display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.35rem;
}
.msg-h .who { color: var(--ink); font-weight: 700; }
button.case-open {
  background: none;
  border: 0;
  padding: 0;
  color: #0e4b3c;
  font: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
button.case-open:hover { color: #08352a; }
a.case-src { color: #0e4b3c; }
.md-code {
  white-space: pre-wrap;
  background: #f6f3ec;
  border-radius: 0.4rem;
  padding: 0.55rem 0.7rem;
  font-size: 0.8rem;
  line-height: 1.45;
  overflow: auto;
}
.stream-body { position: relative; }
.stream-caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  background: #0e4b3c;
  vertical-align: text-bottom;
  animation: caret-blink 1s steps(1) infinite;
}
@keyframes caret-blink {
  50% { opacity: 0; }
}
.msg-body p { margin: 0.4em 0; }
.msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4,
.msg-body .md-h {
  display: block;
  color: #b91c1c;
  font-weight: 700;
  margin: 0.9em 0 0.28em;
  line-height: 1.35;
}
.msg-body h1 { font-size: 1.16em; }
.msg-body h2 { font-size: 1.08em; }
.msg-body h3, .msg-body h4 { font-size: 1em; }
.msg-body ul, .msg-body ol { margin: 0.2em 0 0.65em; padding-left: 1.3em; }
.msg-body li { margin: 0.22em 0; }
.msg-body li p { margin: 0; }
.msg-body .core,
.insight-row .core,
#d-insight .core {
  color: #b91c1c;
  font-weight: 700;
}
.msg-body hr, .msg-body .md-hr {
  display: block;
  border: 0;
  border-top: 1px dashed var(--line);
  margin: 0.75em 0;
  height: 0;
}
.msg-body blockquote {
  margin: 0.45em 0;
  padding: 0.35em 0.75em;
  border-left: 3px solid #e7d3b0;
  background: #fff8eb;
  color: #57534e;
}
.msg-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
  background: #f3efe6;
  padding: 0.05em 0.35em;
  border-radius: 4px;
}
.md-table-wrap {
  overflow-x: auto;
  margin: 0.55em 0 0.85em;
  border: 1px solid #e7e0d4;
  border-radius: 0.45rem;
  background: #fff;
}
.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  line-height: 1.5;
}
.md-table th,
.md-table td {
  border-bottom: 1px solid #efe8dc;
  padding: 0.45rem 0.6rem;
  vertical-align: top;
  text-align: left;
  min-width: 6.5rem;
}
.md-table th {
  background: #f6f1e8;
  font-weight: 700;
  color: #1c1917;
  white-space: nowrap;
}
.md-table tr:last-child td { border-bottom: 0; }
.md-table td .core { font-weight: 700; }
.cites { margin: 0.5rem 0 0; padding: 0; list-style: none; }
.cites li {
  font-size: 0.8rem; border-top: 1px dashed var(--line); padding: 0.35rem 0; display: flex; gap: 0.4rem; align-items: flex-start;
}
.cites .pill-cite {
  flex: 0 0 auto; font-size: 0.72rem; padding: 0.05rem 0.4rem; border-radius: 999px; border: 1px solid;
}
.cites .pill-cite.kb { color: var(--kb); border-color: #a7c4b8; background: #eef6f2; }
.cites .pill-cite.mg { color: var(--mg); border-color: #f0d2a8; background: #fff7ed; }
.cites .pill-cite.uv { color: var(--uv); border-color: #f0b4b4; background: #fef2f2; }

.intervene { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; margin-top: 0.9rem; }
.intervene input, .dlg input, .dlg textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 0.45rem; padding: 0.55rem 0.7rem; font: inherit; background: #fff;
}
.speaking { color: var(--accent); font-size: 0.85rem; animation: pulse 1.2s ease infinite; }
.msg.speaking-msg {
  border-style: dashed; background: linear-gradient(180deg, #f7fbf9, #fff);
}
.typing-line {
  display: flex; align-items: center; gap: 0.55rem;
  color: var(--muted); font-size: 0.92rem;
}
.typing-dots { display: inline-flex; gap: 4px; align-items: center; }
.typing-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  opacity: 0.35; animation: typingDot 1s ease-in-out infinite;
}
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingDot {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

dialog {
  border: 1px solid var(--line); border-radius: 0.75rem; padding: 0; width: min(520px, 92vw); background: var(--panel);
}
dialog::backdrop { background: rgba(28, 25, 23, 0.35); }
.dlg { padding: 1.2rem; display: grid; gap: 0.7rem; }
.dlg h2 { margin: 0; }
.dlg label { display: grid; gap: 0.3rem; font-size: 0.9rem; }
.dlg-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes pulse { 50% { opacity: 0.45; } }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .list-panel { height: auto; max-height: 260px; }
  .grid { grid-template-columns: 1fr; }
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(420px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  padding: 1.4rem;
  display: grid;
  gap: 0.7rem;
  box-shadow: 0 16px 40px rgba(28,25,23,.06);
}
.login-card h1 { margin: 0; font-size: 1.25rem; }
.login-card .mark { width: 3.2rem; height: 3.2rem; }
.err { color: #b91c1c; min-height: 1.2em; margin: 0; }

.model-pick {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.model-pick select {
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  padding: 0.3rem 0.45rem;
  font: inherit;
  background: #fff;
  max-width: 260px;
  min-width: 140px;
  cursor: pointer;
}
.fs-model-pick select {
  max-width: 320px;
  min-width: 180px;
}
.model-badge {
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f3efe6;
}
.model-badge.local { background: #eef6f2; border-color: #a7c4b8; color: #0f4c3a; }
.model-badge.commercial { background: #fef2f2; border-color: #f0b4b4; color: #7f1d1d; }
.model-badge.mock { background: #ece7dc; }

.kb-link {
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  color: var(--accent) !important;
}
.kb-link:hover { color: #0a3a2c !important; }

dialog.dlg-kb {
  width: min(960px, 96vw);
  max-height: 90vh;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  padding: 0;
  background: var(--panel);
}
dialog.dlg-kb::backdrop { background: rgba(28, 25, 23, 0.4); }
.kb-shell { display: flex; flex-direction: column; max-height: 90vh; }
.kb-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; padding: 1rem 1.1rem 0.7rem; border-bottom: 1px solid var(--line);
}
.kb-top h2 { margin: 0 0 0.2rem; font-size: 1.15rem; }
.seg { display: flex; background: #efeae2; border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: transparent; border-radius: 7px; height: 30px; padding: 0 .75rem; cursor: pointer; font: inherit; }
.seg button.on { background: #fff; font-weight: 650; }
.filters h3 { margin: .85rem 0 .35rem; font-size: .82rem; }
.filters h3:first-child { margin-top: 0; }
.chk { display: flex; gap: .4rem; align-items: center; font-size: .86rem; padding: .22rem 0; }
.ingest, .ingest-gate {
  margin-top: .95rem;
  padding-top: .85rem;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: .35rem;
}
.ingest-gate p { margin: 0; font-size: .86rem; line-height: 1.5; }
.ingest input, .ingest select, .ingest textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: .45rem .55rem; font: inherit; background: #fff;
}
.ingest label { display: grid; gap: .25rem; font-size: .82rem; color: var(--muted); }
.ingest label input, .ingest label select, .ingest label textarea { color: var(--ink); }
.kb-detail h3 { margin: 0 0 0.35rem; font-size: 1.1rem; }
.kb-detail .meta { margin: 0 0 0.8rem; }
.kb-chunk {
  border: 1px solid var(--line); border-radius: 0.55rem; padding: 0.7rem 0.8rem;
  margin: 0 0 0.65rem; background: #fffefb; white-space: pre-wrap; line-height: 1.55;
}
.kb-chunk .loc { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.35rem; }
.kb-hit {
  border-left: 3px solid var(--accent); padding: 0.65rem 0.8rem; margin: 0 0 0.65rem;
  background: #f3efe6; border-radius: 0 0.5rem 0.5rem 0; cursor: pointer;
}
.kb-hit:hover { background: #ebe4d6; }
.kb-hit .score { color: var(--accent); font-size: 0.78rem; font-weight: 700; }
.cites .pill-cite.kb { cursor: pointer; }
.cites li.cite-kb { cursor: pointer; }
.cites li.cite-kb:hover { background: #eef6f2; }
.kb-ask-hits { display: grid; gap: 0.45rem; margin: 0.85rem 0 0.5rem; }
.kb-ask-hit {
  display: flex; align-items: center; gap: 0.5rem; width: 100%; text-align: left;
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 0 0.5rem 0.5rem 0; padding: 0.55rem 0.75rem;
  background: #f3efe6; cursor: pointer; font: inherit; color: inherit;
}
.kb-ask-hit:hover { background: #ebe4d6; }
.kb-ask-hit-t { flex: 1; min-width: 0; }

@media (max-width: 900px) {
  .kb-body { grid-template-columns: 1fr; max-height: none; }
  .kb-list-pane { max-height: 180px; border-right: none; border-bottom: 1px solid var(--line); }
}

.env-tag {
  display: inline-flex; width: fit-content; font-size: 0.72rem; color: var(--accent);
  background: var(--accent-soft); padding: 0.18rem 0.5rem; border-radius: 999px;
}
.empty {
  display: grid; place-items: center; min-height: 50vh; color: var(--muted); text-align: center;
}
.empty-inner { display: grid; gap: 0.55rem; justify-items: center; max-width: 360px; }
.empty-inner h2 { margin: 0.3rem 0 0; color: var(--ink); font-size: 1.2rem; }
.empty-inner .mark { margin-bottom: 0.2rem; }

.progress {
  display: grid; gap: 0.4rem; padding: 0.65rem 0.75rem; margin-bottom: 0.75rem;
  background: var(--accent-soft); border-radius: 0.5rem; border: 1px solid #c5ddd3;
}
.progress.hidden { display: none !important; }
.steps { display: flex; align-items: center; }
.step {
  display: flex; align-items: center; gap: 0.35rem; font-size: 0.75rem; color: var(--muted); font-weight: 600;
}
.step i {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid #a7c4b8; background: #fff; display: inline-block;
}
.step.done i { background: var(--accent); border-color: var(--accent); }
.step.cur { color: var(--accent); }
.step.cur i {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 75, 60, 0.2);
}
.step-line { flex: 1; height: 2px; background: #c5ddd3; margin: 0 0.25rem; min-width: 6px; }
.step-line.on { background: var(--accent); }
.compliance-banner {
  margin: 0.5rem 0 0;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  font-size: 0.85rem;
  line-height: 1.45;
}
.compliance-banner.hidden { display: none; }
.progress-meta { margin: 0; font-size: 0.82rem; color: var(--accent); }
.progress-meta.warn { color: var(--accent-2); }

.failbar {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: space-between;
  padding: 0.7rem 0.85rem; margin-bottom: 0.75rem; background: #fef2f2; border-radius: 0.5rem;
  border-left: 3px solid var(--danger);
}
.failbar.hidden { display: none !important; }
.failbar p { margin: 0; font-size: 0.85rem; }
.fail-ops { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.queue {
  margin-bottom: 0.65rem; font-size: 0.78rem; color: var(--accent); background: var(--accent-soft);
  padding: 0.4rem 0.6rem; border-radius: 0.4rem;
}
.queue.hidden { display: none !important; }

.newfab {
  position: absolute; right: 12px; bottom: 8px; z-index: 2;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  padding: 0.4rem 0.75rem; font-size: 0.75rem; font-weight: 600; cursor: pointer;
  box-shadow: 0 8px 20px rgba(14, 75, 60, 0.25);
}
.newfab.hidden { display: none !important; }

.toast {
  position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 200;
  background: #1a1916; color: #f5f2eb; padding: 0.55rem 0.9rem; border-radius: 999px;
  font-size: 0.85rem; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: 90vw;
}
.toast.hidden { display: none !important; }

dialog.dlg-ix {
  border: 1px solid var(--line); border-radius: 0.75rem; padding: 0; width: min(440px, 92vw); background: var(--panel);
}
dialog.dlg-ix::backdrop { background: rgba(28, 25, 23, 0.4); }
.dlg-ix .dlg-actions .btn.danger { background: #fff; }

.board-list li .pulse {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  margin-right: 0.3rem; vertical-align: 2px; animation: pulse 1.2s ease infinite;
}

.msg.collapsed .msg-body { max-height: 12em; overflow: hidden; position: relative; }
.msg.collapsed .msg-body::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3em;
  background: linear-gradient(transparent, #faf7f1);
}
.msg .btn-expand {
  margin-top: 0.35rem; font-size: 0.78rem; color: var(--accent); background: none; border: 0;
  cursor: pointer; padding: 0; font: inherit; font-weight: 600;
}

/* —— 法规同步（NPC flk） —— */
.npc-pane { display: flex; flex-direction: column; gap: .85rem; }
.npc-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .65rem; }
.npc-kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: .65rem;
  padding: .85rem 1rem; display: flex; flex-direction: column; gap: .2rem;
}
.npc-kpi .n { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; color: #1a1916; }
.npc-kpi .l { font-size: .78rem; color: var(--muted); }
.npc-kpi.warn .n { color: #b45309; }
.npc-kpi.danger .n { color: #b91c1c; }
.npc-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1rem; }
.npc-ops { display: flex; flex-wrap: wrap; align-items: end; gap: .45rem; }
.npc-ops.npc-readonly .btn:not(.ghost),
.npc-ops.npc-readonly .npc-fetch { opacity: .45; pointer-events: none; }
.npc-fetch { display: flex; flex-direction: column; gap: .2rem; font-size: .78rem; color: var(--muted); }
.npc-fetch input {
  width: min(280px, 70vw); height: 32px; border: 1px solid var(--line); border-radius: .45rem;
  padding: 0 .55rem; font: inherit; background: #fff;
}
.npc-tabs { align-self: flex-start; }
.npc-panel { padding: 1rem 1.1rem; }
.npc-panel h3 { margin: 0 0 .45rem; font-size: 1rem; }
.npc-panel h3 + .hint, .npc-wl-row + h3 { margin-top: 1.1rem; }
.npc-wl-row { display: flex; gap: .65rem; align-items: flex-start; flex-wrap: wrap; }
.npc-wl-row textarea {
  flex: 1; min-width: 220px; border: 1px solid var(--line); border-radius: .5rem;
  padding: .55rem .65rem; font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82rem; background: #fff;
}
.npc-table-wrap { overflow: auto; max-height: min(52vh, 520px); border: 1px solid var(--line); border-radius: .5rem; }
.npc-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.npc-table th, .npc-table td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.npc-table th { background: #f3efe8; position: sticky; top: 0; font-weight: 650; white-space: nowrap; }
.npc-table td.hint, .npc-table .hint { color: var(--muted); }
.npc-ops-cell { white-space: nowrap; display: flex; gap: .35rem; }
.btn.tiny { height: 28px; padding: 0 .55rem; font-size: .78rem; }
.npc-gate { padding: 1rem 1.1rem; border-left: 3px solid var(--accent); }
@media (max-width: 960px) {
  .npc-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.npc-advanced {
  margin: .85rem 0 1rem; padding: .65rem .85rem; border: 1px dashed var(--line); border-radius: .5rem; background: #faf7f1;
}
.npc-advanced summary { cursor: pointer; font-weight: 650; font-size: .9rem; }
.npc-advanced[open] summary { margin-bottom: .45rem; }
.npc-scope-kpis { font-size: .82rem; color: var(--muted); margin-bottom: .5rem; }

.npc-progress { padding: .85rem 1rem; }
.npc-prog-h { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; margin-bottom: .45rem; }
.npc-prog-bar { height: 8px; background: #efeae2; border-radius: 999px; overflow: hidden; }
.npc-prog-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .25s ease; }
.npc-prog-current { font-size: .86rem; margin: .45rem 0 .35rem; min-height: 1.2em; }
.npc-prog-log { max-height: 220px; margin-top: .4rem; }
.npc-progress.is-running { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(14,75,60,.12); }
.npc-progress.is-failed { border-color: #b91c1c; }
.npc-failed-h { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .35rem; }
.npc-failed-h h3 { margin: 0; }
.npc-filters {
  display: flex; flex-wrap: wrap; gap: .55rem .75rem;
  align-items: end; margin: .55rem 0 .75rem;
  padding: .65rem .75rem; border-radius: 8px;
  background: var(--surface-2, #f4f6f8); border: 1px solid var(--line, #e5e8eb);
}
.npc-filters label {
  display: flex; flex-direction: column; gap: .25rem;
  font-size: .78rem; color: var(--muted, #667);
}
.npc-filters input,
.npc-filters select {
  min-width: 8.5rem; padding: .35rem .5rem;
  border: 1px solid var(--line, #d0d5dd); border-radius: 6px;
  background: #fff; font-size: .85rem;
}
.npc-filters #npc-rf-q { min-width: 11rem; }
.npc-filters #npc-rf-count { align-self: center; margin-left: auto; }
.npc-sort-btn {
  appearance: none; border: 0; background: transparent; padding: 0;
  font: inherit; font-weight: 600; color: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: .2rem;
}
.npc-sort-btn::after {
  content: "⇅"; font-size: .7em; opacity: .35; font-weight: 400;
}
.npc-sort-btn.is-asc::after { content: "↑"; opacity: .9; }
.npc-sort-btn.is-desc::after { content: "↓"; opacity: .9; }
.npc-sort-btn:hover { color: var(--accent, #1a6b4a); }
.npc-action-fail { color: #b91c1c; font-weight: 650; }
.npc-action-ok { color: #0e4b3c; font-weight: 650; }

dialog.dlg-npc-review {
  width: min(920px, 96vw); max-height: 92vh; padding: 0; border: 1px solid var(--line);
  border-radius: .75rem; background: var(--panel);
}
dialog.dlg-npc-review::backdrop { background: rgba(28, 25, 23, 0.45); }
.npc-review-dlg { display: flex; flex-direction: column; max-height: 92vh; padding: 1rem 1.15rem 1rem; gap: .65rem; }
.npc-review-h { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.npc-review-h h2 { margin: 0; font-size: 1.15rem; }
.npc-review-meta-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .45rem .75rem;
  font-size: .82rem; color: var(--muted); padding: .55rem .7rem; background: #f3efe8; border-radius: .5rem;
}
.npc-review-meta-grid strong { color: #1a1916; font-weight: 650; display: block; }
.npc-review-body {
  flex: 1; min-height: 280px; max-height: min(68vh, 720px); overflow: auto;
  border: 1px solid var(--line); border-radius: .5rem; padding: .85rem 1rem;
  background: #fff; font-size: .92rem; line-height: 1.65; white-space: normal;
}
.npc-review-body .bubble { white-space: normal; }
.npc-review-actions { margin-top: .25rem; justify-content: flex-end; }
a.npc-title-link {
  color: var(--accent); font-weight: 650; text-decoration: none; cursor: pointer; border: 0; background: none;
  padding: 0; font: inherit; text-align: left;
}
a.npc-title-link:hover { text-decoration: underline; }
.board-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  cursor: pointer;
  color: var(--accent, #8a3a2a);
}
.strategy-round { border-top: 1px solid var(--line); padding: .6rem 0; }
.strategy-round.is-latest {
  margin: .35rem 0 .55rem;
  padding: .7rem .75rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  background: #f7f3ec;
}
.strategy-ops { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: .4rem 0 .55rem; }
.gap-ops { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .25rem; }

/* 建议下一步条 */
.next-strip {
  display: flex; flex-wrap: wrap; gap: .65rem 1rem; align-items: center;
  justify-content: space-between;
  margin: 0 0 .85rem; padding: .7rem .85rem;
  border: 1px solid #c9ddd4; border-radius: .55rem;
  background: linear-gradient(180deg, #f2f8f5, #eaf3ef);
}
.next-strip-copy { display: flex; flex-direction: column; gap: .15rem; min-width: 0; flex: 1; }
.next-strip-copy strong { font-size: .95rem; }
.next-strip-ops { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }

/* 顶栏导出收纳 */
.export-more { position: relative; display: inline-flex; }
.export-more > summary {
  list-style: none; cursor: pointer; user-select: none;
}
.export-more > summary::-webkit-details-marker { display: none; }
.export-more-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 40;
  display: flex; flex-direction: column; gap: .25rem; min-width: 7.5rem;
  padding: .4rem; border: 1px solid var(--line); border-radius: .45rem;
  background: #fffcf7; box-shadow: 0 8px 24px rgba(26, 25, 22, .08);
}
.export-more-menu .btn { width: 100%; justify-content: flex-start; }

/* 历史轮折叠 + 轮内更多 */
.strategy-round-fold {
  margin: .25rem 0; border: 1px solid transparent; border-radius: .45rem;
}
.strategy-round-fold > summary {
  display: flex; flex-wrap: wrap; gap: .35rem .75rem; align-items: baseline;
  cursor: pointer; list-style: none; padding: .45rem .55rem;
  border-radius: .45rem; color: var(--ink);
}
.strategy-round-fold > summary::-webkit-details-marker { display: none; }
.strategy-round-fold > summary:hover { background: #f3efe6; }
.strategy-round-fold[open] > summary { border-bottom: 1px dashed var(--line); margin-bottom: .2rem; }
.strategy-round-fold .strategy-round { border-top: 0; padding-top: .35rem; }
.round-more { position: relative; display: inline-flex; }
.round-more > summary {
  list-style: none; cursor: pointer; user-select: none;
}
.round-more > summary::-webkit-details-marker { display: none; }
.round-more-menu {
  position: absolute; left: 0; top: calc(100% + 4px); z-index: 30;
  display: flex; flex-direction: column; gap: .25rem; min-width: 8rem;
  padding: .4rem; border: 1px solid var(--line); border-radius: .45rem;
  background: #fffcf7; box-shadow: 0 8px 24px rgba(26, 25, 22, .08);
}
.round-more-menu .btn { width: 100%; justify-content: flex-start; }

.inspector-inline {
  display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center;
  margin: .15rem 0 .45rem; padding: .45rem .55rem;
  background: #fff; border-radius: .4rem; border: 1px dashed var(--line);
}
.inspector-round-evals { margin-top: .35rem; }
.inspector-panel {
  margin-top: .75rem;
  padding: .75rem .85rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  background: #f7f3ec;
}
.inspector-panel .panel-h { margin-bottom: .35rem; }
.inspector-eval { margin-top: .55rem; padding-top: .55rem; border-top: 1px dashed var(--line); }
#strategy-box ul { margin: .2rem 0 .4rem 1rem; }

/* 待补 · 绑定材料点选 */
.pick-material-list {
  list-style: none; margin: .5rem 0 0; padding: 0;
  max-height: min(50vh, 320px); overflow: auto;
  border: 1px solid var(--line); border-radius: .5rem; background: #fff;
}
.pick-material-item {
  display: flex; flex-direction: column; gap: .15rem;
  padding: .65rem .75rem; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.pick-material-item:last-child { border-bottom: 0; }
.pick-material-item:hover { background: #f3efe6; }
.pick-material-item.on {
  background: var(--accent-soft, #e8f2ee);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.pick-material-item strong { font-size: .92rem; }
.pick-material-item .hint { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .75rem; }
.gap-ops { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .25rem; }
