:root{
  --bg:#0A0A0C;
  --surface:#18181B;
  --surface-2:#212125;
  --line:#2C2C31;
  --text:#F6F5F3;
  --muted:#8F8F97;
  --accent:#FF7A3D;
  --accent-2:#FFB648;
  --accent-ink:#FFFFFF;
  --orange:#FF8A4C;
  --teal:#39DDC4;
  --purple:#9D7BFF;
  --pink:#FF5C93;
  --blue:#4FA6FF;
  --warn:#FF6B57;
  --radius:22px;
  --maxw:520px;
  --grad-accent:linear-gradient(135deg, var(--accent), var(--accent-2));
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  background:var(--bg);
  color:var(--text);
  font-family:'Manrope','Work Sans',sans-serif;
  font-size:15px;
  line-height:1.45;
  -webkit-font-smoothing:antialiased;
  padding-bottom:100px;
}

h1,h2,h3,.display{
  font-family:'Archivo Black','Manrope',sans-serif;
  font-weight:400;
  letter-spacing:0.01em;
  text-transform:uppercase;
  margin:0;
  color:var(--text);
}

.topbar{
  position:sticky; top:0; z-index:20;
  display:flex; align-items:baseline; justify-content:space-between;
  padding:18px 20px 12px;
  background:var(--bg);
  max-width:var(--maxw); margin:0 auto;
}
.brand{
  font-family:'Archivo Black',sans-serif;
  font-weight:400; font-size:19px; letter-spacing:0.02em;
  color:var(--text);
}
.brand em{
  font-style:normal;
  background:var(--grad-accent);
  -webkit-background-clip:text; background-clip:text; color:transparent;
}
.topbar-date{font-size:13px; color:var(--muted); font-weight:600;}

#app{max-width:var(--maxw); margin:0 auto; padding:6px 20px 20px;}

.section-title{
  font-size:25px; line-height:1.12; margin-bottom:4px;
}
.section-sub{color:var(--muted); font-size:14px; margin-bottom:18px; text-transform:none;}

.card{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:18px;
  margin-bottom:14px;
}

.row{display:flex; gap:10px;}
.col{flex:1;}

/* Stat pill row (esercizi / durata / kcal) */
.statrow{display:flex; gap:10px; margin:14px 0;}
.statpill{
  flex:1; background:var(--surface-2); border-radius:16px; padding:12px 10px 11px;
  text-align:center; border-top:3px solid var(--accent);
}
.statpill:nth-child(2){border-top-color:var(--teal);}
.statpill:nth-child(3){border-top-color:var(--purple);}
.statpill .sv{font-size:17px; font-weight:800; color:var(--text); display:block; font-family:'Archivo Black',sans-serif; font-weight:400;}
.statpill .sl{font-size:10px; color:var(--muted); margin-top:3px; display:block; text-transform:uppercase; letter-spacing:.04em; font-weight:700;}

/* Icon badges */
.badge{
  width:42px; height:42px; border-radius:14px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
  background:var(--grad-accent); color:#fff;
  box-shadow:0 6px 16px -4px rgba(255,122,61,0.55);
}
.badge.orange{background:var(--grad-accent); color:#fff;}
.badge.purple{background:linear-gradient(135deg,var(--purple),#6E5AD1); color:#fff;}
.badge.pink{background:linear-gradient(135deg,var(--pink),#D13E73); color:#fff;}
.badge.blue{background:linear-gradient(135deg,var(--blue),#2E7FE0); color:#fff;}
.badge.green{background:var(--grad-accent); color:#fff;}
.badge svg{width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round;}

/* Chip selection */
.chipset{display:flex; flex-wrap:wrap; gap:8px; margin:8px 0 4px;}
.chip{
  border:1.5px solid var(--line);
  background:var(--surface-2);
  color:var(--text);
  padding:9px 14px;
  border-radius:999px;
  font-size:14px;
  font-weight:600;
  cursor:pointer;
  user-select:none;
  transition:border-color .15s, background .15s, color .15s;
}
.chip.selected{
  background:var(--grad-accent);
  border-color:transparent;
  color:#fff;
}

label.field-label{
  display:block; font-size:12px; font-weight:800; color:var(--muted);
  margin:14px 0 2px; text-transform:uppercase; letter-spacing:.04em;
}
input[type=number], input[type=text], select, textarea{
  width:100%;
  border:1.5px solid var(--line);
  border-radius:14px;
  padding:11px 12px;
  font-size:16px;
  font-family:inherit;
  background:var(--surface-2);
  color:var(--text);
}
input::placeholder, textarea::placeholder{color:var(--muted);}
input:focus, select:focus, textarea:focus{outline:2px solid var(--accent); outline-offset:1px;}

button.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  border:none; border-radius:999px;
  padding:15px 20px;
  font-size:15px; font-weight:800;
  font-family:'Manrope',sans-serif;
  cursor:pointer;
  width:100%;
}
.btn-primary{background:var(--grad-accent); color:#fff; box-shadow:0 10px 24px -8px rgba(255,122,61,0.55);}
.btn-effort{background:var(--grad-accent); color:#fff; box-shadow:0 10px 24px -8px rgba(255,122,61,0.55);}
.btn-nutrition{background:var(--grad-accent); color:#fff; box-shadow:0 10px 24px -8px rgba(255,122,61,0.55);}
.btn-effort::after, .btn-primary::after{content:'→'; font-weight:700;}
.btn-ghost{background:var(--surface-2); color:var(--text); border:1.5px solid var(--line);}
.btn-sm{padding:9px 14px; font-size:13px; width:auto; border-radius:12px;}
.btn-sm::after{content:none;}

/* Day block — poster card with gradient glow instead of photography */
.day-block{
  position:relative; overflow:hidden;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255,122,61,0.28), transparent 60%),
    linear-gradient(180deg, #1D1B1E, var(--surface));
  border:1px solid var(--line); border-radius:var(--radius);
  padding:20px; margin-bottom:16px;
}
.day-num{
  font-weight:800; font-size:11px; letter-spacing:.12em;
  color:var(--accent-2); text-transform:uppercase;
}
.day-title{
  font-size:21px; margin:4px 0 4px; text-transform:uppercase; font-family:'Archivo Black',sans-serif; font-weight:400;
}
.exercise-row{
  display:flex; justify-content:space-between; align-items:center;
  padding:12px 0; border-bottom:1px solid var(--line);
  gap:10px;
}
.exercise-row:last-child{border-bottom:none;}
.exercise-left{display:flex; align-items:center; gap:11px;}
.exercise-thumb{
  width:42px; height:42px; border-radius:13px; background:var(--surface-2);
  display:flex; align-items:center; justify-content:center; color:var(--accent-2); flex-shrink:0;
  border:1px solid var(--line);
}
.exercise-thumb svg{width:19px; height:19px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round;}
.exercise-name{font-weight:700; font-size:14px; color:var(--text);}
.exercise-meta{color:var(--muted); font-size:12.5px; margin-top:1px;}
.exercise-sets{font-variant-numeric:tabular-nums; font-weight:800; font-size:14px; white-space:nowrap; color:var(--accent-2);}

/* Ring (kcal) */
.ring-wrap{display:flex; align-items:center; gap:18px;}
.ring-box{position:relative; width:96px; height:96px; flex-shrink:0;}
.ring-box svg{position:absolute; top:0; left:0;}
.ring-center{position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center;}
.ring-center-val{font-size:20px; font-weight:400; font-family:'Archivo Black',sans-serif; color:var(--text); line-height:1.1;}
.ring-center-lbl{font-size:10.5px; color:var(--muted); margin-top:2px;}
.macro-list{flex:1; display:flex; flex-direction:column; gap:10px;}
.macro-item{display:flex; align-items:center; gap:10px;}
.macro-dot{width:9px; height:9px; border-radius:50%; flex-shrink:0;}
.macro-item .mi-label{font-size:12.5px; color:var(--muted);}
.macro-item .mi-val{font-size:13.5px; font-weight:800; color:var(--text);}

.macro-bar-track{
  background:var(--surface-2); border-radius:6px; height:7px; overflow:hidden; margin-top:6px;
}
.macro-bar-fill{height:100%; border-radius:6px; background:var(--grad-accent);}
.macro-bar-fill.over{background:var(--warn);}
.kcal-big{font-weight:400; font-family:'Archivo Black',sans-serif; font-size:36px; line-height:1; color:var(--text);}
.kcal-big small{font-family:'Work Sans',sans-serif; font-weight:500; font-size:14px; color:var(--muted); text-transform:none;}

.foodlog-item{
  display:flex; justify-content:space-between; align-items:center; padding:10px 0; border-bottom:1px solid var(--line); font-size:14px;
}
.foodlog-item:last-child{border-bottom:none;}
.foodlog-item .fl-kcal{color:var(--muted); white-space:nowrap; margin-left:10px;}

.meal-label{
  font-weight:800; font-size:14px;
  letter-spacing:.02em; margin:18px 4px 6px; color:var(--text);
}

.empty-state{
  text-align:center; padding:40px 16px; color:var(--muted);
}
.empty-state .btn{margin-top:14px;}

/* Bottom nav — floating pill, active tab gets gradient background */
.bottomnav{
  position:fixed; bottom:14px; left:14px; right:14px; z-index:30;
  display:flex; justify-content:space-around;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:24px;
  padding:8px 6px calc(8px + env(safe-area-inset-bottom));
  box-shadow:0 14px 34px -12px rgba(0,0,0,0.6);
  max-width:calc(var(--maxw) - 28px); margin:0 auto; left:0; right:0;
}
.navbtn{
  background:none; border:none; display:flex; flex-direction:column; align-items:center;
  gap:3px; color:var(--muted); font-size:10.5px; font-family:'Manrope',sans-serif; font-weight:700;
  padding:7px 6px; cursor:pointer; flex:1; border-radius:16px; transition:background .15s, color .15s;
}
.navbtn svg{width:21px; height:21px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round;}
.navbtn.active{color:#fff; background:var(--grad-accent);}

.toast{
  position:fixed; left:50%; bottom:100px; transform:translateX(-50%) translateY(20px);
  background:var(--grad-accent); color:#fff; padding:10px 18px; border-radius:999px;
  font-size:13px; font-weight:700; opacity:0; pointer-events:none; transition:opacity .2s, transform .2s;
  z-index:50; white-space:nowrap; box-shadow:0 10px 24px -8px rgba(255,122,61,0.6);
}
.toast.show{opacity:1; transform:translateX(-50%) translateY(0);}

.progress-chart{width:100%; height:160px;}

.setline{display:flex; align-items:center; gap:8px; margin:4px 0;}
.setline input{width:64px; padding:7px; font-size:14px;}
.setline span{font-size:13px; color:var(--muted); width:52px;}

/* Session page (log reps/weight) */
.session-topbar{
  display:flex; align-items:center; gap:8px; margin-bottom:4px;
}
.back-btn{
  background:var(--surface-2); border:none; color:var(--text);
  width:34px; height:34px; border-radius:10px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center; cursor:pointer;
}
.back-btn svg{width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round;}

.session-ex-card{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:16px; margin-bottom:14px;
}
.session-ex-head{display:flex; align-items:center; gap:11px; margin-bottom:12px;}
.session-ex-target{color:var(--muted); font-size:12px; margin-top:1px;}

.set-header-row, .set-row{
  display:grid; grid-template-columns:34px 1fr 1fr 40px; gap:8px; align-items:center;
  padding:6px 0;
}
.set-header-row{color:var(--muted); font-size:10.5px; font-weight:700; letter-spacing:.03em; text-transform:uppercase;}
.set-row input{padding:9px 8px; font-size:14px; text-align:center;}
.set-label{font-weight:800; font-size:13px; color:var(--text);}
.timer-btn{
  background:var(--surface-2); border:none; border-radius:10px; height:38px;
  display:flex; align-items:center; justify-content:center; color:var(--accent-2); cursor:pointer;
}
.timer-btn svg{width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round;}

/* Rest timer modal */
.rest-overlay{
  position:fixed; inset:0; z-index:100;
  background:rgba(0,0,0,0.78);
  display:flex; align-items:center; justify-content:center;
  padding:24px;
}
.rest-modal{
  background:var(--surface); border-radius:28px; padding:32px 28px;
  display:flex; flex-direction:column; align-items:center; gap:6px;
  max-width:280px; width:100%; border:1px solid var(--line);
}
.rest-label{color:var(--muted); font-size:13px; font-weight:700; letter-spacing:.04em; text-transform:uppercase;}
.rest-ring-box{position:relative; width:180px; height:180px; margin:14px 0;}
.rest-ring-box svg{position:absolute; top:0; left:0;}
.rest-ring-val{position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:42px; font-weight:400; font-family:'Archivo Black',sans-serif; color:var(--text);}
.rest-actions{display:flex; gap:10px; width:100%; margin-top:6px;}
.rest-adjust-row{display:flex; gap:10px; width:100%; margin-top:14px;}
.rest-adjust-btn{
  flex:1; background:var(--surface-2); border:none; color:var(--accent-2);
  font-weight:800; font-size:14px; border-radius:14px; padding:11px 0; cursor:pointer;
}
.rest-skip-link{
  background:none; border:none; color:var(--muted); font-size:13px; font-weight:600;
  margin-top:12px; cursor:pointer; text-decoration:underline;
}

/* Profile switcher */
.profile-card{
  display:flex; align-items:center; gap:13px;
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:14px 16px; margin-bottom:10px; cursor:pointer;
}
.profile-avatar{
  width:44px; height:44px; border-radius:50%; background:var(--grad-accent); color:#fff;
  display:flex; align-items:center; justify-content:center; font-weight:800; font-size:16px; flex-shrink:0;
}
.profile-card-name{font-weight:700; font-size:15px; color:var(--text);}
.profile-card-meta{font-size:12px; color:var(--muted); margin-top:1px; text-transform:capitalize;}

/* Workout plan edit mode */
.workout-header-row{display:flex; justify-content:space-between; align-items:flex-start; gap:10px;}
.icon-btn{
  background:var(--surface-2); border:none; color:var(--text); border-radius:10px;
  width:36px; height:36px; display:flex; align-items:center; justify-content:center; cursor:pointer; flex-shrink:0;
}
.icon-btn svg{width:17px; height:17px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round;}
.exercise-row.editing{align-items:flex-start;}
.edit-fields{display:flex; gap:6px; align-items:center;}
.edit-fields input{width:46px; padding:7px 4px; font-size:13px; text-align:center;}
.edit-fields span{color:var(--muted); font-size:12px;}
.remove-ex-btn{
  background:var(--surface-2); border:none; color:var(--warn); width:28px; height:28px; border-radius:8px;
  display:flex; align-items:center; justify-content:center; cursor:pointer; flex-shrink:0; font-size:14px; font-weight:800;
}
.add-ex-row{display:flex; gap:8px; margin-top:10px;}
.add-ex-row select{flex:1;}

/* Auth gate centering + plain link */
.auth-centered{
  display:flex; flex-direction:column; justify-content:center;
  min-height:calc(100vh - 150px);
}
.text-link{
  display:block; text-align:center; background:none; border:none;
  color:var(--muted); font-size:13px; font-weight:600; text-decoration:underline;
  margin-top:16px; cursor:pointer; width:100%;
}

/* Bottom nav hide (trainer mode / pre-login) */
.bottomnav.hidden{display:none;}
body.no-nav{padding-bottom:20px;}

/* Trainer / athlete link card */
.pt-linked{font-size:13.5px; color:var(--text);}
.pt-linked strong{color:var(--accent-2);}
.pt-code-display{
  font-family:'Archivo Black',monospace; font-size:30px; font-weight:400; letter-spacing:.08em;
  color:var(--accent-2);
  text-align:center; background:var(--surface-2);
  border-radius:16px; padding:16px; margin:10px 0;
}

/* Trainer dashboard: athlete list */
.athlete-card{
  display:flex; align-items:center; gap:13px;
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:14px 16px; margin-bottom:10px; cursor:pointer;
}
.athlete-avatar{
  width:42px; height:42px; border-radius:50%; background:var(--grad-accent); color:#fff;
  display:flex; align-items:center; justify-content:center; font-weight:800; font-size:15px; flex-shrink:0;
}
.athlete-card-name{font-weight:700; font-size:14.5px; color:var(--text);}
.athlete-card-meta{font-size:12px; color:var(--muted); margin-top:1px; text-transform:capitalize;}

.back-link{
  display:flex; align-items:center; gap:6px; background:none; border:none;
  color:var(--muted); font-size:13px; font-weight:600; cursor:pointer; margin-bottom:10px;
}
.back-link svg{width:15px; height:15px; fill:none; stroke:currentColor; stroke-width:2.4;}

/* Food entry mode tabs */
.food-mode-tabs{display:flex; gap:8px; margin:8px 0 14px;}
.food-mode-tab{
  flex:1; background:var(--surface-2); border:none; color:var(--muted);
  font-size:12.5px; font-weight:700; padding:10px 4px; border-radius:10px; cursor:pointer;
}
.food-mode-tab.active{background:var(--grad-accent); color:#fff;}

.food-preview-item{
  display:flex; justify-content:space-between; align-items:center;
  padding:9px 0; border-bottom:1px solid var(--line); font-size:13px;
}
.food-preview-item:last-child{border-bottom:none;}
.food-preview-meta{color:var(--muted); font-size:11px;}
.scan-dropzone{
  border:1.5px dashed var(--line); border-radius:16px; padding:24px 14px;
  text-align:center; color:var(--muted); font-size:13px; cursor:pointer;
}
.scan-dropzone svg{width:26px; height:26px; stroke:var(--accent-2); fill:none; stroke-width:1.6; margin-bottom:6px;}
