/* ============================================================================
 * Agent 工作室（Agent Studio）
 * 建 Agent → 用 Agent → 升级 Agent 的统一入口界面
 * ==========================================================================*/

#opc-studio { padding: 0; overflow: hidden; }

.stu-topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex: none;
}
.stu-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.stu-stat { font-size: 11.5px; color: var(--text-secondary); }
.stu-stat b { color: var(--text-primary); font-size: 13px; margin-right: 3px; }
.stu-flex { flex: 1; }
.stu-topbar .stu-hint { font-size: 11px; color: var(--text-muted); }

.stu-body { flex: 1; display: flex; min-height: 0; overflow: hidden; }

/* ---------------- 左侧：Agent 列表 ---------------- */
.stu-side {
  width: 264px; flex: none; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--bg-secondary, var(--surface));
  min-height: 0;
}
.stu-side-head { padding: 10px; border-bottom: 1px solid var(--border); }
.stu-search {
  width: 100%; box-sizing: border-box; padding: 7px 10px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-input); color: var(--text-primary); outline: none;
}
.stu-search:focus { border-color: var(--accent); }
.stu-list { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }
.stu-empty { padding: 18px 10px; font-size: 12px; color: var(--text-muted); text-align: center; line-height: 1.7; }

.stu-item {
  padding: 9px 10px; border-radius: 8px; cursor: pointer; margin-bottom: 4px;
  border: 1px solid transparent;
}
.stu-item:hover { background: var(--bg-hover); }
.stu-item.active { background: var(--accent-bg); border-color: var(--accent); }
.stu-item-name {
  font-size: 12.5px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stu-item-id { font-size: 10.5px; color: var(--text-muted); margin-top: 1px; }
.stu-item-tags { margin-top: 5px; display: flex; gap: 4px; flex-wrap: wrap; }
.stu-tag {
  font-size: 9.5px; padding: 1px 6px; border-radius: 5px;
  background: var(--bg-input); color: var(--text-secondary);
}
.stu-tag.plat { background: rgba(59,130,246,.12); color: #3b82f6; }
.stu-tag.mode { background: rgba(16,185,129,.12); color: #10b981; }
.stu-tag.off  { background: rgba(239,68,68,.12); color: #ef4444; }

.stu-side-foot { padding: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 7px; }
.stu-primary-btn, .stu-ghost-btn {
  width: 100%; padding: 8px 10px; font-size: 12px; border-radius: 8px;
  cursor: pointer; font-weight: 600;
}
.stu-primary-btn { border: none; background: var(--accent); color: #fff; }
.stu-primary-btn:hover { filter: brightness(1.08); }
.stu-ghost-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-primary); font-weight: 500; }
.stu-ghost-btn:hover { background: var(--bg-hover); }

/* ---------------- 右侧：工作区 ---------------- */
.stu-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stu-main-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 9px 16px; border-bottom: 1px solid var(--border); flex: none;
}
.stu-cur { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.stu-cur-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.stu-cur-id { font-size: 11px; color: var(--text-muted); }
.stu-cur-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.stu-subtabs { margin-left: auto; display: flex; gap: 4px; }
.stu-subtab {
  padding: 5px 12px; font-size: 12px; border-radius: 7px; cursor: pointer;
  border: 1px solid transparent; background: transparent; color: var(--text-secondary);
}
.stu-subtab:hover { background: var(--bg-hover); color: var(--text-primary); }
.stu-subtab.active { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); font-weight: 600; }

.stu-sub { flex: 1; display: none; flex-direction: column; min-height: 0; overflow: hidden; }
.stu-sub.active { display: flex; }
.stu-scroll { flex: 1; overflow-y: auto; padding: 16px; min-height: 0; }

/* ---- 对话 ---- */
.stu-chat { flex: 1; overflow-y: auto; padding: 16px; min-height: 0; }
.stu-msg { margin-bottom: 12px; font-size: 12.5px; line-height: 1.75; }
.stu-msg.user {
  margin-left: auto; max-width: 78%; padding: 8px 12px; border-radius: 10px;
  background: var(--accent-bg); color: var(--text-primary); width: fit-content;
}
.stu-msg.assistant { color: var(--text-primary); }
.stu-msg.assistant .markdown-body { font-size: 12.5px; }
.stu-msg.system { font-size: 11px; color: var(--text-muted); }
.stu-msg.error { font-size: 12px; color: var(--danger, #ef4444); }
.stu-msg.tool {
  font-size: 11px; color: var(--text-secondary); padding: 5px 9px;
  background: var(--bg-input); border-radius: 7px; border-left: 2px solid var(--accent);
  white-space: pre-wrap; word-break: break-all;
}
.stu-thinking { font-size: 11.5px; color: var(--accent); margin-bottom: 10px; }

.stu-welcome { padding: 8px 0; }
.stu-welcome-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.stu-welcome-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.8; margin-bottom: 12px; }
.stu-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.stu-chip {
  padding: 6px 11px; font-size: 11.5px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary);
}
.stu-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---- 内嵌渲染面（ui_* 工具输出） ---- */
.stu-render {
  flex: none; max-height: 42vh; overflow: auto; border-top: 1px solid var(--border);
  background: var(--surface); padding: 12px 16px;
}
.stu-render.max { position: absolute; inset: 0; max-height: none; z-index: 5; }
.stu-render-bar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  font-size: 11px; color: var(--text-secondary);
}
.stu-render-bar .stu-flex { flex: 1; }
.stu-mini-btn {
  padding: 3px 9px; font-size: 11px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary);
}
.stu-mini-btn:hover { color: var(--accent); border-color: var(--accent); }
.stu-sub-chat { position: relative; }

/* ---- 输入区 ---- */
.stu-composer {
  flex: none; display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface);
}
.stu-composer textarea {
  flex: 1; resize: none; padding: 9px 12px; font-size: 12.5px; line-height: 1.6;
  border: 1px solid var(--border); border-radius: 9px; outline: none;
  background: var(--bg-input); color: var(--text-primary); font-family: inherit;
}
.stu-composer textarea:focus { border-color: var(--accent); }
.stu-composer button {
  padding: 9px 16px; font-size: 12px; font-weight: 600; border-radius: 9px; cursor: pointer;
  border: none; background: var(--accent); color: #fff;
}
.stu-composer button:disabled { opacity: .5; cursor: not-allowed; }
.stu-composer button.ghost { border: 1px solid var(--border); background: var(--surface); color: var(--text-primary); font-weight: 500; }
.stu-composer-row { display: flex; gap: 8px; align-items: flex-end; width: 100%; }
.stu-composer .btn-attach {
  flex: none; padding: 9px 12px; font-size: 15px; line-height: 1; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-primary); font-weight: 500;
}
.stu-composer .btn-attach:hover { color: var(--accent); border-color: var(--accent); }
/* 附件列表（待发送） */
.attach-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 240px;
  padding: 3px 8px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg-input); font-size: 11.5px; color: var(--text-primary);
}
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.attach-size { color: var(--text-secondary); font-size: 10.5px; }
.attach-status { font-size: 10.5px; }
.attach-status.parsing { color: var(--accent); }
.attach-status.done { color: #2f9e44; }
.attach-status.error { color: #e03131; }
.attach-remove { cursor: pointer; color: var(--text-secondary); padding: 0 2px; }
.attach-remove:hover { color: #e03131; }
/* 气泡内已附文件提示 */
.msg-attachments { margin-top: 4px; font-size: 11.5px; color: var(--text-secondary); }

/* ---- 能力升级 ---- */
.stu-up-card {
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  padding: 14px 16px; margin-bottom: 14px;
}
.stu-up-title { font-size: 12.5px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.stu-up-desc { font-size: 11.5px; color: var(--text-muted); line-height: 1.7; margin-bottom: 10px; }
.stu-up-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stu-up-mode {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; border-radius: 8px; background: var(--bg-input); font-size: 11.5px;
}
.stu-up-mode b { color: var(--text-primary); font-size: 12px; }
.stu-up-auto { font-size: 10px; padding: 1px 7px; border-radius: 5px; background: var(--accent-bg); color: var(--accent); }
.stu-up-task {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 62px;
  padding: 9px 12px; font-size: 12.5px; line-height: 1.6; font-family: inherit;
  border: 1px solid var(--border); border-radius: 9px; background: var(--bg-input);
  color: var(--text-primary); outline: none; margin-bottom: 10px;
}
.stu-up-task:focus { border-color: var(--accent); }
.stu-btn {
  padding: 7px 14px; font-size: 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-primary);
}
.stu-btn:hover { background: var(--bg-hover); }
.stu-btn.primary { border: none; background: var(--accent); color: #fff; font-weight: 600; }
.stu-btn.danger { border-color: rgba(239,68,68,.45); color: #ef4444; }
.stu-btn:disabled { opacity: .5; cursor: not-allowed; }
.stu-btn-primary { border: none; background: var(--accent); color: #fff; font-weight: 600; }
.stu-up-status { font-size: 11.5px; color: var(--text-secondary); margin-top: 10px; line-height: 1.7; white-space: pre-wrap; }
.stu-up-ok { font-size: 11.5px; color: #10b981; margin-top: 8px; }
.stu-manual-land { margin-top: 10px; padding: 10px 12px; border: 1px solid rgba(245,158,11,.4); border-radius: 8px; background: rgba(245,158,11,.08); display: flex; flex-direction: column; gap: 10px; }
.stu-manual-land .stu-up-ok { margin-top: 0; color: #f59e0b; }
.stu-manual-land code { font-family: var(--mono); font-size: 11px; background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 4px; color: var(--text-primary); }
.stu-manual-warn { font-size: 11px; line-height: 1.5; color: #f59e0b; background: rgba(245,158,11,.12); border-left: 3px solid #f59e0b; padding: 7px 9px; border-radius: 4px; }
.stu-manual-sep { font-size: 10.5px; color: var(--text-muted); text-align: center; opacity: .8; }
.stu-btn-warn { border-color: rgba(245,158,11,.55); color: #f59e0b; background: rgba(245,158,11,.1); font-weight: 600; }
.stu-btn-warn:hover { background: rgba(245,158,11,.2); }
.stu-btn-warn:disabled { opacity: .5; cursor: not-allowed; }
.stu-score { font-size: 13px; font-weight: 600; color: var(--text-primary); margin: 4px 0 10px; }
.stu-findings { margin-top: 8px; }
.stu-find-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.stu-find {
  border: 1px solid var(--border); border-left-width: 3px; border-radius: 8px;
  padding: 8px 11px; background: var(--bg-input); font-size: 11.5px;
}
.stu-find-high { border-left-color: #ef4444; }
.stu-find-medium { border-left-color: #f59e0b; }
.stu-find-low { border-left-color: #3b82f6; }
.stu-find-sev {
  display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  padding: 1px 7px; border-radius: 5px; background: var(--bg-hover); color: var(--text-secondary); margin-right: 6px;
}
.stu-find-dim { font-size: 11px; color: var(--text-muted); }
.stu-find-title { margin: 5px 0 2px; font-weight: 600; color: var(--text-primary); }
.stu-find-msg { margin: 3px 0; line-height: 1.6; color: var(--text-secondary); }
.stu-find-ev { font-size: 11px; color: var(--text-muted); line-height: 1.6; word-break: break-all; }
.stu-find-adv { font-size: 11px; color: var(--text-muted); line-height: 1.6; }
.stu-status { font-size: 11.5px; color: var(--text-secondary); margin-top: 8px; line-height: 1.7; }
.stu-status.ok { color: #10b981; }
.stu-status.err { color: #ef4444; }
.stu-status.warn { color: #e3b341; }
.stu-status.run { color: var(--accent); }
.stu-report { font-size: 12px; line-height: 1.8; color: var(--text-primary); }
.stu-report:empty { display: none; }
.stu-diag {
  margin-top: 10px; padding: 10px; border-radius: 8px; background: var(--bg-input);
  font-size: 10.5px; line-height: 1.6; color: var(--text-secondary);
  white-space: pre-wrap; max-height: 240px; overflow: auto;
}
.stu-diag:empty { display: none; }

/* ---- 升级：评级 / 轨道 / rubric / 达标门禁 ---- */
.stu-up-select {
  padding: 6px 10px; font-size: 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg-input); color: var(--text-primary);
}
.stu-up-label { font-size: 12px; color: var(--text-secondary); margin-right: 8px; }
.stu-up-rubric-status { font-size: 11.5px; }
.stu-up-rubric-status.ok { color: #3fb950; }
.stu-up-rubric-status.err { color: #ef4444; }
.stu-up-baseline { margin-top: 8px; font-size: 12px; color: var(--text-primary); line-height: 1.7; }
.stu-up-baseline b { color: var(--text-secondary); font-weight: 600; }
.stu-up-muted { color: var(--text-muted); }
.stu-up-err { color: #ef4444; }
.stu-tracks { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.stu-track { display: flex; align-items: center; gap: 9px; font-size: 12px; }
.stu-track-dot { color: var(--text-muted); font-size: 15px; line-height: 1; }
.stu-track-dot.on { color: #3fb950; }
.stu-track-name { color: var(--text-primary); font-weight: 600; min-width: 168px; }
.stu-track-desc { color: var(--text-muted); font-size: 11px; }
.stu-gate {
  margin-top: 12px; padding: 11px 13px; border-radius: 9px; border: 1px solid var(--border);
  font-size: 12px;
}
.stu-gate.ok { border-color: #3fb950; background: rgba(63,185,80,0.08); }
.stu-gate.warn { border-color: #e3b341; background: rgba(227,179,65,0.08); }
.stu-gate-title { font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.stu-gate-rows { color: var(--text-primary); line-height: 1.9; }
.stu-gate-verdict { margin-top: 6px; color: var(--text-secondary); }
.stu-gate:empty { display: none; }

/* ---- 角色信息 ---- */
.stu-info-row { display: flex; gap: 10px; font-size: 12px; line-height: 2; }
.stu-info-key { width: 96px; flex: none; color: var(--text-secondary); }
.stu-info-val { color: var(--text-primary); word-break: break-all; }

/* ---- 构建预览卡 ---- */
.stu-build-card {
  margin: 8px 0 12px; padding: 14px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--accent-bg);
}
.stu-build-title { font-size: 12.5px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.stu-build-line { font-size: 12px; line-height: 1.9; }
.stu-build-line span { display: inline-block; width: 82px; color: var(--text-secondary); }
.stu-build-actions { margin-top: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.stu-build-note { margin-top: 8px; font-size: 10.5px; color: var(--text-muted); }
