/* 作品集 AI 助手：标题下的入口按钮 + 右下角头像入口 + 浮动聊天窗口。颜色沿用首页的变量。 */
.ag-ava { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.ag-online {
  position: absolute; right: 1px; bottom: 1px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--ok); border: 2px solid var(--surface);
}

/* 标题下的入口 */
.ag-cta {
  margin-top: 18px; display: inline-flex; align-items: center; gap: 12px; max-width: 100%;
  font: inherit; text-align: left; cursor: pointer; color: var(--text);
  background: var(--accent-soft); border: 1px solid transparent; border-radius: 999px; padding: 6px 18px 6px 6px;
  transition: border-color .15s, transform .15s;
}
.ag-cta:hover { border-color: var(--accent); transform: translateY(-1px); }
.ag-cta .ag-ava { width: 40px; height: 40px; flex: none; }
.ag-cta span { display: flex; flex-direction: column; min-width: 0; }
.ag-cta b { font-size: 15px; color: var(--accent); }
.ag-cta small { font-size: 13px; color: var(--muted); }
.ag-cta em { font-style: normal; color: var(--accent); font-weight: 700; }

/* 右下角头像入口和招呼气泡 */
#ag-launch { position: fixed; right: 24px; bottom: 24px; z-index: 40; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
#ag-launch.away { display: none; }
.ag-launch-btn {
  position: relative; width: 60px; height: 60px; padding: 3px; border-radius: 50%; cursor: pointer;
  background: var(--surface); border: 2px solid var(--accent); box-shadow: 0 8px 24px rgb(30 111 217 / .3);
  transition: transform .15s;
}
.ag-launch-btn:hover { transform: scale(1.06); }
.ag-launch-btn .ag-online { right: 2px; bottom: 2px; }
.ag-bubble-tip {
  position: relative; max-width: 240px; font-size: 14px; line-height: 1.6; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 14px 14px 4px 14px;
  padding: 10px 28px 10px 14px; box-shadow: 0 6px 20px rgb(0 0 0 / .12); animation: ag-in .25s ease;
}
.ag-x { position: absolute; top: 4px; right: 6px; font-size: 12px; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 2px; }

/* 聊天窗口 */
#ag-win {
  position: fixed; right: 24px; bottom: 24px; z-index: 50; width: 400px; height: min(640px, calc(100vh - 48px));
  display: flex; flex-direction: column; overflow: hidden; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 18px 50px rgb(0 0 0 / .22);
  opacity: 0; transform: translateY(16px) scale(.98); transform-origin: bottom right; pointer-events: none;
  visibility: hidden; transition: opacity .18s, transform .18s, width .2s, height .2s, visibility 0s .18s;
}
#ag-win.open { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition: opacity .18s, transform .18s, width .2s, height .2s; }
#ag-win.wide { width: min(860px, calc(100vw - 48px)); height: calc(100vh - 48px); }
.ag-head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 14px; color: #fff;
  background: linear-gradient(135deg, var(--accent), #3b8bef); }
.ag-head-ava { position: relative; width: 42px; height: 42px; flex: none; padding: 2px; border-radius: 50%; background: rgb(255 255 255 / .9); }
.ag-head-ava .ag-online { border-color: #fff; }
.ag-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ag-title b { font-size: 16px; }
.ag-title small { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-icon { width: 32px; height: 32px; display: grid; place-items: center; flex: none; color: #fff; background: none; border: 0; border-radius: 8px; cursor: pointer; }
.ag-icon:hover { background: rgb(255 255 255 / .18); }
.ag-icon svg, .ag-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#ag-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.ag-row { display: flex; gap: 8px; align-items: flex-start; }
.ag-row.user { justify-content: flex-end; }
.ag-row > .ag-ava { width: 30px; height: 30px; flex: none; margin-top: 2px; }
.ag-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ag-chips button {
  font: inherit; font-size: 13px; padding: 3px 11px; border-radius: 999px; cursor: pointer;
  color: var(--accent); background: var(--accent-soft); border: 1px solid transparent;
}
.ag-chips button:hover { border-color: var(--accent); }
.ag-typing span { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--muted); animation: ag-dot 1.2s infinite; }
.ag-typing span:nth-child(2) { animation-delay: .2s; } .ag-typing span:nth-child(3) { animation-delay: .4s; }
.ag-typing.ag-cursor::after { content: none; }
@keyframes ag-dot { 0%, 80%, 100% { opacity: .25; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }
@keyframes ag-in { from { opacity: 0; transform: translateY(8px); } }

.ag-msg { font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; }
.ag-msg.user {
  max-width: 85%; background: var(--accent); color: #fff;
  padding: 8px 12px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap;
}
.ag-msg.bot {
  flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line);
  padding: 10px 12px; border-radius: 4px 14px 14px 14px;
}
.ag-msg.err { color: var(--alarm); font-size: 14px; }
.ag-msg p { margin: 0 0 8px; }
.ag-msg p:last-child { margin-bottom: 0; }
.ag-msg ul, .ag-msg ol { margin: 0 0 8px; padding-left: 22px; }
.ag-msg h4 { font-size: 15px; margin: 10px 0 4px; }
.ag-msg code { font-size: 13px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.ag-msg pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; overflow-x: auto; font-size: 13px; }
.ag-msg pre code { border: 0; padding: 0; background: none; }
.ag-msg .tbl { overflow-x: auto; margin: 0 0 8px; }
.ag-msg table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.ag-msg th, .ag-msg td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.ag-msg th { background: var(--bg); }
.ag-cursor::after { content: "▍"; color: var(--accent); animation: ag-blink 1s steps(2) infinite; }
@keyframes ag-blink { 50% { opacity: 0; } }

/* 执行过程：每次工具调用、耗时、token、费用 */
.ag-steps { margin: 0 0 8px; display: flex; flex-direction: column; gap: 4px; }
.ag-step { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: baseline; }
.ag-step i { font-style: normal; width: 14px; text-align: center; flex: none; }
.ag-step.node b { color: var(--text); font-weight: 600; }
.ag-step.tool { padding-left: 20px; }
.ag-memo { padding: 6px 14px; font-size: 12px; color: var(--muted); background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.ag-memo b { color: var(--accent); font-weight: 600; margin-right: 4px; }
.ag-step.run i::before { content: "⋯"; color: var(--accent); }
.ag-step.ok i::before { content: "✓"; color: var(--ok); }
.ag-step.bad i::before { content: "✗"; color: var(--alarm); }
.ag-trace { margin-top: 6px; font-size: 12px; color: var(--muted); }
.ag-trace summary { cursor: pointer; user-select: none; }
.ag-trace summary:hover { color: var(--accent); }
.ag-trace pre { margin: 6px 0 0; font-size: 12px; white-space: pre-wrap; max-height: 260px; overflow-y: auto; }

.ag-foot { border-top: 1px solid var(--line); padding: 10px 12px 10px; background: var(--surface); }
.ag-foot form { display: flex; gap: 8px; align-items: flex-end; }
.ag-foot textarea {
  flex: 1; font: inherit; font-size: 15px; line-height: 1.5; resize: none; max-height: 140px;
  padding: 8px 12px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 20px; outline: none;
}
.ag-foot textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ag-send { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  color: #fff; background: var(--accent); border: 0; }
.ag-send:disabled { opacity: .45; cursor: default; }
.ag-note { font-size: 11px; color: var(--muted); margin: 6px 4px 0; }

/* 助手高亮的项目卡片 */
.card.ag-hit { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: ag-pulse 1.2s ease 2; }
@keyframes ag-pulse { 50% { box-shadow: 0 0 0 7px var(--accent-soft); } }

@media (max-width: 620px) {
  #ag-win, #ag-win.wide { inset: 0; width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .ag-wide-btn { display: none; }
  #ag-launch { right: 16px; bottom: 16px; }
  .ag-cta small { display: none; }
}
