:root {
  --fondo: #ffffff;
  --bordo: #efeff2;
  --corpo: #17161c;          /* the drop, and the chat window it becomes */
  --corpo-chiaro: #3b3844;   /* the light side of the drop */
  --corpo-scuro: #0c0b10;
  --occhi: #ffffff;
  --testo: #f6f5f8;
  --testo-2: #a7a4b0;
  --testo-3: #74717d;
  --vetro: rgba(255, 255, 255, .07);
  --filo: rgba(255, 255, 255, .13);
  --accento: #ffb23e;        /* the single accent: Quill’s amber, on the send button and the quick replies */
  --ombra: 22, 20, 34;
  --s: 3.6em;                /* the drop */
  --gap: 1.15em;             /* its distance from the corner */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { font-size: clamp(12px, min(3.4vw, 3vh), 17px); }
body {
  background: var(--fondo);
  color: var(--testo);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; background: none; border: 0; }
button { cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.stage { height: 100vh; display: grid; place-items: center; padding: 3vh 3vw; }

/* just the corner of the app window: a hairline frame, nothing inside */
.corner {
  position: relative;
  width: min(23em, 94vw);
  height: min(29em, 92vh);
  border: 1px solid var(--bordo);
  border-radius: 1.2em;
  overflow: hidden;
}

/* ---- the soft shadow on the floor: it shrinks and fades while the drop is in the air ---- */
.shadow {
  position: absolute;
  right: var(--gap);
  bottom: calc(var(--gap) - .42em);
  width: var(--s); height: .7em;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(var(--ombra), .26), rgba(var(--ombra), 0));
  transform-origin: 50% 50%;
  pointer-events: none;
}

/* ---- the drop: one element that is the button closed and the chat window open, anchored to the corner ---- */
.buddy {
  position: absolute;
  right: var(--gap); bottom: var(--gap);
  width: var(--s); height: var(--s);
  border-radius: 50% 50% 46% 46% / 56% 56% 44% 44%;
  background:
    radial-gradient(120% 95% at 30% 18%, var(--corpo-chiaro) 0%, var(--corpo) 52%, var(--corpo-scuro) 100%);
  box-shadow:
    inset 0 -.35em .7em -.3em rgba(0, 0, 0, .55),
    inset 0 .12em .2em -.05em rgba(255, 255, 255, .16),
    0 .9em 1.6em -1em rgba(var(--ombra), .55);
  overflow: hidden;
  transform-origin: 50% 100%;
  z-index: 2;
}
.buddy__shine {
  position: absolute; left: 18%; top: 11%;
  width: 34%; height: 22%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .34), rgba(255, 255, 255, 0));
  transform: rotate(-24deg);
  pointer-events: none;
}
.buddy__hit {
  position: absolute; inset: 0;
  border-radius: inherit;
  z-index: 3;
}
.buddy__hit:focus-visible { outline: 2px solid var(--accento); outline-offset: -4px; }
.buddy.is-open .buddy__hit { display: none; }

/* ---- the eyes: placed by the script (x, y), the look follows the pointer, each eye blinks ---- */
.eyes {
  position: absolute; right: 0; bottom: 0;
  width: 1.36em; height: .82em;
  pointer-events: none;
  z-index: 2;
}
.eyes__look { width: 100%; height: 100%; display: flex; justify-content: space-between; align-items: center; }
.eye {
  display: block;
  width: .34em; height: .66em;
  border-radius: .2em;
  background: var(--occhi);
  box-shadow: 0 0 .5em rgba(255, 255, 255, .12);
  transform-origin: 50% 60%;
}

/* ---- the chat window: laid out at its final size from the start, so nothing reflows while the drop grows ---- */
.chat {
  position: absolute; right: 0; bottom: 0;
  width: var(--pw, 18em); height: var(--ph, 23em);
  display: grid; grid-template-rows: auto 1fr auto;
  visibility: hidden;
}
.chat__head {
  position: relative;
  display: flex; align-items: center; gap: .75em;
  padding: 1em 1em .9em 1.05em;
  border-bottom: 1px solid var(--filo);
}
/* the eyes land inside this ring: it is the assistant’s avatar */
.chat__ring {
  flex: none;
  width: 2.3em; height: 2.3em;
  border-radius: 50%;
  background: radial-gradient(120% 95% at 30% 18%, #4a4654 0%, #24222b 55%, #121117 100%);
  box-shadow: inset 0 .08em .14em rgba(255, 255, 255, .14), inset 0 -.2em .4em -.15em rgba(0, 0, 0, .6), 0 0 0 1px var(--filo);
}
.chat__who { display: grid; line-height: 1.22; min-width: 0; flex: 1; }
.chat__who strong { font-weight: 640; font-size: .96em; letter-spacing: -.01em; }
.chat__who span { font-size: .74em; color: var(--testo-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat__x {
  flex: none;
  width: 2em; height: 2em; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--testo-2);
  transition: background-color .25s, color .25s;
}
.chat__x svg { width: 1.15em; height: 1.15em; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.chat__x:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }
@media (hover: hover) { .chat__x:hover { background: var(--vetro); color: var(--testo); } }

.chat__body { padding: 1em 1.05em; display: grid; align-content: start; gap: .85em; overflow: hidden; }
.msg {
  justify-self: start;
  max-width: 92%;
  padding: .7em .9em;
  border-radius: 1em 1em 1em .3em;
  background: var(--vetro);
  font-size: .88em; line-height: 1.45;
}
.msg .w { display: inline-block; white-space: pre; }
.quick { display: grid; justify-items: start; gap: .42em; }
.quick__b {
  padding: .48em .85em;
  border: 1px solid var(--filo);
  border-radius: 2em;
  font-size: .78em; font-weight: 520;
  color: var(--testo);
  transition: border-color .25s, color .25s, background-color .25s;
}
.quick__b.is-on { border-color: color-mix(in srgb, var(--accento) 60%, transparent); color: var(--accento); background: color-mix(in srgb, var(--accento) 9%, transparent); }
@media (hover: hover) {
  .quick__b:hover { border-color: color-mix(in srgb, var(--accento) 60%, transparent); color: var(--accento); background: color-mix(in srgb, var(--accento) 9%, transparent); }
}

.chat__foot { display: flex; gap: .5em; align-items: center; padding: .75em .8em .8em; border-top: 1px solid var(--filo); }
.field { flex: 1; min-width: 0; display: block; }
.field input {
  width: 100%; height: 2.25em;
  padding: 0 .9em;
  border-radius: 2em;
  background: var(--vetro);
  font-size: .85em;
  outline: none;
}
.field input::placeholder { color: var(--testo-3); }
.send {
  flex: none;
  width: 2.1em; height: 2.1em; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accento);
  color: #1a1408;
}
.send svg { width: 1.1em; height: 1.1em; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- the speech bubble: grows from the drop’s side on hover ---- */
.tip {
  position: absolute;
  right: calc(var(--gap) + var(--s) + 1em);
  bottom: calc(var(--gap) + var(--s) * .52);
  padding: .55em .85em;
  border-radius: 1em 1em .3em 1em;
  background: #ffffff;
  color: var(--corpo);
  font-size: .86em; font-weight: 600; letter-spacing: -.005em;
  white-space: nowrap;
  box-shadow: 0 0 0 1px rgba(var(--ombra), .08), 0 .6em 1.4em -.6em rgba(var(--ombra), .3);
  transform-origin: 100% 100%;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
