/* 对话式论文工作台：左侧对话，右侧按阶段切换的画布。 */

:root {
  --ink: #1d2426;
  --ink-soft: #5b6a66;
  --ink-faint: #8a9691;
  --paper: #ffffff;
  --canvas: #f4f2ec;
  --line: #e2e0d6;
  --line-strong: #c9c8ba;
  --accent: #116a62;
  --accent-dark: #0b4844;
  --accent-wash: #eaf2ef;
  --warn: #a8632a;
  --danger: #a8443d;
  --ok: #2b6b4f;
  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 8px;
  --ring: 0 0 0 3px rgba(17, 106, 98, 0.18);
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

body {
  background: var(--canvas);
  color: var(--ink);
}

/* ---------- 骨架 ---------- */

/* 三种布局：只有对话（刚进来）/ 对话+画布 / 再加历史侧栏。
   画布在对话开始前不占位，页面一进来是一根居中的对话列。 */
.shell {
  grid-template-columns: minmax(0, 1fr);
  justify-content: center;
  gap: 20px;
  max-width: 1640px;
  height: 100vh;
  min-height: 0;
  margin: auto;
  padding: 20px;
  overflow: hidden;
}

.shell > .composer { max-width: 760px; width: 100%; justify-self: center; }

.shell.rail-open { grid-template-columns: 248px minmax(0, 1fr); }

.shell.has-canvas { grid-template-columns: minmax(380px, 30%) minmax(0, 1fr); }
.shell.has-canvas > .composer { max-width: none; }

.shell.has-canvas.rail-open { grid-template-columns: 248px minmax(340px, 26%) minmax(0, 1fr); }

/* ---------- 历史对话侧栏 ---------- */

.rail {
  min-width: 0;
  min-height: 0;
  display: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 16px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  overflow: hidden;
}
.shell.rail-open > .rail { display: grid; }

.rail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rail-head h2 { font-size: 15px; margin: 0; }
#rail-new { font-size: 12px; min-height: 30px; padding: 5px 10px; white-space: nowrap; }

.rail-list { display: grid; gap: 4px; align-content: start; overflow-y: auto; min-height: 0; }
.rail-empty { margin: 0; font-size: 12px; line-height: 1.7; color: var(--ink-faint); }

.rail-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  text-align: left;
  color: var(--ink-soft);
}
.rail-item:hover { background: #f5f4ee; border-color: var(--line); }
.rail-item.is-active { background: var(--accent-wash); border-color: #bcd6cd; color: var(--accent-dark); }

/* 条目主体是个 button，会继承全局的深色实心按钮样式，
   不覆盖的话整列历史看起来全都是选中态。 */
.rail-item__main {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 0;
  border: 0;
  min-height: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  /* 全局 button 规则带了 justify-content:center，不覆盖的话
     短标题会居中，整列看起来参差不齐。 */
  /* stretch 而不是 start：start 会让标题按内容撑宽，
     text-overflow 的省略号永远不触发，长标题直接顶出侧栏。 */
  justify-items: stretch;
  justify-content: start;
  align-items: start;
}
.rail-item__main > span { max-width: 100%; }
.rail-item__main:hover { transform: none; box-shadow: none; background: transparent; }
.rail-item__title {
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-item__meta { font-size: 11px; color: var(--ink-faint); }
.rail-item.is-active .rail-item__meta { color: var(--accent-dark); opacity: .75; }

.rail-item__remove {
  flex: none;
  min-height: 24px;
  width: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-faint);
  font-size: 15px;
  line-height: 1;
  opacity: 0;
  cursor: pointer;
}
.rail-item:hover .rail-item__remove,
.rail-item__remove:focus-visible { opacity: 1; }
.rail-item__remove:hover { background: #f6e7e5; color: var(--danger); transform: none; box-shadow: none; }

.icon-button {
  flex: none;
  min-height: 30px;
  width: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.icon-button:hover { border-color: var(--accent); color: var(--accent-dark); transform: none; box-shadow: none; }

.workspace { animation: canvas-in 260ms ease both; }
@keyframes canvas-in { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }

.composer {
  min-width: 0;
  min-height: 0;
  padding: 22px;
  /* 用 flex 而不是固定行数的 grid：这一列里 deployment-note、review-form、
     meta 都可能是 hidden，display:none 的元素不占 grid 行，
     1fr 会落到错误的行上，对话区就撑不满、输入框跟着上下跳。 */
  display: flex;
  flex-direction: column;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  overflow: hidden;
}

.intake-panel { flex: 1 1 auto; }

.workspace {
  min-width: 0;
  min-height: 0;
  padding: 0;
  gap: 14px;
  background: transparent;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.brand { gap: 12px; padding-bottom: 16px; }
.brand h1 { font-size: 23px; }
.brand > div { min-width: 0; }
.brand p { margin: 5px 0 0; }
.brand .subtitle { font-size: 12px; color: var(--ink-faint); }

/* ---------- 左：对话 ---------- */

.intake-panel {
  min-height: 0;
  display: grid;
  /* 标题 / 对话区 / 输入框 / 状态：输入框始终贴在同一位置，
     不因为有没有消息而上下跳动。 */
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  gap: 14px;
  color: var(--ink);
}

.chat-area {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.intake-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* 三个子元素（折叠钮 / 标题 / 新对话）配 space-between 会把标题挤到正中，
   让标题自己占满剩余宽度并左对齐。 */
.intake-heading h2 { flex: 1 1 auto; min-width: 0; font-size: 19px; line-height: 1.4; margin: 0; }
.intake-heading button { font-size: 12px; padding: 6px 12px; min-height: 32px; }

.intake-hint,
#intake-status {
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-soft);
  margin: 0;
}

#intake-status:not(:empty) {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-wash);
  color: var(--accent-dark);
}

#intake-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scroll-behavior: smooth;
}

#intake-chat:empty { display: none; }

/* 消息少时沉到输入框附近，像正常聊天工具；
   溢出时 auto 外边距自动归零，不影响滚动。 */
#intake-chat > .intake-message:first-child { margin-top: auto; }

.intake-message {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.75;
  animation: rise 220ms ease both;
}

.intake-message--user {
  margin-left: 14%;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.intake-message--assistant {
  margin-right: 8%;
  background: #f5f4ee;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.intake-message--pending { color: var(--ink-faint); }

.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-faint);
  animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }

@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 空状态 */
.chat-empty {
  /* 只在没有消息时出现，靠下贴近输入框；有消息后由对话流接管这块空间。 */
  margin: auto 0 0;
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fbfaf5;
}
.chat-empty__lead { font-size: 14px; line-height: 1.7; margin: 0; }
.chat-empty__hint { font-size: 12.5px; line-height: 1.7; color: var(--ink-soft); margin: 0; }
.chat-seeds { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }

.seed {
  min-height: 30px;
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-soft);
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  white-space: normal;
}
.seed:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-wash); transform: none; box-shadow: none; }

/* 输入区 */
#intake-form { display: grid; gap: 8px; }

.composer-box {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.composer-box:focus-within { border-color: var(--accent); box-shadow: var(--ring); }

#intake-message {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 12px 13px 6px;
  resize: none;
  line-height: 1.7;
  font-size: 14px;
  max-height: 30vh;
  min-height: 0;
}
#intake-message:focus { outline: none; box-shadow: none; }

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 4px 8px 8px 13px;
}
/* 提示变长（确认后会换成一句解释）时整条独占一行，不去挤发送按钮。 */
.composer-tip { flex: 1 1 auto; min-width: 0; font-size: 11.5px; line-height: 1.6; color: var(--ink-faint); }
#intake-send { flex: none; }
#intake-send { min-width: 78px; min-height: 34px; padding: 0 16px; background: var(--accent); border-color: var(--accent-dark); }

/* ---------- 右：画布 ---------- */

.canvas-rail { min-width: 0; }

.canvas-steps {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.canvas-step {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #faf9f4;
  color: var(--ink-faint);
  font-size: 13px;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease;
}

.canvas-step__no { font-variant-numeric: tabular-nums; font-size: 11px; letter-spacing: .06em; }
.canvas-step__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.canvas-step.is-current {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.canvas-step.is-done {
  background: var(--accent-wash);
  border-color: #bcd6cd;
  color: var(--accent-dark);
}

.canvas-view {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 14px;
  overflow: hidden;
}

/* 交付说明与交付面板都会按任务状态隐藏，display:none 的元素不占 grid 行，
   用固定行数的 grid 时预览会掉回 auto 行、只剩一百多像素高。
   （左栏 .composer 之前踩过同一个坑。）用 flex 才与隐藏无关。 */
#view-paper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#view-paper > .preview-frame { flex: 1 1 auto; min-height: 0; }
#view-paper > .meta,
#view-paper > .intake-delivery-panel { flex: none; }

.intake-summary-panel,
.intake-delivery-panel,
.run-panel {
  min-width: 0;
  min-height: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
}

/* --- 视图 A：需求卡片 --- */

#view-brief .intake-summary-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
  overflow: hidden;
}

.brief-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.brief-head h2 { font-size: 20px; margin: 0; }

.brief-progress {
  margin: 0;
  font-size: 12.5px;
  padding: 5px 11px;
  border-radius: 999px;
  background: #f6ecdf;
  color: var(--warn);
  white-space: nowrap;
}
.brief-progress.is-ready { background: var(--accent-wash); color: var(--accent-dark); }

.brief-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  align-content: start;
  overflow-y: auto;
  padding-right: 4px;
  margin: 0;
}

.brief-card {
  display: grid;
  gap: 7px;
  align-content: start;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fcfbf7;
  transition: border-color 200ms ease, background 200ms ease, box-shadow 200ms ease;
}

.brief-card.is-missing { border-color: #e2c9a6; background: #fffaf2; }
.brief-card.is-wide { grid-column: 1 / -1; }
.brief-card.just-filled { animation: flash 900ms ease both; }

@keyframes flash {
  0% { box-shadow: 0 0 0 0 rgba(17, 106, 98, 0.32); border-color: var(--accent); }
  100% { box-shadow: 0 0 0 8px rgba(17, 106, 98, 0); }
}

.brief-card__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: .02em;
}

.brief-card__req {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #f0e5d4;
  color: var(--warn);
}

.brief-card__value {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 24px;
  padding: 4px 6px;
  margin: -4px -6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: text;
}
.brief-card__value:hover { border-color: var(--line-strong); background: #fff; }
.brief-card__value:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: var(--ring); }
.brief-card__value.is-empty { color: var(--ink-faint); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }

.chip {
  min-height: 32px;
  padding: 5px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.chip:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-dark); transform: none; box-shadow: none; }
.chip.is-on {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: #fff;
}
.chip:disabled { opacity: .5; cursor: not-allowed; }

.brief-footer { display: grid; gap: 10px; }
#intake-confirm {
  width: 100%;
  min-height: 46px;
  background: var(--accent);
  border-color: var(--accent-dark);
  font-size: 15px;
}
#intake-confirm:disabled { background: #d9d8cd; border-color: #cfcec2; color: #7d837c; }

/* --- 视图 B：生成中 --- */

.run-panel {
  /* 第三次踩同一个坑后的结论：这一列的子元素会按状态显隐
     （预算条、run-actions），固定行数的 grid 会把 1fr 分给错的孩子。
     一律 flex，主体区拿 flex:1。 */
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}
.run-panel > .run-body { flex: 1 1 auto; min-height: 0; }
.run-panel > .run-head,
.run-panel > .run-detail,
.run-panel > .run-budget,
.run-panel > .run-actions,
.run-panel > .intake-hint { flex: none; }

.run-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.run-head h2 { font-size: 20px; margin: 0; }
.run-elapsed { margin: 0; font-size: 13px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.run-detail {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--accent-wash);
  color: var(--accent-dark);
  font-size: 13.5px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.run-detail.is-error { background: #fbeeec; color: var(--danger); }

.run-stages {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
  align-content: start;
  overflow-y: auto;
}

.run-stage {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  font-size: 13.5px;
  color: var(--ink-faint);
  border-radius: var(--radius-sm);
}

.run-stage__dot {
  width: 9px;
  height: 9px;
  justify-self: center;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: #fff;
}

.run-stage.is-done { color: var(--ink-soft); }
.run-stage.is-done .run-stage__dot { background: var(--ok); border-color: var(--ok); }

.run-stage.is-current { color: var(--ink); background: #f6f8f6; font-weight: 600; }
.run-stage.is-current .run-stage__dot {
  background: var(--accent);
  border-color: var(--accent);
  animation: pulse 1.4s infinite ease-out;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(17, 106, 98, 0.45); }
  100% { box-shadow: 0 0 0 9px rgba(17, 106, 98, 0); }
}

/* --- 视图 C：论文 --- */

.intake-delivery-panel { display: grid; gap: 8px; padding: 10px 14px; align-content: start; }

/* 质检说明默认收起成一行标题，PDF 才是这一页的主角；没内容时整块消失。 */
.quality-box { display: grid; gap: 6px; }
.quality-box:has(> #quality-notes:empty) { display: none; }
.quality-box > summary { cursor: pointer; font-size: 12.5px; color: var(--warn); }
.quality-box[open] > summary { color: var(--ink-soft); }

.delivery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.intake-downloads { display: flex; gap: 10px; flex-wrap: wrap; }
.intake-downloads a:not([hidden]) {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid #56816a;
  border-radius: var(--radius-sm);
  color: #285b40;
  background: #f0f6ee;
  text-decoration: none;
  font-size: 13.5px;
}
.intake-downloads a:hover { background: #e4efe1; }

.edit-entry { display: block; }
.edit-entry button { min-height: 32px; background: var(--accent-dark); border-color: var(--accent-dark); font-size: 13px; padding: 0 12px; }

#quality-notes:empty { display: none; }
#quality-notes {
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
}
#quality-notes:not(:empty) {
  padding: 8px 11px;
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  background: #fdf8f1;
}

.refine-box { border-top: 1px solid var(--line); padding-top: 6px; display: grid; gap: 8px; }
.refine-box summary { cursor: pointer; font-size: 12.5px; color: var(--accent-dark); }
.refine-box[open] summary { margin-bottom: 2px; }
.refine-box label { font-size: 12.5px; color: var(--ink-soft); }
#refine-focus { border-radius: var(--radius-sm); }
#refine-budget { max-width: 170px; }

.preview-frame {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  overflow: hidden;
}
.preview { width: 100%; height: 100%; min-height: 0; border: 0; display: block; }

/* ---------- 通用 ---------- */

button:disabled { cursor: not-allowed; opacity: .6; }
button:focus-visible,
a:focus-visible,
textarea:focus-visible,
select:focus-visible,
[contenteditable]:focus-visible { outline: 3px solid #7fa690; outline-offset: 2px; }

.meta {
  min-height: 0;
  padding: 7px 11px;
  border-left: 3px solid var(--warn);
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 1080px) {
  /* 窄屏一律单列：侧栏、对话、画布依次堆叠，不再横向挤。 */
  .shell,
  .shell.rail-open,
  .shell.has-canvas,
  .shell.has-canvas.rail-open { grid-template-columns: minmax(0, 1fr); }
  .shell { height: auto; overflow: visible; padding: 14px; }
  .shell > .composer { max-width: none; }
  .rail { max-height: 46vh; }
  .composer, .workspace { min-height: 0; overflow: visible; }
  #intake-chat { max-height: 46vh; }
  .canvas-view, #view-brief .intake-summary-panel, .run-panel { overflow: visible; }
  .brief-grid, .run-stages { overflow: visible; }
  .preview-frame, .preview { min-height: 70vh; }
}

@media (max-width: 560px) {
  .shell { padding: 10px; gap: 12px; }
  .composer, .intake-summary-panel, .intake-delivery-panel, .run-panel { padding: 16px; }
  /* 窄屏也保留阶段名：只剩 01/02/03 时用户根本不知道各是什么。 */
  .canvas-step { padding: 9px 8px; font-size: 12px; gap: 5px; }
  .canvas-step__no { font-size: 10px; }
  .intake-heading h2 { font-size: 17px; }
  .intake-heading button { flex: none; white-space: nowrap; }
  #intake-confirm, #refine-start { width: 100%; }
  .brief-grid { grid-template-columns: 1fr; }
  .brief-head { flex-wrap: wrap; gap: 8px; }
}

@media (max-width: 380px) {
  /* 实在放不下才退化成序号。 */
  .canvas-step__name { display: none; }
  .canvas-step { justify-content: center; }
}

/* 确认前的预期说明：右栏留白处告诉用户点下去会发生什么。 */
.brief-expect {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfaf5;
}
.brief-expect__title { margin: 0; font-size: 13px; color: var(--ink-soft); }
.brief-expect__flow {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.brief-expect__flow li { display: flex; align-items: center; gap: 10px; }
.brief-expect__flow li + li::before { content: "›"; color: var(--ink-faint); }
.brief-expect__note { margin: 0; font-size: 12px; line-height: 1.7; color: var(--ink-faint); }

/* 未送达的消息：保持可见并给出重发入口，不静默回滚。 */
.intake-message--failed {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border-color: #e6cdc9;
  background: #fdf3f1;
  color: var(--danger);
  font-size: 13px;
}

.retry-send {
  flex: none;
  min-height: 28px;
  padding: 3px 11px;
  border: 1px solid var(--danger);
  border-radius: 999px;
  background: #fff;
  color: var(--danger);
  font-size: 12.5px;
  cursor: pointer;
}
.retry-send:hover { background: var(--danger); color: #fff; transform: none; box-shadow: none; }

/* 生成视图：左边阶段流水，右边论文章节逐章成形。 */
.run-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  overflow: hidden;
}
.run-body:has(#run-outline:not([hidden])) { grid-template-columns: minmax(220px, 0.85fr) minmax(0, 1fr); }

.run-outline {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fcfbf7;
}
.run-outline__head {
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.run-outline__count { font-variant-numeric: tabular-nums; color: var(--accent-dark); }
.run-outline__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
  align-content: start;
  overflow-y: auto;
}
.run-chapter {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: baseline;
  gap: 8px;
  padding: 6px 6px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-faint);
}
.run-chapter__mark { justify-self: center; font-size: 11px; }
.run-chapter.is-done { color: var(--ink); background: #f2f7f3; }
.run-chapter.is-done .run-chapter__mark { color: var(--ok); }
.run-chapter.is-writing { color: var(--ink); background: #f6f8f6; font-weight: 600; }
.run-chapter.is-writing .run-chapter__mark { color: var(--accent); }

@media (max-width: 1080px) {
  .run-body, .run-body:has(#run-outline:not([hidden])) { grid-template-columns: 1fr; }
  .run-outline__list { overflow: visible; }
}

/* ---------- 可点的阶段页签 ---------- */

.canvas-step.is-available { cursor: pointer; }
.canvas-step.is-available:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: #f0f5f2;
}
.canvas-step.is-available:focus-visible { outline: 3px solid #7fa690; outline-offset: 2px; }
.canvas-step[aria-disabled="true"]:not(.is-current) { cursor: default; }

/* ---------- 失败后的出路 ---------- */

.run-actions {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fbfaf5;
}
#run-retry {
  justify-self: start;
  min-height: 38px;
  background: var(--paper);
  border: 1px solid var(--accent-dark);
  color: var(--accent-dark);
}
#run-retry:hover { background: var(--accent-wash); transform: none; box-shadow: none; }

/* ---------- 文本卡片的可编辑暗示 ---------- */

.brief-card:hover .brief-card__value.is-editable:not(:focus)::after {
  content: " ✎";
  color: var(--ink-faint);
  font-size: 12px;
}

/* ---------- 交付后的对话动作区 ---------- */
/* 确认之后对话不再是死的：交付完成后在这里继续选「是否打磨」、
   直接输入修改要求，或转去编辑器。 */
.chat-actions {
  display: grid;
  gap: 9px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-bottom-left-radius: 4px;
  background: #f5f4ee;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink);
  animation: rise 220ms ease both;
}
.chat-actions p { margin: 0; }
.chat-actions .chips { margin-top: 2px; }
.chat-actions .chat-actions__note { font-size: 12px; color: var(--ink-faint); }

/* ---------- 限时打磨的预算进度 ---------- */

.run-budget { display: grid; gap: 8px; }
.run-budget__track {
  height: 10px;
  border-radius: 999px;
  background: #eceae1;
  border: 1px solid var(--line);
  overflow: hidden;
}
.run-budget__fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #2f8f7a);
  transition: width 900ms linear;
}
.run-budget__note { margin: 0; font-size: 12.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ---------- 删除对话的二次确认 ---------- */

.rail-item__remove.is-armed {
  opacity: 1;
  width: auto;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  white-space: nowrap;
}
