/* ---------- Token: tema scuro (predefinito) ---------- */
:root {
  --bg: #0a0b0a;
  --surface: #151715;
  --surface-2: #1f221f;
  --line: #2a2e2a;
  --text: #f2f4ef;
  --muted: #8b928a;
  --faint: #596058;
  --bar-bg: rgba(10, 11, 10, .86);
  --danger: #ff6464;
  --red: #ff4d4f;
  /* colore del marchio, impostato da app.js */
  --accent: #99ff00;
  --accent-ink: #000000;
  --accent-strong: #3a6600;
  --accent-text: var(--accent);   /* testi e icone colorati */
  --field-bg: var(--surface);
  --radius: 18px;
  --tabbar-h: 50px;                 /* come le app native (49) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* sotto la tab bar: lo spazio della barra Home su iPhone, un margine minimo sugli altri telefoni */
  --bar-bottom: max(var(--safe-bottom), 8px);
  --ease: cubic-bezier(.22, .8, .24, 1);
  color-scheme: dark;
}
/* ---------- Tema chiaro ---------- */
:root[data-theme="light"] {
  --bg: #f2f3ef;
  --surface: #ffffff;
  --surface-2: #e9ebe5;
  --line: #dcdfd6;
  --text: #0f110e;
  --muted: #5f665d;
  --faint: #9aa197;
  --bar-bg: rgba(242, 243, 239, .88);
  --danger: #d93636;
  --accent-text: var(--accent-strong);
  color-scheme: light;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; overflow: hidden; }
button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0;
  cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
button:disabled { cursor: default; }
input, textarea { font: inherit; color: inherit; }
h1, h2, h3, p, ol, ul, figure { margin: 0; }
svg { display: block; }
img { display: block; }
.num { font-variant-numeric: tabular-nums; }

/* clip: la tab bar nascosta sporge sotto il bordo e non deve rendere #app scorrevole */
#app { position: absolute; inset: 0; max-width: 520px; margin: 0 auto; overflow: hidden; overflow: clip; }
#stack { position: absolute; inset: 0; }

/* ---------- Viste e transizioni ---------- */
.view {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  transition: transform .42s var(--ease), opacity .42s var(--ease);
}
.view.pushed { box-shadow: -14px 0 36px rgba(0, 0, 0, .35); }
.view.enter { transform: translateX(100%); }
.view.behind { transform: translateX(-24%); opacity: .45; pointer-events: none; }
.view.fade { opacity: 0; transition-duration: .22s; }
.view.dragging { transition: none; }

.scroll {
  flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 18px) 16px calc(var(--tabbar-h) + var(--bar-bottom) + 108px);
}
.view.pushed .scroll { padding-top: 6px; padding-bottom: calc(var(--safe-bottom) + 108px); }
.view.bare .scroll { padding-bottom: calc(var(--tabbar-h) + var(--bar-bottom) + 28px); }

/* ---------- Barra in alto delle viste interne ---------- */
.navbar {
  flex: none; display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 4px;
  padding: calc(var(--safe-top) + 4px) 10px 6px 6px; min-height: calc(var(--safe-top) + 54px);
}
.back { display: grid; place-items: center; width: 44px; height: 44px; color: var(--text); }
.back svg { width: 26px; height: 26px; }
.nav-title { overflow: hidden; font-size: 18px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; text-overflow: ellipsis; }
.nav-right { display: flex; justify-content: flex-end; min-width: 44px; }
.link-btn { padding: 8px 6px; color: var(--accent-text); font-size: 15px; font-weight: 700; }
.icon-seg { display: flex; gap: 3px; padding: 3px; border-radius: 12px; background: var(--surface); }
.icon-seg button { display: grid; place-items: center; width: 38px; height: 32px; border-radius: 9px; color: var(--muted); }
.icon-seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.icon-seg svg { width: 18px; height: 18px; }

/* ---------- Testata delle sezioni ---------- */
.eyebrow { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.hero h1 { margin-top: 4px; font-size: 32px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }
.bell { position: relative; flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--surface); }
.bell svg { width: 22px; height: 22px; }
.badge {
  position: absolute; top: -5px; right: -5px; display: grid; place-items: center;
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 800; box-shadow: 0 0 0 2px var(--bg);
}
.badge-inline { display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--red); color: #fff; font-size: 12px; font-weight: 800; }

/* ---------- Titoli e testi ---------- */
.section-title { margin: 28px 2px 12px; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.section-title.first { margin-top: 2px; }
.group-title { margin: 24px 2px 10px; color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.hint-text { margin: 14px 2px 0; color: var(--muted); font-size: 14px; line-height: 1.42; }
.muted { margin-top: 6px; color: var(--muted); font-size: 14px; line-height: 1.42; }
.muted-inline { color: var(--muted); font-weight: 600; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 24px 20px; color: var(--muted); text-align: center; }
.empty svg { width: 40px; height: 40px; color: var(--faint); }
.empty p { font-size: 15px; line-height: 1.42; }
.fineprint { margin-top: 18px; color: var(--faint); font-size: 13px; line-height: 1.4; text-align: center; }

/* ---------- Settimana ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 18px; }
.day {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 0 9px; border-radius: 14px; background: var(--surface); color: var(--muted);
  transition: background .2s, color .2s, transform .12s;
}
.day:active { transform: scale(.94); }
.day:disabled { opacity: .35; }
.day .dn { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.day .dd { color: var(--text); font-size: 17px; font-weight: 700; }
.day .dm { font-size: 11px; font-weight: 600; }
.day .dot { width: 6px; height: 6px; border-radius: 50%; }
.day.train .dot { background: var(--faint); }
.day.done .dot { background: var(--accent); opacity: .55; }
.day.done .dot.full, .v-oggi .day.done .dot { opacity: 1; }
.day.today .dn { color: var(--accent-text); }
.day[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.day[aria-pressed="true"] .dd, .day[aria-pressed="true"].today .dn { color: var(--bg); }
.day[aria-pressed="true"].train .dot { background: var(--bg); }
.day-scroller { display: flex; gap: 6px; margin: 14px -16px 0; padding: 0 16px 4px; overflow-x: auto; scrollbar-width: none; }
.day-scroller::-webkit-scrollbar { display: none; }
.day-scroller .day { flex: 0 0 58px; }

/* ---------- Card ---------- */
.card { padding: 18px; border-radius: var(--radius); background: var(--surface); }
.card + .card { margin-top: 12px; }
.wc-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.pill { padding: 5px 10px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.pill.ghost { background: var(--surface-2); color: var(--muted); }
.pill-new { padding: 3px 8px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 800; }
.pill-done { padding: 3px 8px; border-radius: 99px; background: var(--surface-2); color: var(--accent-text); font-size: 11px; font-weight: 800; }
.wc-when { color: var(--muted); font-size: 14px; font-weight: 600; }
.wc-title { font-size: 32px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }
.wc-focus { margin-top: 5px; color: var(--muted); font-size: 15px; }
.stats { display: flex; gap: 22px; margin-top: 18px; }
.stat b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 12px; font-weight: 600; }
.coach { display: flex; gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.coach small { display: block; margin-bottom: 3px; color: var(--muted); font-size: 12px; font-weight: 600; }
.coach p { font-size: 15px; line-height: 1.42; }
.coach-logo { flex: none; width: 38px; height: 38px; border-radius: 11px; object-fit: cover; }
.avatar { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); color: var(--accent-text); font-size: 14px; font-weight: 800; }
.avatar.big { width: 56px; height: 56px; font-size: 22px; }
.progress { height: 6px; margin-top: 18px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .5s var(--ease); }
.progress-label { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.rest-card p { margin-top: 10px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.values .value-row, .acc-body .value-row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; font-size: 15px; }
.values { padding-top: 6px; padding-bottom: 6px; }
.values .value-row + .value-row, .acc-body .value-row + .value-row { border-top: 1px solid var(--line); }
.value-row span { color: var(--muted); }
.value-row b { font-weight: 700; text-align: right; }
.value-row em { margin-left: 6px; color: var(--muted); font-size: 12px; font-style: normal; font-weight: 600; }

/* ---------- Liste ---------- */
.list { display: flex; flex-direction: column; border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; text-align: left; transition: background .15s; }
.row + .row { border-top: 1px solid var(--line); }
.row:active { background: var(--surface-2); }
.row-ic { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--surface-2); color: var(--accent-text); }
.row-ic svg { width: 20px; height: 20px; }
.row-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-title { font-size: 16px; font-weight: 600; }
.row-sub { color: var(--muted); font-size: 13px; line-height: 1.35; }
.row-end { display: flex; align-items: center; gap: 8px; color: var(--faint); }
.row-end svg { width: 18px; height: 18px; }
.danger-row { margin-top: 12px; border-radius: var(--radius); background: var(--surface); color: var(--danger); }
.danger-row .row-ic { color: var(--danger); }
.notif.unread .row-title { font-weight: 800; }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent-text); }

/* ---------- Coach ---------- */
.coach-card { display: flex; align-items: center; gap: 14px; }
.coach-card .coach-logo { width: 56px; height: 56px; border-radius: 16px; }
.coach-card b { font-size: 16px; }
.coach-card p { margin-top: 2px; color: var(--muted); font-size: 14px; }
.next-appt { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; }
.next-appt > svg { width: 18px; height: 18px; color: var(--faint); }
.date-chip {
  flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 52px; height: 56px; border-radius: 14px; background: var(--accent); color: var(--accent-ink);
  font-size: 12px; font-weight: 700; text-transform: uppercase;
}
.date-chip b { font-size: 21px; line-height: 1.05; }
.hub { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-height: 132px; padding: 16px; border-radius: var(--radius); background: var(--surface); text-align: left; transition: transform .12s; }
.tile:active { transform: scale(.97); }
.tile-ic { position: relative; display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: auto; border-radius: 12px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-text); }
.tile-ic svg { width: 22px; height: 22px; }
.tile-title { margin-top: 14px; font-size: 17px; font-weight: 700; }
.tile-sub { color: var(--muted); font-size: 13px; line-height: 1.3; }

/* chat */
.chat-scroll { display: flex; flex-direction: column; gap: 6px; padding-bottom: calc(var(--safe-bottom) + 96px) !important; }
.day-sep { align-self: center; margin: 12px 0 6px; padding: 4px 10px; border-radius: 99px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 700; }
.msg { max-width: 82%; padding: 10px 14px 7px; border-radius: 18px; font-size: 15px; line-height: 1.42; }
.msg p { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.in { align-self: flex-start; border-bottom-left-radius: 6px; background: var(--surface); }
.msg.out { align-self: flex-end; border-bottom-right-radius: 6px; background: var(--accent); color: var(--accent-ink); }
.msg time { display: block; margin-top: 3px; font-size: 11px; opacity: .6; text-align: right; }
.ref { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 14px; font-weight: 600; text-align: left; }
.ref span { flex: 1; }
.ref svg { width: 18px; height: 18px; color: var(--accent-text); }
.ref svg:last-child { color: var(--faint); }
.composer {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(var(--safe-bottom) + 10px);
  background: var(--bar-bg); -webkit-backdrop-filter: saturate(160%) blur(20px); backdrop-filter: saturate(160%) blur(20px);
  border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; display: block; min-height: 44px; max-height: 120px; padding: 11px 16px;
  border: 1px solid var(--line); border-radius: 22px; outline: none; resize: none;
  background: var(--surface); font-size: 16px; line-height: 1.35;
}
.composer textarea:focus { border-color: var(--accent-text); }
.send { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); }
.send svg { width: 20px; height: 20px; }

/* prenotazioni e appuntamenti */
.slot { display: flex; align-items: center; gap: 14px; width: 100%; padding: 13px 16px; text-align: left; }
.slot + .slot { border-top: 1px solid var(--line); }
.slot:active { background: var(--surface-2); }
.slot-time { flex: none; min-width: 58px; font-size: 18px; font-weight: 800; }
.slot > svg { width: 20px; height: 20px; color: var(--accent-text); }
.appt { display: flex; align-items: center; gap: 14px; }
.appt + .appt { margin-top: 10px; }
.pill-status { align-self: flex-start; margin-top: 6px; padding: 3px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; }
.pill-status.ok { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-text); }
.pill-status.off { color: var(--danger); }
.btn-small { flex: none; height: 36px; padding: 0 14px; border-radius: 10px; background: var(--surface-2); font-size: 14px; font-weight: 600; }

/* documenti */
.upload-box {
  display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 12px; padding: 22px;
  border: 1.5px dashed var(--line); border-radius: var(--radius); text-align: center; cursor: pointer;
}
.upload-box svg { width: 28px; height: 28px; color: var(--accent-text); }
.upload-box b { font-size: 16px; }
.upload-box span { color: var(--muted); font-size: 13px; }

/* ---------- Segmenti ---------- */
.seg { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; gap: 4px; margin-bottom: 14px; padding: 4px; border-radius: 14px; background: var(--surface); }
.seg button { display: flex; align-items: center; justify-content: center; gap: 6px; height: 38px; border-radius: 10px; color: var(--muted); font-size: 15px; font-weight: 600; transition: background .2s, color .2s; }
.seg button svg { width: 16px; height: 16px; }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.card .seg { background: var(--surface-2); }
.card .seg button[aria-pressed="true"] { background: var(--surface); }
.seg.small { margin: 12px 0 2px; }
.seg.small button { height: 32px; font-size: 13px; }

/* ---------- Lista esercizi ---------- */
.ex-list { display: flex; flex-direction: column; gap: 8px; padding: 0; list-style: none; }
.ex-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px; border-radius: 16px; background: var(--surface); text-align: left; transition: background .15s; }
.ex-row:active { background: var(--surface-2); }
.idx { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 14px; font-weight: 700; }
.idx svg { width: 20px; height: 20px; }
.ex-row.done .idx { background: var(--accent); color: var(--accent-ink); }
.ex-row.partial .idx { box-shadow: inset 0 0 0 2px var(--accent); color: var(--text); }
.ex-main { flex: 1; min-width: 0; }
.ex-name, .ex-sub { display: block; }
.ex-name { overflow: hidden; font-size: 16px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.ex-row.done .ex-name { color: var(--muted); }
.ex-sub { margin-top: 3px; color: var(--muted); font-size: 13px; }
.ex-end { flex: none; color: var(--faint); font-size: 13px; font-weight: 700; }
.ex-end svg { width: 18px; height: 18px; }
.superset { border-radius: 16px; background: var(--surface); overflow: hidden; }
.ss-label { display: flex; align-items: baseline; gap: 8px; padding: 12px 14px 0; color: var(--accent-text); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.ss-label span { color: var(--muted); font-weight: 500; letter-spacing: 0; text-transform: none; }
.superset .ex-row { border-radius: 0; background: transparent; }
.superset li + li .ex-row { border-top: 1px solid var(--line); }

/* ---------- Pulsanti ---------- */
.cta {
  position: absolute; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--bar-bottom));
  display: flex; gap: 10px; padding: 18px 16px 12px;
  background: linear-gradient(to top, var(--bg) 62%, transparent);
  pointer-events: none;
}
.cta > * { pointer-events: auto; }
.view.pushed .cta { bottom: 0; padding-bottom: calc(var(--safe-bottom) + 12px); }
[data-hand="sinistra"] .cta, [data-hand="sinistra"] .composer { flex-direction: row-reverse; }
.btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0;
  height: 54px; padding: 0 18px; border-radius: 16px;
  font-size: 17px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap;
  transition: transform .12s, background .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn svg { flex: none; width: 20px; height: 20px; }
.btn span { overflow: hidden; text-overflow: ellipsis; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-fit { flex: 0 0 auto; }
.btn.wide { width: 100%; margin-top: 16px; }
.btn.pulse { animation: pulse 1.2s var(--ease) 2; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 0%, transparent); }
}
.icon-btn { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.danger { width: 100%; height: 50px; margin-top: 12px; border-radius: 14px; background: var(--surface); color: var(--danger); font-weight: 600; }
.btn-text { height: 46px; color: var(--muted); font-size: 16px; font-weight: 600; }

/* ---------- Dettaglio esercizio ---------- */
.video {
  position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 16 / 9;
  margin-bottom: 18px; border-radius: var(--radius); overflow: hidden;
  background:
    radial-gradient(90% 120% at 85% 110%, color-mix(in srgb, var(--accent) 22%, transparent) 0%, transparent 55%),
    radial-gradient(120% 90% at 15% 0%, #2b2f2b 0%, #141614 65%);
}
.video .play { display: grid; place-items: center; width: 62px; height: 62px; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); transition: transform .15s; }
.video:active .play { transform: scale(.92); }
.video .play svg { width: 26px; height: 26px; margin-left: 4px; }
.video .vlabel { position: absolute; left: 14px; bottom: 12px; color: rgba(255, 255, 255, .7); font-size: 13px; font-weight: 600; }
.video .vcode { position: absolute; right: 14px; top: 10px; color: rgba(255, 255, 255, .08); font-size: 64px; font-weight: 900; letter-spacing: -.05em; }
.ex-title { margin-top: 6px; font-size: 28px; font-weight: 800; letter-spacing: -.025em; line-height: 1.1; }
.targets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.target { padding: 12px; border-radius: 14px; background: var(--surface); }
.target span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.target b { display: block; margin-top: 4px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.target small { color: var(--muted); font-size: 12px; font-weight: 600; }
.ss-banner { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 13%, transparent); font-size: 14px; line-height: 1.4; }
.ss-banner b { color: var(--accent-text); }
.note { margin-top: 12px; padding: 14px 16px; border-radius: 14px; background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); font-size: 15px; line-height: 1.45; }
.note small { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.sets { margin-top: 26px; }
.sets-head, .set-row { display: grid; grid-template-columns: 30px 1fr 74px 74px 48px; gap: 8px; align-items: center; }
.sets.no-kg .sets-head, .sets.no-kg .set-row { grid-template-columns: 30px 1fr 100px 48px; }
.sets-head { padding: 0 4px 8px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.sets-head span:nth-child(n+3) { text-align: center; }
.set-row { margin: 0 -4px; padding: 5px 8px; border-radius: 14px; transition: background .25s; }
.set-row + .set-row { margin-top: 2px; }
.set-row .n { color: var(--muted); font-weight: 700; text-align: center; }
.set-row .prev { color: var(--muted); font-size: 14px; }
.set-row input {
  width: 100%; height: 46px; border: 1px solid transparent; border-radius: 12px; outline: none;
  background: var(--surface); text-align: center; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums;
  transition: background .25s, border-color .15s; -webkit-appearance: none; appearance: none;
}
.set-row input:focus { border-color: var(--accent-text); }
.set-row input::placeholder { color: var(--faint); }
.check { display: grid; place-items: center; width: 48px; height: 46px; border-radius: 12px; background: var(--surface); color: var(--faint); transition: background .2s, color .2s, transform .12s; }
.check:active { transform: scale(.9); }
.check svg { width: 22px; height: 22px; }
.set-row.done { background: color-mix(in srgb, var(--accent) 11%, transparent); }
.set-row.done input { background: transparent; }
.set-row.done .n { color: var(--accent-text); }
.set-row.done .check { background: var(--accent); color: var(--accent-ink); }
.set-row.just .check { animation: pop .35s var(--ease); }
@keyframes pop { 0% { transform: scale(.7); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
.add-set { width: 100%; height: 46px; margin-top: 10px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: 15px; font-weight: 600; }

/* ---------- Check giornaliero e calendario ---------- */
.cal { margin-bottom: 14px; padding: 14px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head button { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; }
.cal-head svg { width: 20px; height: 20px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-wd { padding: 4px 0; color: var(--muted); font-size: 11px; font-weight: 700; }
.cal-day { position: relative; height: 40px; border-radius: 12px; font-weight: 600; }
.cal-day.today { color: var(--accent-text); }
.cal-day[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.cal-day:disabled { opacity: .3; }
.cal-day i { position: absolute; left: 50%; bottom: 5px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--accent); opacity: .55; }
.cal-day i.full { opacity: 1; }

/* ---------- Moduli ---------- */
.form { display: flex; flex-direction: column; gap: 18px; margin-top: 14px; }
.form .group-title { margin: 8px 2px -6px; }
.field-label { margin-bottom: 8px; font-size: 15px; font-weight: 700; line-height: 1.35; }
.req { color: var(--accent-text); }
.field input[type="text"], .field input[type="date"], .field textarea, .opt input[type="time"] {
  width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; outline: none;
  background: var(--field-bg); font-size: 16px; -webkit-appearance: none; appearance: none;
}
.field textarea { height: auto; min-height: 88px; padding: 12px 14px; line-height: 1.4; resize: none; }
.field input:focus, .field textarea:focus { border-color: var(--accent-text); }
.input-unit { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--field-bg); }
.input-unit:focus-within { border-color: var(--accent-text); }
.field .input-unit input { border: 0; background: transparent; font-weight: 600; }
.input-unit span { padding-right: 14px; color: var(--muted); font-size: 14px; font-weight: 600; }
.level, .yesno { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.yesno { grid-template-columns: 1fr 1fr; }
.scale { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 4px; }
.level button, .yesno button, .scale button, .choices button {
  height: 46px; border-radius: 12px; background: var(--field-bg); font-weight: 700; transition: background .15s, color .15s;
}
.scale button { height: 42px; border-radius: 10px; font-size: 15px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices button { height: 40px; padding: 0 14px; border-radius: 99px; font-size: 14px; font-weight: 600; }
.level button[aria-pressed="true"], .yesno button[aria-pressed="true"], .scale button[aria-pressed="true"], .choices button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.level-words { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 12px; }
.range { display: flex; align-items: center; gap: 14px; }
.range input { flex: 1; accent-color: var(--accent); }
.range output { min-width: 48px; font-weight: 800; text-align: right; }
.photo-pick { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; height: 150px; border: 1.5px dashed var(--line); border-radius: 14px; color: var(--muted); font-size: 14px; overflow: hidden; cursor: pointer; }
.photo-pick svg { width: 26px; height: 26px; }
.photo-pick img { width: 100%; height: 100%; object-fit: cover; }
.grid-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-fields .field-label { font-size: 14px; }
details.advanced summary { display: flex; align-items: center; gap: 6px; color: var(--accent-text); font-weight: 700; list-style: none; cursor: pointer; }
details.advanced summary::-webkit-details-marker { display: none; }
details.advanced summary svg { width: 18px; height: 18px; transition: transform .2s; }
details.advanced[open] summary svg { transform: rotate(180deg); }
details.advanced .field { margin-top: 18px; }

/* ---------- Fisarmonica (storico misure e questionari) ---------- */
.acc { padding: 0; overflow: hidden; }
.acc + .acc { margin-top: 10px; }
.acc-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 16px; text-align: left; }
.acc-head > svg { width: 20px; height: 20px; color: var(--muted); transition: transform .2s; }
.acc.open .acc-head > svg { transform: rotate(180deg); }
.acc-body { padding: 0 16px 8px; }
.qa { display: flex; flex-direction: column; gap: 3px; padding: 11px 0; }
.qa + .qa { border-top: 1px solid var(--line); }
.qa span { color: var(--muted); font-size: 13px; }
.qa b { font-size: 15px; font-weight: 600; white-space: pre-wrap; }

/* ---------- Impostazioni ---------- */
.opt { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 12px 16px; font-size: 16px; font-weight: 600; text-align: left; }
.opt + .opt { border-top: 1px solid var(--line); }
.opt > span:not(.switch) { flex: 1; }
.opt > svg:first-child { width: 20px; height: 20px; color: var(--muted); }
.opt > svg:last-child { width: 20px; height: 20px; color: var(--accent-text); visibility: hidden; }
.opt[aria-pressed="true"] > svg:last-child { visibility: visible; }
.opt input[type="time"] { width: auto; height: 38px; padding: 0 10px; }
.switch { position: relative; flex: none; width: 50px; height: 30px; border-radius: 99px; background: var(--surface-2); transition: background .2s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s var(--ease); }
[aria-checked="true"] .switch { background: var(--accent); }
[aria-checked="true"] .switch i { transform: translateX(20px); }
.swatches { display: flex; gap: 12px; margin-top: 14px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .15); transition: transform .15s, box-shadow .2s; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text); }

/* ---------- Profilo, info ---------- */
.profile { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.profile b { font-size: 18px; }
.profile p { color: var(--muted); font-size: 14px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand img { width: 64px; height: 64px; border-radius: 16px; }
.brand b { font-size: 18px; }
.brand p { margin-top: 2px; color: var(--muted); font-size: 14px; }
.steps { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; padding: 0; list-style: none; counter-reset: s; }
.steps li { display: flex; gap: 12px; font-size: 15px; line-height: 1.4; counter-increment: s; }
.steps li::before { content: counter(s); flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); color: var(--accent-text); font-size: 13px; font-weight: 800; }
.inline-ic { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; color: var(--accent-text); }

/* ---------- Misure e foto ---------- */
.kcal { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.kcal b { font-size: 42px; font-weight: 800; letter-spacing: -.04em; }
.kcal span { color: var(--muted); font-size: 15px; font-weight: 600; }
.spark { width: 100%; height: 86px; margin-top: 14px; overflow: visible; }
.spark .line { fill: none; stroke: var(--accent-text); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark .area { fill: color-mix(in srgb, var(--accent) 16%, transparent); }
.delta { color: var(--accent-text); font-size: 15px; font-weight: 700; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.photo { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; aspect-ratio: 3 / 4; border: 1.5px dashed var(--line); border-radius: 14px; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.photo svg { width: 22px; height: 22px; color: var(--accent-text); }
.photo-thumb { position: relative; aspect-ratio: 3 / 4; border-radius: 14px; background: var(--surface); overflow: hidden; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb figcaption { position: absolute; left: 6px; bottom: 6px; padding: 2px 8px; border-radius: 99px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; font-weight: 700; }

/* ---------- Alimentazione ---------- */
.macro { margin-top: 16px; }
.macro-top { display: flex; justify-content: space-between; font-size: 15px; font-weight: 600; }
.macro-top span { color: var(--muted); }
.bar { height: 8px; margin-top: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .5s var(--ease); }
.bar.c i { opacity: .7; }
.bar.f i { opacity: .45; }
.meal + .meal { margin-top: 10px; }
.meal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.meal-head b { margin-right: 8px; font-size: 17px; }
.meal-kcal { color: var(--muted); font-size: 14px; font-weight: 700; }
.foods { margin-top: 8px; padding: 0; list-style: none; }
.foods li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 15px; }
.foods li + li { border-top: 1px solid var(--line); }
.foods b { font-weight: 600; white-space: nowrap; }
.meal-macros { margin-top: 6px; color: var(--muted); font-size: 13px; }
.tips { display: flex; flex-direction: column; gap: 12px; padding: 0; list-style: none; }
.tips li { display: flex; gap: 12px; font-size: 15px; line-height: 1.42; }
.tips li::before { content: ""; flex: none; width: 6px; height: 6px; margin-top: 8px; border-radius: 50%; background: var(--accent); }

/* ---------- Tab bar ---------- */
#tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--bar-bottom)); padding-bottom: var(--bar-bottom);
  background: var(--bar-bg); -webkit-backdrop-filter: saturate(160%) blur(20px); backdrop-filter: saturate(160%) blur(20px);
  border-top: 1px solid var(--line);
  transition: transform .42s var(--ease);
}
#tabbar.hidden { transform: translateY(100%); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; padding-top: 7px; color: var(--faint); font-size: 10.5px; font-weight: 600; transition: color .2s; }
.tab-ic { position: relative; }
.tab svg { width: 24px; height: 24px; }
.tab .badge { top: -4px; right: -9px; }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"] svg { color: var(--accent-text); }

/* ---------- Foglio dal basso ---------- */
.backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .5); opacity: 0; transition: opacity .35s; }
.sheet {
  --field-bg: var(--surface-2);
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 520px; max-height: 92dvh; margin: 0 auto; overflow-y: auto; overscroll-behavior: contain;
  padding: 10px 16px calc(var(--safe-bottom) + 16px);
  border-radius: 26px 26px 0 0; background: var(--surface);
  transform: translateY(100%); transition: transform .42s var(--ease);
}
.sheet .card { background: var(--surface-2); }
.sheet .values .value-row + .value-row { border-color: var(--line); }
.sheet-open .backdrop { opacity: 1; }
.sheet-open .sheet { transform: none; }
.grabber { width: 40px; height: 5px; margin: 0 auto 16px; border-radius: 99px; background: var(--line); }
.sheet h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet .lead { margin-top: 6px; color: var(--muted); font-size: 15px; line-height: 1.4; }
.sheet > .field-label { display: flex; margin: 22px 0 10px; }
.rpe { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.rpe button { height: 46px; border-radius: 10px; background: var(--surface-2); font-weight: 700; transition: background .15s, color .15s; }
.rpe button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
#note { display: block; width: 100%; min-height: 96px; padding: 12px 14px; border: 1px solid transparent; border-radius: 14px; outline: none; resize: none; background: var(--surface-2); font-size: 16px; line-height: 1.4; }
#note:focus { border-color: var(--accent-text); }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; }
.sheet-actions .btn { flex: none; }

/* ---------- Fine allenamento ---------- */
.done-hero { padding-top: 24px; text-align: center; }
.done-badge { display: grid; place-items: center; width: 92px; height: 92px; margin: 0 auto 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); animation: badge .6s var(--ease) both; }
.done-badge svg { width: 46px; height: 46px; }
@keyframes badge { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
.done-hero h1 { font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.done-hero p { margin-top: 8px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.grid-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 26px; }
.grid-stats .target b { font-size: 24px; }
.quote { margin-top: 12px; padding: 14px 16px; border-radius: 14px; background: var(--surface); color: var(--muted); font-size: 15px; line-height: 1.45; }

/* ---------- Avviso installazione ---------- */
.hint { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; padding: 14px; border-radius: 16px; background: var(--surface); font-size: 14px; line-height: 1.42; }
.hint .hint-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); color: var(--accent-text); }
.hint .hint-icon svg { width: 20px; height: 20px; }
.hint .x { flex: none; margin: -4px -4px 0 auto; padding: 6px; color: var(--muted); }
.hint .x svg { width: 18px; height: 18px; }
.hint .btn { height: 40px; margin-top: 10px; font-size: 15px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(var(--safe-top) + 10px); z-index: 30;
  width: max-content; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 16px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600; line-height: 1.35; text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  opacity: 0; transform: translate(-50%, -16px); pointer-events: none;
  transition: opacity .3s, transform .4s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .view, #tabbar, .sheet, .toast { transition-duration: .01s; }
  .done-badge, .set-row.just .check, .btn.pulse { animation: none; }
}
