*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --surface: #1a1a24;
  --surface2: #22222e;
  --border: #2e2e3e;
  --accent: #f97316;
  --accent2: #fb923c;
  --blue: #6366f1;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --text: #f0f0f8;
  --muted: #7070a0;
  --font: 'Inter', sans-serif;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  overflow-x: hidden;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── HEADER ── */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10,10,15,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 1.4rem; }
.brand-name {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header-right { display: flex; gap: 8px; }

/* ── MAIN ── */
main {
  flex: 1;
  padding: 20px 20px 100px;
  overflow-y: auto;
}

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: rgba(17,17,24,0.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 50;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.7rem;
  font-family: var(--font);
  cursor: pointer;
  transition: color 0.2s;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--accent); }
.nav-btn-log {
  color: var(--accent);
  position: relative;
}
.nav-btn-log svg {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  padding: 4px;
  width: 36px;
  height: 36px;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: var(--font);
  transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 10px; border-radius: 8px; }

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
}
.card-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ── SECTION LABEL ── */
.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 14px;
  margin-top: 28px;
}
.section-label:first-child { margin-top: 0; }

/* ── DASHBOARD ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
}
.stat-card .num {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-card .lbl { font-size: 0.72rem; color: var(--muted); font-weight: 500; }

.streak-banner {
  background: linear-gradient(135deg, rgba(249,115,22,0.15), rgba(99,102,241,0.1));
  border: 1px solid rgba(249,115,22,0.25);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.streak-flame { font-size: 2.5rem; }
.streak-text h3 { font-size: 1.1rem; font-weight: 700; }
.streak-text p { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }

/* ── WORKOUT LIST ── */
.workout-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.workout-row:hover { border-color: var(--accent); transform: translateX(2px); }
.workout-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: rgba(249,115,22,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.workout-info { flex: 1; min-width: 0; }
.workout-name { font-weight: 600; font-size: 0.95rem; }
.workout-meta { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.workout-actions { display: flex; gap: 6px; }

/* ── EXERCISES ── */
.exercise-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 4px 4px 4px 0;
}

/* ── ACTIVE WORKOUT ── */
.active-workout-header {
  background: linear-gradient(135deg, rgba(249,115,22,0.1), rgba(99,102,241,0.05));
  border: 1px solid rgba(249,115,22,0.2);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.active-title { font-size: 1.1rem; font-weight: 700; }
.timer {
  font-size: 1.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.exercise-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
}
.exercise-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.exercise-block-name { font-weight: 600; font-size: 0.95rem; }
.exercise-block-sub { font-size: 0.78rem; color: var(--muted); }

.sets-table { padding: 12px 16px; }
.sets-table-header {
  display: grid;
  grid-template-columns: 40px 1fr 1fr 40px;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.set-row {
  display: grid;
  grid-template-columns: 40px 1fr 1fr 40px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.set-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}
.set-num.done { background: var(--green); border-color: var(--green); color: #fff; }
.set-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  width: 100%;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}
.set-input:focus { border-color: var(--accent); }
.set-check {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.set-check.done { background: var(--green); border-color: var(--green); }
.set-check svg { width: 16px; height: 16px; stroke: #fff; }
.add-set-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.82rem;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  margin-top: 4px;
  transition: border-color 0.15s, color 0.15s;
}
.add-set-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── HISTORY ── */
.history-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.history-date-badge {
  background: rgba(249,115,22,0.12);
  border: 1px solid rgba(249,115,22,0.2);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
  flex-shrink: 0;
  min-width: 48px;
}
.history-date-badge .day { font-size: 1.3rem; font-weight: 800; color: var(--accent); line-height: 1; }
.history-date-badge .mon { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.history-info { flex: 1; }
.history-name { font-weight: 600; }
.history-meta { font-size: 0.8rem; color: var(--muted); margin-top: 3px; }
.history-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.history-chip {
  font-size: 0.72rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--muted);
}

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-select option { background: var(--surface2); }
.form-textarea { min-height: 80px; resize: vertical; }

/* Exercise picker in builder */
.exercise-pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.exercise-pick-name { flex: 1; font-size: 0.9rem; font-weight: 500; }
.exercise-pick-meta { font-size: 0.78rem; color: var(--muted); }
.exercise-pick-sets {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}
.exercise-pick-sets input {
  width: 44px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  outline: none;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px 20px 40px;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}
.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 20px;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 300;
  white-space: nowrap;
  animation: fadeInOut 2.5s forwards;
}
.toast.hidden { display: none; }
@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(8px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1.1rem; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; margin-bottom: 24px; }

/* ── MUSCLE GROUP BADGE ── */
.muscle-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: capitalize;
}
.muscle-chest { background: rgba(239,68,68,0.15); color: #ef4444; }
.muscle-back { background: rgba(99,102,241,0.15); color: #818cf8; }
.muscle-legs { background: rgba(34,197,94,0.15); color: #22c55e; }
.muscle-shoulders { background: rgba(234,179,8,0.15); color: #eab308; }
.muscle-arms { background: rgba(249,115,22,0.15); color: #f97316; }
.muscle-core { background: rgba(20,184,166,0.15); color: #14b8a6; }
.muscle-cardio { background: rgba(236,72,153,0.15); color: #ec4899; }
.muscle-full { background: rgba(148,163,184,0.15); color: #94a3b8; }

/* ── MISC ── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.text-muted { color: var(--muted); font-size: 0.85rem; }
.text-accent { color: var(--accent); }
.font-bold { font-weight: 700; }
