/* AI Trainer: stile unico («direzione B» estesa a tutta l'app, docs/design/alimentazione/SPEC.md).
   Mobile-first, una mano in palestra, tema chiaro e scuro. Tema scelto con :root[data-theme] oppure dal sistema. */
:root {
  --radius: 14px; --radius-s: 10px; --radius-l: 24px; --tap: 48px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: .75rem; --fs-s: .8125rem; --fs-m: .9375rem; --fs-b: 1rem; --fs-l: 1.125rem;
  --fs-xl: 1.375rem; --fs-2xl: 1.75rem; --fs-3xl: 2.375rem; --fs-4xl: 3.5rem;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --bg: #f6f5f2; --surface: #ffffff; --surface-2: #eeece8; --surface-3: #e6e2dc; --track: #e7e4de;
  --line: #e4e1db; --line-strong: #cdc8bf; --ink: #16140f; --muted: #615b52;
  --accent: #cc4510; --accent-ink: #ffffff; --accent-soft: #fde8dc; --accent-text: #b83c0a;
  --over: #d9961c; --warn: #8a5300; --warn-soft: #fbefd6;
  --danger: #b4123a; --danger-soft: #f9e1e6; --danger-ink: #ffffff;
  --toast-action: #ffa66f; --scrim: rgba(22, 20, 15, .42);
  --shadow: 0 1px 2px rgba(22, 20, 15, .06), 0 12px 32px rgba(22, 20, 15, .10);
  --shadow-sheet: 0 -8px 40px rgba(22, 20, 15, .16);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1a17; --surface: #26231f; --surface-2: #312d28; --surface-3: #3d3832; --track: #38332d;
    --line: #3a352f; --line-strong: #4f4840; --ink: #f5f2ed; --muted: #b3aba0;
    --accent: #ff7a33; --accent-ink: #1d0c02; --accent-soft: #47270f; --accent-text: #ff9457;
    --over: #f0ad3e; --warn: #f2b95b; --warn-soft: #3d2f16;
    --danger: #ff7f97; --danger-soft: #45202a; --danger-ink: #2a0710;
    --toast-action: #b83c0a; --scrim: rgba(0, 0, 0, .55);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px rgba(0, 0, 0, .45);
    --shadow-sheet: 0 -8px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1a17; --surface: #26231f; --surface-2: #312d28; --surface-3: #3d3832; --track: #38332d;
  --line: #3a352f; --line-strong: #4f4840; --ink: #f5f2ed; --muted: #b3aba0;
  --accent: #ff7a33; --accent-ink: #1d0c02; --accent-soft: #47270f; --accent-text: #ff9457;
  --over: #f0ad3e; --warn: #f2b95b; --warn-soft: #3d2f16;
  --danger: #ff7f97; --danger-soft: #45202a; --danger-ink: #2a0710;
  --toast-action: #b83c0a; --scrim: rgba(0, 0, 0, .55);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px rgba(0, 0, 0, .45);
  --shadow-sheet: 0 -8px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
  container: app / inline-size; /* le regole a due colonne (PC) guardano la larghezza dell'app, non della finestra */
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--fs-2xl); line-height: 1.15; letter-spacing: -.025em; font-weight: 780; }
h2 { font-size: var(--fs-l); letter-spacing: -.01em; font-weight: 700; line-height: 1.3; }
h3 { font-size: var(--fs-b); font-weight: 650; }
a { color: var(--accent-text); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; opacity: 0; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.ic { display: block; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-pieno { fill: currentColor; }
/* Scala dei caratteri: i numeri sono l'elemento di carattere (tabellari, pesanti, stretti) */
.t-num-xl { font-size: var(--fs-4xl); font-weight: 800; letter-spacing: -.045em; line-height: 1; font-variant-numeric: tabular-nums; }
.t-num-l { font-size: var(--fs-3xl); font-weight: 800; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.t-num-m { font-size: var(--fs-2xl); font-weight: 780; letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.t-titolo { font-size: var(--fs-2xl); font-weight: 780; letter-spacing: -.025em; line-height: 1.15; }
.t-titolo-s { font-size: var(--fs-xl); font-weight: 750; letter-spacing: -.02em; line-height: 1.2; }
.t-sez { font-size: var(--fs-l); font-weight: 700; letter-spacing: -.01em; line-height: 1.3; }
.t-sub { font-size: var(--fs-m); color: var(--muted); }
.t-et { font-size: var(--fs-xs); font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 12px; }
.stack-s { display: grid; gap: 6px; }
/* Le griglie a una colonna non si allargano oltre lo schermo per un contenuto largo (select, righe lunghe). */
.view, .stack, .stack-s, .sec, .panel, .field { grid-template-columns: minmax(0, 1fr); }
.right { margin-left: auto; }
.center { text-align: center; }

/* ---------- Guscio ---------- */
#app { min-height: 100dvh; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top) + 8px) 8px 4px 16px; min-height: 60px; background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.top h1 { font-size: var(--fs-xl); font-weight: 750; letter-spacing: -.02em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 4px 16px calc(96px + env(safe-area-inset-bottom)); display: grid; gap: 28px; align-content: start; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
.tab {
  display: grid; justify-items: center; align-content: center; gap: 3px; padding: 4px 0; min-height: 56px; border: 0; background: none;
  color: var(--muted); font-size: .65625rem; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; text-decoration: none; border-radius: 12px;
}
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"] svg { color: var(--accent); }
.side-brand { display: none; }
/* PC: barra laterale larga con le scritte (icona e scritta affiancate, voci una sotto l'altra) e colonna centrale. */
@container app (min-width: 900px) {
  .tabbar { top: 0; bottom: 0; right: auto; width: 232px; grid-template-columns: 1fr; align-content: start; gap: 2px; border-top: 0; border-right: 1px solid var(--line); padding: 20px 12px; }
  .side-brand { display: block; padding: 4px 12px 20px; font-size: 1.0625rem; font-weight: 800; letter-spacing: -.02em; }
  .tab { grid-auto-flow: column; justify-content: start; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; font-size: var(--fs-m); letter-spacing: 0; }
  .tab[aria-current="page"] { background: var(--surface-2); }
  #app.has-tabs { padding-left: 232px; }
  .top { width: 100%; max-width: 760px; margin: 0 auto; }
  .view { padding-bottom: 40px; }
  .timer { left: 232px; }
  #toasts { left: 232px; bottom: 24px; }
  body:has(.timer) #toasts { bottom: 96px; }
  /* Ingresso: colonna centrata di al massimo 560 px, sfondo a tutta pagina, contenuto centrato anche in verticale (soluzione provvisoria, vedi docs/decisioni.md). */
  .ingresso { align-items: center; }
  .in-blocco { flex: none; width: 100%; max-width: 560px; min-height: 0; }
  .in-allenamento { margin-top: auto; }
  .in-alimentazione { margin-top: 12px; margin-bottom: auto; border-radius: 28px; padding-bottom: 24px; }
}

/* ---------- Sezioni e righe ---------- */
.sec { display: grid; gap: 10px; }
.sec-title { font-size: var(--fs-xs); font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
/* Niente card ovunque: pannello a filo e liste a righe sottili (stesse classi di prima, aspetto nuovo). */
.panel { background: var(--surface); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.list { border-top: 1px solid var(--line); }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 6px 0; border: 0; background: none; text-align: left;
  border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; cursor: pointer;
}
.item:active { background: var(--surface-2); }
div.item { cursor: default; }
.item-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.item-title { font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { color: var(--muted); font-size: var(--fs-s); }
.item-val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chev { color: var(--muted); }
.empty { text-align: center; padding: 26px 16px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); display: grid; gap: 12px; justify-items: center; }
.hero { display: grid; gap: 4px; }
.hero .kicker { font-size: var(--fs-xs); font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.big { font-size: var(--fs-3xl); font-weight: 800; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 600px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 0; color: inherit; font: inherit; border-radius: var(--radius-s); padding: 10px 12px; display: grid; gap: 2px; }
.stat b { font-size: var(--fs-xl); font-weight: 780; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.stat span { font-size: .75rem; color: var(--muted); }
.note { background: var(--accent-soft); border-radius: var(--radius-s); padding: 10px 12px; font-size: .9rem; }
.note-warn { background: var(--warn-soft); color: var(--ink); }
.note-danger { background: var(--danger-soft); }

/* ---------- Pulsanti ---------- */
/* Pulsanti: principale pieno arancione, secondario a filo (il bordo è un'ombra interna, non occupa spazio). */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 8px 20px;
  border: 0; border-radius: 999px; background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-strong); color: var(--ink);
  font-weight: 650; font-size: var(--fs-b); line-height: 1.2; white-space: normal; cursor: pointer; text-decoration: none; text-align: center;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.btn-danger { background: var(--danger-soft); color: var(--danger); box-shadow: none; }
.btn-ghost { box-shadow: none; background: none; color: var(--accent-text); padding: 0 12px; }
.btn-block { width: 100%; }
.btn-s { font-size: var(--fs-m); padding: 6px 16px; }
.btn-xl { min-height: 56px; font-size: var(--fs-l); font-weight: 750; }
.btn small { font-weight: 500; color: var(--muted); }
.icon-btn { display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); padding: 0; border: 0; border-radius: 50%; background: none; color: var(--ink); cursor: pointer; flex: none; }
.icon-btn:active { background: var(--surface-2); }
.icon-btn[disabled] { opacity: .35; cursor: default; }
.icon-btn[aria-pressed="true"] { color: var(--accent); }
#entry-fav[aria-pressed="true"] svg { fill: currentColor; }
.icon-btn.sm { width: 36px; height: 36px; color: var(--muted); }
.icon-btn.danger { color: var(--danger); }
.link { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0; border: 0; background: none; color: var(--accent-text); font-weight: 650; font-size: var(--fs-m); text-decoration: none; cursor: pointer; white-space: nowrap; }
/* «+» rotondo: tenue sulle righe, pieno sulla testa del pasto, spunta quando aggiunto */
.piu { display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); padding: 0; border: 0; border-radius: 50%; flex: none; cursor: pointer; background: var(--accent-soft); color: var(--accent-text); transition: transform .08s ease, background .15s ease; }
.piu .ic { width: 22px; height: 22px; stroke-width: 2.6; }
.piu:active { transform: scale(.92); }
.piu-pieno, .piu.fatto { background: var(--accent); color: var(--accent-ink); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); font-size: .75rem; font-weight: 650; white-space: nowrap; }
.chip-accent { background: var(--accent-soft); color: var(--accent-text); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg button { border: 0; background: none; min-height: 38px; padding: 0 14px; border-radius: 999px; font-weight: 650; font-size: .88rem; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
/* Filtri a pillola (la zona di tocco è alta 48 px, la pillola meno) */
.filtri { display: flex; gap: 4px; }
.filtro { min-height: var(--tap); padding: 0; border: 0; background: none; cursor: pointer; display: inline-grid; align-items: center; }
.filtro span { display: block; padding: 7px 12px; border-radius: 999px; background: var(--surface-2); font-size: var(--fs-s); font-weight: 650; color: var(--ink); white-space: nowrap; }
.filtro[aria-pressed="true"] span { background: var(--ink); color: var(--bg); }

/* ---------- Campi ---------- */
.field { display: grid; gap: 5px; }
.field label, .lbl { font-size: var(--fs-s); font-weight: 650; color: var(--muted); }
.hint { font-size: var(--fs-s); color: var(--muted); }
input[type="text"], input[type="password"], input[type="date"], input[type="number"], input[type="url"], input[type="search"], select, textarea {
  width: 100%; min-height: 52px; padding: 10px 14px; border: 0; border-radius: 12px; background: var(--surface-2); color: var(--ink);
  font-size: 17px; /* evita lo zoom di iOS */
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { min-height: 96px; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
input.num { text-align: center; font-variant-numeric: tabular-nums; font-weight: 650; padding: 10px 4px; }
.check { display: flex; gap: 10px; align-items: flex-start; min-height: var(--tap); padding: 8px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.err { color: var(--danger); font-size: .9rem; font-weight: 600; min-height: 1.3em; }
pre.preview { margin: 0; white-space: pre-wrap; word-break: break-word; font: .82rem/1.45 ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); border-radius: var(--radius-s); padding: 12px; max-height: 46vh; overflow: auto; }
.answer { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }

/* ---------- Finestre e avvisi ---------- */
dialog.dlg {
  border: 0; border-radius: var(--radius-l) var(--radius-l) 0 0; background: var(--surface); color: var(--ink); padding: 0; width: 100%; max-width: 560px;
  margin: auto auto 0; max-height: 92dvh; box-shadow: var(--shadow-sheet);
}
dialog.dlg[open] { display: flex; flex-direction: column; }
dialog.dlg::backdrop { background: var(--scrim); }
@media (min-width: 620px) { dialog.dlg { margin: auto; border-radius: var(--radius-l); box-shadow: var(--shadow); } dialog.dlg-wide { max-width: 720px; } }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 14px 10px 6px 18px; }
.dlg-head h2 { flex: 1; font-size: var(--fs-xl); font-weight: 750; letter-spacing: -.02em; }
.dlg-body { padding: 8px 18px 16px; overflow: auto; display: grid; gap: 14px; align-content: start; }
.dlg-foot { display: flex; gap: 10px; padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.dlg-foot .btn { flex: 1; }
#toasts { position: fixed; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 50; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
/* Con il timer di recupero in vista, l'avviso sta sopra il timer e non lo copre. */
body:has(.timer) #toasts { bottom: calc(150px + env(safe-area-inset-bottom)); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: var(--ink); color: var(--bg); padding: 2px 16px; min-height: 52px; border-radius: var(--radius); font-weight: 600; font-size: var(--fs-m); box-shadow: var(--shadow); max-width: 100%; animation: rise .18s ease; }
.toast-err { background: var(--danger); color: var(--danger-ink); }
.toast-action { min-height: var(--tap); padding: 0 6px; border: 0; background: none; color: var(--toast-action); font-weight: 800; cursor: pointer; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Blocco ---------- */
.lock { min-height: 100dvh; display: grid; align-content: center; gap: 20px; max-width: 460px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 28px) 22px calc(env(safe-area-inset-bottom) + 28px); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.bullets { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.bullets li { padding-left: 18px; position: relative; color: var(--muted); }
.bullets li::before { content: ""; position: absolute; left: 0; top: .6em; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.code { font: 700 1.15rem/1.6 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; text-align: center; padding: 16px 10px; background: var(--surface-2); border-radius: var(--radius); word-break: break-word; user-select: all; -webkit-user-select: all; }

/* ---------- Allenamento ---------- */
.ex { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.ex-head { display: flex; align-items: center; gap: 8px; padding: 12px 8px 8px 14px; }
.ex-head h3 { flex: 1; min-width: 0; font-size: 1.02rem; }
.ex-meta { padding: 0 14px 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.ex-body { padding: 4px 10px 12px; display: grid; gap: 6px; }
.set { display: grid; grid-template-columns: 34px 1fr 1fr 58px 46px; gap: 6px; align-items: center; }
.set.no-rir { grid-template-columns: 34px 1fr 1fr 46px; }
.set-ed { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr 36px; gap: 6px; align-items: center; }
.set-list { display: grid; gap: 6px; }
.set-sum { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 4px 10px 4px 8px; border: 0; border-radius: var(--radius-m, 12px); background: var(--surface-2); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.set-sum:active { filter: brightness(.96); }
.set-sum .set-reps { font-size: var(--fs-l); font-variant-numeric: tabular-nums; flex: 1; min-width: 0; }
.set-sum .chip { background: var(--surface); }
.set-sum .chip-accent { background: var(--accent-soft); }
.set-go { color: var(--muted); display: inline-grid; flex: none; }
.seg-days button { display: grid; justify-items: center; align-content: center; gap: 0; min-width: 52px; padding: 2px 10px; line-height: 1.15; }
.seg-days button b { font-size: 1rem; font-weight: 750; }
.seg-days button small { font-size: .66rem; font-weight: 600; max-width: 84px; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.seg-days button#add-day { min-width: 44px; font-size: 1.2rem; }
.save-bar { display: flex; align-items: center; gap: 12px; padding: 12px 0 4px; border-top: 1px solid var(--line); }
.save-state { flex: 1; font-size: var(--fs-s); color: var(--muted); font-variant-numeric: tabular-nums; }
.save-state.save-err { color: var(--danger); font-weight: 650; }
.save-bar .btn { min-width: 120px; }
.set-head { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: center; }
.set-n { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 750; font-size: .8rem; background: var(--surface-2); color: var(--muted); border: 0; }
.set-n[data-type="warmup"] { background: var(--warn-soft); color: var(--warn); }
.set-n[data-type="failure"], .set-n[data-type="drop"], .set-n[data-type="myo"], .set-n[data-type="partial"] { background: var(--danger-soft); color: var(--danger); }
.set.done input { background: var(--accent-soft); border-color: transparent; }
.set-done { width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--muted); cursor: pointer; }
.set.done .set-done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.set-hint { grid-column: 2 / -1; font-size: .78rem; color: var(--muted); margin: -2px 0 4px; }
.timer {
  position: fixed; left: 12px; right: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 7; max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; background: var(--ink); color: var(--bg); border-radius: 18px; padding: 10px 10px 10px 18px; box-shadow: var(--shadow);
}
.timer b { font-size: 1.6rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; min-width: 68px; }
.timer .btn { background: transparent; color: inherit; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--bg) 35%, transparent); min-height: 40px; padding: 0 12px; }
.timer.over { background: var(--accent); color: var(--accent-ink); }
.rule { display: grid; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rule:last-child { border-bottom: 0; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-h { font-size: .68rem; text-align: center; color: var(--muted); font-weight: 700; }
.cal-d { aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center; font-size: .8rem; font-variant-numeric: tabular-nums; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.cal-d.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 750; }
.cal-d.act { background: var(--accent-soft); border-color: transparent; color: var(--ink); font-weight: 650; }
.cal-d.out { visibility: hidden; }
.cal-d.now { outline: 2px solid var(--ink); outline-offset: 1px; }

/* ---------- Alimentazione, progressi ---------- */
.bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.over i { background: var(--over); }
.chart { width: 100%; height: auto; display: block; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--accent); }
.chart-txt { font-size: 9px; fill: var(--muted); font-family: var(--font); }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo { position: relative; aspect-ratio: 3 / 4; border-radius: var(--radius-s); overflow: hidden; background: var(--surface-2); border: 0; padding: 0; cursor: pointer; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo span { position: absolute; left: 6px; bottom: 6px; background: rgba(0, 0, 0, .6); color: #fff; font-size: .68rem; font-weight: 650; padding: 2px 7px; border-radius: 99px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.compare img { width: 100%; border-radius: var(--radius-s); display: block; }
.bubble { padding: 10px 13px; border-radius: 16px; max-width: 92%; white-space: pre-wrap; word-break: break-word; }
.bubble.me { background: var(--accent); color: var(--accent-ink); justify-self: end; border-bottom-right-radius: 5px; }
.bubble.ai { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.tbl th, table.tbl td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.tbl th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* ---------- Scelte a schede, primo avvio, configurazione AI ---------- */
.choices { display: grid; gap: 8px; }
.choice {
  display: grid; gap: 2px; width: 100%; text-align: left; padding: 12px 14px; min-height: var(--tap); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); color: var(--ink); transition: border-color .12s ease, background .12s ease;
}
.choice-title { font-weight: 680; }
.choice-sub { font-size: .84rem; color: var(--muted); }
.choice[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.seg-fill { display: flex; width: 100%; }
.seg-fill button { flex: 1; padding: 0 8px; }
.steps-head { display: grid; gap: 8px; }
.steps-head .kicker { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.steps-head .bar { height: 4px; }
.step-title { font-size: 1.45rem; letter-spacing: -.02em; }
.onboarding { gap: 18px; }
.view-bare { padding-bottom: 0; }
.ob-nav { position: sticky; bottom: 0; z-index: 5; margin: 0 -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); box-shadow: 0 -1px 0 var(--line); }
.ob-nav .err:empty { display: none; }
.lock-cta { position: sticky; bottom: 0; z-index: 5; display: grid; gap: 6px; padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); background: var(--bg); }
.lock-cta .err:empty { display: none; }
.item-tight { min-height: 44px; padding: 8px 0; }
.item-sub-ink { font-size: .92rem; }
.panel-accent { background: var(--accent-soft); border-color: transparent; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; }
.dot-on { background: var(--accent); }
a.list { display: block; text-decoration: none; color: inherit; }
.steps-list { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.steps-list li::marker { font-weight: 750; color: var(--accent-text); }
details.adv { border-top: 1px solid var(--line); padding-top: 10px; }
details.adv summary { cursor: pointer; font-weight: 650; color: var(--muted); min-height: 32px; }
details.adv[open] summary { margin-bottom: 8px; }

/* ---------- Stampa (report PDF) ---------- */
[hidden] { display: none !important; }
a.note { color: inherit; text-decoration: none; }
.btn > .grow { text-align: left; }

/* Assistente AI */
.preview { max-height: 42vh; overflow: auto; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font: inherit; font-size: .82rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg { max-width: 92%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.msg .answer { margin: 0; }
.msg-user { align-self: flex-end; background: var(--surface-2, var(--bg)); }
.msg-ai { align-self: flex-start; }
.msg-who { display: block; margin-bottom: 2px; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
button.item { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; font: inherit; color: inherit; cursor: pointer; }

/* Alimentazione */
.flip svg { transform: scaleX(-1); }
.plan-meal { display: grid; gap: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
ul.plain { margin: 0; padding-left: 18px; font-size: .9rem; color: var(--muted); }
.stat .bar { margin-top: 4px; height: 5px; }

/* Progressi */
.big-num { font-size: 1.9rem; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.photo-empty { cursor: default; border: 1px dashed var(--line); background: none; }
.photo-empty span { background: none; color: var(--muted); }
.photo-full img { width: 100%; max-height: 62vh; object-fit: contain; border-radius: var(--radius-s); display: block; background: var(--surface-2); }
.compare figure { margin: 0; display: grid; gap: 4px; }
.compare figcaption { font-size: .78rem; color: var(--muted); text-align: center; }
.compare img { aspect-ratio: 3 / 4; object-fit: cover; background: var(--surface-2); }
.report-title { font-size: 1.35rem; letter-spacing: -.02em; }
.report table.tbl td:not(:first-child), .report table.tbl th:not(:first-child) { text-align: right; }
.report table.tbl td:first-child { overflow-wrap: anywhere; }
@media (max-width: 380px) {
  .report table.tbl { font-size: .8rem; }
  .report table.tbl th, .report table.tbl td { padding: 6px 4px; }
  .report table.tbl th { font-size: .62rem; letter-spacing: 0; }
}

@media print {
  .report-photos { break-inside: avoid; }
  .report .compare { max-width: 120mm; }
  :root { --bg: #fff; --surface: #fff; --surface-2: #f2f2f2; --track: #e4e4e4; --ink: #000; --muted: #444; --line: #ccc; --accent: #c2410c; --accent-ink: #fff; --accent-soft: #fbe5d8; --accent-text: #c2410c; }
  .top, .tabbar, #toasts, .no-print, .timer { display: none !important; }
  #app.has-tabs { padding-left: 0; }
  .view { max-width: none; padding: 0; }
  .panel, .list, .stat { break-inside: avoid; }
  body { font-size: 11pt; }
}

/* Elenco esercizi con ricerca (scheda su misura). */
.pick-list { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overscroll-behavior: contain; }
.pick-group { position: sticky; top: 0; z-index: 1; padding: 8px 12px; background: var(--surface-2); font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pick { display: flex; align-items: center; width: 100%; min-height: 44px; padding: 8px 12px; border: 0; border-top: 1px solid var(--line); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.pick-group + .pick { border-top: 0; }
.pick::after { content: ''; margin-left: auto; flex: none; width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--muted); }
.pick[aria-checked="true"] { background: var(--accent-soft); }
.pick[aria-checked="true"]::after { border-color: var(--accent); background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/14px no-repeat; }
.pick:hover { background: var(--surface-2); }
.pick-empty { padding: 12px; }
.chip-btn { min-height: 36px; padding: 6px 12px; border: 0; font: inherit; font-size: .8rem; font-weight: 650; cursor: pointer; }
.chip-tag { margin-left: 8px; padding: 1px 7px; font-size: .68rem; vertical-align: 1px; }
.choices-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.choices-grid .choice { min-height: 44px; padding-block: 8px; }
.tags { gap: 4px; margin-top: 4px; }
.tags .chip-tag { margin-left: 0; }

/* ---------- Ingresso: scelta tra Allenamento e Alimentazione ---------- */
.ingresso {
  --in-top: var(--surface); --in-sheet: var(--surface-2); --in-track-sheet: var(--surface); --in-cell: var(--surface);
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
  background: var(--in-top); color: var(--ink); animation: in-fade .18s ease;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ingresso { --in-top: var(--bg); --in-sheet: var(--surface); --in-track-sheet: var(--line); --in-cell: var(--surface-2); }
}
:root[data-theme="dark"] .ingresso { --in-top: var(--bg); --in-sheet: var(--surface); --in-track-sheet: var(--line); --in-cell: var(--surface-2); }
@keyframes in-fade { from { opacity: 0; } }

.in-blocco { flex: var(--peso, 1) 1 0px; min-height: min-content; display: flex; flex-direction: column; gap: 14px; padding: 0 20px 24px; }
.in-allenamento { padding-top: calc(env(safe-area-inset-top) + 12px); background: var(--in-top); }
.in-alimentazione { padding: 22px 20px calc(env(safe-area-inset-bottom) + 24px); background: var(--in-sheet); border-radius: 28px 28px 0 0; }
.in-corpo { flex: 1; display: flex; flex-direction: column; gap: 16px; }

.in-barra-alta { display: flex; align-items: center; gap: 10px; min-height: var(--tap); }
.in-barra-alta .brand-mark { width: 32px; height: 32px; border-radius: 9px; flex: none; }
.in-data { flex: 1; min-width: 0; font-size: .94rem; font-weight: 650; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.in-link { display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); padding: 0 2px; border: 0; background: none; color: var(--accent-text); font-size: .94rem; font-weight: 650; text-decoration: none; white-space: nowrap; cursor: pointer; }
.in-link-ink { color: var(--ink); }
.in-testa { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 24px; }
.in-testa .in-link { margin: -12px 0; }
.in-testa h2 { font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.in-riga { display: flex; align-items: center; gap: 16px; }
.in-testo { flex: 1; min-width: 0; display: grid; gap: 4px; }
.in-titolo { font-size: 2.25rem; line-height: 1.05; font-weight: 780; letter-spacing: -.03em; }
.in-titolo-m { font-size: 1.75rem; line-height: 1.12; font-weight: 780; letter-spacing: -.025em; }
.in-titolo-s { font-size: 1.25rem; line-height: 1.2; font-weight: 750; letter-spacing: -.02em; }
.in-sub { font-size: .94rem; color: var(--muted); }
.in-stato { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: .88rem; font-weight: 700; color: var(--accent-text); }
.in-stato::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }

.in-anello { position: relative; flex: none; }
.in-anello svg { display: block; transform: rotate(-90deg); }
.in-anello-txt { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1.1; }
.in-anello-txt b { font-variant-numeric: tabular-nums; }
.in-anello-txt span { font-size: .7rem; color: var(--muted); }

.in-settimana { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.in-giorno { height: 40px; border-radius: 9px; display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.in-giorno.fatto { background: var(--accent-text); border-color: var(--accent-text); color: var(--accent-ink); }
.in-giorno.oggi { background: var(--in-top); color: var(--ink); border: 2px solid var(--ink); }

.in-cta { margin-top: auto; font-size: 1.15rem; font-weight: 750; }
.in-cta-2 { margin-top: auto; background: var(--in-cell); }
.in-progresso { display: grid; gap: 8px; }
.in-progresso-riga { display: flex; justify-content: space-between; font-size: .88rem; color: var(--muted); }
.in-progresso-riga b { color: var(--ink); }

.in-spunta { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-text); }

.in-kcal { display: flex; align-items: center; gap: 18px; }
.in-kcal .in-anello-txt b { font-size: 1.6rem; font-weight: 780; letter-spacing: -.02em; }
.in-macro { flex: 1; min-width: 0; display: grid; gap: 10px; }
.in-macro-riga { display: flex; align-items: center; gap: 10px; }
.in-macro-riga svg { flex: none; display: block; transform: rotate(-90deg); }
.in-macro-txt { min-width: 0; line-height: 1.25; }
.in-macro-txt small { display: block; font-size: .75rem; color: var(--muted); }
.in-macro-txt b { font-size: .94rem; font-variant-numeric: tabular-nums; }
.in-macro-txt b span { font-weight: 500; color: var(--muted); }

.in-pasti { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--in-cell); border-radius: var(--radius); overflow: hidden; }
.in-pasto { min-height: 58px; padding: 6px 2px; border: 0; border-left: 1px solid var(--in-sheet); background: var(--in-cell); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer; }
.in-pasto:first-child { border-left: 0; }
.in-pasto small { font-size: .75rem; color: var(--muted); }
.in-pasto b { font-size: .94rem; font-variant-numeric: tabular-nums; }
.in-agg { display: inline-flex; align-items: center; gap: 2px; font-size: .8rem; font-weight: 700; color: var(--accent-text); }

.in-lista { display: grid; border-top: 1px solid var(--line); }
.in-lista-riga { display: flex; align-items: center; gap: 12px; min-height: var(--tap); border-bottom: 1px solid var(--line); }
.in-lista-riga span { flex: 1; font-weight: 620; }
.in-lista-riga b { font-variant-numeric: tabular-nums; }

.in-extra { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; font-size: .8rem; color: var(--muted); }
.in-extra b { color: var(--ink); font-variant-numeric: tabular-nums; }
.in-extra > span { display: inline-flex; align-items: center; gap: 6px; }
.in-seg { display: inline-flex; gap: 3px; }
.in-seg i { width: 10px; height: 4px; border-radius: 2px; background: var(--in-track-sheet); }
.in-seg i.on { background: var(--accent); }

/* Ingresso: adattamenti a schermi stretti (non sono nel riferimento).
   «Alimentazione» è più lunga di «Cibo»: sotto i 380 px si riduce solo il carattere dell'etichetta, i tab restano alti uguale.
   «+ Aggiungi» nei pasti vuoti a 320 px non deve venire tagliato. */
@media (max-width: 380px) {
  .tab { font-size: .62rem; padding-inline: 0; letter-spacing: -.03em; }
  .btn { white-space: normal; padding-block: 8px; }
  .in-agg { font-size: .7rem; }
  .in-agg svg { width: 12px; height: 12px; }
}
/* A 320 px «Alimentazione» in cinque colonne è stretta: carattere ancora più piccolo, mai tagliato. */
@media (max-width: 340px) {
  .tab { font-size: .56rem; }
}

/* Aggiungere un alimento: ricerca unica a gruppi. */
.food-results { display: grid; gap: 14px; }

/* ---------- Alimentazione (blocco 12): righe, anello, barre, settimana, foglio, avvisi, campi, vista del giorno ---------- */
/* Riga di lista: niente card, solo linee sottili */
.lista { display: grid; border-top: 1px solid var(--line); }
.riga {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 6px 0;
  border: 0; border-bottom: 1px solid var(--line); background: var(--bg); color: inherit; font: inherit; text-align: left; position: relative;
}
.foglio .riga, .dia-lato .riga { background: transparent; }
button.riga { cursor: pointer; }
.riga-main, .riga-tocco { flex: 1; min-width: 0; display: grid; gap: 1px; }
.riga-tocco { min-height: var(--tap); padding: 6px 0; border: 0; background: none; text-align: left; cursor: pointer; align-content: center; }
.riga-nome { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 620; }
.riga-nome > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.riga-nome .ic { width: 14px; height: 14px; color: var(--accent); }
.riga-sub { font-size: var(--fs-s); color: var(--muted); font-variant-numeric: tabular-nums; }
.fonte { font-size: var(--fs-xs); font-weight: 650; letter-spacing: .02em; }
.riga-kcal { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.riga-kcal small { font-size: var(--fs-s); font-weight: 500; color: var(--muted); }
.riga.risultato { padding-block: 2px; }
.riga mark { background: none; color: inherit; font-weight: 800; }
.riga.aggiunta { width: auto; margin-inline: -16px; padding-inline: 16px; background: var(--accent-soft); border-bottom-color: transparent; }
.riga.attiva { width: auto; margin-inline: -12px; padding-inline: 12px; border-radius: 12px; background: var(--surface-2); border-bottom-color: transparent; box-shadow: inset 0 0 0 2px var(--accent); }
/* Scorrimento a sinistra: la riga scorre di 96 px e scopre «Elimina» */
.scorre { position: relative; overflow: hidden; margin-inline: -16px; }
.scorre .riga { padding-inline: 16px; transform: translateX(-96px); transition: transform .2s ease; }
.scorre-elimina { position: absolute; top: 0; right: 0; bottom: 1px; width: 96px; border: 0; background: var(--danger); color: var(--danger-ink); font-weight: 700; font-size: var(--fs-s); display: grid; place-content: center; justify-items: center; gap: 2px; cursor: pointer; }

/* Anello */
.anello { position: relative; display: inline-grid; place-items: center; flex: none; }
.anello svg { display: block; transform: rotate(-90deg); }
.anello-traccia { fill: none; stroke: var(--track); }
.anello-arco { fill: none; stroke: var(--accent); stroke-linecap: round; transition: stroke-dasharray .4s ease; }
.anello-l .anello-traccia, .anello-l .anello-arco { stroke-width: 12px; }
.anello-txt { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; line-height: 1; }
.anello-num { font-size: var(--fs-3xl); font-weight: 800; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.anello-et { margin-top: 6px; font-size: var(--fs-xs); font-weight: 650; color: var(--muted); }
.anello.oltre .anello-arco { stroke: var(--over); }
.anello.oltre .anello-num { color: var(--warn); }

/* Barra di avanzamento: semplice, oltre, doppia (già nel giorno + questa voce) */
.barra { display: flex; height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.barra > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.barra.oltre > i { background: var(--over); }
.barra-doppia > i { border-radius: 0; }
.barra-doppia > i.gia { background: var(--muted); opacity: .45; }
.barra-doppia > i:last-child { border-radius: 0 99px 99px 0; }
.macro { display: grid; gap: 6px; }
.macro-testa { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: var(--fs-s); }
.macro-nome { color: var(--muted); font-weight: 600; }
.macro-val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.macro-val b { color: var(--ink); font-size: var(--fs-b); font-weight: 750; }
.macro-val b.oltre { color: var(--warn); }
.macro-val b.piu-val { color: var(--accent-text); }

/* Striscia della settimana */
.sett { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.sett-g { display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 62px; padding: 4px 0; border: 0; border-radius: 14px; background: none; color: var(--ink); cursor: pointer; }
.sett-g small { font-size: var(--fs-xs); font-weight: 650; color: var(--muted); }
.sett-g b { font-size: var(--fs-b); font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.1; }
.sett-g i { width: 5px; height: 5px; border-radius: 50%; }
.sett-g.con-voci i { background: var(--accent); }
.sett-g[aria-current="date"] { background: var(--ink); color: var(--bg); }
.sett-g[aria-current="date"] small { color: inherit; }
.sett-g[disabled] { opacity: .38; cursor: default; }

/* Avviso con «Annulla» */
.avvisi { position: fixed; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 50; display: grid; justify-items: center; pointer-events: none; }
.avvisi.nel-foglio { bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 33; }

/* Campi */
.campo { display: grid; gap: 6px; }
.campo > span:first-child, .campo-et { font-size: var(--fs-s); font-weight: 650; color: var(--muted); }
.campo em, .campo-et em { font-style: normal; font-weight: 500; }
.input { width: 100%; min-height: 52px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--surface-2); color: var(--ink); font-size: 17px; outline: none; }
.input::placeholder { color: var(--muted); }
.input:focus, .input.a-fuoco { box-shadow: inset 0 0 0 2px var(--accent); }
.unita { position: relative; display: flex; align-items: center; }
.unita .input { padding-right: 52px; font-weight: 650; font-variant-numeric: tabular-nums; }
.unita > span { position: absolute; right: 14px; font-size: var(--fs-m); font-weight: 600; color: var(--muted); pointer-events: none; }
.input-xl { min-height: 64px; font-size: var(--fs-2xl); font-weight: 780 !important; letter-spacing: -.02em; }
.griglia-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.griglia-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cerca { position: relative; display: flex; align-items: center; }
.cerca > .ic { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.cerca .input { padding: 0 48px 0 44px; }
.cerca .icon-btn { position: absolute; right: 2px; color: var(--muted); }
.cerca.vuoto.a-fuoco::after { content: ""; position: absolute; left: 44px; width: 2px; height: 22px; border-radius: 1px; background: var(--accent); }

/* ---------- [4] ALIMENTAZIONE ---------- */
.dia { display: flex; flex-direction: column; gap: 28px; }
.dia-destra { display: contents; }
.dia-lato { order: 1; display: grid; gap: 20px; }
.dia-pasti { order: 2; display: grid; gap: 28px; }
.dia-link { order: 3; }

.giorno { display: flex; align-items: center; gap: 4px; margin: 0 -8px; }
.giorno-txt { flex: 1; display: grid; text-align: center; line-height: 1.25; }
.giorno-txt b { font-size: var(--fs-l); font-weight: 750; }
.giorno-txt span { font-size: var(--fs-s); color: var(--muted); }

.riepilogo { display: flex; align-items: center; gap: 20px; width: 100%; padding: 4px 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; }
.riepilogo-anello { display: grid; justify-items: center; gap: 8px; flex: none; }
.riepilogo-di { font-size: var(--fs-s); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.riepilogo-di b { color: var(--ink); font-weight: 750; }
.riepilogo-macro { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (max-width: 359px) { .riepilogo { flex-direction: column; align-items: stretch; gap: 14px; } .riepilogo-anello { justify-self: center; } }
.riepilogo-vai { display: flex; align-items: center; justify-content: flex-end; gap: 2px; margin-top: -4px; font-size: var(--fs-s); font-weight: 650; color: var(--accent-text); }

.nota { display: flex; gap: 12px; padding: 14px 14px 10px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.nota-ic { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-text); }
.nota-testo { flex: 1; min-width: 0; }
.nota-titolo { font-weight: 700; }
.nota-sub { font-size: var(--fs-m); color: var(--muted); }
.nota-sub b { color: var(--ink); font-variant-numeric: tabular-nums; }
.nota-azioni { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px; margin: 10px 0 0; }

.proposta { display: grid; gap: 16px; padding: 20px; border-radius: 20px; background: var(--accent-soft); }
.proposta .t-et { color: var(--accent-text); }
.proposta-kcal { display: flex; align-items: baseline; gap: 8px; }
.proposta-kcal span { font-weight: 650; color: var(--muted); }
.proposta-macro { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.proposta-macro div { display: grid; gap: 2px; }
.proposta-macro small { font-size: var(--fs-s); color: var(--muted); font-weight: 600; }
.proposta-da { font-size: var(--fs-s); color: var(--muted); }
.proposta-azioni { display: flex; flex-wrap: wrap; gap: 8px; }
.dati { display: grid; border-top: 1px solid color-mix(in srgb, var(--accent-text) 25%, transparent); }
.dato { display: flex; align-items: center; gap: 10px; min-height: 44px; border-bottom: 1px solid color-mix(in srgb, var(--accent-text) 25%, transparent); }
.dato > span { flex: 1; font-weight: 600; }
.dato b { font-weight: 650; }
.dato .ic { width: 18px; height: 18px; }
.dato.ok .ic { color: var(--accent-text); }
.dato.manca b { color: var(--warn); }

.pasto { display: grid; }
.pasto-testa { display: flex; align-items: center; gap: 12px; min-height: 56px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.pasto-testa h2 { font-size: var(--fs-xl); font-weight: 750; letter-spacing: -.02em; }
.pasto-kcal { flex: 1; font-size: var(--fs-m); color: var(--muted); font-variant-numeric: tabular-nums; }
.pasto-kcal b { color: var(--ink); font-weight: 750; }
.pasto .lista { border-top: 0; }
.pasto-vuoto { display: flex; align-items: center; justify-content: flex-start; gap: 12px; min-height: 64px; color: var(--muted); font-size: var(--fs-m); border-bottom: 1px solid var(--line); }

.collegamenti { display: grid; border-top: 1px solid var(--line); }
.coll { display: flex; align-items: center; gap: 14px; min-height: 64px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.coll-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-2); }
.coll-txt { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.coll-txt b { font-weight: 620; }
.coll-txt span { font-size: var(--fs-s); color: var(--muted); font-variant-numeric: tabular-nums; }
.coll > .ic { color: var(--muted); }

/* Aggiungi */
.pasto-scelta { display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); padding: 0; border: 0; background: none; font-size: var(--fs-xl); font-weight: 750; letter-spacing: -.02em; cursor: pointer; justify-self: start; white-space: nowrap; }
.pasto-scelta b { color: var(--accent-text); font-weight: 750; }
.pasto-scelta .ic { color: var(--accent-text); }
.agg-conta { display: flex; align-items: center; gap: 4px; margin-top: -10px; font-size: var(--fs-s); font-weight: 700; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.agg-conta .ic { width: 14px; height: 14px; stroke-width: 2.8; }
.agg-strumenti { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 8px; margin-top: -4px; }
.gruppo { display: grid; }
.gruppo-titolo { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0 6px; border-bottom: 1px solid var(--line); }
.carica { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-s); color: var(--muted); font-weight: 600; }
.giro { animation: giro .9s linear infinite; }
.giro circle { fill: none; stroke: var(--accent); stroke-width: 3px; stroke-linecap: round; stroke-dasharray: 30 60; }
@keyframes giro { to { transform: rotate(360deg); } }
.scheletro { display: grid; gap: 8px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.scheletro i { display: block; height: 12px; width: 55%; border-radius: 6px; background: var(--surface-2); }
.scheletro i + i { width: 32%; height: 10px; }
.agg-crea { display: flex; align-items: center; justify-content: center; gap: 6px; padding-top: 8px; color: var(--muted); font-size: var(--fs-m); }
.tasti { display: none; }
kbd { display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 6px; border-radius: 6px; background: var(--surface-2); box-shadow: inset 0 -1px 0 var(--line-strong); font: 600 .75rem/1 var(--font); color: var(--ink); }

/* Quantità */
.qta-testa { padding-left: 4px; gap: 4px; }
.qta-nome { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.qta-nome b { font-size: var(--fs-l); font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qta-nome span { font-size: var(--fs-s); color: var(--muted); }
.qta-campo { display: flex; align-items: baseline; justify-content: center; gap: 6px; width: 220px; margin: 4px auto 0; padding: 6px 0 10px; border-bottom: 3px solid var(--accent); }
.qta-campo input { width: 150px; padding: 0; border: 0; background: none; outline: none; text-align: right; font-size: var(--fs-4xl); font-weight: 800; letter-spacing: -.045em; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink); }
.qta-g { font-size: var(--fs-xl); font-weight: 700; color: var(--muted); }
.qta-rapidi { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.qta-rapidi .btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); box-shadow: none; }
.anteprima { display: grid; gap: 14px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.anteprima-kcal { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.anteprima-kcal > b { font-size: var(--fs-3xl); font-weight: 800; letter-spacing: -.04em; line-height: 1; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.anteprima-kcal > b small { margin-left: 4px; font-size: var(--fs-l); font-weight: 700; letter-spacing: 0; }
.anteprima-kcal > span { font-size: var(--fs-s); color: var(--muted); text-align: right; line-height: 1.35; font-variant-numeric: tabular-nums; }
.anteprima-kcal > span strong { color: var(--ink); font-weight: 750; }
.scelta { display: flex; align-items: center; justify-content: space-between; min-height: 56px; border-bottom: 1px solid var(--line); font-weight: 600; }
.scelta-btn { display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); padding: 0; border: 0; background: none; color: var(--accent-text); font-weight: 700; cursor: pointer; }

/* Obiettivi */
.obj-riga { display: flex; align-items: center; gap: 12px; min-height: 76px; border-bottom: 1px solid var(--line); }
.obj-txt { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.obj-txt b { font-weight: 650; font-size: var(--fs-l); }
.obj-txt span { font-size: var(--fs-s); color: var(--muted); font-variant-numeric: tabular-nums; }
.obj-riga .unita { width: 128px; flex: none; }
.ripart { display: grid; gap: 10px; }
.ripart-barra { display: flex; gap: 3px; height: 12px; }
.ripart-barra i { display: block; height: 100%; border-radius: 4px; }
.ripart-barra i:nth-child(1), .leg i.p { background: var(--accent); }
.ripart-barra i:nth-child(2), .leg i.c { background: color-mix(in srgb, var(--accent) 55%, var(--bg)); }
.ripart-barra i:nth-child(3), .leg i.g { background: var(--over); }
.leg { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: var(--fs-s); color: var(--muted); font-variant-numeric: tabular-nums; }
.leg span { display: inline-flex; align-items: center; gap: 6px; }
.leg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.leg b { color: var(--ink); }
.obj-da { font-size: var(--fs-s); color: var(--muted); line-height: 1.45; }


/* Foglio «Aggiungi» / «Quantità»: un <dialog> modale. Telefono: sale dal basso; PC: pannello centrato. */
.foglio {
  position: fixed; inset: 40px 0 0 0; margin: 0; padding: 0; border: 0; width: 100%; max-width: none; height: auto; max-height: none;
  flex-direction: column; background: var(--surface); color: var(--ink);
  border-radius: var(--radius-l) var(--radius-l) 0 0; box-shadow: var(--shadow-sheet); overflow: hidden;
}
.foglio[open] { display: flex; animation: foglio-su .2s ease; }
.foglio::backdrop { background: var(--scrim); }
.foglio::before { content: ""; flex: none; align-self: center; width: 36px; height: 5px; margin-top: 8px; border-radius: 3px; background: var(--line-strong); }
@keyframes foglio-su { from { transform: translateY(24px); opacity: 0; } }
.foglio-testa { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 16px; min-height: 60px; }
.foglio-titolo { flex: 1; min-width: 0; display: grid; }
.foglio-sub { font-size: var(--fs-s); color: var(--muted); }
.foglio-nome { font-size: var(--fs-l); font-weight: 750; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obj-pagina { max-width: 560px; }
.foglio-corpo { flex: 1; overflow: auto; padding: 0 16px 24px; display: grid; gap: 12px; align-content: start; }
.foglio-piede { display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.foglio-piede .btn { flex: 1; }

@container app (min-width: 900px) {
  #app:has(.dia) .view, #app:has(.dia) .top { max-width: 1112px; }
  .dia { display: grid; grid-template-columns: minmax(0, 1fr) 368px; gap: 48px; align-items: start; }
  .dia-destra { display: grid; gap: 16px; grid-column: 2; grid-row: 1; position: sticky; top: 16px; }
  .dia-pasti { grid-column: 1; grid-row: 1; }
  .dia-lato { padding: 20px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); }
  .dia-lato .nota { background: var(--bg); }
  .dia-link .coll { min-height: 56px; }
  .foglio { inset: 56px auto auto calc(50% - 280px); width: 560px; height: min(760px, calc(100% - 112px)); border-radius: var(--radius-l); box-shadow: var(--shadow); }
  .foglio::before { display: none; }
  .foglio-testa { padding: 12px 16px 4px 24px; }
  .foglio-corpo { padding: 0 24px 24px; }
  .riga.aggiunta { margin-inline: -24px; padding-inline: 24px; }
  .tasti { display: flex; align-items: center; justify-content: center; gap: 20px; padding: 12px 24px; border-top: 1px solid var(--line); font-size: var(--fs-s); color: var(--muted); }
  .tasti span { display: inline-flex; align-items: center; gap: 4px; }
}

/* Righe del diario: scorrimento col dito per eliminare (solo tocco). Sul PC «Elimina» sta nella finestra della voce. */
.scorre { margin-inline: 0; }
.scorre .riga { padding-inline: 0; transform: none; touch-action: pan-y; }
.scorre-elimina { visibility: hidden; }
.scorre.aperta .riga { transform: translateX(-96px); }
.scorre.aperta .scorre-elimina, .scorre.trascina .scorre-elimina { visibility: visible; }
.scorre.trascina .riga { transition: none; }
.piu .ic { width: 22px; height: 22px; }

/* Foglio «Aggiungi»: il menu del pasto sta trasparente sopra il testo */
.pasto-scelta, .scelta-btn { position: relative; }
.pasto-select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; font-size: 16px; }
.foglio-titolo .agg-conta { margin-top: 0; }
/* ricerca e filtri restano fermi in alto mentre l'elenco scorre */
.agg-fisso { position: sticky; top: 0; z-index: 2; display: grid; gap: 12px; padding: 2px 0 8px; background: var(--surface); }
