/* ======= Numero regolabile scorrendo ======= */
.num-drag {
  position: relative; touch-action: none; cursor: ns-resize;
  background: var(--bg); border: 1px solid var(--border-field); border-radius: 8px;
  color: var(--text); text-align: center; padding: 7px 2px; font-size: 0.85rem; width: 56px;
}
.num-drag:focus { border-color: var(--primary); }
.num-drag.dragging { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-shadow); }
.num-hint { font-size: 0.58rem; color: var(--muted); text-align: center; margin-top: 1px; }

/* ======= + / - serie nella sessione ======= */
/* fino a 6 bottoni: a 390px non stanno in una riga, vanno a capo (e si dividono lo spazio) invece di uscire dalla card */
.set-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.set-tool-btn { flex: 1; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 7px; border-radius: 7px; font-size: 0.72rem; font-weight: 800; cursor: pointer; }
/* nella riga + / - serie i tasti si allargano al testo e vanno a capo tutti interi (es. "+ Rest-pause"); fuori da qui (Registra del peso) resta flex: 1 */
.set-tools .set-tool-btn { flex: 1 1 auto; padding: 7px 8px; white-space: nowrap; }
.set-tool-btn:disabled { opacity: 0.35; cursor: not-allowed; }
/* macchinario occupato: tendina con alternative per lo stesso muscolo, solo per oggi; si apre sopra la scheda e si chiude toccando fuori */
.busy-wrap { position: relative; margin-top: 8px; }
.busy-btn { width: 100%; display: flex; align-items: center; gap: 8px; background: transparent; border: 1px dashed var(--border-strong); color: var(--muted); padding: 10px 12px; border-radius: 10px; font: inherit; font-size: 0.76rem; font-weight: 800; cursor: pointer; text-align: left; transition: border-color .15s ease, color .15s ease, background .15s ease; }
.busy-btn:active { transform: scale(0.98); }
.busy-btn[aria-expanded="true"] { color: var(--primary-ink); border-style: solid; border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }
.busy-lbl { flex: 1; }
.busy-chev { transition: transform .2s ease; flex-shrink: 0; }
.busy-btn[aria-expanded="true"] .busy-chev { transform: rotate(180deg); }
.busy-panel { --text-dim: var(--muted); /* M15: sul riquadro (--surface-3) il grigio spento faceva 3,99:1 nello scuro */ position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20; max-height: min(70vh, 460px); overflow-y: auto; overscroll-behavior: contain; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 12px; padding: 4px 6px 6px; box-shadow: 0 12px 32px color-mix(in srgb, #000 38%, transparent); animation: busy-in .22s cubic-bezier(0.16, 1, 0.3, 1) both; }
/* poco posto sotto (ultimo esercizio, barra in basso): si apre verso l alto */
.busy-panel.busy-su { top: auto; bottom: calc(100% + 6px); }
@keyframes busy-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.busy-head { font-size: 0.72rem; font-weight: 700; color: var(--muted); padding: 8px 8px 6px; line-height: 1.35; }
.busy-head b { color: var(--text); }
.busy-opt { width: 100%; display: flex; align-items: center; gap: 10px; background: transparent; border: 0; color: var(--text); padding: 10px 8px; min-height: 48px; font: inherit; text-align: left; cursor: pointer; border-radius: 8px; }
.busy-opt + .busy-opt { border-top: 1px solid var(--border); border-top-left-radius: 0; border-top-right-radius: 0; }
.busy-opt:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.busy-opt:active { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.busy-opt-txt { flex: 1; min-width: 0; }
.busy-opt-name { display: block; font-size: 0.88rem; font-weight: 800; line-height: 1.25; }
.busy-opt-meta { display: block; font-size: 0.72rem; color: var(--muted); font-weight: 600; margin-top: 2px; }
.busy-opt-go { color: var(--muted); font-size: 1.1rem; flex-shrink: 0; }
.busy-opt.torna .busy-opt-name { color: var(--primary); }
.busy-none { font-size: 0.8rem; color: var(--muted); padding: 10px 8px; }
.busy-wrap > .busy-none { padding: 4px 2px 0; }
.busy-chip { display: flex; align-items: flex-start; gap: 6px; font-size: 0.72rem; font-weight: 700; line-height: 1.35; color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); border-radius: 8px; padding: 6px 10px; margin-top: 8px; }
.busy-chip svg { flex-shrink: 0; margin-top: 2px; }
.busy-chip b { font-weight: 800; }
@media (prefers-reduced-motion: reduce) { .busy-panel { animation: none; } .busy-chev, .busy-btn { transition: none; } }

/* ======= Segnalazione "gia scelto" ======= */
.use-tag { display: inline-block; font-size: 0.6rem; font-weight: 900; text-transform: uppercase; border-radius: 999px; padding: 2px 7px; margin-left: 6px; white-space: nowrap; }
.use-tag.today { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success-ink); border: 1px solid var(--success); }
.use-tag.week { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning-ink); border: 1px solid var(--warning); }
/* gia scelto: si spegne coi colori e non con l opacita, che portava il testo a 2.5-3.5:1 (ora 4.5:1 e oltre) */
.sugg-row.used-week, .lib-row.used-week { --muted: var(--text-dim); }
.sugg-row.used-today, .lib-row.used-today { --text: var(--text-dim); --muted: var(--text-dim); --primary: var(--text-dim); }
.lib-add-btn.week { background: var(--warning); color: var(--on-status); }

/* schede pronte: colore diverso se gia caricate */
.carousel-card.tpl-partial { border-color: var(--warning); }
.carousel-card.tpl-done { border-color: var(--success); --muted: var(--text-dim); }
.tpl-state { display: inline-block; font-size: 0.62rem; font-weight: 900; text-transform: uppercase; border-radius: 999px; padding: 2px 8px; margin-top: 6px; }
.tpl-state.partial { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning-ink); border: 1px solid var(--warning); }
.tpl-state.done { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success-ink); border: 1px solid var(--success); }
.tpl-state.fresh { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ======= Carico settimanale per gruppo: due tonalita' ======= */
/* VERDE = gruppo gia in programma, volume dentro il range utile
   AMBRA = volume alto, fatica settimanale da tenere d occhio
   Soglie dalla letteratura: ~10-20 serie a settimana per gruppo. */
@keyframes vol-emoji-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}

/* Il CARICO si legge dall icona e dal badge, non dal bordo:
   il bordo resta riservato alla SELEZIONE, altrimenti i due segnali
   si confondono e azzerando la selezione sembra non cambiare nulla. */
.group-card.vol-start .group-emoji { filter: drop-shadow(0 0 5px color-mix(in srgb, var(--success) 50%, transparent)); }
.group-card.vol-ok .group-emoji { filter: drop-shadow(0 0 7px color-mix(in srgb, var(--success) 85%, transparent)); animation: vol-emoji-breathe 2.4s ease-in-out infinite; }
.group-card.vol-high .group-emoji { filter: drop-shadow(0 0 8px color-mix(in srgb, var(--warning) 90%, transparent)); animation: vol-emoji-breathe 1.3s ease-in-out infinite; }

/* SELEZIONE: bordo spesso nel colore del protocollo + puntino in alto a destra */
.group-card.selected { border: 2px solid var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); box-shadow: 0 0 10px var(--primary-shadow); }
.group-card.selected::after { content: ''; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.clear-sel-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.vol-check {
  position: absolute; top: 4px; left: 5px;
  width: 17px; height: 17px; border-radius: 50%;
  font-size: 0.62rem; font-weight: 900; line-height: 17px; text-align: center;
}
.vol-check.ok { background: var(--success); color: var(--on-status); }
.vol-check.start { background: color-mix(in srgb, var(--low) 30%, transparent); color: var(--low-ink); }
.vol-check.high { background: var(--warning); color: var(--on-status); }
.group-vol { font-size: 0.62rem; font-weight: 800; margin-top: 2px; }
.group-vol.ok { color: var(--success); }
.group-vol.start { color: var(--low-ink); }
.group-vol.high { color: var(--warning); }

.vol-legend { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 10px; }
.vol-legend span { display: flex; align-items: center; gap: 4px; }
.vol-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.vol-dot.start { background: var(--corpo-basso); }
.vol-dot.ok { background: var(--corpo-utile); }
.vol-dot.high { background: var(--corpo-alto); }

/* la stessa lettura sulla figura anatomica */
.bm-muscle.load-start { fill: var(--corpo-basso); stroke: var(--surface-1); animation: none; }
.bm-muscle.load-ok { fill: var(--corpo-utile); stroke: var(--surface-1); animation: none; }
.bm-muscle.load-high { fill: var(--corpo-alto); stroke: var(--surface-1); animation: none; }

/* ======= Selezione multipla e azioni di massa ======= */
.plan-head-tools { display: flex; gap: 6px; flex-shrink: 0; }
.bulk-bar { display: flex; gap: 6px; margin-bottom: 10px; }
.bulk-btn { flex: 1; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 9px 6px; border-radius: 8px; font-size: 0.74rem; font-weight: 800; cursor: pointer; }
.bulk-btn.danger { background: var(--primary-glow); border-color: var(--accent); color: #fff; }
.bulk-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.plan-bulk-actions { display: flex; gap: 6px; margin-top: 10px; }
.plan-bulk-actions .plan-tool-btn { flex: 1; }
.plan-tool-btn.danger { color: var(--accent); border-color: var(--accent); }
.plan-check { flex-shrink: 0; width: 26px; height: 26px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: transparent; font-weight: 900; font-size: 0.85rem; cursor: pointer; margin-top: 2px; display: none; }
body.select-mode .plan-check { display: block; }
.plan-check.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
body.select-mode .plan-card-actions, body.select-mode .reorder-arrows { display: none; }
.plan-card.picked { border-color: var(--primary); }

/* ======= Suggerimenti ======= */
.sugg-row { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.sugg-row:last-child { border-bottom: none; }
.sugg-main { flex: 1; min-width: 0; }
.sugg-name { font-weight: 700; font-size: 0.86rem; }
.sugg-meta { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.sugg-more { width: 100%; margin-top: 10px; background: transparent; border: 1px dashed var(--border); color: var(--muted); padding: 9px; border-radius: 8px; font-size: 0.74rem; font-weight: 800; cursor: pointer; }

/* ======= Swipe: sfondo che si rivela sotto la riga ======= */
.swipe-host { position: relative; overflow: hidden; border-radius: 10px; }
.swipe-bg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; font-weight: 900; font-size: 0.8rem; border-radius: 10px; }
.swipe-bg .sw-add { color: var(--success-ink); }
.swipe-bg .sw-del { color: var(--on-status); }
.swipe-host.to-left .swipe-bg { background: color-mix(in srgb, var(--danger) 90%, transparent); }
.swipe-host.to-right .swipe-bg { background: color-mix(in srgb, var(--success) 18%, transparent); }
.swipe-fg { position: relative; background: var(--surface-1); transition: transform .18s ease; will-change: transform; touch-action: pan-y; }
.swipe-hint { font-size: 0.66rem; color: var(--muted); text-align: center; margin: 6px 0 2px; }

/* ======= Snackbar con Annulla ======= */
.snackbar {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 95;
  width: calc(100% - 28px); max-width: 452px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  /* Nascosta davvero: la sola traslazione del 140% la lasciava spuntare
     dal bordo inferiore. Servono anche opacita', visibility e pointer-events,
     altrimenti resta visibile e continua a intercettare i tocchi. */
  transform: translate(-50%, 24px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform .25s ease, opacity .25s ease, visibility 0s linear .25s;
}
.snackbar.show {
  transform: translate(-50%, 0);
  opacity: 1; visibility: visible; pointer-events: auto;
  transition: transform .25s ease, opacity .25s ease, visibility 0s linear 0s;
}
/* regione viva dell'avviso (T27): c'e sempre, non si vede, la leggono i lettori di schermo */
.snackbar-live { position: absolute; left: 0; top: 0; width: 1px; height: 1px; margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.snackbar-text { flex: 1; font-size: 0.8rem; min-width: 0; }
.snackbar-btn { flex-shrink: 0; background: transparent; border: none; color: var(--primary); font-weight: 900; font-size: 0.8rem; text-transform: uppercase; cursor: pointer; padding: 4px 6px; }

/* ======= Giorno di riposo / esercizio saltato ======= */
.rest-toggle { width: 100%; margin-top: 10px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 10px; border-radius: 8px; font-weight: 800; font-size: 0.78rem; cursor: pointer; }
.rest-toggle.on { background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: var(--accent); color: var(--accent-ink); }
.rest-banner { text-align: center; padding: 22px 12px; }
.rest-banner .rest-emoji { font-size: 2.2rem; }
.rest-banner .rest-text { font-weight: 800; margin-top: 6px; }
.rest-banner .rest-sub { font-size: 0.76rem; color: var(--muted); margin-top: 4px; }
/* esercizio saltato: spento coi colori (testo e comandi in grigio tenue, 4.5:1 e oltre) e non con l opacita, che portava tutto a 2-3:1; il pulsante Riprendi (.skip-btn.on, accento) resta a piena forza */
.workout-item.skipped { --text: var(--text-dim); --muted: var(--text-dim); --primary: var(--text-dim); }
.workout-item.skipped .ex-name { text-decoration: line-through; }
/* anche la fiamma del cedimento e la spunta della serie (sfumatura, alone, verde pieno) vanno in grigio: nella scheda saltata resta vivo solo Riprendi */
.workout-item.skipped .set-flame-btn.fiamma, .workout-item.skipped .set-check { filter: grayscale(1); box-shadow: none; }
.skip-btn { background: transparent; border: 1px solid var(--border); color: var(--muted); font-size: 0.68rem; font-weight: 800; padding: 5px 9px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.skip-btn.on { border-color: var(--accent); color: var(--accent-ink); }

/* ======= Settimane salvate ======= */
.week-card { display: flex; align-items: center; gap: 10px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.week-main { flex: 1; min-width: 0; }
.week-name { font-weight: 800; font-size: 0.85rem; }
.week-meta { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
/* nel foglio «Settimane salvate» del Piano (T19 della scheda allievo) i pulsanti dell elenco sono bersagli da 44 px */
#weeks-sheet .week-card .track-select-btn, #weeks-sheet .week-card .del-btn { min-height: 44px; min-width: 44px; }

/* ======= Carosello orizzontale (meno scroll verticale) ======= */
.carousel { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.carousel::-webkit-scrollbar { display: none; }
.carousel-card { flex: 0 0 82%; scroll-snap-align: start; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.carousel-card .template-name { font-weight: 800; font-size: 0.9rem; }
.carousel-hint { font-size: 0.66rem; color: var(--muted); text-align: right; margin-top: 4px; }

/* ======= Schermata dedicata al gruppo muscolare ======= */
.group-sheet {
  position: fixed; inset: 0; z-index: 90; background: var(--bg);
  display: flex; flex-direction: column;
}
.group-sheet.hidden { display: none; }
.group-sheet:focus { outline: none; }   /* il foglio prende il fuoco all'apertura (tabindex -1) perche il lettore annunci il titolo: non e un comando, niente anello (T27) */
.sheet-bar, .session-bar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  border-bottom: 1px solid var(--border); background: var(--surface-1);
}
.session-bar { padding-top: 12px; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 14px; }
.sheet-back {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  font-size: 1.2rem; font-weight: 800; cursor: pointer;
}
.sheet-titles { min-width: 0; }
.sheet-title { font-size: 1.05rem; font-weight: 900; line-height: var(--lh-base); text-transform: uppercase; letter-spacing: 0.4px; }
.sheet-sub { font-size: 0.74rem; line-height: var(--lh-tight); color: var(--muted); margin-top: var(--sp-1); }
.sheet-body { flex: 1; overflow-y: auto; padding: var(--sp-5) var(--sp-4) var(--sp-6); max-width: 480px; width: 100%; margin: 0 auto; }
.sheet-map { display: flex; justify-content: center; margin-bottom: 10px; }
.sheet-map svg { width: 100%; max-width: 210px; height: auto; }
.sheet-hint { font-size: 0.74rem; color: var(--accent); font-weight: 700; margin-bottom: 10px; text-align: center; }
.sheet-footer {
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--surface-1);
}
.sheet-footer .btn-start-workout { max-width: 480px; margin: 0 auto; display: block; }

/* ======= Scelta del giorno in Allenamento ======= */
.wday-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 12px; margin-bottom: 8px; cursor: pointer; color: var(--text);
}
.wday-card:active { transform: scale(0.99); }
.wday-card.empty { --text: var(--text-dim); --muted: var(--text-dim); }
.wday-card.empty .wday-go { color: var(--text-dim); }
.wday-card.today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.wday-main { flex: 1; min-width: 0; }
.wday-name { font-weight: 800; font-size: 0.95rem; }
.wday-meta { font-size: 0.75rem; line-height: var(--lh-tight); color: var(--muted); margin-top: var(--sp-1); }
.wday-badge { flex-shrink: 0; font-size: 0.6rem; font-weight: 900; color: var(--primary); border: 1px solid var(--primary); border-radius: 999px; padding: 2px 7px; }
.wday-go { flex-shrink: 0; font-size: 1.2rem; color: var(--primary); font-weight: 900; }
.wday-progress { height: 4px; border-radius: 999px; background: var(--surface-2); margin-top: 7px; overflow: hidden; }
.wday-progress span { display: block; height: 100%; background: var(--success); border-radius: 999px; }

/* ======= Intestazioni a passi ======= */
.step-head { display: flex; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-2) 0; }
.step-num {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: var(--on-primary); font-size: 0.72rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}
.step-label { font-size: 0.85rem; font-weight: 800; line-height: var(--lh-tight); text-transform: uppercase; letter-spacing: 0.4px; }
.plan-tool-btn.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
