:root {
  --fondo: #050506;
  --superficie: #121214;
  --campo: #17171a;
  --bordo: rgba(255, 255, 255, 0.08);
  --bordo-forte: rgba(255, 255, 255, 0.15);
  --testo: #f4f4f5;
  --testo-2: #8d8d95;
  --testo-3: #5c5c63;
  --accento: #8e86ff;
  --rosso: #ff6b6b;
}

* { box-sizing: border-box; margin: 0; }

html, body { height: 100%; }

body {
  background: var(--fondo);
  color: var(--testo);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(14px, 4vmin, 40px);
}

.chat {
  width: min(540px, 100%);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2.2vh, 16px);
}

/* the thread: fixed height, so the answer never pushes the composer */
.chat__thread {
  height: clamp(172px, 42vh, 236px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: clamp(8px, 1.8vh, 12px);
  padding: 0 4px;
}

.msg { display: flex; flex-direction: column; gap: 4px; }
.msg__who { font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em; color: var(--testo-2); }
.msg__text { font-size: clamp(13.5px, 1.4vw + 7px, 15px); line-height: 1.45; color: #d9d9de; max-width: 92%; }

.msg--me { align-items: flex-end; opacity: 0; }
.msg__bubble {
  max-width: 86%;
  padding: 9px 14px;
  border-radius: 16px 16px 4px 16px;
  background: #1e1e22;
  border: 1px solid var(--bordo);
  font-size: clamp(13.5px, 1.4vw + 7px, 15px);
  line-height: 1.42;
  min-height: 1.42em;
}
.msg__bubble .w { display: inline-block; will-change: filter, opacity, transform; }
.msg__meta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--testo-3);
  font-variant-numeric: tabular-nums;
}
.msg__meta svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }

.msg--reply { opacity: 0; }
.msg--reply .w { display: inline-block; }

/* the composer: a pill with the field, the recording pill on top of it and the round microphone button */
.composer {
  position: relative;
  height: clamp(54px, 9vh, 60px);
  border-radius: 999px;
  background: var(--campo);
  border: 1px solid var(--bordo);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 18px 40px -18px rgba(0, 0, 0, 0.9);
  isolation: isolate;
}

.glow {
  position: absolute;
  left: -4%;
  right: -4%;
  bottom: -46%;
  height: 300%;
  border-radius: 50%;
  background: radial-gradient(55% 48% at 50% 72%, var(--accento) 0%, rgba(142, 134, 255, 0.45) 36%, rgba(142, 134, 255, 0) 72%);
  filter: blur(22px);
  opacity: 0;
  transform-origin: 50% 100%;
  z-index: -1;
  pointer-events: none;
}

.composer__field {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 64px 0 18px;
  color: var(--testo-3);
  font-size: clamp(13.5px, 1.4vw + 7px, 15px);
}
.composer__plus { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--testo-2); stroke-width: 1.5; stroke-linecap: round; }
.composer__hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* the recording pill: it grows out of the microphone button, from the right */
.rec {
  position: absolute;
  top: 5px;
  bottom: 5px;
  right: 5px;
  width: calc(100% - 10px);
  border-radius: 999px;
  --lv: 0;
  background: linear-gradient(to top, rgba(142, 134, 255, calc(0.05 + var(--lv) * 0.16)), rgba(142, 134, 255, 0) 70%), #1b1a23;
  border: 1px solid rgba(142, 134, 255, calc(0.2 + var(--lv) * 0.3));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 calc(clamp(44px, 7.4vh, 48px) + 8px) 0 6px;
  clip-path: inset(0 0 0 100% round 999px);
  visibility: hidden;
}
.rec__bin {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--testo-2);
  transition: background-color 0.2s, color 0.2s;
}
.rec__bin svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.rec__bin:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }
.rec__bin.is-hot { background: rgba(255, 107, 107, 0.12); color: var(--rosso); }
.rec__time {
  flex: none;
  min-width: 3.1em;
  font-size: 13.5px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  color: var(--testo);
}
.rec__wave { flex: 1; min-width: 0; height: 28px; display: block; }

.mic {
  position: absolute;
  top: 50%;
  right: 5px;
  width: clamp(44px, 7.4vh, 48px);
  height: clamp(44px, 7.4vh, 48px);
  margin-top: calc(clamp(44px, 7.4vh, 48px) / -2);
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: #f4f4f5;
  color: #0b0b0d;
  cursor: pointer;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.8), 0 0 0 0 rgba(142, 134, 255, 0);
  z-index: 2;
}
.mic:focus-visible { outline: 2px solid var(--accento); outline-offset: 3px; }
.mic__face { position: absolute; inset: 0; display: grid; place-items: center; }
.mic__icon { position: absolute; width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.mic__icon--stop { fill: currentColor; stroke: none; opacity: 0; }

.chat__foot { font-size: 11.5px; color: var(--testo-3); text-align: center; }

.ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  fill: #f4f4f5;
  stroke: #050506;
  stroke-width: 1.4;
  stroke-linejoin: round;
  pointer-events: none;
  z-index: 5;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

@media (hover: hover) {
  .rec__bin:hover { background: rgba(255, 107, 107, 0.12); color: var(--rosso); }
}

@media (max-width: 420px) {
  .composer__field { padding-left: 14px; }
  .rec { gap: 6px; }
}
