/* ==========================================================================
   AI agent widget (uses the colour tokens from site.css)
   ========================================================================== */
.ag { position: fixed; right: 20px; bottom: 20px; z-index: 60; font-size: 15px; }
/* Launcher: glowing orb + label */
.ag-launch {
  display: inline-flex; align-items: center; gap: 12px; padding: 7px 20px 7px 7px; border-radius: 999px;
  border: 1px solid var(--line); cursor: pointer; background: var(--surface); color: var(--ink); text-align: left;
  box-shadow: 0 18px 40px -18px rgba(10, 88, 104, .55), 0 2px 8px rgba(0, 0, 0, .08);
  transition: transform .3s var(--ease), box-shadow .3s, opacity .2s;
}
.ag-launch:hover { transform: translateY(-3px); box-shadow: 0 22px 46px -18px rgba(10, 88, 104, .7), 0 2px 8px rgba(0, 0, 0, .1); }
.ag-launch:hover .ag-orb__spark { transform: rotate(90deg) scale(1.08); }
.ag.is-open .ag-launch, .ag.is-open .ag-teaser { opacity: 0; pointer-events: none; transform: scale(.9); }
.ag-launch__text { display: grid; line-height: 1.2; }
.ag-launch__text b { font-family: var(--display); font-size: 15px; font-weight: 700; }
.ag-launch__text small { font-size: 11.5px; color: var(--muted); }

.ag-orb {
  position: relative; flex: none; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 30% 25%, #4fd1e4, #14a0b5 45%, #0a5868 100%);
  box-shadow: inset 0 -4px 10px rgba(0, 0, 0, .25), inset 0 3px 6px rgba(255, 255, 255, .35);
}
.ag-orb__halo {
  position: absolute; inset: -4px; border-radius: 50%; z-index: -1;
  background: conic-gradient(from 0deg, #63c6d6, transparent 30%, #9adbe6 50%, transparent 75%, #63c6d6);
  filter: blur(5px); opacity: .75; animation: agSpin 6s linear infinite;
}
.ag-orb__icon { width: 30px; height: 30px; overflow: visible; }
.ag-orb__bubble { fill: rgba(255, 255, 255, .16); stroke: #fff; stroke-width: 1.6; stroke-linejoin: round; }
.ag-orb__spark { fill: #fff; transform-origin: 16px 12.9px; transition: transform .5s var(--ease); animation: agPulse 2.8s ease-in-out infinite; }
.ag-orb__twinkle { fill: #fff; animation: agTwinkle 2.8s ease-in-out infinite; }
.ag-orb__live { position: absolute; right: 1px; bottom: 1px; width: 12px; height: 12px; border-radius: 50%; background: #3ccf8e; border: 2px solid var(--surface); }
@keyframes agSpin { to { transform: rotate(360deg); } }
@keyframes agPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes agTwinkle { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

/* Greeting bubble */
.ag-teaser {
  position: absolute; right: 0; bottom: calc(100% + 12px); width: 260px;
  padding: 14px 34px 14px 16px; border-radius: 16px 16px 4px 16px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  box-shadow: 0 20px 44px -20px rgba(0, 0, 0, .45); cursor: pointer;
  font-size: 13.5px; line-height: 1.5;
  animation: agTeaser .45s var(--ease);
  transition: opacity .2s, transform .2s;
}
.ag-teaser:hover { border-color: var(--accent); }
.ag-teaser__close {
  position: absolute; top: 6px; right: 8px; width: 24px; height: 24px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 17px; line-height: 1;
}
.ag-teaser__close:hover { background: var(--surface-2); color: var(--ink); }
@keyframes agTeaser { from { opacity: 0; transform: translateY(10px) scale(.96); } }

.ag-panel {
  position: absolute; right: 0; bottom: 0;
  width: min(410px, calc(100vw - 24px)); height: min(640px, calc(100dvh - 40px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 30px 80px -24px rgba(0, 0, 0, .45);
  animation: agIn .3s var(--ease);
}
@keyframes agIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.ag-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; border-bottom: 1px solid var(--line); }
.ag-avatar {
  position: relative; flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 25%, #4fd1e4, #14a0b5 45%, #0a5868 100%); color: #fff;
  font-family: var(--display); font-weight: 800; font-size: 14px;
}
.ag-avatar i { position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; background: #3ccf8e; border: 2px solid var(--surface); }
.ag-head__text { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.ag-head__text b { font-family: var(--display); font-size: 15px; }
.ag-head__text span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-icon { width: 34px; height: 34px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.ag-icon:hover { background: var(--surface-2); color: var(--ink); }
.ag-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.ag-log { flex: 1; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.ag-msg { display: grid; gap: 8px; max-width: 92%; }
.ag-msg--user { align-self: flex-end; justify-items: end; }
.ag-bubble { padding: 11px 14px; border-radius: 16px; line-height: 1.55; font-size: 14.5px; }
.ag-msg--bot .ag-bubble { background: var(--surface-2); border-top-left-radius: 6px; }
.ag-msg--user .ag-bubble { background: var(--accent); color: var(--on-accent); border-top-right-radius: 6px; }
.ag-msg--err .ag-bubble { background: rgba(239, 68, 68, .1); color: #e25555; }
.ag-bubble p + p, .ag-bubble p + ul, .ag-bubble ul + p, .ag-bubble p + ol, .ag-bubble ol + p { margin-top: 8px; }
.ag-bubble ul, .ag-bubble ol { margin: 0; padding-left: 18px; list-style: revert; display: grid; gap: 3px; }
.ag-bubble a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.ag-msg--user .ag-bubble a { color: inherit; }
.ag-bubble code { font-family: var(--mono); font-size: 12.5px; padding: 1px 5px; border-radius: 5px; background: var(--line); }

.ag-typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.ag-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: agDot 1.2s infinite ease-in-out; }
.ag-typing i:nth-child(2) { animation-delay: .15s; }
.ag-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes agDot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.ag-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-chip {
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink-2); cursor: pointer;
  padding: 7px 12px; border-radius: 999px; font-size: 13px; text-align: left; transition: border-color .2s, color .2s;
}
.ag-chip:hover { border-color: var(--accent); color: var(--accent); }

.ag-projects { display: grid; gap: 8px; }
.ag-project {
  display: grid; gap: 3px; text-align: left; cursor: pointer; padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); transition: border-color .2s, transform .2s var(--ease);
}
.ag-project:hover { border-color: var(--accent); transform: translateY(-1px); }
.ag-project__meta { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.ag-project b { font-family: var(--display); font-size: 15px; }
.ag-project__sum { font-size: 13px; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ag-project__cta { font-size: 12.5px; font-weight: 600; color: var(--accent); margin-top: 2px; }

.ag-blueprint { border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: grid; gap: 14px; background: var(--surface); }
.ag-kicker { display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.ag-blueprint__head b { font-family: var(--display); font-size: 17px; display: block; }
.ag-blueprint__head p { color: var(--muted); font-size: 13.5px; margin-top: 4px; line-height: 1.5; }
.ag-flow { display: grid; margin: 0; padding: 0; list-style: none; }
.ag-flow li { position: relative; display: grid; grid-template-columns: 26px 1fr; column-gap: 10px; padding-bottom: 12px; }
.ag-flow li:not(:last-child)::after { content: ""; position: absolute; left: 12px; top: 28px; bottom: 2px; width: 2px; border-radius: 2px; background: var(--accent-soft); }
.ag-flow__n { grid-row: span 2; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.ag-flow b { font-size: 14px; }
.ag-flow span:not(.ag-flow__n) { font-size: 13px; color: var(--muted); line-height: 1.45; }
.ag-blueprint__steps ul { margin: 0; padding-left: 18px; list-style: revert; display: grid; gap: 4px; font-size: 13.5px; }
.ag-blueprint__outcome { font-size: 13.5px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); }
.ag-blueprint__related { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-btn {
  justify-self: start; border: 0; cursor: pointer; padding: 10px 16px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 13.5px;
}
.ag-chess { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.ag-chess div { padding: 10px; border-radius: 12px; background: var(--surface-2); display: grid; }
.ag-chess small { font-size: 10.5px; color: var(--muted); font-family: var(--mono); }
.ag-chess b { font-family: var(--display); font-size: 20px; }
.ag-sent { padding: 12px 14px; border-radius: 14px; background: rgba(60, 207, 142, .12); color: var(--ink); font-size: 14px; }
.ag-sent span { color: #2fb67b; font-weight: 700; margin-right: 4px; }

.ag-form {
  display: flex; align-items: flex-end; gap: 8px; margin: 8px 12px 6px; padding: 6px 6px 6px 14px;
  border: 1px solid var(--line-strong); border-radius: 18px; background: var(--bg);
  transition: border-color .2s, box-shadow .2s;
}
.ag-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.ag-form textarea { flex: 1; border: 0; background: transparent; resize: none; outline: none; padding: 8px 0; max-height: 140px; line-height: 1.45; font-size: 14.5px; }
.ag-send { flex: none; width: 38px; height: 38px; border-radius: 12px; border: 0; cursor: pointer; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); }
.ag-send:disabled { opacity: .5; cursor: progress; }
.ag-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ag-foot { font-size: 11.5px; color: var(--muted); text-align: center; padding: 0 12px 10px; }
.ag-foot a { color: var(--accent); }

@media (max-width: 560px) {
  .ag { right: 14px; bottom: 14px; }
  .ag-launch__text { display: none; }
  .ag-launch { padding: 6px; }
  .ag-teaser { width: min(260px, calc(100vw - 40px)); }
  .ag.is-open { inset: 0; }
  .ag-panel { position: fixed; inset: 0; width: 100%; height: 100%; border-radius: 0; border: 0; }
}
@media print { .ag { display: none; } }
@media (prefers-reduced-motion: reduce) { .ag-orb__halo, .ag-orb__spark, .ag-orb__twinkle { animation: none; } }
