/* ==========================================================================
   FIT OS — foglio di stile unico
   Mobile first. Nessun web font, nessun framework, nessuna dipendenza.
   Peso: ~11 KB non minificato. Ordine dei blocchi = ordine di lettura.
   ========================================================================== */

/* 1. Token ---------------------------------------------------------------- */
:root {
  --ink: #14150F;
  --ink-2: #6E7370;
  --ink-3: #9AA095;
  --paper: #EDEBE4;
  --surface: #FFFFFF;
  --surface-2: #F6F5F0;
  --field: #FBFAF7;
  --signal: #1D6B3F;
  --alert: #A8341C;

  --hair: rgba(20, 21, 19, 0.14);
  --hair-soft: rgba(20, 21, 19, 0.08);
  --line: rgba(20, 21, 19, 0.22);

  --font: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --s1: 4px;
  --s2: 6px;
  --s3: 9px;
  --s4: 12px;
  --s5: 14px;
  --s6: 20px;

  /* altezze fisse usate per il calcolo dello scroll */
  --header-h: 58px;
  --tabbar-h: 62px;
}

/* 2. Reset minimo -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
}

h1, h2, h3, p, ul, ol { margin: 0; }
ol, ul { padding-left: 16px; }

a { color: var(--signal); text-underline-offset: 3px; }
a:hover { color: var(--ink); }

img, svg { display: block; max-width: 100%; }

button, input, select, textarea { font: inherit; color: inherit; }

* { -webkit-tap-highlight-color: transparent; }

/* 3. Utility tipografiche ------------------------------------------------ */
/* Ogni numero passa da .num: cifre a larghezza fissa, niente salti. */
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.muted { color: var(--ink-2); }
.ok { color: var(--signal); }
.warn { color: var(--alert); }
.pretty { text-wrap: pretty; }

/* 4. Guscio applicazione ------------------------------------------------- */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: var(--s4) var(--s5) 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--hair);
}
.app-header__title { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.app-header__meta { text-align: right; }
.app-header__meta-value { font-size: 15px; font-weight: 700; }

.app-main { flex: 1; }

/* Barra di navigazione: 5 voci, target 44px minimi. */
.tab-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--hair);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab-bar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-height: 46px;
  padding: var(--s3) 2px 7px;
  border: 0;
  background: none;
  color: #A7ABA2;
  cursor: pointer;
  text-decoration: none;
}
.tab-bar__item svg { width: 19px; height: 19px; stroke: currentColor; stroke-width: 1.7; fill: none; }
.tab-bar__label { font-size: 9.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.tab-bar__item.is-active { color: var(--ink); }

/* 5. Blocchi di contenuto ------------------------------------------------ */
/* Il layout denso non usa card staccate: fasce a tutta larghezza separate
   da un filetto. Un blocco = una fascia. */
.block {
  background: var(--surface);
  border-bottom: 1px solid var(--hair);
  padding: var(--s4) var(--s5);
}
.block--flush { padding: 0; }
.block__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: var(--s3);
}
.block__bar {
  padding: 8px var(--s5);
  background: var(--surface-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* 6. Griglie numeriche --------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border-bottom: 1px solid var(--hair);
}
.stat-grid--4 { grid-template-columns: repeat(4, 1fr); }
.stat-grid--2 { grid-template-columns: repeat(2, 1fr); }
.stat {
  padding: 10px var(--s4);
  border-right: 1px solid var(--hair-soft);
}
.stat:last-child { border-right: 0; }
.stat--center { text-align: center; }
.stat__value {
  margin-top: 3px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.04em;
}
.stat__value--sm { font-size: 18px; letter-spacing: -0.02em; }
.stat__note { margin-top: 1px; font-size: 10.5px; color: var(--ink-2); }

/* Riga etichetta/valore: profilo, misure, statistiche di costanza. */
.data-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: var(--s3) var(--s5);
  border-top: 1px solid var(--hair-soft);
  background: var(--surface);
  font-size: 13px;
  width: 100%;
  border-left: 0; border-right: 0; border-bottom: 0;
  text-align: left;
  cursor: pointer;
}
.data-row--static { cursor: default; }
.data-row__value { font-family: var(--mono); font-weight: 700; }
.data-row:hover { background: var(--surface-2); }
.data-row--danger { color: var(--alert); }
.data-row--danger:hover { background: #FBF3F1; }

/* 7. Barre macro (SVG inline, nessuna libreria) -------------------------- */
.macro { display: flex; flex-direction: column; gap: var(--s3); }
.macro__row { display: flex; align-items: baseline; justify-content: space-between; font-size: 11.5px; }
.macro__name { font-weight: 600; }
.macro__val { font-family: var(--mono); color: var(--ink-2); }
.macro-bar {
  display: block;
  width: 100%;
  height: 4px;
  margin-top: var(--s1);
  background: #E7E5DC;
}
.macro-bar rect { fill: var(--ink); }

/* 8. Grafici ------------------------------------------------------------- */
.chart { display: block; width: 100%; overflow: visible; }
.chart__grid { stroke: rgba(20, 21, 19, 0.10); stroke-width: 1; }
.chart__grid--base { stroke: rgba(20, 21, 19, 0.20); }
.chart__raw { fill: none; stroke: rgba(20, 21, 19, 0.34); stroke-width: 1; }
.chart__avg { fill: none; stroke: var(--signal); stroke-width: 2.2; }
.chart__axis {
  display: flex;
  justify-content: space-between;
  padding: 2px 0 var(--s1);
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--ink-3);
}

/* 9. Pasti --------------------------------------------------------------- */
.meal-card {
  display: block;
  width: 100%;
  padding: 11px var(--s5);
  border: 0;
  border-top: 1px solid var(--hair-soft);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.meal-card:hover { background: var(--surface-2); }
.meal-card__top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.meal-card__slot { font-size: 9px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.meal-card__state { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.meal-card__state.is-done { color: var(--signal); }
.meal-card__name { margin-top: 2px; font-size: 14px; font-weight: 600; }
.meal-card__macro { margin-top: 2px; font-family: var(--mono); font-size: 11px; color: var(--ink-2); }
.meal-card__foot { display: flex; align-items: center; justify-content: space-between; margin-top: var(--s2); }

/* Tabella ingredienti del dettaglio pasto. */
.ing {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px 36px 30px 46px;
  align-items: baseline;
  padding: var(--s3) var(--s5);
  border-bottom: 1px solid var(--hair-soft);
  font-size: 12px;
}
.ing--head {
  border-bottom: 1px solid var(--hair);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.ing--total { background: var(--surface-2); font-weight: 700; font-family: var(--mono); border-bottom: 0; }
.ing > span + span { text-align: right; font-family: var(--mono); }
.ing__qty { font-family: var(--mono); font-size: 11px; color: var(--ink-2); }

/* 10. Allenamento -------------------------------------------------------- */
.workout-card {
  padding: 11px var(--s5) 13px;
  background: var(--surface);
  border-bottom: 1px solid var(--hair);
}
.workout-card.is-started { background: #F4F7F2; }
.workout-card__top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.workout-card__name { font-size: 14px; font-weight: 700; }
.workout-card__scheme { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.workout-card__note { margin-top: 7px; font-size: 11px; color: var(--ink-2); }
.workout-card__foot { display: flex; align-items: center; gap: 8px; margin-top: var(--s3); }

/* Confronto "ultimo allenamento / suggerito": due celle su filetto. */
.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-top: var(--s3);
  background: rgba(20, 21, 19, 0.12);
  border: 1px solid rgba(20, 21, 19, 0.12);
}
.compare__cell { padding: 7px var(--s3); background: var(--surface); }
.compare__label { font-size: 8.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.compare__value { margin-top: 2px; font-size: 12.5px; font-weight: 700; font-family: var(--mono); }
.compare__value--text { font-family: var(--font); }

/* Stepper kg / ripetizioni / RIR. */
.set-logger { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.set-logger__field { border: 1px solid rgba(20, 21, 19, 0.18); }
.set-logger__label { padding: var(--s2) 0 2px; text-align: center; font-size: 8.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.set-logger__value { text-align: center; font-family: var(--mono); font-size: 20px; font-weight: 700; }
.set-logger__ctrl { display: flex; border-top: 1px solid rgba(20, 21, 19, 0.12); }
.set-logger__btn {
  flex: 1;
  min-height: 34px;
  border: 0;
  background: var(--field);
  font-size: 14px;
  cursor: pointer;
}
.set-logger__btn:first-child { border-right: 1px solid rgba(20, 21, 19, 0.12); }

/* 11. Lista della spesa -------------------------------------------------- */
.shopping-group { background: var(--surface); border-bottom: 1px solid var(--hair); }
.shopping-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px var(--s5);
  border: 0;
  border-top: 1px solid var(--hair-soft);
  background: none;
  text-align: left;
  cursor: pointer;
}
.shopping-item:hover { background: var(--surface-2); }
.shopping-item__box {
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(20, 21, 19, 0.3);
  background: var(--surface);
  color: var(--surface);
  font-size: 11px;
}
.shopping-item__name { flex: 1; font-size: 13px; }
.shopping-item__qty { font-family: var(--mono); font-size: 12px; font-weight: 700; }
.shopping-item.is-checked .shopping-item__box { background: var(--ink); }
.shopping-item.is-checked .shopping-item__name { color: var(--ink-3); text-decoration: line-through; }
.shopping-item.is-checked .shopping-item__qty { color: var(--ink-3); }

.list-done { padding: 40px var(--s6) 34px; text-align: center; background: var(--surface); border-bottom: 1px solid var(--hair); }
.list-done__kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--signal); }
.list-done__count { margin-top: 8px; font-family: var(--mono); font-size: 30px; font-weight: 700; letter-spacing: -0.03em; }

/* 12. Form --------------------------------------------------------------- */
.form-group { display: block; margin-bottom: var(--s5); }
.form-group__label {
  display: block;
  margin-bottom: 5px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.form-group__hint { margin-top: var(--s1); font-size: 11px; color: var(--ink-2); }
.input {
  width: 100%;
  min-height: 44px;
  padding: 11px var(--s4);
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--field);
  font-size: 14px;
}
.input--num { font-family: var(--mono); font-size: 13.5px; }
.input:focus { outline: 2px solid var(--ink); outline-offset: -2px; }
.input[aria-invalid="true"] { border-color: var(--alert); }
.field-error { margin-top: var(--s1); font-size: 11px; color: var(--alert); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Selezione multipla: preferenze, allergie, giorni, attrezzatura. */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12.5px;
  color: #3A3D37;
  cursor: pointer;
}
.chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--surface); }

/* 13. Bottoni ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 13px var(--s5);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.btn:hover { background: #F0EFE9; }
.btn--primary { border-color: var(--ink); background: var(--ink); color: var(--surface); }
.btn--primary:hover { background: var(--signal); border-color: var(--signal); }
.btn--danger { color: var(--alert); }
.btn--block { width: 100%; }
.btn--sm { min-height: 34px; padding: 8px var(--s4); font-size: 10.5px; letter-spacing: 0.06em; }
.btn--link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--signal);
  font-size: 12.5px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: underline;
}
.btn-row { display: flex; gap: var(--s2); }
.btn-row > .btn { flex: 1; }

/* 14. Avvisi ------------------------------------------------------------- */
/* Un avviso è una fascia con un filetto verticale, non una card colorata. */
.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px var(--s5);
  background: var(--surface-2);
  border-bottom: 1px solid var(--hair);
  font-size: 11.5px;
  line-height: 1.45;
}
.notice::before {
  content: "";
  flex: 0 0 3px;
  align-self: stretch;
  background: var(--ink);
}
.notice--alert::before { background: var(--alert); }
.notice--block { background: var(--ink); color: var(--surface); border-bottom-color: var(--ink); }
.notice--block::before { background: var(--surface); }
.notice__title { font-size: 12.5px; font-weight: 700; }
.notice__body { margin-top: 2px; color: var(--ink-2); }
.notice--block .notice__body { color: rgba(255, 255, 255, 0.7); }

/* 15. Onboarding --------------------------------------------------------- */
.wizard { display: flex; flex-direction: column; min-height: 100dvh; background: var(--surface); }
.wizard__head { padding: var(--s6) var(--s6) var(--s4); border-bottom: 1px solid var(--hair); }
.wizard__meta { display: flex; align-items: baseline; justify-content: space-between; }
.wizard__step { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--ink-2); }
.wizard__progress { display: flex; gap: 3px; margin-top: var(--s3); }
.wizard__progress span { flex: 1; height: 3px; background: var(--hair); }
.wizard__progress span.is-done { background: var(--ink); }
.wizard__title { margin: 13px 0 3px; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.wizard__sub { font-size: 12px; color: var(--ink-2); }
.wizard__body { flex: 1; }
.wizard__section { padding: 13px var(--s6) 15px; border-bottom: 1px solid rgba(20, 21, 19, 0.10); }
.wizard__foot {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: var(--s4) var(--s6) calc(var(--s4) + env(safe-area-inset-bottom, 0));
  background: var(--surface);
  border-top: 1px solid var(--hair);
}
.wizard__foot .btn--primary { flex: 1; }

/* Esito del motore mostrato dentro il wizard. */
.calc { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--hair); border: 1px solid var(--hair); }
.calc__cell { padding: var(--s3) 10px; background: var(--surface-2); }
.calc__value { margin-top: 2px; font-family: var(--mono); font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }

/* 16. Autenticazione ----------------------------------------------------- */
.auth { min-height: 100dvh; padding: var(--s6) 26px 40px; background: var(--surface); }
.auth__brand { font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }
.auth__title { margin: 26px 0 var(--s2); font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.auth__sub { margin-bottom: 26px; max-width: 30ch; font-size: 13px; color: var(--ink-2); }
.auth__links { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s3); margin-top: 18px; }
.auth__note { margin-top: 26px; padding: 11px var(--s4); border: 1px solid var(--hair); background: var(--surface-2); font-size: 11.5px; color: var(--ink-2); }

/* 17. Pannello sostituzioni --------------------------------------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: rgba(20, 21, 19, 0.42);
}
.sheet-backdrop__close { flex: 1; border: 0; background: none; cursor: pointer; }
.sheet {
  display: flex;
  flex-direction: column;
  max-height: 74vh;
  background: var(--surface);
  border-top: 1px solid rgba(20, 21, 19, 0.2);
}
.sheet__head { padding: var(--s5) var(--s5) 11px; border-bottom: 1px solid var(--hair); }
.sheet__title { margin-top: 2px; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.sheet__sub { margin-top: 8px; font-size: 11.5px; color: var(--ink-2); }
.sheet__body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet__foot { padding: 11px var(--s5) calc(11px + env(safe-area-inset-bottom, 0)); border-top: 1px solid var(--hair); font-size: 11px; color: var(--ink-2); }

.swap-option {
  display: block;
  width: 100%;
  padding: var(--s4) var(--s5);
  border: 0;
  border-bottom: 1px solid var(--hair-soft);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.swap-option:hover { background: #F3F2ED; }
.swap-option__top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.swap-option__name { font-size: 13.5px; font-weight: 600; }
.swap-option__qty { font-family: var(--mono); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.swap-option__macro { display: flex; gap: 10px; margin-top: 5px; font-family: var(--mono); font-size: 11px; color: var(--ink-2); }
.swap-option__delta { margin-top: var(--s2); font-size: 11px; color: var(--ink-2); }
.swap-option.is-warn .swap-option__delta { color: var(--alert); }

/* 18. Foto progresso ---------------------------------------------------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-grid--pair { grid-template-columns: 1fr 1fr; }
.photo-slot {
  aspect-ratio: 2 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s2);
  border: 1px dashed rgba(20, 21, 19, 0.3);
  background: var(--field);
  font-size: 10.5px;
  color: var(--ink-3);
  text-align: center;
}
.photo-slot--image { padding: 0; border-style: solid; }
.photo-slot--image img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot--wide { aspect-ratio: 3 / 2; }
.photo-caption { margin-top: 5px; font-size: 9px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }

/* 19. Selettore settimana / segmenti ----------------------------------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--surface); border-bottom: 1px solid var(--hair); }
.week__day {
  padding: var(--s3) 0;
  border: 0;
  border-right: 1px solid var(--hair-soft);
  background: none;
  text-align: center;
  cursor: pointer;
}
.week__day:last-child { border-right: 0; }
.week__dow { font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.week__num { font-family: var(--mono); font-size: 13px; font-weight: 700; }
.week__day.is-active { background: var(--ink); color: var(--surface); }
.week__day.is-active .week__dow { color: rgba(255, 255, 255, 0.6); }

.segmented { display: flex; gap: 1px; background: var(--surface); border-bottom: 1px solid var(--hair); }
.segmented__item {
  flex: 1;
  min-height: 40px;
  border: 0;
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}
.segmented__item.is-active { background: var(--ink); color: var(--surface); }

/* 20. Admin -------------------------------------------------------------- */
.food-row {
  display: grid;
  grid-template-columns: 1fr 44px 34px 34px 34px;
  align-items: baseline;
  padding: 8px var(--s5);
  border-top: 1px solid var(--hair-soft);
  background: var(--surface);
  font-size: 12px;
}
.food-row--head {
  border-top: 0;
  background: var(--surface-2);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.food-row > span + span { text-align: right; font-family: var(--mono); color: var(--ink-2); }
.food-row__cat { font-size: 10.5px; color: var(--ink-3); }

/* 21. Desktop ------------------------------------------------------------ */
/* Il progetto è mobile first: da 720px le fasce si centrano, la tab bar
   diventa una sidebar. Nessun ridisegno, solo riposizionamento. */
@media (min-width: 720px) {
  .app { flex-direction: row; align-items: flex-start; max-width: 1080px; margin: 0 auto; }
  .app-sidebar { display: block; }
  .app__col { flex: 1; min-width: 0; }
  .tab-bar {
    position: sticky;
    top: 0;
    bottom: auto;
    grid-template-columns: 1fr;
    width: 190px;
    height: 100dvh;
    border-top: 0;
    border-right: 1px solid var(--hair);
  }
  .tab-bar__item { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 12px var(--s5); }
  .stat-grid { grid-template-columns: repeat(6, 1fr); }
  .stat-grid--4 { grid-template-columns: repeat(4, 1fr); }
  .sheet { max-width: 520px; margin: 0 auto; }
}

/* 22. Preferenze utente ------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media print {
  .tab-bar, .app-header, .sheet-backdrop { display: none; }
  .block, .stat-grid { border-color: #000; }
}

/* 22. Estensioni FIT OS (aggiunte in fase di sviluppo, stesse regole: niente raggi, niente ombre) */
.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; line-height: 1.45; cursor: pointer; }
.check-row input { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; accent-color: var(--ink); }
.form-group__hint { display: block; margin-top: 5px; font-size: 11px; color: var(--ink-2); }
.form-inline { margin-top: var(--s3); }
.btn-row--tight { margin-top: var(--s3); }
.week-nav { display: flex; gap: 4px; }
.week-nav .btn { min-height: 34px; padding: 6px 12px; }
.details { margin-bottom: var(--s5); }
.details summary { list-style: none; cursor: pointer; margin-bottom: var(--s3); }
.details summary::-webkit-details-marker { display: none; }
.segmented-links { display: flex; gap: 10px; }
.segmented-links .is-on { color: var(--ink); font-weight: 700; }
.btn--danger-link { color: var(--alert); }
.notice--toast { border-top: 1px solid var(--hair); }
.chart__label { font-family: var(--mono); font-size: 8px; fill: var(--ink-3); }
.macro-bar-wrap { margin: var(--s3) 0; }
textarea.input { min-height: 64px; resize: vertical; font-family: inherit; }
select.input { appearance: none; -webkit-appearance: none; background-image: none; }
button.data-row { width: 100%; border: 0; border-top: 1px solid var(--hair-soft); font: inherit; cursor: pointer; text-align: left; }
button.ing { width: 100%; border: 0; border-top: 1px solid var(--hair-soft); background: none; font: inherit; text-align: left; cursor: pointer; }
button.ing:hover { background: var(--surface-2); }
button.ing:disabled { cursor: default; color: var(--ink-2); }
.ing > span:first-child { text-align: left; }
.meal-card__name { display: block; color: inherit; text-decoration: none; }
a.week__day, a.segmented__item, a.tab-bar__item { text-decoration: none; color: inherit; }
a.segmented__item { display: flex; align-items: center; justify-content: center; }
a.week__day { display: block; }
.week__day.is-active a, a.week__day.is-active { color: var(--surface); }
body.has-sheet { overflow: hidden; }
.pretty { line-height: 1.5; font-size: 13px; }
.block h2.label { margin-top: var(--s4); }
.block h2.label:first-child { margin-top: 0; }
.admin-tools { display: flex; gap: var(--s2); flex-wrap: wrap; }
.admin-tools .input { flex: 1; min-width: 160px; }

/* 23. Correzioni mobile: overflow, zoom iOS, tocco --------------------- */
/* Niente zoom automatico su iPhone: i campi hanno sempre 16px; doppio tap non ingrandisce. */
html { touch-action: manipulation; }
a, button, input, select, textarea, label { touch-action: manipulation; }
.input, .input--num, select.input, textarea.input { font-size: 16px; }
.chip { font-size: 14px; }
.input { min-width: 0; max-width: 100%; border-radius: 0; }
.input:not([type="date"]):not([type="time"]):not([type="file"]) { -webkit-appearance: none; appearance: none; }
input[type="date"].input, input[type="time"].input { display: block; width: 100%; min-height: 44px; line-height: 1.2; text-align: left; }
input[type="file"].input { padding: 9px var(--s4); }
select.input {
  padding-right: 32px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2314150F' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
}
/* Le griglie a due colonne non devono mai allargarsi oltre lo schermo. */
.form-grid > * { min-width: 0; }
.form-group { min-width: 0; }
.form-group__label { letter-spacing: 0.08em; line-height: 1.3; overflow-wrap: anywhere; }
/* Statistiche a 4 colonne: numeri più piccoli su schermi stretti, mai sovrapposti. */
.stat { min-width: 0; padding: 10px var(--s3); }
.stat__value { overflow-wrap: anywhere; }
.stat-grid--4 .stat__value { font-size: 19px; letter-spacing: -0.03em; }
.stat-grid--4 .stat__value--sm { font-size: 15px; }
.stat__note { overflow-wrap: anywhere; }
@media (min-width: 420px) { .stat-grid--4 .stat__value { font-size: 22px; } }
/* Righe etichetta/valore: il valore va a capo se lungo, non copre l'etichetta. */
.data-row { flex-wrap: wrap; row-gap: 2px; }
.data-row > span:first-child { flex: 1 1 140px; min-width: 0; }
.data-row__value { text-align: right; overflow-wrap: anywhere; }
.calc__cell { min-width: 0; }
.calc__value { font-size: 15px; overflow-wrap: anywhere; }
.app-header { min-height: var(--header-h); }
.app-header > div:first-child { min-width: 0; }
.app-header__title { overflow-wrap: anywhere; line-height: 1.15; }
.app-header__meta { flex: 0 0 auto; }
.block__head { flex-wrap: wrap; gap: 4px 10px; }
.meal-card__top, .meal-card__foot { flex-wrap: wrap; gap: 4px 8px; }
.macro__row { gap: 8px; }
.macro__val { white-space: nowrap; }
.swap-option__top { flex-wrap: wrap; }
.swap-option__delta { overflow-wrap: anywhere; }
.shopping-item__name { min-width: 0; overflow-wrap: anywhere; }
.ing > span { min-width: 0; overflow-wrap: anywhere; }
.ing > span:first-child { padding-right: 4px; }
a.ing { color: inherit; text-decoration: none; display: grid; }
a.ing:hover, .ing.is-on { background: var(--surface-2); }
.food-row > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.sheet__foot a { margin-left: 6px; }
.btn { min-width: 0; text-align: center; line-height: 1.2; }
.btn-row { flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 120px; }
.btn-row > form { flex: 1 1 120px; display: flex; }
.btn-row > form > .btn { flex: 1; }
.chips { gap: var(--s2); }
.chip { max-width: 100%; overflow-wrap: anywhere; text-align: left; }
.week__day { min-width: 0; }
.notice { overflow-wrap: anywhere; }
.notice > div { min-width: 0; flex: 1; }
.wizard__section, .block, .auth { min-width: 0; overflow-x: clip; }
.block--flush > .sheet__sub { padding: 0 var(--s5) var(--s3); margin-top: 0; }

/* 24. Pannello: l'attributo hidden deve sempre vincere sul display del componente. */
[hidden] { display: none !important; }
.sheet__search { padding: var(--s3) var(--s5); border-bottom: 1px solid var(--hair); background: var(--surface); }
.sheet__search .input { min-height: 40px; padding: 8px var(--s4); }
.swap-search { display: flex; gap: var(--s2); padding: var(--s3) var(--s5); border-bottom: 1px solid var(--hair); }
.swap-search .input { flex: 1; min-height: 40px; padding: 8px var(--s4); }
.swap-search .btn { flex: 0 0 auto; }

/* 25. Titoli di sezione nei blocchi senza padding + aree sicure iPhone (notch, indicatore Home) */
.block--flush > .block__head, .shopping-group > .block__head { padding: var(--s4) var(--s5) var(--s2); margin-bottom: 0; }
.block--flush > .block__head + .data-row, .block--flush > .block__head + form > .data-row { border-top: 0; }
.app-header { padding-top: calc(var(--s4) + env(safe-area-inset-top, 0px)); padding-left: calc(var(--s5) + env(safe-area-inset-left, 0px)); padding-right: calc(var(--s5) + env(safe-area-inset-right, 0px)); }
.tab-bar { padding-bottom: env(safe-area-inset-bottom, 0px); }
.tab-bar__item { min-height: 56px; }
@media (display-mode: standalone) { .tab-bar { border-top-width: 1px; } .app-header { position: sticky; } }

/* 26. Modalità semplice: cosa mangio, quanto, quando. I numeri restano dietro "Mostra i numeri". */
body.is-simple .simple-hide { display: none !important; }
body.is-detailed .simple-only { display: none !important; }
body.is-simple .ing { grid-template-columns: minmax(0, 1fr) 96px; }
body.is-simple .ing > span:nth-child(2) { text-align: right; }
.meal-card__summary { margin-top: 4px; font-size: 12.5px; color: var(--ink-2); line-height: 1.4; }
.form-inline--head { margin: 0; }
.form-inline--head .btn--link { font-size: 12px; }
.push-block { margin-top: var(--s4); }
.push-block .btn { margin-bottom: var(--s2); }

/* 27. Rifinitura form: spaziature coerenti, select e campi numerici, righe "alimento di ogni giorno" */
.form-group { margin-bottom: 14px; }
.form-grid { gap: 12px; }
.form-grid .form-group { margin-bottom: 14px; }
.form-group__label { margin-bottom: 6px; }
.input { padding: 10px 12px; line-height: 1.3; }
select.input { padding: 10px 34px 10px 12px; line-height: 1.3; }
.input--num { text-align: left; }
.check-row { margin: 10px 0 14px; align-items: flex-start; }
.check-row input { margin-top: 2px; }
.chips { margin-bottom: 4px; }
.chip { min-height: 36px; padding: 8px 12px; }
.block form + form { margin-top: 12px; }
.block .btn--block + .btn--block, .block form + .btn-row { margin-top: 10px; }
.wizard__section > .form-group:last-child, .block > form > .form-group:last-of-type { margin-bottom: 12px; }
.btn--block { margin-top: 4px; }
.data-row form, form.data-row { align-items: center; }
.swap-search { padding: 0; border: 0; margin-top: 10px; }
.addon-row { display: flex; flex-direction: column; gap: 8px; padding: var(--s3) var(--s5); border-top: 1px solid var(--hair-soft); }
.addon-row__name { font-size: 13px; }
.addon-row__ctl { display: grid; grid-template-columns: 76px auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.addon-row__ctl .input { min-height: 40px; padding: 8px 10px; }
.addon-row__ctl select.input { padding-right: 30px; }

/* 28. Avvertenza consigli alimentari + pasto libero */
.disclaimer { padding: var(--s4) var(--s5) var(--s5); font-size: 10.5px; line-height: 1.45; color: var(--ink-3); }
.addon-row__ctl--2 { grid-template-columns: 90px auto auto; justify-content: start; }
