:root {
  --sfondo: #F1F1F1;
  --card: #FFFFFF;
  --grigio: #E7E7E9;
  --tondo: #E4E4E6;
  --scuro: #15172A;
  --sec: #5F6170;
  --sec-grigio: #4E5060;
  --sec-scuro: #C4C6D0;
  --accento: #FF4A23;
  --accento-testo: #D33C1A;
  --tinta: #FFE3DB;
  --tinta-testo: #A92C10;
  --bordo: #C9CBD3;
  --righe: repeating-linear-gradient(135deg, #A9ABB5 0 3px, #FFFFFF 3px 7px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--sfondo); }
body { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; color: var(--scuro); -webkit-text-size-adjust: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { color: inherit; text-decoration: none; touch-action: manipulation; }
h1, h2, p { margin: 0; }
svg { display: block; flex-shrink: 0; }
:focus-visible { outline: 3px solid var(--scuro); outline-offset: 2px; }
.su-scuro :focus-visible { outline-color: #FFFFFF; }

#app { height: 100vh; height: 100dvh; max-width: 480px; margin: 0 auto; }
.schermo { position: relative; height: 100%; display: flex; flex-direction: column; background: var(--sfondo); overflow: hidden; }
.scorre { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; padding: calc(16px + env(safe-area-inset-top)) 16px 24px; gap: 20px; }
.scorre > * { flex-shrink: 0; }

/* Barra in alto */
.barra { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; }
.barra-titolo { text-align: center; font-weight: 700; font-size: 1.375rem; }
.tondo { width: 48px; height: 48px; border-radius: 50%; background: var(--tondo); display: flex; align-items: center; justify-content: center; }
.barra-fissa { flex-shrink: 0; padding: calc(16px + env(safe-area-inset-top)) 16px 8px; }

/* Barra in basso */
.nav { flex-shrink: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--card); border-radius: 24px 24px 0 0; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
.nav a { min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--sec); font-size: 0.8125rem; font-weight: 600; }
.nav a[aria-current] { color: var(--scuro); font-weight: 800; }
.nav a[aria-current] svg { stroke: var(--accento); stroke-width: 2.2; }

/* Elementi comuni */
.sez { display: flex; flex-direction: column; gap: 12px; }
.sez-testa { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sez h2, .sez-testa h2 { font-weight: 700; font-size: 1.375rem; }
.sez-testa span { font-size: 0.8125rem; font-weight: 500; color: var(--sec); }
.tag { padding: 2px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; }
.tag-target { background: var(--tinta); color: var(--tinta-testo); }
.tag-rp { background: var(--scuro); color: #FFFFFF; }
.pillola { padding: 6px 12px; border-radius: 999px; font-size: 0.8125rem; font-weight: 700; white-space: nowrap; }
.btn-primario { width: 100%; min-height: 58px; border: 0; border-radius: 12px; background: var(--accento-testo); color: #FFFFFF; font-weight: 700; font-size: 1.0625rem; display: flex; align-items: center; justify-content: center; gap: 10px; }
.anello { position: relative; display: block; flex-shrink: 0; }
.anello svg { transform: rotate(-90deg); }
.anello span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; }
.anello.grande { width: 96px; height: 96px; }
.anello.grande span { font-size: 1.125rem; }
.anello.ridotto { width: 44px; height: 44px; }
.anello.ridotto span { font-size: 0.6875rem; font-weight: 700; }
.card-anello { border-radius: 22px; background: var(--card); padding: 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-anello .testi { display: flex; flex-direction: column; gap: 8px; }
.grosso { font-weight: 800; font-size: 1.75rem; line-height: 1.15; }
.card-anello .meta { font-size: 0.9375rem; font-weight: 500; color: var(--sec); }
.continua { margin-top: 6px; align-self: flex-start; min-height: 48px; padding: 0 20px; border-radius: 10px; background: var(--accento-testo); color: #FFFFFF; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.9375rem; }
.cerchi { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cerchio { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 0.875rem; font-weight: 500; text-align: center; }
.cerchio i { width: 60px; height: 60px; border-radius: 50%; background: var(--card); display: flex; align-items: center; justify-content: center; font-style: normal; font-weight: 700; font-size: 0.9375rem; }
.cerchio[aria-current] { font-weight: 700; }
.cerchio[aria-current] i { background: var(--scuro); color: #FFFFFF; }
.legenda { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.8125rem; font-weight: 500; color: var(--sec-grigio); padding: 2px 4px; }
.legenda span { display: flex; align-items: center; gap: 6px; }
.legenda i { width: 12px; height: 12px; border-radius: 4px; }
.legenda i.tondo-l { border-radius: 50%; }

/* Programma */
.blocco { position: relative; overflow: hidden; border-radius: 22px; background: var(--scuro); color: #FFFFFF; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.cerchi-dec { position: absolute; right: -30px; top: -30px; pointer-events: none; }
.blocco-testa { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.blocco-testa div { display: flex; flex-direction: column; gap: 4px; }
.blocco-testa small { font-size: 0.875rem; font-weight: 500; color: var(--sec-scuro); }
.blocco-testa .pillola { background: #FFFFFF; color: var(--scuro); }
.fasi { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.fase-box { min-height: 84px; border-radius: 16px; background: rgba(255, 255, 255, 0.08); color: #FFFFFF; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 0.8125rem; font-weight: 600; }

/* Fase */
.righe { display: flex; flex-direction: column; gap: 10px; }
.sett { display: flex; align-items: center; gap: 10px; border-radius: 18px; background: var(--card); padding: 10px 10px 10px 14px; }
.sett-n { width: 58px; flex-shrink: 0; display: flex; flex-direction: column; line-height: 1.2; }
.sett-n small { font-size: 0.8125rem; font-weight: 500; color: var(--sec); }
.sett-n b { font-weight: 800; font-size: 1.25rem; }
.celle { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.cella { position: relative; height: 60px; border-radius: 14px; background: var(--sfondo); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.cella.fatta { background: var(--scuro); color: #FFFFFF; }
.cella.corrente { background: var(--accento-testo); color: #FFFFFF; }
.cella b { font-weight: 800; font-size: 1.125rem; line-height: 1; }
.cella span { font-size: 0.75rem; font-weight: 600; }
.cella svg { position: absolute; top: 6px; right: 6px; }

/* Seduta */
.seduta { gap: 18px; }
.card-grafico { border-radius: 22px; background: var(--grigio); padding: 18px 16px 14px; display: flex; flex-direction: column; gap: 14px; }
.grafico-testa { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.grafico-testa > div { display: flex; flex-direction: column; gap: 4px; }
.grafico-testa .etichetta { font-size: 0.9375rem; font-weight: 600; }
.valore { display: flex; align-items: baseline; gap: 6px; font-size: 1rem; font-weight: 600; }
.valore b { font-weight: 800; font-size: 2rem; line-height: 1; }
.grafico-testa .pillola { background: var(--scuro); color: #FFFFFF; }
.barre { display: grid; gap: 6px; align-items: end; height: 130px; }
.barre i { display: block; border-radius: 999px; background: var(--righe); }
.barre i.piena { background: var(--accento); }
.gruppo { display: flex; flex-direction: column; gap: 10px; }
.gruppo h2 { font-weight: 700; font-size: 1.375rem; }
.riga { display: flex; align-items: center; gap: 4px; border-radius: 18px; background: var(--card); padding: 8px; min-height: 76px; }
.spunta { width: 56px; height: 56px; flex-shrink: 0; border-radius: 14px; border: 0; background: var(--sfondo); padding: 0; display: flex; align-items: center; justify-content: center; }
.spunta[aria-pressed="true"] { background: var(--scuro); }
.spunta i { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #8A8C98; display: block; }
.riga a { flex: 1; min-width: 0; min-height: 60px; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 8px; }
.riga .corpo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.riga .nome { font-weight: 700; font-size: 1rem; line-height: 1.3; }
.riga .sotto { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.presc { font-size: 0.875rem; font-weight: 500; color: var(--sec); }
.riga .carico { flex-shrink: 0; font-weight: 800; font-size: 1.125rem; white-space: nowrap; }
.fine { margin-top: 4px; display: flex; flex-direction: column; gap: 6px; }
.fatta-blocco { min-height: 58px; border-radius: 12px; background: var(--scuro); color: #FFFFFF; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; font-size: 1.0625rem; }
.link-btn { min-height: 48px; border: 0; background: transparent; font-weight: 600; font-size: 0.9375rem; text-decoration: underline; }

/* Scheda esercizio */
.scheda { padding-top: 8px; gap: 16px; }
.video { position: relative; overflow: hidden; height: 196px; border-radius: 22px; background: var(--scuro); color: #FFFFFF; padding: 18px; display: flex; flex-direction: column; justify-content: space-between; }
.video > svg { position: absolute; right: -20px; top: 0; pointer-events: none; }
.video > span { position: relative; font-weight: 800; font-size: 1.5rem; line-height: 1.15; }
.apri-video { position: relative; align-self: flex-start; min-height: 48px; padding: 0 18px; border-radius: 10px; background: #FFFFFF; color: var(--scuro); font-weight: 700; font-size: 0.9375rem; display: flex; align-items: center; gap: 8px; }
.no-video { height: 196px; border-radius: 22px; background: var(--tondo); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--sec-grigio); font-weight: 600; font-size: 1rem; }
.nome-es { font-weight: 800; font-size: 1.5rem; line-height: 1.2; }
.due-card { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mini { border-radius: 18px; background: var(--card); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.mini:only-child { grid-column: 1 / -1; }
.mini-testa { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 0.875rem; font-weight: 600; color: var(--sec-grigio); }
.mini-testa.vicino { justify-content: flex-start; }
.mini .gr { display: flex; align-items: baseline; gap: 4px; font-weight: 800; font-size: 2.25rem; line-height: 1; }
.mini .gr small { font-size: 0.9375rem; font-weight: 600; }
.mini .sot { font-size: 0.9375rem; font-weight: 600; }
.mini .tratto { display: block; height: 4px; width: 60%; border-radius: 2px; background: var(--accento); }
.mini.scura { background: var(--scuro); color: #FFFFFF; justify-content: space-between; }
.mini.scura .mini-testa, .mini.scura .piccolo { color: var(--sec-scuro); }
.mini.scura .rp { font-weight: 800; font-size: 1.5rem; line-height: 1.1; }
.mini.scura .piccolo { font-size: 0.875rem; font-weight: 500; }
.carichi { display: flex; flex-direction: column; gap: 10px; }
.carichi-testa { display: flex; align-items: center; justify-content: space-between; }
.carichi-testa h2, .note label { font-weight: 700; font-size: 1.375rem; }
.link-storico { min-height: 48px; padding: 0 4px 0 12px; display: flex; align-items: center; gap: 6px; font-size: 0.875rem; font-weight: 600; }
.serie { display: flex; align-items: center; gap: 12px; border-radius: 18px; background: var(--card); padding: 10px 12px 10px 10px; }
.serie-n { width: 52px; height: 52px; flex-shrink: 0; border-radius: 14px; background: var(--sfondo); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.25rem; color: var(--accento-testo); }
.serie-testo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.serie-testo label { font-weight: 700; font-size: 1.0625rem; }
.serie-testo span { font-size: 0.8125rem; font-weight: 500; color: var(--sec); }
.serie input { width: 88px; height: 52px; flex-shrink: 0; border-radius: 12px; border: 1.5px solid var(--bordo); background: #F7F7F8; padding: 0 8px; font-weight: 800; font-size: 1.375rem; text-align: right; }
.serie input::placeholder, .note textarea::placeholder { color: #62646F; font-weight: 500; opacity: 1; }
.serie .kg { font-weight: 700; font-size: 0.9375rem; }
.ultima-nota { border-radius: 18px; background: var(--card); padding: 14px 16px; display: flex; gap: 12px; }
.ultima-nota i { width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; background: var(--tinta); display: flex; align-items: center; justify-content: center; }
.ultima-nota div { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ultima-nota span { font-size: 0.8125rem; font-weight: 600; color: var(--sec); }
.ultima-nota p { font-size: 1rem; font-weight: 500; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.note { display: flex; flex-direction: column; gap: 10px; }
.note textarea { min-height: 130px; border-radius: 18px; border: 1.5px solid var(--bordo); background: #FFFFFF; padding: 14px; font-size: 1rem; line-height: 1.45; resize: vertical; }
.salva-barra { flex-shrink: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--card); border-radius: 24px 24px 0 0; display: flex; align-items: center; gap: 12px; }
.salva-barra span { flex: 1; font-size: 0.875rem; font-weight: 500; color: var(--sec); }
.salva-barra button { min-width: 160px; min-height: 56px; border: 0; border-radius: 12px; background: var(--accento-testo); color: #FFFFFF; font-weight: 700; font-size: 1.0625rem; }
.salva-barra button:disabled { background: var(--tondo); color: var(--sec); cursor: not-allowed; }

/* Storico */
.storico { gap: 18px; }
.barre-storico { display: grid; gap: 14px; align-items: end; height: 170px; }
.colonna { height: 170px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; }
.colonna b { font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.colonna i { display: block; width: 100%; max-width: 40px; border-radius: 999px; background: var(--righe); }
.colonna i.piena { background: var(--accento); }
.colonna span { font-size: 0.8125rem; font-weight: 500; color: var(--sec-grigio); }
.voce { border-radius: 18px; background: var(--card); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.voce-testa { display: flex; align-items: center; gap: 12px; }
.voce-testa > b { width: 56px; height: 56px; flex-shrink: 0; border-radius: 14px; background: var(--sfondo); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1rem; }
.voce-testa div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.voce-testa strong { font-weight: 700; font-size: 1rem; }
.voce-testa span { font-size: 0.8125rem; font-weight: 500; color: var(--sec); }
.voce-carichi { font-weight: 800; font-size: 1.25rem; padding: 0 2px; }
.voce p { padding: 10px 12px; border-radius: 12px; background: #F7F7F8; font-size: 0.9375rem; font-weight: 500; line-height: 1.45; color: #2E3040; white-space: pre-wrap; overflow-wrap: anywhere; }
.vuoto { border-radius: 18px; background: var(--card); padding: 20px 16px; font-size: 1rem; line-height: 1.45; color: var(--sec-grigio); }

/* Impostazioni */
.card-dati { border-radius: 22px; background: var(--card); padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.dati-testa { display: flex; align-items: center; gap: 12px; }
.dati-testa i { width: 52px; height: 52px; flex-shrink: 0; border-radius: 14px; background: var(--sfondo); display: flex; align-items: center; justify-content: center; }
.dati-testa div { display: flex; flex-direction: column; gap: 2px; }
.dati-testa h1 { font-weight: 800; font-size: 1.375rem; }
.dati-testa span { font-size: 0.875rem; font-weight: 500; color: var(--sec); }
.testo-dati { font-size: 1rem; font-weight: 500; line-height: 1.5; color: #2E3040; }
.btn-dati { min-height: 56px; border: 1.5px solid var(--scuro); border-radius: 12px; background: #FFFFFF; font-weight: 700; font-size: 1.0625rem; display: flex; align-items: center; justify-content: center; gap: 10px; }
.card-dati .btn-primario { min-height: 56px; }
.piccolo { font-size: 0.875rem; font-weight: 500; line-height: 1.4; color: var(--sec); }
.esito { font-size: 1rem; font-weight: 600; line-height: 1.4; }
.versione { margin: 0 4px; font-size: 0.8125rem; font-weight: 500; color: var(--sec); }
.nascosto { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
