:root {
  --fondo: #ffffff;
  --carta: #ffffff;
  --bordo: #e9e9ee;
  --bordo-2: #dedee5;
  --tinta: #f6f6f9;         /* the header on hover, the user bubble */
  --testo: #14141a;
  --testo-2: #5d5c68;
  --testo-3: #9e9daa;
  --chiave: #8a8996;        /* JSON keys */
  --accento: #4b3cf0;       /* the single accent: values, the running line, the done tick */
  --accento-chiaro: #efedff;
  --ombra: 24, 22, 48;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { font-size: clamp(11px, min(3.9vw, 3.5vh), 18px); }
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 { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul { list-style: none; }
code, pre { font-family: "JetBrains Mono Variable", ui-monospace, monospace; }
.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 4vw; }
.chat { width: min(27em, 92vw); display: grid; gap: .8em; }

/* the messages */
.msg { display: flex; gap: .55em; align-items: flex-start; }
.msg p { font-size: .9em; line-height: 1.42; }
.msg--user { justify-content: flex-end; }
.msg--user p {
  max-width: 82%;
  padding: .62em .9em;
  background: var(--tinta);
  border: 1px solid var(--bordo);
  border-radius: 1.1em 1.1em .35em 1.1em;
}
.msg--ai p { padding-top: .2em; min-height: 1.4em; color: var(--testo); }
.msg__who {
  flex: none; width: 1.7em; height: 1.7em; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--testo);
}
.msg__who svg { width: 1em; height: 1em; display: block; fill: #fff; }

/* the tool call card */
.tool {
  position: relative;
  background: var(--carta);
  border: 1px solid var(--bordo);
  border-radius: .9em;
  overflow: hidden;
  box-shadow:
    0 1px 1px rgba(var(--ombra), .04),
    0 4px 10px -4px rgba(var(--ombra), .08),
    0 14px 30px -18px rgba(var(--ombra), .18);
}
.tool__light {
  position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: radial-gradient(120% 60% at 50% -20%, rgba(75, 60, 240, .07), transparent 60%);
  opacity: 0;
}

.head {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: .7em;
  padding: .7em .8em;
  text-align: left;
  border-radius: .9em .9em 0 0;
  transition: background-color .25s;
}
@media (hover: hover) { .head:hover { background: var(--tinta); } }
.head:focus-visible { outline: 2px solid var(--accento); outline-offset: -2px; }
.head__ico {
  width: 2.1em; height: 2.1em; border-radius: .6em;
  display: grid; place-items: center;
  background: var(--tinta); border: 1px solid var(--bordo);
}
.head__ico svg { width: 1.15em; height: 1.15em; display: block; fill: none; stroke: var(--testo); stroke-width: 1.6; stroke-linejoin: round; }
.head__name { display: grid; gap: .12em; min-width: 0; }
.head__name code { font-size: .84em; font-weight: 560; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head__src { font-size: .7em; color: var(--testo-3); }

.state { display: flex; align-items: center; gap: .4em; color: var(--testo-2); }
.state__ico { position: relative; width: 1.2em; height: 1.2em; flex: none; }
.state__ico svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.i-wait { stroke: var(--testo-3); stroke-width: 1.5; }
.spin__track { stroke: var(--bordo-2); stroke-width: 2; }
.spin__arc { stroke: var(--accento); stroke-width: 2; stroke-dasharray: .28 1; }
.i-done circle { fill: var(--accento); stroke: none; }
.i-done .tick { stroke: #fff; stroke-width: 1.8; stroke-dasharray: 1 1; stroke-dashoffset: 1; }
.i-no circle { fill: var(--testo); stroke: none; }
.i-no .cross { stroke: #fff; stroke-width: 1.7; stroke-dasharray: 1 1; stroke-dashoffset: 1; }
.state__txt { font-size: .74em; font-weight: 540; white-space: nowrap; font-variant-numeric: tabular-nums; }

.chev { width: 1em; height: 1em; display: block; fill: none; stroke: var(--testo-3); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* the thin line running under the header while the tool works */
.run { position: relative; display: block; height: 1px; background: var(--bordo); overflow: hidden; }
.run__bar { position: absolute; top: 0; bottom: 0; left: 0; width: 38%; background: linear-gradient(90deg, transparent, var(--accento), transparent); transform: translateX(-110%); }

.body { overflow: hidden; }
.body__in { padding: .75em .85em .85em; display: grid; gap: .7em; }

.args {
  margin: 0;
  font-size: .76em;
  line-height: 1.62;
  color: var(--testo-2);
  background: #fbfbfd;
  border: 1px solid var(--bordo);
  border-radius: .7em;
  padding: .65em .85em;
  white-space: pre;
  overflow: hidden;
  min-height: calc(7 * 1.62em + 1.3em + 2px);
}
.args .k { color: var(--chiave); }
.args .s, .args .n { color: var(--accento); }
.args .p { color: var(--testo-3); }
.caret { display: inline-block; width: .5em; height: 1.1em; vertical-align: -.2em; margin-left: 1px; background: var(--accento); border-radius: 1px; }

.summary {
  display: none;
  align-items: center; flex-wrap: wrap; gap: .4em;
  font-size: .76em; color: var(--testo-2);
  font-family: "JetBrains Mono Variable", ui-monospace, monospace;
}
.summary svg { width: 1.2em; height: .75em; fill: none; stroke: var(--testo-3); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.summary .sep { color: var(--testo-3); }

.ask { display: grid; gap: .6em; }
.ask__q { font-size: .82em; color: var(--testo-2); }
.ask__q b { color: var(--testo); font-weight: 600; }
.ask__btns { display: grid; grid-template-columns: 1fr 1fr; gap: .5em; }
.btn {
  position: relative;
  height: 2.5em; border-radius: 2em;
  display: grid; place-items: center;
  font-size: .84em; font-weight: 580;
}
.btn span { pointer-events: none; }
.btn--ghost { border: 1px solid var(--bordo-2); color: var(--testo); background: #fff; }
.btn--go { color: #fff; background: var(--testo); box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 6px 14px -8px rgba(var(--ombra), .6); }
@media (hover: hover) {
  .btn--ghost:hover { border-color: var(--testo-3); }
  .btn--go:hover { background: #26252f; }
}
.btn:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }

.results { display: none; gap: .15em; }
.row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .7em;
  padding: .5em .55em; border-radius: .65em;
  position: relative;
}
.row + .row::before { content: ""; position: absolute; left: .55em; right: .55em; top: -.075em; height: 1px; background: var(--bordo); }
.row--best { background: var(--accento-chiaro); }
.row--best::before, .row--best + .row::before { opacity: 0; }
.row__tag {
  width: 2em; height: 2em; border-radius: .55em; display: grid; place-items: center;
  background: #fff; border: 1px solid var(--bordo);
  font-size: .78em; font-weight: 640; letter-spacing: .02em;
}
.row__main { display: grid; gap: .1em; min-width: 0; }
.row__main b { font-size: .84em; font-weight: 600; font-variant-numeric: tabular-nums; }
.row__main span { font-size: .7em; color: var(--testo-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__price { display: grid; justify-items: end; gap: .15em; font-size: .9em; font-weight: 620; font-variant-numeric: tabular-nums; }
.best { font-size: .66em; font-weight: 600; color: var(--accento); background: #fff; border: 1px solid rgba(75, 60, 240, .25); border-radius: 2em; padding: .15em .55em; }
