:root {
  --fondo: #f2f2f2;
  --carta: #ffffff;
  --inchiostro: #111113;
  --grigio: #8a8a90;
  --linea: rgba(17, 17, 19, 0.08);
  --accento: #2f6bff;
  --verde: #12a150;
}

* { 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;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

.card {
  position: relative;
  width: min(440px, calc(100vw - 32px));
  background: var(--carta);
  border-radius: 22px;
  border: 1px solid var(--linea);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 24px 48px -20px rgba(0, 0, 0, 0.22);
  padding: clamp(8px, 1.6vh, 12px);
  user-select: none;
  -webkit-user-select: none;
}

.card__head {
  display: grid;
  grid-template-columns: 70px 1fr 70px;
  align-items: center;
  height: clamp(36px, 7vh, 44px);
  padding: 0 2px 0 4px;
}

.txt, .save {
  font: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 13px;
  letter-spacing: -0.005em;
}

.txt {
  color: var(--grigio);
  justify-self: start;
  padding: 6px 4px;
  opacity: 0.35;
  transition: opacity 0.25s, color 0.2s;
}
.txt.is-on { opacity: 1; }

.head__mid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.mini {
  width: 0;
  height: 22px;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  opacity: 0;
  box-shadow: 0 0 0 1px var(--linea);
}
.mini canvas { width: 22px; height: 22px; display: block; }

.head__title {
  position: relative;
  display: grid;
  font-size: 14px;
  font-weight: 600;
  height: 18px;
  overflow: hidden;
  white-space: nowrap;
  font-variation-settings: "wdth" 100;
}
.head__state { grid-area: 1 / 1; display: block; line-height: 18px; }
.head__state--done { justify-self: start; }

.save {
  justify-self: end;
  position: relative;
  height: 30px;
  min-width: 58px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--inchiostro);
  color: #fff;
  font-weight: 600;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), 0 4px 10px -4px rgba(0, 0, 0, 0.5);
}
.save__label, .save__check { grid-area: 1 / 1; }
.save__check {
  width: 16px; height: 16px;
  fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  opacity: 0;
}

.crop {
  position: relative;
  height: min(292px, 50vh);
  border-radius: 14px;
  overflow: hidden;
  background: #1a1a1d;
  cursor: grab;
  touch-action: none;
}
.crop.is-grab { cursor: grabbing; }

.crop__photo, .crop__mask {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.crop__ring {
  fill: none;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 1.5;
}

.crop__grid line {
  stroke: rgba(255, 255, 255, 0.42);
  stroke-width: 1;
}
.crop__grid { opacity: 0; }

.crop__hint {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.82);
  background: rgba(0, 0, 0, 0.32);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.zoom {
  display: grid;
  grid-template-columns: 18px 1fr 18px 40px;
  align-items: center;
  gap: 10px;
  height: clamp(36px, 8vh, 48px);
  padding: 0 4px 0 6px;
}

.zoom__icon {
  width: 18px; height: 18px;
  fill: none; stroke: var(--grigio); stroke-width: 1.6; stroke-linecap: round;
}

.zoom__track {
  position: relative;
  height: 22px;
  cursor: pointer;
  touch-action: none;
  outline: none;
}
.zoom__track::before, .zoom__fill {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 3px;
  margin-top: -1.5px;
  border-radius: 3px;
  background: rgba(17, 17, 19, 0.1);
}
.zoom__fill { right: auto; width: 0; background: var(--inchiostro); }

.zoom__knob {
  position: absolute;
  top: 50%;
  left: 0;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.18);
}
.zoom__track:focus-visible .zoom__knob { box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.35), 0 2px 6px rgba(0, 0, 0, 0.18); }

.zoom__val {
  font-size: 12px;
  color: var(--grigio);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

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

@media (hover: hover) {
  .txt.is-on:hover { color: var(--inchiostro); }
  .save:hover { box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), 0 8px 16px -6px rgba(0, 0, 0, 0.55); }
}
