:root {
  --fondo: #ffffff;
  --carta: #ffffff;
  --testo: #17171a;
  --testo-2: #6a6a72;
  --testo-3: #a3a3ab;
  --bordo: rgba(17, 17, 19, 0.1);
  --riga: rgba(17, 17, 19, 0.07);
  --vuoto: #f1f1f3;
  --accento: #16b46c;
  --accento-scuro: #0f8f55;
  --accento-tenue: #e9f8f0;
  --focus: #6d5efc;
}

* { box-sizing: border-box; margin: 0; padding: 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;
  -webkit-tap-highlight-color: transparent;
}

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

/* the card, on its own */
.card {
  position: relative;
  width: min(372px, calc(100vw - 32px));
  background: var(--carta);
  border-radius: 22px;
  box-shadow: 0 0 0 1px var(--bordo), 0 1px 2px rgba(17, 17, 19, 0.04), 0 22px 44px -26px rgba(17, 17, 19, 0.38);
  padding: 14px 16px 16px;
  user-select: none;
  -webkit-user-select: none;
}

.card__head { display: flex; align-items: center; gap: 10px; }
.card__mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #f4f4f5;
  transition: background-color 0.35s ease;
}
.card__mark svg { width: 17px; height: 17px; fill: none; stroke: var(--testo); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: stroke 0.35s ease; }
.card.is-charging .card__mark { background: var(--accento-tenue); }
.card.is-charging .card__mark svg { stroke: var(--accento-scuro); }
.card__who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.card__name { font-size: 14px; font-weight: 620; font-stretch: 104%; }
.card__place { font-size: 12.5px; color: var(--testo-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* one line high: the old word leaves before the new one comes in */
.card__badge {
  margin-left: auto;
  flex: none;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f4f4f5;
  color: var(--testo-2);
  font-size: 12px;
  font-weight: 560;
  line-height: 24px;
  overflow: hidden;
  white-space: nowrap;
  transition: background-color 0.35s ease, color 0.35s ease;
}
.card__badge > span { display: block; }
.card.is-charging .card__badge,
.card.is-complete .card__badge { background: var(--accento-tenue); color: var(--accento-scuro); }

/* the level, big, and the time left beside it */
.readout {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: clamp(10px, 3vh, 18px);
}
.readout__level { display: flex; align-items: flex-start; }
.readout__num {
  height: 50px;
  overflow: hidden;
  font-size: 46px;
  line-height: 50px;
  font-weight: 560;
  font-stretch: 112%;
  letter-spacing: -0.02em;
}
.readout__num > span { display: block; }
.readout__pc { font-size: 20px; line-height: 30px; font-weight: 540; color: var(--testo-2); margin-left: 2px; }
.readout__side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; padding-bottom: 6px; }
.readout__label, .readout__eta { overflow: hidden; white-space: nowrap; }
.readout__label { height: 17px; font-size: 12.5px; line-height: 17px; color: var(--testo-2); }
.readout__eta { height: 20px; font-size: 15px; line-height: 20px; font-weight: 620; }
.readout__label > span, .readout__eta > span { display: block; text-align: right; }

/* the battery: the charge, the light running through it, the part past the limit */
.batt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 34px;
}
.batt__body {
  position: relative;
  flex: 1;
  height: clamp(40px, 10vh, 52px);
  border-radius: 12px;
  background: var(--vuoto);
  box-shadow: inset 0 0 0 1px var(--riga);
  touch-action: none;
  cursor: ew-resize;
}
.batt__cap {
  flex: none;
  width: 5px;
  height: 16px;
  border-radius: 0 3px 3px 0;
  background: #e2e2e6;
}
.batt__beyond {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  border-radius: 0 12px 12px 0;
  background-image: repeating-linear-gradient(135deg, rgba(17, 17, 19, 0.06) 0 1.2px, transparent 1.2px 6px);
}
.batt__fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: 12px 4px 4px 12px;
  overflow: hidden;
  background: linear-gradient(180deg, #2fcf86 0%, var(--accento) 55%, #12a362 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
/* the light running through the charge: a thin bright band, only while charging */
.batt__flow {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 34px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.34) 60%, rgba(255, 255, 255, 0) 100%);
  transform: translateX(-80px) skewX(-18deg);
  opacity: 0;
}
/* the leading edge of the charge, slightly brighter */
.batt__edge {
  position: absolute;
  top: 3px;
  bottom: 3px;
  right: 0;
  width: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.75);
}
.batt__ticks { position: absolute; inset: 0; pointer-events: none; }
.batt__ticks i {
  position: absolute;
  top: 50%;
  width: 1px;
  height: 10px;
  margin-top: -5px;
  background: rgba(17, 17, 19, 0.08);
}
.batt__ticks i.is-under { background: rgba(255, 255, 255, 0.3); }

/* the limit: a thin bar on the battery with its tag above */
.limit {
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: 0;
  width: 22px;
  margin-left: -11px;
  display: grid;
  place-items: center;
  outline: none;
  cursor: ew-resize;
}
.limit__bar {
  width: 4px;
  height: 100%;
  border-radius: 3px;
  background: var(--testo);
  box-shadow: 0 0 0 2px var(--carta), 0 2px 6px rgba(17, 17, 19, 0.25);
}
.limit__tag {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--testo);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
}
.limit__tag > span { display: block; }
.limit:focus-visible .limit__bar { box-shadow: 0 0 0 2px var(--carta), 0 0 0 4px var(--focus); }

.scale {
  display: flex;
  justify-content: space-between;
  margin: 6px 8px 0 0;
  font-size: 11px;
  color: var(--testo-3);
}

/* the three small numbers */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: clamp(8px, 2.4vh, 14px);
  padding-top: 10px;
  border-top: 1px solid var(--riga);
}
.stats div { display: flex; flex-direction: column; gap: 1px; }
.stats div + div { padding-left: 12px; border-left: 1px solid var(--riga); }
.stats dt { font-size: 11.5px; color: var(--testo-2); }
.stats dd { font-size: 14px; font-weight: 600; height: 19px; line-height: 19px; overflow: hidden; white-space: nowrap; }
.stats dd > span { display: block; }

/* the button */
.cta {
  position: relative;
  display: block;
  width: 100%;
  height: 46px;
  margin-top: 14px;
  border: 0;
  border-radius: 14px;
  background: var(--testo);
  color: #fff;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  font-stretch: 104%;
  cursor: pointer;
  overflow: hidden;
  transition: background-color 0.35s ease, color 0.35s ease;
}
.cta.is-paused { background: var(--accento); }
.cta.is-complete { background: var(--accento-tenue); color: var(--accento-scuro); }
.cta:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.cta__sweep {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.28) 70%, rgba(255, 255, 255, 0) 100%);
  transform-origin: 0 50%;
  transform: scaleX(0);
  opacity: 0;
}
.cta__label { position: relative; display: block; height: 20px; line-height: 20px; overflow: hidden; }
.cta__label > span { display: inline-flex; align-items: center; gap: 7px; }
.cta__check { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) {
  .cta:hover { filter: brightness(1.12); }
}

/* the drawn pointer of the autopilot */
.ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 5;
}
.ghost path { fill: var(--testo); stroke: #fff; stroke-width: 1.4; stroke-linejoin: round; }

@media (max-height: 460px) {
  .stage { padding: 8px; }
  .card { padding: 10px 14px 12px; }
  .readout { margin-top: 6px; }
  .batt { margin-top: 30px; }
  .readout__num { font-size: 38px; height: 42px; line-height: 42px; }
  .cta { height: 40px; margin-top: 10px; }
}
