/* RANCIO - stile. Fonte di verita': design-system/rancio/MASTER.md */
:root {
  --fondo: #1d1b1a; --scheda: #2b2725; --campo: #141312; 
  --testo: #f6f1e9; --tenue: #a89f92;  --crema: #f3e6c8;
  --accento: #606ebb; --su-accento: #fff; --errore: #ff6b5e;
  /* il complementare dell'accento, come il verde acqua accanto al rosso di Bring */
  --secondo: #d5a047; --su-secondo: #000;      /* tasti secondari */
  --spento: #936c2b; --su-spento: #fff;        /* tessere gia' comprate */
  --rilievo: #7a7067; --su-rilievo: #fff;      /* cio' che si sceglie: giorni, categorie, alternative */
  --raggio: 12px; --raggio-s: 10px;
  --ombra: 4px 4px 0 #000; --ombra-s: 3px 3px 0 #000;
  --alto: env(safe-area-inset-top, 0px); --basso: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
/* Ogni colore rispetta le soglie della skill ui-ux-pro-max: testo 4.5:1 sul suo fondo, bordo del
   controllo 3:1 sulla superficie dove sta (fondo e scheda). Lo verifica test/test_contrasto.py. */
html[data-accento="petrolio"] { --accento: #177f8a; --secondo: #e49681; --spento: #bc5337; }
html[data-accento="blu-petrolio"] { --accento: #2e78b2; --secondo: #df9b5a; --spento: #a0672e; }
html[data-accento="cobalto"] { --accento: #3f6be2; --secondo: #dc9e21; --spento: #906e2a; }
html[data-accento="mattone"] { --accento: #c74933; --secondo: #36bac6; --spento: #277e86; }
html[data-accento="bosco"] { --accento: #398154; --secondo: #d698b9; --spento: #c73c86; }

/* touch-action: manipulation ovunque = niente zoom da doppio tocco; il pizzico lo ferma app.js */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* Altezza del guscio: --vh, scritta da guscio.js. NON 100% e NON 100dvh: vedi il commento in quel file.
   html ha il colore della barra in basso: se mai restasse una fascia sotto il guscio, iOS la dipinge
   con questo colore e continua la barra invece di staccarsene. */
html { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; background-color: var(--campo); }
body {
  height: var(--vh, 100dvh); margin: 0; overflow: hidden; overscroll-behavior: none;
  background: var(--fondo); color: var(--testo);
  font: 700 16px/1.3 -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; -webkit-user-select: none; user-select: none;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--crema); outline-offset: 2px; }

/* colonna a tutta altezza: testata e barra sono elementi normali, scorre solo il contenuto */
.app { height: 100%; display: flex; flex-direction: column; }
.testa { flex: 0 0 auto; padding: calc(var(--alto) + 10px) 12px 10px; display: flex; align-items: flex-end; gap: 10px; }
.testa h1 { margin: 0; flex: 1; font-size: 30px; font-weight: 900; text-transform: uppercase; letter-spacing: -.01em; line-height: 1; }
.contenuto:focus { outline: none; }
.contenuto { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 4px 12px 24px; }
/* il molo: cio' che sta ancorato sopra la barra, a portata di pollice. Elemento normale della colonna, mai fixed */
.molo { flex: 0 0 auto; display: flex; gap: 10px; padding: 10px 12px; border-top: 3px solid #000; background: var(--campo); }
.molo .finto { flex: 1; min-width: 0; text-align: left; }
.cerca-riga { display: flex; gap: 8px; margin: 0 0 4px; }
.cerca-riga .campo { flex: 1; min-width: 0; }
.cerca-riga .tasto { flex: none; min-height: 54px; }
.barra { flex: 0 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; border-top: 3px solid #000; background: var(--campo);
  /* safe area ridotta, come SPOTTER: l'indicatore di casa occupa poco e i tasti devono restare a portata */
  padding: 8px 8px max(8px, calc(var(--basso) - 22px)); }
.barra button { height: 50px; padding: 0; min-width: 0; overflow: hidden; border: 3px solid transparent; border-radius: var(--raggio-s); background: none; color: var(--tenue);
  /* quattro schede, la piu' lunga e' "Impostazioni": a 13px con spaziatura larga veniva tagliata */
  font-weight: 900; font-size: 11.5px; text-transform: uppercase; letter-spacing: .01em; }
.barra button[aria-current="page"] { background: var(--accento); color: var(--su-accento); border-color: #000; box-shadow: var(--ombra-s); }

/* elementi comuni */
.etichetta { font-weight: 900; font-size: 13px; padding: 6px 10px; border: 3px solid #000; border-radius: var(--raggio-s);
  background: var(--crema); color: #000; box-shadow: var(--ombra-s); text-transform: uppercase; white-space: nowrap; }
button.etichetta { min-height: 44px; }

.tasto { min-height: 52px; padding: 0 18px; border: 3px solid #000; border-radius: var(--raggio); background: var(--accento);
  color: var(--su-accento); font-weight: 900; text-transform: uppercase; letter-spacing: .04em; box-shadow: var(--ombra); }
.tasto.neutro { background: var(--secondo); color: var(--su-secondo); }
.tasto.rilievo { background: var(--rilievo); color: var(--su-rilievo); }
.tasto.pericolo { background: var(--errore); color: #000; }
.tasto.quadro { width: 52px; padding: 0; font-size: 24px; }
.tasto:active, .t:active, .etichetta:active { transform: translate(2px, 2px); box-shadow: none; }
.campo { width: 100%; height: 54px; padding: 0 16px; border: 3px solid #000; border-radius: var(--raggio); background: var(--crema);
  color: #000; font-size: 16px; font-weight: 700; box-shadow: var(--ombra); -webkit-user-select: text; user-select: text; }
.campo::placeholder { color: #5a5347; }
/* tutti i campi sono crema: si vedono subito. Mai scuri, mai bianco ottico */
.campo.finto { color: #5a5347; }
.sez { font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .1em; color: var(--tenue); margin: 18px 0 8px; }
.avviso { border: 3px solid #000; border-radius: var(--raggio); background: var(--crema); color: #000; padding: 10px 12px;
  font-size: 14px; font-weight: 700; box-shadow: var(--ombra-s); margin: 0 0 12px; }
.errore { color: var(--errore); min-height: 1.4em; margin: 8px 0 0; font-size: 14px; }
.vuoto { color: var(--tenue); text-align: center; padding: 28px 12px; }
.riga-tasti { display: flex; gap: 10px; margin-top: 12px; }
.riga-tasti > * { flex: 1; }

/* ---- spesa ---- */
.g { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.contenuto > .sez { margin-top: 8px; }
.tasto.staccato { margin-top: 18px; }
.t { aspect-ratio: 1; min-width: 0; border: 3px solid #000; border-radius: var(--raggio); box-shadow: var(--ombra);
  background: var(--accento); color: var(--su-accento); display: flex; flex-direction: column; align-items: center;
  justify-content: flex-end; padding: 6px 4px 8px; text-align: center; overflow: hidden; }
.t img, .t .lettera { flex: 1; min-height: 0; width: 78%; object-fit: contain; }
.t .lettera { display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 900; opacity: .7; }
.t b { font-size: 13px; font-weight: 800; line-height: 1.1; text-transform: uppercase; max-width: 100%; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.t small { font-size: 11px; font-weight: 600; opacity: .85; line-height: 1.15; margin-top: 1px; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t.r { background: var(--spento); color: var(--su-spento); box-shadow: var(--ombra-s); }
.t.nuovo { background: var(--rilievo); color: var(--su-rilievo); border-style: dashed; }
.categorie { display: grid; gap: 10px; }
.liste { display: grid; gap: 10px; margin: 0 0 12px; }
.chiave { color: #000; display: block; padding: 10px 12px; border: 3px dashed #000; border-radius: var(--raggio-s); background: var(--crema);
  font: 600 13px/1.4 ui-monospace, monospace; overflow-wrap: anywhere; -webkit-user-select: all; user-select: all; }
.categoria { width: 100%; min-height: 56px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 3px solid #000; border-radius: var(--raggio); background: var(--rilievo); color: var(--su-rilievo); box-shadow: var(--ombra-s); text-align: left; }
.categoria b { font-weight: 900; text-transform: uppercase; font-size: 14px; letter-spacing: .03em; }
.categoria span { font-weight: 900; font-size: 13px; opacity: .9; }
.categoria[aria-expanded="true"] { background: var(--accento); color: var(--su-accento); }

.dettaglio { border: 3px solid #000; border-radius: var(--raggio); background: var(--scheda); box-shadow: var(--ombra);
  padding: 12px; margin: 0 0 14px; }
.dettaglio h2 { margin: 0 0 10px; font-size: 18px; font-weight: 900; text-transform: uppercase; }

/* ---- oggi ---- */
.giorni { display: flex; gap: 6px; margin: 4px 0 12px; }
.giorni button { flex: 1; min-width: 0; height: 48px; border: 3px solid #000; border-radius: var(--raggio-s); background: var(--rilievo);
  color: var(--su-rilievo); font-weight: 900; font-size: 12px; text-transform: uppercase; padding: 0; }
.giorni button[aria-pressed="true"] { background: var(--crema); color: #000; box-shadow: var(--ombra-s); }
.giorni button.oggi:not([aria-pressed="true"]) { border-style: dashed; }
.tipi { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 14px; }
.tipi button { min-height: 52px; border: 3px solid #000; border-radius: var(--raggio-s); background: var(--rilievo); color: var(--su-rilievo);
  font-weight: 900; font-size: 13px; text-transform: uppercase; padding: 4px 8px; }
.tipi button[aria-pressed="true"] { background: var(--crema); color: #000; box-shadow: var(--ombra-s); }
.pasto { border: 3px solid #000; border-radius: var(--raggio); background: var(--scheda); box-shadow: var(--ombra); margin: 0 0 14px; overflow: hidden; }
.pasto > header { padding: 10px 12px; border-bottom: 3px solid #000; background: var(--accento); color: var(--su-accento); }
.pasto > header b { display: block; font-weight: 900; text-transform: uppercase; font-size: 15px; letter-spacing: .03em; }
.pasto > header small { font-weight: 700; font-size: 12px; opacity: .9; }
.voce { border-bottom: 2px solid rgba(0, 0, 0, .45); }
.voce:last-child { border-bottom: 0; }
.voce > button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 12px; min-height: 62px; border: 0;
  background: none; text-align: left; }
.voce > button:disabled { cursor: default; color: inherit; opacity: 1; }
.comp { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.c { display: flex; align-items: center; gap: 10px; }
.c img, .c .lettera { width: 42px; height: 42px; flex: none; object-fit: contain; }
.c .lettera { display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 22px; color: var(--tenue); }
.c .n { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; line-height: 1.15; }
.c .n small { display: block; font-weight: 600; font-size: 12px; color: var(--tenue); }
.c .q { font-weight: 900; font-size: 22px; letter-spacing: -.02em; white-space: nowrap; }
.c .q small { font-size: 12px; font-weight: 800; opacity: .75; margin-left: 2px; }
.comp .nota { font-size: 12px; font-weight: 600; color: var(--tenue); }
.scelte button[aria-pressed="true"] .nota { color: inherit; opacity: .85; }
.alt { width: 44px; height: 44px; flex: none; border: 3px solid #000; border-radius: var(--raggio-s); background: var(--secondo); color: var(--su-secondo);
  display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 13px; }
.voce[data-aperta] .alt { background: var(--crema); color: #000; }
.scelte { padding: 4px 12px 12px; display: grid; gap: 8px; }
.scelte button { width: 100%; text-align: left; padding: 8px 10px; min-height: 58px; border: 3px solid #000; border-radius: var(--raggio-s);
  background: var(--rilievo); color: var(--su-rilievo); }
.scelte button .n small, .scelte button .nota, .scelte button .lettera { color: inherit; opacity: .9; }
.scelte button[aria-pressed="true"] { background: var(--accento); color: var(--su-accento); box-shadow: var(--ombra-s); outline: 3px solid var(--crema); outline-offset: -6px; }
.scelte button[aria-pressed="true"] .n small, .scelte button[aria-pressed="true"] .lettera { color: inherit; opacity: .85; }
.scelte .c img, .scelte .c .lettera { width: 34px; height: 34px; }
.scelte .c .q { font-size: 18px; }
.limite { display: inline-block; margin-top: 4px; font-size: 11px; font-weight: 900; text-transform: uppercase; background: var(--crema);
  color: #000; border: 2px solid #000; border-radius: 6px; padding: 1px 6px; }
.nota-voce { padding: 0 12px 10px; margin: -2px 0 0; font-size: 12px; font-weight: 600; color: var(--tenue); }

/* ---- le mie liste ---- */
.liste-elenco { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.lista { display: grid; grid-template-columns: 1fr auto; border: 3px solid #000; border-radius: var(--raggio); background: var(--scheda);
  box-shadow: var(--ombra); overflow: hidden; }
.lista.aperta { background: var(--accento); color: var(--su-accento); }
.lista-apri { min-width: 0; min-height: 84px; padding: 12px 14px; border: 0; background: none; text-align: left; display: grid; gap: 4px; align-content: center; }
.lista-nome { font-size: 20px; font-weight: 900; text-transform: uppercase; letter-spacing: -.01em; line-height: 1.1; overflow-wrap: anywhere; }
.lista-stato { font-size: 14px; font-weight: 700; color: var(--tenue); }
.lista.aperta .lista-stato { color: inherit; opacity: .9; }
.lista-segno { justify-self: start; margin-top: 2px; font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em;
  background: var(--crema); color: #000; border: 2px solid #000; border-radius: 6px; padding: 1px 6px; }
.lista-tasto { min-width: 104px; border: 0; border-left: 3px solid #000; background: var(--secondo); color: var(--su-secondo);
  font-weight: 900; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.lista-modifica { grid-column: 1 / -1; padding: 14px; border-top: 3px solid #000; background: var(--scheda); color: var(--testo); }

/* ---- piano e impostazioni ---- */
.numeri { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.numero { border: 3px solid #000; border-radius: var(--raggio); background: var(--scheda); box-shadow: var(--ombra-s); padding: 10px 12px; }
.numero b { display: block; font-size: 24px; font-weight: 900; letter-spacing: -.02em; }
.numero span { font-size: 12px; font-weight: 800; text-transform: uppercase; color: var(--tenue); letter-spacing: .06em; }
.elenco { margin: 0; padding: 0; list-style: none; border: 3px solid #000; border-radius: var(--raggio); background: var(--scheda); box-shadow: var(--ombra-s); }
.elenco li { padding: 10px 12px; border-bottom: 2px solid rgba(0, 0, 0, .45); font-size: 14px; font-weight: 600; display: flex; gap: 10px; justify-content: space-between; }
.elenco li:last-child { border-bottom: 0; }
.elenco li .tasto { min-height: 44px; padding: 0 12px; font-size: 12px; box-shadow: var(--ombra-s); }
.elenco li b { font-weight: 900; text-transform: uppercase; font-size: 13px; }
.colori { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.colori button { height: 64px; border: 3px solid #000; border-radius: var(--raggio); color: #fff; font-weight: 900; font-size: 12px;
  text-transform: uppercase; box-shadow: var(--ombra-s); }
.colori button[aria-pressed="true"] { outline: 3px solid var(--crema); outline-offset: 2px; }
.colori [data-accento="inchiostro"] { background: #606ebb; }
.colori [data-accento="petrolio"] { background: #177f8a; }
.colori [data-accento="blu-petrolio"] { background: #2e78b2; }
.colori [data-accento="cobalto"] { background: #3f6be2; }
.colori [data-accento="mattone"] { background: #c74933; }
.colori [data-accento="bosco"] { background: #398154; }
.modulo { display: grid; gap: 12px; }
.versione { color: var(--tenue); text-align: center; font-size: 12px; margin: 24px 0 0; }

/* ---- moduli con etichette (password) ---- */
.scheda-modulo { border: 3px solid #000; border-radius: var(--raggio); background: var(--scheda); box-shadow: var(--ombra); padding: 14px; gap: 16px; }
.scheda-modulo, .dettaglio, .lista-modifica { color: var(--testo); }
.casella label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
.con-tasto { display: flex; gap: 8px; }
.con-tasto .campo { flex: 1; min-width: 0; }
.vedi { flex: none; min-width: 92px; height: 54px; padding: 0 10px; border: 3px solid #000; border-radius: var(--raggio); background: var(--secondo);
  color: var(--su-secondo); font-weight: 900; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; box-shadow: var(--ombra-s); }
.vedi[aria-pressed="true"] { background: var(--crema); color: #000; }
.sotto-campo { margin: 6px 2px 0; font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--tenue); }
.sotto-campo:empty { display: none; }
.errore-campo { color: var(--errore); font-weight: 800; }
.campo[aria-invalid="true"] { border-color: var(--errore); }
.requisiti { margin: -6px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.requisiti li { display: flex; gap: 8px; align-items: baseline; font-size: 14px; font-weight: 700; color: var(--tenue); }
.requisiti li > span:first-child { flex: none; width: 22px; height: 22px; border: 2px solid #000; border-radius: 6px; background: var(--rilievo); color: var(--su-rilievo);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 900; font-size: 13px; }
.requisiti li.ok { color: var(--testo); }
.requisiti li.ok > span:first-child { background: var(--crema); color: #000; }
.tasto.largo { width: 100%; }
.tasto:disabled, .barra button:disabled { opacity: .45; box-shadow: none; cursor: default; }
.avviso b { font-weight: 900; text-transform: uppercase; }
/* presente per chi ascolta e per i gestori di password, invisibile per chi guarda */
.solo-voce { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- finestre di avviso ----
   Il velo e' trasparente: su iOS nessun livello a schermo intero puo' avere un colore suo.
   A scurirsi e' il contenuto sotto. */
.velo { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  padding: calc(var(--alto) + 16px) 20px calc(var(--basso) + 16px); background: transparent; }
.sotto { filter: brightness(.35) saturate(.6); pointer-events: none; }
.modale { width: 100%; max-width: 360px; max-height: 100%; overflow-y: auto; border: 3px solid #000; border-radius: var(--raggio);
  background: var(--scheda); color: var(--testo); box-shadow: 6px 6px 0 #000; }
.modale h2 { margin: 0; padding: 12px 14px; border-bottom: 3px solid #000; background: var(--errore); color: #000;
  font-size: 17px; font-weight: 900; text-transform: uppercase; letter-spacing: .03em; }
.modale-rete h2 { background: var(--crema); }
.modale-domanda h2 { background: var(--accento); color: var(--su-accento); }
.modale p.aiuto { padding-top: 6px; font-size: 14px; font-weight: 600; color: var(--tenue); }
.striscia { position: fixed; z-index: 11; left: 16px; right: 16px; top: calc(var(--alto) + 12px); padding: 12px 14px; border: 3px solid #000;
  border-radius: var(--raggio); background: var(--crema); color: #000; box-shadow: var(--ombra); font-size: 15px; font-weight: 800; }
.modale p { margin: 0; padding: 16px 14px 4px; font-size: 16px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.modale .riga-tasti { margin: 0; padding: 14px; }
@media (prefers-reduced-motion: no-preference) {
  .modale, .striscia { animation: modale-entra .16s ease-out; }
  .sotto { transition: filter .16s ease-out; }
  @keyframes modale-entra { from { transform: translateY(10px) scale(.97); opacity: 0; } }
}

/* ---- accesso ---- */
.porta { height: 100%; overflow-y: auto; padding-top: var(--alto); padding-bottom: var(--basso); display: flex; align-items: center; justify-content: center; padding: 24px; }
.porta form { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.porta h1 { margin: 0; font-size: 44px; font-weight: 900; text-transform: uppercase; letter-spacing: -.02em; text-align: center; }
.porta p { margin: 0 0 8px; color: var(--tenue); text-align: center; font-size: 14px; }
.porta img { width: 120px; height: 120px; margin: 0 auto; }

@media (prefers-reduced-motion: no-preference) {
  .t, .tasto, .etichetta { transition: transform .12s ease-out, box-shadow .12s ease-out, background-color .18s ease-out; }
}
@media (min-width: 700px) {
  .app, .porta { max-width: 520px; margin: 0 auto; }
}
