/* 回答中的可视化块 */
.viz {
  --viz-surface: #ffffff;
  --viz-ink: rgba(0, 0, 0, 0.88);
  --viz-ink-dim: rgba(0, 0, 0, 0.58);
  --viz-ink-faint: rgba(0, 0, 0, 0.42);
  --viz-line: rgba(0, 0, 0, 0.08);
  --viz-good: #0e7a38;
  --viz-bad: #c4303a;
  margin: 14px 0;
  padding: 16px 18px 12px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: 16px;
  background: var(--viz-surface);
  color: var(--viz-ink);
  overflow: hidden;
  container-type: inline-size;
}
.viz-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

/* 图表 */
.viz-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.viz-grid { stroke: var(--viz-line); stroke-width: 1; }
.viz-base { stroke: rgba(0, 0, 0, 0.22); stroke-width: 1; }
.viz-axis { fill: var(--viz-ink-faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-dot { stroke: var(--viz-surface); stroke-width: 2; }
.viz-hit { fill: transparent; cursor: default; }
.viz-hit:hover { fill: rgba(0, 0, 0, 0.035); }
.viz-slice { stroke: var(--viz-surface); stroke-width: 2; transition: opacity 0.15s; }
.viz-donut:hover .viz-slice { opacity: 0.55; }
.viz-donut .viz-slice:hover { opacity: 1; }
.viz-donut-total { fill: var(--viz-ink); font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }

.viz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--viz-ink-dim);
}
.viz-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.viz-legend-value { margin-left: auto; padding-left: 12px; color: var(--viz-ink); font-variant-numeric: tabular-nums; }
.viz-pie { display: flex; align-items: center; gap: 24px; }
.viz-pie .viz-donut { width: 180px; flex-shrink: 0; }
.viz-legend-col { flex-direction: column; flex: 1; min-width: 0; margin: 0; font-size: 13px; }

.viz-data { margin-top: 8px; font-size: 12px; color: var(--viz-ink-dim); }
.viz-data summary { width: fit-content; cursor: pointer; user-select: none; }
.viz-data summary:hover { color: var(--viz-ink); }
.viz-data table { margin: 8px 0 0; font-size: 12px; border-collapse: collapse; }
.viz-data th, .viz-data td { padding: 4px 12px 4px 0; border: none; border-bottom: 1px solid var(--viz-line); background: none; text-align: left; font-variant-numeric: tabular-nums; }

.viz-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(24, 24, 24, 0.92);
  color: #fff;
  font-size: 12px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}
.viz-tooltip.show { opacity: 1; }
.viz-tooltip-head { font-weight: 600; }

/* 指标 */
.viz-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.viz-stat { padding: 12px 14px; border-radius: 12px; background: var(--surface, #f5f5f5); }
.viz-stat-label { font-size: 12px; color: var(--viz-ink-dim); }
.viz-stat-value { margin-top: 4px; font-size: 24px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.viz-stat-note { margin-top: 4px; font-size: 12px; color: var(--viz-ink-faint); }
.viz-stat-note.up { color: var(--viz-good); }
.viz-stat-note.down { color: var(--viz-bad); }

/* 步骤与时间线 */
.markdown-body .viz-step-list { margin: 0; padding: 0; list-style: none; }
.viz-step { position: relative; display: flex; gap: 12px; padding-bottom: 14px; }
.viz-step:last-child { padding-bottom: 0; }
.viz-step::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 26px;
  bottom: 2px;
  width: 1.5px;
  background: var(--viz-line);
}
.viz-step:last-child::before { display: none; }
.viz-step-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #1f1f1f;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.viz-timeline .viz-step-mark { width: 12px; height: 12px; margin: 6px; border: 2px solid #1f1f1f; background: var(--viz-surface); }
.viz-timeline .viz-step::before { left: 11px; top: 26px; }
.viz-step-body { min-width: 0; padding-top: 2px; }
.viz-step-time { font-size: 12px; color: var(--viz-ink-faint); }
.viz-step-title { font-weight: 600; line-height: 1.5; }
.viz-step-detail { margin-top: 2px; font-size: 13px; line-height: 1.6; color: var(--viz-ink-dim); }

/* 卡片 */
.viz-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.viz-card { padding: 12px 14px; border: 1px solid var(--viz-line); border-radius: 12px; }
.viz-card-tag { display: inline-block; margin-bottom: 6px; padding: 1px 8px; border-radius: 999px; background: var(--surface, #f5f5f5); font-size: 11px; color: var(--viz-ink-dim); }
.viz-card-title { font-weight: 600; line-height: 1.45; }
.viz-card-detail { margin-top: 4px; font-size: 13px; line-height: 1.6; color: var(--viz-ink-dim); }

/* 流程 */
.viz-flow-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.viz-flow-node { padding: 6px 12px; border-radius: 10px; background: var(--surface, #f5f5f5); font-size: 13px; line-height: 1.4; }
.viz-flow-step { display: inline-flex; align-items: center; gap: 8px; }
.viz-flow-arrow { color: var(--viz-ink-faint); }

/* 生成中 */
.viz-pending {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  background: linear-gradient(100deg, #fafafa 30%, #f0f0f0 50%, #fafafa 70%) 0 0 / 200% 100%;
  animation: viz-shimmer 1.4s linear infinite;
}
.viz-pending-text { font-size: 13px; color: var(--viz-ink-faint); }
@keyframes viz-shimmer { to { background-position: -200% 0; } }

/* 图表随宽度缩小时放大坐标文字，保持约 11px 的实际字号 */
@container (max-width: 560px) {
  .viz-axis { font-size: 15px; }
}
@container (max-width: 400px) {
  .viz-axis { font-size: 19px; }
}
@media (max-width: 760px) {
  .viz { padding: 14px 12px 10px; }
  .viz-pie { flex-direction: column; align-items: stretch; gap: 12px; }
  .viz-pie .viz-donut { width: 160px; align-self: center; }
}
@media (prefers-reduced-motion: reduce) {
  .viz-pending { animation: none; }
}

/* 追问建议，只在最新一轮回答下显示 */
.followups { display: none; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
#messages > .assistant-turn:last-child .followups { display: flex; }
.followup {
  max-width: 100%;
  padding: 7px 14px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: 999px;
  background: var(--panel, #fff);
  color: var(--text, rgba(0, 0, 0, 0.88));
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.followup::before { content: "↳ "; color: var(--text-faint, rgba(0, 0, 0, 0.42)); }
.followup:hover { background: var(--hover-bg, rgba(0, 0, 0, 0.04)); border-color: rgba(0, 0, 0, 0.16); }
