/* Fitness — interfaccia */
:root {
  --bg: #070c16; --bg2: #0c1424; --card: #111b2e; --card2: #16233a; --line: #22324d; --line2: #2c3f5f;
  --tx: #eef3fa; --tx2: #a9b8cc; --tx3: #6f819b;
  --ac: #22d3ee; --ac2: #0891b2; --ok: #34d399; --warn: #fbbf24; --bad: #f87171;
  --r: 16px; --r2: 12px; --shadow: 0 10px 30px rgba(0,0,0,.35);
  --nav-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--tx);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--ac); }
.hidden { display: none !important; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h2 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
h3 { font-size: 17px; font-weight: 750; }
.muted { color: var(--tx2); } .dim { color: var(--tx3); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; } .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 14px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- pulsanti ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; font-weight: 700; background: var(--card2); border: 1px solid var(--line2); transition: transform .08s, background .15s; }
.btn:active { transform: scale(.97); }
.btn:hover { background: #1c2c48; }
.btn.primary { background: linear-gradient(135deg, #22d3ee, #10b981); color: #04222b; border: 0; box-shadow: 0 6px 20px rgba(34,211,238,.25); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.big { min-height: 56px; font-size: 17px; border-radius: 14px; padding: 0 22px; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--tx2); }
.btn.ghost:hover { background: var(--card2); color: var(--tx); }
.btn.danger { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.35); color: #fecaca; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--card2); border: 1px solid var(--line); font-size: 18px; }
.icon-btn:hover { background: #1c2c48; }

/* ---------- campi ---------- */
label.f { display: block; font-size: 13px; font-weight: 650; color: var(--tx2); margin-bottom: 6px; }
.in, select.in, textarea.in { width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line2); outline: none; transition: border .15s; }
.in:focus { border-color: var(--ac); box-shadow: 0 0 0 3px rgba(34,211,238,.15); }
textarea.in { min-height: 80px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 520px) { .grid2.resp { grid-template-columns: 1fr; } }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ac); flex: none; margin-top: 1px; }
.check.on { border-color: rgba(34,211,238,.6); background: rgba(34,211,238,.06); }
.choice { display: grid; gap: 8px; }
.choice.c2 { grid-template-columns: 1fr 1fr; } .choice.c3 { grid-template-columns: repeat(3, 1fr); }
.choice button { min-height: 52px; border-radius: 12px; border: 1px solid var(--line2); background: var(--bg2); padding: 8px 10px; font-weight: 650; text-align: center; }
.choice button.on { border-color: var(--ac); background: rgba(34,211,238,.12); color: #cffafe; }
.choice button small { display: block; font-weight: 500; color: var(--tx3); font-size: 12px; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { min-height: 36px; padding: 0 16px; border-radius: 9px; font-weight: 700; color: var(--tx2); }
.seg button.on { background: var(--card2); color: var(--tx); box-shadow: 0 1px 0 rgba(255,255,255,.05) inset; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line2); border-radius: 12px; background: var(--bg2); overflow: hidden; }
.stepper button { width: 44px; height: 44px; font-size: 20px; font-weight: 700; color: var(--tx2); }
.stepper button:active { background: var(--card2); }
.stepper .v { min-width: 56px; text-align: center; font-weight: 800; font-size: 18px; }
.stepper input.v { width: 70px; background: transparent; border: 0; outline: 0; }

/* ---------- card ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.card.pad0 { padding: 0; overflow: hidden; }
.card.hero { background: radial-gradient(120% 140% at 100% 0%, rgba(34,211,238,.18), transparent 55%), linear-gradient(160deg, #13223b, #0e1729); border-color: #23406a; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--card2); border: 1px solid var(--line2); color: var(--tx2); }
.pill.ac { color: #a5f3fc; border-color: rgba(34,211,238,.4); background: rgba(34,211,238,.1); }
.pill.ok { color: #a7f3d0; border-color: rgba(52,211,153,.4); background: rgba(52,211,153,.1); }
.pill.warn { color: #fde68a; border-color: rgba(251,191,36,.4); background: rgba(251,191,36,.1); }
.pill.bad { color: #fecaca; border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.1); }
.stat { display: flex; flex-direction: column; } .stat b { font-size: 22px; font-weight: 800; } .stat span { font-size: 12px; color: var(--tx3); }
.note { padding: 12px 14px; border-radius: 12px; background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.3); color: #fde68a; font-size: 13.5px; }
.note.info { background: rgba(34,211,238,.07); border-color: rgba(34,211,238,.3); color: #cffafe; }
.note.bad { background: rgba(248,113,113,.08); border-color: rgba(248,113,113,.35); color: #fecaca; }
.sep { height: 1px; background: var(--line); margin: 14px 0; }

/* ---------- shell ---------- */
#app { min-height: 100%; }
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(7,12,22,.85); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); padding-top: var(--safe-t); }
.topbar .in-bar { max-width: 1180px; margin: 0 auto; height: 60px; padding: 0 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 850; font-size: 20px; letter-spacing: -.02em; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #22d3ee, #10b981); display: grid; place-items: center; color: #04222b; font-size: 18px; box-shadow: 0 6px 16px rgba(34,211,238,.3); }
.athlete-chip { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); max-width: 210px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: linear-gradient(135deg, #0e7490, #065f46); color: #e0fbff; flex: none; }
.sidenav { display: none; }
.navbtn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--tx3); font-size: 11.5px; font-weight: 700; flex: 1; height: 100%; }
.navbtn .ic { font-size: 21px; line-height: 1; filter: grayscale(1) opacity(.7); }
.navbtn.on { color: var(--ac); } .navbtn.on .ic { filter: none; }
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: flex; background: rgba(9,15,27,.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
main { max-width: 1180px; margin: 0 auto; padding: 18px 16px calc(var(--nav-h) + var(--safe-b) + 28px); }
.view { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.view-head p { margin: 4px 0 0; color: var(--tx2); font-size: 14px; }

@media (min-width: 900px) {
  .bottomnav { display: none; }
  .layout { display: grid; grid-template-columns: 210px 1fr; max-width: 1240px; margin: 0 auto; }
  .sidenav { display: flex; flex-direction: column; gap: 4px; padding: 18px 10px; position: sticky; top: 61px; height: calc(100vh - 61px); }
  .sidenav .navbtn { flex-direction: row; justify-content: flex-start; gap: 12px; height: 46px; flex: none; padding: 0 14px; border-radius: 12px; font-size: 14.5px; color: var(--tx2); }
  .sidenav .navbtn:hover { background: var(--card); }
  .sidenav .navbtn.on { background: var(--card2); color: var(--tx); }
  main { padding-bottom: 40px; margin: 0; max-width: none; }
}

/* ---------- elenchi esercizi ---------- */
.exlist { display: flex; flex-direction: column; gap: 10px; }
.exrow { display: flex; align-items: center; gap: 12px; padding: 10px; padding-right: 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); cursor: pointer; transition: border .15s, background .15s; text-align: left; width: 100%; }
.exrow:hover { border-color: var(--line2); background: #13203a; }
.exrow .thumb { width: 84px; height: 63px; border-radius: 10px; overflow: hidden; flex: none; background: #0b1322; }
.exrow .thumb canvas { width: 100%; height: 100%; display: block; }
.exrow .num { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 13px; font-weight: 800; background: var(--card2); color: var(--ac); flex: none; }
.exrow .t { font-weight: 750; } .exrow .s { font-size: 13px; color: var(--tx2); }
.exrow .meta { text-align: right; font-size: 13px; color: var(--tx2); white-space: nowrap; }
.exrow .meta b { color: var(--tx); font-size: 15px; display: block; }
.phase-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--tx3); margin: 18px 4px 4px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.excard { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; cursor: pointer; text-align: left; transition: transform .12s, border .15s; display: flex; flex-direction: column; }
.excard:hover { transform: translateY(-2px); border-color: var(--line2); }
.excard canvas { width: 100%; aspect-ratio: 4/3; display: block; background: #0b1322; }
.excard .b { padding: 12px 14px 14px; }
.excard .t { font-weight: 750; } .excard .s { font-size: 12.5px; color: var(--tx2); margin-top: 2px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line2); background: var(--card); font-weight: 650; font-size: 13.5px; color: var(--tx2); }
.chip.on { background: rgba(34,211,238,.14); border-color: var(--ac); color: #cffafe; }

/* ---------- player ---------- */
.player { position: relative; border-radius: 14px; overflow: hidden; background: #0b1322; border: 1px solid var(--line); }
.player canvas { width: 100%; aspect-ratio: 4/3; display: block; }
.player .hud { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; pointer-events: none; }
.player .phase { padding: 6px 12px; border-radius: 10px; background: rgba(7,12,22,.82); border: 1px solid rgba(255,255,255,.08); font-weight: 800; font-size: 14px; backdrop-filter: blur(6px); }
.player .phase small { font-weight: 600; color: var(--tx2); margin-left: 6px; }
.player .ctrls { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.player .ctrls button { height: 32px; padding: 0 10px; border-radius: 9px; background: rgba(7,12,22,.75); border: 1px solid rgba(255,255,255,.1); font-size: 13px; font-weight: 700; color: var(--tx2); backdrop-filter: blur(6px); }
.player .ctrls button.on { color: var(--ac); border-color: rgba(34,211,238,.5); }
.player .legend { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.player .legend span { font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 8px; background: rgba(7,12,22,.75); color: #fecaca; border: 1px solid rgba(248,113,113,.35); }

/* ---------- foglio modale ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(2,6,14,.66); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .15s; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet { width: 100%; max-width: 760px; max-height: 92vh; overflow-y: auto; background: var(--bg2); border: 1px solid var(--line2); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 8px 18px calc(22px + var(--safe-b)); animation: up .22s cubic-bezier(.2,.9,.3,1); box-shadow: var(--shadow); }
.sheet.narrow { max-width: 480px; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line2); margin: 4px auto 12px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 22px; border-bottom: 1px solid var(--line2); max-height: 88vh; } .sheet .grab { display: none; } .sheet { padding-top: 20px; } }
.info-block h4 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ac); margin-bottom: 6px; }
.info-block p, .info-block li { color: var(--tx2); font-size: 14.5px; margin: 0; white-space: pre-line; }
.info-block ul { margin: 0; padding-left: 18px; }
.detail-grid { display: grid; gap: 16px; }
@media (min-width: 700px) { .detail-grid { grid-template-columns: 1.05fr 1fr; } }

/* ---------- calendario ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--tx3); padding-bottom: 4px; }
.cal .day { min-height: 64px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); padding: 6px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; text-align: left; }
.cal .day.out { opacity: .25; pointer-events: none; }
.cal .day.today { border-color: var(--ac); }
.cal .day .n { font-size: 13px; font-weight: 800; color: var(--tx2); }
.cal .day.today .n { color: var(--ac); }
.cal .ev { font-size: 11px; font-weight: 750; border-radius: 6px; padding: 2px 5px; background: rgba(34,211,238,.15); color: #a5f3fc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .ev.done { background: rgba(52,211,153,.18); color: #a7f3d0; } .cal .ev.skip { background: var(--card2); color: var(--tx3); }
@media (max-width: 520px) { .cal { gap: 4px; } .cal .day { min-height: 52px; padding: 4px; border-radius: 9px; } .cal .ev { font-size: 0; height: 6px; padding: 0; } }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(80% 60% at 50% 0%, rgba(34,211,238,.12), transparent 70%), var(--bg); }
.auth .box { width: 100%; max-width: 410px; }
.auth .brand { justify-content: center; font-size: 30px; margin-bottom: 6px; }
.auth .brand .logo { width: 48px; height: 48px; font-size: 26px; border-radius: 14px; }
.auth .err { color: #fecaca; background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.35); padding: 10px 12px; border-radius: 10px; font-size: 14px; }

/* ---------- allenamento live ---------- */
.live { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; padding: calc(var(--safe-t)) 0 calc(var(--safe-b) + 20px); }
.live-top { position: sticky; top: 0; z-index: 2; background: rgba(7,12,22,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.live-top .in-bar { max-width: 980px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.progress { height: 4px; background: var(--card2); }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--ac), var(--ok)); transition: width .3s; }
.live-body { max-width: 980px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
@media (min-width: 820px) { .live-body { grid-template-columns: 1.1fr 1fr; align-items: start; } }
.setdots { display: flex; gap: 6px; }
.setdots i { width: 28px; height: 8px; border-radius: 9px; background: var(--card2); border: 1px solid var(--line2); }
.setdots i.done { background: var(--ok); border-color: var(--ok); } .setdots i.cur { background: var(--ac); border-color: var(--ac); }
.big-num { font-size: 44px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.rest { position: fixed; inset: 0; z-index: 55; background: rgba(4,9,18,.94); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; text-align: center; }
.ring { position: relative; width: 230px; height: 230px; }
.ring svg { transform: rotate(-90deg); }
.ring .lbl { position: absolute; inset: 0; display: grid; place-items: center; }
.ring .lbl b { font-size: 58px; font-weight: 900; font-variant-numeric: tabular-nums; }

/* ---------- varie ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); transform: translateX(-50%); z-index: 90; background: #0f1b30; border: 1px solid var(--line2); padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 650; font-size: 14px; max-width: calc(100% - 32px); animation: up .2s; }
@media (min-width: 900px) { .toast { bottom: 24px; } }
.menu { position: fixed; z-index: 70; top: 64px; right: 12px; width: 260px; background: var(--bg2); border: 1px solid var(--line2); border-radius: 16px; box-shadow: var(--shadow); padding: 8px; animation: fadeIn .12s; }
.menu button { width: 100%; text-align: left; display: flex; gap: 10px; align-items: center; padding: 11px 12px; border-radius: 10px; font-weight: 650; }
.menu button:hover { background: var(--card2); }
.menu .who { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.empty { text-align: center; padding: 34px 16px; color: var(--tx2); }
.empty .e { font-size: 36px; margin-bottom: 8px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.t th { color: var(--tx3); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.offline-bar { background: rgba(251,191,36,.12); color: #fde68a; text-align: center; font-size: 13px; padding: 6px; border-bottom: 1px solid rgba(251,191,36,.3); }
.wizard-steps { display: flex; gap: 6px; margin-bottom: 18px; } .wizard-steps i { flex: 1; height: 5px; border-radius: 9px; background: var(--card2); } .wizard-steps i.on { background: var(--ac); }

@media print {
  body { background: #fff; color: #000; }
  .topbar, .bottomnav, .sidenav, .no-print, .btn, .icon-btn { display: none !important; }
  .card, .exrow { background: #fff !important; border-color: #ccc !important; color: #000; break-inside: avoid; }
  .muted, .dim, .exrow .s, .exrow .meta { color: #333 !important; }
  main { padding: 0 !important; }
}

.btn.big.grow { flex: 1 1 220px; }
.live .player { width: min(100%, calc(40vh * 4 / 3)); margin: 0 auto; }
@media (min-width: 820px) { .live .player { width: 100%; } }

/* timer serie e pausa durante l'allenamento */
.timers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .timers { grid-template-columns: 1fr; } }
.timers > * { min-width: 0; }
.tmr .row .btn { padding: 0 10px; }
.live { overflow-x: hidden; }
.tmr { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; transition: border .2s, background .2s; }
.tmr-l { font-size: 12.5px; font-weight: 800; color: var(--tx2); }
.tmr-t { font-size: 38px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.05; text-align: center; }
.tmr.on { border-color: rgba(34,211,238,.6); background: linear-gradient(180deg, rgba(34,211,238,.10), var(--card)); }
#tm-rest.on { border-color: rgba(52,211,153,.6); background: linear-gradient(180deg, rgba(52,211,153,.12), var(--card)); }
#tm-rest.on .tmr-t { color: #a7f3d0; }
#tm-rest.warn .tmr-t { color: var(--warn); animation: blink .5s ease-in-out infinite alternate; }
@keyframes blink { to { opacity: .45; } }
.tmr .btn { white-space: nowrap; }
