/* product layer: the View menu, the responsive shell (Product view = assistant only, Console view = sidebar + developer panel), the welcome card, shared icon buttons.
   (The top bar itself is the app header, 96-frame.css.) Colours come from 00-tokens.css only. */

/* ---------- shared controls ---------- */
.icon-btn { flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid transparent; border-radius: 9px; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg, .bar-btn svg, .bar-pt svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.seg { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.seg button { flex: 1; padding: 6px 10px; border: 0; border-radius: 8px; background: none; color: var(--muted); font: 500 12.5px var(--sans); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--primary-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--primary); }

/* ---------- the assistant's top bar ---------- */
.ag-main { container: agmain / inline-size; }
.bar-pt { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 4px 0 10px; border: 1px solid var(--edge, var(--border)); border-radius: 999px; background: var(--surface); color: var(--muted); }
.bar-pt select { max-width: 170px; height: 100%; padding: 0 6px 0 0; border: 0; background: transparent; color: var(--text); font: 600 13px var(--sans); text-overflow: ellipsis; cursor: pointer; }
.bar-pt select:focus-visible { outline-offset: 4px; }
.bar-btn { gap: 6px; height: 30px; padding: 0 10px; }
@container agmain (max-width: 700px) { .bar-btn span { display: none; } .bar-btn { padding: 0 8px; } }
@container agmain (max-width: 460px) { .bar-pt select { max-width: 110px; } #agFresh { display: none; } }

/* ---------- the View menu ---------- */
.bar-view { position: relative; }
.vmenu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: min(304px, calc(100vw - 24px)); display: grid; gap: 14px; padding: 12px; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface); box-shadow: var(--lift, var(--shadow)); animation: vm-in .14s ease; }
.vmenu[hidden] { display: none; }
@keyframes vm-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.vm-who { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; margin: -2px -2px 0; border: 0; border-radius: 10px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.vm-who:hover { background: var(--surface-2); }
.vm-av { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: var(--primary-ink); font: 700 12px var(--sans); }
.vm-nm { display: grid; min-width: 0; } .vm-nm b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .vm-nm small { color: var(--muted); }
.vm-g { display: grid; gap: 6px; }
.vm-l { font: 600 11px var(--sans); letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
.vm-h { font-size: 12px; line-height: 1.4; color: var(--muted); }
.vm-row { display: flex; align-items: center; width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: none; color: var(--text); font: 500 13px var(--sans); text-align: left; cursor: pointer; }
.vm-row:hover { background: var(--surface-2); }
@media (max-width: 1100px) { .vm-layout { display: none; } }

/* ---------- the shell: Product view (assistant only) and Console view (sidebar + pages) ---------- */
body:not(.dev) .sidebar, html.dev-pre:not(.x) body:not(.dev) .sidebar { display: none; }
body:not(.dev) .app { grid-template-columns: minmax(0, 1fr); }
html.dev-pre body:not(.dev) .sidebar { display: flex; }   /* before the script has run, a saved Console view must not flash the Product layout */
html.dev-pre body:not(.dev) .app { grid-template-columns: 244px minmax(0, 1fr); }
.nav-scrim, .nav-close { display: none; }
@media (max-width: 899px) {
  .app, html.dev-pre body:not(.dev) .app { grid-template-columns: minmax(0, 1fr); }
  html.dev-pre body:not(.dev) .sidebar { display: none; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(300px, 86vw); height: 100dvh; transform: translateX(-104%); transition: transform .22s ease; box-shadow: var(--lift, var(--shadow)); overflow-y: auto; }
  body.nav-open .sidebar { transform: none; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .42); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .nav-close { display: inline-grid; margin-left: auto; }
  .main { padding: 14px 14px 40px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar, .nav-scrim, .vmenu { transition: none; animation: none; } }

/* ---------- the welcome card (first visit, and Help) ---------- */
.ag-m.welcomemsg { max-width: none; padding: 0; background: none; }
.wl { position: relative; display: grid; gap: 16px; padding: 20px clamp(16px, 3cqw, 28px) 18px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.wl-x { position: absolute; top: 10px; right: 10px; }
.wl-h { padding-right: 34px; }
.wl-h h2 { margin: 0 0 4px; font: 600 clamp(19px, 3.4cqw, 24px)/1.2 var(--display); letter-spacing: -.02em; }
.wl-h p { margin: 0; max-width: 62ch; color: var(--muted); font-size: 14px; line-height: 1.55; }
.wl-k { margin: 0 0 8px; font: 600 11px var(--sans); letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
.wl-grid { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
@container agmain (min-width: 620px) { .wl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.wl-tile { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; transition: border-color .15s, background .15s, transform .15s; }
.wl-tile:hover { border-color: var(--primary); background: var(--primary-soft); }
.wl-tile:active { transform: translateY(1px); }
.wl-ic { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--primary-soft); color: var(--primary-text); }
.wl-ic svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.wl-t { display: grid; gap: 1px; min-width: 0; } .wl-t b { font-weight: 600; font-size: 13.5px; } .wl-t span { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.wl-how { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
@container agmain (min-width: 760px) { .wl-how { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
.wl-how li { display: grid; align-content: start; gap: 2px; font-size: 13px; line-height: 1.5; color: var(--muted); } .wl-how b { color: var(--text); font-weight: 600; }
.wl-f { display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap; padding-top: 4px; border-top: 1px solid var(--border); }
.wl-f small { color: var(--muted); }
.wl-tip { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px dashed var(--border-strong); border-radius: 12px; color: var(--muted); font-size: 13px; }
.wl-tip button { margin-left: auto; }

/* ---------- one reading column: the briefing, the conversation and the box line up ---------- */
.ag-main { --col: clamp(680px, 58vw, 920px); }
.ag-stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; } .ag-stage > .ag-msgs { flex: 1; min-height: 0; }
.ag-msgs > .ag-m.welcomemsg, .ag-msgs > .ag-m.summsg, .ag-msgs > .ag-m.landingmsg { width: 100%; max-width: var(--col); margin-inline: auto; }
.ag-composer { max-width: var(--col); }
.ag[data-size="classic"] .ag-msgs > .ag-m.welcomemsg, .ag[data-size="large"] .ag-msgs > .ag-m.welcomemsg { max-width: none; }
@media (max-width: 1100px) { .ag-main { --col: 100%; } .ag-msgs > .ag-m.welcomemsg { padding-inline: 12px; } }

/* ---------- the briefing: the agent telling you what it noticed (the hero of the page) ---------- */
.ag-msgs > .ag-m.summsg { position: relative !important; margin-top: 8px; margin-bottom: 0; padding: 16px clamp(16px, 3vw, 24px) 12px; border: 1px solid var(--border); border-radius: 18px; background: color-mix(in srgb, var(--surface-2) 62%, transparent) !important; box-shadow: none; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }   /* a light, quiet box: no heavy border, no shadow, no gradient */
.ag-msgs > .ag-m.landingmsg { margin-top: 0; margin-bottom: 12px; padding: 2px clamp(16px, 3vw, 26px) 16px; border: 1px solid var(--border-strong); border-top: 1px solid var(--border); border-radius: 0 0 18px 18px; background: var(--surface); box-shadow: var(--shadow); }
.landingmsg .pc-sep { display: none; }
.hero-h { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.hero-av { position: relative; flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--primary); color: var(--primary-ink); }
.hero-live { position: absolute; top: -3px; right: -3px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--surface); background: var(--amber); animation: pulse 1.8s ease-in-out infinite; }
.hero-who { display: grid; min-width: 0; } .hero-who b { font: 600 15px/1.25 var(--sans); letter-spacing: -.01em; } .hero-who small { color: var(--muted); font-size: 12px; }
.summsg .ag-answer { max-width: none; font-size: 16.5px; line-height: 1.62; }
.summsg .pc-h { display: none; }
@media (prefers-reduced-motion: reduce) { .hero-live { animation: none; } }

/* ---------- the dock: the briefing, kept at hand once the conversation has pushed it out of view ---------- */
.ag-dock { position: absolute; top: 10px; left: 50%; z-index: 12; display: flex; align-items: center; gap: 2px; padding: 4px; border: 1px solid var(--border-strong); border-radius: 999px; background: color-mix(in srgb, var(--surface) 88%, transparent); -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3); box-shadow: 0 6px 24px rgba(0, 0, 0, .14); transform: translateX(-50%); animation: dk-in .22s cubic-bezier(.2, .7, .2, 1) both; }
.ag-dock[hidden] { display: none; }
@keyframes dk-in { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.dk { display: inline-flex; align-items: center; gap: 6px; height: 34px; min-width: 34px; padding: 0 9px; border: 0; border-radius: 999px; background: none; color: var(--muted); font: 600 12.5px var(--sans); cursor: pointer; transition: background .15s, color .15s; }
.dk:hover { background: var(--surface-2); color: var(--text); } .dk.on { background: var(--primary-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--primary); } .dk.lab { color: var(--primary-text); padding-right: 12px; }
.dk b { min-width: 20px; padding: 1px 6px; border-radius: 99px; background: var(--surface-3); color: var(--text); font: 700 11.5px/1.5 var(--sans); text-align: center; } .dk b.warn { background: var(--red-soft); color: var(--red); }
.dk-sep { width: 1px; height: 18px; margin: 0 4px; background: var(--border); }
.dock-pop { position: absolute; top: 58px; left: 50%; z-index: 11; width: min(var(--col), calc(100% - 24px)); max-height: min(66%, 560px); overflow: auto; padding: 14px 16px; border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface); box-shadow: 0 14px 44px rgba(0, 0, 0, .22); transform: translateX(-50%); animation: dp-in .16s ease both; overscroll-behavior: contain; }
.dock-pop[hidden] { display: none; }
@keyframes dp-in { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }
.dp-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; } .dp-h b { display: inline-flex; align-items: center; gap: 7px; font: 600 14px var(--sans); } .dp-m { color: var(--muted); font-size: 12px; }
.dp-sum { max-width: none; font-size: 15px; line-height: 1.6; } .dp-f { display: flex; gap: 8px; margin-top: 12px; }
@media (max-width: 640px) { .dk.lab span { display: none; } .dk.lab { padding-right: 9px; } }
@media (prefers-reduced-motion: reduce) { .ag-dock, .dock-pop { animation: none; } }

/* ---------- the guide (Help) as a dialog ---------- */
.wl-modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; } .wl-modal[hidden] { display: none; }
.wl-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); opacity: 0; transition: opacity .18s; } .wl-modal.on .wl-scrim { opacity: 1; }
.wl-box { position: relative; width: min(880px, 100%); max-height: calc(100dvh - 32px); overflow: auto; border-radius: 18px; outline: none; opacity: 0; transform: translateY(8px); transition: opacity .18s, transform .18s; } .wl-modal.on .wl-box { opacity: 1; transform: none; }
.wl-box .wl { box-shadow: 0 24px 80px rgba(0, 0, 0, .35); }
.wl-box .wl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .wl-box .wl-how { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 640px) { .wl-box .wl-how { grid-template-columns: 1fr; } .wl-box .wl-grid { gap: 6px; } .wl-box .wl-tile { flex-direction: column; gap: 8px; padding: 10px; } .wl-box .wl-t span { display: none; } .wl-box .wl-f small { display: none; } }
@media (prefers-reduced-motion: reduce) { .wl-scrim, .wl-box { transition: none; } }
/* narrow (compact window, phone): the tiles become a two-column grid of titles, the examples are one tap away */
@container agmain (max-width: 520px) {
  .wl { gap: 14px; padding: 16px 14px; }
  .wl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .wl-tile { flex-direction: column; gap: 8px; padding: 10px; }
  .wl-t span { display: none; } .wl-t b { font-size: 13px; line-height: 1.25; }
  .wl-f { flex-direction: column; align-items: stretch; } .wl-f small { display: none; }
}
@media (max-width: 899px) { .sidebar { background: var(--side); -webkit-backdrop-filter: none; backdrop-filter: none; } }   /* a slide-over sits on the page: it must not be see-through */

/* ---------- stable streaming: a table or code block on its way holds its place as a skeleton, then replaces it in the same slot ---------- */
.ag-sk { display: grid; grid-template-rows: repeat(var(--n), 1fr); align-items: center; height: var(--h); transition: height .35s ease; margin: 14px 0; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.ag-sk i { display: block; height: 11px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 300% 100%; animation: sk-shine 1.5s linear infinite; }
.ag-sk i:nth-child(3n+1) { width: 94%; } .ag-sk i:nth-child(3n+2) { width: 82%; } .ag-sk i:nth-child(3n) { width: 88%; } .ag-sk i:first-child { width: 60%; height: 12px; }
.ag-sk-code { background: var(--surface-2); }
@keyframes sk-shine { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.ag-answer .ag-sk::after { display: none !important; }
.ag-answer .ag-tbl, .ag-answer pre { contain: layout; }
@media (prefers-reduced-motion: reduce) { .ag-sk i { animation: none; } }
/* the writing marker is out of the text flow (inline after a list or a table it sat on a line of its own, and that line vanished when the answer finished: the page moved) */
.ag-answer.replacing { opacity: .55; transition: opacity .2s; }   /* a replacement answer is being written: the text stays, dimmed, and is swapped once the new one has caught up */
.ag-answer.stopped { opacity: .6; transition: opacity .2s; }   /* Stop: what was written stays, dimmed, with a quiet "Stopped" under it */
.ag-stopped { margin-top: 6px; color: var(--muted); font: 12.5px var(--sans); }
.ag-conn { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--muted); font: 12.5px var(--sans); } .ag-conn .qdot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); animation: pulse 1.2s ease-in-out infinite; flex: none; }
.ag-fail-r { display: flex; align-items: center; justify-content: space-between; gap: 12px; } .ag-fail-r > span { min-width: 0; } .ag-fail-r .btn { flex: none; }   /* the error and its Retry on one line; the text wraps, the button never overlaps it */
.ag-composer .send.stop svg rect { fill: currentColor; stroke: none; }   /* the send button while an answer is written: a filled square = Stop */
@media (prefers-reduced-motion: reduce) { .ag-conn .qdot { animation: none; } }
.ag-answer.streaming > :last-child { position: relative; }
.ag-answer.streaming > :last-child::after { content: ''; position: absolute; left: 2px; bottom: -13px; width: 6px; height: 6px; margin: 0; border-radius: 50%; background: var(--amber); box-shadow: none; animation: pulse 1s ease-in-out infinite; }
.ag-sk { animation: sk-in .45s cubic-bezier(.2,.7,.2,1) both; }
@keyframes sk-in { from { height: 52px; opacity: 0; } to { height: var(--h); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ag-sk { animation: none; } }

/* ---------- tooltips (core/tips.js) ---------- */
.tip { position: fixed; z-index: 500; max-width: 250px; padding: 7px 11px; border-radius: 10px; background: var(--text); color: var(--bg); font: 500 12px/1.4 var(--sans); box-shadow: 0 6px 22px rgba(0,0,0,.28); pointer-events: none; opacity: 0; transform: translateY(3px); transition: opacity .12s ease, transform .12s ease; }
.tip[hidden] { display: none; } .tip.on { opacity: 1; transform: none; } .tip[data-side="below"] { transform: translateY(-3px); } .tip[data-side="below"].on { transform: none; }
.tip b { display: block; font-weight: 600; } .tip span { display: block; margin-top: 1px; opacity: .72; font-weight: 400; }
.tip::after { content: ''; position: absolute; left: var(--ax, 50%); width: 8px; height: 8px; background: inherit; border-radius: 2px; transform: translateX(-50%) rotate(45deg); }
.tip[data-side="above"]::after { bottom: -4px; } .tip[data-side="below"]::after { top: -4px; }
.ico { flex: none; }

/* ---------- icon actions (tooltips say what they do) ---------- */
.ic { flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid transparent; border-radius: 9px; background: none; color: var(--muted); cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.ic:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); } .ic.on { background: var(--primary-soft); color: var(--text); } .ic.ok:hover { color: var(--primary-text); border-color: var(--primary); }
.ic .ico { width: 16px; height: 16px; }
.pc-li > .ic, .ai > .pc-li > .ic { align-self: center; margin-left: 2px; }
.pc-col h3, .pc-new h3 { display: flex; align-items: center; gap: 8px; } .pc-col h3 .ico, .pc-new h3 .ico { color: var(--primary-text); }

/* ---------- the drawer: selection on the left, actions as icons on the right, one tray for everything selected ---------- */
.dr-row .dr-ck { order: -1; margin-right: 2px; } .dr-ck.off { visibility: hidden; }
.dr-btns { flex: none; display: inline-flex; align-items: center; gap: 2px; padding-right: 2px; }
.dr-wrap { gap: 2px; }
.dr-sel { display: flex; align-items: center; gap: 10px; margin: 0 10px 6px; padding: 7px 8px 7px 12px; border: 1px solid var(--primary); border-radius: 12px; background: var(--primary-soft); font-size: 13px; } .dr-sel[hidden] { display: none; }
.dr-sel .sel-n { display: inline-flex; align-items: center; gap: 6px; } .dr-sel .sel-n .ico { color: var(--primary-text); } .dr-sel .sel-k { color: var(--muted); text-transform: capitalize; } .dr-sel .sel-sp { flex: 1; }
.tab-sel { margin-left: 5px; padding: 0 6px; border-radius: 99px; background: var(--primary); color: var(--primary-ink); font: 700 10.5px/17px var(--sans); font-style: normal; }
.dr-row .dr-t { flex: 1; min-width: 0; text-align: left; }

/* the chips under the box: an icon, its name, a count; in a narrow chat only the icon and the count (the tooltip has the name) */
.ctxc { display: inline-flex; align-items: center; gap: 6px; } .ctxc .ico { color: var(--primary-text); }
@container agmain (max-width: 600px) { .ctxc .cl { display: none; } .ctxc { padding-inline: 9px; } }

/* the E/M level's three MDM elements under its code card */
.bl-mdm { display: grid; gap: 3px; margin: 6px 0 2px; font-size: 12.5px; line-height: 1.45; color: var(--muted); } .bl-mdm > div { display: flex; flex-wrap: wrap; gap: 3px 8px; align-items: baseline; } .bl-mdm b { min-width: 62px; font-weight: 500; color: var(--text); } .bl-mdm small { color: var(--faint); }
.ag-answer p.md-h { margin-bottom: 2px; margin-top: 14px; } .ag-answer p.md-h:first-child { margin-top: 0; }
