/* ============ HTML Artifact ============ */
.artifact-block {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card-bg);
}
.artifact-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
}
.artifact-header-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
}
.artifact-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artifact-actions { display: flex; gap: 4px; flex-shrink: 0; }
.artifact-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.artifact-btn:hover {
  background: var(--card-bg);
  color: var(--text-2);
  border-color: var(--border);
}
.artifact-btn svg { width: 12px; height: 12px; flex-shrink: 0; opacity: 0.85; }
.artifact-frame {
  width: 100%;
  border: none;
  display: block;
  background: transparent;
}
.artifact-placeholder-body {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(90deg, var(--card-bg) 0%, var(--sidebar-bg) 50%, var(--card-bg) 100%);
  background-size: 200% 100%;
  animation: artifact-shimmer 1.4s ease-in-out infinite;
}
.artifact-placeholder-label {
  font-size: 13px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 8px;
}
.artifact-placeholder-label::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent, #378ADD);
  animation: artifact-dot-pulse 1s ease-in-out infinite;
}
@keyframes artifact-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@keyframes artifact-dot-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.1); }
}

/* ── 流式生成态：让用户「看见」模型在画 ──
   .artifact-block.is-streaming 给整体 + chip + iframe 底色加生命感 */
.artifact-block.is-streaming {
  border-color: rgba(31, 60, 51, 0.18);
  box-shadow: 0 0 0 3px rgba(31, 60, 51, 0.04), 0 8px 24px -10px rgba(31, 60, 51, 0.12);
  position: relative;
  overflow: hidden;
}
/* 顶部光带：从左到右扫过，2.4s 一轮，提示"还在写" */
.artifact-block.is-streaming::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--ink, #1f3c33), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: artifact-top-sweep 2.4s ease-in-out infinite;
  z-index: 2;
  pointer-events: none;
}
.artifact-block.is-streaming .artifact-header {
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--card-bg) 100%);
}
/* iframe 流式期：底色加极淡的 shimmer，给用户"内容正在浮现"的感觉。
   一旦 receiver 把 partial HTML 写入，iframe 自身背景会覆盖这层 shimmer。 */
.artifact-block.is-streaming .artifact-frame {
  background:
    linear-gradient(90deg, transparent 0%, rgba(31, 60, 51, 0.035) 50%, transparent 100%) var(--card-bg);
  background-size: 200% 100%, 100% 100%;
  animation: artifact-shimmer 1.8s ease-in-out infinite;
}
html[data-theme="dark"] .artifact-block.is-streaming {
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.03), 0 8px 24px -10px rgba(0, 0, 0, 0.4);
}
html[data-theme="dark"] .artifact-block.is-streaming::before {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
}

/* 「生成中」chip：脉冲圆点 + 渐变背景 + shimmer 文字 */
.artifact-streaming-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  padding: 2px 9px 2px 7px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink, #1f3c33);
  background: rgba(31, 60, 51, 0.08);
  border: 1px solid rgba(31, 60, 51, 0.14);
  border-radius: 10px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.artifact-streaming-tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink, #1f3c33);
  animation: artifact-tag-pulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
html[data-theme="dark"] .artifact-streaming-tag {
  color: #e6e5e0;
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.16);
}
html[data-theme="dark"] .artifact-streaming-tag::before {
  background: #c8e6c9;
}
@keyframes artifact-top-sweep {
  0%   { background-position: -40% 0; }
  100% { background-position: 140% 0; }
}
@keyframes artifact-tag-pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.85); box-shadow: 0 0 0 0 rgba(31, 60, 51, 0.35); }
  50%      { opacity: 1;    transform: scale(1);    box-shadow: 0 0 0 4px rgba(31, 60, 51, 0); }
}


/* ── 报告 / 汇报材料 Canvas 面板 (reportCanvas.js) ──────────────────
   右侧独立平行第三列(侧栏 | 对话 | Canvas),复用 .artifact-block 渲染报告。
   作为 body flex 流内第三列:打开时 .main(flex:1)自动让位收窄、两者并排可见,
   不覆盖对话(Codex 风格);关闭([hidden])退出 flex 行,main 自动回满。
   用 flex:0 0 auto + width(不用 flex-basis),让拖拽时设的 inline width 生效;
   position:relative 给左缘 resize handle 作定位锚。窄屏退回全屏覆盖(见下方断点)。 */
.report-canvas {
  position: relative;
  flex: 0 0 auto;
  /* 默认宽度够放下一张固定 794px 的 A4 页(+内边距)而不横向滚动;窄屏/小窗
     会触发 840 断点退全屏覆盖。用户可拖左缘改宽。 */
  width: var(--report-canvas-w, clamp(420px, 54vw, 880px));
  min-width: 360px;
  max-width: 76%;
  height: 100%;
  align-self: stretch;
  background: var(--bg, #fff);
  border-left: 1px solid var(--border-soft, rgba(0,0,0,0.08));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* 开/合过渡：宽度收放（主列平滑让位）+ 淡入淡出。width 过渡每帧重排两列、
     上限约 30fps——曾改成"宽度瞬间就位+内容微滑"追 60fps，面板变成"嘣地出现"，
     滑动方向感全无（2026-06-11 用户反馈回退）。并排布局下主列要平滑让位就必须
     动 width，滑动感优先于帧率；下方 bar/body 的 transform 滑入做方向感叠加。 */
  transition: width .28s ease, opacity .22s ease;
}
/* 关态：宽度收到 0 + 淡出（!important 压过拖拽设的 inline width，保证能收起）。
   保持元素在 DOM/布局里（非 display:none）才能过渡。 */
.report-canvas[hidden] {
  width: 0 !important;
  min-width: 0 !important;
  opacity: 0;
  border-left: none;
  pointer-events: none;
}
/* 内容滑入叠加：顶栏 + 内容从右 28px 滑入/滑出（合成器属性），与宽度过渡
   同步走，强化"从右边滑过来/滑回去"的方向感。 */
.report-canvas .report-canvas-bar,
.report-canvas .report-canvas-body {
  transition: transform .26s cubic-bezier(.2, .8, .2, 1), opacity .22s ease;
}
.report-canvas[hidden] .report-canvas-bar,
.report-canvas[hidden] .report-canvas-body {
  transform: translateX(28px);
  opacity: 0;
}
.report-canvas-resize {
  position: absolute;
  left: 0;
  top: 0;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  z-index: 2;
}
.report-canvas-resize:hover { background: var(--border, rgba(0,0,0,0.1)); }
body.report-canvas-resizing { user-select: none; cursor: ew-resize; }
.report-canvas-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft, rgba(0,0,0,0.06));
  flex-shrink: 0;
}
.report-canvas-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink, #1f2320);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.report-canvas-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  color: var(--text-3, #8a8578);
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}
.report-canvas-close:hover { background: var(--ink-soft, rgba(0,0,0,0.05)); color: var(--ink, #1f2320); }
.report-canvas-close svg { width: 16px; height: 16px; }
/* 顶栏导出按钮组（HTML / PDF）—— 复用 .artifact-btn 样式，放在标题与关闭之间 */
.report-canvas-actions { display: flex; gap: 6px; flex-shrink: 0; }
.report-canvas-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  position: relative; /* is-loading 转圈的定位锚 */
}
/* 预览拉取中的加载态（reportCanvas.js：面板先开、内容后到）。
   spinner 动 transform，合成器动画不掉帧。 */
.report-canvas-body.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2.5px solid var(--border, rgba(0, 0, 0, 0.12));
  border-top-color: var(--ink, #1f3c33);
  border-radius: 50%;
  animation: rc-spin .7s linear infinite;
}
@keyframes rc-spin { to { transform: rotate(360deg); } }
/* Canvas 里的报告**平铺**：去掉内层 artifact 卡片的边框/底色/圆角/外边距，
   并隐藏它自己的头部（标题 + 导出按钮已上移到 Canvas 顶栏）——否则会出现
   "卡片套卡片 + 标题重复"的怪异嵌套（用户实测痛点）。 */
.report-canvas-body .artifact-block {
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}
.report-canvas-body .artifact-header { display: none; }

/* 主对话气泡里替代报告 artifact 的小 chip:点开右侧 Canvas */
.report-canvas-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--ink, #1f2320);
  background: var(--ink-soft, rgba(0,0,0,0.04));
  border: 1px solid var(--border-soft, rgba(0,0,0,0.06));
  border-radius: 10px;
  cursor: pointer;
}
.report-canvas-chip:hover { border-color: var(--border, rgba(0,0,0,0.12)); }
.report-canvas-chip .rcc-ico { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.8; }

/* 窄屏(<840,与 sidebar 浮层化同断点):三列放不下 → Canvas 退回全屏覆盖。 */
@media (max-width: 840px) {
  .report-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 100%;
    z-index: 80;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.12);
    /* 窄屏是全屏浮层 → 用滑入代替宽度收放（宽度收放在 fixed 全屏下不自然）。 */
    transform: translateX(0);
    transition: transform .3s ease, opacity .22s ease;
  }
  /* 关态：滑出右侧而非收宽（覆盖桌面态的 width:0）。 */
  .report-canvas[hidden] {
    width: 100% !important;
    transform: translateX(100%);
    opacity: 1;
  }
}

/* ── 产物交付组件：卡片（收起态）/ 内嵌（展开态）/ 已更新标记 ──
   交付统一后 artifact 段渲成 .artifact-delivery 两态之一（artifacts.js
   buildArtifactDeliveryHtml / ...ExpandedHtml，点击路由在 messages.js）。 */
.artifact-delivery.is-collapsed {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  margin: 10px 0;
  max-width: 420px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.artifact-delivery.is-collapsed:hover {
  border-color: var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.artifact-delivery.is-collapsed.is-loading { opacity: 0.6; pointer-events: none; }
.artifact-delivery-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.artifact-delivery-ico {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--sidebar-bg);
  color: var(--text-3);
}
.artifact-delivery-ico svg { width: 17px; height: 17px; }
.artifact-delivery-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.artifact-delivery-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.artifact-delivery-sub {
  font-size: 11px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.artifact-delivery-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px 0 4px;
  border-left: 1px solid var(--border-soft);
}
.artifact-delivery-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.artifact-delivery-act:hover { background: var(--sidebar-bg); color: var(--text-2); }
.artifact-delivery-act svg { width: 14px; height: 14px; }
/* 展开态撑满消息列：在 .msg-files（flex-wrap 附件容器）里作为 flex 子项会被
   按内容收缩成窄条，与气泡内渲染的 artifact 宽度不一致——flex-basis 100% 强制
   独占整行；width:100% 覆盖普通块级场景。 */
.artifact-delivery.is-expanded { margin: 12px 0; width: 100%; flex: 0 0 100%; }
.artifact-delivery.is-expanded .artifact-block { margin: 0; }

/* 编辑轮「已更新」标记卡：轻量一行，产物的新时间锚点 + 右侧入口。 */
.artifact-updated-markers { margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.artifact-updated-marker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 6px 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.artifact-updated-marker:hover { background: var(--sidebar-bg); border-color: var(--border); }
.artifact-updated-marker svg { width: 13px; height: 13px; flex-shrink: 0; opacity: 0.75; }
.artifact-updated-marker .aum-name { font-weight: 500; }
.artifact-updated-marker .aum-hint { color: var(--text-3); font-size: 11px; }

/* 历史版本标记：同一产物被后续轮编辑后，旧锚点降权成的一行小字。
   比「已更新」标记更轻（无边框、更小字号）——它必须存在（点开看当时版本、
   分支/重试的时间锚点），但视觉上明确让位给最新轮的完整卡片。
   统一收口在 .artifact-history-markers 容器（消息正文下方，与「已更新」
   标记同区域），不原地留在正文里。 */
.artifact-history-markers { margin: 8px 0 0; display: flex; flex-direction: column; gap: 4px; }
.artifact-history-marker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  margin: 6px 0 0;
  padding: 4px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  font-size: 11.5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.artifact-history-marker:hover { background: var(--sidebar-bg); color: var(--text-2); }
.artifact-history-marker svg { width: 12px; height: 12px; flex-shrink: 0; opacity: 0.6; }
.artifact-history-marker .ahm-name { font-weight: 500; }
.artifact-history-marker .ahm-hint { font-size: 11px; opacity: 0.85; }
