:root {
  --sfondo: #fbf6ef;
  --carta: #ffffff;
  --testo: #2b211c;
  --tenue: #6d5f57;
  --accento: #7a2e1f;
  --accento-chiaro: #f3e1d6;
  --bordo: #e2d5c8;
  --errore: #b3261e;
  --ok: #2e6b34;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sfondo: #1d1916;
    --carta: #2a241f;
    --testo: #f3ebe4;
    --tenue: #b9aca2;
    --accento: #e0896f;
    --accento-chiaro: #4a2f26;
    --bordo: #4a3f37;
    --errore: #ff8a80;
    --ok: #8fd694;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--sfondo);
  color: var(--testo);
  font-family: Verdana, Tahoma, sans-serif;
  font-size: 17px;
  line-height: 1.45;
}

header {
  background: var(--accento);
  color: #fff;
  padding: 18px 16px 14px;
  padding-top: calc(18px + env(safe-area-inset-top));
}
@media (prefers-color-scheme: dark) { header { color: #1d1916; } }
header h1 { margin: 0; font-size: 24px; }
header .sotto { margin: 4px 0 0; font-size: 15px; opacity: 0.9; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

section > h2, .passo h2 { font-size: 19px; margin: 0 0 10px; }

.passo {
  background: var(--carta);
  border: 1px solid var(--bordo);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}

.num {
  display: inline-block;
  width: 28px; height: 28px;
  line-height: 28px;
  text-align: center;
  border-radius: 50%;
  background: var(--accento);
  color: var(--carta);
  font-size: 16px;
  margin-right: 6px;
}

button, .scegli-foto {
  font: inherit;
  color: var(--testo);
  background: var(--carta);
  border: 2px solid var(--bordo);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  min-height: 48px;
}
button.grande, .scegli-foto { width: 100%; font-size: 18px; font-weight: bold; padding: 14px; }
button.principale { background: var(--accento); border-color: var(--accento); color: var(--carta); }
button:disabled { opacity: 0.5; cursor: wait; }
button.link {
  border: none; background: none; min-height: 0; padding: 8px 0;
  color: var(--tenue); text-decoration: underline; font-size: 14px; margin-top: 24px;
}

.scegli-foto {
  display: block;
  text-align: center;
  border-style: dashed;
  border-color: var(--accento);
  color: var(--accento);
}

#anteprima {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  border-radius: 10px;
  margin-top: 12px;
}
#anteprima[hidden] { display: none; }

.momenti { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.momenti.piccoli { margin-top: 10px; }
.momenti.piccoli button { font-size: 15px; }
.momento.scelto {
  background: var(--accento-chiaro);
  border-color: var(--accento);
  color: var(--testo);
}

input[type="text"], input[type="password"], textarea {
  width: 100%;
  font: inherit;
  color: var(--testo);
  background: var(--sfondo);
  border: 2px solid var(--bordo);
  border-radius: 10px;
  padding: 12px;
  margin-top: 6px;
}
input:focus, textarea:focus { outline: none; border-color: var(--accento); }
#codice { margin-bottom: 12px; letter-spacing: 2px; font-weight: bold; }
textarea { resize: vertical; line-height: 1.5; }

.nota { color: var(--tenue); font-size: 14px; margin: 6px 0; }
.etichetta { display: block; margin-top: 14px; font-size: 15px; font-weight: bold; }
.errore { color: var(--errore); font-weight: bold; min-height: 1em; }
.ok { color: var(--ok); font-weight: bold; }
.attesa { text-align: center; color: var(--tenue); font-weight: bold; }

#scrivi { margin-top: 4px; }
#risultato { margin-top: 14px; }
#risultato .momenti { margin-top: 10px; }

[hidden] { display: none !important; }
