:root {
  --fondo: #000000;
  --pillola: #0e0f12;
  --pillola-alta: #1d1f24;
  --testo: #f2f3f6;
  --testo-spento: rgba(242, 243, 246, 0.52);
  --filo: rgba(255, 255, 255, 0.1);
  --accento: #9fb4ff;
  --accento-chiaro: #d4ddff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--fondo);
  color: var(--testo);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

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

/* the fit box scales the whole row down on very narrow screens (set from the script) */
.fit { transform-origin: 50% 50%; }
.row {
  display: flex;
  align-items: center;
}

/* the pill: graphite, a hairline that takes the light on top, a soft glow under it while it works */
.btn {
  position: relative;
  display: flex;
  align-items: center;
  height: 60px;
  padding: 0 14px 0 18px;
  border-radius: 30px;
  color: var(--testo);
  background: linear-gradient(180deg, var(--pillola-alta) 0%, var(--pillola) 64%, #09090b 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.055),
    inset 0 -1px 0 rgba(0, 0, 0, 0.7),
    0 14px 32px -14px rgba(159, 180, 255, calc(var(--alone, 0) * 0.5)),
    0 2px 6px -2px rgba(0, 0, 0, 0.9);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  outline: none;
  isolation: isolate;
  white-space: nowrap;
}
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  transition: box-shadow 0.25s ease;
}
.btn:focus-visible::after { box-shadow: 0 0 0 3px #000000, 0 0 0 5px var(--accento); }

/* the inside of the pill reflects the metal: a light that sits where the trail head is, or under the pointer */
.btn__sheen {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}
.btn__sheen::before {
  content: "";
  position: absolute;
  left: var(--hx, 50%);
  top: var(--hy, 0%);
  width: 150px;
  height: 110px;
  margin: -55px 0 0 -75px;
  background: radial-gradient(closest-side, rgba(212, 221, 255, 0.16), rgba(212, 221, 255, 0));
  opacity: var(--riflesso, 0);
}

/* the liquid metal trail lives on the pill's edge, a few pixels outside it */
.trail {
  position: absolute;
  left: -6px;
  top: -6px;
  overflow: visible;
  pointer-events: none;
}
.trail path { fill: none; stroke-linecap: round; }
.trail__rim { stroke: rgba(255, 255, 255, 0); stroke-width: 1; }
.trail__glow path { stroke: var(--accento); }
.trail__metal path { stroke: url(#cromo); }
.trail__head { fill: #ffffff; opacity: 0; }

/* the circular arrow: a ring with a gap and a chevron, drawn by hand */
.btn__icon {
  position: relative;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin-right: 10px;
}
.arrow { display: block; width: 22px; height: 22px; overflow: visible; }
.arrow__ring {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-dasharray: 82 18;
  stroke-dashoffset: -1.4;
}
.arrow__tip {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the label: the stem stays, only the ending changes, «e» or «ing» */
.btn__words {
  display: inline-flex;
  line-height: 22px;
  height: 22px;
  font-size: 15.5px;
  font-weight: 560;
  font-stretch: 100%;
  letter-spacing: -0.005em;
}
.btn__end {
  position: relative;
  display: inline-block;
  height: 22px;
  overflow: hidden;
  vertical-align: top;
}
.btn__suf { display: inline-block; }
.btn__suf--ing { position: absolute; left: 0; top: 0; opacity: 0; }

/* the shortcut chip on the right */
.btn__key {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-left: 12px;
  border-radius: 6px;
  font: inherit;
  font-size: 11px;
  font-weight: 620;
  color: var(--testo-spento);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), inset 0 -1px 0 rgba(255, 255, 255, 0.05);
}

/* the version counter: opens beside the pill after the first regenerate */
.versions {
  width: 0;
  overflow: hidden;
  height: 64px;
  display: flex;
  align-items: center;
}
.versions__in {
  display: flex;
  align-items: center;
  height: 40px;
  margin-left: 10px;
  padding: 0 4px;
  border-radius: 20px;
  background: linear-gradient(180deg, #141519, #0c0d10);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  opacity: 0;
}
.versions__btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 15px;
  color: var(--testo);
  -webkit-tap-highlight-color: transparent;
  outline: none;
  transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}
.versions__btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.versions__btn:focus-visible { box-shadow: 0 0 0 2px var(--accento); }
.versions__btn:disabled { color: rgba(242, 243, 246, 0.24); cursor: default; }
@media (hover: hover) {
  .versions__btn:not(:disabled):hover { background-color: rgba(255, 255, 255, 0.07); }
}
.versions__count {
  display: inline-flex;
  align-items: center;
  min-width: 42px;
  justify-content: center;
  font-size: 13.5px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  color: var(--testo);
}
.versions__sep { margin: 0 4px; color: var(--testo-spento); font-weight: 420; }
.roll {
  position: relative;
  display: inline-block;
  height: 20px;
  line-height: 20px;
  overflow: hidden;
  min-width: 0.62em;
  text-align: center;
}
.roll > span { display: block; }
.roll > span + span { position: absolute; left: 0; right: 0; top: 0; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  margin: -3px 0 0 -4px;
  fill: #ffffff;
  stroke: #111114;
  stroke-width: 1.4;
  stroke-linejoin: round;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

/* when the counter opens, one glint of the same metal runs across its hairline */
.versions__in { position: relative; }
.versions__in::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  padding: 1px;
  background: linear-gradient(100deg, transparent calc(var(--glint, -0.3) * 100% - 18%), rgba(255, 255, 255, 0.85) calc(var(--glint, -0.3) * 100%), var(--accento-chiaro) calc(var(--glint, -0.3) * 100% + 4%), transparent calc(var(--glint, -0.3) * 100% + 20%));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
