:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --mark: #fef08a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 18px; height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); font-size: 16px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center; background: var(--accent); color: #fff; border-radius: 8px; font-size: 15px; }
.topsearch { flex: 1; display: flex; max-width: 520px; }
.topsearch input { flex: 1; border: 1px solid var(--line); border-right: 0; border-radius: 8px 0 0 8px; padding: 9px 12px; font-size: 14px; outline: none; }
.topsearch input:focus { border-color: var(--accent); }
.topsearch button { border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 0 16px; border-radius: 0 8px 8px 0; cursor: pointer; font-size: 14px; }
.nav { display: flex; gap: 14px; align-items: center; font-size: 14px; white-space: nowrap; }
.nav a { color: var(--muted); }
.nav a:hover { color: var(--accent); }
.who { color: var(--muted); font-size: 13px; }

main { padding: 26px 0 60px; }
h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 16px; margin: 0 0 14px; }
h3 { font-size: 14px; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.dot { color: var(--line); margin: 0 4px; }

.hero { text-align: center; padding: 26px 0 10px; }
.hero h1 { font-size: 30px; margin-bottom: 8px; }
.bigsearch { display: flex; max-width: 680px; margin: 20px auto 8px; }
.bigsearch input { flex: 1; border: 1px solid var(--line); border-right: 0; border-radius: 10px 0 0 10px; padding: 14px 16px; font-size: 15px; outline: none; box-shadow: var(--shadow); }
.bigsearch input:focus { border-color: var(--accent); }
.bigsearch button { border: 0; background: var(--accent); color: #fff; padding: 0 26px; border-radius: 0 10px 10px 0; font-size: 15px; cursor: pointer; }
.bigsearch button:hover { background: var(--accent-dark); }
.hint { font-size: 13px; }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 26px 0; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 20px; }
.stat span { color: var(--muted); font-size: 12.5px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel h2 { display: flex; align-items: baseline; gap: 8px; }

.folder-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.folder { display: flex; justify-content: space-between; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 13.5px; }
.folder:hover { border-color: var(--accent); text-decoration: none; }
.folder em { color: var(--muted); font-style: normal; }

.filelist { list-style: none; margin: 0; padding: 0; }
.filelist li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.filelist li:last-child { border-bottom: 0; }
.filelist a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ext { display: inline-block; min-width: 44px; text-align: center; font-size: 10.5px; font-weight: 700; color: #475569; background: #eef2f7; border-radius: 4px; padding: 1px 5px; margin-right: 6px; letter-spacing: .3px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tr:hover td { background: #fafbfd; }

.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 7px; padding: 7px 14px; font-size: 13.5px; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.inline-form { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.inline-form input, .inline-form select { border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; font-size: 13.5px; }
.stack { display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.stack input { border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; font-size: 14px; }
.stack input:focus { border-color: var(--accent); outline: none; }

.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv th { text-align: left; color: var(--muted); font-weight: 500; width: 90px; padding: 7px 0; vertical-align: top; }
.kv td { padding: 7px 16px 7px 0; }

.search-head { margin-bottom: 14px; }
.search-head h1 { font-size: 22px; }
.filters { display: flex; gap: 16px; margin: 12px 0 18px; align-items: center; flex-wrap: wrap; }
.filters .search-input { flex: 1; min-width: 240px; border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; font-size: 13.5px; }
.filters .search-input:focus { border-color: var(--accent); outline: none; }
.filters label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.filters select { border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; background: #fff; }
.tag { display: inline-block; background: #eef2ff; color: #4338ca; border-radius: 4px; padding: 1px 6px; margin-right: 4px; font-size: 12px; }

.hits { list-style: none; margin: 0; padding: 0; }
.hits li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.hits li:last-child { border-bottom: 0; }
.hit-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hit-title .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }
.snippet { margin: 8px 0; color: #374151; font-size: 13.5px; line-height: 1.7; }
.hit-actions { display: flex; gap: 8px; }
mark { background: var(--mark); color: inherit; padding: 0 1px; border-radius: 2px; }

.preview { white-space: pre-wrap; word-break: break-word; font: 13px/1.75 "Microsoft YaHei", "Consolas", monospace; background: #fafbfd; border: 1px solid var(--line); border-radius: 8px; padding: 16px; max-height: 70vh; overflow: auto; }
.notice { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 8px; padding: 12px 14px; margin: 14px 0; font-size: 13.5px; }
.error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; border-radius: 8px; padding: 12px 14px; margin: 14px 0; }
.flash { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 13.5px; }

.login-card { max-width: 380px; margin: 60px auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 30px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 22px; }
.login-card .btn { margin-top: 6px; }

.ask-wrap { max-width: 900px; margin: 0 auto; }
.messages { display: flex; flex-direction: column; gap: 14px; margin: 18px 0; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; max-width: 92%; box-shadow: var(--shadow); font-size: 14px; overflow-wrap: anywhere; }
.msg.user .bubble { background: #eef4ff; border-color: #dbeafe; }
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 6px 0; padding-left: 20px; }
.cite { color: var(--accent); font-size: 11px; vertical-align: super; margin-left: 1px; }
.answer-meta { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.citations { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.citations ol { margin: 0; padding-left: 20px; }
.citations li { margin-bottom: 6px; font-size: 13px; }
.filecards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.filecard { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; background: #fcfdff; }
.filecard .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filecard .meta { color: var(--muted); font-size: 11.5px; }
.ask-form { display: flex; gap: 10px; position: sticky; bottom: 16px; background: var(--bg); padding: 10px 0; }
.ask-form textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; font: inherit; font-size: 14px; outline: none; box-shadow: var(--shadow); }
.ask-form textarea:focus { border-color: var(--accent); }
.ask-form .btn { align-self: stretch; padding: 0 24px; }

.footer { border-top: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 12.5px; padding: 16px 0; }
.footer .wrap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.run-line { text-align: center; margin-top: 6px; }

@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .folder-list { grid-template-columns: 1fr; }
  .topbar-inner { gap: 10px; }
  .topsearch { display: none; }
  .filecards { grid-template-columns: 1fr; }
}

/* ==== 知识助手（与 DSH 面板同步） ==== */
.nav { margin-left: auto; }
.ask-head { margin-bottom: 8px; }
.ask-wrap { max-width: 900px; margin: 0 auto; }
.composer { position: sticky; bottom: 12px; background: var(--bg); padding: 10px 0 6px; z-index: 5; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; box-shadow: var(--shadow); }
.composer-row textarea { flex: 1; resize: none; border: 0; outline: none; font: inherit; font-size: 14px; line-height: 1.55; max-height: 150px; min-height: 38px; padding: 8px 4px; background: transparent; }
.attach { width: 38px; height: 38px; flex: 0 0 auto; border: 1px solid var(--line); background: #fff; color: var(--accent); border-radius: 9px; cursor: pointer; font-size: 20px; line-height: 1; }
.attach:hover { border-color: var(--accent); }
.attach:disabled { opacity: .5; cursor: default; }
.composer .send { align-self: stretch; padding: 0 22px; }
.composer-hint { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px 4px 10px; font-size: 12.5px; max-width: 100%; }
.chip-name { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 3px; border-radius: 4px; }
.chip-x:hover { color: #b91c1c; }
.att-meta { margin-top: 6px; color: var(--muted); font-size: 12px; }
.section-title { margin: 14px 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; }
.filecards { grid-template-columns: 1fr 1fr; }
.filecard-actions { display: flex; gap: 6px; margin-top: 6px; }
.cite-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cite-head .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.cite-n { color: var(--accent); font-weight: 700; font-size: 12px; }
.cite-list { list-style: none; margin: 8px 0 0; padding: 0; }
.cite-list li { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.cite-list li:last-child { border-bottom: 0; }
.cite-list .snippet { margin: 6px 0; font-size: 13px; }
.cite-actions { display: flex; gap: 8px; }
.gen-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.gen-card { display: flex; align-items: center; gap: 10px; margin-top: 10px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font-size: 13.5px; flex-wrap: wrap; }
.gen-card b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md h1, .md h2, .md h3, .md h4 { margin: 14px 0 6px; line-height: 1.4; }
.md h1 { font-size: 17px; }
.md h2 { font-size: 16px; }
.md h3 { font-size: 15px; }
.md h4 { font-size: 14px; }
.md p { margin: 6px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md li { margin: 3px 0; }
.md pre { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow: auto; }
.md code { background: #f1f5f9; border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }
.md pre code { border: 0; background: none; padding: 0; }
.md blockquote { margin: 8px 0; padding: 4px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.md sup { color: var(--accent); font-weight: 700; font-size: 10px; }
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px; }
.overlay[hidden] { display: none; }
.modal { background: #fff; border-radius: 12px; max-width: 92vw; max-height: 88vh; width: 720px; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-close { border: 0; background: transparent; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 8px; border-radius: 6px; }
.modal-close:hover { background: #f1f5f9; }
.modal-body { padding: 16px; overflow: auto; }
.modal-body img { display: block; max-width: 100%; margin: 0 auto; border-radius: 6px; }
.modal-body pre { margin: 0; font: 12.5px/1.7 "Microsoft YaHei", Consolas, monospace; white-space: pre-wrap; word-break: break-word; }

/* ==== 首页内嵌知识助手 ==== */
.home-assistant .messages { text-align: left; max-width: 900px; margin: 16px auto 8px; }
.home-assistant .composer { position: static; max-width: 820px; margin: 14px auto 8px; padding: 0; background: transparent; }
.home-assistant .composer-row { text-align: left; }
.home-assistant .hint { margin-top: 10px; }

