/* CosmoSpark V4 progressive evaluation panel — 复用 v4-shell.css 变量；无 v4 变量时（/app）有回退值。 */
.cp-panel {
  --cp-accent: var(--v4-accent, #0a7d55);
  --cp-ink: var(--v4-ink, #13202e);
  --cp-muted: var(--v4-ink-muted, #5b6b7e);
  --cp-line: var(--v4-hairline, #dfe5ed);
  --cp-surface: var(--v4-surface-1, #ffffff);
  --cp-surface-2: var(--v4-surface-2, #f3f6fa);
  --cp-r: var(--v4-r-lg, 16px);
  --cp-ease: var(--v4-ease, cubic-bezier(.2, .8, .2, 1));
  box-sizing: border-box;
  margin: 0 0 var(--v4-s4, 16px);
  padding: var(--v4-s4, 16px);
  border: 1px solid var(--cp-line);
  border-radius: var(--cp-r);
  background: var(--cp-surface);
  color: var(--cp-ink);
  font-family: var(--v4-font, system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif);
  font-size: 14px;
  line-height: 1.6;
  box-shadow: var(--v4-e2, 0 10px 30px -12px rgba(0, 0, 0, .25));
}
.cp-panel *, .cp-panel *::before, .cp-panel *::after { box-sizing: border-box; }
.cp-head { display: flex; align-items: center; gap: 14px; }
.cp-head-text { flex: 1; min-width: 0; }
.cp-title { font-weight: 650; font-size: 15px; }
.cp-eta { color: var(--cp-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.cp-close { border: 0; background: transparent; color: var(--cp-muted); font-size: 20px; cursor: pointer; padding: 4px 8px; }

/* 倒计时环 */
.cp-ring { --p: 0; position: relative; width: 52px; height: 52px; flex: none; }
.cp-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.cp-ring circle { fill: none; stroke-width: 4; }
.cp-ring-bg { stroke: var(--cp-line); }
.cp-ring-fg {
  stroke: var(--cp-accent); stroke-linecap: round;
  stroke-dasharray: 119.4; stroke-dashoffset: calc(119.4 * (1 - var(--p)));
  transition: stroke-dashoffset .9s linear;
}
.cp-ring.is-over svg { animation: cp-spin 1.4s linear infinite; }
.cp-ring.is-over .cp-ring-fg { stroke-dasharray: 30 90; }
.cp-ring-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 600 12px/1 var(--v4-mono, ui-monospace, monospace); font-variant-numeric: tabular-nums;
}

/* 阶段时间线 */
.cp-timeline { display: flex; gap: 6px; margin: 14px 0 8px; padding: 0; list-style: none; overflow-x: auto; scrollbar-width: none; }
.cp-step { display: flex; align-items: center; gap: 6px; flex: 1 0 auto; color: var(--cp-muted); font-size: 12.5px; white-space: nowrap; }
.cp-step i { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--cp-line); flex: none; }
.cp-step.is-done { color: var(--cp-ink); }
.cp-step.is-done i { background: var(--cp-accent); border-color: var(--cp-accent); }
.cp-step.is-active { color: var(--cp-accent); font-weight: 600; }
.cp-step.is-active i { border-color: var(--cp-accent); animation: cp-pulse 1.2s var(--cp-ease) infinite; }
.cp-bar { height: 3px; border-radius: 3px; background: var(--cp-line); overflow: hidden; }
.cp-bar span { display: block; height: 100%; width: 0; background: var(--cp-accent); transition: width .9s linear; }

/* 实时思考 */
.cp-thinking { margin-top: 12px; border: 1px dashed var(--cp-line); border-radius: 10px; background: var(--cp-surface-2); }
.cp-thinking summary { cursor: pointer; padding: 8px 12px; font-size: 13px; font-weight: 600; list-style-position: inside; }
.cp-thinking summary small { font-weight: 400; color: var(--cp-muted); margin-left: 6px; }
.cp-thinking-body {
  max-height: 160px; overflow-y: auto; padding: 0 12px 10px; white-space: pre-wrap; word-break: break-word;
  font: 12.5px/1.65 var(--v4-mono, ui-monospace, monospace); color: var(--cp-muted);
}
.cp-thinking-body:empty::before { content: "等待模型开始思考…"; opacity: .7; }

/* 分段披露卡片 */
.cp-sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.cp-sections:empty { display: none; }
.cp-card {
  padding: 10px 12px; border: 1px solid var(--cp-line); border-radius: 12px; background: var(--cp-surface);
  animation: cp-in .32s var(--cp-ease) both; overflow-wrap: anywhere;
}
.cp-card small { display: block; color: var(--cp-muted); font-size: 12px; margin-bottom: 4px; }
.cp-card ul { margin: 0; padding-left: 18px; }
.cp-card.is-warn { border-style: dashed; }
.cp-muted { color: var(--cp-muted); }
.cp-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 12px; font-size: 12px; color: var(--cp-muted); }
.cp-notify { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.cp-panel.is-complete .cp-step i { animation: none; }

/* 页面原有 spinner 卡片在进度面板出现后隐藏（骨架屏保留） */
.has-progress > .loading-card { display: none; }

/* /app 浮动坞 */
.cp-dock { position: fixed; right: 16px; bottom: 56px; z-index: 9991; width: min(420px, calc(100vw - 24px)); max-height: min(70vh, 640px); overflow-y: auto; margin: 0; }
.cp-dock.is-min .cp-timeline, .cp-dock.is-min .cp-bar, .cp-dock.is-min .cp-thinking, .cp-dock.is-min .cp-sections, .cp-dock.is-min .cp-foot { display: none; }
.cp-chip {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 9991;
  padding: 8px 14px; border-radius: 999px; background: var(--v4-surface-2, #111b29); color: var(--v4-ink, #eef4ff);
  border: 1px solid var(--v4-accent-line, rgba(78, 225, 160, .38)); font-size: 13px; text-decoration: none; white-space: nowrap;
}

@media (max-width: 640px) {
  .cp-panel { padding: 12px; }
  .cp-ring { width: 44px; height: 44px; }
  .cp-sections { grid-template-columns: 1fr; }
  .cp-dock { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: auto; max-height: 60vh; }
  /* 收起态不再是通栏底栏：缩成右下角小块，盖不住左列的开始检测按钮。 */
  .cp-dock.is-min { left: auto; right: 12px; width: auto; max-width: calc(100vw - 24px); }
  .cp-notify { margin-left: 0; }
}

@keyframes cp-spin { to { transform: rotate(270deg); } }
@keyframes cp-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(78, 225, 160, .45); } 50% { box-shadow: 0 0 0 5px rgba(78, 225, 160, 0); } }
@keyframes cp-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .cp-ring-fg, .cp-bar span { transition: none; }
  .cp-ring.is-over svg, .cp-step.is-active i, .cp-card { animation: none; }
}
