/* "Ask my AI": prompt bars, the conversation panel and its launcher (assets/js/chat.js).

   The magic is the site's own dusk: the amber accent drifting through coral and rose
   into a cool lilac, turning slowly around every place you can ask. Ambient motion
   lives inside prefers-reduced-motion: no-preference, so with reduced motion the
   gradients simply hold still. */

@property --ai-angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@property --ai-reveal { syntax: "<percentage>"; inherits: false; initial-value: 130%; }

:root {
  --ai-1: #ffc46b;
  --ai-2: #ff8a50;
  --ai-3: #ff7ab6;
  --ai-4: #b79cff;
  --ai-stops: var(--ai-1), var(--ai-2) 30%, var(--ai-3) 55%, var(--ai-4) 78%, var(--ai-1);
  --ai-sweep: linear-gradient(100deg, var(--ai-1), var(--ai-2) 35%, var(--ai-3) 65%, var(--ai-4));

  --ai-field: linear-gradient(180deg, #121e19, #0c1511);
  --ai-panel: #0c1511;
  --ai-raised: rgba(255, 255, 255, .035);
  --ai-ink: #1b0f06;
  --ai-glow: .3;
  --ai-shadow: 0 44px 90px -36px rgba(0, 0, 0, .9), 0 0 70px -30px rgba(183, 156, 255, .35);
  --ai-user: linear-gradient(135deg, rgba(255, 183, 77, .2), rgba(255, 122, 182, .13));
  --ai-user-line: rgba(255, 183, 77, .32);
}

[data-theme="light"] {
  --ai-1: #f29a0f;
  --ai-2: #ee6a2c;
  --ai-3: #e0457f;
  --ai-4: #8a6cf0;

  --ai-field: linear-gradient(180deg, #fffefa, #fdf8ee);
  --ai-panel: #fffdf7;
  --ai-raised: rgba(16, 26, 22, .03);
  --ai-ink: #fffaf2;
  --ai-glow: .22;
  --ai-shadow: 0 44px 90px -40px rgba(74, 52, 16, .45), 0 0 70px -34px rgba(138, 108, 240, .35);
  --ai-user: linear-gradient(135deg, rgba(242, 154, 15, .2), rgba(224, 69, 127, .1));
  --ai-user-line: rgba(217, 130, 12, .35);
}

@keyframes ai-spin { to { --ai-angle: 360deg; } }
@keyframes ai-breathe { 0%, 100% { opacity: var(--ai-glow); transform: scale(.98); } 50% { opacity: calc(var(--ai-glow) * 1.6); transform: scale(1.02); } }
@keyframes ai-twinkle { 0%, 100% { transform: scale(1) rotate(0); opacity: 1; } 50% { transform: scale(.72) rotate(45deg); opacity: .7; } }
@keyframes ai-twinkle-sm { 0%, 100% { transform: scale(.6); opacity: .4; } 50% { transform: scale(1.15) rotate(90deg); opacity: 1; } }
@keyframes ai-rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes ai-pop { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes ai-reveal { from { --ai-reveal: 0%; filter: blur(2px); } to { --ai-reveal: 130%; filter: blur(0); } }
@keyframes ai-shimmer { to { background-position: -200% 0; } }
@keyframes ai-think { 0%, 100% { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(.7); } }
@keyframes ai-drift { from { transform: translate3d(-4%, -2%, 0) rotate(-4deg); } to { transform: translate3d(4%, 3%, 0) rotate(5deg); } }
@keyframes ai-ping { 0% { transform: scale(1); opacity: .8; } 80%, 100% { transform: scale(2.6); opacity: 0; } }
@keyframes ai-spark {
  0% { transform: rotate(var(--a)) translateY(0) scale(0); opacity: 1; }
  55% { opacity: 1; }
  100% { transform: rotate(var(--a)) translateY(calc(var(--r) * -1)) scale(var(--s)); opacity: 0; }
}

/* ═══════════════ the orb: the AI's face ═══════════════ */

.aiorb {
  position: relative;
  display: inline-grid; place-items: center;
  flex: none;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: conic-gradient(from var(--ai-angle), var(--ai-stops));
  box-shadow: 0 0 18px -4px rgba(255, 138, 80, .55), 0 0 26px -8px rgba(183, 156, 255, .6);
}
/* A soft highlight, so it reads as a lit pearl rather than a flat disc. */
.aiorb::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, .6), transparent 42%),
    radial-gradient(circle at 70% 85%, rgba(20, 10, 40, .25), transparent 55%);
}
.aiorb__spark {
  position: relative; z-index: 1;
  width: 48%; height: 48%;
  fill: #fffaf0;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, .8));
}

.aiorb--xs { width: 24px; height: 24px; box-shadow: 0 0 12px -3px rgba(255, 138, 80, .55); }
.aiorb--lg { width: 68px; height: 68px; }
.aiorb--lg::before {
  content: "";
  position: absolute; inset: -18px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(183, 156, 255, .35), rgba(255, 138, 80, .15) 45%, transparent 70%);
  filter: blur(6px);
  z-index: -1;
}
.aiorb--fab { width: 34px; height: 34px; }

@media (prefers-reduced-motion: no-preference) {
  .aiorb { animation: ai-spin 7s linear infinite; }
  .aiorb--lg::before { animation: ai-breathe 4.5s ease-in-out infinite; --ai-glow: .8; }
  .aiorb.is-thinking { animation-duration: 1.6s; }
  .aiorb.is-thinking .aiorb__spark { animation: ai-think 1.3s cubic-bezier(.5, 0, .5, 1) infinite; }
}

/* ═══════════════ fields: the glowing inputs ═══════════════ */

/* Two background layers: the field's own surface inside the padding box, and the
   turning gradient behind it that shows only through the transparent border. */
.aifield {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid transparent;
  background:
    var(--ai-field) padding-box,
    conic-gradient(from var(--ai-angle), var(--ai-stops)) border-box;
  transition: box-shadow .35s ease, transform .35s cubic-bezier(.2, .8, .3, 1);
}

/* The glow underneath. Its own static gradient, so only its opacity animates. */
.aifield::before {
  content: "";
  position: absolute; inset: 18% 6% -14%;
  z-index: -1;
  border-radius: inherit;
  background: var(--ai-sweep);
  filter: blur(22px);
  opacity: var(--ai-glow);
  transition: opacity .4s ease;
  pointer-events: none;
}

.aifield__input {
  flex: 1; min-width: 0;
  background: transparent;
  border: 0; outline: 0;
  color: var(--fg);
  font: 500 15px/1.4 Archivo, system-ui, sans-serif;
  caret-color: var(--ai-2);
}
.aifield__input::placeholder { color: var(--fg-faint); opacity: 1; }

.aisend {
  flex: none;
  display: grid; place-items: center;
  width: 42px; height: 42px; padding: 0;
  border: 0; border-radius: 50%;
  background: linear-gradient(140deg, var(--ai-1), var(--ai-2) 55%, var(--ai-3));
  color: var(--ai-ink);
  cursor: pointer;
  box-shadow: 0 8px 20px -8px rgba(255, 110, 90, .75), inset 0 1px 0 rgba(255, 255, 255, .5);
  transition: transform .35s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s ease, filter .3s ease, opacity .3s ease;
}
[data-theme="light"] .aisend { color: #fff; }
.aisend svg { width: 19px; height: 19px; fill: currentColor; transition: transform .35s cubic-bezier(.34, 1.56, .64, 1); }
.aisend:hover { transform: scale(1.07); box-shadow: 0 10px 26px -8px rgba(255, 110, 90, .9), inset 0 1px 0 rgba(255, 255, 255, .5); }
.aisend:hover svg { transform: translateY(-2px); }
.aisend:active { transform: scale(.93); }

/* ---------- the prompt bar ---------- */

.aibar { position: relative; isolation: isolate; display: flex; flex-direction: column; gap: 11px; }

.aibar__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.aibar__label {
  display: inline-flex; align-items: center; gap: 7px;
  margin: 0;
  font: 800 11px Archivo, sans-serif; letter-spacing: .18em; text-transform: uppercase;
}
.aibar__label span {
  background: var(--ai-sweep);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.aibar__label-i { width: 13px; height: 13px; fill: var(--ai-2); }
.aibar__hint { margin: 0; font-size: 12px; color: var(--fg-faint); }

.aifield--bar {
  height: 58px;
  padding: 0 7px 0 18px;
  border-radius: 999px;
}
/* No transform on the field itself: it would make the field a stacking context and
   pull the glow in front of its own surface. */
.aifield--bar:hover::before { opacity: calc(var(--ai-glow) * 1.5); }
.aifield--bar.is-focused::before { opacity: calc(var(--ai-glow) * 2); }

.aifield__sparks { position: relative; flex: none; width: 22px; height: 22px; }
.aifield__sparks .spark { position: absolute; }
.spark--big { left: 0; top: 3px; width: 17px; height: 17px; fill: var(--ai-2); }
.spark--small { right: -2px; top: -1px; width: 8px; height: 8px; fill: var(--ai-4); }

/* The input and the rotating examples share one box, so they line up exactly. */
.aifield__slot { position: relative; flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; }
.aifield__slot .aifield__input { height: 100%; }

.aifield--bar.has-ghost .aifield__input::placeholder { color: transparent; }
.aifield--bar.has-ghost.is-focused .aifield__input::placeholder { color: var(--fg-faint); }

.aighost {
  position: absolute; inset: 0;
  display: grid; align-items: center;
  pointer-events: none;
  overflow: hidden;
  color: var(--fg-faint);
  font: 500 15px/1.4 Archivo, system-ui, sans-serif;
  transition: opacity .25s ease;
}
.aighost__line {
  grid-area: 1 / 1;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  opacity: 0;
  transform: translateY(9px);
  filter: blur(5px);
  transition: opacity .7s ease, transform .8s cubic-bezier(.2, .8, .3, 1), filter .7s ease;
}
.aighost__line.is-on { opacity: 1; transform: none; filter: blur(0); }
.aighost__line:not(.is-on) { transform: translateY(-9px); }
.aighost__line.is-on ~ .aighost__line:not(.is-on) { transform: translateY(9px); }
.aifield.is-focused .aighost, .aifield.has-text .aighost { opacity: 0; }

.aifield__kbd {
  display: none;
  flex: none;
  min-width: 22px; height: 22px;
  place-items: center;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: var(--fg-faint);
  font: 700 11px/1 Archivo, sans-serif;
  transition: opacity .2s ease;
}
@media (hover: hover) and (pointer: fine) {
  .aifield__kbd { display: grid; }
}
.aifield.is-focused .aifield__kbd, .aifield.has-text .aifield__kbd { opacity: 0; }

.aibar__chips { display: flex; gap: 8px; flex-wrap: wrap; }

.aichip {
  display: inline-flex; align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--hero-surface, var(--fill));
  color: var(--fg-dim);
  font: 600 12.5px Archivo, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: color .2s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1), border-color .2s ease, box-shadow .3s ease;
}
.aichip:hover {
  color: var(--fg);
  border-color: transparent;
  background:
    linear-gradient(var(--ai-panel), var(--ai-panel)) padding-box,
    var(--ai-sweep) border-box;
  transform: translateY(-2px);
  box-shadow: 0 10px 22px -14px rgba(255, 122, 182, .6);
}
.aichip:active { transform: translateY(0) scale(.97); }

@media (prefers-reduced-motion: no-preference) {
  .aifield--bar { animation: ai-spin 9s linear infinite; }
  .aifield--bar::before { animation: ai-breathe 5s ease-in-out infinite; }
  .aifield--bar:hover::before, .aifield--bar.is-focused::before { animation: none; }
  .spark--big { animation: ai-twinkle 3.6s ease-in-out infinite; }
  .spark--small { animation: ai-twinkle-sm 3.6s ease-in-out infinite .4s; }
}

/* ═══════════════ the panel ═══════════════ */

.aichat {
  position: fixed;
  right: 24px; bottom: 24px;
  z-index: 90;
  display: flex; flex-direction: column;
  width: min(420px, calc(100vw - 48px));
  height: min(660px, calc(100dvh - 104px));
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  background: var(--ai-panel);
  box-shadow: var(--ai-shadow);
  overflow: hidden;
  isolation: isolate;
  transform-origin: 100% 100%;
}
.aichat[hidden] { display: none; }

/* Hairline of light along the top edge. */
.aichat::before {
  content: "";
  position: absolute; top: 0; left: 12%; right: 12%; height: 1px; z-index: 3;
  background: linear-gradient(90deg, transparent, var(--ai-1), var(--ai-3), var(--ai-4), transparent);
  opacity: .8;
}

.aichat__aura {
  position: absolute; left: -25%; right: -25%; top: -140px; height: 340px;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(38% 55% at 28% 55%, rgba(255, 183, 77, .17), transparent 70%),
    radial-gradient(40% 58% at 72% 45%, rgba(183, 156, 255, .2), transparent 70%),
    radial-gradient(30% 45% at 52% 72%, rgba(255, 122, 182, .12), transparent 70%);
}
[data-theme="light"] .aichat__aura { opacity: .75; }
.aichat.is-empty .aichat__aura { top: -40px; height: 420px; }

.aichat__grip { display: none; }

.aichat__head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 14px 12px 18px;
}
.aichat__id { flex: 1; min-width: 0; }
.aichat__title { margin: 0; font: 800 15px/1.2 Archivo, sans-serif; letter-spacing: -.01em; }
.aichat__sub {
  display: flex; align-items: center; gap: 7px;
  margin: 3px 0 0;
  font-size: 12px; color: var(--fg-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aichat__live { position: relative; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--ai-2); }
.aichat__live::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 1px solid var(--ai-2); }

.aichat__tool {
  flex: none;
  display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--line-soft);
  border-radius: 50%;
  background: var(--ai-raised);
  color: var(--fg-dim);
  cursor: pointer;
  transition: color .2s ease, background-color .2s ease, border-color .2s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1);
}
.aichat__tool[hidden] { display: none; }
.aichat__tool svg { width: 17px; height: 17px; fill: currentColor; }
.aichat__tool:hover { color: var(--fg); border-color: var(--line); background: var(--fill-strong); }
.aichat__fresh:hover svg { transform: rotate(-90deg); transition: transform .4s ease; }
.aichat__close:hover { transform: rotate(90deg); }

.aichat__body {
  flex: 1; min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: 4px 18px 16px;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 16px);
  mask-image: linear-gradient(to bottom, transparent, #000 16px);
}

/* ---------- welcome ---------- */

.aichat__hello {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: 26px 4px 4px;
}
.aichat__hello[hidden] { display: none; }
.aichat__hello-t { margin: 20px 0 0; font: 800 21px/1.2 Archivo, sans-serif; letter-spacing: -.02em; }
.aichat__hello-s { margin: 8px 0 0; max-width: 300px; font-size: 14px; line-height: 1.5; color: var(--fg-dim); }

.aichat__ideas { width: 100%; display: grid; gap: 8px; margin-top: 22px; }

.aichat__idea {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px 10px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--ai-raised);
  color: var(--fg);
  font: 600 13.5px/1.35 Archivo, sans-serif;
  text-align: left;
  cursor: pointer;
  transition: border-color .2s ease, background-color .2s ease, transform .3s cubic-bezier(.2, .8, .3, 1);
}
.aichat__idea svg { flex: none; width: 16px; height: 16px; fill: var(--fg-faint); transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), fill .2s ease; }
.aichat__idea:hover {
  border-color: transparent;
  background:
    linear-gradient(var(--ai-panel), var(--ai-panel)) padding-box,
    var(--ai-sweep) border-box;
  transform: translateY(-1px);
}
.aichat__idea:hover svg { transform: translateX(3px); fill: var(--ai-2); }

/* ---------- messages ---------- */

.aichat__log { display: flex; flex-direction: column; gap: 16px; padding-top: 10px; }
.aichat__log:empty { display: none; }

.aimsg { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.aimsg__text {
  min-width: 0;
  font-size: 14.5px; line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.aimsg__text a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.aimsg__text a:hover { text-decoration-thickness: 2px; }

.aimsg--user { justify-content: flex-end; }
.aimsg--user .aimsg__text {
  max-width: 84%;
  padding: 10px 15px;
  border: 1px solid var(--ai-user-line);
  border-radius: 20px 20px 6px 20px;
  background: var(--ai-user);
  line-height: 1.5;
}

.aimsg--bot .aiorb, .aimsg--err .aiorb { margin-top: 1px; }
.aimsg--bot .aimsg__text { flex: 1; padding-top: 1px; color: var(--fg); }

.aimsg--err .aimsg__text {
  flex: 1;
  padding: 9px 13px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--fg-dim);
  font-size: 13.5px;
}

.aishimmer {
  display: inline-block;
  font-weight: 600;
  background: linear-gradient(90deg, var(--fg-faint) 0%, var(--fg-faint) 35%, var(--ai-1) 45%, var(--ai-3) 52%, var(--ai-4) 58%, var(--fg-faint) 68%, var(--fg-faint) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

@media (prefers-reduced-motion: no-preference) {
  .aichat__aura { animation: ai-drift 11s ease-in-out infinite alternate; }
  .aichat__live::after { animation: ai-ping 2.4s cubic-bezier(.2, .7, .3, 1) infinite; }
  .aishimmer { animation: ai-shimmer 1.8s linear infinite; }

  .aichat:not([hidden]) .aichat__hello .aiorb,
  .aichat:not([hidden]) .aichat__hello-t,
  .aichat:not([hidden]) .aichat__hello-s,
  .aichat:not([hidden]) .aichat__idea { animation: ai-rise .6s cubic-bezier(.2, .8, .3, 1) backwards; }
  .aichat:not([hidden]) .aichat__hello .aiorb { animation: ai-spin 7s linear infinite, ai-rise .6s cubic-bezier(.2, .8, .3, 1) backwards; }
  .aichat:not([hidden]) .aichat__hello-t { animation-delay: .08s; }
  .aichat:not([hidden]) .aichat__hello-s { animation-delay: .13s; }
  .aichat:not([hidden]) .aichat__idea:nth-child(1) { animation-delay: .2s; }
  .aichat:not([hidden]) .aichat__idea:nth-child(2) { animation-delay: .26s; }
  .aichat:not([hidden]) .aichat__idea:nth-child(3) { animation-delay: .32s; }
  .aichat:not([hidden]) .aichat__idea:nth-child(4) { animation-delay: .38s; }

  .aimsg.is-new.aimsg--user .aimsg__text { animation: ai-pop .4s cubic-bezier(.2, .8, .3, 1); transform-origin: 100% 100%; }
  .aimsg--thinking, .aimsg.is-new.aimsg--err { animation: ai-rise .4s cubic-bezier(.2, .8, .3, 1); }

  /* The reply surfaces top to bottom, as if written into place. */
  .aimsg.is-new.aimsg--bot .aimsg__text {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(var(--ai-reveal) - 30%), transparent var(--ai-reveal));
    mask-image: linear-gradient(to bottom, #000 calc(var(--ai-reveal) - 30%), transparent var(--ai-reveal));
    animation: ai-reveal 1.1s cubic-bezier(.3, .6, .25, 1) both;
  }
}

/* ---------- composer ---------- */

.aichat__form { padding: 10px 14px 12px; border-top: 1px solid var(--line-soft); }

.aifield--compose {
  align-items: flex-end;
  padding: 6px 6px 6px 16px;
  border-radius: 24px;
  background:
    var(--ai-field) padding-box,
    linear-gradient(var(--line), var(--line)) border-box;
}
.aifield--compose::before { opacity: 0; }
.aifield--compose:focus-within {
  background:
    var(--ai-field) padding-box,
    conic-gradient(from var(--ai-angle), var(--ai-stops)) border-box;
}
.aifield--compose:focus-within::before { opacity: var(--ai-glow); }
.aifield--compose .aifield__input {
  resize: none;
  align-self: center;
  max-height: 132px;
  padding: 9px 0;
  line-height: 1.45;
  overflow-y: auto;
  scrollbar-width: thin;
}
.aifield--compose .aisend { width: 38px; height: 38px; }
.aifield--compose .aisend svg { width: 17px; height: 17px; }
.aichat.is-busy .aifield--compose .aisend { opacity: .5; pointer-events: none; }

@media (prefers-reduced-motion: no-preference) {
  .aifield--compose:focus-within { animation: ai-spin 9s linear infinite; }
}

.aichat__fine { margin: 9px 0 0; font-size: 11px; line-height: 1.4; color: var(--fg-faint); text-align: center; }

/* ═══════════════ the launcher ═══════════════ */

.aifab {
  position: fixed;
  right: 24px; bottom: 24px;
  z-index: 80;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 18px 6px 6px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  background:
    linear-gradient(var(--ai-panel), var(--ai-panel)) padding-box,
    conic-gradient(from var(--ai-angle), var(--ai-stops)) border-box;
  color: var(--fg);
  font: 800 11px Archivo, sans-serif; letter-spacing: .14em; text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .85), 0 0 34px -12px rgba(255, 122, 120, .55);
  opacity: 0;
  visibility: hidden;
  transform: translateY(26px) scale(.9);
  transition:
    opacity .35s ease, visibility .35s,
    transform .6s cubic-bezier(.34, 1.56, .64, 1),
    box-shadow .3s ease;
}
[data-theme="light"] .aifab { box-shadow: 0 18px 40px -20px rgba(74, 52, 16, .5), 0 0 34px -14px rgba(224, 69, 127, .45); }
.aifab.is-shown { opacity: 1; visibility: visible; transform: none; }
.aifab.is-shown:hover { transform: translateY(-3px); box-shadow: 0 22px 44px -18px rgba(0, 0, 0, .85), 0 0 44px -10px rgba(255, 122, 120, .7); }
.aifab.is-shown:active { transform: scale(.96); }

@media (prefers-reduced-motion: no-preference) {
  .aifab { animation: ai-spin 8s linear infinite; }
}

/* ═══════════════ sparks thrown on send ═══════════════ */

.aiburst { position: fixed; z-index: 95; width: 0; height: 0; pointer-events: none; }
.aiburst i { position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; animation: ai-spark .85s cubic-bezier(.15, .75, .3, 1) forwards; }
.aiburst svg { width: 100%; height: 100%; fill: var(--ai-1); filter: drop-shadow(0 0 4px rgba(255, 196, 107, .8)); }
.aiburst i:nth-child(3n + 2) svg { fill: var(--ai-3); }
.aiburst i:nth-child(3n) svg { fill: var(--ai-4); }

.aichat-scrim { display: none; }

/* ═══════════════ mobile: bottom sheet ═══════════════ */

@media (max-width: 860px) {
  .aifield--bar { height: 56px; padding-left: 16px; }
  .aighost, .aifield__input { font-size: 16px; }

  /* Suggestions scroll sideways rather than stacking three rows deep. */
  .aibar__chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    /* Its full, unwrapped length must not widen the column it sits in. */
    contain: inline-size;
    margin-inline: calc(var(--gut) * -1);
    padding: 2px var(--gut) 6px;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--gut), #000 calc(100% - var(--gut)), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 var(--gut), #000 calc(100% - var(--gut)), transparent);
  }
  .aibar__chips::-webkit-scrollbar { display: none; }
  .aichip { min-height: 40px; }

  .aichat-scrim {
    display: block;
    position: fixed; inset: 0;
    z-index: 85;
    background: rgba(4, 8, 6, .55);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
  }
  [data-theme="light"] .aichat-scrim { background: rgba(40, 30, 14, .28); }
  .aichat-scrim[hidden] { display: none; }

  .aichat {
    left: 0; right: 0; bottom: 0;
    width: auto;
    height: min(88dvh, 760px);
    border-width: 1px 0 0;
    border-radius: 26px 26px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transition: transform .3s cubic-bezier(.2, .8, .3, 1);
  }
  .aichat.is-dragging { transition: none; }

  .aichat__grip {
    display: block;
    position: relative;
    flex: none;
    width: 44px; height: 5px;
    margin: 9px auto 0;
    padding: 0;
    border: 0; border-radius: 3px;
    background: var(--line);
    cursor: grab;
    touch-action: none;
  }
  .aichat__grip::before { content: ""; position: absolute; inset: -14px -50px; }

  .aichat__head { padding-top: 8px; }
  .aichat__close { width: 40px; height: 40px; }
  .aifield--compose .aifield__input { font-size: 16px; }

  html.aichat-open, html.aichat-open body { overflow: hidden; }

  .aifab { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}
