:root {
  --red: #f5333f;
  --red-soft: #fdebec;
  --green: #1fa85a;
  --green-soft: #ecfaf1;
  --ink: #15141a;
  --muted: #8a8a90;
  --line: #e5e5e8;
  --line-strong: #d7d7db;
  --bg: #f1f1f0;
  --card: #ffffff;
  --radius-card: 28px;
  --radius-field: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: "Onest", -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  -webkit-font-smoothing: antialiased;
}

/* top progress */
.progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: transparent;
  z-index: 10;
}
.progress__bar {
  height: 100%;
  width: 20%;
  background: var(--red);
  border-radius: 0 4px 4px 0;
  transition: width 0.5s var(--ease);
}

/* card */
.card {
  width: 100%;
  max-width: 880px;
  height: min(640px, calc(100vh - 56px));
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: 0 30px 70px -40px rgba(20, 20, 25, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 30px 44px 0;
}
.logo {
  height: 26px;
  width: auto;
  display: block;
  transition: height 0.3s var(--ease);
}
.logo.is-large { height: 52px; }
.counter {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.5px;
}
.counter__sep { margin: 0 4px; opacity: 0.5; }

/* stage holds steps */
.stage {
  position: relative;
  flex: 1;
  padding: 0 44px;
}
.step {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: safe center;
  overflow-y: auto;
  padding: 16px 44px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(14px);
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease);
}
.step.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}
.step__inner { width: 100%; max-width: 560px; }

/* staggered entrance of inner elements */
.step.is-active .q-eyebrow,
.step.is-active .q-index,
.step.is-active .q-title,
.step.is-active .q-hint,
.step.is-active .options,
.step.is-active .field-area,
.step.is-active .done-mark {
  animation: rise 0.55s var(--ease) backwards;
}
.step.is-active .q-title { animation-delay: 0.05s; }
.step.is-active .q-hint { animation-delay: 0.1s; }
.step.is-active .options,
.step.is-active .field-area { animation-delay: 0.14s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.q-eyebrow {
  color: var(--red);
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 16px;
}

.q-index {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--red);
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 18px;
}
.q-index__arrow { opacity: 0.7; }
.q-title {
  font-size: 33px;
  line-height: 1.18;
  font-weight: 600;
  letter-spacing: -0.4px;
}
.q-hint {
  margin-top: 14px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

/* options */
.options {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.opt {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 17px 18px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-field);
  font-family: inherit;
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.18s, background 0.18s, transform 0.12s;
}
.opt:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.opt.is-selected {
  border-color: var(--green);
  background: var(--green-soft);
}
.opt__label { flex: 1; }
.opt__key {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1.5px solid var(--line-strong);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.opt.is-selected .opt__key { border-color: var(--green); color: var(--green); }
.opt__dot {
  width: 13px; height: 13px; border-radius: 50%;
  flex-shrink: 0;
}
.opt__dot--green { background: #22c55e; }
.opt__dot--amber { background: #f6a609; }
.opt__dot--red { background: var(--red); }

/* conditional reveal panels (free text / calendar link) */
.reveal { margin-top: 14px; }
.reveal .field-area { margin-top: 0; }
.cal-link {
  display: inline-block;
  margin-top: 4px;
  background: var(--green-soft);
  border: 1.5px solid var(--green);
  color: #137a3f;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: var(--radius-field);
  transition: filter 0.15s;
}
.cal-link:hover { filter: brightness(0.97); }

/* textarea */
.field-area {
  margin-top: 26px;
  width: 100%;
  resize: none;
  font-family: inherit;
  font-size: 18px;
  color: var(--ink);
  background: #fff;
  border: none;
  border-bottom: 2px solid var(--line);
  padding: 6px 2px 12px;
  transition: border-color 0.2s;
}
.field-area::placeholder { color: #b4b4ba; }
.field-area:focus { outline: none; border-bottom-color: var(--red); }

/* done */
.step--done .step__inner { text-align: center; max-width: 460px; margin: 0 auto; }
.done-mark {
  width: 64px; height: 64px;
  margin: 0 auto 24px;
  display: grid; place-items: center;
  background: var(--red);
  color: #fff;
  border-radius: 50%;
  font-size: 30px;
  font-weight: 600;
}

/* footer nav */
.navbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px 44px 30px;
}
.nav-back {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.18s, opacity 0.18s;
}
.nav-back:hover { border-color: var(--line-strong); }
.nav-back.is-hidden { display: none; }
.nav-spacer { flex: 1; }
.btn-next {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 26px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-field);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.18s, transform 0.12s;
}
.btn-next:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-next:active { transform: translateY(0); }
.btn-next:disabled {
  background: #e9e9ec;
  color: #b1b1b8;
  cursor: default;
  filter: none;
  transform: none;
}
.btn-next:disabled .btn-next__kbd {
  background: rgba(0, 0, 0, 0.06);
  color: #b1b1b8;
}
.btn-next__kbd {
  display: grid; place-items: center;
  min-width: 22px; height: 22px;
  padding: 0 4px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.btn-next.is-hidden { display: none; }

/* submit spinner */
.btn-next__spinner {
  display: none;
  width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn-next.is-loading .btn-next__spinner { display: block; }
.btn-next.is-loading .btn-next__kbd { display: none; }
/* keep the button on-brand (not disabled-grey) while sending, so the white
   spinner stays legible */
.btn-next.is-loading:disabled {
  background: var(--red);
  color: #fff;
  filter: none;
  cursor: progress;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  body { padding: 0; }
  .card {
    height: 100vh;            /* fallback for older mobile browsers */
    height: 100dvh;           /* tracks the dynamic viewport (URL bar show/hide) */
    max-width: none;
    border-radius: 0;
  }
  .topbar { padding: max(18px, env(safe-area-inset-top)) 20px 0; }
  .logo { height: 24px; }
  .logo.is-large { height: 40px; }

  .stage { padding: 0; }
  .step {
    padding: 18px 20px;
    align-items: safe center;  /* center when it fits, top-align + scroll when it doesn't */
  }
  .step__inner { max-width: 100%; }

  .q-eyebrow { font-size: 15px; margin-bottom: 12px; }
  .q-index { font-size: 14px; margin-bottom: 14px; }
  .q-title { font-size: 25px; line-height: 1.2; letter-spacing: -0.2px; }
  .q-hint { font-size: 15px; margin-top: 12px; }

  .options { margin-top: 22px; gap: 10px; }
  .opt {
    padding: 16px;
    font-size: 16px;          /* >=16px avoids iOS auto-zoom */
    min-height: 54px;         /* comfortable tap target */
  }
  .opt__key { display: none; }  /* keyboard shortcuts are irrelevant on touch */
  .field-area { font-size: 16px; margin-top: 20px; }

  /* sticky bottom bar with a full-width primary action */
  .navbar {
    gap: 12px;
    padding: 14px 20px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
  }
  .nav-spacer { display: none; }            /* let the primary button fill the row */
  .nav-back { width: 50px; height: 50px; flex-shrink: 0; }
  .btn-next {
    flex: 1;
    justify-content: center;
    padding: 15px 24px;
    min-height: 50px;
  }
  .btn-next__kbd { display: none; }         /* "↵" hint is irrelevant on touch */
}
