/* Gym Journal - stile. Tema scuro di default, chiaro opzionale. */

:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --bg-glass: rgba(11, 13, 16, 0.86);
  --surface: #14171c;
  --surface-2: #1a1e24;
  --surface-3: #232830;
  --border: #262b33;
  --border-strong: #363c47;
  --text: #eceef1;
  --text-2: #a7aeb9;
  --text-3: #808896;
  --accent: #c6f24e;
  --accent-ink: #11150a;
  --accent-soft: rgba(198, 242, 78, 0.12);
  --accent-line: rgba(198, 242, 78, 0.45);
  --pr: #f5c451;
  --pr-soft: rgba(245, 196, 81, 0.14);
  --danger: #f2685c;
  --danger-soft: rgba(242, 104, 92, 0.13);
  --good: #4fd18b;
  --bad: #f2685c;
  --warm: #f2a65a;
  --drop: #7fb2ff;
  --grid: #20252d;
  --axis: #3a404a;
  --band: rgba(198, 242, 78, 0.1);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --radius-sm: 11px;
  --nav-h: 62px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f2f3f5;
  --bg-glass: rgba(242, 243, 245, 0.88);
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eceef1;
  --border: #e1e4e8;
  --border-strong: #cdd1d7;
  --text: #101317;
  --text-2: #49505a;
  --text-3: #69717d;
  --accent: #4d7c0f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(77, 124, 15, 0.1);
  --accent-line: rgba(77, 124, 15, 0.4);
  --pr: #a8700f;
  --pr-soft: rgba(201, 138, 22, 0.13);
  --danger: #c8372d;
  --danger-soft: rgba(200, 55, 45, 0.08);
  --good: #1d8a52;
  --bad: #c8372d;
  --warm: #b35f10;
  --drop: #2f66c4;
  --grid: #eceef1;
  --axis: #cdd1d7;
  --band: rgba(77, 124, 15, 0.1);
  --shadow: 0 10px 28px rgba(16, 19, 23, 0.12);
}

@media (prefers-color-scheme: light) {
  :root[data-theme='auto'] {
    color-scheme: light;
    --bg: #f2f3f5;
    --bg-glass: rgba(242, 243, 245, 0.88);
    --surface: #ffffff;
    --surface-2: #f6f7f9;
    --surface-3: #eceef1;
    --border: #e1e4e8;
    --border-strong: #cdd1d7;
    --text: #101317;
    --text-2: #49505a;
    --text-3: #69717d;
    --accent: #4d7c0f;
    --accent-ink: #ffffff;
    --accent-soft: rgba(77, 124, 15, 0.1);
    --accent-line: rgba(77, 124, 15, 0.4);
    --pr: #a8700f;
    --pr-soft: rgba(201, 138, 22, 0.13);
    --danger: #c8372d;
    --danger-soft: rgba(200, 55, 45, 0.08);
    --good: #1d8a52;
    --bad: #c8372d;
    --warm: #b35f10;
    --drop: #2f66c4;
    --grid: #eceef1;
    --axis: #cdd1d7;
    --band: rgba(77, 124, 15, 0.1);
    --shadow: 0 10px 28px rgba(16, 19, 23, 0.12);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
html.noscroll, html.noscroll body { overflow: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }
a { color: inherit; }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.center { text-align: center; }
.italic { font-style: italic; }
.grow { flex: 1 1 auto; min-width: 0; }
.icon { flex: none; }
.mt { margin-top: 12px; }
.gold { color: var(--pr); }

/* ---------------------------------------------------------------- avvio */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-logo { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-3); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

/* ---------------------------------------------------------------- layout */
.app { min-height: 100vh; }
.statusbar-band { display: none; }
@media (display-mode: standalone) {
  :root[data-theme='light'] .statusbar-band {
    display: block; position: fixed; top: 0; left: 0; right: 0; height: var(--safe-t); background: #101317; z-index: 40;
  }
}
.main {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 10px) 16px calc(var(--nav-h) + var(--safe-b) + 28px);
}
.app.has-rest .main { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 108px); }

.topbar { display: flex; align-items: center; gap: 6px; min-height: 52px; margin: 0 -6px 10px; }
.topbar .tb-title { flex: 1 1 auto; min-width: 0; padding: 0 6px; }
.topbar h1 { font-size: 21px; font-weight: 750; letter-spacing: -0.01em; line-height: 1.2; overflow-wrap: anywhere; }
.topbar .tb-sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.topbar.big { margin-top: 6px; margin-bottom: 14px; }
.topbar.big h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.025em; }
.topbar.big .tb-sub { font-size: 14px; }
.tb-right { display: flex; align-items: center; gap: 4px; flex: none; }
.back-btn { margin-left: -2px; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 26px 2px 10px; }
.section-head h2 { font-size: 18px; font-weight: 750; letter-spacing: -0.01em; }
.list-label {
  display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; margin: 22px 4px 8px; background: none; border: 0; padding: 0;
}
button.list-label { cursor: pointer; }

/* ---------------------------------------------------------------- card */
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  text-decoration: none;
  color: inherit;
}
button.card { width: 100%; text-align: left; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }

/* ---------------------------------------------------------------- bottoni */
.btn {
  appearance: none; border: 0; border-radius: 12px; min-height: 44px; padding: 0 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface-3); color: var(--text); font-weight: 650; font-size: 15px;
  text-decoration: none; white-space: nowrap; transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s;
  user-select: none; -webkit-user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger-text { color: var(--danger); }
.btn.block { display: flex; width: 100%; white-space: normal; text-align: center; line-height: 1.25; padding-top: 8px; padding-bottom: 8px; }
.btn.lg { min-height: 52px; font-size: 16px; border-radius: 14px; padding: 0 20px; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.dashed { background: transparent; border: 1.5px dashed var(--border-strong); color: var(--text-2); }
.btn.grow { flex: 1 1 auto; }
.icon-btn {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center; border: 0; border-radius: 12px;
  background: transparent; color: var(--text-2);
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn.danger { color: var(--danger); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 600;
}
.pill.sync-ok svg { color: var(--accent); }
.pill.sync-offline, .pill.sync-auth { color: var(--warm); }
.pill.sync-syncing svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge {
  display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--accent-soft); color: var(--text); border: 1px solid var(--accent-line); vertical-align: middle;
  text-transform: uppercase; letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------- campi */
.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: 16px;
}
textarea.input { resize: vertical; min-height: 44px; line-height: 1.4; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.sm { min-height: 38px; padding: 6px 10px; font-size: 16px; border-radius: 10px; }
.input.auto { width: auto; }
.input::placeholder { color: var(--text-3); opacity: 1; }
.big-input { font-size: 20px !important; font-weight: 700; min-height: 52px; }
.title-input { font-size: 18px; font-weight: 700; }
.field { display: block; margin-bottom: 12px; min-width: 0; }
.field > span { display: block; font-size: 13px; color: var(--text-2); font-weight: 600; margin: 0 0 6px 2px; }
.field > span small { font-weight: 500; color: var(--text-3); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.hint-text { font-size: 12.5px; color: var(--text-3); margin-top: 10px; line-height: 1.45; }
.warn-text { font-size: 13px; color: var(--warm); margin-top: 8px; }
.form-error { color: var(--danger); font-size: 14px; }

.search { position: relative; margin-bottom: 10px; }
.search > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 38px; }
.search.sticky { position: sticky; top: 0; z-index: 2; background: var(--surface); padding-bottom: 2px; }
.search.sticky > svg { top: calc(50% - 1px); }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 6px; padding: 2px 16px 8px; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.chip {
  flex: none; border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 0 13px; min-height: 36px; font-size: 14px; font-weight: 600;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.sheet .chip { background: var(--surface-2); }
.sheet .chip.on { background: var(--text); }

.seg { display: inline-flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 2px; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: none; border: 0; background: transparent; color: var(--text-2); font-size: 14px; font-weight: 650; padding: 0 12px; min-height: 36px; border-radius: 9px; }
.seg.small button { font-size: 13px; padding: 0 10px; min-height: 32px; }
.seg button.on { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }

.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); transition: background 0.18s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--text-2); transition: transform 0.18s, background 0.18s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--accent-ink); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.stepper { display: inline-flex; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; height: 40px; }
.stepper button { width: 38px; height: 38px; border: 0; background: transparent; display: grid; place-items: center; color: var(--text-2); }
.stepper span { min-width: 26px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- liste */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 11px 14px;
  border: 0; border-bottom: 1px solid var(--border); background: none; text-align: left; text-decoration: none; color: inherit;
}
.row:last-child { border-bottom: 0; }
a.row:hover, button.row:hover:not(:disabled) { background: var(--surface-2); }
.row .title { font-weight: 620; line-height: 1.3; }
.row .sub { font-size: 13px; color: var(--text-2); margin-top: 2px; line-height: 1.35; }
.row.danger, .row.danger .title { color: var(--danger); }
.row.column { flex-direction: column; align-items: stretch; gap: 10px; }
.row-icon { width: 38px; height: 38px; border-radius: 11px; background: var(--surface-3); display: grid; place-items: center; color: var(--text-2); flex: none; }
.row.danger .row-icon { background: var(--danger-soft); color: var(--danger); }
.muted-row { opacity: 0.65; }
.list.settings .row { min-height: 60px; }
.row-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 4px; }
.unit-input { display: flex; align-items: center; gap: 6px; width: 110px; }
.unit-input .input { text-align: right; }

/* ---------------------------------------------------------------- vuoti */
.empty { text-align: center; padding: 28px 16px; color: var(--text-2); }
.empty-icon { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); }
.empty h3 { color: var(--text); font-size: 18px; margin-bottom: 6px; }
.empty p { max-width: 420px; margin: 0 auto 16px; font-size: 14.5px; line-height: 1.5; }
.empty-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ---------------------------------------------------------------- navigazione */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--bg-glass); -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--border); padding-bottom: var(--safe-b);
}
.nav-inner { display: grid; grid-template-columns: repeat(5, 1fr); max-width: 720px; margin: 0 auto; height: var(--nav-h); }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--text-3); font-size: 11px; font-weight: 650; }
.nav a.active { color: var(--text); }
.nav a.active .nav-icon svg { color: var(--accent); }
.nav-icon { position: relative; display: grid; place-items: center; height: 26px; }
.nav-icon .live-dot { position: absolute; top: -1px; right: -7px; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent-line); animation: live 1.6s infinite; flex: none; }
@keyframes live { 0% { box-shadow: 0 0 0 0 var(--accent-line); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------------------------------------------------------------- home */
.hero { padding: 18px; }
.hero-kicker { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; }
.hero-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 6px 0 4px; line-height: 1.15; }
.hero-sub { color: var(--text-2); font-size: 14.5px; margin-bottom: 16px; }
.hero-actions { display: flex; gap: 10px; }
.hero-actions .btn.primary { flex: 1 1 auto; }
.hero.live { border-color: var(--accent-line); background: linear-gradient(160deg, var(--accent-soft), var(--surface) 60%); }
.welcome h2 { font-size: 18px; margin-bottom: 10px; }
.welcome ol { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 8px; color: var(--text-2); font-size: 14.5px; line-height: 1.45; }
.welcome ol strong { color: var(--text); }
.welcome .muted { margin-bottom: 14px; }

.week-goal { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.week-count { display: flex; align-items: baseline; gap: 6px; }
.week-count .big { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.week-count .of { font-size: 20px; font-weight: 700; color: var(--text-2); }
.week-days { display: flex; gap: 5px; }
.wd { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--text-3); }
.wd.on { background: var(--accent); color: var(--accent-ink); }
.wd.today:not(.on) { box-shadow: inset 0 0 0 1.5px var(--text-3); color: var(--text); }
.wd.future { opacity: 0.55; }
.goal-bar { height: 6px; border-radius: 999px; background: var(--surface-3); margin: 14px 0 14px; overflow: hidden; }
.goal-bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.3s; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mini-stats > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mini-stats .label, .tile .label, .stat-row .label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.mini-stats .value { font-size: 18px; font-weight: 750; letter-spacing: -0.01em; white-space: nowrap; }
.delta { font-size: 12px; font-weight: 650; white-space: nowrap; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat, .delta.neutral { color: var(--text-3); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.tiles.t3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile .value { font-size: 26px; font-weight: 780; letter-spacing: -0.02em; display: flex; align-items: center; gap: 4px; line-height: 1.2; white-space: nowrap; }
.tile .value small, .body-card .value small { font-size: 14px; font-weight: 600; color: var(--text-2); margin-left: 3px; }
.tile .value.small-value { font-size: 19px; }
.tile .sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .flame { color: var(--warm); }
@media (max-width: 400px) {
  .tiles.t3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles.t3 .tile:last-child { grid-column: span 2; }
}

.pr-list { display: grid; }
.pr-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); text-decoration: none; }
.pr-row:last-child { border-bottom: 0; padding-bottom: 0; }
.pr-row:first-child { padding-top: 0; }
.pr-row .title { font-weight: 650; }
.pr-row .sub { font-size: 13px; color: var(--text-2); }
.body-card { display: flex; align-items: center; gap: 12px; }
.body-card .label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.body-card .value { font-size: 26px; font-weight: 780; letter-spacing: -0.02em; }
.body-card .sub { font-size: 13px; color: var(--text-2); }
.body-cta, .start-free { display: flex; align-items: center; gap: 12px; color: var(--text-2); }
.body-cta strong, .start-free strong { display: block; color: var(--text); font-weight: 680; }
.body-cta small, .start-free small { display: block; font-size: 13px; color: var(--text-2); margin-top: 2px; }
.start-icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.band-key { display: inline-block; width: 14px; height: 8px; border-radius: 2px; background: var(--band); box-shadow: inset 0 0 0 1px var(--accent-line); vertical-align: middle; margin-right: 4px; }

/* ---------------------------------------------------------------- schede */
.tpl { display: flex; align-items: center; gap: 12px; }
.tpl.next { border-color: var(--accent-line); }
.tpl-main { flex: 1 1 auto; min-width: 0; text-decoration: none; }
.tpl-title { font-size: 17px; font-weight: 720; }
.tpl-sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.tpl-ex { font-size: 13px; color: var(--text-3); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-ex-card { padding: 12px 12px 12px 14px; }
.tpl-ex-head { display: flex; align-items: center; gap: 2px; margin-bottom: 10px; }
.tpl-ex-head .title { font-weight: 680; }
.tpl-ex-head .sub { font-size: 13px; color: var(--text-2); }
.tpl-ex-grid { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; margin-bottom: 10px; }
.field-inline { display: flex; flex-direction: column; gap: 5px; }
.field-inline > span { font-size: 12px; color: var(--text-2); font-weight: 600; }
.range { display: flex; align-items: center; gap: 6px; }
.range .input { width: 58px; text-align: center; }
.note-input { font-size: 14px !important; }
.program { background: var(--surface-2); }
.program-title { font-size: 17px; font-weight: 720; margin-bottom: 4px; }
.program-days { margin: 10px 0 12px; padding-left: 18px; font-size: 13.5px; color: var(--text-2); display: grid; gap: 4px; }
.program-days strong { color: var(--text); }

/* ---------------------------------------------------------------- allenamento */
.wk-bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  margin: calc(-10px - var(--safe-t)) -16px 12px; padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: var(--bg-glass); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border);
}
.wk-bar-info { flex: 1 1 auto; min-width: 0; }
.wk-name { width: 100%; border: 0; background: transparent; font-size: 20px; font-weight: 780; letter-spacing: -0.01em; padding: 2px 0; border-radius: 6px; }
.wk-name:focus { outline: none; background: var(--surface-2); padding: 2px 6px; }
.wk-meta { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13.5px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.sep { color: var(--text-3); margin: 0 1px; }
.wk-notes { margin-bottom: 12px; }
.wk-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 10px; }
.add-ex { min-height: 52px; }
.edit-meta .grid3 { grid-template-columns: 1.3fr 1fr 1fr; }

.ex-card { padding: 14px 12px 8px; }
.ex-card.complete { border-color: var(--accent-line); }
.ex-head { display: flex; align-items: flex-start; gap: 6px; padding-left: 4px; }
.ex-name { font-size: 17px; font-weight: 740; line-height: 1.25; }
.ex-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 13px; color: var(--text-2); margin-top: 3px; }
.ex-meta svg { margin-right: -1px; }
.ex-tnote { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; color: var(--text-2); margin: 8px 4px 0; font-style: italic; }
.ex-tnote svg { flex: none; margin-top: 2px; }
.ex-note { margin-top: 8px; font-size: 14px !important; min-height: 38px !important; }
.hint {
  display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 10px; padding: 9px 12px; border-radius: 11px;
  background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--text); font-size: 13.5px; font-weight: 600; text-align: left;
}
.hint svg { color: var(--accent); flex: none; }
.hint span:first-of-type { flex: 1 1 auto; }
.hint-cta { font-size: 12px; font-weight: 750; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }

.sets { margin-top: 10px; }
.set-head, .set-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 70px 58px 46px; gap: 7px; align-items: center; }
.sets.k-time .set-head, .sets.k-time .set-row { grid-template-columns: 34px minmax(0, 1fr) 100px 46px; }
.sets.k-cardio .set-head, .sets.k-cardio .set-row { grid-template-columns: 34px minmax(0, 1fr) 62px 76px 46px; }
.set-head { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; padding: 0 4px 4px; }
.set-head span:nth-child(n + 3) { text-align: center; }
.set-row { padding: 4px; border-radius: 12px; transition: background 0.15s; }
.set-row + .set-row { margin-top: 2px; }
.set-row.done { background: var(--accent-soft); }
.set-label { height: 34px; border: 0; border-radius: 9px; background: var(--surface-3); color: var(--text-2); font-weight: 800; font-size: 14px; display: grid; place-items: center; }
.set-label.kw { color: var(--warm); }
.set-label.kt { color: var(--accent-ink); background: var(--accent); }
.set-label.kb { color: var(--drop); }
.set-label.kd { color: var(--drop); }
.set-label.kf { color: var(--danger); }
.set-prev.from-plan span { font-style: italic; }
.plan-note { font-style: normal; color: var(--text-3); }
.wk-tnote { display: flex; gap: 6px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); margin: -4px 2px 12px; }
.wk-tnote svg { flex: none; margin-top: 2px; }
.tpl-scheme { margin: -2px 0 10px; }
.tpl-scheme-text { margin: -2px 0 10px; }
.rest-inner.stopwatch { grid-template-columns: auto minmax(0, 1fr) auto; padding-bottom: 10px; }
.rest-inner.stopwatch .rest-time { color: var(--text-2); }
.set-prev { display: flex; align-items: center; gap: 4px; min-width: 0; height: 34px; padding: 0 2px; border: 0; background: none; color: var(--text-3); font-size: 14px; font-variant-numeric: tabular-nums; text-align: left; }
.set-prev span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-prev:disabled { opacity: 1; }
.pr-icon { color: var(--pr); flex: none; }
.set-row input.num {
  width: 100%; height: 40px; padding: 0 4px; border-radius: 10px; border: 1px solid transparent; background: var(--surface-3);
  text-align: center; font-size: 17px; font-weight: 720; font-variant-numeric: tabular-nums; color: var(--text);
}
.set-row input.num::placeholder { color: var(--text-3); font-weight: 600; }
.set-row input.num:focus { outline: none; border-color: var(--accent-line); background: var(--surface-2); }
.set-row.done input.num { background: transparent; }
.check { height: 40px; border: 0; border-radius: 10px; background: var(--surface-3); color: var(--text-3); display: grid; place-items: center; }
.set-row.done .check { background: var(--accent); color: var(--accent-ink); }
.set-row.pr { box-shadow: inset 0 0 0 1px var(--pr); }
.add-set { margin: 6px 0 0 2px; }

.menu-section { margin-bottom: 18px; }
.menu-label { font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 8px; }
.menu-list { margin-bottom: 4px; }
.menu-list .row { min-height: 52px; gap: 14px; }
.menu-list .row svg { color: var(--text-2); flex: none; }
.menu-list .row.danger svg { color: var(--danger); }

/* ---------------------------------------------------------------- storico */
.wcard { padding: 14px 16px; }
.wcard-head { display: flex; align-items: flex-start; gap: 10px; }
.wcard-title { font-size: 17px; font-weight: 720; }
.wcard-date { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.wcard-stats { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 8px; font-size: 13.5px; color: var(--text-2); }
.wcard-stats span { display: inline-flex; align-items: center; gap: 5px; }
.wcard-ex { font-size: 13.5px; display: grid; gap: 2px; }
.pr-pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; background: var(--pr-soft); color: var(--pr); font-size: 13px; font-weight: 750; flex: none; }
.pr-inline { color: var(--pr); display: inline-flex; vertical-align: -2px; }
.done-hero { text-align: center; padding: 22px 16px; border-color: var(--accent-line); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 75%); }
.done-badge { width: 60px; height: 60px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.done-hero h2 { font-size: 22px; margin-bottom: 4px; }
.detail-date { font-size: 14px; color: var(--text-2); margin-bottom: 12px; }
.detail-notes { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--text-2); font-size: 14.5px; white-space: pre-wrap; }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat-row > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-row .value { font-size: 19px; font-weight: 750; white-space: nowrap; }
@media (max-width: 420px) { .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pr-card { border-color: var(--pr-soft); }
.pr-card h2 svg { color: var(--pr); }
.pr-line { display: flex; align-items: baseline; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14.5px; }
.card-head + .pr-line { border-top: 0; padding-top: 0; }
.ex-detail { padding: 14px 16px 10px; }
.ex-detail-head { display: flex; align-items: center; justify-content: space-between; text-decoration: none; margin-bottom: 6px; color: var(--text); }
.ex-detail-head h3 { font-size: 16px; font-weight: 720; }
.ex-detail-head svg { color: var(--text-3); }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }

/* ---------------------------------------------------------------- tabelle */
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; padding: 6px 6px 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 9px 6px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table tr.warm td { color: var(--text-2); }
.table tr.work-row td { color: var(--text); background: var(--accent-soft); }
.set-chip { display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 6px; border-radius: 7px; background: var(--surface-3); color: var(--text-2); font-size: 12.5px; font-weight: 800; }
.set-chip.kw { color: var(--warm); }
.set-chip.kt { color: var(--accent-ink); background: var(--accent); }
.set-chip.kb { color: var(--drop); }
.set-chip.kd { color: var(--drop); }
.set-chip.kf { color: var(--danger); }

/* ---------------------------------------------------------------- progressi */
.ex-row .ex-row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.ex-row-best { font-size: 13px; font-weight: 700; white-space: nowrap; }
.ex-row-best .muted { font-weight: 500; font-size: 12px; }
.spark { display: block; overflow: visible; }
.session-row { align-items: flex-start; }
.session-best { font-weight: 720; font-size: 14px; white-space: nowrap; padding-top: 1px; }
.ex-notes { display: flex; gap: 8px; align-items: flex-start; color: var(--text-2); font-size: 14px; margin: -4px 2px 12px; }
.ex-notes svg { flex: none; margin-top: 2px; }
.danger-zone { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }

/* ---------------------------------------------------------------- grafici */
.chart { position: relative; width: 100%; user-select: none; -webkit-user-select: none; }
.chart svg { display: block; overflow: visible; touch-action: pan-y; }
.chart svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.chart .grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-label { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .end-label { fill: var(--text); font-size: 12.5px; font-weight: 750; font-variant-numeric: tabular-nums; }
.chart .crosshair { stroke: var(--text-3); stroke-width: 1; }
.chart .ring { stroke: var(--surface); stroke-width: 2; }
.chart .ring-thin { stroke: var(--surface); stroke-width: 1; }
.chart .bar { fill: var(--accent); transition: opacity 0.15s; }
.chart .bar.faded { opacity: 0.5; }
.chart .bar.hot { opacity: 0.8; }
.chart-card { padding: 14px 14px 10px; }
.chart-empty { display: grid; place-items: center; min-height: 120px; color: var(--text-3); font-size: 14px; text-align: center; }
.tip {
  position: absolute; z-index: 5; transform: translate(-50%, -100%); pointer-events: none;
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 10px;
  box-shadow: var(--shadow); font-size: 12.5px; white-space: nowrap; max-width: 260px;
}
.tip-title { color: var(--text-2); font-size: 12px; margin-bottom: 3px; }
.tip-row { display: flex; align-items: center; gap: 7px; }
.tip-row strong { font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }
.tip-label { color: var(--text-2); }
.tip-key.line { width: 12px; height: 2px; border-radius: 2px; }
.tip-key.dot { width: 7px; height: 7px; border-radius: 50%; }
.tip-sub { color: var(--text-2); font-size: 12px; margin-top: 2px; white-space: normal; min-width: 140px; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.lg-line { width: 14px; height: 2px; border-radius: 2px; background: var(--accent); }

.heat .hc { transition: opacity 0.12s; }
.hc.l0 { fill: var(--surface-3); }
.hc.l1 { fill: var(--accent); opacity: 0.3; }
.hc.l2 { fill: var(--accent); opacity: 0.52; }
.hc.l3 { fill: var(--accent); opacity: 0.76; }
.hc.l4 { fill: var(--accent); }
.hc.hot { stroke: var(--text); stroke-width: 1.5; }
.heat-legend { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 8px; font-size: 11.5px; color: var(--text-3); }
.heat-legend span { margin: 0 4px; }
.hc-swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; background: var(--surface-3); }
.hc-swatch.l1 { background: var(--accent); opacity: 0.3; }
.hc-swatch.l2 { background: var(--accent); opacity: 0.52; }
.hc-swatch.l3 { background: var(--accent); opacity: 0.76; }
.hc-swatch.l4 { background: var(--accent); }

.mbars { display: grid; gap: 9px; }
.mbar { display: grid; grid-template-columns: 96px minmax(0, 1fr) 34px; align-items: center; gap: 10px; }
.mbar-label { font-size: 13.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mbar-track { position: relative; height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.mbar-band { position: absolute; top: 0; bottom: 0; background: var(--band); box-shadow: inset 1px 0 0 var(--accent-line), inset -1px 0 0 var(--accent-line); }
.mbar-fill { position: absolute; left: 0; top: 2px; bottom: 2px; border-radius: 999px; background: var(--accent); min-width: 0; }
.mbar-val { font-size: 13.5px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- strumenti */
.quick-adjust { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.quick-adjust .btn { flex: 1 1 0; padding: 0 6px; }
.barviz { width: 100%; height: auto; max-height: 130px; display: block; margin: 8px 0 4px; }
.bar-shaft, .bar-sleeve { fill: var(--text-3); }
.bar-collar { fill: var(--text-2); }
.plate { stroke: rgba(0, 0, 0, 0.35); stroke-width: 1; }
.plates-text { text-align: center; font-size: 15px; color: var(--text-2); }
.plates-text strong { color: var(--text); font-size: 17px; }
.result { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 10px 0 16px; }
.result .label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.result-big { font-size: 46px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.result-big small { font-size: 18px; font-weight: 650; color: var(--text-2); margin-left: 4px; }

/* ---------------------------------------------------------------- corpo */
.quick-add .row-actions { align-items: center; flex-wrap: wrap; }
.quick-add .date-input { width: auto; min-width: 150px; flex: 1 1 150px; }

/* ---------------------------------------------------------------- sincronizzazione */
.sync-status { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 4px; }
.sync-status.s-ok svg { color: var(--accent); }
.sync-status.s-offline, .sync-status.s-auth { color: var(--warm); }

/* ---------------------------------------------------------------- timer recupero */
.rest { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b)); z-index: 29; display: flex; justify-content: center; padding: 0 12px 8px; pointer-events: none; }
.rest-inner {
  position: relative; overflow: hidden; pointer-events: auto; width: 100%; max-width: 696px;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 16px; padding: 10px 10px 12px 16px; box-shadow: var(--shadow);
}
.rest-inner.done { border-color: var(--accent); animation: flash 0.8s ease 2; }
@keyframes flash { 50% { background: var(--accent-soft); } }
.rest-progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); transition: width 0.25s linear; }
.rest-time { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; min-width: 72px; }
.rest-label { font-size: 13px; font-weight: 650; color: var(--text-2); min-width: 0; }
.rest-label small { display: block; font-weight: 500; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rest-actions { display: flex; gap: 6px; }
.rest-actions .btn { padding: 0 10px; min-width: 44px; }

/* ---------------------------------------------------------------- fogli e dialoghi */
.sheet-backdrop, .dialog-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: flex-end; justify-content: center; animation: fade 0.15s ease;
}
.dialog-backdrop { z-index: 60; align-items: center; padding: 20px; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 640px; max-height: calc(100vh - var(--safe-t) - 24px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-bottom: 0; border-radius: 22px 22px 0 0;
  animation: up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); padding-bottom: var(--safe-b);
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 10px 6px 20px; }
.sheet-head h3 { flex: 1 1 auto; font-size: 18px; font-weight: 750; min-width: 0; overflow-wrap: anywhere; }
.sheet-body { overflow-y: auto; padding: 6px 20px 20px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 20px 14px; border-top: 1px solid var(--border); }
.sheet .list { background: var(--surface-2); }
.sheet .input { background: var(--surface-2); }
.sheet .chips { margin: 0 -20px 6px; padding: 2px 20px 8px; }
.sheet .chips.wrap { margin: 0; padding: 0; }
.row.pick { min-height: 54px; }
.row.pick.selected { background: var(--accent-soft); }
.pick-check { width: 26px; height: 26px; border-radius: 8px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; flex: none; }
.row.pick.selected .pick-check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { border-radius: 22px; border-bottom: 1px solid var(--border); max-height: 86vh; padding-bottom: 0; }
}
.dialog { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 20px; padding: 20px; box-shadow: var(--shadow); animation: pop 0.16s ease; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } }
.dialog h3 { font-size: 18px; margin-bottom: 8px; }
.dialog p { color: var(--text-2); font-size: 15px; line-height: 1.45; }
.dialog-actions { display: flex; gap: 10px; margin-top: 18px; }
.dialog-actions .btn { flex: 1 1 0; white-space: normal; text-align: center; line-height: 1.2; }
.dialog-actions.stack { flex-direction: column; }

.toasts { position: fixed; top: calc(var(--safe-t) + 12px); left: 0; right: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  display: flex; align-items: center; gap: 8px; max-width: 460px; padding: 11px 16px; border-radius: 14px;
  background: var(--text); color: var(--bg); font-size: 14.5px; font-weight: 650; box-shadow: var(--shadow); animation: drop 0.22s ease;
}
.toast.pr { background: var(--pr); color: #1b1404; }
@keyframes drop { from { transform: translateY(-12px); opacity: 0; } }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; text-align: center; }
.login-logo { margin: 0 auto 4px; border-radius: 20px; }
.login-card h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }

/* ---------------------------------------------------------------- schermi stretti */
@media (max-width: 360px) {
  .main { padding-left: 12px; padding-right: 12px; }
  .ex-card { padding-left: 8px; padding-right: 8px; }
  .set-head, .set-row { grid-template-columns: 30px minmax(0, 1fr) 62px 52px 42px; gap: 5px; }
  .week-days { gap: 3px; }
  .wd { width: 26px; height: 26px; }
  .mbar { grid-template-columns: 82px minmax(0, 1fr) 30px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
