/* ============================================================
   @AGENT-TOPBAR  1:1 参考站「智能体工作区」左上角纵向堆叠
   新任务（主题色描边 pill）+ 历史（下拉 pill）
   参考实测尺寸（1879px 视口）：
     - 每个 pill 113.5 × 42，圆角 100px，字号 14.7px
     - 新任务 y=17，历史 y=67（间距 8px）
     - 下拉面板 268.8 × 100（展开），背景 rgba(18,18,24,.98)，
       圆角 8.4px，描边 rgba(255,255,255,.08)，内层 padding 6.3px
   ============================================================ */
.ws-v2 .tb-agent-stack {
  position: absolute;
  top: 14px;
  left: 2px;
  z-index: 1300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}
.ws-v2 .tb-agent-stack.hidden { display: none; }

/* 侧边栏折叠后，左上角「新任务/历史」整组右移，给最左缘的展开箭头「›」让出位置（1:1 参考站） */
.ws-v2 .ws-sidebar.collapsed ~ .ws-main .tb-agent-stack,
.ws-v2 .ws-sidebar.collapsed ~ .sb-history-anchor ~ .ws-main .tb-agent-stack { left: 46px; }
/* 折叠后浮动的展开箭头保证在最顶层、可点击 */
.ws-v2 .ws-sidebar.collapsed ~ .ws-main .sb-expand-btn,
.ws-v2 .ws-sidebar.collapsed ~ .sb-history-anchor ~ .ws-main .sb-expand-btn { z-index: 1400 !important; }

/* 新任务：主题色描边 pill（颜色由 JS 注入 --ag-theme） */
.ws-v2 .tb-agent-newtask {
  height: 42px;
  padding: 0 21px;
  border-radius: 100px;
  border: 1px solid var(--ag-theme, rgba(139, 92, 246, .35));
  background: linear-gradient(135deg, var(--ag-theme-soft, rgba(139, 92, 246, .15)), var(--ag-theme-soft2, rgba(171, 118, 251, .12)));
  color: var(--ag-theme-text, rgba(171, 118, 251, .9));
  font-size: 14.7px;
  font-weight: 500;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s ease, border-color .2s ease, transform .15s ease;
}
.ws-v2 .tb-agent-newtask:hover {
  background: linear-gradient(135deg, var(--ag-theme-softer, rgba(139, 92, 246, .24)), var(--ag-theme-soft2, rgba(171, 118, 251, .2)));
  border-color: var(--ag-theme-text, rgba(171, 118, 251, .9));
}
.ws-v2 .tb-agent-newtask:active { transform: scale(.97); }

/* 历史 pill 容器（相对定位承载下拉） */
.ws-v2 .tb-agent-hist { position: relative; }
.ws-v2 .tb-agent-trigger {
  height: 42px;
  width: 113.5px;
  padding: 0 21px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, .06);
  background: rgba(255, 255, 255, .06);
  color: rgba(255, 255, 255, .7);
  font-size: 14.7px;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  transition: background .2s ease, border-color .2s ease;
}
.ws-v2 .tb-agent-trigger:hover { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .12); }
.ws-v2 .tb-agent-trigger .tb-agent-arrow { transition: transform .22s ease; }
.ws-v2 .tb-agent-hist.open .tb-agent-trigger .tb-agent-arrow { transform: rotate(180deg); }
.ws-v2 .tb-agent-hist-txt { line-height: 1; }

/* 下拉面板：默认折叠（高度 0），展开 100px / 内容多时自动撑高 */
.ws-v2 .tb-agent-panel {
  position: absolute;
  top: 50px;
  left: 0;
  width: 269px;
  max-height: 380px;
  background: rgba(18, 18, 24, .98);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 8.4px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px);
  height: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease, height .22s ease;
}
.ws-v2 .tb-agent-hist.open .tb-agent-panel {
  opacity: 1;
  transform: translateY(0);
  height: auto;
  pointer-events: auto;
}
.ws-v2 .tb-agent-listwrap {
  padding: 6.3px;
  max-height: 366px;
  overflow-y: auto;
}
/* 空态 */
.ws-v2 .tb-agent-state {
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, .35);
  font-size: 12.6px;
}
/* 历史任务项 */
.ws-v2 .tb-agent-task {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s ease;
}
.ws-v2 .tb-agent-task:hover { background: rgba(255, 255, 255, .07); }
.ws-v2 .tb-agent-task-thumb {
  width: 34px; height: 34px;
  border-radius: 7px;
  background: #1c1c24;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  overflow: hidden;
}
.ws-v2 .tb-agent-task-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ws-v2 .tb-agent-task-main { flex: 1; min-width: 0; }
.ws-v2 .tb-agent-task-title {
  font-size: 13px; color: rgba(255, 255, 255, .88);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.3;
}
.ws-v2 .tb-agent-task-sub {
  font-size: 11px; color: rgba(255, 255, 255, .4);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-v2 .tb-agent-task-badge {
  font-size: 10px; padding: 2px 7px; border-radius: 999px;
  flex-shrink: 0;
  background: var(--ag-theme-soft, rgba(139, 92, 246, .16));
  color: var(--ag-theme-text, rgba(171, 118, 251, .9));
}

/* 进入智能体时：隐藏模型态的左上角控件（新任务/历史由 stack 接管） */
.ws-v2 body.agent-view #newChatBtn,
body.agent-view .ws-v2 #newChatBtn,
.ws-v2.agent-view #newChatBtn { display: none !important; }
body.agent-view #newChatBtn,
body.agent-view #taskListBtn,
body.agent-view #tbTipBtn,
body.agent-view #tbHelpBtn { display: none !important; }

/* 滚动条统一 */
.ws-v2 .tb-agent-listwrap::-webkit-scrollbar { width: 6px; }
.ws-v2 .tb-agent-listwrap::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 6px; }

/* 窄屏：缩小并保证不遮挡主内容 */
@media (max-width: 760px) {
  .ws-v2 .tb-agent-stack { top: 10px; left: 12px; }
  .ws-v2 .tb-agent-newtask,
  .ws-v2 .tb-agent-trigger { height: 38px; font-size: 13.5px; }
  .ws-v2 .tb-agent-panel { width: 240px; }
}
