/* S1 Apex (s1-agent.js). The page is the approved mockup's t-agent, drawn by redesign-v3.css (.hd .hdr .hda .btn .conv .um .am .apex .stt .steps .ans .cite .st .comp .chips .chip .inp .go .fine).
 * Only the glue the mockup does not draw is here: the History drawer, markdown inside an answer, the empty and AI-off states, the stop button, the Think harder switch and the page's fit in the shell.
 * The text box inside .inp is styled by the shared `.comp .inp textarea` rule in s1-messages.css (the same composer). */
.s1ag-host { display: block; }
.s1ag { padding: 0; gap: 0; max-width: none; }
.s1ag-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- the page: header, then the conversation, then the composer band ---- */
/* One reading column for the conversation AND its composer (the mockup's 720px measure, wider and a step larger on big screens). The composer's rows fill it:
   see `.comp > *` in s1-messages.css for why they used to shrink to their content. test/browser/apex-composer-width.spec.mjs holds both. */
.s1ag { --s1ag-col: 760px; }
.s1ag .conv > *, .s1ag .comp > * { max-width: var(--s1ag-col); }
@media (min-width: 1600px) {
  .s1ag { --s1ag-col: 860px; }
  .s1ag .am p, .s1ag .um span, .s1ag .s1ag-md ul, .s1ag .s1ag-md ol { font-size: var(--s1-fs-4); }
  .s1ag .comp .inp { font-size: var(--s1-fs-4); }
  .s1ag .cite a { font-size: var(--s1-fs-3); }
}
.s1ag-shell { position: relative; display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; min-height: 0; overflow: hidden; }
.s1ag-main { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; min-height: 0; }
.s1ag-thread-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
/* The full page scrolls as a page (owner rule: no inner scroll boxes, nothing clipped): the shell, the column and the thread grow with the conversation, the main column
   (s1-shell.css) is the one scroller, and the composer sticks to the foot of it so it is always reachable. The floating panel (.s1ag--panel) keeps its own thread box. */
.s1ag:not(.s1ag--panel) .s1ag-shell { overflow: visible; min-height: auto; flex: 1 0 auto; }
.s1ag:not(.s1ag--panel) .s1ag-main:not(.is-empty) { min-height: auto; flex: 1 0 auto; }
.s1ag:not(.s1ag--panel) .s1ag-main:not(.is-empty) .s1ag-thread-wrap { min-height: auto; flex: 1 0 auto; }
.s1ag:not(.s1ag--panel) .s1ag-main:not(.is-empty) .s1ag-thread.conv { overflow: visible; flex: 1 0 auto; min-height: auto; }
.s1ag:not(.s1ag--panel) .comp { position: sticky; bottom: 0; z-index: 2; }
.s1ag-thread { min-width: 0; overscroll-behavior: contain; }
.s1ag-jump { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); box-shadow: var(--shadow-pop); border-radius: 99px; }
.s1ag-jump[hidden] { display: none; }
.s1ag-center { margin: auto; display: grid; justify-items: center; gap: calc(10px * var(--s1-scale, 1)); color: var(--mute); max-width: 420px; }
.s1ag-pad { padding: calc(14px * var(--s1-scale, 1)) var(--gut); display: grid; gap: calc(8px * var(--s1-scale, 1)); }
.um span { overflow-wrap: anywhere; text-align: left; }
.s1ag-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: calc(6px * var(--s1-scale, 1)); margin-top: -14px; margin-bottom: 22px; }
.s1ag-file { cursor: default; max-width: 100%; }

/* ---- an answer: markdown inside .ans (the mockup draws paragraphs; the rest is here) ---- */
.s1ag-md > :first-child { margin-top: 0; } .s1ag-md > :last-child { margin-bottom: 10px; }
.s1ag-md ul, .s1ag-md ol, .s1ag-t0-steps { margin: 0 0 10px; padding-left: 1.4em; font-size: var(--s1-fs-3); line-height: 1.6; }
.s1ag-md li + li { margin-top: .25em; }
.s1ag-md .rwt-md-h { margin: 1em 0 .4em; font-family: var(--display); font-weight: 700; line-height: 1.3; }
.s1ag-md h3.rwt-md-h { font-size: var(--s1-fs-4); } .s1ag-md h4.rwt-md-h { font-size: var(--s1-fs-4); } .s1ag-md h5.rwt-md-h { font-size: var(--s1-fs-4); } .s1ag-md h6.rwt-md-h { font-size: var(--s1-fs-3); }
.s1ag-md code { font: 500 var(--s1-fs-1)/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--well); border-radius: 5px; padding: 1px 5px; }
.s1ag-md pre { margin: 0 0 10px; padding: calc(12px * var(--s1-scale, 1)) calc(14px * var(--s1-scale, 1)); background: var(--well); border: 1px solid var(--line-soft); border-radius: 8px; overflow-x: auto; }
.s1ag-md pre code { background: none; padding: 0; font-size: var(--s1-fs-1); }
.s1ag-md blockquote { margin: 0 0 10px; padding: 2px 0 2px calc(14px * var(--s1-scale, 1)); font-style: italic; color: var(--ink-2); }
.s1ag-md hr { border: 0; border-top: 1px solid var(--line-soft); margin: 1em 0; }
.rwt-md-table { overflow-x: auto; margin: 0 0 10px; border: 1px solid var(--line-soft); border-radius: 8px; }
.rwt-md-table table { border-collapse: collapse; width: 100%; font-size: var(--s1-fs-3); }
.rwt-md-table th, .rwt-md-table td { padding: calc(7px * var(--s1-scale, 1)) calc(12px * var(--s1-scale, 1)); text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.rwt-md-table th { background: var(--well); font-weight: 700; white-space: nowrap; }
.rwt-md-table tr:last-child td { border-bottom: 0; }
.steps .late .ic { color: var(--late); }
.am.is-live .s1ag-md > :last-child::after { content: ""; display: inline-block; width: 7px; height: 1em; margin-left: 3px; vertical-align: text-bottom; background: var(--ink); opacity: .55; animation: s1ag-caret 1s steps(2, start) infinite; }
@keyframes s1ag-caret { to { visibility: hidden; } }
.s1ag-cards { display: grid; gap: calc(10px * var(--s1-scale, 1)); margin-bottom: 10px; }
.s1ag-cards:empty { display: none; }
.s1ag-t0-title { font-weight: 650; }
.s1ag-t0-act { margin-bottom: 10px; }

/* ---- empty and AI-off: a big Apex, one line, nothing else ---- */
.s1ag-empty { margin: auto; display: grid; justify-items: center; gap: calc(10px * var(--s1-scale, 1)); text-align: center; max-width: 640px; padding: calc(12px * var(--s1-scale, 1)) 0 calc(24px * var(--s1-scale, 1)); }
.s1ag-empty-mark { display: inline-flex; align-items: center; justify-content: center; width: 104px; height: 104px; }
.s1ag-empty-title { margin: 0; font: 800 var(--s1-fs-6)/1.2 var(--display); letter-spacing: -.02em; text-wrap: balance; }
/* A new conversation on a desktop: the greeting, the text box and the suggestions sit together in the middle of the page (s1-agent.js sets .is-empty),
   with the suggestions under the box where the eye already is. The first message moves the box to the foot, as in any conversation. */
@media (min-width: 861px) {
  .s1ag-main.is-empty { justify-content: center; padding-bottom: 6vh; }
  .s1ag-main.is-empty .s1ag-thread-wrap { flex: 0 0 auto; }
  .s1ag-main.is-empty .conv { flex: none; overflow: visible; padding-top: 0; padding-bottom: calc(22px * var(--s1-scale, 1)); width: 100%; }
  .s1ag-main.is-empty .s1ag-empty { padding: 0; }
  .s1ag-main.is-empty .comp { background: none; border-top: 0; padding-top: 0; }
  .s1ag-main.is-empty .comp .inp { order: 1; align-items: center; padding: calc(10px * var(--s1-scale, 1)) calc(10px * var(--s1-scale, 1)) calc(10px * var(--s1-scale, 1)) calc(12px * var(--s1-scale, 1)); border-radius: 16px; font-size: var(--s1-fs-4); box-shadow: 0 1px 2px rgb(17 19 24 / .05), 0 6px 24px rgb(17 19 24 / .06); }
  .s1ag-main.is-empty .s1ag-bar { order: 2; margin-top: 2px; }
  .s1ag-main.is-empty .comp [data-s1ag-chips] { order: 3; margin: 18px auto 0; justify-content: center; }
  .s1ag-main.is-empty .fine { order: 4; margin-top: 18px; }
}
.s1ag-empty-sub { margin: 0; color: var(--mute); font-size: var(--s1-fs-3); line-height: 1.55; max-width: 52ch; text-wrap: pretty; }
@media (min-width: 1600px) { .s1ag-empty-title { font-size: var(--s1-fs-7); } .s1ag-empty-sub { font-size: var(--s1-fs-4); } }

/* ---- the composer band: the files, the Think harder switch, the count ---- */
.s1ag-bar { display: flex; align-items: center; flex-wrap: wrap; gap: calc(6px * var(--s1-scale, 1)); margin-top: 8px; }
.s1ag-fchip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.s1ag-hermes { cursor: default; }
.s1ag-count { margin-left: auto; font-size: var(--s1-fs-1); color: var(--mute); font-variant-numeric: tabular-nums; }
.s1ag-stop-sq { display: inline-block; width: 11px; height: 11px; border-radius: 2px; background: currentColor; }

/* ---- History: the conversations list is a drawer at every width (opened by the History button, which appears once there is history) ---- */
.s1ag-side { position: absolute; inset: 0 0 0 auto; z-index: 3; width: min(320px, 86vw); display: flex; flex-direction: column; min-height: 0; background: var(--raised); border-left: 1px solid var(--line); box-shadow: var(--shadow-pop); transform: translateX(102%); visibility: hidden; transition: transform var(--d2) var(--ease), visibility 0s var(--d2); }
.s1ag-side.is-open { transform: none; visibility: visible; transition: transform var(--d3) var(--ease), visibility 0s; }
.s1ag-scrim { position: absolute; inset: 0; z-index: 2; background: rgb(17 19 24 / .38); }
.s1ag-scrim[hidden] { display: none; }
.s1ag-side-top { display: grid; gap: calc(8px * var(--s1-scale, 1)); padding: calc(12px * var(--s1-scale, 1)); }
.s1ag-sugg-btn { justify-content: flex-start; }
.s1ag-sugg-btn[aria-pressed="true"] { border-color: var(--ink); }
.s1ag-sugg-btn .n { margin-left: auto; }
.s1ag-side .srch { margin: 0; flex: none; }
.s1ag-side .srch input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; color: var(--ink); }
.s1ag-list-wrap { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 calc(6px * var(--s1-scale, 1)) calc(8px * var(--s1-scale, 1)); }
.s1ag-empty-list { font-size: var(--s1-fs-2); line-height: 1.5; }
.s1ag-sessions { list-style: none; margin: 0; padding: 0; }
.s1ag-item { display: flex; align-items: center; gap: 2px; }
.s1ag-row > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s1ag-pin { display: inline-flex; vertical-align: -1px; margin-right: 5px; color: var(--mute); }
.s1ag-more { flex: none; opacity: .75; } /* always visible: no control appears only on hover */
.s1ag-item:hover .s1ag-more, .s1ag-item:focus-within .s1ag-more, .s1ag-more[aria-expanded="true"] { opacity: 1; }

/* On the full page the shell grows with the conversation and the page scrolls, so a drawer pinned to the shell would sit at the top of a tall column, out of
   sight. It is pinned to the window instead (below the top bar), on the right where its History button is, and scrolls its own short list. */
.s1ag:not(.s1ag--panel) .s1ag-side { position: fixed; top: var(--s1-tb-h, 48px); right: 0; bottom: 0; left: auto; height: auto; z-index: 40; }
.s1ag:not(.s1ag--panel) .s1ag-scrim { position: fixed; top: var(--s1-tb-h, 48px); right: 0; bottom: 0; left: 0; z-index: 39; }
/* An answer is always shown whole: nothing on the page clamps or crops it. */
.s1ag .am, .s1ag .am > div, .s1ag .ans, .s1ag .ans p, .s1ag .s1ag-md, .s1ag .s1ag-md li { -webkit-line-clamp: unset; line-clamp: unset; max-height: none; overflow: visible; text-overflow: clip; }
.s1ag:not(.s1ag--panel) .s1ag-sugg { overflow: visible; }

/* Suggestions (nudges, clean-ups, merges) fill the conversation's place while open */
.s1ag-sugg { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: calc(16px * var(--s1-scale, 1)) var(--gut); }
.s1ag-sugg[hidden], .s1ag-thread-wrap[hidden] { display: none; }
.s1ag-sugg-title { margin: 0 0 4px; font: 800 var(--s1-fs-5)/1.2 var(--display); }
.s1ag-sugg-sub { margin: 0 0 14px; color: var(--mute); font-size: var(--s1-fs-3); }

@media (max-width: 860px) {
  .s1ag-shell { min-height: 300px; }
  .s1ag-input { font-size: var(--s1-fs-5); }
  .s1ag-composer kbd { display: none; }
  .s1ag-empty:not(.s1ag-empty--off):has(.s1ag-empty-mark) .s1ag-empty-sub { display: none; }
  .s1ag-empty-mark { zoom: .6; }
}
@media (forced-colors: active) {
  .s1ag-composer, .s1ag-side { border: 1px solid CanvasText; }
}
.chips[hidden], .chips:empty { display: none; }
/* Apex page has no page gutter (padding 0), so the kit's "run edge to edge" pull-out on a page header would drag the title off the grid. */
.k-page.s1ag > .hd { margin: 0; width: auto; } /* and its widened header (100% + two gutters) would run past the right edge and clip its buttons */
.s1ag .comp { grid-template-columns: minmax(0, 1fr); } /* the composer's rows shrink to the page; a grid column otherwise grows to its widest chip row */
.s1ag .comp .chip { max-width: 100%; white-space: normal; text-align: left; height: auto; min-height: 30px; line-height: 1.3; padding-block: 5px; }
