/* RAG 知识库页专用样式 */

/* ---------- Hero ---------- */
.page-hero h1 .text-grad { display: inline-block; }
.rh-actions { justify-content: flex-start; }
.rh-note { margin-top: var(--sp-5); }
.rh-mock .mock-body { display: grid; gap: var(--sp-4); }
.rh-q {
  justify-self: end; max-width: 85%;
  padding: 10px 14px; border-radius: 14px 14px 4px 14px;
  background: var(--primary); color: var(--on-primary); font-size: 14px; line-height: 1.6;
}
.rh-a { display: flex; gap: 10px; align-items: flex-start; }
.rh-a-ico {
  flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--grad-brand); color: #06281c;
}
.rh-a-ico svg { width: 16px; height: 16px; }
.rh-a > div { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 4px 14px 14px 14px; background: var(--surface-2); border: 1px solid var(--border); }
.rh-a p { margin: 0; font-size: 14px; line-height: 1.75; color: var(--text); }
.rh-a sup, .ht-answer-body sup { font-weight: 700; color: var(--primary); }
.rh-src { display: grid; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border-strong); }
.rh-src-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); min-width: 0; }
.rh-src-item b { color: var(--primary); }
.rh-src-item em { margin-left: auto; font-style: normal; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rh-foot { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }

/* ---------- 流程 ---------- */
.rag-stage + .rag-stage { margin-top: var(--sp-8); }
.rs-label { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: var(--sp-4); font-size: 13px; }
.rag-stage .flow-item { max-width: 190px; }

/* ---------- 数据源 ---------- */
.source-card { display: flex; flex-direction: column; }
.sc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.sc-top .badge { flex: none; }

/* ---------- 切片策略 ---------- */
.chunk-tabs { margin-top: var(--sp-6); }
.chunk-tabs .tab-panel { padding-top: var(--sp-5); }
.chunk-tabs .tab-panel > p { color: var(--text-2); }
.chunk-mock .mock-body { display: grid; gap: var(--sp-4); }
.cm-row { display: grid; gap: 8px; }
.cm-label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--text-2); }
.cm-label b { font-family: var(--font-mono); font-size: 12.5px; color: var(--primary); font-weight: 600; }
.cm-select {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 14px; color: var(--text);
}
.cm-select svg { width: 16px; height: 16px; color: var(--text-3); }
.cm-slider { position: relative; display: block; height: 6px; border-radius: 3px; background: var(--bg-muted); margin: 6px 0 0; }
.cm-slider i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--grad-brand); }
.cm-slider em { position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); box-shadow: var(--shadow-sm); }
.cm-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); font-family: var(--font-mono); }
.cm-seps { display: flex; flex-wrap: wrap; gap: 6px; }
.cm-seps code { padding: 3px 8px; border: 1px solid var(--border); font-size: 12px; }
.cm-toggles { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.cm-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.cm-toggle::before {
  content: ""; width: 30px; height: 18px; border-radius: 9px; background: var(--border-strong); flex: none;
  background-image: radial-gradient(circle at 9px 9px, #fff 6px, transparent 6.5px);
}
.cm-toggle.on::before { background-color: var(--primary); background-image: radial-gradient(circle at 21px 9px, #fff 6px, transparent 6.5px); }
.cm-preview { padding: var(--sp-3); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); display: grid; gap: 8px; }
.cm-preview-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.cm-chunk { position: relative; padding: 8px 10px 8px 46px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; line-height: 1.65; color: var(--text-2); }
.cm-no { position: absolute; left: 10px; top: 9px; font-family: var(--font-mono); font-size: 11.5px; color: var(--primary); font-weight: 700; }
.cm-chunk mark, .cm-legend mark { background: rgba(20,184,176,.18); color: inherit; border-radius: 3px; padding: 0 2px; }
.cm-legend { margin: 0; font-size: 12px; color: var(--text-3); }

/* ---------- 向量库 ---------- */
.vdb-grid { list-style: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--sp-4); }
.vdb-grid .vendor-card { align-items: flex-start; }
.vdb-grid .vendor-card > div { min-width: 0; }
.vdb-grid .badge { margin-top: 8px; }
.vdb-builtin { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(52, 211, 153,.08); }
.retrieval-head { margin-top: var(--sp-20); }
.boost-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--sp-4); }
@media (max-width: 1024px) { .vdb-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .retrieval-head { margin-top: var(--sp-16); } }
@media (max-width: 768px) { .vdb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .vdb-grid { grid-template-columns: 1fr; } }

/* ---------- 命中测试 ---------- */
.ht-mock .mock-bar { flex-wrap: nowrap; }
.ht-demo-badge { margin-left: auto; flex: none; }
.ht-body { display: grid; grid-template-columns: 320px minmax(0, 1fr); }
.ht-side { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-5); border-right: 1px solid var(--border); background: var(--surface-2); }
.ht-label { font-size: 13px; font-weight: 600; color: var(--text); }
.ht-side .ht-label + .chips { margin-top: -2px; }
.ht-side .ht-label:not(:first-child) { margin-top: var(--sp-3); }
.ht-input { min-height: 88px; font-size: 14px; }
.ht-presets { gap: 6px; }
.ht-presets .chip { padding: 5px 11px; font-size: 13px; }
.ht-params { display: grid; gap: 8px; margin-top: var(--sp-3); padding-top: var(--sp-4); border-top: 1px solid var(--border); font-size: 13px; }
.ht-params > div { display: flex; justify-content: space-between; color: var(--text-3); }
.ht-params b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.ht-switch { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--text); font-weight: 600; cursor: pointer; flex-direction: row-reverse; }
.ht-switch input { position: absolute; opacity: 0; width: 34px; height: 20px; right: 0; margin: 0; cursor: pointer; }
.ht-switch-ui { position: relative; flex: none; width: 34px; height: 20px; border-radius: 10px; background: var(--border-strong); transition: background .2s; }
.ht-switch-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s var(--ease); }
.ht-switch input:checked + .ht-switch-ui { background: var(--primary); }
.ht-switch input:checked + .ht-switch-ui::after { transform: translateX(14px); }
.ht-switch input:focus-visible + .ht-switch-ui { box-shadow: var(--ring); }

.ht-main { padding: var(--sp-5); min-width: 0; display: flex; flex-direction: column; gap: var(--sp-4); }
.ht-result-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 15px; }
.ht-meta { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ht-results { display: grid; gap: 10px; min-height: 120px; align-content: start; }
.ht-results[aria-busy="true"] { opacity: .55; }
.ht-empty { margin: 0; padding: var(--sp-6); text-align: center; font-size: 14px; color: var(--text-3); border: 1px dashed var(--border-strong); border-radius: var(--r-md); }
.ht-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: var(--sp-6); font-size: 14px; color: var(--text-3); }
.ht-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--primary); animation: ht-spin .8s linear infinite; }
@keyframes ht-spin { to { transform: rotate(360deg); } }

.ht-chunk {
  padding: 12px 14px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border);
  transition: border-color .25s, box-shadow .25s, background .25s;
}
.ht-chunk.is-cited { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(52, 211, 153,.16); }
.ht-chunk.is-dim { opacity: .62; }
.ht-chunk:focus { outline: none; }
.ht-chunk:focus-visible { box-shadow: var(--ring); }
.ht-c-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.ht-rank { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 6px; border-radius: 6px; background: var(--primary-soft); color: var(--primary-soft-text); font-size: 12px; font-weight: 700; }
.ht-src { font-size: 13px; font-weight: 600; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.ht-src small { font-weight: 400; color: var(--text-3); margin-left: 4px; }
.ht-scores { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ht-score { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ht-score b { color: var(--text); font-weight: 700; }
.ht-score .bar { width: 56px; height: 5px; border-radius: 3px; background: var(--bg-muted); overflow: hidden; }
.ht-score .bar i { display: block; height: 100%; background: var(--grad-brand); border-radius: 3px; }
.ht-score.muted-score .bar i { background: var(--border-strong); }
.ht-text { margin: 0; font-size: 13.5px; line-height: 1.7; color: var(--text-2); }
.ht-text mark { background: rgba(250,204,21,.32); color: inherit; border-radius: 3px; padding: 0 1px; }
.ht-below { font-size: 12px; color: var(--text-3); padding: 0 2px; }

.ht-answer { border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); padding: 14px 16px; }
.ht-answer-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; font-size: 15px; }
.ht-answer-head .rh-a-ico { width: 26px; height: 26px; border-radius: 8px; }
.ht-answer-head .muted { font-size: 12px; margin-left: auto; }
.ht-answer-body { font-size: 14.5px; line-height: 1.8; color: var(--text); min-height: 1.8em; }
.ht-answer-body p { margin: 0; color: var(--text); }
.ht-answer-body .ht-note { margin-top: 6px; font-size: 12px; color: var(--text-3); }
.ht-cite {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: super;
  min-width: 22px; height: 18px; padding: 0 4px; margin: 0; border-radius: 5px; border: 0;
  background: var(--primary-soft); color: var(--primary-soft-text); font-size: 11px; font-weight: 700; line-height: 1;
}
.ht-cite:hover, .ht-cite[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

@media (max-width: 1024px) { .ht-body { grid-template-columns: 280px minmax(0, 1fr); } }
@media (max-width: 860px) {
  .ht-body { grid-template-columns: 1fr; }
  .ht-side { border-right: 0; border-bottom: 1px solid var(--border); }
}
@media (max-width: 480px) {
  .ht-side, .ht-main { padding: var(--sp-4); }
  .ht-scores { margin-left: 0; width: 100%; }
  .ht-answer-head .muted { margin-left: 0; width: 100%; }
  .ht-mock .mock-title { display: none; }
}

/* ---------- 权限 ---------- */
.perm-link { margin-top: var(--sp-6); }
.perm-mock .mock-body { display: grid; gap: var(--sp-4); }
.pm-user { display: flex; align-items: center; gap: 12px; }
.pm-user > div { flex: 1; min-width: 0; line-height: 1.4; }
.pm-user b { display: block; font-size: 15px; color: var(--text); }
.pm-user small { font-size: 12.5px; color: var(--text-3); }
.pm-avatar { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--grad-brand); color: #06281c; font-weight: 700; }
.pm-q { padding: 10px 14px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; color: var(--text); }
.pm-docs { list-style: none; display: grid; gap: 8px; }
.pm-docs li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); }
.pm-docs li.deny { background: var(--surface-2); border-style: dashed; }
.pm-docs li.deny .pm-name { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.pm-ico { flex: none; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; }
.pm-ico svg { width: 15px; height: 15px; }
.pm-docs .ok .pm-ico { background: rgba(22,163,74,.12); color: var(--success); }
.pm-docs .deny .pm-ico { background: var(--bg-muted); color: var(--text-3); }
.pm-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.4; overflow-wrap: anywhere; }
.pm-name small { display: block; font-size: 12px; font-weight: 400; color: var(--text-3); text-decoration: none; }
.pm-docs .badge { flex: none; }
.pm-foot { margin: 0; font-size: 13px; color: var(--text-2); padding: 10px 12px; border-radius: var(--r-md); background: var(--primary-soft); }

/* ---------- 文档列表 ---------- */
.doc-mock .mock-body { display: grid; gap: var(--sp-3); }
.dl-toolbar { display: flex; gap: 10px; align-items: center; }
.dl-search { flex: 1; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); font-size: 13px; color: var(--text-3); }
.dl-search svg { width: 15px; height: 15px; }
.dl-upload { pointer-events: none; }
.dl-table-wrap { border-radius: var(--r-md); }
.dl-table { min-width: 500px; font-size: 13.5px; }
.dl-table th, .dl-table td { padding: 10px; white-space: nowrap; }
.dl-table th:first-child { padding-left: 12px; }
:lang(en) .dl-table { font-size: 13px; }
@media (min-width: 1025px) { :lang(en) .dl-table tbody th { white-space: normal; } }
:lang(en) .dl-table th, :lang(en) .dl-table td { padding: 10px 7px; }
:lang(en) .dl-table th:first-child { padding-left: 12px; }
.dl-table tbody th { font-weight: 600; color: var(--text); }
.dl-file { display: inline-grid; place-items: center; width: 32px; height: 20px; margin-right: 8px; border-radius: 4px; font-size: 9.5px; font-weight: 800; color: #fff; letter-spacing: .02em; vertical-align: 1px; }
.dl-file.pdf { background: #e03131; }
.dl-file.doc { background: #1c7ed6; }
.dl-file.xls { background: #2f9e44; }
.dl-file.web { background: #0e958f; }
.dl-file.md { background: #495057; }
.st-running { background: rgba(2,132,199,.12); color: var(--info); }
.st-running .dot { animation: st-blink 1.2s ease-in-out infinite; }
@keyframes st-blink { 50% { opacity: .25; } }
.st-fail { background: rgba(220,38,38,.12); color: var(--danger); }
.dl-err { margin: 0; padding: 10px 12px; border-radius: var(--r-md); font-size: 13px; color: var(--text-2); background: rgba(220,38,38,.06); border: 1px solid rgba(220,38,38,.22); }
.dl-err b { color: var(--danger); }
.dl-note { margin: 0; font-size: 12px; color: var(--text-3); text-align: right; }


@media (max-width: 480px) {
  .rh-src-item em { display: none; }
  .rh-q { max-width: 100%; }
}
