/* Ask Grapim's panel, and the page top bar with its button. Loaded by every
   team page in the hub and by the review desk at /w/<team>/<workspace>/, so
   it only relies on the shared tokens (ui/tokens.css) and names its own
   copies of the few base styles it needs (.agent-panel .btn-*, keyframes).
   Monochrome like the rest (design/brand.md): greys and black pills, green
   only for a confirmed action, the danger red only for errors and
   destructive buttons. References: reports/ux-2026-11/ask-grapim-references.md. */

@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes spin { to { transform: rotate(360deg); } }
.agent-panel .icon { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: -3px; }
.agent-panel .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: var(--fs-13); font-weight: 500; white-space: nowrap; cursor: pointer; transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.agent-panel .btn:hover { background: var(--surface-2); }
.agent-panel .btn:active:not(:disabled) { transform: scale(.97); }
.agent-panel .btn .icon { width: 14px; height: 14px; vertical-align: -2px; }
.agent-panel .btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.agent-panel .btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.agent-panel .btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.agent-panel .btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.agent-panel .btn-sm { height: 28px; padding: 0 12px; font-size: var(--fs-13); }
.agent-panel .btn:disabled { opacity: 0.55; cursor: not-allowed; }
.agent-panel .btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.agent-panel .reveal-value { flex: 1; min-width: 0; font-family: var(--mono); font-size: var(--fs-12); }
.agent-panel .num { font-variant-numeric: tabular-nums; }
.agent-panel .mono { font-family: var(--mono); }
.agent-panel kbd { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text-3); font: 500 var(--fs-11)/1 var(--font); }

/* ---------------------------------------------------------------- Ask Grapim (src/hub/agent/, agent.js)
   A docked panel on the right, resizable like the sidebar; a full-screen
   sheet on phones. Motion: the motion tokens, transform and opacity (the
   steps list also eases its grid rows open), all off under reduced motion. */

:root { --agent-w: 400px; }

/* The page's top bar: where you are on the left, Ask Grapim on the right. */
.main-bar {
  position: sticky; top: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 48px; padding: 0 12px 0 24px; flex: none;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.main-bar .crumbs { margin: 0; font-size: var(--fs-13); }
.main-bar .crumb.current { color: var(--text); font-weight: 500; }
.main-bar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.ask-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 12px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text); font-size: var(--fs-13); font-weight: 500;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.ask-btn:hover { background: var(--surface-2); }
.ask-btn:active { transform: translateY(0.5px); }
.ask-btn[aria-expanded="true"] { background: var(--surface-3); border-color: var(--border-strong); }
.ask-btn .icon { color: var(--text); }
.ask-btn span { white-space: nowrap; }
.ask-btn kbd { height: 18px; min-width: 18px; margin-left: 2px; font-size: var(--fs-11); border-bottom-width: 1px; color: var(--text-3); }
.ask-btn kbd + kbd { margin-left: -2px; }
.topbar .icon-btn[data-action="agent"] .icon { color: var(--accent-text); }

.ask-run .icon { color: var(--accent-text); }
.run-bar-review { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* The page makes room: a third grid column that eases open with the panel. */
.app:has(> .agent-panel) { grid-template-columns: var(--sidebar) minmax(0, 1fr) 0px; }
html[data-agent="open"] .app:has(> .agent-panel) { grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--agent-w); }
html[data-resizing] .app { transition: none; }

.agent-panel {
  grid-column: 3; grid-row: 1; position: sticky; top: 0; z-index: 10;
  width: var(--agent-w); height: 100vh; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--bg); padding: 8px 8px 8px 0;
}
.agent-card {
  position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
}
.agent-panel[hidden] { display: none; }
.agent-panel:focus { outline: none; }
.agent-panel.is-in { animation: agent-in var(--dur-slow) var(--ease-out); }
.agent-panel.is-out { animation: agent-out var(--dur) var(--ease-out) forwards; pointer-events: none; }
@keyframes agent-in { from { opacity: 0; transform: translateX(16px); } }
@keyframes agent-out { to { opacity: 0; transform: translateX(16px); } }

.agent-resize { position: absolute; top: 8px; bottom: 8px; left: -6px; width: 8px; z-index: 2; cursor: col-resize; touch-action: none; }
.agent-resize::after { content: ""; position: absolute; top: 16px; bottom: 16px; left: 3px; width: 2px; border-radius: 1px; background: var(--border-strong); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
.agent-resize:hover::after, html[data-resizing] .agent-resize::after { opacity: 1; transition-delay: 80ms; }
.agent-resize:focus-visible { outline: none; }
.agent-resize:focus-visible::after { opacity: 1; background: var(--focus); }

/* The header: the conversation's title, then history, new, close. Its
   hairline appears only once the log scrolls under it. */
.agent-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 44px; padding: 0 8px 0 14px; border-bottom: 1px solid transparent; flex: none; transition: border-color var(--dur) var(--ease-out); }
.agent-panel.is-scrolled .agent-head, .agent-panel.is-history .agent-head { border-bottom-color: var(--border); }
.agent-head-start { display: flex; align-items: center; gap: 2px; min-width: 0; }
.agent-back { margin-left: -8px; }
.agent-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: var(--fs-13); line-height: 20px; font-weight: 600; letter-spacing: -0.005em; }
.agent-title-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-panel.has-conv .agent-title { font-weight: 500; }
.agent-mark { color: var(--text); width: 15px; height: 15px; }
.agent-panel.has-conv .agent-title .agent-mark { color: var(--text-3); }
.agent-status { display: none; margin-right: 6px; font-size: var(--fs-12); white-space: nowrap; }
.agent-panel.is-busy .agent-status { display: inline-block; animation: fade-in var(--dur) var(--ease-out), agent-shimmer 1.8s linear infinite; }
.agent-head-actions { display: flex; align-items: center; gap: 0; flex: none; }
.agent-icon-btn { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: var(--radius); background: none; color: var(--text-3); cursor: pointer; transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.agent-icon-btn:hover { background: var(--surface-3); color: var(--text); }
.agent-icon-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.agent-icon-btn:disabled { opacity: .4; cursor: default; background: none; }
.agent-icon-btn[hidden] { display: none; }
.agent-head-actions .agent-icon-btn[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }

.agent-body { position: relative; flex: 1; min-height: 0; display: flex; }
.agent-log { position: relative; flex: 1; min-width: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 16px; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.agent-log:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

.agent-jump {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px 0 8px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text-2);
  font-size: var(--fs-12); font-weight: 500; box-shadow: var(--shadow-pop);
  animation: agent-jump-in var(--dur) var(--ease-out);
}
.agent-jump[hidden] { display: none; }
.agent-jump:hover { color: var(--text); }
.agent-jump .icon { width: 13px; height: 13px; }
@keyframes agent-jump-in { from { opacity: 0; transform: translate(-50%, 6px); } }

/* Empty: a mark, one line, the questions this page suggests, recent
   conversations, the keys. Rows, not boxes. Also "not set up" and the demo. */
.agent-empty { margin: auto 0 0; padding: 16px 0 4px; display: flex; flex-direction: column; align-items: stretch; gap: 0; }
.agent-empty-mark { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); margin-bottom: 14px; box-shadow: var(--shadow-1); }
.agent-empty-mark .icon { width: 16px; height: 16px; }
.agent-empty h3 { font-size: var(--fs-20); line-height: 28px; font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
.agent-empty > p { margin-top: 6px; color: var(--text-2); font-size: var(--fs-13); line-height: 20px; max-width: 44ch; text-wrap: pretty; }
.agent-off .agent-empty-mark { color: var(--text-3); }
.agent-fine { margin-top: 12px; font-size: var(--fs-12); line-height: 18px; color: var(--text-3); }
.agent-empty > .agent-fine { color: var(--text-3); font-size: var(--fs-12); line-height: 18px; }
.agent-fine a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.agent-fine code { font-family: var(--mono); background: var(--surface-3); padding: 1px 5px; border-radius: 4px; color: var(--text); }
.agent-section { margin-top: 24px; }
.agent-section + .agent-section { margin-top: 16px; }
.agent-section[hidden] { display: none; }
.agent-section-label { margin: 0 0 4px; font-size: var(--fs-11); line-height: 16px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.agent-starters { display: flex; flex-direction: column; margin: 0 -8px; padding: 0; list-style: none; }
.agent-starters > li { --i: 0; animation: rise-in var(--dur-slow) var(--ease-out) both; animation-delay: calc(var(--i) * 30ms + 40ms); }
.agent-starter {
  width: 100%; display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 7px 8px; cursor: pointer; text-align: left;
  border: 0; border-radius: var(--radius); background: none; color: var(--text); font-size: var(--fs-13); line-height: 20px;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.agent-starter:hover, .agent-starter:focus-visible { background: var(--surface-3); }
.agent-starter:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.agent-starter:active { transform: scale(.99); }
.agent-starter-icon { width: 15px; height: 15px; color: var(--text-3); }
.agent-starter-text { flex: 1; min-width: 0; }
.agent-starter.is-recent .agent-starter-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.agent-starter-count { flex: none; min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 999px; background: var(--text); color: var(--bg); font-size: var(--fs-11); font-weight: 600; line-height: 1; }
.agent-starter-count + .agent-starter-go { display: none; }
.agent-starter-meta { flex: none; color: var(--text-3); font-size: var(--fs-12); }
.agent-starter-go { width: 14px; height: 14px; color: var(--text-3); opacity: 0; transform: translateX(-4px); transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.agent-starter:hover .agent-starter-go, .agent-starter:focus-visible .agent-starter-go { opacity: 1; transform: none; }
.agent-keys { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 24px; color: var(--text-3); font-size: var(--fs-12); line-height: 18px; }
.agent-keys span { display: inline-flex; align-items: center; gap: 3px; }
.agent-keys kbd + kbd { margin-left: 1px; }
.agent-keys kbd { margin-right: 2px; }
.agent-loading { margin: auto 0; }

/* Messages: the question in a grey block on the right, the answer as
   plain prose at full width (no bubble, no avatar). */
.ag-msg { min-width: 0; overflow-wrap: anywhere; }
.ag-msg.is-live { animation: rise-in var(--dur) var(--ease-out); }
.msg-user { align-self: flex-end; max-width: 85%; padding: 8px 12px; border-radius: 12px; background: var(--surface-3); color: var(--text); font-size: var(--fs-14); line-height: 21px; white-space: pre-wrap; }
.msg-user + .msg-user { margin-top: -8px; }
.msg-notice { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 8px; color: var(--text-3); font-size: var(--fs-12); line-height: 18px; }
.msg-notice .notice-icon { width: 14px; height: 14px; margin-top: 2px; }
.msg-notice .notice-text { flex: 1; min-width: 0; }
/* Errors and offline: a hairline box with the mark in the danger red (grey
   when offline: nothing went wrong, it is just not connected), Retry inside. */
.msg-notice:is(.notice-error, .notice-offline, .notice-limit) { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text); font-size: var(--fs-13); line-height: 20px; }
.msg-notice:is(.notice-error, .notice-offline, .notice-limit) .notice-icon { margin-top: 3px; }
.msg-notice.notice-error .notice-icon, .msg-notice.notice-refusal .notice-icon { color: var(--danger); }
.msg-notice.notice-offline .notice-icon, .msg-notice.notice-limit .notice-icon { color: var(--text-2); }
.msg-notice.notice-refusal { color: var(--text-2); }
.msg-notice .msg-actions { flex-basis: 100%; padding-left: 22px; }
.msg-actions { display: flex; gap: 8px; }

/* Answers: compact prose. */
.agent-md { color: var(--text); font-size: var(--fs-14); line-height: 22px; }
.agent-md > * + *, .agent-md .md-done > * + *, .agent-md .md-done:not(:empty) + .md-open:not(:empty) { margin-top: 10px; }
.agent-md h3 { font-size: var(--fs-14); font-weight: 600; margin-top: 16px; }
.agent-md h4 { font-size: var(--fs-13); font-weight: 600; margin-top: 12px; }
.agent-md strong { font-weight: 600; }
.agent-md ul, .agent-md ol { padding-left: 18px; }
.agent-md ul { list-style: disc; }
.agent-md ol { list-style: decimal; }
.agent-md li { padding-left: 2px; }
.agent-md li::marker { color: var(--text-3); }
.agent-md code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
/* In prose, a repo or path reads as a name, not a button: mono only, no fill. */
.agent-md :is(p, li) > code { background: none; padding: 0; color: var(--text-2); }
.agent-md li + li { margin-top: 6px; }
.agent-md blockquote { padding-left: 12px; border-left: 2px solid var(--border-strong); color: var(--text-2); }
.agent-md a.link { color: var(--text); font-weight: 500; text-decoration: underline; text-decoration-color: var(--border-strong); text-decoration-thickness: 1px; text-underline-offset: 3px; transition: text-decoration-color var(--dur-fast) var(--ease-out); }
.agent-md a.link:hover { text-decoration-color: currentColor; }
.agent-table { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.agent-md table { border-collapse: collapse; width: 100%; font-size: var(--fs-12); line-height: 18px; font-variant-numeric: tabular-nums; }
.agent-md th, .agent-md td { text-align: left; padding: 7px 10px; border-top: 1px solid var(--border); vertical-align: top; }
.agent-md thead th { border-top: 0; color: var(--text-3); font-weight: 500; background: var(--surface-2); white-space: nowrap; }
.agent-md td a.link { font-family: var(--mono); font-weight: 400; }
.agent-code-wrap { position: relative; }
.agent-code { margin: 0; padding: 10px 0; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); font-family: var(--mono); font-size: var(--fs-12); line-height: 19px; scrollbar-width: thin; }
.agent-code code { display: block; width: max-content; min-width: 100%; padding: 0 64px 0 12px; background: none; border-radius: 0; font-size: inherit; white-space: pre; }
.agent-code .dl { display: inline-block; min-width: calc(100% + 76px); margin: 0 -64px 0 -12px; padding: 0 64px 0 12px; }
.agent-code .dl-add { background: var(--add-bg); color: var(--add-text); }
.agent-code .dl-del { background: var(--del-bg); color: var(--text-2); }
.agent-code .dl-hunk { color: var(--text-3); }
.agent-copy {
  position: absolute; top: 6px; right: 6px; height: 24px; padding: 0 10px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: var(--fs-12); font-weight: 500;
  opacity: 0; transition: opacity var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.agent-code-wrap:hover .agent-copy, .agent-copy:focus-visible, .agent-copy.is-done { opacity: 1; }
.agent-copy.is-done { color: var(--ok-text); }

/* Streaming: each new chunk fades in where it lands. */
.md-open { white-space: pre-wrap; }
.md-open:empty, .md-done:empty { display: none; }
.ag-tok { animation: fade-in var(--dur-slow) var(--ease-out); }

/* Before the first token: one line, where the steps line will appear. */
.ag-thinking { display: flex; align-items: center; gap: 8px; height: 26px; color: var(--text-3); font-size: var(--fs-13); font-weight: 500; animation: fade-in var(--dur) var(--ease-out); }
.ag-pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: agent-pulse 1.2s var(--ease-in-out) infinite; }
@keyframes agent-pulse { 50% { transform: scale(.55); opacity: .45; } }
/* Work in progress: a light passes over the label's grey text. */
.ag-shimmer, .ag-steps[data-state="running"] .ag-steps-sum-text, .ag-step[data-status="running"] .ag-step-label {
  color: transparent;
  background: linear-gradient(90deg, var(--text-3) 0%, var(--text-3) 38%, var(--text) 50%, var(--text-3) 62%, var(--text-3) 100%);
  background-size: 220% 100%; -webkit-background-clip: text; background-clip: text;
  animation: agent-shimmer 1.8s linear infinite;
}
@keyframes agent-shimmer { from { background-position: 150% 0; } to { background-position: -120% 0; } }

/* Tool steps: one grey line (what it read, the time it took), that opens to
   a row per step with its status at the end. */
.ag-steps { display: flex; flex-direction: column; font-size: var(--fs-13); color: var(--text-2); }
.ag-steps.is-live { animation: fade-in var(--dur) var(--ease-out); }
.ag-steps-sum {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; max-width: calc(100% + 8px); height: 26px; padding: 0 6px 0 8px; margin-left: -8px;
  border: 0; border-radius: var(--radius); background: none; color: var(--text-3); cursor: pointer; font-size: var(--fs-13); font-weight: 500;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.ag-steps-sum:hover { background: var(--surface-3); color: var(--text); }
.ag-steps-sum:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.ag-steps-sum-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-steps-time { flex: none; color: var(--text-3); font-weight: 400; }
.ag-steps-time:empty { display: none; }
.ag-steps-time::before { content: "·"; margin-right: 6px; }
.ag-steps-chev { width: 12px; height: 12px; flex: none; transition: transform var(--dur) var(--ease-out); }
.ag-steps.is-open .ag-steps-chev { transform: rotate(90deg); }
.ag-steps-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--dur-slow) var(--ease-out); }
.ag-steps.is-open .ag-steps-body { grid-template-rows: 1fr; }
.ag-steps-inner { min-height: 0; overflow: hidden; }
.ag-steps-list { display: flex; flex-direction: column; margin: 4px 0 2px; padding: 4px 0; list-style: none; border: 1px solid var(--border); border-radius: var(--radius); opacity: 0; transition: opacity var(--dur) var(--ease-out); }
.ag-steps.is-open .ag-steps-list { opacity: 1; }
.ag-step { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; padding: 0 10px 0 12px; font-size: var(--fs-12); }
.ag-step + .ag-step { border-top: 1px solid var(--border); }
.ag-step.is-live { animation: rise-in var(--dur) var(--ease-out); }
.ag-step-mark { width: 14px; height: 14px; flex: none; display: grid; place-items: center; }
.ag-step-mark > * { grid-area: 1 / 1; transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); }
.ag-step-mark .icon { width: 14px; height: 14px; opacity: 0; transform: scale(.6); }
.ag-step-check { color: var(--ok-text); }
.ag-step-x { color: var(--danger); }
.ag-spin { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid currentColor; border-right-color: transparent; opacity: .7; animation: spin 700ms linear infinite; }
.ag-step[data-status="done"] .ag-spin, .ag-step[data-status="error"] .ag-spin { opacity: 0; transform: scale(.6); }
.ag-step[data-status="done"] .ag-step-check, .ag-step[data-status="error"] .ag-step-x { opacity: 1; transform: none; }
.ag-step-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.ag-step[data-status="error"] .ag-step-label { color: var(--danger); }

/* Action cards: a precise card that waits for the person. What it is,
   what it will do, the facts in mono, one black pill and Cancel. */
.ag-act { padding: 14px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-1); transform-origin: 50% 0; transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out); }
.ag-act.is-live { animation: agent-card-in var(--dur-slow) var(--ease-out); }
@keyframes agent-card-in { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.act-head { display: flex; flex-direction: column; gap: 6px; }
.act-tag { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: var(--fs-11); font-weight: 500; line-height: 16px; letter-spacing: .08em; text-transform: uppercase; }
.act-tag-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text); }
.act-title { font-size: var(--fs-14); font-weight: 600; line-height: 20px; letter-spacing: -0.005em; overflow-wrap: anywhere; }
.act-effect { margin-top: 4px; color: var(--text-2); font-size: var(--fs-13); line-height: 20px; }
.act-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; margin: 12px 0 0; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-12); line-height: 18px; }
.act-facts:empty { display: none; }
.act-facts dt { color: var(--text-3); }
.act-facts dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.act-buttons { display: flex; align-items: center; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.act-hint { flex-basis: 100%; margin-top: 4px; color: var(--text-3); font-size: var(--fs-12); line-height: 18px; }
.act-ok .ag-spin { display: none; width: 10px; height: 10px; }
.act-ok[aria-busy="true"] { opacity: 1; }
.act-ok[aria-busy="true"] .ag-spin { display: block; }
.act-ok:disabled, .act-no:disabled { cursor: progress; }
.ag-act.is-pending { border-color: var(--text-3); }
.ag-act[data-status="done"] { border-color: var(--border); box-shadow: none; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn-danger-solid:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.act-result { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; font-size: var(--fs-13); line-height: 20px; color: var(--text); font-weight: 500; }
.act-done-mark { width: 18px; height: 18px; margin-top: 1px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--ok-bg); color: var(--ok-text); }
.act-done-mark .icon { width: 12px; height: 12px; }
.ag-act.is-confirmed .act-done-mark { animation: agent-check var(--dur-slow) var(--ease-out); }
.ag-act.is-confirmed .act-done-mark .icon { animation: agent-check-in var(--dur-slow) var(--ease-out) 60ms both; }
@keyframes agent-check { from { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } }
@keyframes agent-check-in { from { transform: scale(.3) rotate(-20deg); opacity: 0; } }
.act-failed { color: var(--danger); font-weight: 400; }
.act-failed .icon { width: 14px; height: 14px; margin-top: 3px; }
.act-secret { display: flex; gap: 6px; margin-top: 10px; }
.act-secret .reveal-value { flex: 1; min-width: 0; height: 32px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-2); color: var(--text); font-size: var(--fs-12); }
.act-secret .reveal-value:focus { outline: 2px solid var(--focus); outline-offset: -1px; }
.act-secret .btn { height: 32px; }
.act-fine { margin-top: 8px; color: var(--text-3); font-size: var(--fs-12); line-height: 18px; }
.act-link { margin-top: 8px; font-size: var(--fs-13); }
.act-link a.link { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.act-link a.link:hover { text-decoration-color: currentColor; }
.ag-act.is-leaving { opacity: 0; transform: scale(.98); }
.ag-act[data-status="cancelled"] { padding: 0; border-color: transparent; background: none; box-shadow: none; }
.ag-act.is-cancelled { animation: fade-in var(--dur) var(--ease-out); }
.act-line { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: var(--fs-12); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.act-line .icon { width: 12px; height: 12px; }

/* The composer: one box, the field on top and a toolbar under it. */
.agent-compose { flex: none; padding: 4px 10px 10px; }
.agent-field { border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-1); cursor: text; transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
.agent-field:focus-within { border-color: var(--text-3); box-shadow: 0 0 0 3px var(--surface-3); }
.agent-input { display: block; width: 100%; min-height: 44px; max-height: 180px; padding: 12px 14px 4px; border: 0; background: none; resize: none; font: 400 var(--fs-14)/20px var(--font); color: var(--text); }
.agent-input::placeholder { color: var(--text-3); }
.agent-input:focus-visible { outline: none; }
.agent-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px 6px 10px; }
.agent-toolbar-end { display: flex; align-items: center; gap: 8px; flex: none; }
.agent-chip { display: inline-flex; align-items: center; gap: 5px; min-width: 0; height: 22px; padding: 0 8px 0 6px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-2); font-size: var(--fs-12); font-weight: 500; cursor: default; }
.agent-chip .icon { width: 12px; height: 12px; color: var(--text-3); }
.agent-chip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-model { flex: none; color: var(--text-3); font-size: var(--fs-12); white-space: nowrap; }
.agent-model:empty { display: none; }
.agent-send {
  width: 28px; height: 28px; flex: none; display: grid; place-items: center; cursor: pointer;
  border: 0; border-radius: 999px; background: var(--surface-3); color: var(--text-3);
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.agent-send .icon { width: 15px; height: 15px; }
.agent-compose.has-text .agent-send, .agent-panel.is-busy .agent-send { background: var(--accent); color: var(--on-accent); }
.agent-compose.has-text .agent-send:hover, .agent-panel.is-busy .agent-send:hover { background: var(--accent-hover); }
.agent-send:active { transform: scale(.9); }
.agent-send:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.agent-send-icons { display: grid; }
.agent-send-icons .icon { grid-area: 1 / 1; transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); }
.agent-send .i-stop { opacity: 0; transform: scale(.5) rotate(-45deg); width: 13px; height: 13px; place-self: center; }
.agent-panel.is-busy .agent-send .i-send { opacity: 0; transform: translateY(-6px) scale(.6); }
.agent-panel.is-busy .agent-send .i-stop { opacity: 1; transform: none; }
.agent-offline { display: flex; align-items: center; gap: 8px; margin: 0 2px 6px; color: var(--text-2); font-size: var(--fs-12); line-height: 18px; animation: rise-in var(--dur) var(--ease-out); }
.agent-offline[hidden] { display: none; }
.agent-offline .icon { width: 14px; height: 14px; }
.agent-compose.is-offline .agent-field { border-style: dashed; }
.agent-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 6px; margin-top: 8px; padding: 0 4px; color: var(--text-3); font-size: var(--fs-11); line-height: 16px; text-align: center; }
.agent-foot .sep { color: var(--border-strong); }
.agent-usage { display: inline-flex; align-items: center; gap: 6px; }
.agent-meter { position: relative; width: 24px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.agent-meter-fill { position: absolute; inset: 0; background: var(--text-3); transform-origin: 0 50%; transition: transform var(--dur-slow) var(--ease-out); }
.agent-usage { color: var(--text-2); }
.agent-usage.is-out { color: var(--text); font-weight: 500; }

/* Answer actions: copy, good, bad; quiet until the answer is hovered. */
.ag-answer-actions { display: flex; gap: 2px; margin: -10px 0 0 -6px; opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
.agent-log > :is(.msg-text:hover, .ag-answer-actions:hover, .ag-answer-actions:focus-within), .ag-answer-actions.is-rated,
.ag-answer-actions.is-last, .msg-text:hover + .ag-answer-actions { opacity: 1; }
.ag-act-btn { width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: var(--radius); background: none; color: var(--text-3); cursor: pointer; transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.ag-act-btn .icon { width: 14px; height: 14px; }
.ag-act-btn:hover { background: var(--surface-3); color: var(--text); }
.ag-act-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.ag-act-btn[aria-pressed="true"] { color: var(--text); background: var(--surface-3); }
.ag-act-btn.is-done { color: var(--ok-text); }

/* Ask next: three questions under the latest answer, as quiet rows under a
   hairline; the hooked arrow says "and then". Gone once you ask. */
.ag-followups { margin-top: 2px; padding-top: 10px; border-top: 1px solid var(--border); }
.ag-followups-label { margin: 0 0 2px; font-size: var(--fs-12); line-height: 18px; font-weight: 500; color: var(--text-3); }
.ag-followups-list { display: flex; flex-direction: column; margin: 0 -8px; padding: 0; list-style: none; }
.ag-followups-list > li { --i: 0; animation: rise-in var(--dur-slow) var(--ease-out) both; animation-delay: calc(var(--i) * 40ms + 120ms); }
.ag-followup {
  display: flex; align-items: flex-start; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: var(--radius);
  background: none; color: var(--text-2); font: inherit; font-size: var(--fs-13); line-height: 20px; text-align: left; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.ag-followup:hover, .ag-followup:focus-visible { background: var(--surface-3); color: var(--text); }
.ag-followup:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.ag-followup:active { transform: scale(.99); }
.ag-followup-icon { width: 14px; height: 14px; margin-top: 3px; color: var(--text-3); flex: none; }

/* Past conversations. */
.ag-history { display: flex; flex-direction: column; gap: 0; margin: 0 -8px; }
.ag-history-item {
  --i: 0;
  width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; cursor: pointer; text-align: left;
  border: 0; border-radius: var(--radius); background: none; color: var(--text);
  animation: rise-in var(--dur) var(--ease-out) both; animation-delay: calc(var(--i) * 20ms);
  transition: background-color var(--dur-fast) var(--ease-out);
}
.ag-history-item:hover { background: var(--surface-3); }
.ag-history-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.ag-history-title { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-13); font-weight: 500; }
.ag-history-meta { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: var(--fs-12); font-variant-numeric: tabular-nums; }
.ag-history-now { padding: 0 6px; border: 1px solid var(--border-strong); border-radius: 999px; color: var(--text); font-size: var(--fs-11); font-weight: 500; line-height: 16px; }

/* Phones: a full-screen sheet that slides up over the page. */
@media (max-width: 860px) {
  .main-bar { position: static; height: auto; padding: 12px 16px 0; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; border: 0; }
  .main-bar .crumbs { font-size: var(--fs-12); }
  .main-bar-actions { display: none; }
  .app:has(> .agent-panel), html[data-agent="open"] .app:has(> .agent-panel) { grid-template-columns: minmax(0, 1fr); }
  .agent-panel { position: fixed; inset: 0; z-index: 70; grid-column: auto; width: auto; height: 100dvh; padding: 0; }
  .agent-card { border: 0; border-radius: 0; }
  .agent-panel.is-in { animation: agent-sheet-in var(--dur-slow) var(--ease-out); }
  .agent-panel.is-out { animation: agent-sheet-out var(--dur) var(--ease-out) forwards; }
  .agent-resize { display: none; }
  .agent-head { height: 52px; padding: 0 8px 0 16px; padding-top: env(safe-area-inset-top); }
  .agent-icon-btn { width: 36px; height: 36px; }
  .agent-log { padding: 8px 16px 20px; }
  .agent-compose { padding: 4px 8px max(8px, env(safe-area-inset-bottom)); }
  .agent-input { font-size: var(--fs-16); line-height: 22px; }
  .agent-send { width: 32px; height: 32px; }
  .agent-starter { min-height: 40px; }
  .msg-user { max-width: 90%; }
  .agent-keys { display: none; }
}
@keyframes agent-sheet-in { from { transform: translateY(100%); } }
@keyframes agent-sheet-out { to { transform: translateY(100%); } }

@media (hover: none) {
  .ask-btn kbd, .agent-keys { display: none; }
  .agent-copy { opacity: 1; }
  .ag-answer-actions { opacity: 1; }
  .ag-followup { min-height: 40px; align-items: center; }
  .ag-followup-icon { margin-top: 0; }
  .agent-starter-go { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ag-spin, .ag-pulse, .act-tag-dot { animation: none !important; }
  .ag-shimmer, .agent-status, .ag-steps[data-state="running"] .ag-steps-sum-text, .ag-step[data-status="running"] .ag-step-label { animation: none !important; background: none; color: var(--text-2); }
  .ag-steps-body, .ag-steps-list, .agent-head { transition: none; }
  .agent-starters > li, .ag-followups-list > li, .ag-history-item, .ag-act.is-confirmed .act-done-mark, .ag-act.is-confirmed .act-done-mark .icon, .agent-offline { animation: none; }
  .agent-starter-go { transition: none; }
}

/* The top bar's breadcrumb on its own (the review desk has no hub.css). */
.main-bar .crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-3); }
.main-bar .slash { color: var(--border-strong); }
.main-bar .crumb { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.main-bar a.crumb:hover { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.main-bar .crumb.current { color: var(--text); font-weight: 500; }
.main-bar .ask-btn kbd { display: inline-grid; place-items: center; padding: 0 4px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); font-family: var(--font); line-height: 1; }
.topbar .agent-top .icon { color: var(--accent-text); }
/* A toast sits beside the open panel, not over it. */
html[data-agent="open"] .toast { right: calc(var(--agent-w) + 16px); }
