/* ============================================================
   Layout + Components
   ============================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: var(--fs-md);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1,h2,h3,h4 { margin: 0; font-weight: 650; color: var(--text); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--text-3); }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: #10152b;
  color: #c7cde0;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar__logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), #6f7cf0);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
  flex: none;
}
.sidebar__brand b { color: #fff; font-size: 15px; letter-spacing: .2px; }
.sidebar__brand span { display: block; font-size: 11px; color: #8b93b3; }
.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav__group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6b7392; padding: 14px 12px 6px; }
.nav__item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 8px; color: #c1c7dc;
  font-size: var(--fs-md); margin-bottom: 2px; transition: background .12s, color .12s;
}
.nav__item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav__item.active { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.nav__item svg { width: 18px; height: 18px; flex: none; }
.nav__item .badge { margin-left: auto; }
.sidebar__foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.07); font-size: 11px; color: #6b7392; }

/* ---------- Topbar ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
}
.crumbs { display: flex; align-items: center; gap: 7px; font-size: var(--fs-sm); color: var(--text-3); min-width: 0; }
.crumbs a:hover { color: var(--brand); }
.crumbs b { color: var(--text); font-weight: 600; }
.crumbs .sep { color: var(--border-strong); }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.role-select {
  display: flex; align-items: center; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 6px 5px 12px; font-size: var(--fs-sm);
}
.role-select select { border: none; background: transparent; font: inherit; color: var(--text); outline: none; cursor: pointer; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}

/* ---------- Content ---------- */
.content { padding: 24px 28px 60px; max-width: 1320px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-head h1 { font-size: var(--fs-2xl); }
.page-head .sub { color: var(--text-3); font-size: var(--fs-sm); margin-top: 3px; }
.page-head__actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card__head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card__head h3 { font-size: var(--fs-lg); }
.card__head .sub { color: var(--text-3); font-size: var(--fs-xs); }
.card__head .spacer { margin-left: auto; }
.card__body { padding: 20px; }
.card__body.tight { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1080px){ .grid.cols-4{grid-template-columns:repeat(2,1fr);} .grid.cols-3{grid-template-columns:repeat(2,1fr);} }
@media (max-width: 720px){ .grid.cols-2,.grid.cols-3,.grid.cols-4{grid-template-columns:1fr;} .shell{grid-template-columns:1fr;} .sidebar{display:none;} }

/* ---------- Stat tiles ---------- */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm); }
.stat__label { color: var(--text-3); font-size: var(--fs-sm); display: flex; align-items: center; gap: 8px; }
.stat__value { font-size: 30px; font-weight: 700; margin-top: 8px; letter-spacing: -.5px; }
.stat__foot { font-size: var(--fs-xs); color: var(--text-3); margin-top: 4px; }
.stat__ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-050); color: var(--brand); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm); font-size: var(--fs-md); font-weight: 550;
  transition: background .12s, border-color .12s, box-shadow .12s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-600); }
.btn--success { background: var(--success); border-color: var(--success); color: #fff; }
.btn--success:hover { filter: brightness(.96); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--neutral-bg); }
.btn--danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn--danger:hover { background: var(--danger-bg); }
.btn--sm { padding: 5px 10px; font-size: var(--fs-sm); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.tbl th { text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 600; padding: 11px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: var(--fs-sm); }
.row-link { cursor: pointer; }

/* ---------- Tags / badges ---------- */
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--neutral-bg); color: var(--text-2); white-space: nowrap; }
.tag--success { background: var(--success-bg); color: var(--success); }
.tag--warning { background: var(--warning-bg); color: var(--warning); }
.tag--danger  { background: var(--danger-bg);  color: var(--danger); }
.tag--info    { background: var(--info-bg);    color: var(--info); }
.tag--brand   { background: var(--brand-050);  color: var(--brand-700); }
.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge { background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; min-width: 18px; text-align: center; }
.badge--muted { background: rgba(255,255,255,.14); }
.pill { font-family: var(--mono); font-size: var(--fs-xs); background: var(--neutral-bg); padding: 2px 7px; border-radius: 5px; color: var(--text-2); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; color: var(--text); background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-050); }
.textarea { resize: vertical; min-height: 76px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- Steps (pipeline progress) ---------- */
.steps { display: flex; gap: 0; overflow-x: auto; padding: 6px 0 2px; }
.step { display: flex; flex-direction: column; align-items: center; text-align: center; flex: 1; min-width: 120px; position: relative; padding: 0 4px; }
.step__dot {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: var(--fs-sm); font-weight: 700; background: var(--surface); border: 2px solid var(--border-strong); color: var(--text-3); position: relative; z-index: 1;
}
.step__body { padding-top: 8px; min-width: 0; max-width: 100%; }
.step__title { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); line-height: 1.3; }
.step__meta { font-size: 11px; color: var(--text-3); margin-top: 1px; }
/* 連接線畫在兩個圓點中心之間（圓點 z-index 較高會蓋住，不會壓到下方文字） */
.step::after { content: ""; position: absolute; top: 16px; left: 50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.step:last-child::after { display: none; }
.step__dot svg { width: 16px; height: 16px; }
.step--done .step__dot { background: var(--success); border-color: var(--success); color: #fff; }
.step--done::after { background: var(--success); }
.step--active .step__dot { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 0 0 4px var(--brand-050); }
.step--active .step__title { color: var(--text); }
.step--skipped .step__dot { border-style: dashed; }
.step--skipped .step__title { text-decoration: line-through; color: var(--text-3); }

/* ---------- Progress bar ---------- */
.progress { height: 7px; border-radius: 999px; background: var(--neutral-bg); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .3s; }

/* ---------- 圓點進度（研究專案列表） ---------- */
.pdots { display: flex; align-items: center; gap: 12px; }
.pdots__row { display: inline-flex; align-items: flex-start; min-height: 30px; }
.pdots__step { position: relative; display: inline-flex; flex-direction: column; align-items: center; width: 30px; }
.pdots__dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); position: relative; z-index: 1; }
.pdots__step::after { content: ""; position: absolute; top: 6px; left: 50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.pdots__step:last-child::after { display: none; }
.pdots__step--done .pdots__dot { background: var(--brand); border-color: var(--brand); }
.pdots__step--done::after { background: var(--brand); }
.pdots__step--skipped .pdots__dot { border-style: dashed; background: var(--neutral-bg); }
.pdots__step--active .pdots__dot { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px var(--brand-050); }
.pdots__lbl { position: absolute; top: 17px; white-space: nowrap; font-size: 11px; font-weight: 600; color: var(--brand-700); }
.pdots__pct { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-2); flex: none; }

/* ---------- HITL stage ---------- */
.stage-panel { display: flex; flex-direction: column; gap: 16px; }
.hitl-plan { border: 1px solid var(--brand-100); background: var(--brand-050); border-radius: var(--radius); padding: 16px 18px; }
.hitl-plan h4 { color: var(--brand-700); display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.hitl-plan ol { margin: 0; padding-left: 20px; }
.hitl-plan li { margin: 6px 0; color: var(--text-2); }
.step-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.step-card__head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.step-card__head .n { width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 700; flex: none; }
.step-card__head h4 { font-size: var(--fs-md); }
.step-card__head .spacer { margin-left: auto; }
.step-card__body { padding: 16px; }
.step-card.pending { opacity: .55; }
.step-card.pending .step-card__head .n { background: var(--border-strong); }

/* thinking / typing */
.thinking { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: var(--fs-sm); padding: 8px 0; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.dots::after { content: "…"; animation: dots 1.4s steps(4,end) infinite; }
@keyframes dots { 0%{content:"";} 25%{content:"·";} 50%{content:"··";} 75%{content:"···";} }

/* result blocks */
.result-block { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.result-block__head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 600; font-size: var(--fs-sm); }
.result-block__body { padding: 14px; }
.doc { font-size: var(--fs-md); color: var(--text-2); line-height: 1.7; }
.doc h5 { color: var(--text); margin: 14px 0 6px; font-size: var(--fs-md); }
.doc p { margin: 0 0 10px; }
.doc ul { margin: 6px 0; padding-left: 20px; }
.figure { text-align: center; }
.figure svg { max-width: 100%; height: auto; }
.figure figcaption { font-size: var(--fs-xs); color: var(--text-3); margin-top: 8px; }

/* ---------- Empty / callout ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty svg { width: 44px; height: 44px; opacity: .5; margin-bottom: 12px; }
.callout { display: flex; gap: 12px; padding: 13px 16px; border-radius: var(--radius); font-size: var(--fs-sm); border: 1px solid; }
.callout--info { background: var(--info-bg); border-color: #bcd8f8; color: #1a4f8a; }
.callout--warning { background: var(--warning-bg); border-color: #f3d9a8; color: #8a5a00; }
.callout--success { background: var(--success-bg); border-color: #b6e5d0; color: #12694a; }
.callout svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(16,21,43,.5); display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column; animation: pop .14s; }
.modal.lg { max-width: 780px; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal__head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal__head h3 { font-size: var(--fs-lg); }
.modal__head .close { margin-left: auto; background: none; border: none; color: var(--text-3); font-size: 22px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.modal__head .close:hover { background: var(--neutral-bg); color: var(--text); }
.modal__body { padding: 22px; overflow-y: auto; }
.modal__foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--border); }

/* ---------- Toast ---------- */
#toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--text); color: #fff; padding: 11px 16px; border-radius: var(--radius-sm); font-size: var(--fs-sm); box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 9px; animation: slidein .18s; max-width: 340px; }
.toast--success { background: #15694a; }
.toast--error { background: #b23434; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

/* ---------- Misc ---------- */
.muted { color: var(--text-3); }
.mono { font-family: var(--mono); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 16px; font-size: var(--fs-md); }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.text-c { text-align: center; }
.w-100 { width: 100%; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 12px; } .mb-2 { margin-bottom: 12px; }
/* ---------- MOA 版面：左目錄 + 可收合卡片 ---------- */
.moa-layout { display: flex; gap: 20px; align-items: flex-start; }
.moa-content { flex: 1; min-width: 0; }
.moa-toc { width: 208px; flex: none; position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 12px; box-shadow: var(--shadow-sm); }
.moa-toc__head { font-weight: 650; font-size: var(--fs-sm); display: flex; align-items: center; gap: 6px; margin-bottom: 10px; color: var(--text-2); }
.moa-toc__head svg { width: 16px; height: 16px; }
.moa-toc__tools { display: flex; gap: 6px; margin-bottom: 8px; }
.moa-toc__tools .btn { flex: 1; padding: 4px 6px; font-size: 11px; justify-content: center; }
.moa-toc__list { list-style: none; margin: 0; padding: 0; }
.moa-toc__item { display: flex; gap: 8px; align-items: flex-start; width: 100%; text-align: left; border: none; background: none; padding: 6px 8px; border-radius: 6px; font-size: var(--fs-sm); color: var(--text-2); line-height: 1.35; cursor: pointer; }
.moa-toc__item:hover { background: var(--brand-050); color: var(--brand-700); }
.moa-toc__n { flex: none; width: 18px; height: 18px; border-radius: 5px; background: var(--neutral-bg); color: var(--text-3); font-size: 11px; display: grid; place-items: center; margin-top: 1px; }
@media (max-width: 960px) { .moa-toc { display: none; } }

/* 收合 / 展開 */
.doc-card { scroll-margin-top: 76px; }
.doc-head h3 { cursor: pointer; }
.doc-toggle { border: none; background: none; color: var(--text-3); cursor: pointer; padding: 2px; margin-right: 2px; display: inline-flex; }
.doc-toggle svg { width: 18px; height: 18px; transition: transform .15s; }
.doc-card .doc-toggle svg { transform: rotate(90deg); }
.doc-card.collapsed .doc-toggle svg { transform: rotate(0deg); }
.doc-card.collapsed > .card__body { display: none; }

/* ---------- Markdown 文件卡片 ---------- */
.doc-card .card__head h3 { font-size: var(--fs-md); }
.doc-card .md-body { max-height: 560px; overflow: auto; }
.md-body h1 { font-size: 20px; margin: 14px 0 8px; }
.md-body h2 { font-size: 17px; margin: 14px 0 6px; }
.md-body h3 { font-size: 15px; margin: 12px 0 6px; }
.md-body h4, .md-body h5, .md-body h6 { font-size: 14px; margin: 10px 0 4px; }
.md-body > :first-child { margin-top: 0; }
.md-body p { margin: 0 0 10px; color: var(--text-2); }
.md-body ul, .md-body ol { margin: 6px 0 10px; padding-left: 22px; color: var(--text-2); }
.md-body li { margin: 3px 0; }
.md-body blockquote { border-left: 3px solid var(--border-strong); margin: 10px 0; padding: 4px 14px; color: var(--text-3); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.md-body a { color: var(--brand); text-decoration: underline; }
.md-body code { font-family: var(--mono); font-size: .9em; background: var(--neutral-bg); padding: 1px 5px; border-radius: 4px; }
.md-body pre.code-block { background: #0f1729; color: #e6edf7; padding: 12px 14px; border-radius: 8px; overflow: auto; font-family: var(--mono); font-size: 12px; margin: 10px 0; }
.md-body pre.code-block code { background: none; padding: 0; }
.md-body table.tbl { margin: 10px 0; }

/* ---------- WYSIWYG 編輯 ---------- */
.doc-card.editing { box-shadow: 0 0 0 2px var(--brand-100); }
.doc-seg { margin-bottom: 12px; }
.prose-edit { border: 1px dashed var(--border-strong); border-radius: 8px; padding: 10px 14px; min-height: 40px; background: var(--surface); max-height: 420px; overflow: auto; }
.prose-edit:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-050); }
.edit-tbl th, .edit-tbl td { position: relative; }
.edit-tbl .cell { min-width: 56px; padding: 3px 5px; border-radius: 4px; outline: none; }
.edit-tbl .cell:focus { box-shadow: 0 0 0 2px var(--brand-050); background: #fff; }
.cellctl { border: none; background: var(--neutral-bg); color: var(--text-3); border-radius: 5px; width: 20px; height: 20px; line-height: 1; cursor: pointer; font-size: 13px; margin-left: 4px; padding: 0; }
.cellctl:hover { background: var(--danger-bg); color: var(--danger); }
.cellctl.add:hover { background: var(--brand-050); color: var(--brand); }
.edit-tbl .rowctl { width: 30px; text-align: center; background: var(--surface-2); }

/* ---------- Diff ---------- */
.diff { font-family: var(--mono); font-size: 12px; border: 1px solid var(--border); border-radius: 8px; overflow: auto; max-height: 420px; }
.diff-line { padding: 1px 10px; white-space: pre-wrap; word-break: break-word; display: flex; gap: 8px; }
.diff-mark { width: 10px; color: var(--text-3); flex: none; text-align: center; }
.diff-add { background: #e6f6ef; }
.diff-del { background: #fdecec; }
.diff-ctx { color: var(--text-3); }

/* ---------- 簽核鏈 ---------- */
.chain { display: flex; flex-direction: column; gap: 8px; }
.chain__row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.chain__row .avatar { width: 30px; height: 30px; font-size: 12px; }
.chain__row--active { border-color: #f3d9a8; background: var(--warning-bg); }
.chain__row--done { border-color: #b6e5d0; background: var(--success-bg); }
.chain__row--reject { border-color: #f3c0c0; background: var(--danger-bg); }
.chain-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }

/* ---------- Agent 執行終端（黑框） ---------- */
.agent-console { background: #0d1017; border: 1px solid #1e2530; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-sm); }
.agent-console__bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: #12182400; border-bottom: 1px solid #1e2530; }
.ac-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.ac-dot.r { background: #ff5f57; } .ac-dot.y { background: #febc2e; } .ac-dot.g { background: #28c840; }
.ac-title { margin-left: 8px; font-family: var(--mono); font-size: 12px; color: #6b7392; }
.agent-console__body { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; color: #c7cde0; padding: 12px 14px; max-height: 320px; overflow: auto; }
.ac-line { display: flex; gap: 8px; white-space: pre-wrap; word-break: break-word; padding: 1px 0; animation: acin .12s ease-out; }
@keyframes acin { from { opacity: 0; transform: translateY(2px); } }
.ac-pre { flex: none; width: 34px; text-align: left; opacity: .9; }
.ac-think { color: #8b93b3; } .ac-think .ac-pre { color: #6b7392; }
.ac-db   { color: #67e8f9; } .ac-db .ac-pre { color: #22d3ee; }
.ac-tool { color: #c4b5fd; } .ac-tool .ac-pre { color: #a78bfa; }
.ac-ok   { color: #86efac; } .ac-ok .ac-pre { color: #4ade80; }
.ac-warn { color: #fcd34d; } .ac-warn .ac-pre { color: #fbbf24; }
.ac-cursor { display: inline-block; color: #67e8f9; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.trace-wrap { margin-top: 8px; }
.trace-toggle { border: none; background: none; color: var(--text-3); cursor: pointer; font-size: var(--fs-sm); padding: 4px 2px; display: inline-flex; align-items: center; gap: 6px; }
.trace-toggle::before { content: "▸"; transition: transform .15s; display: inline-block; }
.trace-toggle.open::before { transform: rotate(90deg); }
.trace-toggle:hover { color: var(--brand); }
.agent-trace { margin-top: 8px; }

.uploader { border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--text-3); background: var(--surface-2); display: block; }
.uploader svg { width: 28px; height: 28px; opacity: .7; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: var(--fs-sm); }
.file-row svg { width: 16px; height: 16px; flex: none; }
.result-block__head svg { width: 16px; height: 16px; flex: none; }
.card__head > svg { width: 20px; height: 20px; flex: none; }
