/* =========================================================
   在线演示页
   ========================================================= */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 10px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: 0 0 8px 0;
}

.skip-link:focus {
  left: 0;
}

.demo-page {
  background:
    radial-gradient(1200px 520px at 50% -120px, rgba(31, 111, 235, 0.07), transparent 70%),
    var(--bg);
}

.demo-hero {
  padding: 34px 0 18px;
}

.demo-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid #f0e0b8;
  border-radius: 10px;
  background: var(--warn-soft);
  color: #6b5318;
  font-size: 13px;
  line-height: 1.5;
}

.demo-banner strong {
  color: #5c4712;
  white-space: nowrap;
}

.demo-banner b {
  color: #8a5a00;
}

.demo-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(180, 136, 39, 0.14);
}

.demo-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
  padding: 28px 0 4px;
}

.demo-head h1 {
  font-size: clamp(34px, 4.2vw, 52px);
  margin-bottom: 16px;
}

.demo-head .lead {
  max-width: 62ch;
  margin-bottom: 0;
}

.demo-status-card {
  flex: 0 0 300px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  padding: 14px 18px;
  font-size: 13px;
  box-shadow: var(--shadow);
}

.ds-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}

.ds-row:last-child {
  border-bottom: 0;
}

.ds-row span {
  color: var(--ink-3);
}

.ds-row b {
  font-weight: 600;
  color: var(--ink);
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.ds-online {
  color: var(--ok) !important;
}

.ds-online i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(15, 157, 88, 0.13);
}

.ds-warn {
  color: var(--warn) !important;
}

/* ---------- 主体布局 ---------- */

.demo-main {
  padding: 18px 0 56px;
}

.demo-layout {
  display: grid;
  grid-template-columns: 336px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.scene-panel {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 10px;
}

.scene-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}

.scene-title h2 {
  font-size: 18px;
  margin: 0;
}

.scene-title span {
  font-size: 11.5px;
  color: var(--ink-3);
}

.scene-card {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.scene-card:hover {
  border-color: #c7d2e1;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.scene-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.sc-legal {
  background: #f0edff;
  color: #5b46c9;
}

.sc-law {
  background: #eaf7f5;
  color: #0f766e;
}

.sc-compare {
  background: #fff4e5;
  color: #a66400;
}

.sc-invoice {
  background: #eafaf1;
  color: #0b7a45;
}

.sc-en {
  background: #fff4e5;
  color: #a66400;
}

.scene-body {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.scene-body strong {
  font-size: 14.5px;
  letter-spacing: -0.01em;
}

.scene-body em {
  font-style: normal;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.5;
}

.scene-body span {
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.5;
}

.scene-arrow {
  margin-left: auto;
  color: var(--ink-3);
  font-size: 14px;
  line-height: 38px;
}

.scene-dev {
  background: linear-gradient(180deg, #fffdf7, #fff);
  border-style: dashed;
}

.scene-note {
  margin-top: 8px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--soft);
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.65;
}

.scene-note strong {
  display: block;
  color: var(--ink);
  font-size: 12px;
  margin-bottom: 4px;
}

.scene-note p {
  margin: 0;
}

/* ---------- 聊天面板 ---------- */

.chat-shell {
  display: flex;
  flex-direction: column;
  min-height: 520px;
  height: calc(100vh - 470px);
  max-height: 720px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.demo-layout > * {
  min-width: 0;
}

.chat-shell.dragover {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(31, 111, 235, 0.12), var(--shadow-lg);
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.9);
}

.chat-id {
  display: flex;
  align-items: center;
  gap: 11px;
}

.chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #2b7cf0, var(--accent-dark));
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.chat-id strong {
  display: block;
  font-size: 14px;
  line-height: 1.3;
}

.chat-id span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-3);
}

.online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}

.chat-reset {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  padding: 6px 11px;
  cursor: pointer;
}

.chat-reset:hover {
  background: var(--soft);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px 10px;
  scroll-behavior: auto;
  background:
    linear-gradient(180deg, rgba(246, 248, 251, 0.55), transparent 120px),
    var(--bg);
}

.msg {
  display: grid;
  gap: 6px;
  margin-bottom: 22px;
  animation: msg-in 0.24s ease both;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.msg.user {
  justify-items: end;
}

.msg-meta {
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 0 4px;
}

.msg.user .msg-meta {
  order: 2;
}

.bubble {
  max-width: min(660px, 88%);
  padding: 13px 16px;
  border-radius: 12px;
  background: var(--soft);
  border: 1px solid var(--line-soft);
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.bubble p {
  margin: 0 0 0.6em;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble ul,
.bubble ol {
  margin: 0.2em 0 0.7em;
  padding-left: 1.25em;
}

.bubble li {
  margin: 0.15em 0;
}

.bubble strong {
  font-weight: 650;
}

.bubble code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: rgba(15, 23, 42, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

.bubble-muted {
  color: var(--ink-3);
  font-size: 12.5px;
}

.bubble-gap {
  height: 0.35em;
  margin: 0 !important;
}

.msg.user .bubble {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.user .bubble code {
  background: rgba(255, 255, 255, 0.18);
}

.msg.assistant .bubble {
  border-bottom-left-radius: 4px;
}

/* 工具调用状态 */

.tool-trail {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 7px;
}

.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
}

.tool-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.tool-chip.done {
  background: #eafaf1;
  color: #0b7a45;
}

.tool-chip.done::before {
  background: var(--ok);
}

.tool-chip.running::before {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
    transform: scale(0.7);
  }
}

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 2px 0;
}

.typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-3);
  animation: typing 1.1s ease-in-out infinite;
}

.typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

/* ---------- 快捷问题 ---------- */

.chat-chips {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  padding: 8px 20px 0;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  padding: 5px 11px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chip:hover {
  background: var(--accent-soft);
  border-color: #c9dcff;
  color: var(--accent-dark);
}

/* ---------- 输入区 ---------- */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 14px 16px 6px;
}

.icon-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--ink-2);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--soft);
  color: var(--ink);
}

#chat-input {
  flex: 1;
  min-height: 38px;
  max-height: 132px;
  resize: none;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.send-btn {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 18px;
}

.send-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.composer-hint {
  margin: 0;
  padding: 0 20px 12px;
  font-size: 11px;
  color: var(--ink-3);
}

/* ---------- 对话内卡片 ---------- */

.demo-card {
  max-width: min(660px, 92%);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
  font-size: 13.5px;
}

.dc-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 16px;
  background: var(--soft);
  border-bottom: 1px solid var(--line-soft);
}

.dc-head strong {
  font-size: 14px;
}

.dc-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.dc-badge.ok {
  background: #eafaf1;
  color: #0b7a45;
}

.dc-badge.high {
  background: #fdecec;
  color: #c0392b;
}

.dc-badge.mid {
  background: var(--warn-soft);
  color: var(--warn);
}

.dc-badge.low {
  background: #eef4ff;
  color: var(--accent-dark);
}

.dc-body {
  padding: 14px 16px;
}

.dc-grid {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 7px 14px;
  margin: 0;
}

.dc-grid dt {
  color: var(--ink-3);
}

.dc-grid dd {
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.dc-amount {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.dc-actions {
  display: flex;
  gap: 8px;
  padding: 0 16px 14px;
}

.dc-actions .btn {
  padding: 8px 14px;
  font-size: 13px;
}

.dc-note {
  margin: 0;
  padding: 10px 16px;
  border-top: 1px dashed var(--line);
  background: #fffdf7;
  color: #8a6d2f;
  font-size: 11.5px;
  line-height: 1.6;
}

.dc-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #f3fbf6;
  border-top: 1px solid #d8f0e1;
  color: #0b6b3f;
  font-size: 13px;
}

.dc-result a {
  margin-left: auto;
  color: var(--accent-dark);
  font-weight: 600;
  white-space: nowrap;
}

/* 法条问答 */

.legal-card {
  max-width: min(660px, 96%);
}

.legal-question {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--soft);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
}

.legal-question::before {
  content: "问题 · ";
  color: var(--ink-3);
  font-weight: 600;
}

.legal-answer {
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--ink);
}

.legal-answer p {
  margin: 0 0 0.7em;
}

.legal-answer p:last-child {
  margin-bottom: 0;
}

.legal-card .citations {
  margin-top: 12px;
}

/* 量化分析 */

.quant-card {
  max-width: min(660px, 96%);
}

.sector-list {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.sector-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--soft);
  font-size: 13px;
}

.sector-row b {
  font-variant-numeric: tabular-nums;
}

.sector-row .up {
  color: #c0392b;
}

.sector-row .down {
  color: #0b7a45;
}

.quant-strategy {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 10px 12px;
  margin-bottom: 14px;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
  font-size: 12.5px;
  color: var(--ink-2);
}

/* 版本比对 */

.compare-card {
  max-width: min(660px, 96%);
}

.compare-files {
  display: flex;
  gap: 18px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--soft);
  font-size: 12px;
  color: var(--ink-3);
  flex-wrap: wrap;
}

.compare-files b {
  color: var(--ink-2);
}

.change {
  border-bottom: 1px solid var(--line-soft);
}

.change:last-child {
  border-bottom: 0;
}

.change summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.change summary::-webkit-details-marker {
  display: none;
}

.change summary:hover {
  background: var(--soft);
}

.change-body {
  padding: 0 16px 12px;
}

.change-row {
  margin: 0 0 6px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink-2);
}

.change-row b {
  color: var(--ink-3);
  font-weight: 600;
}

.dc-badge.add {
  background: #eafaf1;
  color: #0b7a45;
}

.dc-badge.del {
  background: #fdecec;
  color: #c0392b;
}

.dc-badge.mod {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

/* 合同审查结果 */

.review-card {
  max-width: min(660px, 96%);
}

.review-summary {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
  line-height: 1.7;
}

.risk-list {
  display: grid;
}

.risk {
  border-bottom: 1px solid var(--line-soft);
}

.risk:last-child {
  border-bottom: 0;
}

.risk summary {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.risk summary::-webkit-details-marker {
  display: none;
}

.risk summary:hover {
  background: var(--soft);
}

.risk-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.55;
}

.risk-clause {
  display: block;
  font-weight: 400;
  color: var(--ink-3);
  font-size: 11.5px;
  margin-top: 1px;
}

.risk-body {
  padding: 0 16px 14px 16px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.75;
}

.risk-quote {
  margin: 0 0 10px;
  padding: 9px 12px;
  border-left: 3px solid var(--line);
  background: var(--soft);
  color: var(--ink-2);
  font-size: 12.5px;
  border-radius: 0 6px 6px 0;
}

.risk-row {
  margin: 0 0 8px;
}

.risk-row b {
  color: var(--ink);
  font-weight: 600;
}

.citations {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.citation {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-size: 11.5px;
  color: var(--ink-2);
}

.citation .ok {
  color: var(--ok);
  font-weight: 700;
}

.citation .bad {
  color: #c0392b;
  font-weight: 700;
}

.review-foot {
  padding: 10px 16px;
  border-top: 1px dashed var(--line);
  background: #fffdf7;
  color: #8a6d2f;
  font-size: 11.5px;
  line-height: 1.6;
}

/* ---------- 页尾说明 ---------- */

.demo-after {
  padding: 0 0 72px;
}

.demo-after-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  align-items: center;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--soft);
}

.demo-after h2 {
  font-size: 24px;
  margin-bottom: 10px;
}

.demo-after p {
  margin: 0;
  color: var(--ink-2);
  font-size: 14.5px;
}

.demo-after .check-list {
  margin-top: 0;
}

/* ---------- 响应式 ---------- */

@media (max-width: 1040px) {
  .demo-layout {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .chat-shell {
    height: 74vh;
  }

  .demo-after-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

@media (max-width: 860px) {
  .demo-head {
    flex-direction: column;
    align-items: stretch;
    gap: 22px;
  }

  .demo-status-card {
    flex: 1 1 auto;
  }

  .demo-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  .chat-shell {
    order: -1;
  }

  .scene-panel {
    order: 0;
    position: static;
    grid-template-columns: 1fr 1fr;
  }

  .scene-title,
  .scene-note {
    grid-column: 1 / -1;
  }

  .chat-shell {
    height: 540px;
    min-height: 460px;
  }
}

@media (max-width: 620px) {
  .demo-status-card {
    display: none;
  }

  .demo-banner {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .scene-panel {
    grid-template-columns: 1fr;
  }

  .scene-card {
    padding: 13px;
  }

  .chat-log {
    padding: 18px 13px 8px;
  }

  .bubble,
  .demo-card {
    max-width: 94%;
  }

  .chat-chips {
    padding-inline: 13px;
  }

  .composer {
    padding-inline: 12px;
  }

  .composer-hint {
    padding-inline: 14px;
  }

  .dc-grid {
    grid-template-columns: 74px minmax(0, 1fr);
  }
}
