/* =========================================================================
   Palestra — design system
   Dark-first, mobile-first, zero dipendenze.
   ========================================================================= */

:root {
  /* superfici */
  --bg: #0a0b0f;
  --bg-grad: radial-gradient(120% 80% at 50% -10%, #161a24 0%, #0a0b0f 60%);
  --surface: #14171e;
  --surface-2: #1a1e27;
  --surface-3: #232835;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .13);

  /* testo */
  --txt: #f3f5f9;
  --txt-2: #a6adbd;
  --txt-3: #6d7585;

  /* accenti */
  --acc: #d7ff3e;
  --acc-2: #9ae630;
  --acc-ink: #0a0b0f;
  --acc-soft: rgba(215, 255, 62, .13);
  --violet: #8b7bff;
  --cyan: #4cd7f6;
  --ok: #35d07f;
  --warn: #ffb020;
  --err: #ff5c5c;

  /* forma */
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-full: 999px;

  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-2: 0 8px 24px -8px rgba(0, 0, 0, .65);
  --sh-3: 0 24px 60px -16px rgba(0, 0, 0, .8);
  --glow: 0 6px 28px -8px rgba(215, 255, 62, .5);

  /* spazi */
  --pad: 16px;
  --tabbar-h: 62px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* La barra non riserva tutti i 34pt dell'home indicator: con metà spazio le
     icone restano libere ma il menù non sembra sollevato dal bordo. */
  --safe-pad-b: max(6px, calc(var(--safe-b) * .55));
  /* Le barre in basso devono avere una superficie riconoscibile: con uno
     sfondo quasi identico alla pagina la striscia sotto le icone legge come
     vuoto e la barra sembra sospesa a mezz'aria. */
  --bar-bg: rgba(21, 25, 34, .94);

  --ease: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f5f8;
  --bg-grad: radial-gradient(120% 80% at 50% -10%, #ffffff 0%, #eef0f5 60%);
  --surface: #ffffff;
  --surface-2: #f6f7fa;
  --surface-3: #eceef4;
  --line: rgba(10, 12, 20, .08);
  --line-2: rgba(10, 12, 20, .15);
  --txt: #0e1117;
  --txt-2: #5a6273;
  --txt-3: #8c94a3;
  --acc: #5f8f00;
  --acc-2: #4d7500;
  --acc-ink: #ffffff;
  --acc-soft: rgba(95, 143, 0, .12);
  --violet: #6b4ef0;
  --cyan: #0b8fb0;
  --sh-2: 0 8px 24px -10px rgba(16, 20, 35, .18);
  --sh-3: 0 24px 60px -18px rgba(16, 20, 35, .3);
  --glow: 0 6px 24px -10px rgba(95, 143, 0, .5);
  --bar-bg: rgba(255, 255, 255, .94);
  color-scheme: light;
}

/* ------------------------------------------------------------- reset ---- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;             /* lo scroll avviene dentro #view */
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

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

button { background: none; border: 0; cursor: pointer; touch-action: manipulation; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

::selection { background: var(--acc); color: var(--acc-ink); }

/* scrollbar discreta (desktop) */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------- shell ---- */

/* `inset: 0` su un elemento fisso copre esattamente il viewport di layout.
   Niente dvh: in standalone su iOS vale "schermo meno la status bar", e la
   schermata finiva ~60pt sopra il bordo inferiore. */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* unico contenitore scrollabile dell'app */
#view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  position: relative;
}

.screen {
  padding: calc(var(--safe-t) + 10px) var(--pad) 28px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  animation: screenIn .34s var(--ease) both;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  min-height: 42px;
}

.topbar h1 {
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -.03em;
}

.topbar .sub { font-size: 13px; color: var(--txt-2); font-weight: 500; letter-spacing: -.01em; }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--txt-2);
  flex: none;
  transition: transform .18s var(--spring), background .18s;
}
.icon-btn:active { transform: scale(.9); background: var(--surface-3); }
.icon-btn.ghost { background: transparent; border-color: transparent; }

/* ---------------------------------------------------------- tab bar ----- */

.tabbar {
  flex: none;
  position: relative;
  z-index: 60;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  height: calc(var(--tabbar-h) + var(--safe-pad-b));
  padding-bottom: var(--safe-pad-b);
  background: var(--bar-bg);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--line-2);
  box-shadow: 0 -12px 26px -14px rgba(0, 0, 0, .9);
}

.tabbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0 4px;
  color: var(--txt-3);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: -.01em;
  transition: color .2s;
}
.tabbar button.on { color: var(--txt); }
.tabbar button.on svg { color: var(--acc); }
.tabbar button:active { transform: scale(.93); }
.tabbar svg { width: 23px; height: 23px; transition: transform .25s var(--spring); }
.tabbar button.on svg { transform: translateY(-1px) scale(1.06); }

/* Pulsante centrale. I selettori partono da .tabbar per battere in specificità
   `.tabbar button`, che altrimenti gli imporrebbe flex-direction e padding. */
.tabbar .fab-slot { align-self: stretch; display: grid; place-items: center; }
.tabbar .tab-fab {
  width: 56px; height: 56px;
  padding: 0;
  border-radius: 19px;
  background: linear-gradient(160deg, var(--acc), var(--acc-2));
  color: var(--acc-ink);
  display: grid;
  place-items: center;
  box-shadow: var(--glow);
  transform: translateY(-10px);
  transition: transform .2s var(--spring);
}
.tabbar .tab-fab:active { transform: translateY(-10px) scale(.92); }
.tabbar .tab-fab svg { width: 30px; height: 30px; transform: none; }

/* -------------------------------------------------------------- card ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--sh-1);
}
.card + .card { margin-top: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.card.tappable { transition: transform .18s var(--ease); }
.card.tappable:active { transform: scale(.985); }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--txt-3);
  margin: 26px 2px 10px;
}
.section-title button { color: var(--acc); font-size: 12.5px; font-weight: 700; letter-spacing: 0; text-transform: none; }

.card > .t, .card .grow > .t { display: block; font-weight: 650; font-size: 15.5px; letter-spacing: -.015em; }
.card > .s, .card .grow > .s { display: block; font-size: 12.5px; color: var(--txt-3); margin-top: 2px; }

/* ------------------------------------------------------------ bottoni --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 20px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--txt);
  font-weight: 650;
  font-size: 15.5px;
  letter-spacing: -.01em;
  transition: transform .15s var(--spring), background .18s, opacity .18s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn svg { width: 19px; height: 19px; }
.btn.block { display: flex; width: 100%; }
.btn.primary {
  background: linear-gradient(165deg, var(--acc), var(--acc-2));
  color: var(--acc-ink);
  border-color: transparent;
  box-shadow: var(--glow);
  font-weight: 750;
}
.btn.violet { background: linear-gradient(165deg, var(--violet), #6a57f0); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; border-color: var(--line-2); }
.btn.danger { background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.btn.sm { height: 38px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn.lg { height: 58px; font-size: 17px; border-radius: var(--r-lg); }
.btn.xl { height: 66px; font-size: 18.5px; border-radius: var(--r-lg); }

/* ------------------------------------------------------------- chips ---- */

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; scroll-snap-type: x proximity; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-full);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--txt-2);
  font-size: 13.5px;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .18s var(--ease);
  scroll-snap-align: start;
}
.chip.on { background: var(--acc); color: var(--acc-ink); border-color: transparent; font-weight: 700; }
.chip:active { transform: scale(.94); }

.seg {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  padding: 4px;
  gap: 2px;
}
.seg button {
  flex: 1;
  height: 34px;
  border-radius: var(--r-full);
  color: var(--txt-2);
  font-size: 13.5px;
  font-weight: 650;
  transition: all .22s var(--ease);
}
.seg button.on { background: var(--surface-3); color: var(--txt); }

/* ------------------------------------------------------------ pillole --- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--txt-2);
  font-size: 11.5px; font-weight: 700;
  letter-spacing: -.01em;
}
.pill.acc { background: var(--acc-soft); color: var(--acc); }
.pill.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.pill.violet { background: color-mix(in srgb, var(--violet) 18%, transparent); color: var(--violet); }

/* -------------------------------------------------------------- stat ---- */

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px 12px;
  text-align: left;
}
.stat .v { font-size: 22px; font-weight: 800; letter-spacing: -.045em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .k { font-size: 11px; color: var(--txt-3); font-weight: 600; margin-top: 3px; letter-spacing: -.01em; }
.stat .u { font-size: 12px; color: var(--txt-3); font-weight: 600; margin-left: 2px; }

/* -------------------------------------------------------------- liste --- */

.rows { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  width: 100%;
  transition: background .15s;
}
.row:last-child { border-bottom: 0; }
.row:active { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; display: block; }
.row .t { display: block; font-weight: 620; font-size: 15.5px; letter-spacing: -.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { display: block; font-size: 12.5px; color: var(--txt-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .chev { color: var(--txt-3); flex: none; }

.avatar {
  width: 42px; height: 42px; flex: none;
  border-radius: 13px;
  background: var(--surface-3);
  display: grid; place-items: center;
  color: var(--txt-2);
  overflow: hidden;
}
.avatar.acc { background: var(--acc-soft); color: var(--acc); }

/* -------------------------------------------------------------- input --- */

.field { margin-bottom: 14px; }
.field > label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--txt-3);
  margin-bottom: 7px;
}
.input, select.input, textarea.input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--txt);
  font-size: 16px;
  outline: none;
  transition: border-color .18s, background .18s;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus { border-color: var(--acc); background: var(--surface); }
textarea.input { height: auto; min-height: 96px; padding: 12px 14px; line-height: 1.5; resize: vertical; font-family: inherit; }
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a6adbd' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 38px;
}
.input::placeholder { color: var(--txt-3); }

.switch {
  width: 50px; height: 30px; flex: none;
  border-radius: var(--r-full);
  background: var(--surface-3);
  border: 1px solid var(--line);
  position: relative;
  transition: background .22s var(--ease);
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--txt-2);
  transition: transform .26s var(--spring), background .22s;
}
.switch.on { background: var(--acc); border-color: transparent; }
.switch.on::after { transform: translateX(20px); background: var(--acc-ink); }

/* ----------------------------------------------------------- stepper ---- */

.stepper {
  display: flex;
  align-items: stretch;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  height: 54px;
}
.stepper button {
  width: 48px;
  display: grid; place-items: center;
  color: var(--txt-2);
  font-size: 22px;
  font-weight: 500;
  transition: background .15s;
}
.stepper button:active { background: var(--surface-3); color: var(--acc); }
.stepper .val {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-width: 0;
}
.stepper .val input {
  width: 100%;
  background: none; border: 0; outline: none;
  text-align: center;
  font-size: 21px;
  font-weight: 750;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  padding: 0;
}
.stepper .val small { font-size: 10px; color: var(--txt-3); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-top: -2px; }

/* -------------------------------------------------------------- sheet --- */

.scrim {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 90;
  animation: fade .25s ease both;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.sheet {
  position: fixed;
  left: 0; right: 0;
  bottom: var(--kb, 0px);
  z-index: 91;
  max-height: calc(100% - var(--kb, 0px) - 24px);
  transition: bottom .18s ease;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--line-2);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sh-3);
  padding-bottom: var(--safe-b);
  animation: sheetIn .36s var(--ease) both;
  max-width: 560px; margin: 0 auto;
}
body.kb-open .sheet { padding-bottom: 0; }
body.kb-open .sheet .sheet-foot { padding-bottom: 12px; }
@keyframes sheetIn { from { transform: translateY(102%) } to { transform: none } }
.sheet.closing { animation: sheetOut .24s ease-in both; }
@keyframes sheetOut { to { transform: translateY(102%) } }
.scrim.closing { animation: fadeOut .24s ease-in both; }
@keyframes fadeOut { to { opacity: 0 } }

.sheet .grab { width: 38px; height: 4px; border-radius: 99px; background: var(--line-2); margin: 10px auto 2px; flex: none; }
.sheet .sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 18px 12px;
  flex: none;
}
.sheet .sheet-head h3 { font-size: 19px; font-weight: 750; letter-spacing: -.025em; }
.sheet .sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 18px 20px; }
.sheet .sheet-foot { padding: 12px 18px calc(16px + var(--safe-b)); border-top: 1px solid var(--line); flex: none; display: flex; gap: 10px; }
.sheet .sheet-foot .btn { flex: 1; }

/* Se nonostante tutto iOS tiene il viewport più corto dello schermo, la safe
   area in fondo è già fuori dal viewport: riservarle spazio lo sprecherebbe
   due volte. */
html.vp-short { --safe-pad-b: 0px; }

/* Senza `viewport-fit=cover` le env() valgono 0 e il viewport è già dentro le
   safe area: la barra si appoggia al bordo dell'area utile e serve solo un
   filo di respiro sotto le icone. */
html.vp-inset { --safe-t: 0px; --safe-b: 0px; --safe-pad-b: 7px; }

/* E proviamo a prolungare la superficie della barra dentro la striscia che
   resta fuori dal viewport. Se iOS la ritaglia non si perde niente — resta
   esattamente com'era — ma se la disegna la barra arriva al bordo fisico. */
html.vp-short .tabbar::after,
html.vp-short .rail::after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 100%;
  height: var(--vp-gap, 0px);
  background: var(--bar-bg);
  pointer-events: none;
}

/* Seconda strada, quella con le prove a favore: lo sfondo dell'elemento radice
   diventa lo sfondo del canvas e per specifica lo copre tutto, anche la parte
   fuori dal viewport — lo si vede nello screenshot, dove la striscia morta è
   nera come la pagina e non del colore del sistema. Allora ci dipingiamo sopra
   una fascia del colore della barra, posizionata appena sotto il viewport. */
html.vp-short body {
  background-image:
    linear-gradient(var(--bar-bg), var(--bar-bg)),
    var(--bg-grad);
  background-repeat: no-repeat, no-repeat;
  background-size: 100% var(--vp-gap, 0px), 100% 100%;
  background-position: left calc(100% + var(--vp-gap, 0px)), left top;
  background-attachment: fixed, fixed;
}

/* ------------------------------------------------------- solo verticale --- */

/* iOS ignora sia `orientation` nel manifest sia `screen.orientation.lock()`:
   in orizzontale l'unica strada è coprire l'app. Il limite sull'altezza lascia
   passare desktop e tablet, dove l'orizzontale non è un problema. */
#rotate { display: none; }

@media (orientation: landscape) and (max-height: 600px) {
  #rotate {
    position: fixed; inset: 0;
    z-index: 400;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 24px 32px;
    background: var(--bg);
    background-image: var(--bg-grad);
    text-align: center;
  }
  #rotate svg { width: 44px; height: 44px; color: var(--acc); }
  #rotate strong { display: block; font-size: 19px; font-weight: 750; letter-spacing: -.025em; }
  #rotate span { display: block; margin-top: 3px; font-size: 14px; color: var(--txt-2); }
}

/* -------------------------------------------------------------- toast --- */

#toasts {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  top: calc(var(--safe-t) + 10px);
  z-index: 120;
  width: min(480px, calc(100% - 24px));
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 11px 15px;
  font-size: 14.5px;
  font-weight: 600;
  box-shadow: var(--sh-2);
  display: flex; align-items: center; gap: 10px;
  animation: toastIn .4s var(--spring) both;
}
.toast.pr { background: linear-gradient(120deg, var(--acc), var(--acc-2)); color: var(--acc-ink); border-color: transparent; }
.toast.err { background: var(--err); color: #fff; border-color: transparent; }
.toast.out { animation: toastOut .3s ease-in both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(.96) } to { opacity: 1; transform: none } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px) scale(.97) } }

/* ------------------------------------------------------------- vuoto ---- */

.empty { text-align: center; padding: 42px 20px; }
.empty .ico { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; color: var(--txt-3); }
.empty h3 { font-size: 17px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 6px; }
.empty p { font-size: 14px; color: var(--txt-3); max-width: 280px; margin: 0 auto 18px; line-height: 1.5; }

/* ===================================================== SCHERMATA WORKOUT = */

.wk {
  flex: 1;
  min-height: 0;
  background: var(--bg);
  background-image: var(--bg-grad);
  display: flex;
  flex-direction: column;
  animation: wkIn .4s var(--ease) both;
}
@keyframes wkIn { from { opacity: 0; transform: translateY(18px) scale(.98) } to { opacity: 1; transform: none } }

.wk-head {
  flex: none;
  padding: calc(var(--safe-t) + 8px) 14px 8px;
  display: flex; align-items: center; gap: 10px;
}
.wk-head .t { flex: 1; min-width: 0; }
.wk-head .t .n { font-size: 15px; font-weight: 750; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-head .t .m { font-size: 12px; color: var(--txt-3); font-variant-numeric: tabular-nums; margin-top: 1px; }

.wk-prog { flex: none; height: 3px; background: var(--surface-2); margin: 4px 14px 0; border-radius: 99px; overflow: hidden; }
.wk-prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--acc-2), var(--acc)); border-radius: 99px; transition: width .5s var(--ease); }

.wk-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 14px 10px; }
.wk-body > * { max-width: 520px; margin-left: auto; margin-right: auto; }

.ex-hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.ex-hero .anim-wrap {
  position: relative;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border-bottom: 1px solid var(--line);
  display: grid; place-items: center;
  padding: 6px 0;
}
.ex-hero .anim-wrap .info-fab {
  position: absolute; right: 10px; top: 10px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  color: var(--txt-2);
}
.ex-hero .anim-wrap .tgt {
  position: absolute; left: 12px; top: 12px;
  display: flex; gap: 6px;
}
.ex-hero .meta { padding: 14px 16px 0; }
.ex-hero h2 { font-size: 23px; font-weight: 800; letter-spacing: -.035em; line-height: 1.15; }
.ex-hero .sub { font-size: 13px; color: var(--txt-3); margin-top: 4px; font-weight: 550; }

.set-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 16px 16px 4px;
}
.set-head .big { font-size: 15px; font-weight: 750; letter-spacing: -.02em; }
.set-head .hint { font-size: 12.5px; color: var(--acc); font-weight: 650; }

.inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 8px 16px 14px; }
.inputs.uno { grid-template-columns: 1fr; }   /* un campo solo: tutta la riga */

.coach {
  display: flex; align-items: flex-start; gap: 9px;
  margin: 0 16px 14px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--acc-soft);
  border: 1px solid color-mix(in srgb, var(--acc) 24%, transparent);
  font-size: 13px;
  color: var(--txt);
  line-height: 1.45;
}
.coach svg { flex: none; width: 17px; height: 17px; color: var(--acc); margin-top: 1px; }
.coach b { font-weight: 750; }

.cta-wrap { padding: 0 16px 16px; display: flex; gap: 10px; }
.cta-wrap .btn.primary { flex: 1; }

/* --- registro serie (tabella compatta) --- */
.sets-log { margin-top: 16px; }

.log-head, .set-line {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto 68px;
  gap: 8px;
  align-items: center;
}

.log-head {
  padding: 0 12px 7px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--txt-3);
}
.log-head .c-prev, .log-head .c-val { text-align: right; }

.set-line {
  padding: 9px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 7px;
  animation: setIn .35s var(--spring) both;
}
@keyframes setIn { from { opacity: 0; transform: translateX(-8px) } to { opacity: 1; transform: none } }
.set-line.done { background: color-mix(in srgb, var(--ok) 9%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.set-line.cur { border-color: var(--acc); background: var(--acc-soft); }

.set-line .idx {
  width: 30px; height: 30px;
  border-radius: 10px;
  background: var(--surface-3);
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 800;
  color: var(--txt-2);
  transition: transform .15s var(--spring);
}
.set-line .idx:active { transform: scale(.86); }
.set-line .idx.warm { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.set-line .idx.drop { background: color-mix(in srgb, var(--violet) 24%, transparent); color: var(--violet); }
.set-line .idx.myo { background: color-mix(in srgb, var(--cyan) 20%, transparent); color: var(--cyan); }
.set-line .idx.fail { background: color-mix(in srgb, var(--err) 20%, transparent); color: var(--err); }
.set-line.done .idx { background: var(--ok); color: #06240f; }
.set-line.cur .idx { background: var(--acc); color: var(--acc-ink); }
.set-line.w.cur .idx { background: var(--warn); color: #2a1a00; }
.pill.warm { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

.set-line .prev {
  font-size: 12.5px; color: var(--txt-3);
  font-variant-numeric: tabular-nums;
  text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.set-line .val {
  font-size: 15px; font-weight: 750; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right;
}
.set-line .val i { font-style: normal; color: var(--txt-3); font-weight: 500; margin: 0 3px; font-size: 12px; }
.set-line .val em { font-style: normal; font-size: 11px; color: var(--violet); font-weight: 800; margin-left: 5px; }
.set-line .act { display: flex; gap: 4px; justify-content: flex-end; }

.mini {
  width: 30px; height: 30px; flex: none;
  border-radius: 9px;
  display: grid; place-items: center;
  color: var(--txt-3);
  background: color-mix(in srgb, var(--txt) 6%, transparent);
  transition: transform .15s var(--spring), color .15s;
}
.mini:active { transform: scale(.86); color: var(--acc); }

/* --- superset, nota, RPE --- */
/* ------------------------------------------------------ riscaldamento ---- */
/* Una serie di riscaldamento non va confusa con una di lavoro: la scheda
   cambia colore, non solo il badge accanto al numero. */
.ex-hero.warm { border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.warm-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  font-size: 11px; font-weight: 800;
  letter-spacing: .05em; text-transform: uppercase;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 15%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 26%, transparent);
}
.warm-bar svg { width: 14px; height: 14px; flex: none; }
.warm-bar .wb-note { text-transform: none; letter-spacing: 0; font-weight: 650; opacity: .8; }
.set-head .big.warm { color: var(--warn); }
.set-head .hint.warm { color: var(--warn); }
/* la spinta motivazionale: deve staccarsi dal consiglio tecnico */
.coach.push {
  background: color-mix(in srgb, var(--acc) 15%, transparent);
  border-color: color-mix(in srgb, var(--acc) 34%, transparent);
}
.coach.push svg { color: var(--acc); }

.coach.warm {
  background: color-mix(in srgb, var(--warn) 13%, transparent);
  border-color: color-mix(in srgb, var(--warn) 26%, transparent);
  align-items: center;
}
.coach.warm svg { color: var(--warn); }
.btn.warm {
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
}
.btn.warm.lg { background: linear-gradient(165deg, var(--warn), #e08900); color: #2a1a00; border-color: transparent; }
.set-line.w { background: color-mix(in srgb, var(--warn) 9%, var(--surface)); }
.set-line.w.cur { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 17%, var(--surface)); }
.rail-item .p svg { width: 11px; height: 11px; vertical-align: -1px; color: var(--warn); }

.ss-bar {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 14px;
  font-size: 10.5px; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase;
  color: #0a0b0f;
}
.ex-note {
  display: flex; gap: 7px; align-items: flex-start;
  margin-top: 9px; padding: 8px 10px;
  border-radius: 11px;
  background: var(--surface-2);
  font-size: 12.5px; color: var(--txt-2); line-height: 1.4;
}
.rpe-row {
  display: flex; align-items: center; gap: 6px;
  padding: 0 16px 12px;
  overflow-x: auto; scrollbar-width: none;
}
.rpe-row::-webkit-scrollbar { display: none; }
.rpe-lab { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; color: var(--txt-3); flex: none; }
.rpe {
  flex: none; min-width: 38px; height: 30px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 700; color: var(--txt-2);
}
.rpe.on { background: var(--violet); border-color: transparent; color: #fff; }

/* --- conferme con spunta nei riepiloghi --- */
.check-row {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 14px; line-height: 1.4;
}
.check-row input { width: 21px; height: 21px; accent-color: var(--acc); flex: none; margin: 1px 0 0; }

/* rail esercizi */
.rail {
  flex: none;
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 10px 14px calc(10px + var(--safe-pad-b));
  border-top: 1px solid var(--line-2);
  background: var(--bar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-item {
  flex: none;
  min-width: 112px; max-width: 150px;
  padding: 9px 11px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
  transition: all .2s var(--ease);
}
.rail-item .n { font-size: 12.5px; font-weight: 650; letter-spacing: -.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item .p { font-size: 10.5px; color: var(--txt-3); margin-top: 2px; font-variant-numeric: tabular-nums; }
.rail-item.on { border-color: var(--acc); background: var(--acc-soft); }
.rail-item.ok { opacity: .55; }
.rail-item.ok .p { color: var(--ok); }
.rail-item.add { min-width: 52px; max-width: 52px; display: grid; place-items: center; color: var(--txt-3); }

/* con la tastiera aperta liberiamo spazio verticale */
body.kb-open .rail,
body.kb-open .tabbar { display: none; }

/* -------------------------------------------------------- rest timer ---- */

.rest {
  position: fixed; inset: 0;
  z-index: 95;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(26px);
  -webkit-backdrop-filter: blur(26px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: calc(var(--safe-t) + 20px) 22px calc(var(--safe-b) + 20px);
  animation: fade .3s ease both;
}
.rest.closing { animation: fadeOut .22s ease-in both; }
.rest .lab { font-size: 12.5px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; color: var(--txt-3); }
.rest .dial { position: relative; width: min(74vw, 290px); aspect-ratio: 1; margin: 18px 0 6px; }
.rest .dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.rest .dial .txt {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.rest .dial .num { font-size: 64px; font-weight: 820; letter-spacing: -.06em; font-variant-numeric: tabular-nums; line-height: 1; }
.rest .dial .of { font-size: 13px; color: var(--txt-3); margin-top: 7px; font-weight: 600; }
.rest .nextup {
  margin-top: 14px;
  padding: 13px 16px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  width: 100%; max-width: 360px;
  text-align: center;
}
.rest .nextup .k { font-size: 11px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--txt-3); }
.rest .nextup .v { font-size: 17px; font-weight: 750; letter-spacing: -.025em; margin-top: 4px; }
.rest .nextup .w { font-size: 13.5px; color: var(--acc); font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
.rest .ctr { display: flex; gap: 10px; margin-top: 16px; width: 100%; max-width: 360px; }
.rest .ctr .btn { flex: 1; }
.rest.flash { animation: flashPulse .5s ease 3; }
@keyframes flashPulse { 50% { background: color-mix(in srgb, var(--acc) 18%, var(--bg)); } }

/* --------------------------------------------------------- animazione --- */

.exfig { width: 100%; max-width: 230px; height: 158px; }
.exfig.sm { max-width: 92px; height: 74px; }
.exfig.lg { max-width: 300px; height: 210px; }

/* ----------------------------------------------------------- grafici ---- */

.chart { width: 100%; height: 150px; display: block; overflow: visible; }
.chart text { font-size: 10px; fill: var(--txt-3); font-weight: 600; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.heat::-webkit-scrollbar { display: none; }
.heat i { width: 12px; height: 12px; border-radius: 3.5px; background: var(--surface-2); }
.heat i[data-l="1"] { background: color-mix(in srgb, var(--acc) 28%, var(--surface-2)); }
.heat i[data-l="2"] { background: color-mix(in srgb, var(--acc) 55%, var(--surface-2)); }
.heat i[data-l="3"] { background: color-mix(in srgb, var(--acc) 78%, var(--surface-2)); }
.heat i[data-l="4"] { background: var(--acc); }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-row .lab { width: 86px; flex: none; font-size: 12.5px; color: var(--txt-2); font-weight: 600; letter-spacing: -.01em; }
.bar-row .track { flex: 1; height: 9px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-row .track i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--acc-2), var(--acc)); transition: width .7s var(--ease); }
.bar-row .n { width: 34px; text-align: right; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--txt-2); }

/* --------------------------------------------------------- calendario --- */

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .dow { text-align: center; font-size: 10px; font-weight: 700; color: var(--txt-3); text-transform: uppercase; letter-spacing: .04em; }
.cal .d {
  aspect-ratio: 1;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 600;
  color: var(--txt-3);
  background: var(--surface-2);
}
.cal .d.off { background: transparent; opacity: .3; }
.cal .d.has { background: var(--acc); color: var(--acc-ink); font-weight: 800; }
.cal .d.today { outline: 2px solid var(--acc); outline-offset: -2px; }

/* --------------------------------------------------------- misc utils --- */

.muted { color: var(--txt-3); }
.tnum { font-variant-numeric: tabular-nums; }
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap6 { gap: 6px } .gap8 { gap: 8px } .gap10 { gap: 10px } .gap12 { gap: 12px }
.mt6 { margin-top: 6px } .mt10 { margin-top: 10px } .mt14 { margin-top: 14px } .mt20 { margin-top: 20px }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.tc { text-align: center; }
.fs12 { font-size: 12.5px } .fs13 { font-size: 13.5px } .fs15 { font-size: 15px }
.fw7 { font-weight: 700 }
.nowrap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.divider { height: 1px; background: var(--line); margin: 14px 0; }

.drag-handle { color: var(--txt-3); touch-action: none; cursor: grab; padding: 4px; }
.dragging { opacity: .55; }

.cues li {
  display: flex; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14.2px;
  line-height: 1.5;
  color: var(--txt-2);
}
.cues li:last-child { border-bottom: 0; }
.cues li .n {
  width: 21px; height: 21px; flex: none;
  border-radius: 7px;
  background: var(--acc-soft);
  color: var(--acc);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 800;
  margin-top: 1px;
}
.cues.warn li .n { background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); }

/* confetti PR */
.sparkle { position: fixed; inset: 0; pointer-events: none; z-index: 130; overflow: hidden; }
.sparkle i {
  position: absolute; top: -12px;
  width: 8px; height: 13px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: .15; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------- figura esercizi (SVG) */

/* il corpo è fatto di capsule piene, non di linee */
.exfig .b-fill { fill: var(--txt); opacity: .9; }
.exfig .b-fill-d { fill: var(--txt); opacity: .3; }          /* arto lontano */
.exfig .b-fill-s { fill: var(--txt); opacity: .68; }         /* arto lontano, di fronte */
.exfig .b-torso-wide {                                        /* tronco di fronte */
  stroke: var(--txt); stroke-width: 6; stroke-linejoin: round; opacity: .9;
}
.exfig .b-head { fill: var(--txt); opacity: .92; }
/* I muscoli sono contorni scuri sul corpo chiaro: è così che si legge
   l'anatomia nelle tavole degli esercizi. Quello che lavora va in rosso. */
.exfig .b-mus { fill: #0a0b0f; opacity: .11; }
.exfig .b-focus { fill: #e03a2f; stroke: #8f1d16; stroke-width: .9; opacity: .95; }
.exfig .b-spine { stroke: var(--txt); opacity: .4; stroke-dasharray: 3 3; }
.exfig .b-shadow { fill: var(--txt); opacity: .05; }

.exfig .p-floor { stroke: var(--line-2); }
.exfig .p-eq { stroke: var(--txt-3); opacity: .75; stroke-linecap: round; }
.exfig .p-eq-f { fill: var(--txt-3); opacity: .55; }
.exfig .p-cable { stroke: var(--txt-3); opacity: .8; stroke-dasharray: 3 3; }

.exfig .p-w { fill: var(--acc); }
.exfig .p-w-i { fill: var(--bg); opacity: .8; }
.exfig .p-w-l { stroke: var(--acc); stroke-linecap: round; }
.exfig .p-w-h { stroke: var(--acc); stroke-width: 2.4; fill: none; stroke-linecap: round; }

/* evidenziazione dei risultati di ricerca */
mark {
  background: color-mix(in srgb, var(--acc) 30%, transparent);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}
.gap14 { gap: 14px; }
