:root {
  --fondo: #f7f6f4;
  --carta: #ffffff;
  --testo: #1d1b18;
  --tenue: #6b655c;
  --linea: #e2ddd5;
  --accento: #1d1b18;
  --errore: #a12a1f;
  --ok: #2f6b3a;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--testo);
  background: var(--fondo);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }

.top {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
  max-width: 40rem; margin: 0 auto; padding: 1.5rem 1rem 1rem;
}
.brand { margin: 0; font-size: .75rem; letter-spacing: .18em; text-transform: uppercase; color: var(--tenue); }
h1 { margin: .2rem 0 0; font-size: 1.4rem; font-weight: 600; }

main { max-width: 40rem; margin: 0 auto; padding: 0 1rem 2rem; }
.card {
  background: var(--carta); border: 1px solid var(--linea); border-radius: 12px; padding: 1.25rem;
  display: flex; flex-direction: column; gap: .9rem;
}

label { font-weight: 600; font-size: .9rem; }
input[type="password"] {
  width: 100%; padding: .75rem; font-size: 1rem; border: 1px solid var(--linea); border-radius: 8px; margin-top: .35rem;
}
form { display: flex; flex-direction: column; gap: .9rem; }

button, .button {
  font: inherit; font-size: 1rem; border-radius: 8px; padding: .8rem 1rem; cursor: pointer;
  text-align: center; text-decoration: none; min-height: 44px;
}
.primary { background: var(--accento); color: #fff; border: 1px solid var(--accento); font-weight: 600; }
.secondary { background: var(--carta); color: var(--testo); border: 1px solid var(--testo); }
.link { background: none; border: none; color: var(--tenue); text-decoration: underline; padding: .5rem; }
button:focus-visible, .button:focus-visible, input:focus-visible, .drop:focus-within {
  outline: 3px solid #8a7a52; outline-offset: 2px;
}
button:disabled { opacity: .5; cursor: default; }

.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: .4rem;
  padding: 2.5rem 1rem; border: 2px dashed var(--linea); border-radius: 10px; text-align: center; cursor: pointer;
  font-weight: 400;
}
.drop.over { border-color: var(--testo); background: var(--fondo); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-title { font-weight: 600; font-size: 1.05rem; }

.muted { color: var(--tenue); font-size: .9rem; margin: 0; }
.note { color: var(--tenue); font-size: .85rem; margin: 0; line-height: 1.45; }
.file-name { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.error { color: var(--errore); margin: 0; }
.ok { color: var(--ok); font-weight: 600; font-size: 1.1rem; margin: 0; }
.target { margin: 0; font-size: .95rem; }
p { margin: 0; }

.bar { height: 10px; background: var(--fondo); border-radius: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accento); transition: width .3s; }
.bar.busy span { width: 100%; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.stage {
  position: relative; width: 100%; aspect-ratio: 1 / 1; background: #111; border-radius: 10px; overflow: hidden;
}
.stage video, .stage img { position: absolute; left: 50%; top: 50%; max-width: none; }
.crop { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55); pointer-events: none; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
input[type="range"] { width: 100%; margin: .5rem 0 0; min-height: 44px; }
.scale { display: flex; justify-content: space-between; color: var(--tenue); font-size: .8rem; }

@media (max-width: 380px) {
  .row { grid-template-columns: 1fr; }
  .card { padding: 1rem; }
}
