/* GymPro - stile. Nessun font o risorsa esterna (CSP: solo 'self'). */

/* ---------- Colori ---------- */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #eef0f3; --surface-3: #e3e7ec;
  --fg: #111417; --fg-2: #3c434d; --mut: #5f6874; --bd: #dde1e7; --bd-strong: #c5cbd3;
  --on-acc: #ffffff;
  --ok: #0a7d3a; --warn: #9a5b00; --danger: #c22f2f; --danger-bg: #fdecec;
  --grid: #e8eaee; --axis: #c3c8cf;
  --shadow: 0 1px 2px rgba(16, 20, 24, .06), 0 4px 16px rgba(16, 20, 24, .05);
  --radius: 16px; --radius-s: 10px;
  --nav-h: 64px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  color-scheme: light;
}
:root[data-accent="verde"]   { --acc-l: #0a7d5a; --acc-d: #3ddc9a; }
:root[data-accent="blu"]     { --acc-l: #1f63c4; --acc-d: #6aa8ff; }
:root[data-accent="arancio"] { --acc-l: #b4530a; --acc-d: #ff9d57; }
:root[data-accent="viola"]   { --acc-l: #6243d1; --acc-d: #ae97ff; }
:root[data-accent="rosso"]   { --acc-l: #c0303a; --acc-d: #ff7373; }
:root[data-accent="rosa"]    { --acc-l: #b62d73; --acc-d: #ff86bf; }
:root { --acc: var(--acc-l, #0a7d5a); --acc-soft: color-mix(in srgb, var(--acc) 12%, transparent); --acc-mid: color-mix(in srgb, var(--acc) 30%, transparent); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e11; --surface: #15181d; --surface-2: #1d2128; --surface-3: #262b33;
    --fg: #eef0f3; --fg-2: #c4cad3; --mut: #9aa3b0; --bd: #262b33; --bd-strong: #353c46;
    --on-acc: #0c0e11; --acc: var(--acc-d, #3ddc9a);
    --ok: #3ddc84; --warn: #f2b33d; --danger: #ff6b6b; --danger-bg: #3a1a1c;
    --grid: #21252c; --axis: #39404a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0e11; --surface: #15181d; --surface-2: #1d2128; --surface-3: #262b33;
  --fg: #eef0f3; --fg-2: #c4cad3; --mut: #9aa3b0; --bd: #262b33; --bd-strong: #353c46;
  --on-acc: #0c0e11; --acc: var(--acc-d, #3ddc9a);
  --ok: #3ddc84; --warn: #f2b33d; --danger: #ff6b6b; --danger-bg: #3a1a1c;
  --grid: #21252c; --axis: #39404a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
:root[data-text="grande"] { font-size: 112.5%; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 750; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: .4rem 0; }
a { color: var(--acc); }
button, a, [role="button"], label, select, input[type="checkbox"] { touch-action: manipulation; }
button, [role="button"], .btn, .chip, .nav-item { user-select: none; -webkit-user-select: none; }
input, select, textarea { font: inherit; font-size: max(16px, 1rem); color: inherit; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.ic { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.25em; }
.muted { color: var(--mut); }
.small { font-size: .85rem; }
.center { text-align: center; }
.cap { text-transform: capitalize; }
.hide { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.warn { color: var(--warn); }
.danger-text { color: var(--danger) !important; }
.noscript { padding: 24px; text-align: center; }
.link { background: none; border: 0; padding: 0; color: var(--acc); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; }

/* ---------- Struttura ---------- */
#app { min-height: 100dvh; }
#main { max-width: 820px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 96px); }
#view { outline: none; }
#view.enter { animation: enter .22s var(--ease-out); }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }
body[data-view="login"] #main { padding-bottom: 32px; }

#nav {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-around; align-items: stretch;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--bd);
  padding: 4px max(4px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-left, 0px));
}
#nav[hidden] { display: none; }
#nav .brand { display: none; }
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; padding: 6px 2px; border-radius: 12px;
  color: var(--mut); text-decoration: none; font-size: .72rem; font-weight: 600;
  transition: color .15s, background-color .15s;
}
.nav-item .ic { width: 24px; height: 24px; }
.nav-item.on { color: var(--acc); }
.nav-item:active { background: var(--surface-2); }
body[data-view="allena"] #nav { display: none; }
body[data-view="allena"] #main { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 110px); }

@media (min-width: 900px) {
  #app { display: grid; grid-template-columns: 232px minmax(0, 1fr); }
  #nav { grid-column: 1; grid-row: 1; }
  #main { grid-column: 2; grid-row: 1; }
  body[data-view="login"] #app { display: block; }
  #nav {
    position: sticky; top: 0; height: 100dvh; flex-direction: column; justify-content: flex-start; gap: 4px;
    border-top: 0; border-right: 1px solid var(--bd); padding: 20px 12px; background: var(--surface);
  }
  #nav .brand { display: flex; align-items: center; gap: 10px; padding: 8px 12px 20px; font-weight: 800; font-size: 1.2rem; color: var(--fg); text-decoration: none; }
  #nav .brand .ic { color: var(--acc); width: 28px; height: 28px; }
  .nav-item { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 44px; padding: 0 14px; font-size: .95rem; }
  .nav-item.on { background: var(--acc-soft); }
  .nav-admin { margin-top: auto; }
  body[data-view="allena"] #nav { display: flex; }
  #main { padding: 32px 32px 120px; width: 100%; }
}
@media (hover: hover) and (pointer: fine) {
  .nav-item:hover { color: var(--fg); background: var(--surface-2); }
  .nav-item.on:hover { color: var(--acc); background: var(--acc-soft); }
}

#banner {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px;
  background: var(--acc-soft); border: 1px solid var(--acc-mid); color: var(--fg);
  border-radius: var(--radius-s); padding: 10px 12px; font-size: .9rem;
}
#banner[hidden] { display: none; }
#banner .ic { color: var(--acc); }

.boot { display: grid; place-items: center; min-height: 60dvh; }
.boot span { width: 28px; height: 28px; border: 3px solid var(--surface-3); border-top-color: var(--acc); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Componenti ---------- */
.card { background: var(--surface); border: 1px solid var(--bd); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card, .card + .stack, .stack + .card { margin-top: 12px; }
.card h2 + p.muted { margin-top: 2px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 18px; }
.page-head > div { min-width: 0; }
.page-head .btn.icon { margin-right: -4px; }
.page-head:has(> .btn.icon) { justify-content: flex-start; flex-wrap: nowrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 26px 0 10px; font-size: 1rem; color: var(--fg-2); }
.section-title .ic { color: var(--acc); }
.eyebrow { margin: 0 0 6px; color: var(--acc); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.row-actions.center { justify-content: center; }
.two-col { display: grid; gap: 12px; margin-top: 12px; }
.two-col .card + .card { margin-top: 0; }
@media (min-width: 720px) { .two-col { grid-template-columns: 1fr 1fr; } }
.empty-state { text-align: center; padding: 32px 20px; }
.empty-state .btn { margin-top: 12px; }
.empty { color: var(--mut); text-align: center; padding: 20px 0; margin: 0; font-size: .9rem; }
.notice { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; background: var(--acc-soft); border-color: var(--acc-mid); font-size: .9rem; }
.notice.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); border-radius: var(--radius-s); padding: 8px 12px; display: block; }
.notice.warn p { margin: 2px 0; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; background: var(--acc-soft); color: var(--acc); font-size: .72rem; font-weight: 700; vertical-align: 1px; }
.badge.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; overscroll-behavior-x: contain; }
.chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--fg-2); font-size: .78rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; font-family: inherit; }
button.chip { cursor: pointer; min-height: 32px; }
.chip.on { background: var(--acc); color: var(--on-acc); }

/* Pulsanti */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--bd-strong);
  background: var(--surface); color: var(--fg); font: inherit; font-weight: 650; font-size: .95rem;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform .12s var(--ease-out), background-color .15s, border-color .15s, opacity .15s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }
.btn.ghost { background: transparent; border-color: var(--bd); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .85rem; border-radius: 10px; }
.btn.icon { min-width: 44px; padding: 0; }
.btn.small.icon, .pi-actions .btn.icon { min-width: 36px; min-height: 36px; }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 54px; font-size: 1.05rem; border-radius: 14px; }
.btn .ic { width: 1.15em; height: 1.15em; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { border-color: var(--acc); }
  .btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
  .btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
}
.file-btn { position: relative; }

/* Campi */
.form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--fg-2); }
.field.card { margin-top: 12px; }
.field.compact { margin: 0; }
.field small { font-size: .78rem; }
input:where(:not([type="checkbox"], [type="radio"], [type="file"])), select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-s);
  border: 1px solid var(--bd-strong); background: var(--surface); color: var(--fg);
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--mut) 75%, transparent); }
.form-err { color: var(--danger); min-height: 1.2em; margin: 0; font-size: .9rem; font-weight: 600; }
.form-err:empty { min-height: 0; }
.check { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--acc); }
.search { margin-bottom: 4px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin: 12px 0; }
.inline-form .field { flex: 1 1 120px; }
.field-label { font-weight: 650; margin: 18px 0 8px; }

/* Selettore a segmenti */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.seg button { min-height: 36px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--fg-2); font: inherit; font-size: .88rem; font-weight: 650; cursor: pointer; }
.seg button[aria-checked="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }
.seg.small button { min-height: 32px; padding: 0 10px; font-size: .8rem; }
.filters { margin-bottom: 14px; }

/* ---------- Accesso ---------- */
.auth { min-height: calc(100dvh - 64px); display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--bd); border-radius: 22px; padding: 28px 24px; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.25rem; margin-bottom: 22px; }
.auth-brand .ic { width: 34px; height: 34px; padding: 6px; border-radius: 10px; background: var(--acc); color: var(--on-acc); }
.auth h1 { font-size: 1.5rem; }

/* ---------- Oggi ---------- */
.page-head h1 { overflow-wrap: anywhere; }
.week-card { display: flex; align-items: center; gap: 16px; }
.week-ring { position: relative; flex: none; width: 72px; height: 72px; }
.week-ring span { position: absolute; inset: 0; display: flex; align-items: baseline; justify-content: center; padding-top: 24px; font-size: .9rem; color: var(--mut); }
.week-ring b { color: var(--fg); font-size: 1.25rem; }
.week-txt h3 { margin-bottom: 4px; }
.week-txt .ic { color: var(--acc); }
.ring-track { stroke: var(--surface-3); }
.ring-fill { stroke: var(--acc); transition: stroke-dashoffset .5s var(--ease-out); }
.day-card { margin-top: 12px; }
.day-card.featured { border-color: var(--acc-mid); background: linear-gradient(180deg, var(--acc-soft), transparent 60%), var(--surface); padding: 20px; }
.day-card.featured h2 { font-size: 1.5rem; }
.day-head { display: flex; flex-direction: column; gap: 2px; }
.day-card .btn { margin-top: 12px; }
.ex-preview { margin: 6px 0 4px; padding-left: 1.3em; color: var(--fg-2); columns: 2 200px; column-gap: 24px; }
.ex-preview li { margin: 3px 0; break-inside: avoid; }
.ex-preview li.more { list-style: none; }
.grid-days { display: grid; gap: 12px; }
.grid-days .day-card { margin-top: 0; }
@media (min-width: 600px) { .grid-days { grid-template-columns: 1fr 1fr; } }

/* ---------- Allenamento ---------- */
.w-head {
  position: sticky; top: 0; z-index: 10; margin: -16px -16px 12px; padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 12px;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bd);
}
@media (min-width: 900px) { .w-head { margin: -32px -32px 16px; padding: 16px 32px; } }
.w-title { min-width: 0; }
.w-title h1 { font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-clock { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--fg); }
.w-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.w-bar span { display: block; height: 100%; width: 0; background: var(--acc); border-radius: 3px; transition: width .35s var(--ease-out); }
.ex-list { display: flex; flex-direction: column; gap: 10px; }
.ex { padding: 0; overflow: hidden; scroll-margin-top: 110px; transition: border-color .2s; }
.ex.open { border-color: var(--acc-mid); box-shadow: 0 0 0 1px var(--acc-mid), var(--shadow); }
.ex.is-done:not(.open) { opacity: .7; }
.ex-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.ex-num { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); font-weight: 750; font-size: .95rem; color: var(--fg-2); }
.ex.open .ex-num { background: var(--acc); color: var(--on-acc); }
.ex-num.ok { background: var(--acc-soft); color: var(--acc); }
.ex.open .ex-num.ok { background: var(--acc); color: var(--on-acc); }
.ex-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ex-title b { font-size: 1.05rem; overflow-wrap: anywhere; }
.ex-title small { color: var(--mut); font-size: .82rem; }
.ex-muscle { color: var(--acc); font-weight: 650; }
.ex-dots { display: flex; gap: 4px; flex-wrap: wrap; max-width: 60px; justify-content: flex-end; }
.ex-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-3); }
.ex-dots i.on { background: var(--acc); }
.ex-body { padding: 0 16px 16px; }
.ex-note { display: flex; gap: 8px; margin: 0 0 10px; padding: 8px 12px; border-radius: var(--radius-s); background: var(--surface-2); font-size: .9rem; color: var(--fg-2); }
.ex-note .ic { color: var(--acc); margin-top: 2px; }
.ex-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.ex-tools.end { justify-content: flex-end; margin: 12px 0 0; }
.ex-fig { margin-bottom: 10px; }
.fig-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fig-step { background: var(--surface-2); border-radius: 12px; padding: 8px; }
.fig-step svg { width: 100%; height: auto; max-height: 160px; color: var(--fg); display: block; }
.fig-step small { display: block; margin-top: 4px; color: var(--acc); font-weight: 750; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.fig-step p { margin: 2px 0 0; font-size: .85rem; line-height: 1.35; color: var(--fg-2); }
.fig-load { fill: var(--acc); stroke: none; }
.ex-last { margin: 0 0 8px; font-size: .9rem; }
.ex-sug { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 10px; padding: 8px 12px; border-radius: var(--radius-s); background: var(--acc-soft); color: var(--fg); font-size: .9rem; }
.ex-sug .ic { color: var(--acc); margin-top: 2px; }
.sets { display: flex; flex-direction: column; gap: 8px; }
.set-h, .set { display: grid; grid-template-columns: 34px 1fr 1fr 52px; align-items: center; gap: 8px; }
.set-h { font-size: .75rem; color: var(--mut); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.set-h span:nth-child(2), .set-h span:nth-child(3) { text-align: center; }
.set-n { display: grid; place-items: center; height: 34px; font-weight: 750; color: var(--mut); }
.set input[type="number"] { text-align: center; font-weight: 700; font-size: 1.1rem; min-height: 50px; padding: 8px 4px; font-variant-numeric: tabular-nums; }
.set.ok input[type="number"] { border-color: var(--acc-mid); background: var(--acc-soft); }
.set-done {
  width: 52px; height: 50px; border-radius: 12px; border: 2px solid var(--bd-strong); background: var(--surface);
  color: transparent; display: grid; place-items: center; cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .12s var(--ease-out);
}
.set-done .ic { width: 26px; height: 26px; stroke-width: 3; }
.set-done:active { transform: scale(.92); }
.set.ok .set-done { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }
.set:not(.ok) .set-done { color: var(--bd-strong); }
.w-foot { margin-top: 20px; display: flex; flex-direction: column; gap: 8px; }

/* Timer di recupero */
#timer {
  position: fixed; z-index: 30; left: 12px; right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--nav-h) + 12px);
  max-width: 520px; margin: 0 auto;
}
body[data-view="allena"] #timer { bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
#timer[hidden] { display: none; }
.timer-inner {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 18px;
  background: var(--fg); color: var(--bg); box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
  animation: rise .25s var(--ease-out);
}
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
.timer-inner .btn { color: var(--bg); border-color: color-mix(in srgb, var(--bg) 30%, transparent); }
.timer-ring { display: grid; }
.timer-ring .ring-track { stroke: color-mix(in srgb, var(--bg) 25%, transparent); }
.timer-ring .ring-fill { stroke: var(--acc); transition: none; }
.timer-txt { flex: 1; display: flex; flex-direction: column; line-height: 1.1; }
.timer-txt small { font-size: .72rem; opacity: .7; text-transform: uppercase; letter-spacing: .05em; }
.timer-time { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.timer-inner.done { background: var(--acc); color: var(--on-acc); }
.timer-inner.done .btn { color: var(--on-acc); }
.timer-go { flex: 1; font-weight: 800; font-size: 1.1rem; padding-left: 6px; }
@media (min-width: 900px) { #timer { left: auto; right: 24px; bottom: 24px; width: 420px; } body[data-view="allena"] #timer { bottom: 24px; } }

/* Riepilogo */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin: 12px 0; }
.summary > div { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; border-radius: 12px; background: var(--surface-2); text-align: center; }
.summary b { font-size: 1.15rem; }
.summary span { font-size: .78rem; color: var(--mut); }
.summary.card > div { background: var(--surface-2); }
.prs { margin: 10px 0; padding: 10px 12px; border-radius: 12px; background: var(--acc-soft); }
.prs p { display: flex; gap: 8px; margin: 3px 0; font-weight: 600; }
.prs .ic { color: var(--acc); }
.feel { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.feel button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; border-radius: 12px; border: 1px solid var(--bd); background: var(--surface); color: var(--fg); font: inherit; cursor: pointer; }
.feel button b { font-size: 1.2rem; }
.feel button span { font-size: .68rem; color: var(--mut); }
.feel button[aria-checked="true"] { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }
.feel button[aria-checked="true"] span { color: var(--on-acc); }

/* Dialoghi */
dialog#dlg { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--bd); border-radius: 20px; background: var(--surface); color: var(--fg); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog#dlg:has(.wide) { width: min(760px, calc(100vw - 24px)); }
dialog#dlg[open] { animation: pop .2s var(--ease-out); }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(8px); } }
dialog::backdrop { background: rgba(8, 10, 12, .55); backdrop-filter: blur(2px); }
.dlg-body { padding: 22px 20px 18px; overflow-y: auto; max-height: calc(100dvh - 26px); overscroll-behavior: contain; }
.dlg-body h2 { margin-bottom: 8px; font-size: 1.25rem; }
.dlg-body h3 { margin: 18px 0 6px; font-size: .9rem; color: var(--fg-2); }
.dlg-actions { position: sticky; bottom: -18px; display: flex; justify-content: flex-end; gap: 8px; margin: 18px -20px -18px; padding: 12px 20px calc(14px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--bd); }
@media (max-width: 600px) {
  dialog#dlg, dialog#dlg:has(.wide) { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 92dvh; }
  dialog#dlg[open] { animation: sheet .25s var(--ease-out); }
  .dlg-body { max-height: 92dvh; }
  .dlg-actions .btn { flex: 1; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: .6; } }
.steps { padding-left: 1.2em; }
.steps li { margin: 8px 0; }
.secret { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.secret code { font: 700 1rem/1.3 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .04em; overflow-wrap: anywhere; user-select: all; }
.secret.big { flex-direction: column; align-items: stretch; }
.secret.big > div { display: flex; flex-direction: column; }
.secret.big code { font-size: 1.25rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 8px 0 4px; font-size: .9rem; }
.kv dt { color: var(--mut); }
.kv dd { margin: 0; font-weight: 600; }

/* Notifiche */
.toast {
  position: fixed; z-index: 60; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 12px);
  transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 480px); padding: 12px 16px; border-radius: 14px;
  background: var(--fg); color: var(--bg); font-weight: 600; font-size: .92rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  transition: transform .25s var(--ease-out), opacity .2s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- Storico ---------- */
.w-row { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; padding: 12px 14px; }
.w-row + .w-row { margin-top: 0; }
.w-date { flex: none; width: 46px; display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.w-date b { font-size: 1.35rem; }
.w-date span { font-size: .72rem; color: var(--mut); text-transform: uppercase; }
.w-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.feel-badge { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 800; font-size: .85rem; background: var(--surface-2); color: var(--fg-2); }
.feel-badge.f4, .feel-badge.f5 { background: var(--acc-soft); color: var(--acc); }
@media (hover: hover) and (pointer: fine) { .w-row:hover { border-color: var(--acc-mid); } }
.tbl-wrap { overflow-x: auto; overscroll-behavior-x: contain; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: .75rem; color: var(--mut); font-weight: 650; text-transform: uppercase; letter-spacing: .03em; padding: 6px 8px; border-bottom: 1px solid var(--bd); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--bd); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.muted td { color: var(--mut); }
.tbl input[type="number"] { min-height: 40px; max-width: 110px; padding: 6px 8px; }
.tbl td .ic { color: var(--acc); }
.card > h3.row-between { margin-bottom: 6px; }

/* ---------- Progressi ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; transition: opacity .2s; }
.tiles.loading { opacity: .5; }
.tile { background: var(--surface); border: 1px solid var(--bd); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.tile-label { font-size: .8rem; color: var(--mut); font-weight: 600; }
.tile-value { font-size: 1.6rem; font-weight: 750; letter-spacing: -.02em; }
.delta { font-size: .75rem; color: var(--mut); }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }
.chart-card h2 { display: flex; align-items: center; gap: 8px; }
.chart-card h2 .ic { color: var(--acc); }
.chart { position: relative; margin-top: 10px; min-height: 40px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--mut); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .area { fill: var(--acc); opacity: .1; }
.chart .line { fill: none; stroke: var(--acc); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--acc); stroke: var(--surface); stroke-width: 1.5; }
.chart .end { fill: var(--acc); stroke: var(--surface); stroke-width: 2; }
.chart .endlabel { fill: var(--fg); font-size: 12px; font-weight: 700; }
.chart .cross { stroke: var(--mut); stroke-width: 1; }
.chart .hot { fill: var(--acc); stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.chart .bar { fill: var(--acc); }
.chart .hit { fill: transparent; cursor: pointer; outline: none; }
.chart .hit.on { fill: var(--acc-soft); }
.chart .goal { stroke: var(--fg-2); stroke-width: 1; opacity: .55; }
.chart .cal { fill: var(--surface-2); outline: none; }
.chart .cal.l1 { fill: color-mix(in srgb, var(--acc) 45%, var(--surface-2)); }
.chart .cal.l2 { fill: color-mix(in srgb, var(--acc) 75%, var(--surface-2)); }
.chart .cal.l3 { fill: var(--acc); }
.chart .cal:focus { stroke: var(--fg); stroke-width: 1.5; }
.chart svg { touch-action: pan-y; }
.chart-tip {
  position: absolute; z-index: 2; pointer-events: none; opacity: 0; transform: translateY(4px);
  display: flex; flex-direction: column; padding: 6px 10px; border-radius: 10px;
  background: var(--fg); color: var(--bg); font-size: .8rem; white-space: nowrap; box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
  transition: opacity .12s, transform .12s;
}
.chart-tip.on { opacity: 1; transform: none; }
.chart-tip strong { font-size: .95rem; }
.chart-tip span { opacity: .75; }
.chart-ctrl { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0 4px; }
.chart-ctrl .field { flex: 1 1 220px; }
.data-view { margin-top: 10px; font-size: .85rem; }
.data-view summary { cursor: pointer; color: var(--mut); font-weight: 600; padding: 4px 0; }
.data-view .tbl-wrap { max-height: 280px; overflow-y: auto; }
.hbars { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hbars li { display: grid; grid-template-columns: minmax(80px, 38%) 1fr auto; align-items: center; gap: 10px; font-size: .88rem; }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.hb-fill { display: block; height: 100%; width: 0; background: var(--acc); border-radius: 0 5px 5px 0; }
.hb-val { color: var(--fg-2); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Scheda ---------- */
.plan-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: thin; overscroll-behavior-x: contain; }
.plan-tabs button { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--bd); background: var(--surface); color: var(--fg-2); font: inherit; font-weight: 650; cursor: pointer; }
.plan-tabs button[aria-selected="true"] { border-color: var(--acc); color: var(--fg); box-shadow: 0 0 0 1px var(--acc); }
.plan-meta .field { margin-top: 0; }
.day-edit { margin-top: 12px; padding: 14px; }
.day-edit-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 6px; }
.day-edit-head .day-name { flex: 1 1 160px; font-weight: 750; font-size: 1.1rem; }
.day-edit-head .muted { flex: none; }
.pi-list { list-style: none; margin: 8px 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pi { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: start; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.pi-fig { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--surface); color: var(--fg-2); }
.pi-fig svg { width: 38px; height: 38px; }
.pi-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.pi-main input, .pi-main select { min-height: 40px !important; padding: 6px 10px !important; }
.pi-name { font-weight: 650; }
.pi-fields { display: grid; grid-template-columns: 1fr 1.2fr 1.2fr; gap: 6px; }
.pi-fields label { display: flex; flex-direction: column; gap: 2px; }
.pi-fields label span { font-size: .7rem; color: var(--mut); font-weight: 650; text-transform: uppercase; letter-spacing: .03em; }
.pi-notes { font-size: .9rem; }
.pi-main .warn { margin: 0; }
.pi-actions { display: flex; flex-direction: column; gap: 2px; }
.day-edit-head .pi-actions { flex-direction: row; }
@media (max-width: 480px) {
  .pi { grid-template-columns: 1fr auto; }
  .pi .pi-fig { display: none; }
}
.savebar {
  position: fixed; z-index: 25; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom, 0px) + var(--nav-h) + 12px);
  max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 16px;
  background: var(--fg); color: var(--bg); box-shadow: 0 10px 30px rgba(0, 0, 0, .3); animation: rise .25s var(--ease-out);
}
.savebar[hidden] { display: none; }
.savebar span { flex: 1; font-weight: 650; font-size: .92rem; }
.savebar .btn.ghost { color: var(--bg); border-color: color-mix(in srgb, var(--bg) 30%, transparent); }
@media (min-width: 900px) { .savebar { left: 264px; bottom: 24px; } }
.ex-mine { list-style: none; margin: 8px 0 0; padding: 0; }
.ex-mine li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--bd); }
.ex-mine li:last-child { border-bottom: 0; }
.pick-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; min-height: 200px; }
.pick-list button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px; border: 0; border-radius: 12px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.pick-list button span:last-child { display: flex; flex-direction: column; }
.pick-list button:active { background: var(--surface-2); }
@media (hover: hover) and (pointer: fine) { .pick-list button:hover { background: var(--surface-2); } }
.pick-list .pi-fig { background: var(--surface-2); }

/* ---------- Profilo ---------- */
.profile-card { display: flex; align-items: center; gap: 14px; }
.profile-card > div:not(.avatar) { flex: 1; min-width: 0; }
.avatar { flex: none; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--acc); color: var(--on-acc); font-weight: 800; font-size: 1.4rem; }
.avatar.small { width: 40px; height: 40px; font-size: 1rem; }
.settings { padding: 4px 16px; }
.set-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--bd); }
.set-row:last-child { border-bottom: 0; }
.set-row > span { display: flex; flex-direction: column; min-width: 0; flex: 1 1 200px; }
.set-row.col { flex-direction: column; align-items: stretch; }
.set-row select { width: auto; min-width: 120px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--bd); cursor: pointer; }
.switch-row:last-child { border-bottom: 0; }
.switch-row > span { display: flex; flex-direction: column; }
input[role="switch"] {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 50px; height: 30px; margin: 0;
  border-radius: 999px; background: var(--surface-3); cursor: pointer; transition: background-color .2s;
}
input[role="switch"]::after { content: ""; 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-out); }
input[role="switch"]:checked { background: var(--acc); }
input[role="switch"]:checked::after { transform: translateX(20px); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--bd-strong); cursor: pointer; padding: 0; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--fg); }
.sw-verde { background: #0a7d5a; } .sw-blu { background: #1f63c4; } .sw-arancio { background: #b4530a; }
.sw-viola { background: #6243d1; } .sw-rosso { background: #c0303a; } .sw-rosa { background: #b62d73; }
:root[data-theme="dark"] .sw-verde { background: #3ddc9a; } :root[data-theme="dark"] .sw-blu { background: #6aa8ff; }
:root[data-theme="dark"] .sw-arancio { background: #ff9d57; } :root[data-theme="dark"] .sw-viola { background: #ae97ff; }
:root[data-theme="dark"] .sw-rosso { background: #ff7373; } :root[data-theme="dark"] .sw-rosa { background: #ff86bf; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sw-verde { background: #3ddc9a; } :root:not([data-theme="light"]) .sw-blu { background: #6aa8ff; }
  :root:not([data-theme="light"]) .sw-arancio { background: #ff9d57; } :root:not([data-theme="light"]) .sw-viola { background: #ae97ff; }
  :root:not([data-theme="light"]) .sw-rosso { background: #ff7373; } :root:not([data-theme="light"]) .sw-rosa { background: #ff86bf; }
}
.sessions { list-style: none; margin: 6px 0; padding: 0; }
.sessions li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--bd); }
.sessions li:last-child { border-bottom: 0; }
.sessions li > span { display: flex; flex-direction: column; min-width: 0; }

/* ---------- Admin ---------- */
.user-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; padding: 12px 14px; }
.user-row + .user-row { margin-top: 0; }
.u-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.u-name { overflow-wrap: anywhere; }
.status { flex: none; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--fg-2); }
.status.ok { background: var(--acc-soft); color: var(--acc); }
.status.warn { background: var(--danger-bg); color: var(--danger); }
.status.wait { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.status.off { text-decoration: line-through; }
@media (hover: hover) and (pointer: fine) { .user-row:hover { border-color: var(--acc-mid); } }
.audit td { white-space: nowrap; font-size: .82rem; }
.audit td:nth-child(4) { white-space: normal; min-width: 160px; }
.warn-row td { color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
  #nav, #timer, #banner, .savebar, .btn { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* Backup (admin) */
.tbl.backups td { white-space: nowrap; }
@media (max-width: 600px) { .hide-sm { display: none; } }
