/* Tempra — stile di casa (STILE.md §9) con accento blu #2448ff, arancione solo per i test */
:root {
  --bg: #F6F1E7; --side: #EFE8DA; --paper: #FBF8F1; --ink: #2A2520; --soft: #5C544B; --faint: #6F665A;
  --line: #E0D7C6; --hover: rgba(60,40,20,.06); --mark: #F4DD8A; --danger: #B8492F;
  --acc: #2448ff; --acc-ink: #fff; --acc-bg: #E6EAFB; --test: #D2470F; --test-bg: #FBE6DA; --ok: #2F6B52;
  --acc2: #AEBDFF; --m0: #E6DFD2; --sk: #D3CAB9;
  --shadow: 0 1px 2px rgba(40,30,20,.05), 0 8px 24px rgba(40,30,20,.06);
  --serif: "Iowan Old Style", Palatino, Georgia, serif;
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --num: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  --tabs-h: 64px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1B1917; --side: #161412; --paper: #23201D; --ink: #E9E2D6; --soft: #B0A79A; --faint: #9A9083;
    --line: #34302B; --hover: rgba(255,240,220,.07); --mark: #6B5A1E; --danger: #EE8C73;
    --acc: #7D93FF; --acc-ink: #10131f; --acc-bg: #232842; --test: #FF8A55; --test-bg: #3A2418; --ok: #8CCBA8;
    --acc2: #4B5FB8; --m0: #3A3530; --sk: #4F4943;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1B1917; --side: #161412; --paper: #23201D; --ink: #E9E2D6; --soft: #B0A79A; --faint: #9A9083;
  --line: #34302B; --hover: rgba(255,240,220,.07); --mark: #6B5A1E; --danger: #EE8C73;
  --acc: #7D93FF; --acc-ink: #10131f; --acc-bg: #232842; --test: #FF8A55; --test-bg: #3A2418; --ok: #8CCBA8;
    --acc2: #4B5FB8; --m0: #3A3530; --sk: #4F4943;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--ui); min-height: 100dvh;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); overscroll-behavior-y: none; }
body.with-timer { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 104px); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--acc) 55%, transparent); outline-offset: 2px; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* barra in alto */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); min-height: 52px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font: 600 19px var(--serif); }
.brand img { border-radius: 7px; }
#topRight { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--soft); }
main { max-width: 560px; margin: 0 auto; padding: 16px; outline: none; }
h1 { font: 600 26px/1.2 var(--serif); margin: 4px 0 4px; letter-spacing: -.01em; }
h2 { font: 600 20px/1.25 var(--serif); margin: 24px 0 8px; }
h3 { font: 600 17px/1.3 var(--ui); margin: 0; }
p { margin: 8px 0; }
.soft { color: var(--soft); } .faint { color: var(--faint); font-size: 14px; }
.small { font-size: 14px; }

/* settimane */
.weeks { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 8px; margin: 8px -16px 4px; scrollbar-width: none; scroll-snap-type: x proximity; }
.weeks::-webkit-scrollbar { display: none; }
.wk { flex: 0 0 auto; min-width: 56px; min-height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font: 600 17px var(--num); scroll-snap-align: start; padding: 4px 10px; }
.wk small { font: 500 11px var(--ui); color: var(--faint); }
.wk[aria-pressed="true"] { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.wk[aria-pressed="true"] small { color: inherit; opacity: .85; }
.wk.done:not([aria-pressed="true"]) { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }

/* schede */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
a.card { display: block; color: inherit; text-decoration: none; }
a.card:active, button.card:active { transform: scale(.99); }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.day-letter { font: 700 15px var(--ui); color: var(--acc); }
.pill { display: inline-flex; align-items: center; gap: 4px; font: 600 12px var(--ui); padding: 3px 9px; border-radius: 99px; background: var(--side); color: var(--soft); white-space: nowrap; }
.pill.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.acc { background: var(--acc-bg); color: var(--acc); }
.pill.test { background: var(--test-bg); color: var(--test); }
.exlist { margin: 8px 0 0; padding: 0; list-style: none; font-size: 14px; color: var(--soft); }
.exlist li { padding: 2px 0; display: flex; justify-content: space-between; gap: 8px; }
.exlist b { font-weight: 500; color: var(--ink); }
.resume { background: var(--acc); color: var(--acc-ink); border: 0; }
.resume .soft { color: inherit; opacity: .85; }

.warn { border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 14px; background: var(--acc-bg); color: var(--ink); border-left: 4px solid var(--acc); }
.warn.test { background: var(--test-bg); border-left-color: var(--test); }

/* pulsanti */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--paper); font-weight: 600; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font-size: 18px; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn:active { filter: brightness(.95); }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; }
.sticky-cta { position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px); margin-top: 16px; }

/* allenamento */
.wo-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.clock { font: 600 17px var(--num); color: var(--ink); }
.group { position: relative; }
.group.multi { border-left: 4px solid var(--acc); padding-left: 8px; margin-left: -2px; }
.group-label { font: 700 12px var(--ui); color: var(--acc); text-transform: uppercase; letter-spacing: .06em; margin: 16px 0 -4px; }
.ex { padding: 14px 12px 10px; }
.ex.is-test { border-color: color-mix(in srgb, var(--test) 45%, var(--line)); }
.ex-head { display: flex; align-items: flex-start; gap: 8px; }
.ex-title { flex: 1; min-width: 0; }
.ex-title h3 { font-size: 18px; }
.ex-title .target { font: 600 15px var(--num); color: var(--acc); margin-top: 2px; }
.ex.is-test .target { color: var(--test); }
.more { width: 44px; height: 44px; border-radius: 10px; border: 0; background: transparent; color: var(--soft); font-size: 22px; flex: 0 0 auto; margin: -8px -6px 0 0; }
.info { font-size: 13px; color: var(--faint); margin-top: 4px; }
.plates { font: 500 13px var(--num); color: var(--soft); margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.plate { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--side); border: 1px solid var(--line); }
.sets { width: 100%; border-collapse: collapse; margin-top: 8px; table-layout: fixed; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.sets th { font: 600 11px var(--ui); color: var(--faint); text-transform: uppercase; letter-spacing: .05em; text-align: center; padding: 4px 2px; }
.sets td { padding: 3px 2px; text-align: center; vertical-align: middle; }
.sets tr.done td { background: color-mix(in srgb, var(--ok) 12%, transparent); }
.sets tr.done td:first-child { border-radius: 8px 0 0 8px; } .sets tr.done td:last-child { border-radius: 0 8px 8px 0; }
.sets tr.wu .lbl { color: var(--faint); }
.lbl { font: 700 15px var(--num); }
.lbl.a { color: var(--test); }
.prev { font: 13px var(--num); color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sets input, .sets select { display: block; width: 100%; height: 44px; margin: 0; border-radius: 8px; border: 1px solid var(--line); background: var(--bg);
  text-align: center; text-align-last: center; font: 600 17px/44px var(--num); padding: 0; -webkit-appearance: none; appearance: none; }
.sets select { font-size: 14px; color: var(--faint); background-image: none; }
.sets select:has(option:checked:not([value=""])) { color: var(--ink); font-weight: 600; }
.sets input::placeholder { color: var(--faint); opacity: .6; font-weight: 500; }
.sets .c-lbl { width: 36px; } .sets .c-kg { width: 70px; } .sets .c-reps { width: 60px; } .sets .c-rpe { width: 56px; } .sets .c-ok { width: 52px; }
.sets th.c-prev, .sets td.prev { text-align: center; }
.check { display: grid; place-items: center; width: 46px; height: 44px; margin: 0 auto; padding: 0; border-radius: 10px; border: 1.5px solid var(--line); background: var(--paper); color: var(--line); }
.check svg { display: block; }
@media (max-width: 380px) {
  .sets .c-lbl { width: 30px; } .sets .c-kg { width: 64px; } .sets .c-reps { width: 54px; } .sets .c-rpe { width: 50px; } .sets .c-ok { width: 48px; }
  .sets input { font-size: 16px; } .sets select { font-size: 13px; } .prev { font-size: 12px; }
  .sets th { font-size: 10px; letter-spacing: .02em; }
  .check { width: 42px; }
}
tr.done .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.ex-note { width: 100%; min-height: 44px; margin-top: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); padding: 10px; font-size: 15px; resize: vertical; }
.ex-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.tag-sub { font-size: 13px; color: var(--test); }

/* timer */
body.with-timer .toast { bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 108px); }
.timer { position: fixed; left: 8px; right: 8px; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 8px); z-index: 30;
  max-width: 544px; margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 16px;
  background: var(--ink); color: var(--bg); box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.timer[hidden] { display: none; }
.tmain { flex: 1; text-align: center; min-width: 0; }
.tlabel { font-size: 12px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tclock { font: 700 34px/1.1 var(--num); font-variant-numeric: tabular-nums; }
.tbar { height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--bg) 25%, transparent); overflow: hidden; margin-top: 4px; }
.tbar i { display: block; height: 100%; background: var(--acc); width: 0; transition: width .25s linear; }
.tbtn { min-width: 56px; min-height: 52px; border-radius: 12px; border: 0; background: color-mix(in srgb, var(--bg) 16%, transparent); color: inherit; font: 600 16px var(--num); }
.tskip { background: var(--acc); color: var(--acc-ink); }
.timer.ending .tclock { color: var(--mark); }

/* schede in basso */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; justify-content: space-around;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); background: color-mix(in srgb, var(--side) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.tabs a { flex: 1; max-width: 140px; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--faint); font: 600 12px var(--ui); border-radius: 10px; }
.tabs a svg { width: 24px; height: 24px; }
.tabs a[aria-current="page"] { color: var(--acc); }
.tabs a.live { color: var(--acc); }
.tabs a.live::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--test); position: absolute; margin: -22px 0 0 22px; }

/* tabelle massimali */
.tm-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tm-row:last-child { border-bottom: 0; }
.tm-big { font: 700 24px var(--num); text-align: right; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--soft); }
.field input, .field select, .field textarea { min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); padding: 0 12px; font-size: 17px; color: var(--ink); }
.field textarea { padding: 10px 12px; min-height: 88px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; min-height: 44px; border: 0; background: var(--paper); font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--acc); color: var(--acc-ink); }

/* foglio (dialog) */
.sheet { border: 0; padding: 0; width: 100%; max-width: 560px; margin: auto auto 0; border-radius: 18px 18px 0 0; background: var(--paper); color: var(--ink);
  max-height: 88dvh; }
.sheet::backdrop { background: rgba(20,15,10,.4); }
.sheet form { padding: 20px 16px calc(env(safe-area-inset-bottom) + 16px); display: flex; flex-direction: column; gap: 12px; }
.sheet h3 { font: 600 20px var(--serif); }
.sheet .opt { min-height: 52px; text-align: left; justify-content: flex-start; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 50;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 15px; transition: .25s ease; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty { text-align: center; padding: 32px 8px; color: var(--soft); }

/* cartelle e routine (0.2) */
.folder-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 24px; }
.folder-head h2 { margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.folder-head .more { margin: 0 -6px 0 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.linkbtn { border: 0; background: none; padding: 8px 0; min-height: 44px; }
.btn:disabled { opacity: .4; }
.btn.opt.danger { color: var(--danger); }
.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 46dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.pick-list .btn.opt { min-height: 48px; height: auto; padding-top: 10px; padding-bottom: 10px; line-height: 1.25; font-weight: 500; gap: 8px; text-align: left; }
.pick-list .grow { flex: 1; min-width: 0; }
.pick-list .faint { font-size: 12px; white-space: nowrap; }
.pick-new { border-color: var(--acc); color: var(--acc); font-weight: 600 !important; }
.ed { padding: 14px 12px 12px; }
.ed.multi { border-left: 4px solid var(--acc); }
.ed-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.ed-grid .span2 { grid-column: 1 / -1; }
.ed-grid .field { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-grid .field input { min-width: 0; padding: 0 6px; text-align: center; font: 600 17px var(--num); }
.info.bad { color: var(--danger); }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 6px; font-size: 15px; color: var(--soft); }
.check-row input { width: 22px; height: 22px; accent-color: var(--acc); }
.sheet form { overflow-y: auto; max-height: 88dvh; }

/* storico, record e grafici (0.3) */
h2.month { font-size: 17px; text-transform: capitalize; margin: 20px 0 4px; color: var(--soft); }
.card.hist { padding: 14px 16px; }
.pill.rec { background: color-mix(in srgb, var(--mark) 55%, transparent); color: var(--ink); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.tiles div { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.tiles b { display: block; font-size: 16px; white-space: nowrap; }
.tiles span { font-size: 12px; color: var(--faint); }
.rec-card { border-color: color-mix(in srgb, var(--mark) 70%, var(--line)); }
.rec-card a, .chart-cap a { color: var(--acc); }
.ex-link { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; text-decoration: none; color: inherit; min-height: 32px; }
.htab { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 15px; }
.htab th { font: 600 11px var(--ui); color: var(--faint); text-transform: uppercase; letter-spacing: .05em; text-align: center; padding: 4px 2px; }
.htab td { text-align: center; padding: 5px 2px; border-top: 1px solid var(--line); }
.htab td.lbl { font-size: 14px; } .htab td.wu { color: var(--faint); }
.htab tr.undone td { color: var(--faint); text-decoration: line-through; }
.htab tr.undone td:last-child { text-decoration: none; }
.ex-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; min-height: 52px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.ex-row:last-child { border-bottom: 0; }
.ex-row b { font-weight: 600; }
.rec-row { color: inherit; text-decoration: none; }
.tm-big small { font-size: 14px; font-weight: 500; color: var(--faint); }
.chart { display: block; width: 100%; height: auto; margin-top: 8px; touch-action: manipulation; }
.chart .bar { fill: color-mix(in srgb, var(--acc) 45%, transparent); } .chart .bar.now { fill: var(--acc); }
.chart .bar-n { font: 600 10px var(--num); fill: var(--soft); text-anchor: middle; }
.chart .ax { font: 10px var(--num); fill: var(--faint); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--acc); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--paper); stroke: var(--acc); stroke-width: 1.5; }
.chart .sel { fill: var(--acc); stroke: var(--paper); stroke-width: 2; }
.chart-cap { text-align: center; font-size: 15px; margin-top: 4px; min-height: 22px; }
.small-seg button { min-height: 38px; font-size: 14px; }
.sr:not(td):not(th) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.card.hist .day-head > span { white-space: nowrap; }

/* mappa muscolare (fase 4) */
.mmap { margin: 8px 0 4px; }
.mmap .bodies { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0 auto; width: min(100%, 260px); min-height: 120px; }
.mmap .bodies svg { width: 100%; height: auto; display: block; }
.mmap .outline, .mmap .nontarget { fill: var(--sk); }
.mmap .muscle { stroke: var(--paper); }
.mmap .muscle:not([data-muscle]) { fill: var(--m0); }
.mmap figcaption { text-align: center; color: var(--soft); margin-top: 6px; line-height: 1.5; }
.mmap .mk { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 4px 0 6px; vertical-align: -1px; }
.mmap .mk.pri { background: var(--acc); } .mmap .mk.sec { background: var(--acc2); }
