:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #121826;
  --muted: #667085;
  --line: #d9dde5;
  --accent: #111827;
  --accent-soft: #e8ebef;
  --success: #146c43;
  --warning: #8a4b08;
  --radius: 20px;
  --shadow: 0 12px 30px rgba(18, 24, 38, 0.08);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100dvh; padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(16px + env(safe-area-inset-top)) 18px 14px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.5rem; letter-spacing: -0.03em; }
h2 { margin-bottom: 8px; font-size: 1.25rem; letter-spacing: -0.025em; }
h3 { margin-bottom: 5px; font-size: 1rem; }
.eyebrow { color: var(--muted); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.11em; }
.main-content { width: min(100%, 760px); margin: 0 auto; padding: 18px; }

.bottom-nav {
  position: fixed;
  z-index: 25;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.nav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 14px;
  padding: 7px 2px;
  display: grid;
  gap: 3px;
  place-items: center;
}
.nav-item span { font-size: 1.25rem; }
.nav-item small { font-size: 0.7rem; }
.nav-item.active { color: var(--text); background: var(--accent-soft); font-weight: 700; }

.hero {
  border-radius: 28px;
  padding: 22px;
  color: white;
  background: linear-gradient(145deg, #111827, #344054);
  box-shadow: var(--shadow);
}
.hero .eyebrow { color: #c7ccd5; }
.hero h2 { font-size: 1.55rem; margin: 6px 0 8px; }
.hero p { margin-bottom: 0; color: #d4d8df; }
.hero-row { display: flex; justify-content: space-between; gap: 14px; align-items: end; }
.hero-badge { white-space: nowrap; padding: 8px 11px; border-radius: 999px; background: rgba(255,255,255,.12); font-size: .78rem; }

.section { margin-top: 22px; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.section-title h2 { margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.metric {
  padding: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.metric strong { display: block; font-size: 1.1rem; }
.metric span { color: var(--muted); font-size: .72rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 5px 18px rgba(18,24,38,.035);
}
.stack { display: grid; gap: 12px; }
.card-row { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.badge { display: inline-flex; border-radius: 999px; padding: 6px 9px; background: var(--accent-soft); color: var(--text); font-size: .72rem; font-weight: 700; }
.badge.easy { background: #e9f7ef; color: var(--success); }
.badge.hard { background: #fff2e5; color: var(--warning); }

.week-selector, .day-selector { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.week-selector::-webkit-scrollbar, .day-selector::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 13px;
  white-space: nowrap;
}
.chip.active { color: white; background: var(--accent); border-color: var(--accent); }

.group-card { padding: 0; overflow: hidden; }
.group-head { padding: 14px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.exercise { padding: 15px 16px; border-bottom: 1px solid var(--line); }
.exercise:last-child { border-bottom: 0; }
.exercise-top { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.exercise-prescription { color: var(--muted); font-size: .82rem; }
.exercise-cue { margin: 8px 0 0; font-size: .84rem; }
.demo-button, .rest-button, .ghost-button, .icon-button, .primary-button, .secondary-button, .preset-button {
  border-radius: 13px;
  border: 1px solid var(--line);
  padding: 9px 12px;
  background: var(--surface);
  color: var(--text);
}
.demo-button { padding: 7px 10px; font-size: .76rem; }
.rest-button { margin-top: 11px; width: 100%; background: var(--accent-soft); border-color: transparent; font-size: .82rem; font-weight: 700; }
.primary-button { background: var(--accent); color: white; border-color: var(--accent); font-weight: 750; }
.secondary-button { background: var(--surface-2); font-weight: 700; }
.full { width: 100%; }
.icon-button { width: 38px; height: 38px; padding: 0; border-radius: 999px; font-size: 1.3rem; }

.set-grid { display: grid; gap: 8px; margin-top: 12px; }
.set-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) minmax(0, 1fr) 34px; gap: 8px; align-items: center; }
.set-number { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); font-size: .75rem; font-weight: 700; }
.field {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 11px;
  padding: 9px 10px;
}
.check { width: 26px; height: 26px; accent-color: var(--accent); }

.progress-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress-track span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .25s ease; }

.diet-grid { display: grid; gap: 12px; }
.meal-card { display: grid; gap: 10px; }
.meal-meta { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.macro-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.water-row { display: flex; align-items: center; gap: 12px; }
.water-button { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 1.25rem; }

.form-grid { display: grid; gap: 12px; }
.form-label { display: grid; gap: 6px; color: var(--muted); font-size: .78rem; }
.form-label input, .form-label textarea { color: var(--text); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.timer-tray { position: fixed; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 28; }
.timer-pill { display: flex; gap: 10px; align-items: center; border: 0; border-radius: 999px; padding: 11px 15px; background: var(--accent); color: white; box-shadow: var(--shadow); }
.timer-pill span { font-size: .75rem; color: #d4d8df; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.modal { width: min(92vw, 520px); border: 0; border-radius: 24px; padding: 18px; background: var(--surface); color: var(--text); box-shadow: 0 25px 80px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(17,24,39,.56); backdrop-filter: blur(4px); }
.modal-head { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.modal-copy { color: var(--muted); font-size: .9rem; }
.demo-stage { position: relative; aspect-ratio: 16 / 9; margin: 14px 0; border-radius: 18px; overflow: hidden; background: var(--surface-2); }
.demo-stage img, .demo-stage video { position: absolute; inset: 0; width: 100%; height: 100%; }
.demo-stage img { object-fit: contain; transition: opacity .55s ease; }
.demo-stage video { object-fit: cover; background: #111827; }
.demo-stage img:last-of-type { opacity: 0; }
.demo-stage.peak img:first-of-type { opacity: 0; }
.demo-stage.peak img:last-of-type { opacity: 1; }
.demo-fallback { height: 100%; display: grid; place-items: center; color: var(--muted); }
.demo-progress { position: absolute; left: 12px; right: 12px; bottom: 12px; height: 7px; background: rgba(17,24,39,.12); border-radius: 999px; overflow: hidden; }
.demo-progress span { display: block; width: 0; height: 100%; background: var(--accent); }
.demo-source { margin: -4px 0 14px; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.demo-source a { color: inherit; text-decoration: underline; }
.timer-large { font-variant-numeric: tabular-nums; font-size: 4.2rem; font-weight: 800; text-align: center; padding: 22px 0; letter-spacing: -.06em; }
.preset-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }

.source-note { margin: 22px 0 4px; font-size: .72rem; color: var(--muted); text-align: center; }
.source-note a { color: inherit; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

@media (max-width: 430px) {
  .main-content { padding: 14px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics .metric:last-child { grid-column: 1 / -1; }
  .set-row { grid-template-columns: 32px 1fr 1fr 30px; gap: 6px; }
  .field { padding: 8px 7px; }
  .hero-row { align-items: start; flex-direction: column; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #151b24;
    --surface-2: #1d2530;
    --text: #f2f4f7;
    --muted: #a2aaba;
    --line: #2b3441;
    --accent: #f2f4f7;
    --accent-soft: #252e3a;
    --shadow: 0 14px 34px rgba(0,0,0,.28);
  }
  .hero { background: linear-gradient(145deg, #222b38, #0f141c); }
  .primary-button, .timer-pill, .chip.active { color: #101318; }
}
