:root {
  --bg: #FAFAF8;
  --ink: #1B1B18;
  --muted: #6E6B63;
  --accent: #355E3B;
  --accent-warn: #9C4A2E;
  --highlight: #EFE7D2;
  --font-display: -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-body: -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  --radius: 4px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0 auto;
  max-width: 720px;
  padding: 2rem 1.25rem 4rem;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
}

fieldset {
  border: none;
  margin: 0;
  padding: 0;
}

legend {
  padding: 0;
  margin: 0 0 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Header ---------- */

.site-header {
  margin-bottom: 2.5rem;
}

.site-header__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.site-header__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.5rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}

.site-header__tagline {
  color: var(--muted);
  margin: 0 0 1rem;
  max-width: 32rem;
}

.site-header__reset {
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
}

/* ---------- Steps ---------- */

.step,
.result-card {
  margin-bottom: 1.75rem;
}

.step__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 0 0 0.35rem;
}

.step__heading {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  margin: 0 0 0.5rem;
}

.step__intro {
  color: var(--muted);
  margin: 0 0 1.25rem;
  max-width: 36rem;
}

/* ---------- Form fields ---------- */

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 600px) {
  .field-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label {
  font-weight: 600;
  font-size: 0.9rem;
}

.field__legend {
  font-weight: 600;
  font-size: 0.9rem;
}

.field input,
.field select {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.btn:focus-visible,
.unit-toggle__btn:focus-visible,
.radio-option input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

/* Weight field needs its label on its own row, then the input and the
   kg/lb fieldset side by side on the next — done with grid instead of
   an extra wrapper div. */
.field--weight {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.4rem 0.5rem;
}

.field--weight label {
  grid-column: 1 / -1;
}

.field--weight input {
  grid-column: 1;
  min-width: 0;
}

.field--weight .unit-toggle {
  grid-column: 2;
}

.field__note {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}

.unit-toggle {
  display: flex;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
  width: fit-content;
}

.unit-toggle__btn {
  font: inherit;
  font-size: 0.85rem;
  padding: 0 0.85rem;
  height: 2.4rem;
  border: none;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.unit-toggle__btn + .unit-toggle__btn {
  border-left: 1.5px solid var(--ink);
}

.unit-toggle__btn.is-active {
  background: var(--ink);
  color: var(--bg);
}

.step__actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.btn {
  font: inherit;
  font-weight: 700;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1.5px solid var(--ink);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: #2a4a2e;
}

.btn--ghost {
  background: transparent;
  color: var(--ink);
}

.btn--ghost:hover {
  background: rgba(27, 27, 24, 0.06);
}

.form-error {
  background: #fff;
  border: 1.5px solid var(--accent-warn);
  color: var(--accent-warn);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-top: 1.25rem;
}

/* ---------- Result card (nutrition-label style) ---------- */

.result-card {
  border: 3px solid var(--ink);
  background: var(--highlight);
  padding: 1.25rem 1.5rem 1.5rem;
}

.result-card__title {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 1.25rem;
  border-bottom: 8px solid var(--ink);
  padding-bottom: 0.6rem;
  margin: 0 0 0.75rem;
}

.result-list {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  margin: 0;
}

.result-list dt,
.result-list dd {
  padding: 0.5rem 0;
  margin: 0;
  border-bottom: 1px solid var(--ink);
}

.result-list dd {
  text-align: right;
}

.result-list__main {
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-weight: 700;
}

/* Every pair after the first reads as supporting detail rather than
   the headline number. */
.result-list dt:nth-of-type(n + 2),
.result-list dd:nth-of-type(n + 2) {
  border-bottom: 1px dashed #b9b3a0;
  font-size: 0.85rem;
  color: var(--muted);
}

.result-row__unit {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
}

.result-row__mono {
  font-family: var(--font-mono);
}

.result-footnote {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
  margin: 0.85rem 0 0;
}

/* ---------- Plan cards (Step 3) ---------- */

.plan-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .plan-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.plan-card {
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  background: #fff;
}

.plan-card.is-selected {
  border-width: 3px;
  background: var(--highlight);
}

.plan-card__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  margin: 0 0 0.25rem;
}

.plan-card__rate {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.plan-card__stats {
  margin-bottom: 0.75rem;
}

.plan-card__stats dt,
.plan-card__stats dd {
  font-size: 0.85rem;
  padding: 0.35rem 0;
}

.plan-card__warning {
  font-size: 0.8rem;
  color: var(--accent-warn);
  margin: 0 0 0.75rem;
}

.plan-card__select {
  width: 100%;
}

/* ---------- Macro style picker (Step 4) ---------- */

.macro-style {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.radio-option {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.9rem;
  font-weight: 400;
  cursor: pointer;
}

.radio-option input {
  margin-top: 0.2rem;
  accent-color: var(--accent);
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 2.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.site-footer__formulas {
  margin-top: 0.5rem;
  font-size: 0.75rem;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* ---------- Small-screen refinements ----------
   The layout is already mobile-first (single column by default,
   upgrading at 600px/640px). These tighten things up further for
   actual phone-sized screens: bigger tap targets, less wasted
   padding, and the weight field stacking instead of squeezing. */

@media (max-width: 480px) {
  body {
    padding: 1.5rem 1rem 3rem;
  }

  .site-header__title {
    font-size: 2rem;
  }

  .site-header__tagline {
    max-width: none;
  }

  .step__intro {
    max-width: none;
  }

  /* Full-width primary actions are easier to tap than small buttons
     floating on the left. */
  .step__actions .btn {
    width: 100%;
  }

  .unit-toggle__btn {
    height: 2.75rem;
    padding: 0 1rem;
  }

  .result-list__main {
    font-size: 1.5rem;
  }

  .plan-card {
    padding: 1rem;
  }

  .radio-option {
    padding: 0.3rem 0;
  }
}

@media (max-width: 380px) {
  /* On the narrowest phones, side-by-side weight input + unit toggle
     gets too tight — stack them instead. */
  .field--weight {
    grid-template-columns: 1fr;
  }

  .field--weight .unit-toggle {
    grid-column: 1;
    width: 100%;
  }

  .field--weight .unit-toggle__btn {
    flex: 1;
  }
}