@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/space-grotesk.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --bg: #fdfcfe;
  --wash-1: #f1ecfb;
  --wash-2: #eef1fa;
  --wash-3: #f6eef9;
  --ink: #272532;
  --ink-soft: #6c6678;
  --line: #e6e1f0;
  --accent: #8b7bc7;
  --accent-deep: #5f4eb8;
  --accent-ink: #fff;
  --surface: #ffffff;
  --radius: 18px;
  --ease-dream: cubic-bezier(0.22, 0.61, 0.26, 1);
  --dur-slow: 620ms;
  --dur-med: 420ms;
  --dur-fast: 220ms;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 50% at 10% 0%, var(--wash-1) 0%, transparent 60%),
    radial-gradient(ellipse 60% 45% at 95% 15%, var(--wash-2) 0%, transparent 55%),
    radial-gradient(ellipse 65% 50% at 50% 100%, var(--wash-3) 0%, transparent 60%);
  background-attachment: fixed;
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Progress */
.progress-wrap {
  position: sticky;
  top: 0;
  padding: 18px 0 10px;
  background: linear-gradient(to bottom, var(--bg) 70%, transparent);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-btn {
  appearance: none;
  border: none;
  background: var(--surface);
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 10px rgba(0, 0, 0, 0.04);
  transition: transform var(--dur-fast) var(--ease-dream), box-shadow var(--dur-fast) var(--ease-dream), opacity var(--dur-fast) ease;
  opacity: 0;
  pointer-events: none;
}

.back-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-btn:hover {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.06);
}

.back-btn:active {
  transform: scale(0.92);
}

.back-btn svg {
  width: 16px;
  height: 16px;
  stroke: var(--ink);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.progress-track {
  flex: 1;
  height: 4px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  transition: width var(--dur-slow) var(--ease-dream);
}

.progress-label {
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-size: 11px;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* Screen stage */
.stage {
  flex: 1;
  position: relative;
  /* Generous bottom clearance so the fixed .screen-footer button never
     overlaps the last field(s) on taller screens (e.g. the weight fields
     screen, which has 7 stacked inputs) -- 140px was cutting it close on
     real phone viewports once the browser's own address-bar chrome and
     the footer's own gradient fade are accounted for. */
  padding: 10px 0 220px;
}

.screen {
  position: absolute;
  inset: 10px 0 auto 0;
  opacity: 0;
  transform: translateY(18px) scale(0.985);
  filter: blur(2px);
  pointer-events: none;
  transition:
    opacity var(--dur-slow) var(--ease-dream),
    transform var(--dur-slow) var(--ease-dream),
    filter var(--dur-slow) var(--ease-dream);
  will-change: transform, opacity;
}

.screen.active {
  position: relative;
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
  pointer-events: auto;
}

.screen.leaving-back {
  transform: translateY(-14px) scale(0.985);
}

.greeting {
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--accent);
  font-weight: 600;
  margin: 0 0 6px;
  opacity: 0;
  animation: fade-in-up var(--dur-med) var(--ease-dream) forwards;
  animation-delay: 60ms;
}

.screen-title {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 28px;
  letter-spacing: -0.01em;
}

.intro-screen {
  text-align: center;
  padding-top: 18vh;
}

.intro-screen .mark {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
}

.intro-screen h1 {
  font-size: 30px;
  font-weight: 600;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}

.intro-screen p {
  color: var(--ink-soft);
  font-size: 15px;
  margin: 0 0 40px;
  line-height: 1.6;
}

/* Fields */
.field {
  margin-bottom: 26px;
  opacity: 0;
  transform: translateY(10px);
  animation: fade-in-up var(--dur-med) var(--ease-dream) forwards;
}

.field-label {
  display: block;
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 10px;
  color: var(--ink);
}

.field-required {
  color: var(--accent-deep);
  font-weight: 600;
}

.field-hint {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: -6px 0 10px;
}

input[type="text"],
input[type="number"],
input[type="date"],
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-dream), box-shadow var(--dur-fast) var(--ease-dream), transform var(--dur-fast) var(--ease-dream);
}

textarea {
  resize: vertical;
  min-height: 92px;
  line-height: 1.5;
}

input:hover, textarea:hover {
  border-color: #d8cfc2;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(139, 123, 199, 0.14);
}

/* Pills */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  appearance: none;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-dream),
    background var(--dur-fast) var(--ease-dream),
    color var(--dur-fast) var(--ease-dream),
    transform 150ms var(--ease-dream),
    box-shadow var(--dur-fast) var(--ease-dream);
}

.pill:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(139, 123, 199, 0.14);
}

.pill:active {
  transform: scale(0.95);
}

.pill.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  animation: pill-pop 360ms var(--ease-dream);
}

.pill.pulse {
  animation: pill-pop 360ms var(--ease-dream);
}

@keyframes pill-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Footer / continue */
.screen-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 20px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  display: flex;
  justify-content: center;
  z-index: 15;
}

.screen-footer-inner {
  width: 100%;
  /* .app's content width is its own 560px max-width MINUS its 20px side
     padding on each edge (520px) -- this must match exactly or the
     Continue button renders visibly wider than the fields/pills above it
     on any viewport wide enough for .app to actually hit its max-width
     (e.g. landscape/tablet/desktop), since .screen-footer has no
     corresponding side padding built into its own max-width the way
     .app's content area does. */
  max-width: 520px;
}

.continue-btn {
  width: 100%;
  appearance: none;
  border: none;
  background: var(--ink);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 16px 20px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform var(--dur-fast) var(--ease-dream), opacity var(--dur-fast) ease, box-shadow var(--dur-fast) var(--ease-dream);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.continue-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}

.continue-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.continue-btn:disabled {
  background: var(--line);
  color: var(--ink-soft);
  cursor: not-allowed;
  box-shadow: none;
}

.continue-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.start-btn {
  padding: 16px 36px;
}

/* State screens: invalid link, submitted */
.state-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 24px;
}

.state-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.state-icon svg {
  width: 26px;
  height: 26px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.state-screen h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 10px;
}

.state-screen p {
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.6;
  max-width: 320px;
  margin: 0;
}

.saving-dot {
  position: fixed;
  top: 18px;
  right: 20px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--dur-fast) ease;
  z-index: 25;
}

.saving-dot.show {
  opacity: 0.7;
  animation: saving-pulse 900ms ease-in-out infinite;
}

@keyframes saving-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.85; }
}

@media (min-width: 560px) {
  .app {
    padding: 0 28px;
  }
  .screen-footer-inner {
    /* .app's side padding grows to 28px at this breakpoint (560 - 56 =
       504px content width) -- keep the footer's max-width in sync so the
       button doesn't drift wider than the fields again above 560px. */
    max-width: 504px;
  }
  .screen-title {
    font-size: 27px;
  }
  .intro-screen h1 {
    font-size: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
