:root {
  color-scheme: light;
  --ink: #17332c;
  --muted: #5d706b;
  --surface: #ffffff;
  --canvas: #f5f8f5;
  --line: #d9e4dc;
  --accent: #157b57;
  --accent-dark: #0e6244;
  --danger-bg: #fff1ee;
  --danger: #9f2d1a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: radial-gradient(circle at top right, #e5f3e9, transparent 42rem), var(--canvas);
  color: var(--ink);
}

.onboarding-shell {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.brand {
  display: inline-block;
  margin: 0 0 18px;
  color: var(--accent-dark);
  font-size: 1.1rem;
  font-weight: 760;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.close-onboarding {
  display: grid;
  position: absolute;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--canvas);
  color: var(--muted);
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}

.close-onboarding:hover { border-color: #b8c9bd; background: #eef4ef; color: var(--accent-dark); }

.onboarding-card {
  position: relative;
  padding: clamp(22px, 5vw, 38px);
  border: 1px solid rgba(24, 71, 51, .1);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 14px 42px rgba(21, 74, 51, .09);
}

.progress-copy {
  margin-bottom: 22px;
}

.progress-copy p {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: .87rem;
  font-weight: 650;
}

progress {
  display: block;
  width: 100%;
  height: 7px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #e8efea;
}

progress::-webkit-progress-bar { background: #e8efea; }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

h1 {
  margin: 0;
  font-size: clamp(1.62rem, 6vw, 2.25rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

#onboarding-title { padding-right: 48px; }

form { margin: 0; }
fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend,
.field-label {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 750;
}

label:not(.choice):not(.check-row) {
  display: grid;
  gap: 7px;
  margin: 0 0 16px;
  color: var(--ink);
  font-size: .95rem;
  font-weight: 670;
}

.measurement-control {
  display: grid;
  grid-template-columns: minmax(112px, .52fr) minmax(0, 1.48fr);
  gap: 14px;
  align-items: end;
  margin: 0 0 16px;
}

.measurement-control + .measurement-control { margin-top: 4px; }
.measurement-control .measurement-input { margin: 0; }

.measurement-ruler {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 34px auto;
  gap: 4px;
}

.ruler-output {
  min-height: 1.2em;
  color: var(--accent-dark);
  font-size: .88rem;
  font-weight: 750;
}

.ruler-output.is-updated { animation: ruler-value .24s ease; }

.ruler {
  --ruler-fill: 0%;
  width: 100%;
  height: 34px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: ew-resize;
}

.ruler::-webkit-slider-runnable-track {
  height: 20px;
  border-radius: 999px;
  background:
    repeating-linear-gradient(90deg, transparent 0 11px, rgba(23, 51, 44, .28) 11px 12px) center / 100% 12px no-repeat,
    linear-gradient(90deg, var(--accent) 0 var(--ruler-fill), var(--line) var(--ruler-fill) 100%) center / 100% 3px no-repeat;
}

.ruler::-moz-range-track {
  height: 20px;
  border-radius: 999px;
  background:
    repeating-linear-gradient(90deg, transparent 0 11px, rgba(23, 51, 44, .28) 11px 12px) center / 100% 12px no-repeat,
    linear-gradient(90deg, var(--accent) 0 var(--ruler-fill), var(--line) var(--ruler-fill) 100%) center / 100% 3px no-repeat;
}

.ruler::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  margin-top: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 7px rgba(14, 98, 68, .28);
}

.ruler::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 7px rgba(14, 98, 68, .28);
}

.ruler-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1;
}

@keyframes ruler-value {
  from { opacity: .35; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

input[type="number"], select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid #b8c9bd;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
}

textarea { min-height: 104px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus, a:focus {
  outline: 3px solid rgba(21, 123, 87, .28);
  outline-offset: 2px;
}

.optional { color: var(--muted); font-size: .85em; font-weight: 500; }

.choice, .check-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin: 0 0 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fcfdfc;
  cursor: pointer;
}

.choice input, .check-row input { flex: 0 0 auto; width: 19px; height: 19px; margin: 1px 0 0; accent-color: var(--accent); }
.choice span, .check-row span { min-width: 0; line-height: 1.38; }
.choice b { display: block; font-size: .98rem; }
.choice small { display: block; margin-top: 3px; color: var(--muted); font-size: .86rem; }
.check-row a { color: var(--accent-dark); }

.diet-choice-grid { display: grid; gap: 12px; }
.diet-choice { margin-bottom: 0; }
.diet-note {
  margin: 14px 0 18px;
  padding: 15px;
  border: 1px solid #c9dfd0;
  border-radius: 14px;
  background: #f1f8f3;
  color: var(--ink);
  font-size: .9rem;
  line-height: 1.45;
}
.diet-note p { margin: 0; }
.diet-note p + p { margin-top: 9px; }
.diet-note .check-row { margin: 13px 0 0; background: #fff; }
.diet-note[hidden] { display: none; }

.preset-section { margin: -2px 0 18px; }
.preset-section .field-label { margin-bottom: 9px; font-size: .9rem; }
.preset-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-card {
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fcfdfc;
  color: var(--ink);
  font-size: .86rem;
  font-weight: 650;
  line-height: 1.25;
}
.preset-card:hover { border-color: #a8c5b4; background: #f1f8f3; }
.preset-card[aria-pressed="true"] { border-color: var(--accent); background: #e5f3e9; color: var(--accent-dark); }

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.form-actions > form { margin: 0; }
.honeypot { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.summary-actions { flex-wrap: nowrap; }
.summary-actions > form:first-child { flex: 0 0 auto; }
.summary-actions > form:last-child { min-width: 0; flex: 1 1 0; }
.summary-actions .primary { width: 100%; }
button {
  min-height: 47px;
  padding: 11px 17px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-weight: 740;
  cursor: pointer;
}
.primary { flex: 1 1 190px; background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-dark); }
.secondary { flex: 0 1 auto; border: 1px solid #c7d5cc; background: #fff; color: var(--ink); }
.privacy-note { margin: 18px 0 0; color: var(--muted); font-size: .84rem; line-height: 1.45; }

.form-error { margin: 0 0 19px; padding: 12px 13px; border: 1px solid #f1b8aa; border-radius: 12px; background: var(--danger-bg); color: var(--danger); line-height: 1.42; }

.summary { margin: 0 0 22px; }
.summary dl { margin: 0; }
.summary dl > div { display: grid; grid-template-columns: minmax(120px, .85fr) minmax(0, 1.3fr); gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.summary dt { color: var(--muted); font-size: .88rem; }
.summary dd { margin: 0; font-weight: 650; line-height: 1.35; }
.summary-edits { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 17px; }
.summary-edits button { min-height: auto; padding: 0; color: var(--accent-dark); background: transparent; font-size: .86rem; text-decoration: underline; }
@media (max-width: 440px) {
  .onboarding-shell { padding: 16px 12px 30px; }
  .onboarding-card { border-radius: 18px; }
  .summary dl > div { grid-template-columns: 1fr; gap: 3px; }
  .form-actions > button { width: 100%; }
  .measurement-control { grid-template-columns: minmax(104px, .6fr) minmax(0, 1.4fr); gap: 10px; }
}
