/* Onboarding: base, responsive and interaction states. */
.setup {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  max-width: 1320px;
  margin: auto;
}

.setup-intro {
  padding: 48px 65px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}

.setup-copy {
  margin: auto 0;
  padding: 70px 0;
}

.setup-copy h1 {
  font-size: 58px;
  line-height: 1.13;
  max-width: 450px;
  letter-spacing: -2.7px;
  margin: 22px 0;
}

.setup-copy h1 span {
  color: var(--accent);
}

.setup-copy p {
  max-width: 360px;
  font-size: 17px;
}

.setup-bottom {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.setup-main {
  padding: 70px 70px;
  display: flex;
  align-items: center;
}

.setup-form {
  width: 100%;
  max-width: 470px;
  margin: auto;
}

.steps {
  display: flex;
  gap: 6px;
  margin-bottom: 42px;
}

.steps span {
  width: 30px;
  height: 5px;
  background: var(--step);
  border-radius: 5px;
}

.steps .active {
  background: var(--text);
}

.setup-form h1 {
  margin: 10px 0 12px;
}

.setup-form > .muted {
  margin-bottom: 30px;
}

.setup-actions {
  display: flex;
  gap: 12px;
  margin-top: 30px;
}

.setup-actions .primary {
  flex: 1;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: left;
  font-size: 15px;
  background: var(--card);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.choice.selected {
  border-color: var(--accent);
  background: var(--warm-surface);
  color: var(--warm-text);
}

.target-preview {
  text-align: center;
  padding: 32px;
  margin: 24px 0;
}

.target-preview .big {
  font-size: 76px;
  font-weight: 800;
  letter-spacing: -4px;
}

.target-preview .big small {
  font-size: 30px;
  letter-spacing: 0;
}

.setup-error {
  margin-top: 14px;
}

@media (max-width: 1100px) {
  .setup-intro {
    padding: 40px;
  }

  .setup-main {
    padding: 45px;
  }

  .setup-copy h1 {
    font-size: 47px;
  }
}

@media (max-width: 700px) {
  .setup {
    display: block;
  }

  .setup-intro {
    padding: 25px 26px;
    border: none;
  }

  .setup-copy {
    display: none;
  }

  .setup-bottom {
    display: none;
  }

  .setup-main {
    padding: 20px 26px 45px;
  }

  .steps {
    margin-bottom: 28px;
  }

  .setup-form h1 {
    font-size: 32px;
  }

  .target-preview .big {
    font-size: 68px;
  }
}

.setup-form .weight-ruler {
  padding: 24px 20px 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  overflow: hidden;
}

.weight-ruler .field-grid {
  display: block;
}

.weight-ruler .weight-input-row {
  max-width: 320px;
  margin: 0 auto;
  align-items: center;
}

.setup-form .weight-ruler #weight {
  font-weight: 750;
  text-align: center;
  letter-spacing: -.04em;
  background: var(--page);
  min-width: 0;
}

.weight-ruler #weightConversion {
  min-height: 0;
}

.weight-ruler-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 12px;
  text-align: center;
}

.weight-ruler-controls button {
  flex: 0 0 44px;
  min-width: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 24px;
  border-radius: 50%;
}

.weight-ruler-controls .small {
  font-size: 13px;
  max-width: 180px;
}

.weight-scale-dial {
  position: relative;
  height: 112px;
  border: 1px solid var(--line);
  border-radius: 50% 50% 16px 16px / 22% 22% 16px 16px;
  background: var(--page);
  overflow: hidden;
}

.weight-ruler-ticks {
  position: absolute;
  top: 28px;
  left: 50%;
  display: flex;
  width: 574px;
  height: 64px;
  pointer-events: none;
}

.scale-tick {
  position: relative;
  flex: 0 0 14px;
  height: 22px;
  border-left: 1px solid var(--muted);
}

.scale-tick.major {
  height: 36px;
  border-left: 2px solid var(--text);
}

.scale-tick>span {
  position: absolute;
  top: 42px;
  left: 0;
  transform: translateX(-50%);
  font-size: 14px;
  color: var(--muted);
}

.weight-scale-pointer {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 9px;
  bottom: 12px;
  width: 2px;
  background: var(--accent);
  transform: translateX(-50%);
  pointer-events: none;
}

.weight-scale-pointer::before {
  content: "";
  position: absolute;
  top: 0;
  left: -5px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 9px solid var(--accent);
}

#setupWeightRuler {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: ew-resize;
  touch-action: pan-y;
}

.weight-scale-dial:has(#setupWeightRuler:focus-visible) {
  outline: 3px solid var(--blue);
  outline-offset: -4px;
}


.plan-reveal {
  max-width: 520px;
  text-align: center;
  padding: 36px;
  overflow: auto;
}

.plan-reveal-bagel {
  display: block;
  margin: 0 auto 24px;
  border-radius: 18px;
  animation: reveal-bagel 850ms ease-out both;
}

.plan-reveal-target {
  margin: 24px 0 12px;
}

.plan-reveal-target strong {
  display: block;
  font-size: clamp(48px,9vw,72px);
  line-height: 1.1;
  letter-spacing: -.05em;
}

.plan-reveal-meals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 24px 0;
}

.plan-reveal-meals>div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  animation: reveal-meal 450ms ease-out both;
  animation-delay: calc(300ms + var(--reveal-order)*150ms);
}

.plan-reveal>button {
  width: 100%;
}

@keyframes reveal-bagel {0%{transform:translateY(12px) rotate(-18deg);opacity:0}65%{transform:translateY(-5px) rotate(8deg)}100%{transform:none;opacity:1}}

@keyframes reveal-meal {from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}

@media(prefers-reduced-motion:reduce) {
  .plan-reveal-bagel,.plan-reveal-meals>div {
    animation: none;
  }
}

.weight-scale-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.weight-scale-header label {
  margin: 0;
}

.weight-scale-units {
  display: flex;
  gap: 2px;
}

.weight-scale-units button {
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
  min-height: 44px;
  font-weight: 400;
}

.weight-scale-units button[aria-pressed=true] {
  border-color: var(--muted);
}

.setup-form .weight-ruler #weight {
  flex: 1;
  width: 0;
  max-width: 280px;
  font-size: 64px;
  padding: 16px 8px;
}

#setupForm .weight-ruler-controls {
  gap: 24px;
  margin: 0 0 24px;
}

#setupForm .weight-ruler-controls button.secondary {
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
  aspect-ratio: 1;
}

.plan-reveal-meal-title {
  font-size: 16px;
  margin: 24px 0 12px;
}

.plan-reveal-meals {
  margin-top: 0;
}

.plan-reveal .setup-friendly-note {
  margin: 16px 0 24px;
  text-align: left;
}

@media(max-width:480px) {
  .weight-scale-header {
    align-items: center;
    gap: 6px;
  }

  .weight-scale-units button {
    padding: 6px 8px;
    font-size: 14px;
  }

  #setupForm .weight-ruler-controls {
    gap: 12px;
  }

  .setup-form .weight-ruler #weight {
    font-size: 48px;
  }

  #setupForm .weight-ruler-controls button.secondary {
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    flex-basis: 44px;
  }
}

#setupForm > #weightLabel {
  margin-bottom: -12px;
}

.weight-ruler > .field-grid[hidden] {
  display: none!important;
}

.weight-scale-header {
  margin-bottom: 24px;
}

.weight-scale-instruction {
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  flex: 1;
  min-width: 0;
}

.weight-scale-units {
  flex-shrink: 0;
}

#setupForm .weight-ruler-controls button.secondary {
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  flex: 0 0 44px;
}

#setupForm .weight-ruler-controls > .ios-save-haptic {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
}

.weight-ruler #weightConversion {
  margin: 16px 0 0;
  text-align: center;
}

.weight-ruler #weightConversion:empty {
  display: none;
}

.plan-reveal-meals > div > span::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--meal-colour);
  margin-right: 8px;
}

.plan-reveal .setup-friendly-note > .icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}

.plan-reveal > button.primary {
  position: sticky;
  bottom: 0;
  z-index: 2;
  box-shadow: 0 12px 0 12px var(--page);
}

.welcome {
  min-height: 100vh;
  max-width: 1150px;
  margin: auto;
  padding: 42px 50px 50px;
}

.welcome .brand {
  font-size: 44px;
  gap: 0;
}

.welcome-content {
  max-width: 920px;
  margin: 75px auto 0;
}

.welcome h1 {
  font-size: 62px;
  letter-spacing: -2.5px;
  line-height: 1.1;
  margin: 20px 0 24px;
}

.welcome-summary {
  font-size: 19px;
  max-width: 570px;
}

.welcome-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 30px;
  margin: 45px 0;
}

.welcome-features > div {
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.welcome-features .icon {
  color: var(--accent);
  margin-bottom: 16px;
  width: 26px;
  height: 26px;
}

.welcome-features h3 {
  margin-bottom: 10px;
}

.welcome-features p {
  color: var(--muted);
  font-size: 15px;
}

.welcome-note {
  font-size: 13px;
  margin-top: 17px;
  max-width: 430px;
}

.weight-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 85px;
  gap: 8px;
}

.weight-input-row select {
  padding: 12px 8px;
}

#stoneExtra {
  margin-top: 12px;
}

#stoneExtra label {
  font-size: 13px;
}

#weightConversion {
  margin-top: 7px;
}

@media (max-width: 700px) {
  .welcome {
    padding: 26px;
  }

  .welcome .brand {
    font-size: 36px;
  }

  .welcome-content {
    margin-top: 45px;
  }

  .welcome h1 {
    font-size: 42px;
    letter-spacing: -1.8px;
  }

  .welcome-summary {
    font-size: 17px;
  }

  .welcome-features {
    grid-template-columns: 1fr;
    gap: 20px;
    margin: 30px 0;
  }

  .welcome-features > div {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 0 16px;
    padding-top: 18px;
  }

  .welcome-features .icon {
    grid-row: 1/3;
    margin: 0;
  }

  .welcome-features p {
    grid-column: 2;
  }

  .welcome .primary {
    width: 100%;
  }
}

@media (max-width: 450px) {
  .weight-field {
    grid-column: 1/-1;
  }
}

.setup-intro .brand {
  font-size: 44px;
}

@media (max-width: 700px) {
  .setup-intro .brand {
    font-size: 36px;
  }
}

.choice.selected .preference-indicator::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.welcome-brand-dot {
  color: var(--accent);
}

.preview-start {
  font-size: 14px;
  margin-top: 12px;
  color: var(--text);
}

.plan-preview {
  padding: 24px;
  margin: 20px 0;
}

.plan-preview-total {
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  line-height: 1.2;
}

.plan-preview-total #previewTotal {
  font-size: 48px;
  letter-spacing: -2px;
}

.plan-preview-total > span + span {
  font-size: 18px;
  letter-spacing: normal;
}

.plan-preview .preview-start {
  margin-top: 12px;
}

.plan-preview #previewFormula {
  margin-top: 6px;
}

.plan-choice {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.plan-choice legend {
  padding: 0;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 600;
}

.plan-choice-options {
  display: flex;
  gap: 8px;
}

.plan-choice-options label {
  flex: 1;
  position: relative;
  margin: 0;
  font-weight: 600;
}

.plan-choice-options input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
}

.plan-choice-options span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-size: 14px;
}

.plan-choice-options input:checked + span {
  background: var(--accent);
  color: var(--accent-white);
  border-color: var(--accent);
}

.plan-choice-options input:focus-visible + span {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.onboarding-help {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.onboarding-help summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.onboarding-help .rate-help {
  margin-top: 16px;
  padding: 0;
  border: 0;
}

.onboarding-help .source {
  margin: 16px 0 0;
}

.setup-form:has(.plan-preview) .setup-actions {
  margin-top: 4px;
}

.loading-duration-choice #selectedDurationHelp,
.daily-carb-choice #selectedRateHelp {
  margin-top: 10px;
}

.setup-intro .brand-header {
  flex-wrap: wrap;
  row-gap: 12px;
}

.setup-intro .brand-header > .brand {
  flex-shrink: 0;
}

.setup-intro .brand-header > .row {
  flex-wrap: wrap;
  max-width: 100%;
}

.setup-friendly-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: var(--card);
  border-radius: 12px;
}

.setup-friendly-note > .icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  color: var(--muted);
}

@media(max-width:480px) {
  .setup-actions>.primary,.setup-actions>.ios-save-haptic {
    order: -1;
  }
}

.setup-options {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin: 0;
  min-width: 0;
}

.setup-options legend {
  font-weight: 700;
  padding: 0 6px;
}

.setup-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 18px;
}

.setup-option input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  margin: 3px 0 0;
  flex: 0 0 20px;
  accent-color: var(--accent);
}

.setup-option span.small {
  display: block;
  font-weight: 400;
  margin-top: 5px;
}

.setup-options>p {
  margin: 0;
}

.setup-option {
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
}

.setup-option>span {
  flex: 1;
  min-width: 0;
}

.setup-option input[role="switch"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: 0 0 48px;
  width: 48px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  margin: 0;
  border: 2px solid var(--field-border);
  border-radius: 999px;
  background: var(--field-border);
  cursor: pointer;
  box-shadow: none;
}

.setup-option input[role="switch"]::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--page);
  transition: transform .15s ease;
}

.setup-option input[role="switch"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.setup-option input[role="switch"]:checked::before {
  transform: translateX(20px);
}

.setup-option input[role="switch"]:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.setup-option input[role="switch"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media(prefers-reduced-motion:reduce) {
  .setup-option input[role="switch"]::before {
    transition: none;
  }
}

#setupForm .weight-ruler-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

#setupForm .weight-ruler-controls > button.secondary {
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  flex: 0 0 44px;
  padding: 0;
}

main.setup {
  overflow-anchor: none;
}
