:root{
  --bg:#0E0E10;
  --surface:#1B1B1E;
  --surface-2:#252528;
  --line:#2E2E32;
  --text:#F4F4F5;
  --muted:#96969C;
  --accent:#C6FF4A;
  --accent-ink:#10140A;
  --orange:#FF8A4C;
  --purple:#9D7BFF;
  --pink:#FF5C93;
  --blue:#4FA6FF;
  --warn:#FF6B57;
  --radius:18px;
  --maxw:520px;
}

*{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:82px;
}

h1,h2,h3,.display{
  font-family:'Manrope',sans-serif;
  font-weight:800;
  letter-spacing:-0.01em;
  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:'Manrope',sans-serif;
  font-weight:800; font-size:20px; letter-spacing:0.01em;
  color:var(--accent);
}
.brand em{color:var(--accent); font-style:normal;}
.topbar-date{font-size:13px; color:var(--muted);}

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

.section-title{
  font-size:26px; line-height:1.1; margin-bottom:4px;
}
.section-sub{color:var(--muted); font-size:14px; margin-bottom:18px;}

.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:14px; padding:12px 10px;
  text-align:center;
}
.statpill .sv{font-size:18px; font-weight:800; color:var(--text); display:block;}
.statpill .sl{font-size:10.5px; color:var(--muted); margin-top:2px; display:block;}

/* Icon badges */
.badge{
  width:38px; height:38px; border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}
.badge.orange{background:rgba(255,138,76,0.16); color:var(--orange);}
.badge.purple{background:rgba(157,123,255,0.16); color:var(--purple);}
.badge.pink{background:rgba(255,92,147,0.16); color:var(--pink);}
.badge.blue{background:rgba(79,166,255,0.16); color:var(--blue);}
.badge.green{background:rgba(198,255,74,0.16); color:var(--accent);}
.badge svg{width:19px; height:19px; 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(--accent);
  border-color:var(--accent);
  color:var(--accent-ink);
}

label.field-label{
  display:block; font-size:13px; font-weight:700; color:var(--muted);
  margin:14px 0 2px;
}
input[type=number], input[type=text], select, textarea{
  width:100%;
  border:1.5px solid var(--line);
  border-radius:12px;
  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:6px;
  border:none; border-radius:999px;
  padding:14px 18px;
  font-size:15px; font-weight:800;
  font-family:'Manrope',sans-serif;
  cursor:pointer;
  width:100%;
}
.btn-primary{background:var(--accent); color:var(--accent-ink);}
.btn-effort{background:var(--accent); color:var(--accent-ink);}
.btn-nutrition{background:var(--accent); color:var(--accent-ink);}
.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;}

/* Day block */
.day-block{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:18px; margin-bottom:16px;
}
.day-num{
  font-weight:800; font-size:11px; letter-spacing:.08em;
  color:var(--accent);
}
.day-title{font-size:20px; margin:3px 0 4px;}
.exercise-row{
  display:flex; justify-content:space-between; align-items:center;
  padding:11px 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:40px; height:40px; border-radius:11px; background:var(--surface-2);
  display:flex; align-items:center; justify-content:center; color:var(--accent); flex-shrink:0;
}
.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(--text);}

/* 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:22px; font-weight:800; 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(--accent);}
.macro-bar-fill.over{background:var(--warn);}
.kcal-big{font-weight:800; font-size:40px; line-height:1; color:var(--text);}
.kcal-big small{font-family:'Work Sans',sans-serif; font-weight:500; font-size:14px; color:var(--muted);}

.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 */
.bottomnav{
  position:fixed; bottom:0; left:0; right:0; z-index:30;
  display:flex; justify-content:space-around;
  background:var(--surface);
  border-top:1px solid var(--line);
  padding:10px 4px calc(10px + env(safe-area-inset-bottom));
}
.navbtn{
  background:none; border:none; display:flex; flex-direction:column; align-items:center;
  gap:3px; color:var(--muted); font-size:11px; font-family:'Manrope',sans-serif; font-weight:600;
  padding:4px 6px; cursor:pointer; flex:1;
}
.navbtn svg{width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round;}
.navbtn.active{color:var(--accent);}

.toast{
  position:fixed; left:50%; bottom:90px; transform:translateX(-50%) translateY(20px);
  background:var(--accent); color:var(--accent-ink); 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;
}
.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); 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:24px; padding:32px 28px;
  display:flex; flex-direction:column; align-items:center; gap:6px;
  max-width:280px; width:100%;
}
.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:44px; font-weight:800; 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);
  font-weight:800; font-size:14px; border-radius:12px; 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(--surface-2); color:var(--accent);
  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;}
