/* ============================================================
   Demo 页面共享外壳
   与 site.css 共用色板
   ============================================================ */

.demo-page { background: #070a10; }
.demo-topbar {
  position: sticky; top: 0; z-index: 40;
  height: 62px;
  display: flex; align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 10, 16, 0.86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.demo-topbar .container { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.demo-back { display: inline-flex; align-items: center; gap: 9px; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); letter-spacing: .04em; transition: color .2s; }
.demo-back:hover { color: var(--accent); }
.demo-back svg { width: 14px; height: 14px; }
.demo-brandline { display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 11px; color: var(--dim); letter-spacing: .1em; }
.demo-live { display: inline-flex; align-items: center; gap: 7px; color: var(--mint); }
.demo-live i { width: 5px; height: 5px; border-radius: 50%; background: var(--mint); }

.demo-main { padding: 38px 0 72px; }
.demo-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; padding-bottom: 26px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.demo-intro h1 { margin: 10px 0 0; font-size: clamp(28px, 3.4vw, 42px); letter-spacing: -.03em; line-height: 1.15; font-weight: 700; }
.demo-intro h1 span { display: block; font-family: var(--font-mono); font-size: 11px; color: var(--accent); letter-spacing: .18em; font-weight: 400; margin-bottom: 8px; }
.demo-intro p { max-width: 590px; margin: 10px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.85; }
.demo-intro-meta { flex: none; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.demo-pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-family: var(--font-mono); font-size: 10px; color: var(--text-2); letter-spacing: .05em; white-space: nowrap; }
.demo-pill.warn { border-color: rgba(240, 200, 121, .3); color: var(--warm); background: rgba(240, 200, 121, .05); }

.workspace { display: grid; grid-template-columns: minmax(0, 1.32fr) minmax(0, .88fr); gap: 18px; align-items: start; }
.workspace.two { grid-template-columns: 1fr 1fr; }
.workspace.right-wide { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(15, 22, 34, .78), rgba(9, 14, 22, .72));
  overflow: hidden;
  min-width: 0;
}
.panel-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 44px; padding: 0 16px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 10.5px; color: var(--dim); letter-spacing: .07em;
  background: rgba(255, 255, 255, .018);
}
.panel-hd .dots { display: flex; gap: 5px; margin-right: 6px; }
.panel-hd .dots i { width: 6px; height: 6px; border-radius: 50%; background: #273142; }
.panel-hd .dots i:first-child { background: rgba(255, 128, 128, .55); }
.panel-hd .dots i:nth-child(2) { background: rgba(240, 200, 121, .5); }
.panel-hd .dots i:nth-child(3) { background: rgba(114, 227, 191, .5); }
.panel-hd .hd-left { display: flex; align-items: center; }
.panel-hd b { color: var(--text-2); font-weight: 400; }
.panel-bd { padding: 18px; }

.chat-log { height: 430px; overflow-y: auto; padding: 18px 18px 8px; scroll-behavior: smooth; }
.chat-log::-webkit-scrollbar, .scroll-area::-webkit-scrollbar { width: 8px; }
.chat-log::-webkit-scrollbar-thumb, .scroll-area::-webkit-scrollbar-thumb { background: rgba(148,163,184,.16); border-radius: 4px; }
.msg { display: flex; gap: 10px; margin-bottom: 18px; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }
.msg-avatar { width: 26px; height: 26px; border-radius: 7px; flex: none; display: grid; place-items: center; font-family: var(--font-mono); font-size: 10px; border: 1px solid var(--line); color: var(--muted); background: rgba(255,255,255,.02); }
.msg.ai .msg-avatar { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }
.bubble { max-width: 82%; padding: 11px 14px; border-radius: 10px; font-size: 13px; line-height: 1.8; border: 1px solid var(--line); background: rgba(255,255,255,.022); color: var(--text-2); }
.msg.user .bubble { background: rgba(90, 169, 255, .1); border-color: rgba(90, 169, 255, .24); color: var(--text); }
.msg.ai .bubble { border-color: rgba(90,169,255,.16); }
.msg.ai .bubble .cite { display: inline-flex; vertical-align: 1px; margin-left: 2px; padding: 0 4px; border-radius: 3px; background: rgba(90,169,255,.12); color: var(--accent); font-family: var(--font-mono); font-size: 9.5px; }
.bubble .answer-flag { display: block; margin-bottom: 7px; font-family: var(--font-mono); font-size: 9.5px; color: var(--dim); letter-spacing: .06em; }
.msg-time { font-family: var(--font-mono); font-size: 9px; color: var(--dim); margin-top: 5px; }
.cursor { display: inline-block; width: 5px; height: 11px; background: var(--accent); vertical-align: -1px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.composer { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; gap: 9px; align-items: flex-end; background: rgba(0,0,0,.12); }
.composer textarea {
  flex: 1; resize: none; min-height: 42px; max-height: 100px;
  background: rgba(255,255,255,.025); border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; color: var(--text); font-family: var(--font-sans); font-size: 13px; line-height: 1.55;
  outline: none; transition: border-color .2s;
}
.composer textarea:focus { border-color: var(--accent-line); }
.composer textarea::placeholder { color: var(--dim); }
.send-btn { width: 42px; height: 42px; border-radius: 9px; border: 0; background: var(--accent); color: #05101f; display: grid; place-items: center; flex: none; transition: background .2s, transform .2s; }
.send-btn:hover { background: #78bcff; transform: translateY(-1px); }
.send-btn:disabled { opacity: .45; cursor: default; transform: none; }
.send-btn svg { width: 17px; height: 17px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 14px 12px; }
.chip { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px; padding: 5px 11px; font-size: 11.5px; transition: border-color .2s, color .2s, background .2s; }
.chip:hover { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }

.trace-list { padding: 8px 14px 16px; max-height: 520px; overflow-y: auto; }
.stage { padding: 10px 0; border-bottom: 1px dashed rgba(148,163,184,.1); }
.stage:last-child { border-bottom: 0; }
.stage-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stage-name { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-2); }
.stage-no { font-family: var(--font-mono); font-size: 9px; color: var(--dim); }
.stage-ms { font-family: var(--font-mono); font-size: 9.5px; color: var(--dim); }
.stage-status { font-family: var(--font-mono); font-size: 9px; color: var(--dim); }
.stage-status.ok { color: var(--mint); }
.stage-status.run { color: var(--warm); }
.stage-body { margin-top: 7px; font-family: var(--font-mono); font-size: 10.5px; line-height: 1.7; color: var(--muted); word-break: break-word; }
.stage-body em { color: var(--accent); font-style: normal; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.bar-label { width: 44px; flex: none; font-family: var(--font-mono); font-size: 9px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 4px; border-radius: 2px; background: rgba(148,163,184,.1); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, rgba(90,169,255,.45), var(--accent)); width: 0; transition: width .55s ease; }
.bar-fill.mint { background: linear-gradient(90deg, rgba(114,227,191,.35), var(--mint)); }
.bar-num { width: 32px; text-align: right; font-family: var(--font-mono); font-size: 9px; color: var(--dim); flex: none; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed rgba(148,163,184,.1); font-family: var(--font-mono); font-size: 10.5px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--dim); }
.kv b { color: var(--text-2); font-weight: 400; text-align: right; }
.kv b.accent { color: var(--accent); }
.kv b.mint { color: var(--mint); }

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.tool-item { border: 1px solid var(--line); border-radius: 7px; padding: 8px 9px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-family: var(--font-mono); font-size: 10px; color: var(--dim); transition: border-color .2s, color .2s, background .2s; }
.tool-item.on { border-color: rgba(90,169,255,.34); color: var(--accent); background: rgba(90,169,255,.07); }
.tool-item .dot { width: 5px; height: 5px; border-radius: 50%; background: rgba(148,163,184,.25); flex: none; }
.tool-item.on .dot { background: var(--accent); }
.tool-item small { font-size: 8.5px; color: var(--dim); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.mini-btn { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 6px; padding: 5px 9px; font-family: var(--font-mono); font-size: 10px; transition: all .2s; }
.mini-btn:hover { border-color: var(--accent-line); color: var(--accent); }
.mini-btn.primary { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }

input.field, select.field {
  background: rgba(255,255,255,.025); border: 1px solid var(--line); border-radius: 7px;
  color: var(--text); padding: 8px 10px; font-family: var(--font-sans); font-size: 12px; outline: none;
}
input.field:focus, select.field:focus { border-color: var(--accent-line); }

.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { width: 13px; height: 13px; accent-color: var(--accent); }

.foot-note { margin-top: 22px; display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; border: 1px dashed rgba(240, 200, 121, .22); border-radius: 10px; background: rgba(240, 200, 121, .03); color: var(--muted); font-size: 11.5px; line-height: 1.8; }
.foot-note b { color: var(--warm); font-weight: 500; }

@media (max-width: 1000px) {
  .workspace, .workspace.two, .workspace.right-wide { grid-template-columns: 1fr; }
  .chat-log { height: 360px; }
  .demo-intro { flex-direction: column; align-items: flex-start; gap: 18px; }
  .demo-intro-meta { align-items: flex-start; flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 620px) {
  .demo-main { padding-top: 24px; }
  .panel-bd { padding: 14px; }
  .demo-topbar .demo-brandline { display: none; }
  .tool-grid { grid-template-columns: 1fr; }
}

/* ============ 顶栏右侧操作区 ============ */
.demo-top-actions { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.demo-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.demo-topbar .icon-btn { width: 34px; height: 34px; }

/* ============ 亮色主题 ============ */
html[data-theme="light"] .demo-page { background: var(--bg); }
html[data-theme="light"] .demo-topbar {
  background: rgba(248, 250, 253, 0.88);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}
html[data-theme="light"] .panel {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}
html[data-theme="light"] .panel-hd { background: rgba(15, 23, 42, 0.025); }
html[data-theme="light"] .panel-hd .dots i { background: #c9d4e2; }
html[data-theme="light"] .panel-hd .dots i:first-child { background: rgba(214, 78, 78, 0.55); }
html[data-theme="light"] .panel-hd .dots i:nth-child(2) { background: rgba(190, 138, 0, 0.5); }
html[data-theme="light"] .panel-hd .dots i:nth-child(3) { background: rgba(11, 143, 115, 0.5); }
html[data-theme="light"] .msg-avatar { background: #f4f7fb; }
html[data-theme="light"] .bubble { background: #f6f9fc; }
html[data-theme="light"] .msg.user .bubble { background: rgba(27, 111, 208, 0.08); border-color: rgba(27, 111, 208, 0.22); }
html[data-theme="light"] .msg.ai .bubble { border-color: rgba(27, 111, 208, 0.18); }
html[data-theme="light"] .msg.ai .bubble .cite { background: rgba(27, 111, 208, 0.09); }
html[data-theme="light"] .composer { background: #f3f7fb; }
html[data-theme="light"] .composer textarea { background: #ffffff; }
html[data-theme="light"] .send-btn { color: #ffffff; }
html[data-theme="light"] .send-btn:hover { background: #155bad; }
html[data-theme="light"] .chip { background: #ffffff; }
html[data-theme="light"] .chip:hover { background: var(--accent-soft); }
html[data-theme="light"] .stage { border-bottom-color: rgba(15, 23, 42, 0.08); }
html[data-theme="light"] .bar-track { background: rgba(15, 23, 42, 0.08); }
html[data-theme="light"] .kv { border-bottom-color: rgba(15, 23, 42, 0.08); }
html[data-theme="light"] .tool-item { background: #ffffff; }
html[data-theme="light"] .tool-item.on { background: rgba(27, 111, 208, 0.07); }
html[data-theme="light"] .mini-btn { background: #ffffff; }
html[data-theme="light"] input.field,
html[data-theme="light"] select.field { background: #ffffff; }
html[data-theme="light"] .foot-note {
  border-color: rgba(156, 101, 0, 0.22);
  background: rgba(240, 200, 121, 0.1);
}
html[data-theme="light"] .demo-pill.warn { background: rgba(240, 200, 121, 0.14); }

@media (max-width: 620px) {
  .demo-top-actions { gap: 8px; }
  .demo-topbar .icon-btn { width: 32px; height: 32px; }
}