/* =====================================================================
   Arenyze AI Agent — the docs chat. Same structure as the Loquitur agent
   window (floating button, panel that slides in from the right and docks,
   centred mode, hero with suggestions, sources under every answer), drawn
   with the docs "developer family" tokens (docs.css v5 layer).
   ===================================================================== */
:root { --agx-w: clamp(380px, 34vw, 520px); --agx-ease: cubic-bezier(.22, .8, .24, 1); }
.agx svg, .agx-fab svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.agx svg.agx-logo, .agx-fab svg.agx-logo { stroke: none; }

/* floating button */
.agx-fab { position: fixed; right: 24px; bottom: max(22px, env(safe-area-inset-bottom)); z-index: 65; display: grid; place-items: center; width: 54px; height: 54px; padding: 0; border-radius: 50%; border: 1px solid var(--line-3); background: radial-gradient(120% 120% at 30% 20%, var(--s3), var(--s1)); color: var(--ink); cursor: pointer; box-shadow: 0 10px 30px -10px #000, 0 2px 6px #0006, 0 0 0 1px #ffffff06 inset; transition: transform .18s, box-shadow .18s, border-color .18s; }
.agx-fab:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--acc) 45%, var(--line-3)); box-shadow: 0 14px 34px -10px #000, 0 0 0 4px color-mix(in srgb, var(--acc) 12%, transparent); }
.agx-fab:focus-visible { outline: 2px solid var(--acc); outline-offset: 4px; }
.agx-fab .agx-logo { width: 27px; height: 30px; }
.agx-fab-dot { position: absolute; top: 2px; right: 1px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--bg); background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.agx-fab-dot[hidden] { display: none; }
.agx-fab[data-tip]::after { content: attr(data-tip); position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%) translateX(4px); padding: 6px 9px; border-radius: 7px; background: var(--s3); border: 1px solid var(--line-2); color: var(--ink); font: 600 12px/1 var(--f-ui); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.agx-fab:hover::after { opacity: 1; transform: translateY(-50%); }
html.agx-open .agx-fab { display: none; }
:root[data-theme="light"] .agx-fab { background: radial-gradient(120% 120% at 30% 20%, #fff, var(--s2)); box-shadow: 0 10px 28px -12px #0005, 0 2px 6px #0001; }

/* window: docked on the right (pushes the page on wide screens) */
.agx { position: fixed; z-index: 70; top: 0; left: calc(100vw - var(--agx-w)); width: var(--agx-w); height: 100dvh; display: flex; flex-direction: column; min-width: 0; overflow: hidden; background: var(--bg); border-left: 1px solid var(--line-2); box-shadow: -12px 0 40px -18px #000; color: var(--ink); font: 400 14px/1.6 var(--f-ui); container: agx / inline-size; animation: agx-slide-in .35s var(--agx-ease) both; transition: left .38s var(--agx-ease), top .38s var(--agx-ease), width .38s var(--agx-ease), height .38s var(--agx-ease), border-radius .38s var(--agx-ease); }
.agx[hidden] { display: none; }
.agx.no-anim { animation: none; }
/* Docked: the page makes room for the chat (wide screens); below 1200 px the chat lies over it. */
@media (min-width: 1200px) {
  html.agx-docked body { margin-right: var(--agx-w); }
  body { transition: margin-right .38s var(--agx-ease); }
  html.agx-docked .search-dlg { right: var(--agx-w); }
  html.agx-docked .shell.has-otp { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  html.agx-docked .otp { display: none; }
  html.agx-docked .top-links .btn:not(.btn-acc) { display: none; }
  html.agx-docked .search-btn { flex: 0 1 300px; white-space: nowrap; }
  html.agx-docked .search-btn span { overflow: hidden; text-overflow: ellipsis; }
}
@media (min-width: 1200px) and (max-width: 1640px) {
  html.agx-docked .top-links > a:not(.btn), html.agx-docked .top-links .vsep { display: none; }
  html.agx-docked .search-btn kbd { display: none; }
}
@keyframes agx-slide-in { from { transform: translateX(100%); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes agx-fade { from { opacity: 0; } to { opacity: 1; } }

/* header */
.agx-head { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px 16px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 92%, var(--s1)); flex: none; }
.agx-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--s2); border: 1px solid var(--line-2); flex: none; }
.agx-icon .agx-logo { width: 18px; height: 20px; }
.agx-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.agx-title b { font: 650 13.5px/1.1 var(--f-ui); letter-spacing: -.01em; display: flex; align-items: center; gap: 7px; }
.agx-title b i { font: 600 10.5px/1 var(--f-ui); font-style: normal; padding: 3px 6px; border-radius: 99px; border: 1px solid color-mix(in srgb, var(--acc) 35%, transparent); color: var(--acc); background: color-mix(in srgb, var(--acc) 8%, transparent); }
.agx-title small { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agx-ib { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid transparent; border-radius: var(--r-sm, 8px); background: transparent; color: var(--ink-3); cursor: pointer; flex: none; transition: background .15s, color .15s; }
.agx-ib:hover { background: var(--s2); color: var(--ink); }
.agx-ib:disabled { opacity: .4; pointer-events: none; }
.agx-ib svg { width: 17px; height: 17px; }

/* thread */
.agx-thread { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.agx-inner { max-width: 820px; margin: 0 auto; padding: 18px 18px 26px; }

/* hero */
.agx-hero { padding: 26px 2px 10px; text-align: center; }
.agx-avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--s2); border: 1px solid var(--line-2); flex: none; }
.agx-avatar .agx-logo { width: 15px; height: 17px; }
.agx-avatar.lg { width: 54px; height: 54px; border-radius: 15px; margin-bottom: 14px; background: radial-gradient(120% 120% at 30% 20%, var(--s3), var(--s1)); box-shadow: 0 0 0 6px color-mix(in srgb, var(--acc) 7%, transparent); }
.agx-avatar.lg .agx-logo { width: 28px; height: 31px; }
.agx-hero h2 { margin: 0; font: 700 23px/1.2 var(--f-ui); letter-spacing: -.025em; }
.agx-hero p { margin: 8px auto 0; max-width: 470px; color: var(--ink-3); font-size: 13.5px; }
.agx-hero-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 22px; text-align: left; }
@container agx (max-width: 620px) { .agx-hero-grid { grid-template-columns: 1fr; } }
.agx-card { display: flex; gap: 11px; align-items: flex-start; padding: 12px 13px; border: 1px solid var(--line-2); border-radius: var(--r, 12px); background: var(--s1); color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: background .15s, border-color .15s; }
.agx-card:hover { background: var(--s2); border-color: var(--line-3); }
.agx-card .ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--s3); color: var(--acc); flex: none; }
.agx-card .ic svg { width: 16px; height: 16px; }
.agx-card b { display: block; font: 600 13px/1.3 var(--f-ui); }
.agx-card span span { display: block; margin-top: 3px; font-size: 12.5px; line-height: 1.45; color: var(--ink-3); }

/* turns */
.agx-turn { margin: 20px 0; display: flex; gap: 10px; min-width: 0; }
.agx-turn.user { justify-content: flex-end; }
.agx-bubble { max-width: 86%; padding: 10px 14px; border-radius: 14px 14px 4px 14px; background: var(--s2); border: 1px solid var(--line-2); color: var(--ink); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.agx-turn.assistant { flex-direction: column; gap: 6px; }
.agx-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; font-size: 11px; color: var(--ink-4); }
.agx-meta b { color: var(--ink-2); font-weight: 650; font-size: 12px; }
.agx-badge { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 5px; background: var(--s3); color: var(--ink-3); font: 600 10.5px/1 var(--f-ui); }
.agx-badge.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.agx-body { min-width: 0; font-size: 14px; line-height: 1.65; color: var(--ink-2); overflow-wrap: anywhere; }
.agx-body > :first-child { margin-top: 0; }
.agx-body > :last-child { margin-bottom: 0; }
.agx-body p { margin: 0 0 10px; }
.agx-body strong { color: var(--ink); font-weight: 650; }
.agx-body h3, .agx-body h4, .agx-body h5 { margin: 16px 0 8px; font: 650 15px/1.3 var(--f-ui); letter-spacing: -.01em; color: var(--ink); }
.agx-body h4, .agx-body h5 { font-size: 13.5px; }
.agx-body ul, .agx-body ol { margin: 0 0 10px; padding-left: 20px; }
.agx-body li { margin: 3px 0; }
.agx-body li::marker { color: var(--ink-4); }
.agx-body blockquote { margin: 0 0 10px; padding: 8px 12px; border-left: 2px solid var(--acc); background: var(--s1); border-radius: 0 8px 8px 0; color: var(--ink-2); }
.agx-body hr { border: 0; border-top: 1px solid var(--line-2); margin: 14px 0; }
.agx-body a { color: var(--acc); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--acc) 35%, transparent); }
.agx-body code { font-size: .84em; }
.agx-body .table-wrap { margin: 4px 0 12px; }
.agx-body table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.agx-body th { text-align: left; padding: 8px 10px; background: var(--s2); color: var(--ink-3); font: 600 11.5px/1.3 var(--f-ui); }
.agx-body td { padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.agx-body .code { margin: 8px 0 12px; }
.agx-body .code pre { max-height: 380px; font-size: 12.3px; }
.agx-body .code-bar { gap: 8px; }
.agx-cite { display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 4px; margin: 0 1px; border-radius: 5px; background: var(--s3); color: var(--ink-2) !important; font: 650 10.5px/1 var(--f-mono); text-decoration: none !important; vertical-align: 2px; transition: background .15s, color .15s; }
.agx-cite:hover { background: color-mix(in srgb, var(--acc) 20%, var(--s3)); color: var(--ink) !important; }
.agx-code-src { display: inline-flex; align-items: center; gap: 6px; min-width: 0; margin-left: auto; height: 24px; padding: 0 8px; border-radius: 6px; background: #ffffff0a; border: 1px solid #ffffff14; color: #b9b9c6 !important; font: 600 11px/1 var(--f-ui); letter-spacing: 0; text-transform: none; text-decoration: none !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 62%; }
.agx-code-src:hover { color: #fff !important; border-color: color-mix(in srgb, var(--acc) 45%, transparent); }
.agx-code-src svg { width: 12px; height: 12px; }
.agx-code-src em { font-style: normal; color: var(--acc); }
.agx-code-src + .copy { margin-left: 0; }

/* actions + sources */
.agx-actions { display: flex; gap: 2px; margin-top: 2px; }
.agx-actions .agx-ib { width: 28px; height: 28px; }
.agx-actions .agx-ib svg { width: 15px; height: 15px; }
.agx-sources { margin-top: 4px; }
.agx-sources summary { display: inline-flex; align-items: center; gap: 6px; padding: 6px 0; cursor: pointer; list-style: none; color: var(--ink-3); font: 600 12px/1 var(--f-ui); }
.agx-sources summary::-webkit-details-marker { display: none; }
.agx-sources summary:hover { color: var(--ink); }
.agx-sources summary svg { width: 13px; height: 13px; transition: transform .2s; }
.agx-sources[open] summary svg { transform: rotate(180deg); }
.agx-sources .hide, .agx-sources[open] .show { display: none; }
.agx-sources[open] .hide { display: inline; }
.agx-src-list { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.agx-src { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--s1); color: var(--ink) !important; text-decoration: none !important; min-width: 0; transition: background .15s, border-color .15s; }
.agx-src:hover { background: var(--s2); border-color: var(--line-3); }
.agx-src .n { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--s3); color: var(--ink-2); font: 650 10.5px/1 var(--f-mono); flex: none; }
.agx-src .t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.agx-src .t b { font: 600 12.5px/1.3 var(--f-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agx-src .t span { font: 500 11px/1.2 var(--f-mono); color: var(--ink-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agx-src svg { margin-left: auto; width: 14px; height: 14px; color: var(--ink-4); }
.agx-src.related { opacity: .8; }

/* thinking */
.agx-thinking { display: flex; align-items: center; gap: 9px; padding: 6px 0; color: var(--ink-3); font-size: 13px; }
.agx-spin { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--s4); border-top-color: var(--acc); animation: agx-spin .8s linear infinite; flex: none; }
.agx-shine { background: linear-gradient(90deg, var(--ink-3) 0%, var(--ink) 45%, var(--ink-3) 90%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: agx-shine 1.8s linear infinite; }
.agx-steps { display: flex; flex-direction: column; gap: 5px; margin: 2px 0 4px; padding-left: 2px; }
.agx-step { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-4); }
.agx-step::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--s5); flex: none; }
.agx-step.done { color: var(--ink-3); }
.agx-step.done::before { background: var(--ok); }
@keyframes agx-spin { to { transform: rotate(360deg); } }
@keyframes agx-shine { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.agx-error { padding: 10px 12px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent); background: color-mix(in srgb, var(--bad) 7%, var(--s1)); color: var(--ink-2); font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.agx-error button { margin-left: auto; }

.agx-to-bottom { position: absolute; left: 50%; bottom: 128px; z-index: 3; transform: translateX(-50%); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--s2); color: var(--ink); cursor: pointer; box-shadow: 0 8px 20px -8px #000; }
.agx-to-bottom[hidden] { display: none; }

/* composer */
.agx-dock { flex: none; padding: 10px 14px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.agx-composer { max-width: 820px; margin: 0 auto; border: 1px solid var(--line-2); border-radius: 14px; background: var(--s1); transition: border-color .15s, box-shadow .15s; }
.agx-composer:focus-within { border-color: color-mix(in srgb, var(--acc) 45%, var(--line-2)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 10%, transparent); }
.agx-composer textarea { display: block; width: 100%; min-height: 46px; max-height: 200px; padding: 12px 14px 4px; border: 0; outline: 0; resize: none; background: transparent; color: var(--ink); font: 400 14px/1.5 var(--f-ui); }
.agx-composer textarea::placeholder { color: var(--ink-4); }
.agx-tools { display: flex; align-items: center; gap: 6px; padding: 6px 8px 8px; }
.agx-send { margin-left: auto; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: var(--acc); color: var(--acc-ink, #170f02); cursor: pointer; flex: none; box-shadow: 0 1px 0 #ffffff55 inset, 0 6px 16px -8px var(--acc); transition: background .15s, opacity .15s; }
.agx-send:hover { background: var(--acc-hi); }
.agx-send:disabled { opacity: .35; cursor: default; box-shadow: none; }
.agx-send svg { width: 16px; height: 16px; stroke-width: 2.2; }
.agx-send.stop { background: var(--s4); color: var(--ink); box-shadow: none; }
.agx-send.stop svg { fill: currentColor; stroke: none; width: 12px; height: 12px; }
.agx-hint { max-width: 820px; margin: 7px auto 0; text-align: center; font-size: 10.5px; color: var(--ink-4); }

/* mobile: full screen */
/* Phones and tablets: the chat takes the whole screen (Loquitur mobile layout). */
@media (max-width: 900px) {
  .agx { --agx-w: 100vw; inset: 0; left: 0; top: 0; width: 100%; height: 100vh; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; animation-name: agx-up; }
  .agx-head { min-height: 56px; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); gap: 8px; }
  .agx-ib { width: 40px; height: 40px; }
  .agx-ib svg { width: 19px; height: 19px; }
  .agx-title small { font-size: 10.5px; }
  .agx-dock { padding: 8px max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .agx-composer textarea { font-size: 16px; min-height: 44px; max-height: 140px; padding: 11px 12px 2px; }
  .agx-tools { padding: 4px 6px 6px; }
  .agx-send { width: 38px; height: 38px; }
  .agx-to-bottom { bottom: 96px; }
  .agx-fab { right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); width: 52px; height: 52px; }
  .agx-fab[data-tip]::after { content: none; }
  html.agx-open, html.agx-open body { overflow: hidden; overscroll-behavior: none; }
}
@keyframes agx-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 520px) {
  .agx-hint { display: none; }
  .agx-inner { padding: 14px 12px 20px; }
  .agx-bubble { max-width: 90%; }
  .agx-hero { padding: 14px 0 6px; }
  .agx-hero h2 { font-size: 20px; }
  .agx-hero p { font-size: 13px; }
  .agx-avatar.lg { width: 46px; height: 46px; margin-bottom: 10px; }
  .agx-hero-grid { margin-top: 16px; }
  .agx-card { padding: 11px 12px; }
  .agx-body { font-size: 14.5px; }
  .agx-body .code pre { font-size: 12px; padding: 12px; }
  .agx-body .code-bar { padding: 5px 5px 5px 10px; }
  .agx-code-src { max-width: 48%; }
  .agx-src { padding: 10px; }
}
@media (prefers-reduced-motion: reduce) { .agx, body { animation: none !important; transition: none !important; } .agx-shine { animation: none; color: var(--ink-2); background: none; } }
@media print { .agx, .agx-fab { display: none !important; } html.agx-docked body { margin-right: 0; } }
.agx-body .code-label, .agx-body .copy { white-space: nowrap; flex: none; }
@container agx (max-width: 460px) { .agx-body .copy span { display: none; } .agx-body .copy { padding: 0 7px; } }
