:root {
  /* Brand NicholasRubini.it — Coach Authority */
  --bg: #0F172A;            /* Slate Deep */
  --bg2: #0B1222;           /* campi di input, un tono sotto lo sfondo */
  --card: #1E293B;          /* Slate Medium */
  --card2: #273449;
  --line: #334155;          /* Slate 700 */
  --text: #F8FAFC;          /* Off White */
  --muted: #94A3B8;         /* Slate 400 */
  --accent: #14B8A6;        /* Teal Accent: badge, highlight */
  --accent-ink: #FFFFFF;
  --blue: #3B82F6;          /* Blue Primary: azioni, link */
  --green: #10B981;         /* Emerald Soft: stati positivi */
  --amber: #F59E0B;         /* solo stato "da verificare" */
  --red: #EF4444;
  --gradient-hero: linear-gradient(135deg, #3B82F6 0%, #14B8A6 100%);
  --gradient-dark: linear-gradient(180deg, #0F172A 0%, #1E293B 100%);
  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tab-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
input, select, textarea { -webkit-user-select: text; user-select: text; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -0.025em; font-family: var(--font-display); font-weight: 800; }
.num, .big, .metric .v, .result-pop .h, .list .item .h, .lock-pad button, .pay-hero .price { font-family: var(--font-display); }
.grad-text { background: var(--gradient-hero); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.wordmark { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.03em; }
.wordmark span { background: var(--gradient-hero); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.num { font-variant-numeric: tabular-nums; }

.view {
  min-height: 100%;
  padding: calc(var(--safe-t) + 14px) 16px calc(var(--tab-h) + var(--safe-b) + 24px);
  max-width: 720px; margin: 0 auto;
}
.view.full { padding: 0; max-width: none; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(15, 23, 42, 0.92); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar svg .fill { fill: currentColor; stroke: none; }
.tabbar a.active { color: var(--accent); }
.tabbar .tab-test svg { width: 30px; height: 30px; }
body.immersive .tabbar { display: none; }

/* ---------- Generic ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; min-height: 40px; }
.topbar h1 { font-size: 30px; font-weight: 800; }
.topbar .sub { color: var(--muted); font-size: 14px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--blue); font-weight: 600; background: none; border: 0; padding: 8px 0; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card2); font-weight: 700; font-size: 16px; cursor: pointer; width: 100%; font-family: var(--font-display);
}
.btn.primary { background: var(--gradient-hero); color: #fff; border-color: transparent; box-shadow: 0 4px 15px rgba(59,130,246,.3); }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 38px; font-size: 14px; padding: 0 14px; width: auto; border-radius: 11px; }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 14px; font-weight: 600; color: var(--muted); }
.chip.on { background: var(--blue); color: #fff; border-color: transparent; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field select {
  width: 100%; height: 50px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg2); font-size: 17px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.toggle:last-child { border-bottom: 0; }
.toggle input[type=checkbox] { width: 46px; height: 28px; appearance: none; -webkit-appearance: none; background: var(--line); border-radius: 999px; position: relative; transition: .2s; flex: none; }
.toggle input[type=checkbox]::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle input[type=checkbox]:checked { background: var(--blue); }
.toggle input[type=checkbox]:checked::after { left: 21px; }
.toggle select { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; height: 36px; padding: 0 10px; }

/* ---------- Hero / metriche ---------- */
.hero { background: radial-gradient(circle at 15% 0%, rgba(59,130,246,.22) 0%, transparent 55%), radial-gradient(circle at 100% 100%, rgba(20,184,166,.18) 0%, transparent 50%), var(--card); border-color: rgba(59,130,246,.35); }
.hero .big { font-size: 64px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.hero .big small { font-size: 22px; font-weight: 700; color: var(--muted); margin-left: 4px; }
.athlete-switch { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-weight: 700; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--gradient-hero); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.avatar.lg { width: 44px; height: 44px; font-size: 17px; }

.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.metric { background: var(--bg2); border-radius: 14px; padding: 12px; border: 1px solid var(--line); }
.metric .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.metric .v { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; }
.metric .v small { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 2px; }
.metric .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
@media (min-width: 520px) { .metrics.m3 { grid-template-columns: repeat(3, 1fr); } }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: 0.02em; }
.badge.type { background: rgba(20,184,166,.14); color: var(--accent); }
.badge.pb { background: var(--gradient-hero); color: #fff; }
.badge.ready { background: rgba(53, 208, 127, 0.15); color: var(--green); }
.badge.caution { background: rgba(255, 181, 71, 0.15); color: var(--amber); }
.badge.fatigued { background: rgba(255, 90, 106, 0.15); color: var(--red); }
.badge.nodata, .badge.notest { background: var(--card2); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.bar { height: 8px; border-radius: 99px; background: var(--card2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gradient-hero); border-radius: 99px; }

.list { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--card); margin-bottom: 14px; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.list .item .h { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; min-width: 72px; text-align: right; }
.list .item .h small { font-size: 12px; color: var(--muted); }
.chev { color: var(--muted); font-size: 20px; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.empty svg { width: 54px; height: 54px; stroke: var(--line); fill: none; stroke-width: 1.5; margin-bottom: 8px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; margin: 22px 4px 10px; }

/* ---------- Calendario ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head b { font-size: 17px; text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal .wd { font-size: 11px; color: var(--muted); font-weight: 700; padding: 4px 0; }
.cal .d { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 12px; font-size: 15px; font-weight: 600; position: relative; }
.cal .d.other { opacity: 0.25; }
.cal .d.today { outline: 1.5px solid var(--muted); }
.cal .d.has::after { content: ''; position: absolute; bottom: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.cal .d.sel { background: var(--accent); color: var(--accent-ink); }
.cal .d.sel::after { background: var(--accent-ink); }

/* ---------- Grafico ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* ---------- Schermata test ---------- */
.stage { position: fixed; inset: 0; background: #000; overflow: hidden; z-index: 30; }
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stage video.mirror { transform: scaleX(-1); }
.stage .hud-top { position: absolute; left: 0; right: 0; top: 0; padding: calc(var(--safe-t) + 10px) 14px 10px; display: flex; align-items: center; gap: 10px; background: linear-gradient(#000a, #0000); }
.stage .hud-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 14px calc(var(--safe-b) + 14px); background: linear-gradient(#0000, #000c 35%); }
.stage .close { width: 42px; height: 42px; border-radius: 50%; background: #0008; border: 1px solid #fff3; display: grid; place-items: center; color: #fff; font-size: 20px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; background: #000c; border: 1px solid #fff2; font-weight: 700; font-size: 15px; }
.status-pill .dot { width: 10px; height: 10px; }
.status-pill.calibrating, .status-pill.nobody, .status-pill.recover { color: var(--amber); }
.status-pill.ready { color: var(--green); }
.status-pill.air { color: var(--accent); }
.status-pill.ready .dot { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.rec-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: #fff; padding: 6px 10px; border-radius: 999px; background: #000a; }
.rec-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: pulse 1.2s infinite; }
.result-pop { text-align: center; margin-bottom: 12px; animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.result-pop .h { font-size: 84px; font-weight: 900; letter-spacing: -0.05em; line-height: 0.95; text-shadow: 0 4px 30px #0008; }
.result-pop .h small { font-size: 28px; color: #fffa; margin-left: 4px; }
.result-pop .meta { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.result-pop .meta span { background: #000a; border: 1px solid #fff2; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.reps { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.reps::-webkit-scrollbar { display: none; }
.reps span { flex: none; background: #000a; border: 1px solid #fff2; border-radius: 10px; padding: 5px 9px; font-size: 13px; font-weight: 700; }
.reps span b { color: var(--accent); margin-right: 4px; font-weight: 800; }
.stop-btn { width: 74px; height: 74px; border-radius: 50%; border: 4px solid #fff; background: transparent; display: grid; place-items: center; margin: 0 auto; }
.stop-btn i { width: 28px; height: 28px; border-radius: 6px; background: var(--red); }
.level { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; }
.level .ring { width: 120px; height: 120px; border-radius: 50%; border: 2px solid #fff6; position: relative; margin: 0 auto 10px; }
.level .ring::before { content: ''; position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px; border-radius: 50%; border: 2px dashed #fff8; }
.level .bubble { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px; border-radius: 50%; background: var(--amber); transition: transform .1s; }
.level.ok .bubble { background: var(--green); }
.level .txt { font-weight: 700; text-shadow: 0 2px 8px #000; }
.athletes-strip { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.athletes-strip::-webkit-scrollbar { display: none; }
.athletes-strip button { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 5px; border-radius: 999px; background: #000a; border: 1px solid #fff3; color: #fff; font-weight: 700; font-size: 14px; }
.athletes-strip button .avatar { width: 26px; height: 26px; font-size: 11px; background: #fff3; color: #fff; }
.athletes-strip button.on { border-color: var(--accent); }
.athletes-strip button.on .avatar { background: var(--accent); color: var(--accent-ink); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: #fff; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid #fff3; border-top-color: var(--accent); animation: spin 0.8s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.guide-frame { position: absolute; left: 18%; right: 18%; top: 12%; bottom: 16%; border: 2px dashed #fff4; border-radius: 30px; pointer-events: none; }

/* ---------- Tips ---------- */
.tips { position: absolute; inset: 0; background: #000d; z-index: 5; display: flex; flex-direction: column; justify-content: center; padding: calc(var(--safe-t) + 20px) 22px calc(var(--safe-b) + 20px); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); overflow-y: auto; }
.tips h2 { font-size: 26px; margin-bottom: 16px; }
.tip { display: flex; gap: 14px; margin-bottom: 16px; align-items: flex-start; }
.tip b { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--gradient-hero); color: #fff; display: grid; place-items: center; font-size: 14px; }
.tip p { margin: 3px 0 0; color: #E2E8F0; }

/* ---------- Player ---------- */
.player { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 9 / 16; max-height: 62vh; margin: 0 auto 12px; }
.player video, .player canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.player .noclip { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); padding: 20px; text-align: center; }
.player-ctrl { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }

/* ---------- Sheet / toast ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; background: #0009; display: flex; align-items: flex-end; }
.sheet .panel { width: 100%; max-width: 720px; margin: 0 auto; background: var(--bg2); border-radius: 22px 22px 0 0; padding: 18px 16px calc(var(--safe-b) + 18px); max-height: 88vh; overflow-y: auto; animation: up .25s ease-out; border-top: 1px solid var(--line); }
.sheet .panel h2 { font-size: 20px; margin-bottom: 14px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 14px); transform: translateX(-50%); z-index: 60; background: var(--card2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 8px 30px #0008; }
.progress { height: 10px; background: var(--card2); border-radius: 99px; overflow: hidden; margin: 14px 0 6px; }
.progress i { display: block; height: 100%; width: 0; background: var(--gradient-hero); transition: width .2s; }

.install-hint { border-style: dashed; }
.lb-rank { width: 28px; text-align: center; font-weight: 800; color: var(--muted); }
.lb-rank.r1 { color: var(--accent); } .lb-rank.r2 { color: var(--blue); } .lb-rank.r3 { color: var(--muted); }

/* ---------- Acquisto ---------- */
.pay-hero { text-align: center; margin-bottom: 16px; }
.pay-hero .price { font-size: 40px; font-weight: 900; letter-spacing: -0.03em; }
.pay-hero .price small { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 6px; }
.feat { list-style: none; padding: 0; margin: 0 0 18px; }
.feat li { display: flex; gap: 10px; padding: 7px 0; font-size: 15px; }
.feat li::before { content: '✓'; color: var(--accent); font-weight: 900; flex: none; }
.code-box { font: 800 22px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.06em; text-align: center; padding: 16px; border-radius: 14px; background: var(--bg); border: 1px dashed var(--accent); color: var(--accent); margin: 12px 0; -webkit-user-select: all; user-select: all; }
.trial-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.code-input { text-transform: uppercase; letter-spacing: 0.06em; font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ---------- Test: protocollo e fps ---------- */
.proto-chips { margin-bottom: 12px; }
.proto-chips .chip { background: #000a; border-color: #fff3; color: #fff; }
.proto-chips .chip.on { background: var(--blue); color: #fff; border-color: transparent; }
.fps-meter { position: absolute; right: 14px; top: calc(var(--safe-t) + 62px); font-size: 12px; font-weight: 700; color: #fffc; background: #0008; padding: 3px 8px; border-radius: 8px; }
.fps-meter:empty { display: none; }
.fps-meter.low { color: var(--amber); }
details.card summary { list-style: none; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary::after { content: ' ›'; color: var(--muted); }
details.card[open] summary::after { content: ' ⌄'; }

/* unità e note accanto ai numeri grandi: font del testo, spaziatura normale */
.num small, .big small, .metric .v small, .result-pop .h small, .list .item .h small, .pay-hero .price small { font-family: var(--font-body); letter-spacing: 0; }

/* drop jump: fotogrammi ingranditi sui piedi da confermare */
.dj-ev { padding: 12px 0; border-top: 1px solid var(--line, #ffffff14); }
.dj-ev:first-of-type { border-top: 0; }
.dj-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dj-th { position: relative; padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: #000; cursor: pointer; }
.dj-th canvas { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; }
.dj-th span { position: absolute; left: 4px; top: 3px; font-size: 11px; font-weight: 700; color: #fff; background: #0009; border-radius: 6px; padding: 1px 5px; }
.dj-th.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
@media (min-width: 560px) { .dj-strip { grid-template-columns: repeat(4, 1fr); } }
.chip.locked { opacity: .55; }
.chip.locked small { font-size: 10px; font-weight: 800; color: var(--accent); }
