:root {
  --accent: #FF6B35;
  --accent-light: #FF8C61;
  --bg: #0C0C0E;
  --surface: #1A1A1E;
  --surface-elevated: #252528;
  --text: #FFFFFF;
  --text-secondary: #8E8E93;
  --text-tertiary: #48484A;
  --success: #34C759;
  --warning: #FF9F0A;
  --error: #FF3B30;
  --border: #2C2C2E;
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Rubik", -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app { max-width: 520px; margin: 0 auto; min-height: 100%; position: relative; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.screen.with-tabs { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }

button { font-family: inherit; cursor: pointer; border: none; }

/* ---------- Buttons ---------- */
.btn-primary {
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  padding: 16px;
  border-radius: 14px;
  width: 100%;
  transition: transform .1s, background .15s;
}
.btn-primary:active { transform: scale(.98); background: var(--accent-light); }
.btn-primary:disabled { opacity: .4; }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  padding: 12px;
  width: 100%;
}
.btn-back {
  background: none; color: var(--text-secondary);
  font-size: 15px; padding: 8px 0; align-self: flex-start; margin-bottom: 8px;
}

/* ---------- Onboarding ---------- */
.onb-logo {
  width: 72px; height: 72px; border-radius: 20px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; margin-bottom: 28px;
}
.onb-title { font-size: 32px; font-weight: 700; line-height: 1.15; margin-bottom: 12px; }
.onb-sub { font-size: 16px; color: var(--text-secondary); line-height: 1.45; margin-bottom: 28px; }
.onb-step { font-size: 13px; font-weight: 600; color: var(--accent); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 10px; }
.onb-features { list-style: none; display: flex; flex-direction: column; gap: 18px; margin-bottom: auto; }
.onb-features li { display: flex; align-items: center; gap: 14px; font-size: 15px; }
.onb-features .fico {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  background: var(--surface-elevated); display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.spacer { flex: 1; }

.option-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: auto; }
.option-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; align-items: center; gap: 14px;
  text-align: left; color: var(--text);
  transition: border-color .15s, background .15s;
}
.option-card.selected { border-color: var(--accent); background: rgba(255, 107, 53, .08); }
.option-card .oico {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: var(--surface-elevated); display: flex; align-items: center; justify-content: center; font-size: 21px;
}
.option-card .otitle { font-size: 16px; font-weight: 600; }
.option-card .odesc { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ---------- Tabs ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px;
  background: rgba(18, 18, 20, .96);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  backdrop-filter: blur(12px);
  z-index: 50;
}
.tabbar button {
  flex: 1; background: none; color: var(--text-tertiary);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 500;
}
.tabbar button .tico { font-size: 21px; }
.tabbar button.active { color: var(--accent); }

/* ---------- Today ---------- */
.greeting { font-size: 14px; color: var(--text-secondary); }
.page-title { font-size: 26px; font-weight: 700; margin: 2px 0 20px; }
.stat-row { display: flex; gap: 10px; margin-bottom: 22px; }
.stat-card {
  flex: 1; background: var(--surface); border-radius: var(--radius);
  padding: 14px 12px; text-align: center;
}
.stat-card .sico { font-size: 18px; }
.stat-card .sval { font-size: 22px; font-weight: 700; margin: 2px 0; }
.stat-card .slabel { font-size: 11px; color: var(--text-secondary); }

.section-title { font-size: 17px; font-weight: 600; margin: 4px 0 12px; display: flex; justify-content: space-between; align-items: center; }

.workout-card {
  background: linear-gradient(135deg, var(--surface-elevated), var(--surface));
  border: 1px solid var(--border);
  border-radius: 20px; padding: 20px; margin-bottom: 24px;
}
.workout-card .badge {
  display: inline-block; background: rgba(255,107,53,.15); color: var(--accent);
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px; margin-bottom: 10px;
}
.workout-card h3 { font-size: 21px; font-weight: 700; margin-bottom: 6px; }
.workout-card .wmeta { font-size: 13px; color: var(--text-secondary); margin-bottom: 14px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip { background: var(--surface-elevated); border: 1px solid var(--border); font-size: 12px; color: var(--text-secondary); padding: 5px 10px; border-radius: 20px; }
.rest-card { background: var(--surface); border-radius: 20px; padding: 26px 20px; text-align: center; margin-bottom: 24px; }
.rest-card .rico { font-size: 34px; }
.rest-card p { color: var(--text-secondary); font-size: 14px; margin-top: 8px; }

.week-grid { display: flex; gap: 6px; margin-bottom: 10px; }
.week-day {
  flex: 1; background: var(--surface); border-radius: 12px; padding: 10px 2px;
  text-align: center; border: 1px solid transparent;
}
.week-day.today { border-color: var(--accent); }
.week-day .wd { font-size: 11px; color: var(--text-secondary); margin-bottom: 5px; }
.week-day .wdot { font-size: 13px; }
.week-day.restday .wdot { color: var(--text-tertiary); }
.week-day.done .wdot { color: var(--success); }

/* ---------- Library ---------- */
.muscle-group { margin-bottom: 20px; }
.muscle-group h4 { font-size: 13px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.exercise-row {
  background: var(--surface); border-radius: 14px; padding: 14px;
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
  width: 100%; color: var(--text); text-align: left;
}
.exercise-row .eico { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-elevated); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.exercise-row .ename { font-size: 15px; font-weight: 500; }
.exercise-row .emeta { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }

/* ---------- Progress ---------- */
.big-streak { text-align: center; padding: 18px 0 24px; }
.big-streak .bs-num { font-size: 52px; font-weight: 700; color: var(--accent); }
.big-streak .bs-label { font-size: 14px; color: var(--text-secondary); }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 110px; background: var(--surface); border-radius: var(--radius); padding: 14px; margin-bottom: 22px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.bar { width: 100%; max-width: 26px; border-radius: 6px 6px 3px 3px; background: var(--surface-elevated); min-height: 4px; }
.bar.filled { background: var(--accent); }
.bar-col span { font-size: 10px; color: var(--text-secondary); }
.level-track { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 22px; }
.level-track .lt-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 10px; }
.level-track .lt-head b { font-weight: 600; }
.level-track .lt-head span { color: var(--text-secondary); }
.progressbar { height: 8px; background: var(--surface-elevated); border-radius: 6px; overflow: hidden; }
.progressbar > div { height: 100%; background: var(--accent); border-radius: 6px; transition: width .4s; }
.milestone-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.milestone {
  background: var(--surface); border-radius: 14px; padding: 14px 8px; text-align: center;
  opacity: .38;
}
.milestone.unlocked { opacity: 1; border: 1px solid rgba(255,107,53,.35); }
.milestone .mico { font-size: 24px; }
.milestone .mlabel { font-size: 11px; margin-top: 6px; color: var(--text-secondary); }
.history-row { background: var(--surface); border-radius: 14px; padding: 13px 14px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.history-row .hname { font-size: 14px; font-weight: 500; }
.history-row .hdate { font-size: 12px; color: var(--text-secondary); }
.empty-note { color: var(--text-secondary); font-size: 14px; text-align: center; padding: 24px 0; }

/* ---------- Profile ---------- */
.profile-card { background: var(--surface); border-radius: var(--radius); padding: 18px; display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.avatar { width: 54px; height: 54px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 26px; }
.profile-card .pname { font-size: 17px; font-weight: 600; }
.profile-card .pmeta { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.settings-row {
  background: var(--surface); border-radius: 14px; padding: 15px;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; width: 100%; color: var(--text); font-size: 15px;
}
.settings-row.danger { color: var(--error); }

/* ---------- Workout session ---------- */
.session-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.session-head .sh-title { font-size: 15px; font-weight: 600; }
.session-head button { background: none; color: var(--text-secondary); font-size: 14px; padding: 8px; }
.session-progress { height: 4px; background: var(--surface-elevated); border-radius: 3px; margin-bottom: 24px; overflow: hidden; }
.session-progress > div { height: 100%; background: var(--accent); transition: width .3s; }
.timer-wrap { display: flex; flex-direction: column; align-items: center; margin: 10px 0 24px; }
.timer-ring { position: relative; width: 230px; height: 230px; }
.timer-ring svg { transform: rotate(-90deg); }
.timer-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 30px;
}
.timer-center .t-big { font-size: 46px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-center .t-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.ex-title { font-size: 24px; font-weight: 700; text-align: center; }
.ex-sub { font-size: 14px; color: var(--text-secondary); text-align: center; margin-top: 4px; margin-bottom: 18px; }
.info-box { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.info-box h5 { font-size: 12px; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.info-box p { font-size: 14px; color: var(--text-secondary); line-height: 1.5; }
.session-actions { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.trophy { text-align: center; margin: auto 0; }
.trophy .tr-ico { font-size: 74px; }
.trophy h2 { font-size: 28px; margin: 14px 0 8px; }
.trophy p { color: var(--text-secondary); font-size: 15px; }


/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(100px + env(safe-area-inset-bottom));
  background: var(--surface-elevated); border: 1px solid var(--border);
  color: var(--text); font-size: 14px; padding: 12px 18px; border-radius: 12px;
  z-index: 100; animation: toastin .25s ease;
  max-width: 90%; text-align: center;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 90;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--surface); border-radius: 20px 20px 0 0; width: 100%; max-width: 520px;
  padding: 22px 20px calc(26px + env(safe-area-inset-bottom));
  animation: slideup .25s ease;
}
@keyframes slideup { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal h3 { font-size: 19px; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.modal .m-muscle { font-size: 13px; color: var(--accent); margin-bottom: 14px; }


.footnote { font-size: 11px; color: var(--text-tertiary); text-align: center; line-height: 1.5; margin-top: 12px; }
