/* BODHI Dashboard · css/agent-chat.css · AI 制片助手悬浮窗
   可拖动 / 居中 / 缩放 / 暗色。层叠顺序 = index.html <link> 先后。*/

/* ── 右下角唤起钮 ─────────────────────────────────────────── */
.agent-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 90;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: linear-gradient(145deg, #c9a36b 0%, #b08642 45%, #8a6730 100%);
  color: #fdfaf4;
  box-shadow:
    0 4px 6px rgb(138 103 48 / 0.2),
    0 10px 28px rgb(138 103 48 / 0.35),
    inset 0 1px 0 rgb(255 255 255 / 0.25);
  cursor: pointer;
  border: 1px solid rgb(176 134 66 / 0.4);
  transition: transform .15s ease, box-shadow .15s ease;
}
.agent-fab:hover {
  transform: scale(1.07) translateY(-1px);
  box-shadow:
    0 6px 10px rgb(138 103 48 / 0.25),
    0 14px 36px rgb(138 103 48 / 0.4);
}
.agent-fab:active { transform: scale(0.98); }
.agent-fab.has-unread::after {
  content: '';
  position: absolute;
  top: 6px; right: 6px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #fdfaf4;
  box-shadow: 0 0 0 1px rgb(239 68 68 / 0.3);
}
.dark .agent-fab {
  background: linear-gradient(145deg, #d4b07a 0%, #c9a36b 50%, #8a6730 100%);
  color: #1c1917;
}

/* ── 主面板（可拖动自由定位） ─────────────────────────────── */
.agent-panel {
  position: fixed;
  z-index: 91;
  display: flex;
  flex-direction: column;
  width: min(480px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 48px));
  min-width: 340px;
  min-height: 360px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  border-radius: 16px;
  background: rgb(255 255 255 / 0.97);
  border: 1px solid rgb(214 211 209 / 0.9);
  box-shadow:
    0 0 0 1px rgb(176 134 66 / 0.08),
    0 4px 6px rgb(0 0 0 / 0.04),
    0 24px 64px -12px rgb(0 0 0 / 0.28);
  overflow: hidden;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  /* left/top 由 JS 写入；默认先给一个不挡视口的位置 */
  left: auto;
  top: auto;
  right: 22px;
  bottom: 90px;
}
.agent-panel.hidden { display: none; }
.agent-panel.is-dragging {
  box-shadow:
    0 0 0 1px rgb(176 134 66 / 0.25),
    0 32px 80px -8px rgb(0 0 0 / 0.35);
  user-select: none;
  cursor: grabbing;
}
.agent-panel.is-centered {
  /* JS 会算 left/top；class 仅作视觉标记 */
  border-color: rgb(176 134 66 / 0.35);
}
.agent-panel.is-expanded {
  width: min(720px, calc(100vw - 32px));
  height: min(820px, calc(100vh - 32px));
}
.dark .agent-panel {
  background: rgb(28 25 23 / 0.97);
  border-color: rgb(68 64 60 / 0.95);
  box-shadow:
    0 0 0 1px rgb(201 163 107 / 0.08),
    0 24px 64px -12px rgb(0 0 0 / 0.55);
}

/* ── 顶栏（拖动手柄） ─────────────────────────────────────── */
.agent-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 14px;
  background:
    linear-gradient(180deg, rgb(253 250 244) 0%, rgb(250 250 249) 100%);
  border-bottom: 1px solid rgb(231 229 228);
  cursor: grab;
  flex-shrink: 0;
  touch-action: none;
}
.agent-panel-header:active,
.agent-panel.is-dragging .agent-panel-header { cursor: grabbing; }
.dark .agent-panel-header {
  background: linear-gradient(180deg, rgb(36 32 30) 0%, rgb(24 21 20) 100%);
  border-color: rgb(68 64 60);
}

.agent-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
  pointer-events: none; /* 整条顶栏可拖，品牌区不抢 */
}
.agent-brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: linear-gradient(145deg, #c9a36b, #8a6730);
  color: #fdfaf4;
  box-shadow: 0 2px 6px rgb(138 103 48 / 0.3);
  flex-shrink: 0;
}
.dark .agent-brand-mark { color: #1c1917; }
.agent-brand-text { min-width: 0; line-height: 1.2; }
.agent-brand-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgb(41 37 36);
}
.dark .agent-brand-title { color: rgb(245 245 244); }
.agent-brand-sub {
  font-size: 10.5px;
  color: rgb(168 162 158);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.agent-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  cursor: default;
}
.agent-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgb(120 113 108);
  font-size: 14px;
  line-height: 1;
  transition: background .1s, color .1s;
}
.agent-icon-btn:hover {
  background: rgb(231 229 228 / 0.9);
  color: rgb(68 64 60);
}
.agent-icon-btn.is-active {
  background: rgb(176 134 66 / 0.15);
  color: rgb(138 103 48);
}
.dark .agent-icon-btn { color: rgb(168 162 158); }
.dark .agent-icon-btn:hover {
  background: rgb(68 64 60);
  color: rgb(231 229 228);
}
.dark .agent-icon-btn.is-active {
  background: rgb(201 163 107 / 0.18);
  color: rgb(201 163 107);
}

/* ── 会话 tabs ────────────────────────────────────────────── */
.agent-tabs-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 0;
  background: rgb(250 250 249 / 0.6);
  border-bottom: 1px solid rgb(231 229 228);
  flex-shrink: 0;
}
.dark .agent-tabs-bar {
  background: rgb(20 18 17 / 0.5);
  border-color: rgb(68 64 60);
}
.agent-tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}
.agent-tab {
  flex-shrink: 0;
  max-width: 160px;
  padding: 4px 4px 4px 10px;
  border-radius: 8px 8px 0 0;
  font-size: 12px;
  white-space: nowrap;
  color: rgb(87 83 78);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  transition: background .1s, color .1s;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.agent-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}
.agent-tab-close {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  color: rgb(168 162 158);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: opacity .1s, background .1s, color .1s;
}
.agent-tab:hover .agent-tab-close { opacity: 1; }
.agent-tab-close:hover {
  background: rgb(220 38 38 / 0.12);
  color: rgb(185 28 28);
}
.dark .agent-tab-close:hover {
  background: rgb(220 38 38 / 0.2);
  color: rgb(252 165 165);
}
.agent-tab:hover { background: rgb(245 245 244); }
.dark .agent-tab { color: rgb(168 162 158); }
.dark .agent-tab:hover { background: rgb(41 37 36); }
.agent-tab-active {
  background: white;
  color: rgb(41 37 36);
  border-color: rgb(231 229 228);
  font-weight: 600;
  box-shadow: 0 -1px 0 white;
  position: relative;
}
.agent-tab-active::after {
  content: '';
  position: absolute;
  left: 10px; right: 10px; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, #b08642, #c9a36b);
  border-radius: 2px 2px 0 0;
}
.dark .agent-tab-active {
  background: rgb(28 25 23);
  color: rgb(245 245 244);
  border-color: rgb(68 64 60);
  box-shadow: 0 -1px 0 rgb(28 25 23);
}
.agent-tab-running { color: rgb(138 103 48); }
.dark .agent-tab-running { color: rgb(201 163 107); }
.agent-tab-new {
  font-weight: 700;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 8px;
  margin-bottom: 6px;
  background: rgb(245 245 244);
  color: rgb(138 103 48);
}
.dark .agent-tab-new { background: rgb(41 37 36); color: rgb(201 163 107); }
.agent-tab-new:hover { background: rgb(176 134 66 / 0.15); }

.agent-history-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  margin-bottom: 6px;
  border-radius: 8px;
  color: rgb(87 83 78);
  background: rgb(245 245 244);
  border: 1px solid transparent;
  white-space: nowrap;
}
.agent-history-toggle:hover { background: rgb(231 229 228); }
.agent-history-toggle.is-active {
  background: rgb(176 134 66 / 0.12);
  color: rgb(138 103 48);
  border-color: rgb(176 134 66 / 0.25);
}
.dark .agent-history-toggle {
  color: rgb(168 162 158);
  background: rgb(41 37 36);
}
.dark .agent-history-toggle.is-active {
  color: rgb(201 163 107);
  background: rgb(201 163 107 / 0.12);
  border-color: rgb(201 163 107 / 0.3);
}
.agent-history-badge {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  background: rgb(176 134 66);
  color: #fdfaf4;
}
.dark .agent-history-badge { color: #1c1917; background: #c9a36b; }
.agent-history-badge.hidden { display: none; }

.agent-body-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* 历史面板：盖住消息区 */
.agent-history-panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: rgb(255 255 255 / 0.98);
  backdrop-filter: blur(8px);
}
.agent-history-panel.hidden { display: none; }
.dark .agent-history-panel { background: rgb(28 25 23 / 0.98); }
.agent-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgb(231 229 228);
  flex-shrink: 0;
}
.dark .agent-history-head { border-color: rgb(68 64 60); }
.agent-history-head-title {
  font-size: 13px;
  font-weight: 700;
}
.agent-history-hint {
  padding: 6px 12px;
  font-size: 11px;
  color: rgb(120 113 108);
  border-bottom: 1px solid rgb(231 229 228 / 0.7);
  flex-shrink: 0;
}
.dark .agent-history-hint {
  color: rgb(168 162 158);
  border-color: rgb(68 64 60);
}
.agent-history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.agent-history-empty {
  padding: 28px 16px;
  text-align: center;
  font-size: 12.5px;
  color: rgb(168 162 158);
  line-height: 1.5;
}
.agent-history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid rgb(231 229 228);
  background: rgb(250 250 249 / 0.8);
  transition: border-color .1s, background .1s;
}
.agent-history-item:hover {
  border-color: rgb(176 134 66 / 0.4);
  background: white;
}
.dark .agent-history-item {
  border-color: rgb(68 64 60);
  background: rgb(36 32 30 / 0.8);
}
.dark .agent-history-item:hover {
  border-color: rgb(201 163 107 / 0.35);
  background: rgb(41 37 36);
}
.agent-history-main { flex: 1; min-width: 0; }
.agent-history-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-history-meta {
  font-size: 11px;
  color: rgb(120 113 108);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dark .agent-history-meta { color: rgb(168 162 158); }
.agent-history-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

/* ── 上下文状态条（模型 / 剧集 / 用量） ───────────────────── */
.agent-ctx-bar {
  flex-shrink: 0;
  padding: 8px 12px 9px;
  border-bottom: 1px solid rgb(231 229 228);
  background: linear-gradient(180deg, rgb(253 250 244 / 0.9), rgb(250 250 249 / 0.55));
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.dark .agent-ctx-bar {
  border-color: rgb(68 64 60);
  background: linear-gradient(180deg, rgb(36 32 30 / 0.95), rgb(24 21 20 / 0.6));
}
.agent-ctx-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.agent-ctx-row-controls { gap: 8px; }
.agent-ctx-label {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex: 1 1 120px;
}
.agent-ctx-label-provider { flex: 0 1 118px; max-width: 140px; }
.agent-ctx-label-model { flex: 1 1 160px; min-width: 120px; }
.agent-ctx-label-effort { flex: 0 1 88px; max-width: 110px; }
.agent-ctx-label-effort.hidden { display: none; }
.agent-ctx-label-ep { flex: 0 1 130px; max-width: 160px; }
.agent-ctx-label-t {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgb(168 162 158);
  text-transform: uppercase;
  flex-shrink: 0;
}
.agent-provider-sel,
.agent-model-sel-main,
.agent-effort-sel,
.agent-perm-sel,
.agent-ep-sel {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  font-size: 11.5px;
  padding: 4px 7px;
  border-radius: 7px;
  border: 1px solid rgb(214 211 209);
  background: white;
  color: inherit;
  font-family: inherit;
}
.dark .agent-provider-sel,
.dark .agent-model-sel-main,
.dark .agent-effort-sel,
.dark .agent-perm-sel,
.dark .agent-ep-sel {
  border-color: rgb(68 64 60);
  background: rgb(28 25 23);
}
.agent-provider-sel:focus,
.agent-model-sel-main:focus,
.agent-effort-sel:focus,
.agent-perm-sel:focus,
.agent-ep-sel:focus {
  outline: none;
  border-color: rgb(176 134 66 / 0.55);
  box-shadow: 0 0 0 2px rgb(176 134 66 / 0.15);
}
.agent-effort-sel:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.agent-ctx-bind {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  color: rgb(138 103 48);
  background: rgb(176 134 66 / 0.1);
  border: 1px solid rgb(176 134 66 / 0.2);
  white-space: nowrap;
}
.agent-ctx-bind:hover { background: rgb(176 134 66 / 0.18); }
.dark .agent-ctx-bind {
  color: rgb(201 163 107);
  background: rgb(201 163 107 / 0.1);
  border-color: rgb(201 163 107 / 0.25);
}

.agent-ctx-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.agent-ctx-pill-idle {
  background: rgb(120 113 108 / 0.12);
  color: rgb(87 83 78);
}
.agent-ctx-pill-run {
  background: rgb(16 185 129 / 0.15);
  color: rgb(5 150 105);
  animation: agent-pulse 1.4s ease-in-out infinite;
}
.agent-ctx-pill-paused {
  background: rgb(220 38 38 / 0.12);
  color: rgb(185 28 28);
}
@keyframes agent-pulse {
  50% { opacity: 0.7; }
}
.dark .agent-ctx-pill-idle { color: rgb(168 162 158); }
.dark .agent-ctx-pill-run { color: rgb(110 231 183); }
.dark .agent-ctx-pill-paused { color: rgb(252 165 165); }

.agent-ctx-chip {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: 6px;
  background: white;
  border: 1px solid rgb(231 229 228);
  color: rgb(68 64 60);
  flex-shrink: 0;
}
.dark .agent-ctx-chip {
  background: rgb(41 37 36);
  border-color: rgb(68 64 60);
  color: rgb(214 211 209);
}
.agent-ctx-chip-gold {
  color: rgb(138 103 48);
  border-color: rgb(176 134 66 / 0.35);
  background: rgb(176 134 66 / 0.08);
  font-weight: 600;
}
.dark .agent-ctx-chip-gold {
  color: rgb(201 163 107);
  background: rgb(201 163 107 / 0.1);
}
.agent-ctx-chip-muted {
  color: rgb(120 113 108);
  font-size: 10.5px;
}
.dark .agent-ctx-chip-muted { color: rgb(168 162 158); }

.agent-ctx-window {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1 1 120px;
  min-width: 100px;
  max-width: 220px;
}
.agent-ctx-window-label {
  font-size: 10px;
  font-weight: 700;
  color: rgb(168 162 158);
  text-transform: uppercase;
}
.agent-ctx-bar-track {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: rgb(231 229 228);
  overflow: hidden;
  min-width: 40px;
}
.dark .agent-ctx-bar-track { background: rgb(68 64 60); }
.agent-ctx-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #b08642, #c9a36b);
  transition: width .25s ease;
}
.agent-ctx-bar-fill.is-warn {
  background: linear-gradient(90deg, #d97706, #f59e0b);
}
.agent-ctx-bar-fill.is-hot {
  background: linear-gradient(90deg, #dc2626, #f87171);
}
.agent-ctx-bar-pct {
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: rgb(120 113 108);
  min-width: 2.4em;
  text-align: right;
}
.dark .agent-ctx-bar-pct { color: rgb(168 162 158); }

.agent-ctx-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.agent-ctx-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgb(214 211 209);
  box-shadow: inset 0 0 0 1px rgb(168 162 158 / 0.4);
}
.agent-ctx-dot.is-on {
  background: #10b981;
  box-shadow: 0 0 0 2px rgb(16 185 129 / 0.2);
}
.dark .agent-ctx-dot { background: rgb(68 64 60); }
.dark .agent-ctx-dot.is-on {
  background: #34d399;
  box-shadow: 0 0 0 2px rgb(52 211 153 / 0.2);
}

/* ── 消息区 ───────────────────────────────────────────────── */
.agent-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13.5px;
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgb(176 134 66 / 0.04), transparent 70%),
    transparent;
  scroll-behavior: smooth;
}
/* body-wrap 内 messages 也要撑满 */
.agent-body-wrap > .agent-messages { flex: 1; }
.dark .agent-messages {
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgb(201 163 107 / 0.05), transparent 70%),
    transparent;
}

/* 空状态 */
.agent-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 16px;
  gap: 10px;
  color: rgb(120 113 108);
}
.dark .agent-empty { color: rgb(168 162 158); }
.agent-empty-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: linear-gradient(145deg, rgb(176 134 66 / 0.12), rgb(176 134 66 / 0.04));
  border: 1px solid rgb(176 134 66 / 0.2);
  margin-bottom: 4px;
}
.agent-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: rgb(41 37 36);
}
.dark .agent-empty-title { color: rgb(245 245 244); }
.agent-empty-desc {
  font-size: 12.5px;
  line-height: 1.5;
  max-width: 280px;
  color: rgb(120 113 108);
}
.agent-empty-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 8px;
  max-width: 340px;
}
.agent-chip {
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  background: white;
  border: 1px solid rgb(231 229 228);
  color: rgb(68 64 60);
  cursor: pointer;
  transition: border-color .1s, background .1s, transform .1s;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}
.agent-chip:hover {
  border-color: rgb(176 134 66 / 0.5);
  background: rgb(253 250 244);
  transform: translateY(-1px);
}
.dark .agent-chip {
  background: rgb(41 37 36);
  border-color: rgb(68 64 60);
  color: rgb(214 211 209);
}
.dark .agent-chip:hover {
  border-color: rgb(201 163 107 / 0.45);
  background: rgb(48 42 38);
}

/* 消息行：头像 + 气泡（行拉满消息区，气泡宽随面板伸缩，不再死卡 420px） */
.agent-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  animation: agent-msg-in .18s ease;
}
@keyframes agent-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.agent-row-user {
  flex-direction: row-reverse;
  align-self: stretch;
  justify-content: flex-start; /* row-reverse 后贴右 */
}
.agent-row-assistant,
.agent-row-system {
  align-self: stretch;
}
/* 后台任务自动通知条（📬 完成/失败）——居中细条，弱化于对话气泡 */
.agent-row-notice {
  align-self: center;
  max-width: 92%;
}
.agent-notice {
  font-size: 12px;
  line-height: 1.5;
  color: rgb(120 113 108);
  background: rgba(176, 134, 66, 0.10);
  border: 1px dashed rgba(176, 134, 66, 0.45);
  border-radius: 8px;
  padding: 6px 10px;
  white-space: pre-wrap;
  text-align: center;
}
.dark .agent-notice {
  color: rgb(180 174 170);
  background: rgba(201, 163, 107, 0.10);
  border-color: rgba(201, 163, 107, 0.40);
}
/* 生图完成通知里直出的产物缩略图（点击进 lightbox）。通知条本身是居中细条，
   图另起一行并限高——别把一条系统提示撑成主视觉。 */
.agent-notice-img {
  display: block;
  margin: 6px auto 0;
  max-width: 100%;
  max-height: 220px;
  border-radius: 6px;
  border: 1px solid rgb(0 0 0 / 0.10);
  cursor: zoom-in;
}
.dark .agent-notice-img { border-color: rgb(255 255 255 / 0.14); }
.agent-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  margin-top: 2px;
}
.agent-avatar-user {
  background: linear-gradient(145deg, #c9a36b, #8a6730);
  color: #fdfaf4;
  font-size: 11px;
  font-weight: 700;
}
.dark .agent-avatar-user { color: #1c1917; }
.agent-avatar-bot {
  background: rgb(245 245 244);
  border: 1px solid rgb(231 229 228);
}
.dark .agent-avatar-bot {
  background: rgb(41 37 36);
  border-color: rgb(68 64 60);
}

/* 气泡列：消息 + 操作条 */
.agent-msg-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-width: calc(100% - 36px);
}
.agent-msg-col-user { align-items: flex-end; }
.agent-msg-col-assistant { align-items: flex-start; max-width: calc(100% - 36px); }
.agent-msg-col .agent-msg {
  max-width: 100%;
}

.agent-msg {
  /* 头像 28 + gap 8 = 36；短文仍随内容收缩，长文吃满面板 */
  max-width: calc(100% - 36px);
  min-width: 0;
  padding: 9px 13px;
  border-radius: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  box-sizing: border-box;
}
.agent-msg-col .agent-msg { max-width: 100%; }

/* 结果卡片耗时页脚：常显、克制 */
.agent-msg-meta {
  font-size: 11px;
  line-height: 1;
  color: #a8a29e;
  padding: 0 2px;
  user-select: none;
  white-space: nowrap;
}
.dark .agent-msg-meta { color: #78716c; }
.agent-msg-meta-clock { opacity: .75; }

/* 消息操作：悬停行时显现 */
.agent-msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  opacity: 0;
  transition: opacity .12s ease;
  pointer-events: none;
}
.agent-row:hover .agent-msg-actions,
.agent-row:focus-within .agent-msg-actions,
.agent-tool-group:hover .agent-tool-group-del {
  opacity: 1;
  pointer-events: auto;
}
.agent-msg-act {
  border: 0;
  background: transparent;
  color: rgb(120 113 108);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.4;
}
.agent-msg-act:hover {
  background: rgb(231 229 228 / 0.8);
  color: rgb(41 37 36);
}
.dark .agent-msg-act { color: rgb(168 162 158); }
.dark .agent-msg-act:hover {
  background: rgb(68 64 60);
  color: rgb(245 245 244);
}
.agent-msg-act-danger:hover {
  background: rgb(220 38 38 / 0.12);
  color: rgb(185 28 28);
}
.dark .agent-msg-act-danger:hover {
  background: rgb(127 29 29 / 0.35);
  color: rgb(252 165 165);
}

/* 用户编辑条 */
.agent-row-editing { width: 100%; }
.agent-edit-box {
  flex: 1;
  min-width: 0;
  max-width: calc(100% - 36px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgb(176 134 66 / 0.45);
  background: rgb(253 250 244);
  box-shadow: 0 2px 8px rgb(138 103 48 / 0.12);
}
.dark .agent-edit-box {
  background: rgb(36 32 30);
  border-color: rgb(201 163 107 / 0.4);
}
.agent-edit-ta {
  width: 100%;
  min-height: 64px;
  max-height: 180px;
  resize: vertical;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  outline: none;
  box-sizing: border-box;
}
.agent-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
.agent-edit-btn { font-size: 12px !important; padding: 4px 10px !important; }
.agent-msg-user {
  /* 用户气泡略收一点，右侧留白更像对话 */
  max-width: min(88%, calc(100% - 36px));
  background: linear-gradient(145deg, #c9a36b 0%, #b08642 50%, #8a6730 100%);
  color: #fdfaf4;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgb(138 103 48 / 0.2);
}
.dark .agent-msg-user {
  background: linear-gradient(145deg, #d4b07a, #c9a36b 40%, #8a6730);
  color: #1c1917;
}
.agent-msg-assistant {
  background: white;
  color: inherit;
  border: 1px solid rgb(231 229 228);
  border-bottom-left-radius: 4px;
  white-space: normal;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.04);
}
.dark .agent-msg-assistant {
  background: rgb(36 32 30);
  border-color: rgb(68 64 60);
  box-shadow: none;
}
.agent-msg-assistant :is(p, ul, ol) { margin: 0.35em 0; }
.agent-msg-assistant :is(p:first-child) { margin-top: 0; }
.agent-msg-assistant :is(p:last-child) { margin-bottom: 0; }
.agent-msg-assistant code {
  font-size: 0.9em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgb(245 245 244);
}
.dark .agent-msg-assistant code { background: rgb(20 18 17); }
.agent-msg-assistant pre {
  margin: 0.5em 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgb(250 250 249);
  overflow-x: auto;
  font-size: 11.5px;
}
.dark .agent-msg-assistant pre { background: rgb(20 18 17); }

/* 流式光标 */
.agent-msg-streaming::after {
  content: '▍
  display: inline-block;
  width: 2px;
  height: 0.95em;
  margin-left: 2px;
  vertical-align: -0.1em;
  background: rgb(176 134 66);
  animation: agent-caret 0.9s step-end infinite;
}
@keyframes agent-caret {
  50% { opacity: 0; }
}

/* 工具卡（自定义折叠头，不用 <details>/<summary>——flex 下 summary 易坍缩） */
.agent-tool-card {
  align-self: stretch;
  margin-left: 36px;
  border: 1px solid rgb(231 229 228);
  border-radius: 8px;
  font-size: 11.5px;
  color: rgb(87 83 78);
  background: rgb(250 250 249 / 0.75);
  overflow: hidden;
  flex-shrink: 0;
}
.dark .agent-tool-card {
  border-color: rgb(68 64 60);
  color: rgb(168 162 158);
  background: rgb(20 18 17 / 0.55);
}
.agent-tool-head {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 0;
  padding: 5px 10px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  user-select: none;
  min-height: 28px;
  box-sizing: border-box;
}
.agent-tool-head:hover { background: rgb(0 0 0 / 0.03); }
.dark .agent-tool-head:hover { background: rgb(255 255 255 / 0.04); }
.agent-tool-empty .agent-tool-head { cursor: default; }
.agent-tool-name {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: rgb(68 64 60);
}
.dark .agent-tool-name { color: rgb(214 211 209); }
/* 人话调用摘要：剧集/镜头/路径，接在中文名后 */
.agent-tool-summary {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  opacity: 0.62;
  font-weight: 400;
}
.agent-tool-summary[hidden] { display: none; }
.agent-tool-meta {
  flex: 0 0 auto;
  font-size: 10px;
  opacity: 0.55;
  white-space: nowrap;
}
.agent-tool-chevron {
  flex: 0 0 auto;
  font-size: 10px;
  opacity: 0.4;
  transition: transform .12s ease;
  line-height: 1;
}
.agent-tool-card.is-open .agent-tool-chevron { transform: rotate(90deg); }
.agent-tool-empty .agent-tool-chevron { visibility: hidden; }
.agent-tool-body {
  display: none;
  border-top: 1px solid rgb(231 229 228 / 0.85);
}
.dark .agent-tool-body { border-color: rgb(68 64 60); }
.agent-tool-card.is-open .agent-tool-body { display: block; }
.agent-tool-card-err,
.agent-tool-err { border-color: rgb(252 165 165 / 0.55); }
.dark .agent-tool-card-err,
.dark .agent-tool-err { border-color: rgb(127 29 29 / 0.55); }
.agent-tool-card-err .agent-tool-name,
.agent-tool-err .agent-tool-name { color: rgb(220 38 38); }
.dark .agent-tool-card-err .agent-tool-name,
.dark .agent-tool-err .agent-tool-name { color: rgb(252 165 165); }
.agent-tool-badge {
  flex: 0 0 auto;
  font-size: 10px;
  line-height: 1.2;
  min-width: 1.4em;
  text-align: center;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgb(176 134 66 / 0.12);
  color: rgb(138 103 48);
  font-weight: 600;
}
.dark .agent-tool-badge {
  background: rgb(201 163 107 / 0.15);
  color: rgb(201 163 107);
}
.agent-tool-badge-ok { background: rgb(16 185 129 / 0.12); color: rgb(5 150 105); }
.agent-tool-badge-err { background: rgb(220 38 38 / 0.1); color: rgb(185 28 28); }
/* 工具来源：内置 vs MCP */
.agent-tool-source {
  flex: 0 0 auto;
  font-size: 9.5px;
  line-height: 1.2;
  padding: 1px 5px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
}
.agent-tool-source-builtin {
  background: rgb(59 130 246 / 0.12);
  color: rgb(37 99 235);
}
.agent-tool-source-mcp {
  background: rgb(168 85 247 / 0.12);
  color: rgb(126 34 206);
}
.agent-tool-source-other {
  background: rgb(120 113 108 / 0.12);
  color: rgb(87 83 78);
}
.dark .agent-tool-source-builtin {
  background: rgb(59 130 246 / 0.18);
  color: rgb(147 197 253);
}
.dark .agent-tool-source-mcp {
  background: rgb(168 85 247 / 0.18);
  color: rgb(216 180 254);
}
.dark .agent-tool-source-other {
  background: rgb(68 64 60);
  color: rgb(168 162 158);
}
.agent-tool-running .agent-tool-badge {
  animation: agent-tool-pulse 1.1s ease-in-out infinite;
}
@keyframes agent-tool-pulse {
  50% { opacity: 0.45; }
}
/* 生成类工具运行中：转圈 spinner + 呼吸提示文案 */
.agent-tool-badge-spin {
  width: 12px;
  height: 12px;
  min-width: 12px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgb(176 134 66 / 0.25);
  border-top-color: rgb(176 134 66);
  background: transparent;
  animation: agent-tool-spin 0.9s linear infinite;
}
.dark .agent-tool-badge-spin {
  border-color: rgb(201 163 107 / 0.25);
  border-top-color: rgb(201 163 107);
}
@keyframes agent-tool-spin {
  to { transform: rotate(360deg); }
}
.agent-tool-genning .agent-tool-meta {
  animation: agent-tool-pulse 1.6s ease-in-out infinite;
}
/* 生图结果缩略图：卡内直出，点开 lightbox */
.agent-tool-imgs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px 10px;
}
.agent-tool-img {
  display: block;
  height: 96px;
  max-width: 200px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgb(0 0 0 / 0.12);
  cursor: zoom-in;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.agent-tool-img:hover {
  transform: scale(1.03);
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.25);
}
.dark .agent-tool-img { border-color: rgb(255 255 255 / 0.14); }
/* 工具结果：人话摘要（非 monospaced JSON） */
.agent-tool-result {
  margin: 0;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 11.5px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 160px;
  overflow-y: auto;
  border-top: 1px dashed rgb(231 229 228 / 0.9);
  color: rgb(68 64 60);
}
.dark .agent-tool-result {
  border-color: rgb(68 64 60);
  color: rgb(214 211 209);
}
.agent-tool-result[hidden] { display: none !important; }
/* 结果原文可能很长（读文件/跑命令输出）：给它比摘要更大的可视高度 */
.agent-tool-card.is-open .agent-tool-result { max-height: 320px; }

/* 展开区的原文块：等宽、保留换行、可滚动、可全选复制。
   工具卡与审批卡共用观感——用户要照着原文判断"到底干了啥 / 批不批"。 */
.agent-tool-raw-wrap[hidden] { display: none !important; }
.agent-tool-raw-label {
  padding: 6px 10px 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.5;
}
.agent-tool-raw,
.agent-approval-raw {
  margin: 4px 10px 8px;
  padding: 7px 9px;
  border-radius: 6px;
  background: rgb(28 25 23 / 0.045);
  border: 1px solid rgb(231 229 228);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow-y: auto;
  color: rgb(41 37 36);
  user-select: text;
}
.dark .agent-tool-raw,
.dark .agent-approval-raw {
  background: rgb(0 0 0 / 0.35);
  border-color: rgb(68 64 60);
  color: rgb(214 211 209);
}
.agent-tool-raw[hidden] { display: none !important; }
/* 审批卡里的原文：卡本身就窄，给足高度，别让人为了看清命令再去翻日志 */
.agent-approval-raw { max-height: 300px; margin: 4px 0 6px; }
.agent-approval-raw-wrap .agent-tool-raw-label { padding: 2px 0 0; }

/* 子代理实况：Agent 卡展开后，内层正文/工具逐条滚在卡里。左侧竖线表明"这是内层"，
   跟主流的工具卡在视觉上一眼分得开——分不开正是改造前混流那个 bug 的观感。 */
.agent-sub-log {
  margin: 4px 10px 8px;
  border-left: 2px solid rgb(168 162 158 / 0.55);
  padding-left: 8px;
}
.dark .agent-sub-log { border-left-color: rgb(120 113 108 / 0.6); }
.agent-sub-log-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.6;
}
.agent-sub-log-count { font-weight: 500; opacity: 0.8; }
.agent-sub-log-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 260px;
  overflow-y: auto;
}
.agent-sub-line {
  font-size: 11px;
  line-height: 1.45;
  word-break: break-word;
  color: rgb(87 83 78);
}
.dark .agent-sub-line { color: rgb(214 211 209); }
.agent-sub-text { white-space: pre-wrap; }
.agent-sub-text.is-streaming::after {
  content: '▍';
  opacity: 0.5;
  animation: agent-caret 1s steps(1) infinite;
}
.agent-sub-tool {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.agent-sub-badge { flex-shrink: 0; width: 1em; opacity: 0.7; }
.agent-sub-name { flex-shrink: 0; font-weight: 600; }
.agent-sub-args {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.7;
}
.agent-sub-running .agent-sub-badge { animation: agent-caret 1s steps(1) infinite; }
.agent-sub-ok .agent-sub-badge { color: rgb(22 163 74); opacity: 1; }
.agent-sub-err .agent-sub-badge { color: rgb(220 38 38); opacity: 1; }

/* 连续工具合并组：默认一行摘要，展开才列明细 */
.agent-tool-group {
  align-self: stretch;
  margin-left: 36px;
  border: 1px solid rgb(231 229 228);
  border-radius: 8px;
  font-size: 11.5px;
  color: rgb(87 83 78);
  background: rgb(250 250 249 / 0.75);
  overflow: hidden;
  flex-shrink: 0;
}
.dark .agent-tool-group {
  border-color: rgb(68 64 60);
  color: rgb(168 162 158);
  background: rgb(20 18 17 / 0.55);
}
.agent-tool-group-head {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 0;
  padding: 5px 10px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  user-select: none;
  min-height: 28px;
  box-sizing: border-box;
}
.agent-tool-group-head:hover { background: rgb(0 0 0 / 0.03); }
.dark .agent-tool-group-head:hover { background: rgb(255 255 255 / 0.04); }
.agent-tool-group-count {
  flex: 0 0 auto;
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
}
.agent-tool-group-names {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 10.5px;
  opacity: 0.85;
}
.agent-tool-group-status {
  flex: 0 0 auto;
  font-size: 10px;
  opacity: 0.55;
  white-space: nowrap;
}
.agent-tool-group-badge { font-size: 11px; }
.agent-tool-group-del {
  flex: 0 0 auto;
  opacity: 0;
  pointer-events: none;
  margin-left: auto;
}
.agent-tool-group.is-open .agent-tool-chevron { transform: rotate(90deg); }
.agent-tool-group-list {
  display: none;
  border-top: 1px solid rgb(231 229 228 / 0.85);
  max-height: min(42vh, 360px);
  overflow-y: auto;
}
.dark .agent-tool-group-list { border-color: rgb(68 64 60); }
.agent-tool-group.is-open .agent-tool-group-list { display: block; }
/* 组内子卡：去外边距/外框，改成分割行 */
.agent-tool-card-nested {
  margin-left: 0;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid rgb(231 229 228 / 0.7);
  background: transparent;
}
.dark .agent-tool-card-nested {
  border-color: rgb(68 64 60 / 0.7);
  background: transparent;
}
.agent-tool-card-nested:last-child { border-bottom: 0; }
.agent-tool-card-nested .agent-tool-head { padding: 4px 10px 4px 12px; min-height: 24px; }
.agent-tool-group-running .agent-tool-group-badge {
  animation: agent-tool-pulse 1.1s ease-in-out infinite;
}
.agent-tool-group-err {
  border-color: rgb(252 165 165 / 0.55);
}
.dark .agent-tool-group-err { border-color: rgb(127 29 29 / 0.55); }
.agent-tool-group-err .agent-tool-group-status { color: rgb(220 38 38); opacity: 0.85; }
.dark .agent-tool-group-err .agent-tool-group-status { color: rgb(252 165 165); }
.agent-tool-group-ok .agent-tool-group-badge {
  background: rgb(16 185 129 / 0.12);
  color: rgb(5 150 105);
}

/* banner / 审批 */
.agent-banner {
  align-self: stretch;
  margin-left: 36px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.4;
}
.agent-banner-error {
  background: rgb(220 38 38 / 0.08);
  color: rgb(185 28 28);
  border: 1px solid rgb(220 38 38 / 0.15);
}
.agent-banner-warn {
  background: rgb(217 119 6 / 0.1);
  color: rgb(180 83 9);
  border: 1px solid rgb(217 119 6 / 0.18);
}
.agent-banner-info {
  background: rgb(37 99 235 / 0.08);
  color: rgb(29 78 216);
  border: 1px solid rgb(37 99 235 / 0.15);
}
.dark .agent-banner-error { color: rgb(252 165 165); }
.dark .agent-banner-warn { color: rgb(253 186 116); }
.dark .agent-banner-info { color: rgb(147 197 253); }

/* 任务清单（内置 Task*）——置底常驻面板，夹在消息区与输入框之间。
   不进 .agent-messages 内部，所以不随对话滚走；清单为空时整个面板由 JS 加 .hidden。
   ⚠ 高度必须封顶：任务多时不能把输入框挤出面板（460px 窄悬浮窗下尤甚），超出自滚。 */
.agent-task-panel {
  flex-shrink: 0;
  max-height: 32%;
  overflow-y: auto;
  border-top: 1px solid rgb(37 99 235 / 0.18);
  background: rgb(37 99 235 / 0.05);
}
.dark .agent-task-panel {
  border-top-color: rgb(147 197 253 / 0.2);
  background: rgb(37 99 235 / 0.08);
}
.agent-task-inner { padding: 8px 12px; font-size: 12.5px; }
.agent-task-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  text-align: left;
  color: rgb(29 78 216);
  margin-bottom: 6px;
}
.dark .agent-task-head { color: rgb(147 197 253); }
.agent-task-caret { flex-shrink: 0; opacity: 0.7; }
/* 折叠时挂在标题上的「当前进行项」：一行截断，别把标题撑成两行 */
.agent-task-cur {
  font-weight: 400;
  opacity: 0.75;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.agent-todo-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.4;
}
.agent-todo-mark { width: 1.1em; flex-shrink: 0; }
.agent-todo-id { font-size: 11px; opacity: 0.65; flex-shrink: 0; }
.agent-todo-text { min-width: 0; }
.agent-todo-done .agent-todo-text {
  text-decoration: line-through;
  opacity: 0.65;
}
.agent-todo-doing .agent-todo-text { font-weight: 600; color: rgb(29 78 216); }
.dark .agent-todo-doing .agent-todo-text { color: rgb(147 197 253); }
/* 内置清单比自建多出来的两项信息：依赖 / 归属（子代理认领） */
.agent-todo-dep, .agent-todo-owner {
  font-size: 11px;
  opacity: 0.6;
  flex-shrink: 0;
}

.agent-approval-card {
  align-self: stretch;
  margin-left: 36px;
  border: 1.5px dashed rgb(176 134 66 / 0.55);
  border-radius: 12px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgb(176 134 66 / 0.08), rgb(176 134 66 / 0.03));
}
.dark .agent-approval-card {
  border-color: rgb(201 163 107 / 0.45);
  background: linear-gradient(180deg, rgb(201 163 107 / 0.1), rgb(201 163 107 / 0.03));
}
.agent-approval-card.agent-approval-done { opacity: .6; }
.agent-approval-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
}
.agent-approval-level {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  background: rgb(176 134 66 / 0.18);
  color: rgb(138 103 48);
}
.dark .agent-approval-level { color: rgb(201 163 107); }
.agent-approval-tool { font-family: monospace; font-size: 12px; }
.agent-approval-cost { margin-left: auto; color: rgb(138 103 48); font-weight: 700; }
.dark .agent-approval-cost { color: rgb(201 163 107); }
.agent-approval-warn { margin: 6px 0 2px; padding: 6px 10px; border-radius: 8px;
  font-size: 12px; background: rgba(245, 158, 11, .12); color: rgb(180 83 9);
  border: 1px solid rgba(245, 158, 11, .35); }
.dark .agent-approval-warn { color: rgb(251 191 36); }
.agent-approval-remember {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11.5px;
  color: rgb(87 83 78);
}
.agent-approval-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.agent-approval-status { font-size: 11.5px; color: rgb(120 113 108); }

/* AskUserQuestion 选项卡（复用 approval 卡壳） */
.agent-question-card {
  border-style: solid;
  border-color: rgb(59 130 246 / 0.4);
  background: linear-gradient(180deg, rgb(59 130 246 / 0.08), rgb(59 130 246 / 0.02));
}
.dark .agent-question-card {
  border-color: rgb(96 165 250 / 0.4);
  background: linear-gradient(180deg, rgb(59 130 246 / 0.12), rgb(59 130 246 / 0.03));
}
.agent-q-block { margin-top: 10px; }
.agent-q-text {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: rgb(41 37 36);
  line-height: 1.4;
}
.dark .agent-q-text { color: rgb(231 229 228); }
.agent-q-opts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.agent-q-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgb(214 211 209);
  background: rgb(255 255 255 / 0.7);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.dark .agent-q-opt {
  border-color: rgb(68 64 60);
  background: rgb(28 25 23 / 0.6);
  color: rgb(231 229 228);
}
.agent-q-opt:hover:not(:disabled) {
  border-color: rgb(59 130 246 / 0.55);
  background: rgb(59 130 246 / 0.08);
}
.agent-q-opt.selected {
  border-color: rgb(37 99 235);
  background: rgb(59 130 246 / 0.14);
  box-shadow: 0 0 0 1px rgb(37 99 235 / 0.25);
}
.dark .agent-q-opt.selected {
  border-color: rgb(96 165 250);
  background: rgb(59 130 246 / 0.2);
}
.agent-q-opt:disabled { opacity: .7; cursor: default; }
.agent-q-opt-label { font-weight: 600; }
.agent-q-opt-desc {
  font-size: 11px;
  color: rgb(120 113 108);
  line-height: 1.35;
}
.dark .agent-q-opt-desc { color: rgb(168 162 158); }
.agent-q-opt-other {
  border-style: dashed;
}
.agent-q-other-input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgb(59 130 246 / 0.45);
  background: rgb(255 255 255 / 0.85);
  font-size: 12.5px;
  box-sizing: border-box;
}
.dark .agent-q-other-input {
  border-color: rgb(96 165 250 / 0.45);
  background: rgb(28 25 23 / 0.7);
  color: rgb(231 229 228);
}
.agent-btn-skip {
  background: transparent;
  border: 1px solid rgb(168 162 158);
  color: rgb(87 83 78);
}
.agent-btn-skip:hover:not(:disabled) {
  background: rgb(168 162 158 / 0.12);
}
.dark .agent-btn-skip {
  border-color: rgb(87 83 78);
  color: rgb(168 162 158);
}

/* ExitPlanMode 计划卡 */
.agent-plan-card {
  border-style: solid;
  border-color: rgb(16 185 129 / 0.45);
  background: linear-gradient(180deg, rgb(16 185 129 / 0.08), rgb(16 185 129 / 0.02));
}
.dark .agent-plan-card {
  border-color: rgb(52 211 153 / 0.4);
  background: linear-gradient(180deg, rgb(16 185 129 / 0.12), rgb(16 185 129 / 0.03));
}
.agent-plan-steps {
  margin: 8px 0 4px 1.2em;
  padding: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: rgb(41 37 36);
}
.dark .agent-plan-steps { color: rgb(231 229 228); }
.agent-plan-steps li { margin: 3px 0; }
.agent-plan-risks {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  background: rgba(245, 158, 11, .1);
  color: rgb(180 83 9);
  border: 1px solid rgba(245, 158, 11, .3);
}
.dark .agent-plan-risks { color: rgb(251 191 36); }
.agent-plan-risks-title { font-weight: 700; margin-bottom: 2px; }
.agent-plan-risks ul { margin: 0 0 0 1.1em; padding: 0; }
.agent-plan-note {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgb(214 211 209);
  background: rgb(255 255 255 / 0.7);
  font-size: 12px;
  box-sizing: border-box;
}
.dark .agent-plan-note {
  border-color: rgb(68 64 60);
  background: rgb(28 25 23 / 0.6);
  color: rgb(231 229 228);
}

.agent-btn {
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  transition: background .1s, transform .1s;
}
.agent-btn:active:not(:disabled) { transform: scale(0.97); }
.agent-btn-allow { background: rgb(16 185 129 / 0.15); color: rgb(5 150 105); }
.agent-btn-allow:hover { background: rgb(16 185 129 / 0.25); }
.agent-btn-deny { background: rgb(220 38 38 / 0.1); color: rgb(185 28 28); }
.agent-btn-deny:hover { background: rgb(220 38 38 / 0.18); }
.agent-btn:disabled { opacity: .5; cursor: default; }

/* 打字中指示 */
.agent-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 36px;
  padding: 4px 0;
  font-size: 12px;
  color: rgb(168 162 158);
}
.agent-typing-dots {
  display: inline-flex;
  gap: 3px;
}
.agent-typing-dots span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgb(176 134 66 / 0.7);
  animation: agent-dot 1.2s ease-in-out infinite;
}
.agent-typing-dots span:nth-child(2) { animation-delay: .15s; }
.agent-typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes agent-dot {
  0%, 80%, 100% { opacity: .3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* ── 底部输入 ─────────────────────────────────────────────── */
.agent-composer {
  border-top: 1px solid rgb(231 229 228);
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgb(250 250 249 / 0.85);
  flex-shrink: 0;
}
.dark .agent-composer {
  border-color: rgb(68 64 60);
  background: rgb(20 18 17 / 0.7);
}
.agent-composer-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: rgb(120 113 108);
  min-height: 22px;
}
.dark .agent-composer-meta { color: rgb(168 162 158); }
.agent-composer-hint {
  font-size: 10.5px;
  color: rgb(168 162 158);
  opacity: .85;
}
.agent-composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  border-radius: 12px;
  border: 1px solid rgb(231 229 228);
  background: white;
  transition: border-color .12s, box-shadow .12s;
}
.agent-composer-box:focus-within {
  border-color: rgb(176 134 66 / 0.55);
  box-shadow: 0 0 0 3px rgb(176 134 66 / 0.15);
}
.dark .agent-composer-box {
  border-color: rgb(68 64 60);
  background: rgb(28 25 23);
}
.agent-input {
  flex: 1;
  min-height: 36px;
  max-height: 140px;
  padding: 7px 0;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 13.5px;
  font-family: inherit;
  line-height: 1.45;
  resize: none;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
  /* contenteditable 占位用 :before；position 方便绝对定位 placeholder */
  position: relative;
}
.agent-input:focus { outline: none; }
.agent-input.is-empty:before {
  content: attr(data-placeholder);
  color: rgb(168 162 158);
  pointer-events: none;
  position: absolute;
  left: 0;
  top: 7px;
  right: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-input.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}
/* 输入区内联 @附件缩略图 chip（contenteditable=false） */
.agent-ce-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin: 0 2px;
  padding: 1px;
  border-radius: 6px;
  border: 1px solid rgb(214 211 209);
  background: rgb(250 250 249);
  cursor: default;
  user-select: none;
  line-height: 0;
}
.dark .agent-ce-chip {
  border-color: rgb(68 64 60);
  background: rgb(41 37 36);
}
.agent-ce-chip-image { cursor: zoom-in; }
.agent-ce-chip-audio,
.agent-ce-chip-video { cursor: pointer; }
.agent-ce-chip-thumb {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  background: #111;
}
.agent-ce-chip-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  border-radius: 4px;
  background: rgb(231 229 228);
}
.dark .agent-ce-chip-icon { background: rgb(28 25 23); }
.agent-ce-chip-icon-audio { background: rgba(139, 92, 246, 0.18); }
.agent-ce-chip-icon-video { background: rgba(14, 116, 144, 0.16); }

.agent-send-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #c9a36b, #8a6730);
  color: #fdfaf4;
  font-size: 15px;
  box-shadow: 0 2px 6px rgb(138 103 48 / 0.25);
  transition: transform .1s, opacity .1s;
}
.agent-send-btn:hover { transform: scale(1.04); }
.agent-send-btn:disabled {
  opacity: .45;
  cursor: default;
  transform: none;
}
.dark .agent-send-btn {
  background: linear-gradient(145deg, #d4b07a, #8a6730);
  color: #1c1917;
}
.agent-stop-btn {
  background: linear-gradient(145deg, #f87171, #dc2626) !important;
  color: white !important;
  box-shadow: 0 2px 6px rgb(220 38 38 / 0.3) !important;
}
.agent-send-btn.hidden { display: none; }

/* 缩放手柄 */
.agent-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  z-index: 2;
}
.agent-resize::before {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 9px;
  height: 9px;
  border-right: 2px solid rgb(176 134 66 / 0.45);
  border-bottom: 2px solid rgb(176 134 66 / 0.45);
  border-radius: 0 0 2px 0;
}

/* 移动端：贴底全宽，禁用拖到屏幕外 */
@media (max-width: 640px) {
  .agent-panel {
    left: 8px !important;
    right: 8px !important;
    top: auto !important;
    bottom: 8px !important;
    width: calc(100vw - 16px) !important;
    height: min(78vh, 640px) !important;
    max-width: none;
    border-radius: 14px;
  }
  .agent-resize { display: none; }
  .agent-fab { right: 16px; bottom: 16px; }
  .agent-composer-hint { display: none; }
}

/* 拖放参考文件高亮 */
.agent-panel.agent-drop-hover {
  outline: 2px dashed rgb(176 134 66 / 0.8);
  outline-offset: -4px;
}
.agent-panel.agent-drop-hover::after {
  content: '松开 → 上传为 @参考';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(30 25 18 / 0.55);
  color: #e7d9bd;
  font-size: 15px;
  pointer-events: none;
  border-radius: inherit;
  z-index: 5;
}

/* ── 反馈 #2/#3（2026-07-23）：composer 附件/技能按钮 + 技能菜单 + 自动批准回执 ── */
.agent-composer-tool-btn {
  flex: 0 0 auto;
  align-self: flex-end;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgb(0 0 0 / 0.12);
  background: transparent;
  color: rgb(120 100 60);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.agent-composer-tool-btn:hover { background: rgb(176 134 66 / 0.12); }
.dark .agent-composer-tool-btn { border-color: rgb(255 255 255 / 0.16); color: rgb(201 163 107); }
.agent-composer-box { position: relative; }
.agent-skill-menu {
  position: absolute;
  left: 6px;
  bottom: calc(100% + 6px);
  z-index: 30;
  min-width: 220px;
  max-height: 260px;
  overflow-y: auto;
  border-radius: 10px;
  border: 1px solid rgb(0 0 0 / 0.14);
  background: #fff;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  padding: 4px;
}
.dark .agent-skill-menu { background: rgb(38 34 28); border-color: rgb(255 255 255 / 0.14); }
.agent-skill-item {
  display: flex;
  width: 100%;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
  padding: 6px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
}
.agent-skill-item:hover { background: rgb(176 134 66 / 0.12); }
.agent-skill-name { font-family: 'JetBrains Mono', Consolas, monospace; color: rgb(138 103 48); }
.dark .agent-skill-name { color: rgb(201 163 107); }
.agent-skill-role { font-size: 11px; opacity: 0.65; }
.agent-skill-empty { cursor: default; opacity: 0.6; }

/* ── @附件下拉：输入框里打 @ 选已挂附件 ─────────────────────────── */
.agent-mention-menu {
  position: absolute;
  left: 6px;
  bottom: calc(100% + 6px);
  z-index: 32;
  min-width: 220px;
  max-width: 340px;
  max-height: 260px;
  overflow-y: auto;
  border-radius: 10px;
  border: 1px solid rgb(0 0 0 / 0.14);
  background: #fff;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  padding: 4px;
}
.agent-mention-menu.hidden { display: none; }
.dark .agent-mention-menu { background: rgb(38 34 28); border-color: rgb(255 255 255 / 0.14); }
.agent-mention-opt {
  display: flex;
  width: 100%;
  gap: 8px;
  align-items: center;
  padding: 4px 8px 4px 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
}
.agent-mention-opt.is-active,
.agent-mention-opt:hover { background: rgb(176 134 66 / 0.14); }
.agent-mention-opt-thumb {
  width: 32px; height: 32px;
  object-fit: cover;
  border-radius: 5px;
  background: #111;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.agent-mention-opt-file { background: rgb(231 229 228); color: rgb(120 113 108); font-size: 15px; }
.dark .agent-mention-opt-file { background: rgb(41 37 36); color: rgb(168 162 158); }
.agent-mention-opt-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgb(68 64 60);
}
.dark .agent-mention-opt-name { color: rgb(214 211 209); }
.agent-banner-auto {
  color: rgb(138 103 48);
  background: rgb(176 134 66 / 0.08);
  border: 1px dashed rgb(176 134 66 / 0.4);
  font-size: 11.5px;
}
.dark .agent-banner-auto { color: rgb(201 163 107); }

/* ── @附件缩略图：输入框上方附件条 + 消息内内联附件 chip ─────────────── */
.agent-attach-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 2px 2px;
  scrollbar-width: thin;
}
.agent-attach-strip.hidden { display: none; }
.agent-attach-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px 3px 3px;
  border: 1px solid rgb(214 211 209);
  border-radius: 8px;
  background: rgb(250 250 249);
  flex: 0 0 auto;
  max-width: 176px;
}
.dark .agent-attach-chip { border-color: rgb(68 64 60); background: rgb(41 37 36); }
.agent-attach-thumb {
  width: 46px; height: 46px;
  object-fit: cover;
  border-radius: 5px;
  background: #111;
  flex: 0 0 auto;
}
.agent-attach-thumb-file {
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; background: rgb(231 229 228);
}
.dark .agent-attach-thumb-file { background: rgb(41 37 36); }
.agent-attach-name {
  font-size: 11px; color: rgb(87 83 78);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dark .agent-attach-name { color: rgb(168 162 158); }
.agent-attach-x {
  border: none; background: transparent; color: rgb(120 113 108);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; flex: 0 0 auto;
}
.agent-attach-x:hover { color: rgb(220 60 60); }

.agent-msg-mention {
  display: inline-flex; align-items: center; gap: 0;
  vertical-align: middle; margin: 1px 2px;
  padding: 1px; border-radius: 6px;
  background: rgba(176, 134, 66, 0.14); color: rgb(138 103 48);
  cursor: zoom-in;
  line-height: 0;
}
.dark .agent-msg-mention { color: rgb(201 163 107); background: rgba(201, 163, 107, 0.16); }
.agent-msg-mention-audio,
.agent-msg-mention-video { cursor: pointer; }
.agent-msg-mention-file { cursor: default; }
.agent-msg-mention-thumb { width: 26px; height: 26px; object-fit: cover; border-radius: 4px; display: block; }
.agent-msg-mention-icon {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; border-radius: 4px;
  background: rgba(176, 134, 66, 0.12);
}
.agent-msg-mention-audio { background: rgba(139, 92, 246, 0.14); }
.agent-msg-mention-video { background: rgba(14, 116, 144, 0.12); }
.agent-msg-mention-name { font-size: 11px; padding: 0 4px; line-height: 1.4; }

/* 审批卡：人话摘要（替代原始 JSON） */
.agent-approval-summary {
  font-size: 12px;
  color: rgb(87 83 78);
  padding: 4px 2px 6px;
  line-height: 1.4;
}
.dark .agent-approval-summary { color: rgb(168 162 158); }

/* 审批卡：线路/模型/分辨率/时长（gen_video / gen_image 从镜头 prompt JSON 抽的生成配置） */
.agent-approval-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  margin: 2px 2px 6px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(176, 134, 66, 0.08);
  font-size: 12px;
  line-height: 1.5;
}
.agent-approval-meta-row { display: contents; }
.agent-approval-meta-k { color: rgb(120 113 108); white-space: nowrap; }
.agent-approval-meta-v {
  color: rgb(41 37 36);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.dark .agent-approval-meta { background: rgba(176, 134, 66, 0.12); }
.dark .agent-approval-meta-k { color: rgb(168 162 158); }
.dark .agent-approval-meta-v { color: rgb(231 229 228); }

/* 审批卡：gen_video『就地改这次生成』的通道/模型/分辨率编辑器 */
.agent-approval-edit {
  margin: 2px 2px 6px;
  padding: 7px 8px;
  border-radius: 6px;
  background: rgba(176, 134, 66, 0.08);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.agent-approval-edit-hint { font-size: 11px; color: rgb(120 113 108); }
.agent-approval-edit-row { display: flex; align-items: center; gap: 8px; }
.agent-approval-edit-k { font-size: 12px; color: rgb(120 113 108); width: 44px; flex-shrink: 0; }
.agent-approval-edit-sel, .agent-approval-edit-inp {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 5px;
  border: 1px solid rgba(120, 113, 108, 0.3);
  background: rgb(255 255 255);
  color: rgb(41 37 36);
}
.dark .agent-approval-edit { background: rgba(176, 134, 66, 0.12); }
.dark .agent-approval-edit-hint, .dark .agent-approval-edit-k { color: rgb(168 162 158); }
.dark .agent-approval-edit-sel, .dark .agent-approval-edit-inp {
  background: rgb(41 37 36); color: rgb(231 229 228); border-color: rgba(168, 162, 158, 0.3);
}

/* 附件条：音视小控件不显示长文件名 */
.agent-attach-chip-media { padding-right: 4px; max-width: none; }
.agent-attach-thumb-audio { background: rgba(139, 92, 246, 0.18) !important; }
.agent-attach-thumb-video { background: rgba(14, 116, 144, 0.16) !important; }
