:root {
  --fondo: #f6f6f4;
  --card: #ffffff;
  --inchiostro: #121214;
  --grigio: #70707a;
  --grigio-chiaro: #a3a3ab;
  --bordo: rgba(18, 18, 20, 0.08);
  --bolla: #f1f1f3;
  --barra: #c9c9cf;
  --accento: #6c4cf5;
  --accento-chiaro: #efebff;
}

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

html, body { height: 100%; }

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

.stage {
  position: relative;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 12px;
}

/* the card has a fixed height that already holds the open transcript, so nothing moves around it */
.chat {
  width: min(372px, 100%);
  height: min(404px, calc(100vh - 24px));
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--bordo);
  border-radius: 22px;
  box-shadow: 0 1px 2px rgba(18, 18, 20, 0.04), 0 22px 50px -22px rgba(18, 18, 20, 0.2);
  overflow: hidden;
}

.chat__head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--bordo);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: #1d1d22; color: #fff;
  font-size: 11.5px; font-weight: 640; letter-spacing: 0.02em;
}
.chat__who { flex: 1; min-width: 0; }
.chat__name { font-size: 14px; font-weight: 620; line-height: 1.2; }
.chat__role { font-size: 12px; color: var(--grigio); }
.chat__call { width: 18px; height: 18px; fill: none; stroke: var(--inchiostro); stroke-width: 1.7; stroke-linejoin: round; }

.chat__body {
  flex: 1;
  min-height: 0;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 14px 8px;
}

.msg { display: flex; flex-direction: column; max-width: 88%; }
.msg--out { align-self: flex-end; align-items: flex-end; }
.msg--in { align-self: flex-start; align-items: flex-start; width: 88%; }
.msg__meta { display: flex; align-items: center; gap: 4px; margin-top: 3px; font-size: 10.5px; color: var(--grigio-chiaro); }
.msg__meta--in { margin-left: 4px; }

.bubble { font-size: 13.5px; line-height: 1.35; padding: 8px 12px; border-radius: 16px; }
.bubble--out { background: var(--inchiostro); color: #fff; border-bottom-right-radius: 5px; }

.ticks { width: 17px; height: 10px; fill: none; stroke: var(--accento); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* the voice bubble */
.voice {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px 9px 9px;
  background: var(--bolla);
  border-radius: 18px; border-bottom-left-radius: 5px;
}

.play {
  flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  border: 0; padding: 0; cursor: pointer;
  display: grid; place-items: center;
  background: var(--accento);
  box-shadow: 0 6px 14px -6px rgba(108, 76, 245, 0.7);
}
.play svg { width: 20px; height: 20px; fill: #fff; }
.play.is-hover { filter: brightness(1.08); }
@media (hover: hover) { .play:hover { filter: brightness(1.08); } }
.play:focus-visible, .speed:focus-visible, .wave:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }

.voice__main { flex: 1; min-width: 0; }

.wave {
  position: relative;
  height: 28px;
  cursor: pointer;
  touch-action: none;
  border-radius: 4px;
}
.wave__row {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: none;
}
.wave__row i {
  display: block;
  width: 2.5px;
  border-radius: 2px;
  background: var(--barra);
  transform-origin: 50% 50%;
}
.wave__row--fill i { background: var(--accento); }
.wave__row--fill { clip-path: inset(0 100% 0 0); }

.voice__meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.voice__time { font-size: 11.5px; font-weight: 560; color: var(--grigio); min-width: 26px; display: inline-block; }
.voice__mic { width: 13px; height: 13px; fill: none; stroke: var(--grigio-chiaro); stroke-width: 1.8; stroke-linecap: round; }
.voice__mic rect { fill: none; }

.speed {
  margin-left: auto;
  height: 20px; padding: 0 7px;
  border: 0; border-radius: 10px; cursor: pointer;
  background: #fff;
  box-shadow: 0 0 0 1px var(--bordo);
  font: inherit; font-size: 11px; font-weight: 640; color: var(--inchiostro);
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.speed.is-hover { background: var(--accento-chiaro); }
@media (hover: hover) { .speed:hover { background: var(--accento-chiaro); } }
.speed__win { display: block; height: 14px; overflow: hidden; line-height: 14px; position: relative; }
.speed__val { display: block; white-space: nowrap; }

/* the transcript, closed at height 0 */
.trans { width: 100%; height: 0; overflow: hidden; }
.trans__in { padding: 8px 4px 2px 12px; border-left: 2px solid var(--accento); margin: 8px 0 0 6px; }
.trans__label { display: flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 620; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accento); }
.trans__label svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.trans__text { margin-top: 4px; font-size: 13px; line-height: 1.42; color: var(--inchiostro); }
.trans__text span { display: inline-block; white-space: pre; }

.chat__foot {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--bordo);
}
.compose { flex: 1; height: 32px; padding: 0 12px; display: flex; align-items: center; border-radius: 16px; background: var(--bolla); color: var(--grigio-chiaro); font-size: 13px; }
.compose__mic { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--bolla); }
.compose__mic svg { width: 15px; height: 15px; fill: none; stroke: var(--grigio); stroke-width: 2; stroke-linecap: round; }

.ghost {
  position: absolute; left: 0; top: 0;
  width: 22px; height: 22px;
  fill: var(--inchiostro); stroke: #fff; stroke-width: 1.4; stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
  pointer-events: none;
  opacity: 0;
  z-index: 50;
}

@media (max-height: 380px) {
  .chat__head { padding: 8px 12px; }
  .chat__body { padding-top: 8px; gap: 6px; }
}
