:root {
  --fondo: #ffffff;
  --carta: #ffffff;           /* the tool card */
  --bordo: #ececec;           /* hairlines */
  --tela: #fafaf9;            /* the little canvas where the stroke is previewed */
  --puntini: #e4e4e2;         /* the canvas dot grid */
  --inchiostro: #141414;      /* the stroke, the text */
  --testo-2: #8a8a86;         /* labels and ticks */
  --binario: #ededeb;         /* the empty wedge of the track */
  --accento: #3b5bff;         /* one accent: the filled track, the brush tip ring, the halo, the chosen tick */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--fondo);
  color: var(--inchiostro);
  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; }

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

/* ---- the tool card ---- */
.tool {
  width: min(340px, calc(100vw - 24px));
  padding: 16px 18px 14px;
  background: var(--carta);
  border: 1px solid var(--bordo);
  border-radius: 20px;
  box-shadow:
    0 1px 1px rgba(20, 20, 20, 0.03),
    0 6px 14px -6px rgba(20, 20, 20, 0.08),
    0 24px 48px -24px rgba(20, 20, 20, 0.14);
  user-select: none;
  -webkit-user-select: none;
}

.tool__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 26px;
}
.tool__title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 560;
  font-stretch: 92%;
  letter-spacing: -0.005em;
}
.tool__icon { width: 17px; height: 17px; overflow: visible; }
.brush__handle { fill: none; stroke: var(--inchiostro); stroke-width: 1.5; stroke-linejoin: round; }
.brush__tip { fill: var(--inchiostro); }

/* the size in pixels: two digit reels that roll */
.readout {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.reels { display: inline-flex; height: 1.25em; line-height: 1.25em; overflow: hidden; }
.reel { position: relative; display: inline-block; width: 0.62em; height: 1.25em; overflow: hidden; }
.reel--tens { width: 0.62em; }
.reel__strip { display: flex; flex-direction: column; will-change: transform; }
.reel__strip span { display: block; height: 1.25em; text-align: center; }
.readout__unit {
  font-family: "JetBrains Mono Variable", ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--testo-2);
  letter-spacing: 0.02em;
}

/* ---- the canvas with the preview stroke ---- */
.canvas {
  position: relative;
  margin-top: 12px;
  height: clamp(96px, 26vh, 132px);
  border-radius: 14px;
  background-color: var(--tela);
  background-image: radial-gradient(circle, var(--puntini) 0.9px, transparent 1.1px);
  background-size: 12px 12px;
  background-position: 6px 6px;
  box-shadow: inset 0 0 0 1px #f0f0ee;
  overflow: hidden;
}
.canvas__svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.guide { fill: none; stroke: none; }
.stroke { fill: var(--inchiostro); }
.stroke__shadow { fill: rgba(20, 20, 20, 0.07); }
.tipring {
  fill: none;
  stroke: var(--accento);
  stroke-width: 1;
  stroke-dasharray: 2.2 2.2;
  vector-effect: non-scaling-stroke;
  opacity: 0;
}

/* ---- the slider row ---- */
.control {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.step {
  align-self: start;
  margin-top: 2px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f5f5f3;
  box-shadow: inset 0 0 0 1px #ebebe8;
  transition: background-color 0.2s ease;
}
.step svg { width: 14px; height: 14px; fill: none; stroke: var(--inchiostro); stroke-width: 1.5; stroke-linecap: round; }
@media (hover: hover) {
  .step:hover { background: #efefec; }
}

.track {
  position: relative;
  height: 52px;
  touch-action: none;
  cursor: pointer;
}
.track__svg {
  position: absolute;
  left: 0;
  right: 0;
  top: 2px;
  width: 100%;
  height: 28px;
}
.wedge { fill: var(--binario); }
.wedge--fill { fill: var(--accento); }

/* the usual sizes under the track */
.ticks { position: absolute; left: 0; right: 0; top: 33px; height: 18px; pointer-events: none; }
.tick { position: absolute; top: 0; width: 0; }
.tick__line {
  position: absolute;
  left: -0.5px;
  top: 0;
  width: 1px;
  height: 5px;
  background: #cfcfcb;
  transform-origin: 50% 0%;
}
.tick__num {
  position: absolute;
  top: 7px;
  left: 0;
  transform: translateX(-50%);
  font-family: "JetBrains Mono Variable", ui-monospace, monospace;
  font-size: 8.5px;
  font-weight: 450;
  color: #a9a9a4;
  white-space: nowrap;
}
.tick__numin { display: inline-block; }

/* the handle: positioned with left by the script; GSAP scales the body inside */
.handle {
  position: absolute;
  top: 16px;
  left: 0;
  width: 0;
  height: 0;
  outline: none;
}
.handle__body {
  position: absolute;
  left: -14px;
  top: -14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow:
    0 0 0 1px rgba(20, 20, 20, 0.07),
    0 2px 4px rgba(20, 20, 20, 0.08),
    0 8px 16px -6px rgba(20, 20, 20, 0.22);
  cursor: grab;
}
.handle__halo {
  position: absolute;
  left: -21px;
  top: -21px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accento);
  opacity: 0;
}
.handle__dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--inchiostro);
}
.handle:focus-visible .handle__body {
  box-shadow:
    0 0 0 2px #ffffff,
    0 0 0 4px var(--accento),
    0 8px 16px -6px rgba(20, 20, 20, 0.22);
}
.tool.is-dragging .handle__body { cursor: grabbing; }
