/* 知险 · 案件评估 —— 一个主色 + 中性灰；状态色只用于状态 */
:root {
  --primary: #1f3a5f;
  --primary-hover: #2a4b78;
  --primary-soft: #eef2f7;
  --ink: #1d2430;
  --text: #3a4452;
  --muted: #6e7887;
  --faint: #a3abb6;
  --line: #e6e9ee;
  --hover: #f4f6f8;
  --bg: #ffffff;
  --side: #fafbfc;
  /* 状态色 */
  --ok: #1f8a58;
  --warn: #b26b00;
  --err: #c0392b;
  --info: #2f6db3;
  --radius: 8px;
}

/* 案件问答：阅读区、输入区，各司其职。 */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.case-chat { width: 100%; max-width: 840px; margin: 0 auto; display: flex; flex: 1; flex-direction: column; min-height: 0; }
.chat-context-bar { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 14px 0; flex-shrink: 0; color: var(--muted); font-size: 13px; }
.chat-context-bar .link-btn { color: var(--muted); }
.chat-history { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 6px 12px 0; scrollbar-gutter: stable; }
.chat-past { border-bottom: 1px solid var(--line); }
.chat-past > summary { display: flex; gap: 12px; align-items: baseline; padding: 12px 0; cursor: pointer; color: var(--muted); font-size: 14px; list-style: none; }
.chat-past > summary::-webkit-details-marker { display: none; }
.chat-past > summary::before { content: '+'; width: 12px; flex-shrink: 0; color: var(--faint); }
.chat-past[open] > summary::before { content: '−'; }
.chat-past > summary > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-past > summary > small { flex-shrink: 0; font-size: 12px; }
.chat-past[open] > summary > span { white-space: normal; color: var(--ink); }
.chat-past > .chat-response { padding: 0 0 20px 24px; }
.chat-current { padding: 22px 0 12px; }
.chat-question { max-width: 88%; margin: 0 0 22px auto; padding: 12px 16px; border-radius: 8px; background: #f3f5f7; }
.chat-question p { white-space: pre-wrap; font-size: 16px; line-height: 1.7; margin: 0; overflow-wrap: anywhere; }
.case-chat .chat-answer { font-size: 16px; line-height: 1.85; overflow-wrap: anywhere; }
.chat-answer-foot { display: flex; gap: 20px; align-items: center; padding-top: 14px; color: var(--muted); font-size: 13px; }
.chat-answer-foot .link-btn { color: var(--muted); }
.chat-answer-foot time { margin-left: auto; font-size: 12px; }
.chat-stale { color: var(--warn); font-size: 13px; line-height: 1.7; }
.chat-failed { display: flex; gap: 18px; align-items: center; color: var(--muted); font-size: 14px; }
.chat-error-detail { margin-top: 10px; font-size: 13px; color: var(--muted); }
.chat-error-detail summary { cursor: pointer; }
.chat-compose { flex-shrink: 0; margin: 12px 0 0; padding: 12px 16px 10px; border: 1px solid #dce2e9; border-radius: 10px; background: var(--bg); }
.chat-compose:focus-within { border-color: #8194ac; }
.chat-compose textarea { display: block; width: 100%; min-height: 52px; max-height: 160px; resize: none; padding: 2px 0; border: 0; outline: none; background: transparent; font: inherit; font-size: 16px; line-height: 1.6; }
.chat-compose textarea::placeholder { color: var(--faint); }
.chat-compose-actions { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.chat-compose-actions > .btn { height: 32px; min-width: 66px; justify-content: center; }
.chat-options > summary { color: var(--muted); font-size: 13px; cursor: pointer; }
.chat-options .menu-pop { top: auto; bottom: calc(100% + 12px); min-width: 205px; padding: 12px; }
.chat-options .menu-pop .switch { margin: 0; }
.chat-options .menu-pop p { font-size: 12px; color: var(--muted); margin: 9px 0 0; }
.chat-working { padding: 16px 0; color: var(--muted); font-size: 14px; }
.chat-welcome { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 32px 12px; }
.chat-welcome h2 { font-size: 22px; font-weight: 500; }
.chat-suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.chat-suggestions button { padding: 8px 13px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; color: var(--text); font-size: 14px; cursor: pointer; }
.chat-suggestions button:hover { background: var(--hover); }
.chat-proof { padding: 18px 0; }
.chat-proof + .chat-proof { border-top: 1px solid var(--line); }
.chat-proof b { overflow-wrap: anywhere; font-size: 14px; }
.chat-proof .source-quote { font-size: 14px; }

/* 材料梳理沿用材料—评估—报告主结构。 */
.intake-panel { margin: 24px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.intake-heading { padding: 20px 22px 10px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.intake-heading h2 { font-size: 17px; }
.intake-heading p { margin: 4px 0; }
.intake-overview { display: flex; flex-wrap: wrap; gap: 22px; padding: 8px 22px 18px; color: var(--muted); font-size: 13px; }
.intake-overview b { color: var(--ink); font-size: 19px; margin-right: 4px; }
.intake-nav { padding: 0 16px; display: flex; gap: 5px; border-block: 1px solid var(--line); background: var(--side); }
.intake-nav button { border: 0; border-bottom: 2px solid transparent; padding: 11px 9px; background: none; font-size: 13px; color: var(--muted); }
.intake-nav button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.intake-body { padding: 4px 22px 16px; }
.intake-check { padding: 15px 0; border-bottom: 1px solid var(--line); }
.intake-check:last-child { border-bottom: 0; }
.intake-check-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.intake-check-top b { font-weight: 550; overflow-wrap: anywhere; }
.intake-check p { margin: 6px 0; font-size: 13px; }
.intake-status { font-size: 11px; white-space: nowrap; color: var(--muted); }
.intake-status.missing, .intake-status.incomplete { color: var(--warn); }
.intake-status.provided { color: var(--ok); }
.intake-fold { border-top: 1px solid var(--line); margin-top: 10px; }
.intake-fold > summary { padding: 13px 0; cursor: pointer; font-size: 14px; }
.intake-fold summary .count { margin-left: 6px; }
.policy-card:first-child { border-top: 0; }
.policy-card summary .small { margin-left: 12px; font-weight: normal; }
.intake-facts { margin: 0; }
.intake-fact { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 18px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.intake-fact:last-child { border-bottom: 0; }
.intake-fact dt { color: var(--muted); font-size: 13px; }
.intake-fact dt .small { display: block; }
.intake-fact dd { margin: 0; overflow-wrap: anywhere; }
.fact-value + .fact-value { margin-top: 12px; }
.intake-source { display: block; font-size: 12px; margin-top: 4px; overflow-wrap: anywhere; }
.intake-foot { padding: 12px 22px; margin: 0; background: var(--side); border-top: 1px solid var(--line); }
.intake-note { margin: 8px 22px; padding: 10px 12px; background: var(--primary-soft); font-size: 13px; border-radius: 6px; }
.intake-note.warn { background: #fff8eb; color: var(--warn); }
.intake-empty { padding: 22px 0; color: var(--muted); }
.intake-empty p { margin: 7px 0; font-size: 13px; }
.material-group { padding: 14px 0 4px; }
.material-group h3 { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.material-group > p { margin: 8px 0; }
.material-files > summary { font-weight: 600; }
.source-quote { white-space: pre-wrap; overflow-wrap: anywhere; border-left: 3px solid var(--primary); padding: 12px 16px; margin: 16px 0; background: var(--side); }
@media (max-width: 680px) {
  .intake-heading { align-items: flex-start; padding: 16px; }
  .intake-body { padding: 4px 16px 12px; }
  .intake-overview { gap: 12px; padding: 8px 16px 14px; }
  .intake-nav { flex-wrap: wrap; padding: 0 7px; }
  .intake-fact { grid-template-columns: 1fr; gap: 4px; }
  .intake-check-top { flex-wrap: wrap; gap: 4px; }
  .intake-note { margin-inline: 16px; }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: 14px; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 52px; border-bottom: 1px solid var(--line); background: var(--bg);
  display: flex; align-items: center; gap: 20px; padding: 0 20px;
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 6px; background: var(--primary);
  color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.topnav { display: flex; gap: 4px; }
.topnav button {
  height: 32px; padding: 0 12px; border: none; background: none; border-radius: 6px;
  color: var(--muted);
}
.topnav button:hover { color: var(--ink); }
.topnav button.active { color: var(--ink); font-weight: 600; background: var(--hover); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { display: none; border: none; background: none; font-size: 18px; color: var(--muted); padding: 4px; }

.cloud-flag { font-size: 12px; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.cloud-flag:empty { display: none; }
.cloud-flag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.cloud-flag.on::before { background: var(--ok); }
.cloud-flag.off { color: var(--warn); }
.cloud-flag.off::before { background: var(--warn); }

/* ---------- 按钮 ---------- */
.btn {
  height: 34px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { border-color: transparent; background: none; color: var(--text); }
.btn-ghost:hover { background: var(--hover); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 40px; padding: 0 22px; font-size: 15px; }
.link-btn { border: none; background: none; padding: 0; color: var(--primary); font-size: inherit; cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }

/* ---------- 下拉菜单 ---------- */
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu[open] > summary { background: var(--hover); }
.menu-pop {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50; min-width: 168px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(20, 28, 40, .10); padding: 4px;
}
.menu-pop.right { left: auto; right: 0; }
.menu-item {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 7px 10px; border-radius: 6px; font-size: 13px; color: var(--ink); text-decoration: none; white-space: nowrap;
}
.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--err); }
.menu-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; font-size: 13px; color: var(--muted); }
.menu-field select { border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; background: var(--bg); font-size: 13px; }
.menu-note { padding: 6px 10px 4px; font-size: 12px; color: var(--faint); border-top: 1px solid var(--line); margin-top: 4px; }

/* ---------- 布局 ---------- */
.layout { display: grid; grid-template-columns: 272px 1fr; height: calc(100vh - 52px); }
.sidebar { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head { padding: 14px 14px 6px; }
.search {
  width: 100%; height: 34px; border-radius: var(--radius); border: 1px solid var(--line);
  padding: 0 10px; background: var(--bg); outline: none;
}
.search:focus { border-color: var(--primary); }
.filter-row { display: flex; gap: 2px; margin-top: 10px; }
.seg {
  height: 26px; padding: 0 9px; border: none; border-radius: 6px; background: none;
  color: var(--muted); font-size: 13px;
}
.seg:hover { color: var(--ink); }
.seg.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.seg-row { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }

.case-list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }
.case-item { padding: 10px 10px; border-radius: var(--radius); cursor: pointer; }
.case-item:hover { background: var(--hover); }
.case-item.active { background: var(--primary-soft); }
.case-item-top { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.case-name { font-weight: 600; }
.case-meta { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-empty { padding: 32px 12px; text-align: center; color: var(--faint); font-size: 13px; }
.sidebar-foot { padding: 10px 16px; font-size: 12px; color: var(--faint); border-top: 1px solid var(--line); }
.sidebar-foot:empty { display: none; }

/* 状态：圆点 + 文字，颜色只在这里出现 */
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; font-weight: 400; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.st-ready::before, .st-materials::before { background: var(--info); }
.st-evaluating::before { background: var(--warn); }
.st-evaluating { color: var(--warn); }
.st-evaluated::before { background: var(--ok); }
.st-reviewed::before { background: var(--ok); }
.st-reviewed { color: var(--ok); }
.st-error::before { background: var(--err); }
.st-error { color: var(--err); }
.row-sub .status { margin-right: 6px; }

/* ---------- 主区 ---------- */
.main { overflow-y: auto; min-width: 0; }
.main-inner { padding: 28px 40px 80px; max-width: 920px; }
.empty-state { min-height: 60vh; display: grid; place-content: center; text-align: center; color: var(--muted); gap: 12px; }
.empty-state p { margin: 0; }
.empty-state.small-empty { min-height: 30vh; }

.case-header { margin-bottom: 20px; }
.case-header-row { display: flex; align-items: center; gap: 12px; }
.case-title { font-size: 22px; font-weight: 600; }
.ml-auto { margin-left: auto; }
.case-more { margin-top: 4px; }
.case-more > summary { cursor: pointer; color: var(--muted); font-size: 13px; list-style: none; }
.case-more > summary::-webkit-details-marker { display: none; }
.case-more > summary::after { content: "  ▾"; color: var(--faint); }
.case-more[open] > summary::after { content: "  ▴"; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 20px; margin: 12px 0 0; }
.kv-grid div { display: flex; gap: 8px; font-size: 13px; min-width: 0; }
.kv-grid dt { color: var(--muted); flex: none; }
.kv-grid dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-summary { margin: 10px 0 0; font-size: 13px; color: var(--text); white-space: pre-wrap; }

.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.tab {
  padding: 10px 0; border: none; background: none; color: var(--muted); font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--primary); }
.tab-n {
  width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 11px; background: var(--hover); color: var(--muted); font-weight: 600;
}
.tab.active .tab-n { background: var(--primary); color: #fff; }
.tab .count { color: var(--faint); font-size: 12px; font-weight: 400; }

.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 600; }
.section-head { display: flex; align-items: center; margin: 32px 0 12px; }
.section-head h2 { font-size: 15px; font-weight: 600; }

/* ---------- 列表行 ---------- */
.list { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 500; color: var(--ink); display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.row-title:hover { color: var(--primary); text-decoration: none; }
.row-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.err-text { color: var(--err); }
.next { margin-top: 28px; }

/* ---------- 上传 ---------- */
.dropzone {
  border: 1px dashed #cdd3db; border-radius: var(--radius); padding: 36px 20px;
  text-align: center; color: var(--muted); cursor: pointer; transition: background .12s, border-color .12s;
}
.dropzone:hover { border-color: var(--primary); }
.dropzone.drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone b { color: var(--primary); font-weight: 600; }
.dropzone .sub { font-size: 12px; margin-top: 6px; color: var(--faint); }
.dropzone.compact { padding: 14px 16px; }
.dropzone.compact .sub { display: none; }
#uploadProgress:not(:empty), #kbUploadProg:not(:empty) { margin-top: 10px; }

/* ---------- 表单 ---------- */
.eval-form { display: grid; gap: 18px; max-width: 640px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.eval-form .field { margin-bottom: 0; }
.field > label { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.field input[type=text], .field input[type=password], .field input[type=number], .field select, .field textarea,
.review-row input, .search-row input {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px;
  background: var(--bg); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus, .review-row input:focus, .search-row input:focus { border-color: var(--primary); }
.field textarea { resize: vertical; line-height: 1.6; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.hint { font-size: 12px; color: var(--faint); margin: 0; }
p.hint { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); padding: 3px 0; }
.switch .muted.small { margin-left: 4px; }
.switch input { width: 15px; height: 15px; accent-color: var(--primary); flex: none; }

/* 折叠区 */
details.fold { margin: 4px 0 14px; }
details.fold > summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 0; list-style: none; user-select: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; display: inline-block; width: 14px; color: var(--faint); }
details.fold[open] > summary::before { content: "▾"; }
details.fold > summary:hover { color: var(--ink); }
details.fold[open] > summary { margin-bottom: 10px; }
.eval-form details.fold { margin: 0; }
.fold-body { display: grid; gap: 16px; padding: 4px 0 4px 14px; border-left: 2px solid var(--line); }
.fold-title { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.run-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* 执行过程 */
.stream { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); }
.stream-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; margin-bottom: 8px; }
.stream-box { margin-top: 12px; max-height: 460px; overflow-y: auto; padding: 4px 0; }
.stage-line { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; padding: 2px 0; }
.spinner {
  width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-bar { height: 2px; background: var(--line); overflow: hidden; margin-top: 8px; }
.progress-bar > i { display: block; height: 100%; width: 30%; background: var(--primary); animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
details.retrieval { font-size: 13px; }

/* ---------- 报告 ---------- */
.report-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  position: sticky; top: -28px; background: var(--bg); padding: 8px 0 12px; z-index: 5;
  border-bottom: 1px solid var(--line); margin-bottom: 8px;
}
.select-plain { border: 1px solid var(--line); border-radius: var(--radius); padding: 5px 8px; background: var(--bg); font-weight: 600; }
.report-edit {
  width: 100%; min-height: 60vh; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  font-family: ui-monospace, Menlo, monospace; font-size: 13px; line-height: 1.7; outline: none; margin-top: 12px;
}
.report-edit:focus { border-color: var(--primary); }
details.cites { margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--line); }
.review-row { display: flex; align-items: center; gap: 10px; margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.review-row input { width: 120px; height: 34px; padding: 0 10px; }
.review-row input.grow { flex: 1; min-width: 200px; }
.review-label { font-size: 13px; color: var(--muted); }
.review-done { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ok); }

/* ---------- Markdown ---------- */
.md { font-size: 14.5px; line-height: 1.8; color: var(--ink); word-break: break-word; }
.md h1, .md h2, .md h3, .md h4 { color: var(--ink); line-height: 1.4; margin: 1.5em 0 .6em; font-weight: 600; }
.md h1 { font-size: 20px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15px; } .md h4 { font-size: 14px; }
.md > :first-child { margin-top: .6em; }
.md p { margin: .6em 0; }
.md ul, .md ol { padding-left: 22px; margin: .5em 0; }
.md li { margin: .2em 0; }
.md table { border-collapse: collapse; width: 100%; margin: .9em 0; font-size: 13px; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: top; }
.md th { font-weight: 600; color: var(--muted); white-space: nowrap; border-bottom-color: #d5dae1; }
.md blockquote { margin: .9em 0; padding: 2px 14px; border-left: 3px solid var(--line); color: var(--text); }
.md code { background: var(--hover); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 1.6em 0; }

/* ---------- 知识库 ---------- */
body.kb-mode .sidebar { display: none; }
body.kb-mode .layout { grid-template-columns: 1fr; }
body.kb-mode .main-inner { margin: 0 auto; }
.search-row { display: flex; gap: 8px; }
.search-row input { height: 40px; font-size: 15px; }
.search-row .btn { height: 40px; }
.hits { margin-top: 14px; }
.hit { padding: 12px 0; border-bottom: 1px solid var(--line); }
.hit-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hit-body { color: var(--text); font-size: 13px; margin-top: 4px; line-height: 1.7; }
details.fold .form-row { margin-top: 4px; }

.cite-list { display: grid; gap: 6px; margin-top: 8px; }
.cite-item { display: flex; gap: 8px; font-size: 13px; align-items: baseline; }
.cite-id { flex: none; font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--muted); background: var(--hover); padding: 0 6px; border-radius: 4px; }
.cite-item a { word-break: break-all; }

.cloud-state { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--err); }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(20, 28, 40, .32); z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal {
  background: var(--bg); border-radius: 12px; width: 100%; max-width: 480px; max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(20, 28, 40, .18);
}
.modal.wide { max-width: 680px; }
.modal-head { padding: 18px 22px 6px; display: flex; align-items: center; font-weight: 600; font-size: 16px; }
.modal-head > button { margin-left: auto; }
.modal-body { padding: 12px 22px 8px; overflow-y: auto; }
.modal-foot { padding: 12px 22px 18px; display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.st-h { font-size: 13px; font-weight: 600; margin: 22px 0 10px; display: flex; gap: 8px; align-items: baseline; }
.st-sec .flex { margin-top: 6px; }

/* ---------- 杂项 ---------- */
.toast-wrap { position: fixed; top: 64px; right: 20px; z-index: 200; display: grid; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--radius); font-size: 13px; max-width: 380px; box-shadow: 0 6px 20px rgba(20, 28, 40, .18); animation: slidein .18s ease-out; }
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }
@keyframes slidein { from { opacity: 0; transform: translateX(12px); } }

.alert { border-radius: var(--radius); padding: 10px 14px; font-size: 13px; margin-bottom: 16px; border-left: 3px solid; }
.alert-warn { background: #fdf7ec; border-color: var(--warn); color: #6e4600; }
.alert-err { background: #fdf0ee; border-color: var(--err); color: var(--err); }
.alert-info { background: var(--primary-soft); border-color: var(--info); color: var(--text); }
.alert-ok { background: #edf7f1; border-color: var(--ok); color: var(--ok); }
.alert .link-btn { margin-left: 8px; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.flex { display: flex; gap: 8px; align-items: center; }
.flex.wrap { flex-wrap: wrap; margin-top: 10px; }
.grow { flex: 1; min-width: 0; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }

.text-view {
  white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Menlo, monospace;
  font-size: 12.5px; line-height: 1.7; background: var(--side); border-radius: var(--radius);
  padding: 14px; max-height: 64vh; overflow: auto;
}

@media (max-width: 900px) {
  .icon-btn { display: block; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.open { display: flex; position: fixed; inset: 52px 0 0 0; z-index: 20; }
  .main-inner { padding: 20px 18px 60px; }
  .form-row { grid-template-columns: 1fr; }
  .brand { display: none; }
}
.fold-body .link-btn { margin-left: 8px; }

/* 精简公共框架，问答只在阅读区滚动，输入始终可见。 */
.layout { grid-template-columns: 240px minmax(0, 1fr); height: calc(100dvh - 52px); }
.filter-row .seg { flex-shrink: 0; white-space: nowrap; padding: 0 6px; }
.filter-row { flex-wrap: wrap; }
.main-inner { max-width: 1080px; margin: 0 auto; padding: 24px 36px 60px; }
.case-header { margin-bottom: 14px; }
.case-title { font-size: 20px; }
.tabs { gap: 28px; margin-bottom: 20px; }
.tab { padding: 10px 2px; }
.icon-btn { display: block; }
body.sidebar-collapsed .layout { grid-template-columns: minmax(0, 1fr); }
body.sidebar-collapsed .sidebar { display: none; }
body.kb-mode .layout { grid-template-columns: minmax(0, 1fr); }
body.kb-mode #btnToggleSide { display: none; }
body.chat-mode .main { overflow: hidden; }
body.chat-mode .main-inner { height: 100%; min-height: 0; display: flex; flex-direction: column; padding-bottom: 20px; }
body.chat-mode .case-header, body.chat-mode .tabs { flex-shrink: 0; }
body.chat-mode .case-more[open] { max-height: 24vh; overflow: auto; }
body.chat-mode .tabs { margin-bottom: 0; }
body.chat-mode #tabBody { display: flex; flex-direction: column; min-height: 0; flex: 1; }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .main-inner { padding: 18px 20px 48px; }
  body.chat-mode .main-inner { padding-bottom: 14px; }
  body.sidebar-collapsed .sidebar.open { display: flex; }
}
@media (max-width: 540px) {
  .topbar { gap: 12px; padding: 0 14px; }
  .topbar-actions { gap: 0; }
  .main-inner { padding: 14px 16px 36px; }
  .case-title { font-size: 18px; }
  .case-header { margin-bottom: 8px; }
  .tabs { justify-content: space-between; gap: 12px; }
  .tab { font-size: 14px; }
  .chat-context-bar { padding: 11px 0; font-size: 12px; }
  .chat-question { max-width: 94%; padding: 10px 12px; }
  .chat-current { padding-top: 16px; }
  .chat-past > .chat-response { padding-left: 0; }
  .chat-compose { padding: 10px 12px; }
  .chat-welcome h2 { font-size: 20px; }
  .chat-suggestions { gap: 8px; }
  .chat-suggestions button { padding: 7px 10px; }
}
/* Team sign-in and account controls */
[hidden]{display:none!important}.team-gate{position:fixed;inset:0;z-index:5000;background:#f6f7f9;display:grid;place-items:center;padding:24px;overflow:auto}.team-login{width:min(100%,380px);padding:36px;background:white;border:1px solid #e6e9ee;border-radius:16px;box-shadow:0 12px 50px #16314b0a}.team-login h1{font-size:24px;margin-top:32px}.team-login label{display:block;margin-top:20px;font-size:14px}.team-login input{width:100%;margin-top:8px;height:44px;border:1px solid #d8dee7;border-radius:6px;padding:10px;box-sizing:border-box}.team-login .btn{width:100%;margin-top:16px;height:44px}.team-error{color:#aa352e;font-size:13px;min-height:20px;margin-top:12px}.team-user{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 0;border-bottom:1px solid #edf0f4}.team-user input[type=checkbox]{width:18px;height:18px}.team-users{margin-bottom:20px}
