/* Starfit: stile condiviso trainer + cliente + stampa.
   Bianco e nero morbido (mai #FFF/#000 puri), testata scura col logo, accento giallo Starfit. */
:root {
  --bg: #F2F2F4; --card: #F9F9FB; --card2: #E9E9ED; --line: #DCDCE1;
  --text: #2C2C2E; --muted: #66666C; --faint: #96969C;
  --head: #1E1E20; --headtext: #E8E8EC; --headmuted: #A4A4AA;
  --accent: #F3E01A; --onaccent: #1E1E20;
  --danger: #C2382F; --warn: #A86A12; --ok: #2E8A52;
  --r: 14px; --rs: 10px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
/* tema: data-theme="light" o "dark" forza, senza attributo segue il telefono */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1C1C1E; --card: #242426; --card2: #2F2F32; --line: #3A3A3E;
    --text: #DCDCE0; --muted: #A2A2A8; --faint: #76767C;
    --head: #141416; --danger: #E5675E; --warn: #E0A040; --ok: #5BBE80;
  }
}
:root[data-theme="dark"] {
  --bg: #1C1C1E; --card: #242426; --card2: #2F2F32; --line: #3A3A3E;
  --text: #DCDCE0; --muted: #A2A2A8; --faint: #76767C;
  --head: #141416; --danger: #E5675E; --warn: #E0A040; --ok: #5BBE80;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; cursor: pointer; }
img { display: block; }
a { color: inherit; }
a.li, a.tab, a.btn, a.brand { text-decoration: none; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* testata */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--head); color: var(--headtext);
  padding: calc(var(--safe-t) + 10px) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
}
.top-in { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 12px; min-height: 40px; }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; text-decoration: none; }
.brand img { height: 34px; width: auto; max-width: 160px; object-fit: contain; }
.wordmark { font-weight: 800; letter-spacing: .08em; font-size: 17px; color: var(--headtext); white-space: nowrap; }
.wordmark i { color: var(--accent); font-style: normal; }
.top .sp { flex: 1; }
.top .who { font-size: 13px; color: var(--headmuted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { max-width: 1080px; margin: 8px auto 0; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: transparent; color: var(--headmuted); padding: 9px 14px; border-radius: 999px;
  font-size: 15px; font-weight: 600; white-space: nowrap; min-height: 40px;
}
.tab.on { background: var(--accent); color: var(--onaccent); }

/* contenitore */
.wrap { max-width: 1080px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-left)) calc(32px + var(--safe-b)); }
.narrow { max-width: 640px; }
h1 { font-size: 26px; line-height: 1.2; margin: 4px 0 4px; letter-spacing: -.01em; }
h2 { font-size: 19px; margin: 24px 0 10px; }
h3 { font-size: 16px; margin: 0 0 6px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

.card { background: var(--card); border-radius: var(--r); padding: 14px; }
.card + .card { margin-top: 10px; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap-r { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }

/* bottoni */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border-radius: var(--rs);
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font-size: 15px; font-weight: 600; text-decoration: none; text-align: center;
}
.btn:active { transform: scale(.98); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--onaccent); }
.btn.dark { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn svg { width: 18px; height: 18px; flex: none; }
.iconbtn {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: inherit;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.iconbtn svg { width: 20px; height: 20px; }

/* campi */
label.f { display: block; font-size: 13px; color: var(--muted); margin: 0 0 10px; }
label.f > span { display: block; margin-bottom: 4px; }
.inp {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--rs);
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 16px;
}
textarea.inp { min-height: 80px; resize: vertical; line-height: 1.4; }
.inp:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.search { position: relative; }
.search .inp { padding-left: 38px; }
.search svg { position: absolute; left: 12px; top: 13px; width: 18px; height: 18px; color: var(--faint); }

/* chip e pillole */
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px;
  padding: 7px 14px; font-size: 14px; font-weight: 600; white-space: nowrap; min-height: 38px;
}
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--card2); color: var(--muted); }
.pill.ok { color: var(--ok); }
.pill.warn { color: var(--warn); }
.pill.bad { color: var(--danger); }

/* elenchi */
.list { background: var(--card); border-radius: var(--r); overflow: hidden; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 60px; border: 0; background: transparent; width: 100%; text-align: left; }
.li + .li { border-top: 1px solid var(--line); }
.li .t { font-weight: 600; }
.li .s { font-size: 13px; color: var(--muted); }
.chev { color: var(--faint); width: 18px; height: 18px; flex: none; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }

/* media esercizio: video, due foto alternate, segnaposto */
.media { position: relative; overflow: hidden; background: var(--card2); border-radius: 10px; aspect-ratio: 3 / 2; }
.media img, .media video { width: 100%; height: 100%; object-fit: cover; }
.media .b { position: absolute; inset: 0; animation: flip 2.4s steps(1, end) infinite; }
@keyframes flip { 0%, 49.9% { opacity: 0; } 50%, 100% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .media .b { animation: none; opacity: 0; } }
.media.ph { display: flex; align-items: center; justify-content: center; color: var(--faint); }
.media.ph svg { width: 28px; height: 28px; }
.thumb { width: 64px; flex: none; }
.badge-anim { position: absolute; right: 6px; bottom: 6px; background: rgba(30,30,32,.75); color: #EDEDF0; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; }

/* foglio dal basso (modale) */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(20,20,22,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 720px; max-height: calc(100vh - var(--safe-t) - 24px); max-height: calc(100dvh - var(--safe-t) - 24px);
  border-radius: 18px 18px 0 0; display: flex; flex-direction: column;
}
@media (min-width: 760px) { .sheet-bg { align-items: center; } .sheet { border-radius: 18px; max-height: 88vh; } }
.sheet-h { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px 16px; border-bottom: 1px solid var(--line); }
.sheet-h h3 { flex: 1; margin: 0; font-size: 17px; }
.sheet-b { overflow-y: auto; padding: 14px 16px calc(16px + var(--safe-b)); -webkit-overflow-scrolling: touch; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + var(--safe-b)); z-index: 80;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 15px; font-weight: 600;
  max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.18);
}

/* stampa A4 */
#print { display: none; }
@media print {
  @page { size: A4; margin: 11mm 10mm 12mm; }
  html, body { background: #fff !important; color: #1E1E20 !important; }
  body > *:not(#print) { display: none !important; }
  #print { display: block !important; font: 10pt/1.3 -apple-system, "Helvetica Neue", Arial, sans-serif; color: #1E1E20; }
}
.pr-head { display: flex; align-items: stretch; gap: 10px; border-bottom: 1.5pt solid #1E1E20; padding-bottom: 6pt; margin-bottom: 8pt; }
.pr-logo { background: #1E1E20; color: #F2F2F4; display: flex; align-items: center; padding: 4pt 8pt; border-radius: 3pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pr-logo img { height: 30pt; width: auto; }
.pr-logo b { font-size: 14pt; letter-spacing: .08em; }
.pr-meta { flex: 1; text-align: right; font-size: 9.5pt; line-height: 1.35; }
.pr-meta .nm { font-size: 14pt; font-weight: 700; }
.pr-notes { font-size: 9pt; margin: 0 0 8pt; padding: 5pt 7pt; border: .75pt solid #B8B8BE; border-radius: 3pt; white-space: pre-wrap; }
.pr-day { break-inside: auto; margin-bottom: 9pt; }
.pr-day h4 { font-size: 11pt; margin: 0 0 3pt; text-transform: uppercase; letter-spacing: .04em; }
.pr-t { width: 100%; border-collapse: collapse; table-layout: fixed; }
.pr-t th { font-size: 7.5pt; text-transform: uppercase; letter-spacing: .04em; text-align: left; color: #55555B; border-bottom: .75pt solid #1E1E20; padding: 2pt 3pt; }
.pr-t td { border-bottom: .5pt solid #C8C8CE; padding: 3pt; vertical-align: middle; font-size: 9.5pt; }
.pr-t tr { break-inside: avoid; }
.pr-t .im { width: 21mm; }
.pr-t .im img { width: 19mm; height: 13mm; object-fit: cover; border-radius: 2pt; filter: grayscale(1) contrast(1.05); }
.pr-t .c { text-align: center; }
.pr-t .w { border-left: .5pt solid #C8C8CE; }
.pr-t .nt { font-size: 8pt; color: #55555B; }
.pr-t .ss td { border-top: 0; }
.pr-ssl { display: inline-block; font-size: 7pt; font-weight: 700; border: .75pt solid #1E1E20; border-radius: 2pt; padding: 0 2pt; margin-right: 3pt; }
.pr-foot { margin-top: 8pt; font-size: 8pt; color: #55555B; display: flex; justify-content: space-between; gap: 10px; }
