:root {
  --bg: #ffffff;
  --group: #f2f3f5;          /* fasce tra i blocchi */
  --field: #f2f3f5;
  --line: #e5e7eb;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #6b7280;
  --blue: #2563eb;
  --blue-press: #1d4ed8;
  --blue-soft: #eaf1ff;
  --green: #16a34a;
  --green-soft: #e9f8ef;
  --red: #dc2626;
  --red-soft: #fdecec;
  --press: #fafafa;          /* riga toccata */
  --chevron: #b6bcc5;
  --dot: #9ca3af;
  --blue-disabled: #a5b8e8;
  --selection: #cfe0ff;
  --body: #e3e6ea;           /* mappa muscoli */
  --body-inert: #f0f2f4;
  --heat: #2563eb;
  --tab-h: 60px;
  --bar-h: 52px;
  --r: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--group); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}
body.no-tabs { padding-bottom: 0; }
::selection { background: var(--selection); color: var(--text); }
input, textarea { caret-color: var(--blue); }
a { color: var(--blue); text-decoration: none; }
main { max-width: 640px; margin: 0 auto; min-height: 100vh; background: var(--group); }
h1, h2, h3, p { margin: 0; }
.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.i.sm { width: 18px; height: 18px; }
.i.xs { width: 16px; height: 16px; stroke-width: 2.6; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }

/* ---------- barra superiore ---------- */
.appbar {
  position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: 4px;
  min-height: calc(var(--bar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 4px 0;
  background: rgba(255,255,255,0.92); backdrop-filter: saturate(1.8) blur(16px); -webkit-backdrop-filter: saturate(1.8) blur(16px);
  border-bottom: 1px solid var(--line);
}
.appbar .title::first-letter { text-transform: uppercase; }
.appbar .title { max-width: 52vw; text-align: center; font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.appbar .side { display: flex; min-width: 0; }
.appbar .side.end { padding-right: 8px; }
.appbar .side.end { justify-content: flex-end; }
.bar-btn { white-space: nowrap; display: inline-flex; align-items: center; gap: 0; min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--blue); font: inherit; font-size: 17px; cursor: pointer; border-radius: 8px; }
.bar-btn:active { opacity: 0.55; }
.large-title { padding: calc(env(safe-area-inset-top) + 20px) 16px 14px; background: var(--bg); display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.large-title h1 { font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }

/* ---------- blocchi ---------- */
.block { background: var(--bg); padding: 16px; margin-top: 8px; }
.block h2 { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
.muted { color: var(--text-3); }
.small { font-size: 14px; }
.cap::first-letter { text-transform: uppercase; }

/* ---------- pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border: 0; border-radius: var(--r); font: inherit; font-weight: 600; font-size: 16px; cursor: pointer;
  background: var(--field); color: var(--text); text-decoration: none; transition: background-color 0.15s, transform 0.15s var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:active { background: var(--blue-press); }
.btn.subtle { background: var(--blue-soft); color: var(--blue); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.full { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 15px; border-radius: 8px; }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 999px; background: none; color: var(--text-3); display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn:active { background: var(--field); }

/* ---------- campi ---------- */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--field); border: 1.5px solid transparent;
  border-radius: var(--r); padding: 11px 12px; width: 100%; min-height: 46px; transition: border-color 0.15s, background-color 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--text-2); opacity: 0.85; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); background: #fff; }
textarea { resize: none; min-height: 46px; line-height: 1.4; field-sizing: content; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.bare { background: transparent; padding: 6px 0; min-height: 36px; border-radius: 0; border: 0; }
.bare:focus { background: transparent; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 32px 24px calc(env(safe-area-inset-bottom) + 32px); max-width: 420px; margin: 0 auto; background: var(--bg); }
.login .logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 20px; box-shadow: 0 6px 16px rgba(17,24,39,0.14); }
.login h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.login .lead { color: var(--text-3); margin: 4px 0 28px; }
.error { color: var(--red); font-size: 14px; min-height: 22px; margin: -4px 0 8px; }
main.login-wrap { background: var(--bg); }

/* ---------- diario ---------- */
.week { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); padding: 2px 16px 16px; }
.week div + div { padding-left: 14px; border-left: 1px solid var(--line); }
.week span { display: block; font-size: 13px; color: var(--text-3); }
.week b { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.start { background: var(--bg); padding: 0 16px 16px; }
.entry { display: block; background: var(--bg); padding: 16px; color: inherit; margin-top: 8px; }
.entry:active { background: var(--press); }
.entry .top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.entry h3 { font-size: 17px; font-weight: 600; }
.entry time { font-size: 14px; color: var(--text-3); white-space: nowrap; }
.metrics { display: flex; gap: 28px; margin: 10px 0 12px; }
.metrics span { display: block; font-size: 13px; color: var(--text-3); }
.metrics b { font-size: 16px; font-weight: 600; }
.lines { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.line { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.line .txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line .muted { white-space: nowrap; }
.month { padding: 22px 16px 0; font-size: 15px; font-weight: 600; color: var(--text-2); }
.month::first-letter { text-transform: uppercase; }

/* ---------- miniatura esercizio ---------- */
.thumb { width: 44px; height: 44px; border-radius: 999px; background: #fff; border: 1px solid var(--line); object-fit: contain; flex: none; }
.thumb.sm { width: 28px; height: 28px; }

/* ---------- mappa muscoli ---------- */
.bodymap { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 300px; margin: 0 auto; }
.bodymap svg { width: 100%; height: auto; display: block; }
.bodymap path { stroke: #fff; stroke-width: 2.5; }
.legend { display: flex; justify-content: center; gap: 18px; font-size: 13px; color: var(--text-3); margin-top: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- allenamento ---------- */
.w-head { background: var(--bg); padding: 12px 16px 14px; }
.w-title { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; padding: 4px 0; min-height: 40px; }
.w-stats { display: flex; gap: 28px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.w-stats span { display: block; font-size: 13px; color: var(--text-3); }
.w-stats b { font-size: 17px; font-weight: 600; }

.ex { background: var(--bg); margin-top: 8px; padding: 14px 0 12px; }
.ex-head { display: flex; align-items: center; gap: 12px; padding: 0 6px 0 16px; }
.ex-head a { flex: 1; min-width: 0; color: var(--blue); font-weight: 600; font-size: 17px; line-height: 1.3; }
.ex-tools { padding: 2px 16px 2px; }
.ex-tools textarea { font-size: 15px; }
.rest-pick { position: relative; display: inline-flex; align-items: center; gap: 6px; color: var(--blue); font-size: 15px; font-weight: 500; min-height: 40px; }

.sets { width: 100%; border-collapse: collapse; margin-top: 4px; }
.sets th { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; height: 30px; padding: 0 4px; text-align: center; }
.sets th:first-child, .sets td:first-child { padding-left: 16px; }
.sets th:last-child, .sets td:last-child { padding-right: 12px; }
.sets td { padding: 3px 4px; text-align: center; transition: background-color 0.2s var(--ease); }
.sets .c-set { width: 56px; text-align: left; }
.sets td.c-prev { color: var(--text-3); font-size: 15px; text-align: left; white-space: nowrap; }
.sets .c-num { width: 72px; }
.sets .c-ok { width: 56px; text-align: right; }
.set-no { border: 0; background: var(--field); border-radius: 8px; width: 40px; height: 44px; font: inherit; font-weight: 600; color: var(--text); cursor: pointer; }
.sets input { text-align: center; padding: 6px 2px; min-height: 44px; font-weight: 600; font-size: 17px; border-radius: 8px; }
.ok { width: 48px; height: 44px; border: 0; border-radius: 8px; background: var(--field); color: var(--text-3); display: inline-grid; place-items: center; cursor: pointer; transition: background-color 0.15s, color 0.15s, transform 0.2s var(--ease); }
.ok:active { transform: scale(0.9); }
tr.done td { background: var(--green-soft); }
tr.done input, tr.done .set-no { background: transparent; }
tr.done .ok { background: var(--green); color: #fff; }
tr.arm td { background: var(--red-soft); }
tr.arm .set-no { background: var(--red); color: #fff; }
.del { height: 44px; border: 0; border-radius: 8px; background: var(--red); color: #fff; font: inherit; font-weight: 600; font-size: 14px; padding: 0 10px; cursor: pointer; }
.add-set { margin: 10px 16px 0; width: calc(100% - 32px); }
.prev-empty { color: var(--text-3); }

/* menu esercizio */
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 4px; top: 42px; z-index: 6; min-width: 220px; background: #fff; border-radius: 12px; padding: 6px;
  box-shadow: 0 12px 32px rgba(17,24,39,0.16), 0 1px 3px rgba(17,24,39,0.08); animation: pop 0.16s var(--ease);
}
.menu-list button { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: none; font: inherit; padding: 11px 10px; border-radius: 8px; color: var(--text); cursor: pointer; text-align: left; }
.menu-list button:active { background: var(--field); }
.menu-list button:disabled { color: var(--text-3); opacity: 0.55; }
.menu-list .danger { color: var(--red); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }

.w-foot { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.w-foot .row { display: flex; gap: 10px; }
.w-foot .row > * { flex: 1; }
.w-foot .btn:not(.primary):not(.danger) { background: var(--bg); }

/* ---------- libreria ---------- */
.search { position: sticky; top: 0; z-index: 4; background: rgba(255,255,255,0.94); backdrop-filter: saturate(1.8) blur(16px); -webkit-backdrop-filter: saturate(1.8) blur(16px); padding: 10px 16px 12px; border-bottom: 1px solid var(--line); }
.search-box { position: relative; }
.search-box .i { position: absolute; left: 12px; top: 12px; color: var(--text-3); }
.search-box input { padding-left: 42px; }
.filters { display: flex; gap: 8px; overflow-x: auto; margin: 10px -16px 0; padding: 0 16px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.pill { position: relative; flex: none; display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 10px 0 14px; border-radius: 999px; background: var(--field); font-size: 15px; font-weight: 500; color: var(--text); white-space: nowrap; }
.pill.on { background: var(--blue); color: #fff; }
.pill.clear { border: 0; font: inherit; font-weight: 600; color: var(--blue); background: none; cursor: pointer; padding: 0 6px; }
.count { padding: 14px 16px 6px; font-size: 13px; color: var(--text-2); }
.rows { background: var(--bg); }
.row-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; width: 100%; border: 0; background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; min-height: 64px; position: relative; }
.row-item + .row-item::before { content: ""; position: absolute; left: 72px; right: 0; top: 0; border-top: 1px solid var(--line); }
.row-item:active { background: var(--press); }
.row-item .txt { flex: 1; min-width: 0; }
.row-item b { display: block; font-weight: 600; font-size: 16px; line-height: 1.3; }
.row-item small { display: block; font-size: 14px; color: var(--text-3); margin-top: 1px; }
.row-item .go { color: var(--chevron); }
.row-item .add { width: 32px; height: 32px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; flex: none; }
.more { margin: 12px 16px; width: calc(100% - 32px); }

/* ---------- dettaglio esercizio ---------- */
.media { background: #fff; display: flex; justify-content: center; padding: 8px 16px 0; }
.media video { width: min(240px, 64vw); aspect-ratio: 1; display: block; }
.ex-title { background: var(--bg); padding: 8px 16px 16px; }
.ex-title h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.ex-title p { color: var(--text-3); font-size: 15px; margin-top: 2px; }
.facts { background: var(--bg); padding: 0 16px; }
.fact { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.fact span { color: var(--text-3); }
.fact b { font-weight: 600; text-align: right; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 12px; padding: 7px 0; line-height: 1.5; }
.steps li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-weight: 700; font-size: 14px; display: grid; place-items: center; margin-top: 0; }
.chart { width: 100%; height: auto; display: block; margin-top: 4px; }
.chart .line { fill: none; stroke: var(--blue); stroke-width: 2.5; stroke-linejoin: round; }
.chart .dot { fill: #fff; stroke: var(--blue); stroke-width: 2.5; }
.chart text { fill: var(--text-3); font-size: 12px; }
.chart .grid { stroke: var(--line); }
.hist { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); color: inherit; }
.hist b { font-weight: 600; white-space: nowrap; }
.hist span { color: var(--text-3); font-size: 15px; text-align: right; }
.dock { position: sticky; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); display: flex; gap: 10px; padding: 12px 16px; background: rgba(255,255,255,0.94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); margin-top: 8px; }
.dock > * { flex: 1; padding: 0 12px; white-space: nowrap; }
.credits { font-size: 12px; color: var(--text-2); padding: 16px; line-height: 1.5; }

/* ---------- coach ---------- */
.ctx { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 6px 0 12px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: 14px; font-weight: 600; border: 0; font-family: inherit; cursor: pointer; max-width: 100%; }
.ctx span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-row { padding: 10px 16px 0; }
.chat { display: flex; flex-direction: column; gap: 8px; padding: 16px 12px 8px; }
.msg { padding: 10px 14px; border-radius: 20px; max-width: 86%; overflow-wrap: anywhere; line-height: 1.45; animation: rise 0.25s var(--ease); }
.msg.user { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--bg); border-bottom-left-radius: 6px; }
.msg p { margin: 0 0 8px; } .msg p:last-child { margin: 0; }
.msg ul, .msg ol { margin: 4px 0 8px; padding-left: 20px; }
.msg li { margin-bottom: 3px; }
.typing { align-self: flex-start; background: var(--bg); border-radius: 20px; padding: 15px 16px; display: flex; gap: 5px; }
.typing i { width: 7px; height: 7px; border-radius: 999px; background: var(--dot); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; } .typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.35; } 30% { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.intro { padding: 32px 24px 8px; text-align: center; }
.intro .badge { width: 56px; height: 56px; border-radius: 16px; background: var(--blue-soft); color: var(--blue); display: inline-grid; place-items: center; margin-bottom: 12px; }
.intro .badge .i { width: 28px; height: 28px; }
.intro h2 { font-size: 20px; font-weight: 700; }
.intro p { color: var(--text-2); font-size: 15px; margin-top: 4px; }
.sugg { display: flex; flex-direction: column; gap: 8px; padding: 16px; }
.sugg button { text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 14px; padding: 13px 14px; font: inherit; font-size: 15px; color: var(--text); cursor: pointer; }
.sugg button:active { background: var(--field); }
main.coach { padding-bottom: 76px; }
.composer { position: fixed; left: 50%; transform: translateX(-50%); width: 100%; max-width: 640px; z-index: 6; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; background: rgba(255,255,255,0.94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.composer textarea { border-radius: 22px; min-height: 44px; max-height: 140px; padding: 11px 16px; }
.send { width: 44px; height: 44px; border-radius: 999px; border: 0; background: var(--blue); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.send:disabled { background: var(--blue-disabled); }
.disclaimer { text-align: center; font-size: 12px; color: var(--text-2); padding: 4px 16px 8px; }

/* ---------- profilo ---------- */
.me { background: var(--bg); padding: 4px 16px 20px; display: flex; align-items: center; gap: 14px; }
.avatar { width: 56px; height: 56px; border-radius: 999px; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 700; text-transform: uppercase; }
.me b { font-size: 20px; font-weight: 700; display: block; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--field); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; font: inherit; font-weight: 600; min-height: 40px; border-radius: 8px; color: var(--text-2); cursor: pointer; transition: background-color 0.2s var(--ease); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(17,24,39,0.12); }
.notice { background: var(--blue-soft); padding: 14px 16px; display: flex; gap: 12px; margin-top: 8px; }
.notice .i { color: var(--blue); margin-top: 1px; }
.notice b { display: block; }
.notice p { font-size: 15px; color: var(--text-2); margin-top: 2px; }

/* ---------- tab bar, timer, toast ---------- */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center;
  background: rgba(255,255,255,0.94); backdrop-filter: saturate(1.8) blur(16px); -webkit-backdrop-filter: saturate(1.8) blur(16px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
#nav a { flex: 1; max-width: 140px; height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-3); font-size: 11px; font-weight: 500; }
#nav a .i { width: 24px; height: 24px; }
#nav a.on { color: var(--blue); }
#timer {
  position: fixed; z-index: 11; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 10px);
  width: min(608px, calc(100% - 24px)); background: #fff; border-radius: 16px; padding: 10px 10px 12px 16px;
  display: flex; align-items: center; gap: 6px; overflow: hidden;
  box-shadow: 0 12px 32px rgba(17,24,39,0.18), 0 2px 6px rgba(17,24,39,0.08);
}
#timer .t-lbl { display: block; font-size: 13px; color: var(--text-2); font-weight: 500; }
#timer .time { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.1; }
#timer .grow { flex: 1; }
#timer button { min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: var(--field); color: var(--text); font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; }
#timer button.skip { background: var(--blue); color: #fff; }
#timer .bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--blue); transition: width 0.25s linear; }
#timer.finished { background: var(--green); color: #fff; }
#timer.finished .t-lbl { color: rgba(255,255,255,0.9); }
#timer.finished button { background: rgba(255,255,255,0.22); color: #fff; }
#toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 10px); transform: translate(-50%, -160%); z-index: 20;
  background: var(--text); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 15px; max-width: calc(100% - 32px);
  box-shadow: 0 10px 28px rgba(17,24,39,0.25); transition: transform 0.3s var(--ease), visibility 0s 0.3s; visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); visibility: visible; transition: transform 0.3s var(--ease); }
.empty { text-align: center; color: var(--text-3); padding: 36px 24px; background: var(--bg); margin-top: 8px; }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }
.skeleton { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.skeleton i { display: block; height: 64px; border-radius: 10px; background: linear-gradient(90deg, #e9ebee, #f5f6f7, #e9ebee); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- aggiunte: chiusura, coach nella scheda, timer ---------- */
body.resting main { padding-bottom: 96px; }
.w-date { position: relative; display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 15px; min-height: 36px; }
.w-date input { position: absolute; inset: 0; opacity: 0; width: 100%; min-height: 0; padding: 0; cursor: pointer; }
.w-notes { min-height: 36px; padding: 8px 0 0; font-size: 15px; }
.coach-btn { margin-top: 12px; min-height: 44px; font-size: 15px; }
.prev { border: 0; background: none; padding: 0; font: inherit; color: var(--text-3); font-size: 15px; min-height: 44px; cursor: pointer; text-align: left; }
.prev:active { color: var(--blue); }
.hint { font-size: 14px; color: var(--text-3); margin: -8px 0 14px; }
.badge-live { display: inline-block; vertical-align: 2px; margin-left: 6px; font-size: 12px; font-weight: 600; color: var(--blue); background: var(--blue-soft); border-radius: 999px; padding: 2px 8px; }
tr.done .ok svg { animation: tick 0.32s var(--ease); }
@keyframes tick { 0% { transform: scale(0.4); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
.w-foot .row { flex-wrap: wrap; }

/* coach a tutta altezza */
main.coach { display: flex; flex-direction: column; min-height: calc(100dvh - var(--tab-h) - env(safe-area-inset-bottom)); }
main.coach .chat-root { flex: 1; display: flex; flex-direction: column; }
.chat { flex: 1; }
.chat.is-empty { justify-content: center; }

/* pannello coach dentro l'allenamento */
dialog.sheet { width: 100%; max-width: 640px; height: 100dvh; max-height: 100dvh; margin: 0 auto; padding: 0; border: 0; background: var(--group); color: var(--text); }
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-in 0.28s var(--ease); }
dialog.sheet::backdrop { background: rgba(17,24,39,0.35); }
.sheet-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.sheet .composer { position: sticky; bottom: 0; left: auto; transform: none; width: auto; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
.sets th.c-prev { text-align: left; }
.appbar .side.end { gap: 2px; align-items: center; }
.coach-icon { color: var(--blue); }
.w-foot .add-ex { background: var(--bg); color: var(--blue); }

/* conferma dentro l'app */
dialog.confirm { width: 100%; max-width: 520px; margin: auto auto 0; border: 0; border-radius: 20px 20px 0 0; padding: 22px 16px calc(16px + env(safe-area-inset-bottom)); background: var(--bg); color: var(--text); box-shadow: 0 -8px 30px rgba(17,24,39,0.12); }
dialog.confirm[open] { animation: sheet-in 0.24s var(--ease); }
dialog.confirm::backdrop { background: rgba(17,24,39,0.35); }
dialog.confirm h2 { font-size: 19px; font-weight: 700; }
dialog.confirm p { color: var(--text-2); margin-top: 6px; line-height: 1.45; }
.confirm-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.btn.danger-solid { background: var(--red); color: #fff; }
@media (min-width: 560px) { dialog.confirm { margin: auto; border-radius: 20px; } }

/* scelte in un foglio (nuovo allenamento da scheda) */
.choices { display: flex; flex-direction: column; margin-top: 12px; max-height: 60vh; overflow-y: auto; }
.choice-row { display: flex; align-items: center; border-top: 1px solid var(--line); }
.choices > .choice { border-top: 1px solid var(--line); }
.choices > :first-child { border-top: 0; }
.choice { flex: 1; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 4px; border: 0; background: none; font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.choice:active { background: var(--press); }
.choice .txt { flex: 1; min-width: 0; }
.choice b { display: block; font-weight: 600; }
.choice small { display: block; color: var(--text-3); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.choice .go { color: var(--chevron); }
.ask-input { margin-top: 14px; }

/* peso corporeo */
.bw-card { display: flex; align-items: center; gap: 12px; color: inherit; }
.bw-card h2 { margin-bottom: 4px; }
.bw-card .txt { flex: 1; min-width: 0; }
.bw-card .go { color: var(--chevron); }
.bw-now { font-size: 22px; font-weight: 700; color: var(--text); }
.spark { width: 96px; height: 32px; flex: none; }
.spark polyline { fill: none; stroke: var(--blue); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.bw-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.bw-form .btn { grid-column: 1 / -1; }
.row-end { display: inline-flex; align-items: center; gap: 4px; }
.hist .row-end { color: var(--text); font-weight: 600; font-size: 16px; }
.push-on { display: flex; align-items: center; gap: 8px; color: var(--green); font-weight: 600; margin-bottom: 10px; }

/* selettore dell'app (sostituisce <select>) */
button.rest-pick { border: 0; background: none; padding: 0; font: inherit; font-size: 15px; font-weight: 500; color: var(--blue); cursor: pointer; min-height: 44px; }
button.pill { border: 0; font: inherit; font-size: 15px; font-weight: 500; cursor: pointer; }
.choice.current b { color: var(--blue); }
.choice .tick-on { color: var(--blue); }
#timer .grow { min-width: 0; }
#timer .t-lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist { align-items: center; }

/* genera con il coach */
.spark-badge { width: 40px; height: 40px; border-radius: 12px; background: var(--blue); color: #fff; display: grid; place-items: center; flex: none; }
.spark-badge.plain { background: var(--field); color: var(--text-2); }
.choices-label { font-size: 13px; font-weight: 600; color: var(--text-3); margin: 14px 0 2px; }
dialog.gen { max-height: 92dvh; overflow-y: auto; }
.opt { border: 0; padding: 0; margin: 16px 0 0; }
.opt legend { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; padding: 0; }
.chip-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt { position: relative; }
.chip-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip-opt span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; background: var(--field); font-size: 15px; font-weight: 500; color: var(--text); transition: background-color 0.15s, color 0.15s; }
.chip-opt input:checked + span { background: var(--blue); color: #fff; }
.chip-opt input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.gen-wait { text-align: center; padding: 72px 28px; background: var(--bg); min-height: calc(100dvh - var(--bar-h) - var(--tab-h)); }
.gen-wait .badge { width: 64px; height: 64px; border-radius: 18px; background: var(--blue-soft); color: var(--blue); display: inline-grid; place-items: center; margin-bottom: 16px; }
.gen-wait .badge .i { width: 30px; height: 30px; animation: spin 2.4s linear infinite; }
.gen-wait h2 { font-size: 20px; font-weight: 700; }
.gen-wait p { margin: 6px auto 20px; max-width: 320px; }
.gen-wait .typing { display: inline-flex; background: var(--field); }
@keyframes spin { to { transform: rotate(360deg); } }
