:root {
  --bg: #f7f8fa; --panel: #fff; --text: #1f2329; --muted: #646a73; --line: #dee0e3;
  --accent: #1664ff; --accent-weak: #e8f0ff; --mark: #fff3b0; --err: #d83931;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16181c; --panel: #1f2227; --text: #e6e8eb; --muted: #9aa0a8; --line: #33373e;
    --accent: #4c8dff; --accent-weak: #1d2a44; --mark: #5a4a00; --err: #ff6b63; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.6 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-size: 17px; font-weight: 600; }
.brand .sub { margin-left: 10px; font-size: 12px; font-weight: 400; color: var(--muted); }
.tabs button { border: 0; background: none; color: var(--muted); font-size: 14px; padding: 6px 12px; cursor: pointer; border-radius: 6px; }
.tabs button.on { color: var(--accent); background: var(--accent-weak); font-weight: 600; }
.products { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 16px 0; }
.products label { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--panel); cursor: pointer; font-size: 12px; color: var(--muted); }
.products input { margin: 0; }
.products label.on { border-color: var(--accent); color: var(--accent); }
main { flex: 1; min-height: 0; min-width: 0; display: flex; }
.pane { display: none; flex: 1; min-height: 0; min-width: 0; flex-direction: column; padding: 10px 16px 12px; }
.pane.on { display: flex; }
.qbar { display: flex; gap: 8px; }
.qbar input, .qbar textarea { flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--text); font: inherit; resize: none; }
.qbar input:focus, .qbar textarea:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
button { font: inherit; }
.qbar button { padding: 0 18px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; }
.qbar button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.qbar button:disabled { opacity: .5; cursor: default; }
.split { flex: 1; min-height: 0; display: flex; gap: 12px; margin-top: 10px; }
.results { flex: 1; min-width: 0; overflow: auto; }
.reader { flex: 1.3; min-width: 0; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 18px; }
.hidden { display: none !important; }
.hint { color: var(--muted); }
.hit { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.hit:hover, .hit.on { border-color: var(--accent); }
.hit .t { font-weight: 600; }
.hit .p { color: var(--muted); font-size: 12px; word-break: break-all; }
.hit .s { margin-top: 4px; white-space: pre-wrap; word-break: break-word; font-size: 13px; max-height: 7.5em; overflow: hidden; }
.badge { display: inline-block; font-size: 11px; padding: 0 6px; margin-right: 6px; border-radius: 4px; background: var(--accent-weak); color: var(--accent); }
mark { background: var(--mark); color: inherit; padding: 0 1px; }
.reader table, .msg table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.reader th, .reader td, .msg th, .msg td { border: 1px solid var(--line); padding: 3px 8px; }
.reader h1 { font-size: 20px; } .reader h2 { font-size: 17px; } .reader h3 { font-size: 15px; }
.reader pre, .msg pre { overflow: auto; padding: 10px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); }
.reader code, .msg code { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: 12.5px; }
.reader .bar { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 8px; word-break: break-all; }
.reader .bar button { border: 0; background: none; color: var(--accent); cursor: pointer; }
.chat { flex: 1; min-height: 0; overflow: auto; padding: 4px 2px 10px; }
.msg { max-width: 920px; margin: 0 auto 10px; padding: 10px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); word-break: break-word; }
.msg.user { background: var(--accent-weak); border-color: transparent; white-space: pre-wrap; }
.msg.sys { color: var(--muted); background: transparent; border-style: dashed; }
.msg.err { color: var(--err); }
.msg .tools { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.msg .tools div::before { content: "🔎 "; }
.msg a.doc { color: var(--accent); cursor: pointer; text-decoration: underline dotted; }
.foot { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; }
.cursor::after { content: "▍"; animation: blink 1s steps(1) infinite; color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }
@media (max-width: 760px) {
  .split { flex-direction: column; }
  .reader { flex: none; max-height: 60vh; }
}
