/* ---------- Colori: chiaro di base, scuro col tema del telefono o col pulsante ---------- */
:root {
  color-scheme: light;
  --sfondo: #FFF8F1; --carta: #FFFFFF; --pillola: #F6EBDF; --pillola-bordo: #EAD9C6;
  --testo: #2A1E17; --tenue: #6E6058; --bordo: #F0E4D7;
  --arancio: #FF6B1A; --arancio-2: #FF8A2B; --arancio-testo: #F2620F;
  --ombra: 0 2px 6px rgb(120 70 30 / .06), 0 10px 28px rgb(120 70 30 / .08);
  --per-bg: #FDECEC; --per-bordo: #E11D2A; --per: #D0101E; --per-bottone: #D90F1C;
  --att-bg: #FFF5E0; --att-bordo: #F0A020; --att: #A85F00;
  --ok-bg: #EAF8EF; --ok-bordo: #3DB36B; --ok: #1E7A45;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --sfondo: #1A1614; --carta: #2A2421; --pillola: #332B27; --pillola-bordo: #43382F;
    --testo: #F6EEE8; --tenue: #B9AAA0; --bordo: #3A312C;
    --arancio-testo: #FF7A2B;
    --ombra: 0 2px 10px rgb(0 0 0 / .35);
    --per-bg: #3A0B0E; --per-bordo: #F0444F; --per: #FF5A64; --per-bottone: #D90F1C;
    --att-bg: #33240A; --att-bordo: #E3A23B; --att: #FFC35A;
    --ok-bg: #102A1C; --ok-bordo: #3DB36B; --ok: #7EE0A6;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --sfondo: #1A1614; --carta: #2A2421; --pillola: #332B27; --pillola-bordo: #43382F;
  --testo: #F6EEE8; --tenue: #B9AAA0; --bordo: #3A312C;
  --arancio-testo: #FF7A2B;
  --ombra: 0 2px 10px rgb(0 0 0 / .35);
  --per-bg: #3A0B0E; --per-bordo: #F0444F; --per: #FF5A64; --per-bottone: #D90F1C;
  --att-bg: #33240A; --att-bordo: #E3A23B; --att: #FFC35A;
  --ok-bg: #102A1C; --ok-bordo: #3DB36B; --ok: #7EE0A6;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--sfondo); color: var(--testo); line-height: 1.45;
  min-height: 100dvh; display: flex; flex-direction: column;
  transition: background-color .25s, color .25s;
}
main { flex: 1; width: 100%; max-width: 520px; margin: 0 auto; padding: 4px 16px 24px; }
button { font-family: inherit; }

/* ---------- Barra in alto ---------- */
.barra {
  display: flex; align-items: center; gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) 16px 8px; max-width: 520px; width: 100%; margin: 0 auto;
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 1.55rem; font-weight: 900; letter-spacing: -.02em; margin-right: auto; min-width: 0; }
.logo img { width: 44px; height: 44px; border-radius: 12px; flex: none; box-shadow: 0 2px 8px rgb(240 80 60 / .25); }
.logo b { color: var(--arancio-testo); font-weight: 900; }
body.su-risultato .logo { margin: 0 auto; }
.azioni { display: flex; align-items: center; gap: 8px; }
body.su-risultato .azioni { display: none; }
.tondo {
  width: 44px; height: 40px; border-radius: 999px; border: 1px solid var(--pillola-bordo);
  background: var(--pillola); color: var(--testo); font-size: 1.15rem; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.pillola-lingua { position: relative; }
.pillola-lingua select {
  appearance: none; font: inherit; font-weight: 800; font-size: .95rem;
  height: 40px; padding: 0 30px 0 14px; border-radius: 999px;
  border: 1px solid var(--pillola-bordo); background: var(--pillola); color: var(--testo); cursor: pointer;
}
.pillola-lingua::after {
  content: ""; position: absolute; right: 13px; top: 50%; width: 7px; height: 7px; margin-top: -6px;
  border-right: 2px solid var(--testo); border-bottom: 2px solid var(--testo); transform: rotate(45deg); pointer-events: none;
}

/* ---------- Schermate ---------- */
.schermata { display: none; }
.schermata.attiva { display: block; animation: entra .25s ease; }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Home ---------- */
#home h1 { font-size: 2.15rem; font-weight: 900; line-height: 1.1; letter-spacing: -.02em; margin: 14px 0 8px; text-align: center; text-wrap: balance; }
.sotto { color: var(--tenue); margin: 0 auto 18px; text-align: center; font-size: 1.08rem; font-weight: 600; max-width: 26em; text-wrap: balance; }

.scatta { display: flex; flex-direction: column; align-items: center; gap: 14px; cursor: pointer; user-select: none; margin: 8px auto 2px; }
.cerchio {
  width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--arancio-2), var(--arancio) 70%);
  display: grid; place-items: center;
  box-shadow: 0 0 0 10px rgb(255 120 40 / .12), 0 0 40px 8px rgb(255 120 40 / .35), 0 12px 24px rgb(255 100 20 / .3);
  transition: transform .15s;
}
.scatta:active .cerchio { transform: scale(.95); }
.cerchio svg { width: 64px; height: 64px; fill: #fff; }
.scatta-testo { font-size: 1.45rem; font-weight: 900; }
.galleria { display: block; text-align: center; color: var(--arancio-testo); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; margin: 6px 0 22px; font-size: 1.05rem; }

.esempi { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.esempi li {
  background: var(--carta); border: 1px solid var(--bordo); border-radius: 22px; box-shadow: var(--ombra);
  padding: 10px 10px 12px; text-align: center; font-weight: 800; font-size: 1rem; line-height: 1.2;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.esempi img { width: 100%; aspect-ratio: 300 / 125; object-fit: contain; border-radius: 14px; background: #FEFBF7; }
.nota { text-align: center; color: var(--tenue); font-size: .9rem; margin-top: 16px; }

/* ---------- Domanda ---------- */
.domanda-titolo { display: block; font-weight: 900; font-size: 1.3rem; margin: 4px 0 8px; }
#testoDomanda {
  width: 100%; font: inherit; font-size: 1.1rem; padding: 12px 14px; resize: vertical; min-height: 64px;
  border-radius: 16px; border: 2px solid var(--pillola-bordo); background: var(--carta); color: var(--testo);
}
#testoDomanda:focus { outline: none; border-color: var(--arancio); }
.suggerimenti { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 2px; }
.suggerimenti button {
  font-weight: 700; font-size: .98rem; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: var(--pillola); border: 1px solid var(--pillola-bordo); color: var(--testo);
}
.suggerimenti button:active { transform: scale(.97); }

.posizione {
  display: flex; align-items: center; gap: 12px; width: 100%; margin: 14px 0 0; padding: 12px 14px;
  border-radius: 16px; border: 2px solid var(--pillola-bordo); background: var(--carta); color: var(--testo);
  font-weight: 700; font-size: 1rem; text-align: left; cursor: pointer;
}
.posizione .spia {
  flex: none; width: 46px; height: 26px; border-radius: 999px; background: var(--pillola-bordo); position: relative; transition: background .2s;
}
.posizione .spia::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .2s;
}
.posizione[aria-pressed="true"] { border-color: var(--arancio); }
.posizione[aria-pressed="true"] .spia { background: var(--arancio); }
.posizione[aria-pressed="true"] .spia::after { transform: translateX(20px); }
.posizione.errore { border-color: var(--per-bordo); }

/* Risposta alla domanda */
.risposta {
  border-radius: 20px; padding: 14px 16px; margin-bottom: 12px;
  background: linear-gradient(180deg, rgb(255 138 43 / .14), rgb(255 107 26 / .08));
  border: 2px solid var(--arancio);
}
.risposta .chiesto { font-weight: 800; color: var(--arancio-testo); margin: 0 0 6px; }
.risposta p { margin: 0 0 6px; font-size: 1.08rem; }
.risposta p:last-child { margin-bottom: 0; }

/* Stima peso / misure */
.stima { border-radius: 20px; padding: 14px 16px; margin-bottom: 12px; background: var(--carta); border: 2px dashed var(--arancio); box-shadow: var(--ombra); }
.stima p { margin: 0 0 6px; }
.stima-titolo { font-weight: 900; font-size: 1.15rem; color: var(--arancio-testo); }
.stima-valore { font-weight: 900; font-size: 1.9rem; line-height: 1.15; }
.stima .etichetta { display: inline-block; margin: 2px 0 8px; }
.stima-sotto { font-weight: 800; margin-top: 8px !important; }
.stima-avviso { color: var(--tenue); font-size: .88rem; font-style: italic; margin: 8px 0 0 !important; }

/* ---------- Attesa ---------- */
.anteprima { border-radius: 22px; overflow: hidden; box-shadow: var(--ombra); margin: 6px 0 14px; background: var(--carta); }
.anteprima img { display: block; width: 100%; max-height: 280px; object-fit: cover; }
.spinner { width: 46px; height: 46px; margin: 24px auto 12px; border-radius: 50%; border: 5px solid var(--pillola); border-top-color: var(--arancio); animation: gira .9s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

/* ---------- Risultato ---------- */
.titolo-oggetto { margin: 4px 0 0; font-size: 2rem; font-weight: 900; line-height: 1.1; letter-spacing: -.01em; text-align: center; text-wrap: balance; }
.scientifico { color: var(--tenue); font-style: italic; font-weight: 600; margin: 2px 0 0; text-align: center; font-size: 1.15rem; }
.etichette { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0 14px; }
.etichetta {
  font-size: .95rem; font-weight: 700; padding: 5px 14px; border-radius: 999px;
  background: var(--pillola); border: 1px solid var(--pillola-bordo); color: var(--testo);
}

.card {
  background: var(--carta); border: 1px solid var(--bordo); border-radius: 20px; box-shadow: var(--ombra);
  padding: 14px 16px; margin-bottom: 10px;
  display: grid; grid-template-columns: 52px 1fr; column-gap: 14px; align-items: start;
}
.card .icona {
  font-size: 2rem; line-height: 1; text-align: center; padding: 4px 12px 4px 0; border-right: 2px solid var(--bordo);
  align-self: stretch; display: flex; align-items: center; justify-content: center;
}
.card h2 { font-size: 1.2rem; font-weight: 900; margin: 0 0 2px; line-height: 1.2; }
.card p { margin: 0 0 6px; color: var(--testo); }
.card p:last-child { margin-bottom: 0; }
.card ol, .card ul { margin: 2px 0 0; padding-left: 22px; }
.card li { margin-bottom: 4px; }

/* Riquadro sicurezza */
.sicurezza {
  border-radius: 20px; border: 2px solid; padding: 14px 16px 16px; margin-bottom: 12px;
}
.sicurezza .testa { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.sicurezza .triangolo { font-size: 2.6rem; line-height: 1; flex: none; }
.sicurezza h2 { margin: 0; font-size: 1.45rem; font-weight: 900; line-height: 1.1; text-transform: uppercase; letter-spacing: .01em; }
.sicurezza h2 small { display: block; text-transform: none; font-size: 1.2rem; }
.sicurezza p { margin: 0 0 8px; }
.sicurezza .cosa-fare { font-weight: 900; font-size: 1.1rem; margin: 8px 0 4px; }
.sicurezza ul { margin: 0 0 8px; padding-left: 0; list-style: none; }
.sicurezza li { position: relative; padding-left: 22px; margin-bottom: 4px; font-weight: 700; }
.sicurezza li::before { content: ""; position: absolute; left: 4px; top: .5em; width: 9px; height: 9px; border-radius: 50%; background: currentColor; color: var(--per); }
.sicurezza .emergenza { color: var(--per); font-weight: 700; font-size: .9rem; text-align: center; margin: 6px 0 10px; }
.chiama {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  padding: 14px; border-radius: 14px; background: var(--per-bottone); color: #fff;
  font-weight: 900; font-size: 1.35rem; text-decoration: none; box-shadow: 0 6px 16px rgb(217 15 28 / .3);
}
.chiama svg { width: 26px; height: 26px; fill: #fff; }

.sicurezza.pericoloso, .sicurezza.molto_pericoloso { background: var(--per-bg); border-color: var(--per-bordo); }
.sicurezza.pericoloso h2, .sicurezza.molto_pericoloso h2 { color: var(--per); }
.sicurezza.attenzione { background: var(--att-bg); border-color: var(--att-bordo); }
.sicurezza.attenzione h2 { color: var(--att); }
.sicurezza.attenzione li::before { color: var(--att); }
.sicurezza.nessun_rischio { background: var(--ok-bg); border-color: var(--ok-bordo); }
.sicurezza.nessun_rischio h2 { color: var(--ok); }
.sicurezza.nessun_rischio li::before { color: var(--ok); }

.bottone {
  display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%;
  margin: 16px 0 6px; padding: 16px; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, var(--arancio-2), var(--arancio)); color: #fff;
  font-weight: 900; font-size: 1.4rem; cursor: pointer; box-shadow: 0 8px 20px rgb(255 100 20 / .3);
}
.bottone svg { width: 30px; height: 30px; fill: #fff; }

.nota-aff { text-align: center; color: var(--tenue); font-size: .92rem; margin: 6px 4px 0; }
.piede { text-align: center; font-size: .8rem; color: var(--tenue); padding: 8px 16px 20px; max-width: 520px; margin: 0 auto; }
