/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* ── TOKENS — iOS Light ── */
:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface2: rgba(0,0,0,0.03);
  --border: rgba(0,0,0,0.08);
  --border-md: rgba(0,0,0,0.14);

  --blue: #007AFF;
  --blue-dim: rgba(0,122,255,0.1);
  --green: #34C759;
  --green-dim: rgba(52,199,89,0.1);
  --orange: #FF9500;
  --orange-dim: rgba(255,149,0,0.1);
  --red: #FF3B30;
  --purple: #AF52DE;
  --teal: #32ADE6;
  --pink: #FF2D55;
  --yellow: #FFCC00;

  --t1: #1c1c1e;
  --t2: rgba(0,0,0,0.5);
  --t3: rgba(0,0,0,0.28);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --r1: 10px; --r2: 14px; --r3: 20px; --r4: 28px; --pill: 100px;
  --sh-sm: 0 1px 6px rgba(0,0,0,0.07);
  --sh-md: 0 4px 18px rgba(0,0,0,0.1);
  --sh-lg: 0 8px 32px rgba(0,0,0,0.13);
}

/* ── BASE ── */
html, body { height: 100%; height: -webkit-fill-available; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
  background: var(--bg); color: var(--t1);
  -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
}
#ambient { display: none; }

/* ── LAYOUT ── */
#app { display: flex; flex-direction: column; height: 100%; height: -webkit-fill-available; }
#main {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 14px) 16px 0;
}
#main::-webkit-scrollbar { display: none; }

/* ── TABBAR ── */
#tabbar {
  flex-shrink: 0; padding-bottom: var(--safe-bottom);
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(30px) saturate(180%); -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-top: 0.5px solid rgba(0,0,0,0.12);
}
.tabbar-inner { display: flex; justify-content: space-around; align-items: center; height: 56px; }
.tab-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 16px; background: none; border: none;
  color: var(--t3); font-size: 10px; font-weight: 600; letter-spacing: 0.2px;
  text-transform: uppercase; cursor: pointer; transition: color 0.15s; min-width: 60px;
}
.tab-btn svg { width: 22px; height: 22px; }
.tab-btn.active { color: var(--blue); }

/* ── CARDS ── */
.card, .glass-card, .glass {
  background: var(--surface); border-radius: var(--r3);
  box-shadow: var(--sh-sm); border: none;
}

/* ── BUTTONS ── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; font-family: inherit; font-weight: 600;
  transition: transform 0.12s, opacity 0.12s; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.96); opacity: 0.84; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-glass { background: rgba(0,0,0,0.05); color: var(--t1); border: 0.5px solid rgba(0,0,0,0.1); }
.btn-ghost { background: none; color: var(--blue); }
.btn-danger { background: var(--red); color: #fff; }
.btn-lg { padding: 17px 24px; font-size: 17px; border-radius: var(--pill); box-shadow: var(--sh-md); }
.btn-md { padding: 13px 20px; font-size: 15px; border-radius: var(--pill); }
.btn-sm { padding: 9px 16px; font-size: 13px; border-radius: var(--pill); }
.btn-full { width: 100%; }
.btn-icon {
  width: 38px; height: 38px; padding: 0; border-radius: var(--r1);
  background: rgba(0,0,0,0.06); border: none; color: var(--t2);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.btn-icon:active { background: rgba(0,0,0,0.12); }
.btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.set-card-lbl svg { width: 14px; height: 14px; }
.nav-back.danger { color: var(--red); }
.workout-hdr .nav-back { margin-bottom: 0; }

/* ── HOME ── */
.home-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.home-greeting { font-size: 28px; font-weight: 800; letter-spacing: -0.6px; line-height: 1.1; }
.home-date { font-size: 14px; color: var(--t2); margin-top: 4px; font-weight: 500; }

.home-hero { padding: 20px; margin-bottom: 14px; }
.home-hero-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--t2); margin-bottom: 6px; }
.home-hero-num { font-size: 48px; font-weight: 900; letter-spacing: -2px; color: var(--blue); line-height: 1; }
.home-hero-muscles { font-size: 13px; color: var(--t2); margin-top: 8px; font-weight: 500; line-height: 1.4; }

.home-ex-strip { display: flex; gap: 8px; margin: 18px 0 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.home-ex-strip::-webkit-scrollbar { display: none; }
.home-ex-thumb {
  width: 54px; height: 54px; object-fit: contain; flex-shrink: 0;
  background: var(--bg); border-radius: var(--r1); padding: 4px;
}

.home-hero-foot { display: flex; align-items: center; justify-content: space-between; }
.home-hero-meta { font-size: 14px; color: var(--t2); font-weight: 500; }

.home-stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.home-stat { padding: 14px 10px; text-align: center; }
.home-stat-val { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.home-stat-key { font-size: 11px; color: var(--t2); margin-top: 3px; font-weight: 500; }
.history-item { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 10px; cursor: pointer; }
.hist-badge { width: 46px; height: 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 800; flex-shrink: 0; }
.hist-info { flex: 1; }
.hist-title { font-size: 15px; font-weight: 600; }
.hist-sub { font-size: 13px; color: var(--t2); margin-top: 2px; }
.hist-vol { font-size: 14px; font-weight: 600; color: var(--t2); }

/* ── WORKOUT — new design ── */
.workout-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.wkt-pill {
  font-size: 13px; font-weight: 700; color: var(--t2);
  background: var(--surface); padding: 6px 14px; border-radius: var(--pill);
  box-shadow: var(--sh-sm);
}
.workout-elapsed {
  font-size: 14px; font-weight: 600; color: var(--t1);
  font-variant-numeric: tabular-nums;
  background: var(--surface); padding: 6px 14px; border-radius: var(--pill);
  box-shadow: var(--sh-sm);
}

/* Progress dots */
.ex-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 14px; flex-wrap: wrap; }
.ex-dot {
  height: 8px; width: 8px; border-radius: 4px;
  background: rgba(0,0,0,0.12); cursor: pointer; transition: all 0.22s ease;
}
.ex-dot.done { background: var(--green); width: 20px; }
.ex-dot.active { background: var(--blue); width: 22px; }

/* Main exercise card */
.wkt-ex-card {
  background: var(--surface); border-radius: var(--r3);
  box-shadow: var(--sh-md); overflow: hidden;
  margin-bottom: 12px;
}
/* Image strip at top */
.wkt-img-strip {
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 16px 16px 12px;
  position: relative;
}
.wkt-ex-img {
  width: 180px; height: 180px; object-fit: contain;
  display: block;
}
.wkt-muscle-badge {
  position: absolute; top: 10px; left: 14px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.7px; padding: 4px 10px;
  border-radius: var(--pill); background: var(--surface);
  box-shadow: var(--sh-sm);
}
/* Info section below image */
.wkt-ex-info {
  padding: 14px 18px 16px;
}
.wkt-ex-meta { flex: 1; min-width: 0; }
.ex-muscle {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; margin-bottom: 5px;
}
.ex-name { font-size: 21px; font-weight: 800; letter-spacing: -0.3px; line-height: 1.1; }
.ex-target { font-size: 15px; color: var(--t2); margin-top: 4px; }
.ex-notes { font-size: 12px; color: var(--t3); margin-top: 4px; font-style: italic; line-height: 1.3; }
.ex-prev {
  margin-top: 8px; padding: 5px 10px; background: var(--bg);
  border-radius: 8px; font-size: 12px; color: var(--t2); display: inline-block;
}

/* Horizontal set cards */
.sets-section { margin-bottom: 12px; }
.sets-section-hdr {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--t2); margin-bottom: 10px;
}
.sets-row { display: flex; gap: 10px; }
.set-card {
  flex: 1; background: var(--surface); border-radius: var(--r2);
  padding: 14px 8px; text-align: center; box-shadow: var(--sh-sm);
  border: 2px solid transparent; transition: all 0.2s;
}
.set-card.done { background: rgba(52,199,89,0.08); border-color: var(--green); box-shadow: none; }
.set-card.active { background: rgba(0,122,255,0.07); border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,122,255,0.1); }
.set-card-lbl {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--t3); margin-bottom: 6px;
}
.set-card.done .set-card-lbl { color: var(--green); }
.set-card.active .set-card-lbl { color: var(--blue); }
.set-card-val { font-size: 13px; font-weight: 700; color: var(--t2); line-height: 1.2; }
.set-card.done .set-card-val { color: var(--t1); font-size: 12px; }
.set-card.active .set-card-val { color: var(--blue); }

.workout-action { padding-bottom: 6px; }

/* ── LOG MODAL ── */
.modal-bg {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; flex-direction: column; justify-content: flex-end;
}
.modal-sheet {
  background: var(--surface);
  border-top: 0.5px solid rgba(0,0,0,0.1);
  border-radius: var(--r4) var(--r4) 0 0;
  padding: 0 16px calc(var(--safe-bottom) + 16px);
  animation: slideUp 0.28s cubic-bezier(0.32,0.72,0,1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle { width: 36px; height: 4px; background: rgba(0,0,0,0.14); border-radius: 2px; margin: 12px auto 20px; }
.modal-title { text-align: center; font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.modal-sub { text-align: center; font-size: 13px; color: var(--t2); margin-bottom: 22px; }
.picker-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--t2); margin-bottom: 8px; }
.picker-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.pick-btn {
  width: 58px; height: 58px; border-radius: var(--r2);
  background: var(--bg); border: none; color: var(--t1);
  font-size: 28px; font-weight: 300; display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: background 0.12s, transform 0.1s;
}
.pick-btn:active { transform: scale(0.88); background: rgba(0,0,0,0.1); }
.pick-val { flex: 1; text-align: center; font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -1.5px; }
.pick-unit { font-size: 14px; color: var(--t2); font-weight: 400; }
.note-inp {
  width: 100%; background: var(--bg); border: none; border-radius: var(--r2);
  color: var(--t1); font-size: 15px; padding: 12px 14px;
  outline: none; font-family: inherit; resize: none; margin-bottom: 18px;
}
.note-inp::placeholder { color: var(--t3); }

/* ── TIMERS — stay dark, high contrast ── */
.ex-timer-overlay, .rest-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(12,12,22,0.97);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 24px; animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.ex-timer-overlay { z-index: 280; }
.ex-timer-title, .rest-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,0.45); margin-bottom: 12px; }
.ex-timer-exname { font-size: 22px; font-weight: 800; margin-bottom: 48px; text-align: center; color: #fff; }
.ex-timer-arc, .rest-arc { position: relative; width: 220px; height: 220px; margin-bottom: 36px; }
.ex-timer-arc svg, .rest-arc svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.arc-bg { fill: none; stroke: rgba(255,255,255,0.1); stroke-width: 6; }
.arc-fill { fill: none; stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.ex-timer-num, .rest-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ex-timer-secs, .rest-secs { font-size: 68px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -3px; color: #fff; }
.ex-timer-setlabel { font-size: 14px; color: rgba(255,255,255,0.45); margin-top: 2px; }
.rest-last { font-size: 16px; color: rgba(255,255,255,0.5); margin-bottom: 44px; text-align: center; }
.rest-last strong { color: #fff; font-weight: 700; }
.rest-arc { margin-bottom: 44px; }
.rest-next { font-size: 14px; color: rgba(255,255,255,0.45); text-align: center; margin-bottom: 28px; }

/* ── WORKOUT COMPLETE ── */
.complete-wrap { display: flex; flex-direction: column; align-items: center; padding: 48px 0 32px; text-align: center; }
.complete-trophy { font-size: 72px; margin-bottom: 16px; }
.complete-title { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 6px; }
.complete-sub { font-size: 16px; color: var(--t2); margin-bottom: 36px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-bottom: 24px; }
.stat-cell { padding: 16px 14px; text-align: center; }
.stat-val { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-key { font-size: 12px; color: var(--t2); margin-top: 3px; }

/* ── HISTORY ── */
.hist-detail { margin-bottom: 8px; }
.hist-ex-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 16px; border-bottom: 0.5px solid rgba(0,0,0,0.06); }
.hist-ex-row:last-child { border-bottom: none; }
.hist-ex-name { font-size: 14px; font-weight: 600; flex: 1; }
.hist-ex-sets { font-size: 13px; color: var(--t2); }

/* ── PROGRESS — new grid ── */
.prog-section-title { font-size: 13px; font-weight: 700; color: var(--t2); text-transform: uppercase; letter-spacing: 0.6px; margin: 18px 0 10px; }
.progress-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 4px; }
.prog-ex-card {
  background: var(--surface); border-radius: var(--r2); box-shadow: var(--sh-sm);
  padding: 14px 10px; cursor: pointer; transition: all 0.15s; text-align: center;
  border: 2px solid transparent;
}
.prog-ex-card:active { transform: scale(0.97); }
.prog-ex-card.selected { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,122,255,0.1); }
.prog-ex-img { width: 60px; height: 60px; object-fit: contain; margin: 0 auto 8px; display: block; }
.prog-ex-name { font-size: 12px; font-weight: 700; color: var(--t1); margin-bottom: 4px; line-height: 1.3; }
.prog-ex-best { font-size: 20px; font-weight: 800; color: var(--blue); line-height: 1; }
.prog-ex-no-data { font-size: 14px; font-weight: 700; color: var(--t3); }
.prog-ex-sessions { font-size: 11px; color: var(--t3); margin-top: 2px; }
.prog-trend {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 700; margin-top: 5px;
  padding: 3px 8px; border-radius: var(--pill);
}
.trend-up { background: rgba(52,199,89,0.1); color: #1a9436; }
.trend-down { background: rgba(255,59,48,0.08); color: var(--red); }
.trend-eq { background: rgba(0,0,0,0.06); color: var(--t3); }

.chart-section { margin-top: 16px; }
.chart-card { background: var(--surface); border-radius: var(--r3); box-shadow: var(--sh-sm); padding: 16px 18px; margin-bottom: 12px; }
.chart-title { font-size: 14px; font-weight: 700; color: var(--t1); margin-bottom: 4px; }
.chart-sub { font-size: 12px; color: var(--t2); margin-bottom: 14px; }
.chart-canvas { display: block; width: 100%; }
.chart-empty { text-align: center; padding: 32px; color: var(--t3); font-size: 14px; }
.pr-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 0.5px solid rgba(0,0,0,0.06); }
.pr-row:last-child { border-bottom: none; }
.pr-label { font-size: 14px; color: var(--t2); }
.pr-val { font-size: 16px; font-weight: 700; color: var(--t1); }

/* ── PLAN ── */
.plan-day-hdr { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--t2); margin: 18px 0 8px; }
.plan-ex { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 8px; cursor: pointer; transition: background 0.12s; }
.plan-ex:active { background: rgba(0,0,0,0.02); }
.plan-ex-info { flex: 1; }
.plan-ex-name { font-size: 15px; font-weight: 600; }
.plan-ex-meta { font-size: 13px; color: var(--t2); margin-top: 2px; }

/* ── EDIT FORM ── */
.field { margin-bottom: 18px; }
.field-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--t2); margin-bottom: 8px; }
.field-inp {
  width: 100%; background: var(--surface); border: 0.5px solid var(--border-md);
  border-radius: var(--r2); color: var(--t1); font-size: 16px; padding: 12px 14px;
  outline: none; font-family: inherit; -webkit-appearance: none; appearance: none; box-shadow: var(--sh-sm);
}
.field-inp:focus { border-color: var(--blue); }
.field-inp option { background: white; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.toggle-label { font-size: 15px; font-weight: 500; }
.tog { width: 51px; height: 31px; background: rgba(0,0,0,0.14); border-radius: 100px; position: relative; cursor: pointer; transition: background 0.2s; }
.tog.on { background: var(--green); }
.tog::after {
  content: ''; position: absolute; width: 27px; height: 27px; background: #fff; border-radius: 50%;
  top: 2px; left: 2px; transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.tog.on::after { transform: translateX(20px); }
.export-ta { width: 100%; height: 130px; background: var(--bg); border: 0.5px solid var(--border); border-radius: var(--r2); color: var(--t2); font-size: 11px; padding: 10px 12px; font-family: monospace; resize: none; outline: none; }

/* ── MUSCLE COLORS (adapted for light bg) ── */
.mc-cardio    { color: #C04D00; }
.mc-addominali { color: #906A00; }
.mc-pettorali  { color: #005CC8; }
.mc-dorsali    { color: #7B2DB0; }
.mc-quadricipiti { color: #1A9436; }
.mc-femorali   { color: #1A9436; }
.mc-glutei     { color: #B22222; }
.mc-tricipiti  { color: #0E7A9E; }
.mc-bicipiti   { color: #B8003A; }

/* ── UTILS ── */
.row { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.flex1 { flex: 1; }
.mb1 { margin-bottom: 6px; } .mb2 { margin-bottom: 10px; } .mb3 { margin-bottom: 14px; } .mb4 { margin-bottom: 20px; }
.mt2 { margin-top: 8px; } .mt4 { margin-top: 20px; }
.sep { height: 0.5px; background: rgba(0,0,0,0.08); margin: 10px 0; }
.empty { text-align: center; padding: 48px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-txt { color: var(--t2); font-size: 15px; }
.nav-back {
  display: flex; align-items: center; gap: 6px;
  color: var(--blue); font-size: 16px; font-weight: 500;
  background: none; border: none; cursor: pointer; padding: 4px 0; margin-bottom: 16px;
}
.section-title { font-size: 22px; font-weight: 800; letter-spacing: -0.3px; margin-bottom: 14px; }
.t-small { font-size: 13px; }
.dim { color: var(--t2); }
