/* 回复里的代码块、脑图、Mermaid 图表（结构和行为见 artifacts.js）。
   颜色沿用 app.css 的变量；深色模式和 app.css 一样跟随系统设置。 */

.artifact {
  --artifact-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  /* 代码高亮配色（GitHub 风格），深色模式在下面覆盖 */
  --hl-keyword: #cf222e;
  --hl-title: #8250df;
  --hl-constant: #0550ae;
  --hl-string: #0a3069;
  --hl-builtin: #953800;
  --hl-comment: #6e7781;
  --hl-tag: #116329;
  --hl-bullet: #953800;
  --hl-add: #116329;
  --hl-add-bg: #dafbe1;
  --hl-del: #82071e;
  --hl-del-bg: #ffebe9;

  margin: 1rem 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  overflow: hidden;
  max-width: 100%;
  min-width: 0;
}
@media (prefers-color-scheme: dark) {
  .artifact {
    --hl-keyword: #ff7b72;
    --hl-title: #d2a8ff;
    --hl-constant: #79c0ff;
    --hl-string: #a5d6ff;
    --hl-builtin: #ffa657;
    --hl-comment: #8b949e;
    --hl-tag: #7ee787;
    --hl-bullet: #f2cc60;
    --hl-add: #aff5b4;
    --hl-add-bg: #033a16;
    --hl-del: #ffdcd7;
    --hl-del-bg: #67060c;
  }
}

/* 标题栏：左边名字，右边按钮；窄屏时按钮换到下一行 */
.artifact-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 6px 8px 6px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.5;
}
.artifact-name {
  flex: 1 1 8em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.artifact-code .artifact-name { font-family: var(--artifact-mono); font-size: .8rem; }
.artifact-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }

.artifact-btn,
a.artifact-btn {
  display: inline-block;
  font: inherit;
  font-size: .8rem;
  line-height: 1.5;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.artifact-btn:hover,
a.artifact-btn:hover { border-color: var(--accent); text-decoration: none; }
.artifact-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* 代码和原文：在框里横向滚动，不撑宽页面 */
figure.artifact > pre {
  margin: 0;
  padding: 12px 14px;
  border: 0;
  border-radius: 0;
  background: var(--code-bg);
  color: var(--text);
  overflow: auto;
  font-family: var(--artifact-mono);
  font-size: .85rem;
  line-height: 1.55;
  tab-size: 4;
}
figure.artifact > pre > code {
  display: block;
  padding: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font: inherit;
  white-space: pre;
}

/* 画好的图。contain: paint 让图里的任何内容都只能画在这个框里 */
.artifact-view {
  position: relative;
  overflow: auto;
  contain: paint;
  background: var(--card);
}
.artifact-view-mermaid { padding: 12px; }
.artifact-view-mermaid > svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.artifact-view-mindmap > svg {
  display: block;
  width: 100%;
  height: 420px;
  cursor: grab;
  touch-action: pan-x pan-y; /* 单指滑动照常滚动页面，双指缩放/移动脑图 */
}
.artifact-view-mindmap > svg:active { cursor: grabbing; }
@media (max-width: 560px) {
  .artifact-view-mindmap > svg { height: 340px; }
}

/* 图画好以后原文默认收起，点「源码」展开 */
.artifact-rendered:not(.artifact-show-source) > .artifact-source { display: none; }
.artifact-rendered > .artifact-source { border-top: 1px solid var(--line); }

.artifact-error {
  margin: 0;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .85rem;
}

/* highlight.js 的高亮记号 */
.artifact .hljs-doctag,
.artifact .hljs-keyword,
.artifact .hljs-meta .hljs-keyword,
.artifact .hljs-template-tag,
.artifact .hljs-template-variable,
.artifact .hljs-type,
.artifact .hljs-variable.language_ { color: var(--hl-keyword); }
.artifact .hljs-title,
.artifact .hljs-title.class_,
.artifact .hljs-title.class_.inherited__,
.artifact .hljs-title.function_ { color: var(--hl-title); }
.artifact .hljs-attr,
.artifact .hljs-attribute,
.artifact .hljs-literal,
.artifact .hljs-meta,
.artifact .hljs-number,
.artifact .hljs-operator,
.artifact .hljs-variable,
.artifact .hljs-selector-attr,
.artifact .hljs-selector-class,
.artifact .hljs-selector-id { color: var(--hl-constant); }
.artifact .hljs-regexp,
.artifact .hljs-string,
.artifact .hljs-meta .hljs-string { color: var(--hl-string); }
.artifact .hljs-built_in,
.artifact .hljs-symbol { color: var(--hl-builtin); }
.artifact .hljs-comment,
.artifact .hljs-code,
.artifact .hljs-formula { color: var(--hl-comment); }
.artifact .hljs-name,
.artifact .hljs-quote,
.artifact .hljs-selector-tag,
.artifact .hljs-selector-pseudo { color: var(--hl-tag); }
.artifact .hljs-subst { color: inherit; }
.artifact .hljs-section { color: var(--hl-constant); font-weight: 600; }
.artifact .hljs-bullet { color: var(--hl-bullet); }
.artifact .hljs-emphasis { font-style: italic; }
.artifact .hljs-strong { font-weight: 600; }
.artifact .hljs-addition { color: var(--hl-add); background: var(--hl-add-bg); }
.artifact .hljs-deletion { color: var(--hl-del); background: var(--hl-del-bg); }
