/* Aster agent UI. Everything is scoped under .ast so it can live inside other demos. */
.ast {
  --a-bg: #ffffff; --a-panel: #f6f5f2; --a-line: #e4e1da; --a-ink: #17191c; --a-muted: #676c73;
  --a-acc: #f2a516; --a-acc-ink: #7a4a00; --a-acc-soft: #fff4dc; --a-ok: #17803d; --a-bad: #b42318; --a-bad-soft: #fff1ef;
  --a-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  display: grid; grid-template-columns: minmax(0, 1fr); height: 100%; min-height: 0;
  background: var(--a-bg); color: var(--a-ink); font-size: 14px; line-height: 1.5;
}
.ast *, .ast *::before, .ast *::after { box-sizing: border-box; }
.ast.ast-host { display: contents; }
.ast button { font: inherit; color: inherit; cursor: pointer; }
.ast-i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ast-vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ast :focus-visible { outline: 2px solid var(--a-acc); outline-offset: 2px; }

/* sources */
.ast-srclist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ast-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; text-align: left; background: var(--a-bg); border: 1px solid var(--a-line); border-radius: 8px; }
button.ast-row:hover { border-color: #cfc9bd; }
.ast-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: transparent; border: 1.5px solid #b7b2a8; }
.ast-srclist li.is-on .ast-dot { background: var(--a-ok); border-color: var(--a-ok); box-shadow: 0 0 0 3px #17803d22; }
.ast-sn { flex: 1; min-width: 0; display: grid; }
.ast-sn b { font-weight: 600; font-size: 13px; }
.ast-sn small { color: var(--a-muted); font-size: 11.5px; }
.ast-sact { font-size: 12px; font-weight: 600; color: var(--a-acc-ink); }
.ast-srclist li:not(.is-on) .ast-sact { padding: 2px 8px; border-radius: 99px; background: var(--a-acc-soft); }
.ast-live { padding: 1px 8px; border-radius: 99px; background: #e7f5ec; color: var(--a-ok); font: 600 11px/1.6 var(--a-mono); text-transform: uppercase; letter-spacing: .04em; }
.ast-live.off { background: var(--a-panel); color: var(--a-muted); }

.ast-chat { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; min-width: 0; }
.ast-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--a-line); }
.ast-glyph { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--a-ink); color: var(--a-acc); flex: none; }
.ast-glyph.big { width: 44px; height: 44px; border-radius: 12px; }
.ast-glyph.big .ast-i { width: 22px; height: 22px; }
.ast-title { display: grid; line-height: 1.2; margin-right: auto; }
.ast-title b { font-size: 15px; }
.ast-model { font-size: 12px; color: var(--a-muted); }
.ast-model.live { color: var(--a-ok); font-weight: 600; }
.ast-demo { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--a-acc-soft); color: var(--a-acc-ink); font-size: 12px; font-weight: 600; white-space: nowrap; }
.ast-gear { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px solid var(--a-line); border-radius: 8px; background: var(--a-bg); font-size: 13px; font-weight: 600; }
.ast-gear:hover { border-color: #c9c3b7; }
.ast-compact .ast-gear { width: 30px; padding: 0; justify-content: center; }
.ast-compact .ast-gear span { display: none; }
.ast-x { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 6px; background: none; color: var(--a-muted); }
.ast-x:hover { background: var(--a-panel); color: var(--a-ink); }
.ast-log { overflow-y: auto; padding: 22px 18px 8px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }

.ast-hello { margin: auto; max-width: 560px; text-align: center; display: grid; justify-items: center; gap: 8px; padding: 20px 0; }
.ast-hello h3 { margin: 6px 0 0; font-size: 20px; letter-spacing: -.01em; }
.ast-hello p { margin: 0; color: var(--a-muted); }
.ast-sugg { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.ast-sugg button { padding: 7px 13px; border: 1px solid var(--a-line); border-radius: 99px; background: var(--a-bg); font-size: 13px; }
.ast-sugg button:hover { border-color: var(--a-acc); background: var(--a-acc-soft); }

.ast-msg { max-width: min(760px, 100%); }
.ast-user { align-self: flex-end; padding: 9px 14px; border-radius: 14px 14px 4px 14px; background: var(--a-ink); color: #fff; white-space: pre-wrap; }
.ast-bot { align-self: flex-start; width: 100%; }
.ast-body p { margin: 0 0 8px; }
.ast-body h4 { margin: 14px 0 4px; font-size: 13px; }
.ast-ul { margin: 4px 0 8px; padding-left: 18px; }
.ast-ul li { margin: 3px 0; }
.ast small { color: var(--a-muted); }
.ast-note { color: var(--a-muted); font-size: 13px; }
.ast-warn { padding: 8px 12px; border-radius: 8px; background: var(--a-acc-soft); color: var(--a-acc-ink); }
.ast-bad { color: var(--a-bad); font-weight: 600; }
.ast-ok { color: var(--a-ok); }
.ast-off { color: #b7b2a8; }
.ast-link { padding: 0; border: 0; background: none; color: var(--a-acc-ink) !important; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

.ast-t { width: 100%; margin: 6px 0 10px; border-collapse: collapse; font-size: 13px; }
.ast-t th { padding: 6px 8px; text-align: left; font: 500 11px/1.2 var(--a-mono); letter-spacing: .04em; text-transform: uppercase; color: var(--a-muted); border-bottom: 1px solid var(--a-line); }
.ast-t td { padding: 7px 8px; border-bottom: 1px solid var(--a-line); vertical-align: top; }
.ast-t td small { display: block; }
.ast-t .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* steps and sources used */
.ast-steps { margin-bottom: 8px; border: 1px solid var(--a-line); border-radius: 10px; background: var(--a-panel); font-size: 12.5px; }
.ast-steps summary { padding: 7px 12px; color: var(--a-muted); cursor: pointer; font-weight: 500; }
.ast-steps ol { list-style: none; margin: 0; padding: 0 12px 10px; display: grid; gap: 6px; }
.ast-steps li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ast-steps li.done .ast-i { color: var(--a-ok); }
.ast-steps li.skip { color: var(--a-muted); }
.ast-steps li.err .ast-i { color: var(--a-bad); }
.ast-steps em { color: var(--a-muted); font-style: normal; }
.ast-steps code { font: 11.5px var(--a-mono); color: var(--a-muted); word-break: break-all; }
.ast-sp { width: 14px; height: 14px; flex: none; border: 2px solid var(--a-line); border-top-color: var(--a-acc); border-radius: 50%; animation: ast-spin .8s linear infinite; display: inline-block; vertical-align: -2px; }
@keyframes ast-spin { to { transform: rotate(360deg); } }
.ast-cites { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ast-chip { padding: 2px 9px; border-radius: 99px; border: 1px solid var(--a-line); font-size: 11.5px; color: var(--a-muted); background: var(--a-bg); }
.ast-chip::before { content: "↳ "; }
.ast-chip.live { border-color: #bfe3cb; color: var(--a-ok); }
.ast-websrc { flex-basis: 100%; font-size: 12.5px; }
.ast-websrc summary { color: var(--a-muted); cursor: pointer; }
.ast-websrc ol { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 3px; }
.ast-body a, .ast-websrc a, .ast-t a { color: var(--a-acc-ink); text-underline-offset: 2px; }

/* action cards */
.ast-acts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 10px; }
.ast-card { min-width: 0; }
.ast-card { border: 1px solid var(--a-line); border-left: 4px solid var(--a-acc); border-radius: 10px; padding: 12px 14px; background: var(--a-bg); box-shadow: 0 1px 2px #0000000a; }
.ast-card.high { border-left-color: var(--a-bad); background: linear-gradient(var(--a-bad-soft), var(--a-bg) 60px); }
.ast-ch { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ast-kind { padding: 1px 8px; border-radius: 4px; background: var(--a-acc-soft); color: var(--a-acc-ink); font: 600 11px/1.6 var(--a-mono); text-transform: uppercase; letter-spacing: .04em; }
.ast-card.high .ast-kind { background: var(--a-bad-soft); color: var(--a-bad); }
.ast-kv { display: flex; gap: 10px; margin: 2px 0; font-size: 13px; }
.ast-kv span { width: 58px; flex: none; color: var(--a-muted); }
.ast-body2 { margin: 8px 0; padding: 10px 12px; max-height: 200px; overflow: auto; border-radius: 8px; background: var(--a-panel); font-family: inherit; font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; }
.ast-receipt:focus { outline: none; }
.ast-card details { margin: 6px 0; font-size: 12.5px; }
.ast-card summary { color: var(--a-muted); cursor: pointer; }
.ast-card details pre { margin: 6px 0 0; padding: 10px; border-radius: 8px; background: #16181b; color: #e7e3d8; font: 11.5px/1.5 var(--a-mono); overflow-x: auto; }
.ast-typed { display: block; margin: 8px 0; font-size: 13px; color: var(--a-bad); }
.ast-typed input { display: block; width: 100%; margin-top: 6px; padding: 7px 10px; border: 1px solid #f0b9b1; border-radius: 6px; font: inherit; }
.ast-cb { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 8px; color: var(--a-muted); }
.ast-receipt { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 8px 0 0; color: var(--a-ok); font-size: 13px; font-weight: 500; }
.ast-receipt.off { color: var(--a-muted); }
.ast-receipt code { font: 11.5px var(--a-mono); }

.ast-btn { padding: 7px 14px; border: 1px solid var(--a-line); border-radius: 8px; background: var(--a-bg); font-weight: 600; font-size: 13px; }
.ast-btn:hover { border-color: #c9c3b7; }
.ast-btn:disabled { opacity: .45; cursor: not-allowed; }
.ast-pri { background: var(--a-ink); border-color: var(--a-ink); color: #fff !important; }
.ast-pri:hover { background: #000; }
.ast-ghost { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; border-color: transparent; background: none; color: var(--a-muted) !important; }
.ast-ghost:hover { color: var(--a-ink) !important; }
.ast-danger { color: var(--a-bad) !important; margin-right: auto; }

/* composer */
.ast-in { display: flex; align-items: flex-end; gap: 8px; margin: 8px 18px 16px; padding: 8px 8px 8px 14px; border: 1px solid var(--a-line); border-radius: 14px; background: var(--a-bg); box-shadow: 0 2px 10px #0000000d; }
.ast-in:focus-within { border-color: var(--a-acc); }
.ast-in textarea:focus-visible { outline: 0; }
.ast-in textarea { flex: 1; min-height: 24px; max-height: 160px; padding: 6px 0; border: 0; outline: 0; resize: none; font: inherit; color: inherit; background: none; }
.ast-send { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: var(--a-ink); color: var(--a-acc) !important; }
.ast-send:disabled { opacity: .4; }

/* dialogs */
.ast dialog { border: 0; border-radius: 14px; padding: 0; width: min(460px, calc(100vw - 32px)); box-shadow: 0 20px 60px #0004; color: var(--a-ink); }
.ast dialog::backdrop { background: #12141766; }
.ast-form { display: grid; gap: 12px; padding: 18px 20px 20px; }
.ast-dh { display: flex; justify-content: space-between; align-items: center; }
.ast-dh h3 { margin: 0; font-size: 17px; }
.ast-muted { margin: 0; color: var(--a-muted); font-size: 13px; }
.ast-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.ast-form input { padding: 9px 11px; border: 1px solid var(--a-line); border-radius: 8px; font: 400 14px var(--a-mono); }
.ast-err { margin: 0; color: var(--a-bad); font-size: 13px; }
.ast-test { margin: 0; padding: 10px; border-radius: 8px; background: #16181b; color: #b9e3c3; font: 12px/1.5 var(--a-mono); white-space: pre-wrap; }
.ast-dbtn { display: flex; justify-content: flex-end; gap: 8px; }
.ast-set { width: min(580px, calc(100vw - 24px)) !important; max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--a-bg); }
.ast-dh h3 { display: flex; align-items: center; gap: 8px; }
.ast-sec { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--a-line); }
.ast-sec h4 { margin: 0; font-size: 14px; }
details.ast-sec summary { display: flex; justify-content: space-between; align-items: baseline; cursor: pointer; list-style: none; }
details.ast-sec summary::-webkit-details-marker { display: none; }
details.ast-sec summary h4::before { content: "▸ "; color: var(--a-muted); }
details.ast-sec[open] summary h4::before { content: "▾ "; }
details.ast-sec summary span { color: var(--a-muted); font-size: 12px; }
details.ast-sec > * + * { margin-top: 8px; }
.ast-keyf { display: grid; gap: 8px; }
.ast-keyrow { display: flex; gap: 8px; }
.ast-keyrow input { flex: 1; min-width: 0; }
.ast-form label.ast-chk { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.ast-form label.ast-chk input { width: auto; padding: 0; accent-color: var(--a-ink); }
.ast-status { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.ast-small { display: flex; gap: 6px; align-items: flex-start; font-size: 12px; }

@media (max-width: 760px) {
  .ast-demo { display: none; }
  .ast-gear span { display: none; }
  .ast-gear { width: 30px; padding: 0; justify-content: center; }
  .ast-head, .ast-log { padding-inline: 12px; }
  .ast-in { margin-inline: 10px; }
  .ast-keyrow { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { .ast-sp { animation-duration: 3s; } }

/* keep host-page table and header styles out of the agent */
.ast-head { background: var(--a-bg); color: var(--a-ink); }
.ast-body { overflow-x: auto; }
.ast-t { border: 0; border-radius: 0; box-shadow: none; background: none; }
.ast-t th, .ast-t td { white-space: normal; position: static; background: none; }
.ast-t th { padding: 6px 8px; }
.ast-t tbody tr { cursor: default; }
.ast-t tbody tr:hover { background: none; }
.ast-model { white-space: nowrap; }
.ast-compact .ast-demo { display: none; }
.ast-compact .ast-model::after { content: " · actions simulated"; }
.ast-compact .ast-t.aw th:nth-child(2), .ast-compact .ast-t.aw td:nth-child(2),
.ast-compact .ast-t.aw th:nth-child(4), .ast-compact .ast-t.aw td:nth-child(4) { display: none; }

/* full-page agent: center the conversation */
.ast:not(.ast-compact) .ast-log { padding-inline: max(18px, calc(50% - 420px)); }
.ast:not(.ast-compact) .ast-in { width: min(840px, calc(100% - 36px)); margin-inline: auto; }
.ast-compact .ast-model::after { content: none; }
