/* AI 反馈卡（二期确认点 checkpoint.confirm）——规格对齐原型
   docs/feat/prototypes/ai-feedback-card.html */

.fb-card {
  background: var(--bg3, #f4f5f7);
  border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px;
  padding: 16px 18px;
  width: 100%;
  max-width: 720px;
  box-sizing: border-box;
  /* 右下角拖大：仅高度（宽度锁聊天列），对齐原型 */
  display: flex; flex-direction: column;
  resize: vertical; overflow: hidden;
  min-height: 320px; max-height: 85vh;
}
.fb-card.fb-readonly { resize: none; }
.fb-head, .fb-supp, .fb-btns { flex-shrink: 0; }

/* 流式骨架：大纲生成期间的占位卡（内容复用 o-card 流式渲染器） */
.fb-card.fb-streaming { min-height: 200px; }
.fb-card.fb-streaming .fb-stream-oc {
  flex: 1 1 auto; min-height: 0;
  border: none; background: transparent; padding: 0;
  overflow-y: auto; overscroll-behavior: contain;
}

/* ── confirm_action 计划卡：agent 自写 markdown 的语义映射 ─────── */
.fb-card.fb-danger { border-color: #d9534f; }
.fb-card.fb-danger .fb-title { color: #d9534f; }
.fb-action-md {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; line-height: 1.7; color: var(--text);
}
.fb-action-md .md-h1 { font-size: 15px; font-weight: 700; margin-top: 4px; }
.fb-action-md .md-h { font-size: 13px; font-weight: 600; color: var(--accent2); margin-top: 6px; }
.fb-action-md .md-kv { display: flex; gap: 10px; align-items: baseline; }
.fb-action-md .md-kv .k { flex-shrink: 0; min-width: 64px; color: var(--text3); font-size: 12px; }
.fb-action-md .md-kv .v { flex: 1; min-width: 0; }
.fb-action-md .md-ul, .fb-action-md .md-ol { margin: 2px 0 2px 4px; padding-left: 18px; }
.fb-action-md .md-quote {
  background: var(--bg4); border-left: 3px solid var(--accent2);
  border-radius: 0 6px 6px 0; padding: 6px 10px; color: var(--text2);
}
.fb-action-md .md-warn { color: #d9534f; font-weight: 500; }
.fb-action-md .md-p { color: var(--text2); }
.fb-action-md .md-chip {
  font-size: 11px; background: var(--bg4); border: 1px solid var(--border);
  border-radius: 4px; padding: 0 5px; color: var(--text2);
  font-family: inherit;
}
.fb-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.fb-title { font-size: 13px; font-weight: 600; color: var(--accent2); }
.fb-round {
  font-size: 11px; font-weight: 500; color: var(--accent2);
  background: var(--bg4); border: 1px solid var(--border);
  border-radius: 10px; padding: 2px 8px;
}
.fb-round-hint { font-size: 11px; color: var(--text3); margin-left: auto; }

/* 摘要区：flex 撑满卡内剩余高度（卡可拖大，列表内滚） */
.fb-summary {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; position: relative;
  flex: 1 1 auto; min-height: 140px;
  display: flex; flex-direction: column; overflow: hidden;
}
.fb-summary .fb-summary-head { flex-shrink: 0; }
.fb-summary-head {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px;
  padding-bottom: 8px; border-bottom: 1px dashed var(--border);
}
.fb-summary-title { font-size: 14px; font-weight: 600; }
.fb-summary-meta { font-size: 11px; color: var(--text3); }
.fb-items {
  display: flex; flex-direction: column; gap: 2px;
  flex: 1 1 auto; min-height: 0;
  max-height: 340px;
  overflow-y: auto; overscroll-behavior: contain;
}
/* 用户拖大卡片（inline height 出现）后解除内容区上限——内容随卡增长，
   仍受卡片自身 max-height(85vh) 约束。默认 340px 让卡保持紧凑，长内容内滚。 */
.fb-card[style*="height"] .fb-items { max-height: none; }
.fb-items::-webkit-scrollbar { width: 5px; }
.fb-items::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.fb-items::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* 行：grid 四列（序号/标题/type/操作），brief 次行 */
.fb-item {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  column-gap: 10px; row-gap: 2px;
  padding: 6px 8px; border-radius: 6px;
  font-size: 13px; line-height: 1.6; align-items: center;
}
.fb-item:hover { background: var(--bg3); }
.fb-item .idx {
  width: 20px; height: 20px; flex-shrink: 0;
  background: var(--bg4); border-radius: 6px; font-size: 11px; color: var(--text2);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: grab;
}
.fb-item .idx:active { cursor: grabbing; }
.fb-item .ttl { min-width: 0; }
.fb-item .type {
  font-size: 10px; color: var(--text3); border: 1px solid var(--border);
  border-radius: 4px; padding: 0 5px; align-self: center; flex-shrink: 0;
}
.fb-item .brief {
  grid-column: 2 / -1; font-size: 11px; color: var(--text3); cursor: text;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fb-item .brief:hover { color: var(--text2); }
.fb-item .brief.brief-edited::after {
  content: "已编辑"; font-size: 10px; color: var(--accent2);
  border: 1px solid var(--accent2); border-radius: 4px; padding: 0 4px; margin-left: 8px;
}
.fb-item.changed .idx { background: var(--accent); color: #fff; }
.fb-item.changed .ttl::after {
  content: "已修改"; font-size: 10px; color: var(--accent2);
  border: 1px solid var(--accent2); border-radius: 4px; padding: 0 4px; margin-left: 6px;
}
.fb-item.added .ttl::before {
  content: "新增"; font-size: 10px; color: #2e7d32;
  border: 1px solid #2e7d32; border-radius: 4px; padding: 0 4px; margin-right: 6px;
}

/* 行操作（悬停显）+ 拖动态 */
.fb-item { position: relative; }
.fb-item .row-acts { display: none; gap: 4px; align-items: center; }
.fb-item:hover .row-acts { display: flex; }
.row-act {
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text2); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1; user-select: none;
}
.row-act:hover { border-color: var(--accent2); color: var(--text); }
.fb-item.dragging {
  opacity: .45; background: var(--bg4);
  outline: 1.5px dashed var(--accent2); outline-offset: -1.5px;
}
.fb-item.drag-over-top { box-shadow: 0 -2px 0 0 var(--accent); }
.fb-item.drag-over-bottom { box-shadow: 0 2px 0 0 var(--accent); }

/* 加一页 */
.fb-add-row {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px dashed var(--border); border-radius: 8px; padding: 7px;
  font-size: 12px; color: var(--text2); cursor: pointer; margin-top: 6px;
  transition: all .15s;
}
.fb-add-row:hover { border-color: var(--accent2); color: var(--accent2); }

/* 行内展开双字段编辑器 */
.fb-editor {
  grid-column: 1 / -1;
  background: var(--bg3); border: 1px solid var(--accent2); border-radius: 8px;
  padding: 10px; display: flex; flex-direction: column; gap: 8px; margin-top: 4px;
}
.fb-editor .ed-title {
  width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 13px; font-weight: 500; color: var(--text);
  font-family: inherit; outline: none;
}
.fb-editor .ed-title:focus { border-color: var(--text); }
.fb-editor .ed-brief {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 72px; max-height: 144px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-size: 12px; line-height: 1.6; color: var(--text);
  font-family: inherit; outline: none;
}
.fb-editor .ed-brief:focus { border-color: var(--text); }
.fb-editor .ed-brief::placeholder { color: var(--text3); }
.fb-editor .ed-foot { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.fb-editor .ed-count { font-size: 10px; color: var(--text3); margin-right: auto; }
.fb-editor .ed-btn {
  font-size: 12px; padding: 4px 14px; border-radius: 6px; cursor: pointer;
  font-family: inherit; border: 1px solid var(--border); background: var(--bg2); color: var(--text);
}
.fb-editor .ed-btn.primary { background: var(--text); color: var(--bg2); border-color: var(--text); }
.fb-editor .ed-btn:hover { opacity: .88; }

/* 意见行（复用澄清卡补充行设计：textarea + 附件按钮 + chips） */
.fb-supp { margin-top: 12px; }
.fb-supp-row { display: flex; align-items: stretch; gap: 8px; }
.fb-supp-row .fb-supp-ta {
  flex: 1; resize: vertical; min-height: 48px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; font-size: 13px; color: var(--text);
  font-family: inherit; outline: none;
}
.fb-supp-row .fb-supp-ta:focus { border-color: var(--text); }
.fb-supp-row .fb-supp-ta::placeholder { color: var(--text3); }
.fb-attach-btn {
  flex-shrink: 0; width: 40px; display: inline-flex; align-items: center;
  justify-content: center; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text2); cursor: pointer;
  transition: border-color .15s, color .15s;
}
.fb-attach-btn:hover { border-color: var(--text2); color: var(--text); }
.fb-attach-btn:disabled { opacity: .4; cursor: not-allowed; }
.fb-supp .attach-bar-wrap { margin-top: 8px; }

/* 按钮区 */
.fb-btns {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px;
  padding-top: 12px; border-top: 1px solid var(--border); align-items: center;
}
.fb-btns .btn {
  font-size: 13px; font-weight: 500; padding: 8px 20px; border-radius: 8px;
  cursor: pointer; font-family: inherit; transition: all .15s; line-height: 1.4;
}
.fb-btns .btn.pr { background: var(--text); color: var(--bg2); border: 1px solid var(--text); }
.fb-btns .btn.pr:hover { opacity: .88; }
.fb-btns .btn.gh { background: var(--bg2); color: var(--text); border: 1px solid var(--border); }
.fb-btns .btn.gh:hover { border-color: var(--text2); }
.fb-dirty { font-size: 11px; color: var(--accent2); margin-right: auto; }

/* 提交后锁定 */
.fb-card.fb-readonly { opacity: .65; filter: grayscale(.25); pointer-events: none; }
.fb-card.fb-readonly .fb-btns, .fb-card.fb-readonly .fb-supp { display: none; }
.fb-note {
  display: none; font-size: 11px; color: var(--text3); margin-top: 8px;
  padding: 6px 10px; background: var(--bg2); border-radius: 6px;
}
.fb-card.fb-readonly .fb-note { display: block; }

/* 通用确认卡（非 plan_outline 的所有工具） */
.fb-generic-card {
  display: flex; align-items: center; gap: 12px; padding: 16px;
}
.fb-generic-icon {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg4); color: var(--accent2); font-size: 14px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.fb-generic-label { font-size: 14px; font-weight: 500; color: var(--text); }

/* ── 四期 before 卡：执行确认（调用摘要） ─────────────────────── */
.fb-before-body .fb-items { display: flex; flex-direction: column; gap: 10px; }
.bc-call {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px;
}
.bc-call-name { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.bc-call-tool { font-size: 11px; color: var(--text3); margin-left: 8px; font-weight: 400; }
.bc-args { display: flex; flex-direction: column; gap: 4px; }
.bc-arg { display: flex; gap: 8px; font-size: 12px; line-height: 1.6; }
.bc-arg-k { color: var(--text3); flex-shrink: 0; min-width: 60px; font-family: ui-monospace, monospace; }
.bc-arg-v { flex: 1; min-width: 0; word-break: break-all; color: var(--text2); }
.bc-arg-preview { color: var(--text3); }
.bc-arg-more {
  background: none; border: none; color: var(--accent2); font-size: 11px;
  cursor: pointer; padding: 0 0 0 6px; font-family: inherit;
}
.bc-arg-full {
  margin-top: 4px; white-space: pre-wrap; background: var(--bg3);
  border-radius: 6px; padding: 8px 10px; font-size: 11px; max-height: 200px;
  overflow-y: auto; font-family: ui-monospace, monospace; color: var(--text);
}
.bc-args-empty { font-size: 12px; color: var(--text3); }

/* grant_writes 勾选（计划卡） */
.fb-grant-row {
  display: flex; align-items: center; gap: 7px; margin-top: 8px;
  font-size: 12px; color: var(--text2); cursor: pointer; user-select: none;
}
.fb-grant-row input { accent-color: var(--accent2, #3562d4); }

/* 摘要行（before/通用 after 卡，payload.summary 或默认拼接） */
.bc-summary {
  font-size: 13.5px; font-weight: 500; color: var(--text);
  padding: 2px 2px 10px; border-bottom: 1px dashed var(--border); margin-bottom: 10px;
}

/* 大纲卡（有投影）的模板叠加区：渲染在可编辑页列表上方 */
.fb-outline-tpl {
  padding: 2px 2px 10px; margin-bottom: 4px;
  border-bottom: 1px dashed var(--border);
}
