@font-face { font-family: "Marcellus"; src: url("../fonts/Marcellus-latin.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("../fonts/InstrumentSans-latin.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }

:root {
  --carta: #f5f2ec;
  --carta-2: #ebe6dd;
  --inchiostro: #1d1c1a;
  --pietra: #77736c;
  --linea: #d9d3c8;
  --ottone: #a07a3f;
  --ottone-chiaro: #f1e6d2;
  --verde: #2f6b4f;
  --avviso: #9a5b13;
  --avviso-chiaro: #f8ecd9;
  --ombra: 0 1px 2px rgba(29,28,26,.06), 0 8px 24px rgba(29,28,26,.08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--carta); color: var(--inchiostro); font: 16px/1.45 "Instrument Sans", system-ui, sans-serif; }
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding-bottom: 96px; }
h1, h2 { font-family: "Marcellus", serif; font-weight: 400; letter-spacing: .01em; }
h1 { font-size: 34px; line-height: 1.12; margin: 8px 0 12px; }
h1 em { font-style: normal; color: var(--ottone); }
h2 { font-size: 24px; margin: 18px 0 4px; }
button { font: inherit; color: inherit; }

/* testata e passi */
.testata { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: rgba(245,242,236,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--linea); }
.testata-logo { width: 40px; height: auto; }
.testata-titolo { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.testata-titolo strong { font-family: "Marcellus", serif; font-weight: 400; font-size: 19px; }
.testata-titolo span { font-size: 12px; color: var(--pietra); }
.icona { border: 1px solid var(--linea); background: #fff; border-radius: 12px; width: 42px; height: 42px; display: grid; place-items: center; cursor: pointer; }
.passi { display: flex; list-style: none; margin: 0; padding: 10px 16px 0; gap: 6px; }
.passi li { flex: 1; font-size: 11px; color: var(--pietra); padding-top: 7px; border-top: 3px solid var(--linea); transition: .3s; }
.passi li.fatto { border-color: var(--inchiostro); color: var(--inchiostro); }
.passi li.attivo { border-color: var(--ottone); color: var(--inchiostro); font-weight: 600; }

.schermo { padding: 8px 16px 16px; animation: entra .45s ease both; }
@keyframes entra { from { opacity: 0; transform: translateY(10px); } }
.sottotitolo { color: var(--pietra); margin: 0 0 20px; }
.nota { color: var(--pietra); font-size: 14px; margin: 0 0 12px; }

/* bottoni */
.bottone { display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 20px; border-radius: 14px; border: 0; cursor: pointer; font-weight: 600; font-size: 16px; text-align: center; }
.primario { background: var(--inchiostro); color: #fff; }
.primario:active { transform: scale(.98); }
.secondario { background: #fff; border: 1px solid var(--linea); }
.fisso { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom)); width: min(528px, calc(100% - 32px)); z-index: 5; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.fisso:active { transform: translateX(-50%) scale(.98); }
.azioni-doppie { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }

/* email */
.posta { background: #fff; border-radius: 18px; padding: 16px; box-shadow: var(--ombra); }
.posta-intestazione { display: flex; gap: 10px; align-items: center; }
.posta-intestazione div { display: flex; flex-direction: column; line-height: 1.25; }
.posta-intestazione span { font-size: 13px; color: var(--pietra); }
.posta-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--ottone-chiaro); color: var(--ottone); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.posta-oggetto { font-weight: 600; margin: 12px 0 4px; }
.posta-testo { margin: 0 0 14px; color: #45423d; font-size: 15px; }
.allegato { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; background: var(--carta); border: 1px solid var(--linea); border-radius: 14px; padding: 8px; cursor: pointer; position: relative; overflow: hidden; }
.allegato img { width: 92px; height: 70px; object-fit: cover; border-radius: 8px; }
.allegato span { display: flex; flex-direction: column; }
.allegato small { color: var(--ottone); font-weight: 600; font-size: 13px; }
.allegato::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.7), transparent 70%); transform: translateX(-100%); animation: luccica 2.8s 1s infinite; }
@keyframes luccica { 60%, 100% { transform: translateX(100%); } }
.oppure { text-align: center; margin: 26px 0 4px; font-size: 13px; color: var(--pietra); }

/* lettura */
.foglio-lettura, .foglio-mini { position: relative; border-radius: 14px; overflow: hidden; box-shadow: var(--ombra); background: #000; }
.foglio-lettura img, .foglio-mini img { display: block; width: 100%; height: auto; }
.scansione { position: absolute; inset: 0; pointer-events: none; }
.scansione::before { content: ""; position: absolute; left: 0; right: 0; height: 90px; top: -90px; background: linear-gradient(transparent, rgba(160,122,63,.35)); border-bottom: 2px solid #e8c88f; box-shadow: 0 6px 18px rgba(232,200,143,.8); animation: scansiona 2.2s ease-in-out infinite; }
.lettura-finita .scansione { display: none; }
@keyframes scansiona { to { top: 100%; } }
.segnaposti { position: absolute; inset: 0; pointer-events: none; }
.segno { position: absolute; transform: translate(-50%, -50%); }
.segno i { display: block; width: 14px; height: 14px; margin: auto; border-radius: 50%; background: var(--ottone); border: 2px solid #fff; box-shadow: 0 0 0 0 rgba(160,122,63,.7); animation: pulsa 1.6s infinite; }
.segno b { position: absolute; left: 50%; top: -30px; transform: translateX(-50%); white-space: nowrap; background: var(--inchiostro); color: #fff; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 8px; animation: entra .3s both; }
.segno.acceso i { background: #e53; transform: scale(1.4); }
@keyframes pulsa { 70% { box-shadow: 0 0 0 12px rgba(160,122,63,0); } 100% { box-shadow: 0 0 0 0 rgba(160,122,63,0); } }
.cronometro { font-weight: 300; font-size: 44px; text-align: center; margin: 18px 0 6px; font-variant-numeric: tabular-nums; }
.fasi { list-style: none; padding: 0; margin: 0; }
.fasi li { padding: 10px 0 10px 34px; position: relative; color: var(--pietra); border-bottom: 1px solid var(--linea); transition: color .3s; }
.fasi li::before { content: ""; position: absolute; left: 4px; top: 12px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--linea); }
.fasi li.in-corso { color: var(--inchiostro); }
.fasi li.in-corso::before { border-color: var(--ottone); border-right-color: transparent; animation: gira .8s linear infinite; }
.fasi li.fatta { color: var(--inchiostro); }
.fasi li.fatta::before { content: "✓"; background: var(--verde); border-color: var(--verde); color: #fff; font-size: 11px; display: grid; place-items: center; font-weight: 700; }
@keyframes gira { to { transform: rotate(360deg); } }
.errore { background: #fbe9e6; color: #8c2a1c; padding: 12px 14px; border-radius: 12px; }

/* scheda */
.foglio-mini { position: sticky; top: 70px; z-index: 4; width: 64%; margin: 0 auto; }
.gruppo { background: #fff; border-radius: 16px; padding: 4px 14px; margin: 10px 0; box-shadow: var(--ombra); }
.gruppo h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--pietra); margin: 12px 0 2px; font-weight: 600; }
.campo { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--carta-2); }
.campo:last-child { border-bottom: 0; }
.campo label { flex: 1; font-size: 15px; }
.campo label small { display: block; color: var(--pietra); font-size: 12px; }
.campo input[type=number], .campo input[type=text] { width: 92px; text-align: right; font: inherit; font-weight: 600; padding: 7px 8px; border: 1px solid var(--linea); border-radius: 10px; background: var(--carta); }
.campo input[type=text] { width: 150px; text-align: left; }
.campo input:focus { outline: 2px solid var(--ottone); border-color: transparent; }
.campo .um { width: 26px; font-size: 13px; color: var(--pietra); }
.etichetta { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--avviso-chiaro); color: var(--avviso); white-space: nowrap; }
.dubbi { background: var(--avviso-chiaro); border-radius: 16px; padding: 12px 14px; margin: 14px 0; }
.dubbi strong { color: var(--avviso); }
.dubbi ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.dubbi li { margin: 4px 0; }

/* proposte */
.vista3d { position: relative; height: 340px; border-radius: 18px; overflow: hidden; box-shadow: var(--ombra); touch-action: none; }
.vista3d canvas { display: block; width: 100%; height: 100%; }
.vista3d-aiuto { position: absolute; left: 12px; bottom: 10px; font-size: 12px; background: rgba(255,255,255,.85); padding: 4px 9px; border-radius: 8px; pointer-events: none; }
.materiali { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chip { flex: none; display: flex; align-items: center; gap: 7px; padding: 6px 12px 6px 6px; border-radius: 999px; border: 1px solid var(--linea); background: #fff; cursor: pointer; font-size: 14px; }
.chip i { width: 24px; height: 24px; border-radius: 50%; border: 1px solid rgba(0,0,0,.1); background-size: cover; }
.chip.scelto { border-color: var(--inchiostro); box-shadow: inset 0 0 0 1px var(--inchiostro); font-weight: 600; }
.proposte { display: grid; gap: 10px; margin: 10px 0; }
.proposta { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: #fff; border: 2px solid transparent; box-shadow: var(--ombra); cursor: pointer; text-align: left; width: 100%; }
.proposta.scelta { border-color: var(--ottone); }
.proposta img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; }
.proposta small { display: block; color: var(--pietra); font-size: 12px; }
.proposta .richiesto { color: var(--ottone); font-weight: 700; }
.proposta .prezzo { font-weight: 600; font-size: 19px; letter-spacing: -.01em; text-align: right; line-height: 1.1; }
.proposta .prezzo small { font-family: "Instrument Sans", sans-serif; }
.misure-veloci { background: #fff; border-radius: 16px; padding: 12px 14px; margin: 10px 0; box-shadow: var(--ombra); }
.misure-veloci summary { font-weight: 600; cursor: pointer; }
.voci { background: #fff; border-radius: 16px; padding: 6px 14px; box-shadow: var(--ombra); font-size: 14px; }
.voce { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--carta-2); }
.voce span:first-child small { display: block; color: var(--pietra); font-size: 12px; }
.voce.totale { border: 0; font-weight: 700; font-size: 17px; padding-top: 12px; }
.lampo { animation: lampo .6s; }
@keyframes lampo { 30% { background: var(--ottone-chiaro); } }

/* fine */
.pronto { display: flex; gap: 14px; align-items: center; background: #fff; padding: 16px; border-radius: 18px; box-shadow: var(--ombra); margin-top: 8px; }
.pronto div { display: flex; flex-direction: column; }
.pronto strong { font-family: "Marcellus", serif; font-weight: 400; font-size: 24px; }
.pronto span { color: var(--pietra); }
.pronto-spunta { width: 48px; height: 48px; border-radius: 50%; background: var(--verde); color: #fff; display: grid; place-items: center; font-size: 26px; animation: entra .5s .1s both; }
.anteprima-cornice { margin-top: 12px; border-radius: 12px; overflow: hidden; box-shadow: var(--ombra); background: #fff; }

/* listino */
dialog { border: 0; border-radius: 20px; padding: 6px 18px 12px; width: min(520px, calc(100% - 24px)); max-height: 88dvh; background: var(--carta); color: var(--inchiostro); }
dialog::backdrop { background: rgba(29,28,26,.45); }
body:has(#documento.anteprima) #app { min-height: 0; padding-bottom: 0; }
#documento.anteprima { margin-top: 0; }
