:root {
  --fondo: #e4e7ec;          /* the paper: background, card, tracks and knobs are all this colour */
  --luce: rgba(255, 255, 255, 0.9);    /* the light shadow, top left */
  --ombra: rgba(146, 156, 176, 0.62);  /* the dark shadow, bottom right */
  --ombra-forte: rgba(120, 131, 154, 0.55); /* the deeper shade of the hollow on the on side */
  --testo: #252a35;
  --testo-2: #636b7d;
  --icona: #8f97a8;          /* the icons while off */
  --accento: #4f7cf7;        /* the filament of light and the icons while on */
  --accento-testo: #2f5bd6;  /* the same blue, dark enough to read */
}

* { 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;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul { list-style: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

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

/* ---- the card: a soft plate raised off the paper ---- */
.group {
  position: relative;
  width: min(392px, calc(100vw - 40px));
  padding: 16px 18px 8px;
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 48%, rgba(120, 130, 150, 0.05)), var(--fondo);
  box-shadow:
    8px 8px 20px rgba(146, 156, 176, 0.5),
    -8px -8px 20px rgba(255, 255, 255, 0.85),
    inset 1px 1px 0 rgba(255, 255, 255, 0.55);
}
.group__title {
  font-size: 12px;
  font-weight: 600;
  font-variation-settings: "wdth" 112;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--testo-2);
  padding: 2px 2px 6px;
}

/* ---- a row: icon well, name, rolling state, switch ---- */
.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 62px;
  cursor: pointer;
}
/* engraved hairline between rows: a dark line with a light one under it */
.row + .row::before {
  content: "";
  position: absolute;
  left: 46px;
  right: 0;
  top: 0;
  height: 1px;
  background: rgba(146, 156, 176, 0.38);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}
.well {
  position: relative;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  box-shadow: inset 2px 2px 4px var(--ombra), inset -2px -2px 4px var(--luce);
}
.ico {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  fill: none;
  stroke: var(--icona);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}
.ico__spark { opacity: 0; }
.row__text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.row__name {
  font-size: 15px;
  font-weight: 600;
  font-variation-settings: "wdth" 100;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row__sub {
  font-size: 12.5px;
  font-weight: 450;
  color: var(--testo-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.state {
  position: relative;
  flex: none;
  width: 26px;
  height: 16px;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 560;
  color: var(--testo-2);
  text-align: right;
}
.state__line {
  position: absolute;
  right: 0;
  top: 0;
  line-height: 16px;
  white-space: nowrap;
}
.state__line--on { color: var(--accento-testo); font-weight: 640; }

/* ---- the switch: a hollow track and a raised knob, driven by CSS variables written by the script ---- */
.switch {
  --tw: 58px;
  --th: 32px;
  --k: 24px;
  --pad: 4px;
  --run: calc(var(--tw) - var(--k) - var(--pad) * 2);
  --i: 3;   /* depth of the hollow */
  --d: 0;   /* the deeper shade on the on side */
  --p: 0;   /* knob position, 0 = off, 1 = on */
  --o: 5;   /* knob relief */
  --y: 0;
  --sx: 1;
  --sy: 1;
  position: relative;
  flex: none;
  width: var(--tw);
  height: var(--th);
  border-radius: 999px;
  background: var(--fondo);
  box-shadow:
    inset calc(var(--i) * 1px) calc(var(--i) * 1px) calc(var(--i) * 2.1px) var(--ombra),
    inset calc(var(--i) * -1px) calc(var(--i) * -1px) calc(var(--i) * 2.1px) var(--luce);
  outline: none;
  touch-action: manipulation;
}
.switch:focus-visible::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 999px;
  border: 1.5px solid rgba(79, 124, 247, 0.55);
}
/* the groove the knob digs: it grows from the left end to the knob */
.switch__deep {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: calc(var(--k) + var(--pad) * 2 + var(--run) * var(--p));
  border-radius: 999px;
  opacity: var(--d);
  background: linear-gradient(90deg, rgba(79, 124, 247, 0.05), rgba(79, 124, 247, 0.1));
  box-shadow: inset 3px 3px 7px var(--ombra-forte), inset -1px -1px 3px rgba(255, 255, 255, 0.5);
  pointer-events: none;
}
.switch__rim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.rim__light {
  fill: none;
  stroke: url(#filo);
  stroke-width: 1.1;
  stroke-linecap: butt;
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
  opacity: 0;
  filter: drop-shadow(0 0 1.5px rgba(79, 124, 247, 0.45));
}
.knob {
  position: absolute;
  left: var(--pad);
  top: var(--pad);
  width: var(--k);
  height: var(--k);
  border-radius: 50%;
  background: var(--fondo);
  box-shadow:
    calc(var(--o) * 0.7px) calc(var(--o) * 0.7px) calc(var(--o) * 1.6px) var(--ombra),
    calc(var(--o) * -0.6px) calc(var(--o) * -0.6px) calc(var(--o) * 1.5px) var(--luce),
    0 0.5px 1px rgba(90, 100, 120, 0.18);
  transform: translateX(calc(var(--run) * var(--p))) translateY(calc(var(--y) * 1px)) scale(var(--sx), var(--sy));
  pointer-events: none;
}
.knob__face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 55%, rgba(120, 130, 150, 0.08));
}
/* a tiny engraved line on the knob: it catches the accent when the switch is on */
.knob__grip {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.5px;
  height: 8px;
  margin: -4px 0 0 -0.75px;
  border-radius: 1px;
  background: rgba(146, 156, 176, 0.55);
  box-shadow: 0.75px 0.75px 0 rgba(255, 255, 255, 0.85);
}

/* phone: the sub lines go, the names keep their room */
@media (max-width: 400px) {
  .group { padding: 14px 14px 6px; }
  .row { gap: 10px; height: 58px; }
  .row__sub { display: none; }
  .row + .row::before { left: 44px; }
}
@media (max-height: 340px) {
  .row { height: 50px; }
  .row__sub { display: none; }
}
