:root {
  color-scheme: dark;
  --bg: #090b0d;
  --surface: #111519;
  --surface-2: #181d22;
  --line: #2a3138;
  --text: #f5f7f8;
  --muted: #98a2ad;
  --green: #55e087;
  --blue: #58a6ff;
  --orange: #ffad57;
  --red: #ff6b6b;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100svh; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }

.login-shell {
  min-height: 100svh;
  display: grid;
  align-content: center;
  gap: 28px;
  max-width: 440px;
  margin: 0 auto;
  padding: 32px 24px;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand img { width: 58px; height: 58px; border-radius: 8px; }
.brand h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
.brand p { margin: 4px 0 0; color: var(--muted); }

.field { display: grid; gap: 8px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 700; }
input, textarea, select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--green); }

.app-shell { min-height: 100svh; padding-bottom: calc(78px + var(--safe-bottom)); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: max(12px, env(safe-area-inset-top)) 18px 10px;
  background: rgba(9, 11, 13, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.topbar-title { font-size: 19px; font-weight: 800; }
.topbar-kicker { font-size: 12px; color: var(--muted); }

.content { max-width: 820px; margin: 0 auto; padding: 20px 16px 32px; }
.section { padding: 20px 0; border-bottom: 1px solid var(--line); }
.section:first-child { padding-top: 4px; }
.section:last-child { border-bottom: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
h2, h3, p { margin-top: 0; }
h2 { font-size: 24px; margin-bottom: 8px; }
h3 { font-size: 17px; margin-bottom: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.big-number { font-size: 44px; line-height: 1; font-weight: 850; font-variant-numeric: tabular-nums; }

.primary, .secondary, .danger, .icon-button {
  border: 0;
  border-radius: 8px;
  min-height: 48px;
  padding: 12px 16px;
  font-weight: 800;
  cursor: pointer;
}
.primary { background: var(--green); color: #07120b; }
.secondary { background: var(--surface-2); border: 1px solid var(--line); }
.danger { background: rgba(255, 107, 107, 0.16); color: var(--red); }
.text-button { border: 0; background: transparent; color: var(--muted); min-height: 42px; padding: 10px; font-weight: 700; }
.wide { width: 100%; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.button-row > * { flex: 1; }

.nav {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 8px 8px calc(8px + var(--safe-bottom));
  background: rgba(9, 11, 13, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(20px);
}
.nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 52px;
  display: grid;
  place-items: center;
  gap: 3px;
  font-size: 11px;
}
.nav button span:first-child { font-size: 20px; }
.nav button.active { color: var(--green); }

.list { display: grid; gap: 0; }
.row {
  display: grid;
  gap: 5px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row-action { cursor: pointer; }
.workout-choice { transition: color .18s ease, padding-left .18s ease; }
.workout-choice:active { color: var(--green); padding-left: 6px; }
.row-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.metric { padding: 14px 10px; background: var(--surface); }
.metric strong { display: block; font-size: 19px; }
.metric span { color: var(--muted); font-size: 12px; }

.badge { display: inline-flex; align-items: center; width: fit-content; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 800; }
.badge.increaseWeight { color: var(--green); background: rgba(85, 224, 135, .14); }
.badge.maintainWeight, .badge.addReps { color: var(--blue); background: rgba(88, 166, 255, .14); }
.badge.reduceWeight, .badge.deload, .badge.recoveryWarning { color: var(--orange); background: rgba(255, 173, 87, .14); }
.badge.noDataYet { color: var(--muted); background: var(--surface-2); }

.workout-head { display: grid; gap: 12px; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 850; letter-spacing: .12em; }
.workout-preview h2 { margin-top: 10px; font-size: clamp(30px, 8vw, 44px); letter-spacing: -.035em; }
.preview-stats, .progress-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.preview-stats > div, .progress-summary > div { padding: 14px 8px 14px 0; display: grid; gap: 3px; }
.preview-stats strong, .progress-summary strong { font-size: 20px; }
.preview-stats span, .progress-summary span { color: var(--muted); font-size: 12px; }
.exercise-plan { display: grid; }
.plan-row { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.plan-row:last-child { border-bottom: 0; }
.plan-index { color: var(--muted); font-size: 12px; padding-top: 3px; }
.plan-row div { display: grid; gap: 4px; }
.plan-row div span { color: var(--muted); font-size: 13px; }
.sticky-actions { display: grid; grid-template-columns: minmax(90px, .7fr) minmax(180px, 1.5fr); gap: 10px; }
.progress-track { height: 5px; background: var(--surface-2); overflow: hidden; border-radius: 999px; }
.progress-fill { height: 100%; background: var(--green); transition: width .2s ease; }
.suggestion { padding: 15px 0 15px 14px; border-left: 3px solid var(--green); }
.suggestion strong { display: block; font-size: 18px; margin: 7px 0; }
.wizard { min-height: 330px; display: grid; align-content: start; gap: 18px; }
.stepper { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 10px; }
.stepper button { min-height: 56px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 26px; }
.stepper-value { text-align: center; font-size: 46px; font-weight: 850; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 3px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 9px 12px; white-space: nowrap; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; min-height: 54px; padding: 0 2px; border-bottom: 1px solid var(--line); }
.toggle-row input { width: 24px; min-height: 24px; }
.timer { text-align: center; padding: 28px 0; }
.timer .big-number { font-size: 68px; color: var(--green); }
.alert-status {
  width: 100%;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: left;
}
.alert-status.enabled { color: var(--green); border-color: rgba(85, 224, 135, .35); }
.alert-status > span:last-child { display: grid; gap: 2px; }
.alert-status small { color: var(--muted); font-size: 11px; font-weight: 500; }

.bar-list { display: grid; gap: 14px; }
.bar-label { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--blue); border-radius: inherit; }

.progress-hero { padding-top: 10px; }
.progress-total {
  margin-top: 8px;
  font-size: clamp(46px, 14vw, 76px);
  line-height: .98;
  font-weight: 880;
  letter-spacing: -.055em;
  font-variant-numeric: tabular-nums;
}
.progress-total span { margin-left: 8px; color: var(--muted); font-size: .28em; letter-spacing: 0; }
.trend { font-size: 13px; font-weight: 850; }
.trend.positive { color: var(--green); }
.trend.negative { color: var(--orange); }
.week-chart { height: 190px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 7px; align-items: end; }
.week-column { height: 100%; min-width: 0; display: grid; grid-template-rows: 22px 1fr 22px; gap: 5px; align-items: end; }
.week-value, .week-label { overflow: hidden; color: var(--muted); font-size: 9px; text-align: center; white-space: nowrap; }
.week-bar { height: 100%; display: flex; align-items: end; justify-content: center; background: linear-gradient(to top, var(--surface-2), transparent); border-radius: 4px; overflow: hidden; }
.week-bar span { width: 100%; min-height: 2px; background: var(--green); border-radius: 4px 4px 0 0; transition: height .35s ease; }
.record-list, .timeline { display: grid; }
.record-row { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.record-row:last-child, .timeline-row:last-child { border-bottom: 0; }
.record-rank { color: var(--muted); font-size: 11px; }
.record-row > div { display: grid; gap: 3px; }
.record-row div span, .record-value span, .timeline-row div span { color: var(--muted); font-size: 11px; }
.record-value { text-align: right; }
.timeline-row { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.timeline-date { display: grid; text-align: center; }
.timeline-date strong { font-size: 19px; }
.timeline-date span { text-transform: uppercase; }
.timeline-row > div:nth-child(2) { display: grid; gap: 4px; min-width: 0; }
.timeline-row > div:nth-child(2) strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline-row > strong { font-size: 13px; color: var(--green); }

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(92px + var(--safe-bottom));
  transform: translateX(-50%);
  padding: 11px 14px;
  background: var(--text);
  color: var(--bg);
  border-radius: 8px;
  font-weight: 800;
  animation: toast-in .2s ease both;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (min-width: 760px) {
  .app-shell { padding-left: 180px; padding-bottom: 0; }
  .nav { top: 0; right: auto; width: 180px; grid-template-columns: 1fr; align-content: center; border-top: 0; border-right: 1px solid var(--line); }
  .nav button { grid-template-columns: 28px 1fr; justify-items: start; padding: 0 18px; font-size: 14px; }
  .content { padding-top: 32px; }
  .sticky-actions { position: sticky; bottom: 24px; background: rgba(9, 11, 13, .92); backdrop-filter: blur(16px); }
}
