/* GymTrack — design dark + neon green, ottimizzato iPhone 17 Pro */
:root {
  --bg: #0a0a0a;
  --bg-900: #171717;
  --bg-800: #262626;
  --bg-700: #404040;
  --text: #ffffff;
  --text-muted: #a3a3a3;
  --text-dim: #737373;
  --accent: #39FF14;
  --danger: #ef4444;
  --radius: 24px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* Scrollbar nascoste ovunque (lo scroll resta attivo) */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }

html, body {
  background: var(--bg);
  color: var(--text);
  color-scheme: dark;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { min-height: 100vh; min-height: 100dvh; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; touch-action: manipulation; }
input { font-family: inherit; }

#app { max-width: 600px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; overflow-x: hidden; overflow-x: clip; }

.screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

/* --- Header (sticky, rispetta la Dynamic Island) --- */
.header {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg-900);
  padding: calc(var(--safe-top) + 18px) 22px 18px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.header.round { border-radius: 0 0 28px 28px; }
.welcome-row { display: flex; align-items: center; gap: 14px; min-width: 0; }
.header-avatar {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  background: var(--bg-900); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--accent);
}
.header-avatar .avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.header h1 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.header .grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { flex: 1; padding: 22px; padding-bottom: calc(var(--safe-bottom) + 40px); }
.content.with-cta { padding-bottom: calc(var(--safe-bottom) + 120px); }

/* --- Bottoni base --- */
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--bg-800); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: transform .1s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.danger { background: rgba(239,68,68,.15); color: var(--danger); }
.icon-btn.accent { background: rgba(57,255,20,.14); color: var(--accent); }

.btn-accent {
  background: var(--accent); color: #0a0a0a; font-weight: 800;
  border-radius: 16px; padding: 12px 20px; font-size: 16px;
  transition: transform .1s;
}
.btn-accent:active { transform: scale(.95); }

.label-accent { color: var(--accent); font-weight: 800; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; }

/* --- Cards --- */
.card {
  background: var(--bg-800); border-radius: var(--radius); padding: 22px;
  width: 100%; text-align: left; transition: transform .1s;
}
.card:active { transform: scale(.97); }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 12px; }

/* --- Selezione profilo --- */
.profile-select { justify-content: center; align-items: center; padding: 40px 24px calc(var(--safe-bottom) + 24px); }
.brand { text-align: center; margin-bottom: 48px; }
.brand .logo {
  width: 88px; height: 88px; border-radius: 26px; background: var(--bg-900);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 18px;
  box-shadow: 0 0 40px rgba(57,255,20,.25);
}
.brand h1 { font-size: 40px; font-weight: 900; letter-spacing: -.03em; text-transform: uppercase; }
.brand .accent { color: var(--accent); }
.brand p { color: var(--text-muted); margin-top: 8px; font-weight: 500; }

.profile-list { width: 100%; max-width: 420px; }
.profile-card {
  position: relative; width: 100%; background: var(--bg-800); border-radius: 28px; overflow: hidden;
}
.profile-pick {
  width: 100%; background: none; padding: 30px; border-radius: 28px;
  display: flex; flex-direction: column; align-items: center; gap: 14px; transition: transform .1s;
}
.profile-pick:active { transform: scale(.95); }
.profile-avatar {
  width: 92px; height: 92px; border-radius: 50%; background: var(--bg-900); color: var(--accent);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.profile-avatar .avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-pick span { font-size: 28px; font-weight: 800; }
.profile-actions { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; }
.pa-btn {
  width: 38px; height: 38px; border-radius: 50%; background: var(--bg-900); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; transition: transform .1s, color .15s;
}
.pa-btn:active { transform: scale(.9); }
.pa-btn.danger { color: #ff5a5a; }
.add-profile { width: 100%; background: var(--bg-900); color: var(--accent); padding: 18px; border-radius: 20px; font-weight: 800; }

/* --- Dashboard --- */
.welcome p { font-size: 13px; }
.welcome h1 { font-size: 36px; font-weight: 900; letter-spacing: -.02em; }

.cta-big {
  width: 100%; background: var(--accent); color: #0a0a0a; padding: 24px;
  border-radius: var(--radius); font-weight: 900; font-size: 20px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 0 24px rgba(57,255,20,.22); transition: transform .1s;
}
.cta-big:active { transform: scale(.96); }
.cta-big .left { display: flex; align-items: center; gap: 16px; }
.cta-big.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 24px rgba(57,255,20,.22);} 50% { box-shadow: 0 0 36px rgba(57,255,20,.5);} }
.cta-sub { display: block; font-size: 12px; opacity: .8; text-transform: uppercase; letter-spacing: .12em; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tile {
  background: var(--bg-800); padding: 24px; border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; gap: 12px; transition: transform .1s;
}
.tile:active { transform: scale(.95); }
.tile .ic { padding: 12px; background: var(--bg-900); border-radius: 16px; color: var(--accent); }
.tile span { font-weight: 700; }

h2.section { font-size: 20px; font-weight: 800; margin-bottom: 16px; }

.history-row {
  width: 100%; background: var(--bg-800); padding: 20px; border-radius: 18px;
  display: flex; align-items: center; justify-content: space-between; text-align: left; transition: transform .1s;
}
.history-row:active { transform: scale(.97); }
.history-row h3 { color: var(--accent); font-size: 18px; font-weight: 800; }
.history-row p { color: var(--text-muted); font-size: 14px; font-weight: 500; margin-top: 2px; }
.meta { display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 13px; font-weight: 700; margin-top: 10px; }

.empty { background: var(--bg-900); padding: 28px; border-radius: 20px; text-align: center; color: var(--text-dim); font-weight: 500; }

/* --- Input --- */
.field-label { display: block; margin-bottom: 12px; }
.input {
  width: 100%; background: var(--bg-800); padding: 18px; border-radius: 18px;
  font-size: 18px; font-weight: 700; color: var(--text); outline: none; border: 2px solid transparent;
}
.input:focus { border-color: var(--accent); }
.input-num {
  flex: 1; background: var(--bg-800); color: var(--text); text-align: center;
  font-size: 22px; font-weight: 800; padding: 14px 6px; border-radius: 14px; outline: none; border: none; min-width: 0;
}
.input-num:focus { background: var(--bg); }

/* --- Crea scheda --- */
.day-card { background: var(--bg-900); border-radius: 26px; padding: 20px; }
.day-name-input { background: var(--bg-800); padding: 14px 16px; border-radius: 14px; font-size: 18px; font-weight: 800; width: 100%; outline: none; border: 2px solid transparent; color: var(--text); }
.day-name-input:focus { border-color: var(--accent); }
.ex-row { display: flex; align-items: center; justify-content: space-between; background: var(--bg-800); padding: 16px; border-radius: 14px; gap: 12px; }
.ex-row .name { font-weight: 700; font-size: 16px; }
.ex-row .type { display: block; font-size: 13px; color: var(--accent); font-weight: 500; margin-top: 2px; }
.add-line { width: 100%; background: var(--bg-800); color: var(--accent); padding: 16px; border-radius: 18px; font-weight: 800; font-size: 16px; }
.add-day { width: 100%; background: var(--bg-800); padding: 18px; border-radius: 24px; font-weight: 800; display: flex; justify-content: center; align-items: center; gap: 8px; }

/* --- Libreria esercizi --- */
.cat-title { color: var(--accent); font-weight: 900; font-size: 18px; text-transform: uppercase; letter-spacing: .12em; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.lib-row { width: 100%; background: var(--bg-800); padding: 16px; border-radius: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; transition: transform .1s; }
.lib-row:active { transform: scale(.97); }
.lib-row .name { font-weight: 700; font-size: 16px; }
.lib-row .sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.lib-row .info-ic { width: 38px; height: 38px; border-radius: 12px; background: var(--bg-900); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.lib-row .info-ic.danger { color: #ff5a5a; }
.stack-sm > .cat-title:not(:first-child) { margin-top: 22px; }

/* select / textarea ereditano lo stile input */
select.input { appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2339ff14' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; padding-right: 44px; }
textarea.input { font-size: 16px; font-weight: 500; line-height: 1.5; resize: vertical; font-family: inherit; }

/* --- Schede di allenamento (gestione) --- */
.routine-card { display: flex; align-items: stretch; gap: 10px; }
.routine-main { flex: 1; background: var(--bg-800); padding: 20px; border-radius: 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; transition: transform .1s; }
.routine-main:active { transform: scale(.97); }
.routine-name { font-weight: 800; font-size: 18px; display: block; }
.routine-meta { font-size: 14px; color: var(--text-muted); margin-top: 3px; display: block; }
.routine-card > .icon-btn { background: var(--bg-800); border-radius: 22px; width: 56px; height: auto; align-self: stretch; }
.icon-btn.danger { color: #ff5a5a; }

/* --- Mappa del corpo --- */
.bodymap { display: flex; gap: 12px; background: var(--bg-900); border-radius: 24px; padding: 16px 8px 10px; }
.bm-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bm-col svg { width: 100%; max-height: 220px; }
.bm-cap { font-size: 12px; font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: .1em; }
.silh { fill: #3c3c42; stroke: none; }
.bm-col svg .face { fill: var(--bg-900); stroke: var(--bg-900); stroke-width: 1; }
.bm-col svg .hint { fill: none; stroke: var(--text-dim); stroke-width: 1.4; stroke-linecap: round; opacity: .7; }
.map-dot { cursor: pointer; }
.map-dot .hit { fill: transparent; }
.map-dot .pt { fill: var(--text-muted); transition: fill .15s, r .15s; }
.map-dot:active .pt { fill: var(--accent); }
.map-dot.on .pt { fill: var(--accent); r: 7; }

/* --- Segmento ordinamento --- */
.seg { display: flex; background: var(--bg-900); border-radius: 16px; padding: 4px; gap: 4px; }
.seg-btn { flex: 1; padding: 12px; border-radius: 12px; font-weight: 800; font-size: 15px; color: var(--text-muted); transition: background .15s, color .15s; }
.seg-btn.on { background: var(--accent); color: #061a00; }

/* --- Chip zone --- */
.zone-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.zchip { padding: 9px 14px; border-radius: 999px; background: var(--bg-800); color: var(--text-muted); font-weight: 700; font-size: 14px; transition: background .15s, color .15s; }
.zchip.on { background: var(--accent); color: #061a00; }

/* --- Opzioni profilo --- */
.opt-photo { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.opt-avatar { width: 110px; height: 110px; border-radius: 50%; overflow: hidden; background: var(--bg-900); color: var(--accent); display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 3px var(--accent); }
.opt-avatar .avatar-img { width: 100%; height: 100%; object-fit: cover; }
.grid2-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2-form > div { min-width: 0; }
.grid2-form .input { width: 100%; min-width: 0; }
/* l'input data nativo non deve sforare il bordo */
input[type="date"].input { -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; }

/* Toggle aptico nelle opzioni */
.opt-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; background: var(--bg-800); padding: 16px 18px; border-radius: 18px; font-weight: 700; font-size: 15px; color: var(--text); }
.opt-toggle .switch { width: 50px; height: 30px; border-radius: 999px; background: var(--bg-700); position: relative; transition: background .15s; flex-shrink: 0; }
.opt-toggle .knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.opt-toggle.on .switch { background: var(--accent); }
.opt-toggle.on .knob { transform: translateX(20px); }
.opt-sep { height: 1px; background: var(--bg-700); margin: 6px 0; }
.danger-line { color: #ff5a5a !important; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* --- Crop foto --- */
.crop-overlay { position: fixed; inset: 0; z-index: 140; background: rgba(0,0,0,.95); display: flex; align-items: center; justify-content: center; padding: 24px; }
.crop-box { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.crop-title { color: #fff; font-weight: 800; font-size: 17px; }
.crop-viewport { position: relative; width: 280px; height: 280px; max-width: 78vw; max-height: 78vw; overflow: hidden; border-radius: 16px; background: #000; touch-action: none; cursor: grab; }
.crop-viewport img { position: absolute; top: 0; left: 0; user-select: none; -webkit-user-drag: none; max-width: none; }
.crop-ring { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 2000px rgba(0,0,0,.55); pointer-events: none; }
.crop-slider { width: 100%; max-width: 280px; accent-color: var(--accent); }
.crop-actions { display: flex; gap: 12px; width: 100%; }
.crop-actions .btn, .crop-actions .btn-soft { flex: 1; width: auto; padding: 16px; font-size: 17px; }

/* --- Gestione utenti (superadmin) --- */
.admin-user { background: var(--bg-800); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.admin-user-top { display: flex; align-items: center; gap: 12px; }
.admin-user-top .name { font-weight: 700; font-size: 16px; }
.admin-user-top .sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; display: block; }
.admin-user-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-900); color: var(--text); padding: 9px 12px; border-radius: 12px; font-weight: 700; font-size: 13px; }
.chip-btn.danger { color: #ff5a5a; }
.chip-btn:active { transform: scale(.95); }

/* --- Allenamento attivo --- */
.ex-item { width: 100%; text-align: left; padding: 20px; border-radius: var(--radius); background: var(--bg-800); display: flex; align-items: center; justify-content: space-between; gap: 14px; transition: transform .1s; }
.ex-item:active { transform: scale(.97); }
.ex-item.done { background: rgba(57,255,20,.1); border: 1px solid rgba(57,255,20,.3); }
.ex-item .drag-handle { flex-shrink: 0; }
.ex-item.dragging { opacity: .55; outline: 2px solid var(--accent); }
.ex-num { width: 32px; height: 32px; border-radius: 50%; background: var(--bg-900); color: var(--text-muted); display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 14px; flex-shrink: 0; }
.ex-num.done { background: var(--accent); color: #0a0a0a; }
.set-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0 44px; }
.chip { font-size: 13px; font-weight: 700; background: var(--bg-900); padding: 5px 12px; border-radius: 10px; }
.check-circle { width: 40px; height: 40px; background: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #0a0a0a; flex-shrink: 0; box-shadow: 0 0 15px rgba(57,255,20,.4); }

.bottom-cta {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  padding: 22px 22px calc(var(--safe-bottom) + 22px);
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  max-width: 600px; margin: 0 auto;
}
.bottom-cta .btn {
  width: 100%; background: var(--accent); color: #0a0a0a; padding: 22px; border-radius: var(--radius);
  font-weight: 900; font-size: 20px; display: flex; align-items: center; justify-content: center; gap: 12px;
  box-shadow: 0 0 24px rgba(57,255,20,.3); transition: transform .1s;
}
.bottom-cta .btn:active { transform: scale(.96); }
/* barra tracker: aggiungi serie a sinistra, salva a destra */
.bottom-cta.tracker-bar { display: flex; gap: 12px; }
.bottom-cta.tracker-bar .btn, .bottom-cta.tracker-bar .btn-soft { flex: 1; width: auto; }
.btn-soft {
  background: var(--bg-800); color: var(--accent); padding: 22px; border-radius: var(--radius);
  font-weight: 900; font-size: 18px; display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .1s;
}
.btn-soft:active { transform: scale(.96); }
.done-check { color: var(--accent); display: inline-flex; }

/* --- Tracker serie --- */
.last-session { background: var(--bg-900); border-radius: var(--radius); padding: 20px; border: 1px solid rgba(57,255,20,.2); }
.last-session .head { display: flex; align-items: center; gap: 8px; color: var(--accent); margin-bottom: 14px; font-weight: 900; text-transform: uppercase; letter-spacing: .1em; font-size: 13px; }
.last-set { background: var(--bg-800); padding: 8px 12px; border-radius: 12px; font-weight: 700; }
.set-head { display: flex; gap: 14px; padding: 0 6px; font-size: 11px; font-weight: 900; color: var(--text-dim); text-transform: uppercase; letter-spacing: .12em; }
.set-head .w12 { width: 48px; text-align: center; }
.set-head .col { flex: 1; text-align: center; }
.set-row { display: flex; align-items: center; gap: 14px; background: var(--bg-900); padding: 12px; border-radius: 18px; }
.set-row .num { width: 48px; height: 48px; background: var(--bg-800); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-weight: 900; color: var(--text-muted); flex-shrink: 0; }
.set-row .del { width: 48px; height: 48px; background: rgba(239,68,68,.1); color: var(--danger); border-radius: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* --- Dettaglio storico --- */
.detail-ex { background: var(--bg-900); padding: 22px; border-radius: var(--radius); }
.detail-ex h3 { font-weight: 900; font-size: 17px; margin-bottom: 14px; display: flex; align-items: center; gap: 12px; }
.detail-set { display: flex; justify-content: space-between; align-items: center; background: var(--bg-800); padding: 14px; border-radius: 16px; }
.detail-set .lbl { color: var(--text-muted); font-weight: 900; }
.detail-set .val { color: var(--accent); font-weight: 900; font-size: 17px; }

/* --- Modal --- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 120; }
.modal { background: var(--bg-900); padding: 30px; border-radius: 28px; width: 100%; max-width: 380px; }
.modal h3 { font-size: 22px; font-weight: 900; margin-bottom: 8px; }
.modal p { color: var(--text-muted); margin-bottom: 28px; font-weight: 500; }
.modal .btn-row { display: flex; flex-direction: column; gap: 14px; }
.btn-danger { width: 100%; background: var(--danger); color: #fff; padding: 16px; border-radius: 18px; font-weight: 900; }
.btn-ghost { width: 100%; background: var(--bg-800); color: var(--text); padding: 16px; border-radius: 18px; font-weight: 900; }

/* --- Tutorial esercizio (sheet) --- */
.sheet-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg-900); width: 100%; max-width: 600px; max-height: 92dvh; border-radius: 28px 28px 0 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding-bottom: calc(var(--safe-bottom) + 24px); animation: slideUp .25s ease; }
@keyframes slideUp { from { transform: translateY(100%);} to { transform: translateY(0);} }
.sheet-handle { width: 44px; height: 5px; background: var(--bg-700); border-radius: 3px; margin: 12px auto; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 4px 22px 16px; gap: 12px; }
.sheet-head h2 { font-size: 24px; font-weight: 900; letter-spacing: -.02em; }
.sheet-head .badge { display: inline-block; margin-top: 8px; font-size: 12px; color: var(--accent); font-weight: 800; background: rgba(57,255,20,.1); padding: 4px 10px; border-radius: 8px; }
.video-wrap { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-wrap.loading { display: flex; align-items: center; justify-content: center; }
.video-wrap.loading .spinner { margin: 0; }
.video-fallback { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  width: 100%; aspect-ratio: 16/9; background: #000; color: var(--accent); text-decoration: none; font-weight: 800; }
.sheet-body { padding: 22px; }
.sheet-body h4 { font-size: 13px; font-weight: 900; color: var(--accent); text-transform: uppercase; letter-spacing: .12em; margin: 22px 0 12px; display: flex; align-items: center; gap: 8px; }
.sheet-body h4:first-child { margin-top: 0; }
.muscle-line { color: var(--text-muted); font-weight: 600; line-height: 1.5; }
.step { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--bg-800); }
.step:last-child { border-bottom: none; }
.step .n { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #0a0a0a; font-weight: 900; font-size: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step .txt { line-height: 1.45; padding-top: 3px; }
.tip { display: flex; gap: 10px; padding: 8px 0; line-height: 1.45; color: var(--text-muted); }
.tip .dot { color: var(--accent); font-weight: 900; }
.yt-link { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; background: var(--bg-800); color: var(--text); padding: 16px; border-radius: 18px; font-weight: 800; margin-top: 8px; text-decoration: none; }

/* --- Toast --- */
.toast {
  position: fixed; top: 0; left: 0; right: 0; z-index: 250;
  display: none; align-items: center; justify-content: center;
  min-height: calc(var(--safe-top) + 80px); padding: calc(var(--safe-top) + 10px) 22px 16px;
  background: var(--accent); color: #061a00; font-weight: 900; font-size: 18px; line-height: 1.25; text-align: center;
  box-shadow: 0 6px 24px rgba(0,0,0,.5); opacity: 0;
}
.toast.show { display: flex; animation: toastFade 1s ease forwards; }
@keyframes toastFade { 0% { opacity: 0; } 15% { opacity: 1; } 78% { opacity: 1; } 100% { opacity: 0; } }

/* --- Login --- */
.gate { justify-content: center; align-items: center; padding: 40px 24px; }
/* campi e pulsante ENTRA tutti alla stessa larghezza del contenitore */
.gate .stack { width: 100%; max-width: 340px; }
.gate .input, .gate .btn-accent { width: 100%; max-width: 100%; }

.spinner { width: 38px; height: 38px; border: 4px solid var(--bg-800); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 80px auto; }
@keyframes spin { to { transform: rotate(360deg);} }

/* Onda alla pressione dei pulsanti */
.ripple { position: absolute; border-radius: 50%; background: rgba(57,255,20,.35); transform: scale(0); animation: rippleAnim .5s ease-out; pointer-events: none; z-index: 1; }
@keyframes rippleAnim { to { transform: scale(2.3); opacity: 0; } }

/* Etichette e divisore dei filtri libreria */
.filter-label { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; margin: 2px 0 -4px; }
.filter-divider { height: 1px; background: var(--bg-700); margin: 14px 0 4px; }
.bodymap { margin-bottom: 14px; }
/* campo ricerca con X per cancellare */
.search-wrap { position: relative; }
.search-wrap .input { padding-right: 48px; }
.search-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 50%; background: var(--bg-700); color: var(--text); display: flex; align-items: center; justify-content: center; }
/* lo scroll ai risultati non finisce sotto l'header sticky */
.cat-title, .lib-row { scroll-margin-top: 84px; }
.lib-row-main { flex: 1; min-width: 0; }
[data-act] { cursor: pointer; }

/* valori non compilati (placeholder) molto più tenui */
.input::placeholder, textarea.input::placeholder { color: #565656; opacity: 1; }
/* icona info più grande nelle righe libreria */
.info-ic.big { width: 46px; height: 46px; }
/* chip filtri giustificati (riempiono la riga) */
.zone-chips .zchip { flex: 1 1 auto; text-align: center; white-space: nowrap; }
/* pulsante Nuova scheda: verde e font grande */
.new-routine-btn { width: 100%; background: var(--accent); color: #061a00; padding: 20px; border-radius: 20px; font-weight: 900; font-size: 19px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.new-routine-btn:active { transform: scale(.97); }
/* riordino esercizi (drag su/giù) */
.ex-list { display: flex; flex-direction: column; gap: 10px; }
.ex-row { display: flex; align-items: center; gap: 10px; }
.drag-handle { color: var(--text-dim); flex-shrink: 0; touch-action: none; cursor: grab; display: flex; }
.ex-row-body { flex: 1; min-width: 0; }
.ex-row.dragging { opacity: .55; outline: 2px solid var(--accent); background: var(--bg-700); }
/* niente selezione testo / menu iOS quando si tiene premuto per trascinare */
.ex-row, .ex-item, .drag-handle { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.about-logo svg { color: var(--accent); }
/* animazione di entrata nelle sezioni */
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.screen.view-enter .content { animation: viewIn .24s ease both; }

/* footer login (in fondo alla pagina) */
.screen.gate { position: relative; }
.login-footer { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 18px); text-align: center; display: flex; flex-direction: column; gap: 4px; color: var(--text-dim); font-size: 12px; }
.login-footer b { color: var(--text-muted); }
/* badge contatore messaggi non letti */
.badge-count { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: #061a00; font-size: 11px; font-weight: 900; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--bg-900); }

/* messaggi / segnalazioni (stile SMS) */
.msg-row { width: 100%; text-align: left; background: var(--bg-800); border-radius: 18px; padding: 15px 16px; display: flex; flex-direction: column; gap: 5px; }
.msg-row.unread { border: 1px solid rgba(57,255,20,.4); }
.msg-row:active { transform: scale(.98); }
.msg-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.msg-from { font-weight: 800; font-size: 14px; color: var(--accent); display: flex; align-items: center; gap: 6px; }
.dot-new { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
.msg-date { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.msg-title { font-weight: 800; font-size: 16px; }
.msg-prev { font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-meta { color: var(--text-muted); font-size: 14px; }
.msg-body { background: var(--bg-800); border-radius: 18px; padding: 18px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }

/* Bottone espandi video + video a schermo intero */
.video-wrap .video-expand { position: absolute; right: 8px; bottom: 8px; width: 40px; height: 40px; border-radius: 12px; background: rgba(0,0,0,.6); color: #fff; display: flex; align-items: center; justify-content: center; z-index: 2; }
.videofull-overlay { position: fixed; inset: 0; z-index: 150; background: #000; display: flex; align-items: center; justify-content: center; }
.videofull-frame { width: 100%; height: 100%; }
.videofull-frame iframe { width: 100%; height: 100%; border: 0; }
.videofull-close { position: fixed; top: calc(var(--safe-top) + 10px); right: 14px; z-index: 151; width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff; display: flex; align-items: center; justify-content: center; }

/* About */
.about-body { text-align: left; }
.about-logo { display: flex; justify-content: center; }
.about-tag { text-align: center; color: var(--accent); font-weight: 800; font-size: 16px; }
.about-body p { color: var(--text-muted); line-height: 1.6; }
.about-body h4 { color: var(--text); display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.about-list { display: flex; flex-direction: column; gap: 6px; color: var(--text-muted); }
.about-meta { display: flex; flex-direction: column; gap: 4px; color: var(--text-dim); font-size: 13px; margin-top: 12px; }

/* ===== Compatibilità universale (Android + tutti i telefoni) ===== */
/* Titoli scalabili per non sforare su schermi stretti */
.brand h1 { font-size: clamp(30px, 9vw, 40px); }
.welcome h1 { font-size: clamp(26px, 7.5vw, 36px); overflow-wrap: anywhere; }

/* Telefoni piccoli (<= 360px): riduci spazi e dimensioni */
@media (max-width: 360px) {
  .content { padding: 16px; }
  .header { padding: calc(var(--safe-top) + 14px) 16px 14px; gap: 12px; }
  .grid2 { gap: 10px; }
  .tile { padding: 18px; }
  .cta-big { padding: 20px; }
  .bottom-cta { padding: 16px 16px calc(var(--safe-bottom) + 16px); }
  .bottom-cta .btn, .btn-soft { padding: 18px; font-size: 17px; }
  .zchip { padding: 8px 12px; font-size: 13px; }
}

/* Schermi molto bassi (landscape o telefoni corti): niente min-height forzata che taglia */
@media (max-height: 520px) {
  .screen { min-height: auto; }
}

/* Tablet / schermi larghi: l'app resta a larghezza telefono, centrata e con bordi morbidi */
@media (min-width: 640px) {
  #app { box-shadow: 0 0 60px rgba(0,0,0,.6); }
}
