:root {
  --paper: #fbf8f6;
  --card: #ffffff;
  --ink: #1d1a2b;
  --ink-2: #4a4560;
  --muted: #8a8499;
  --line: #ebe4e0;
  --line-2: #ddd4cf;
  --pink: #f57072;
  --magenta: #dc5fbb;
  --violet: #9777e9;
  --blue: #41aff8;
  --error: #d93636;
  --brand: linear-gradient(90deg, #f57072 0%, #dc5fbb 49%, #9777e9 70%, #41aff8 100%);
  --brand-soft: linear-gradient(90deg, rgba(245,112,114,.09), rgba(220,95,187,.09) 49%, rgba(151,119,233,.09) 70%, rgba(65,175,248,.09));
  --font: 'Readex Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --rail: 300px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; }
[hidden] { display: none !important; }

/* ---------- progress ---------- */
.progress {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 20;
  background: rgba(29, 26, 43, .06);
}
.progress span {
  display: block; height: 100%; width: 0;
  background: var(--brand); background-size: 100vw 100%;
  transition: width .6s var(--ease);
}

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100dvh; }

.rail {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column;
  padding: 44px 36px 32px;
  border-inline-end: 1px solid var(--line);
  background:
    radial-gradient(120% 60% at 0% 100%, rgba(151,119,233,.07), transparent 60%),
    radial-gradient(90% 50% at 100% 0%, rgba(245,112,114,.06), transparent 60%),
    var(--paper);
}
.rail-logo { width: 132px; height: auto; }
.rail-steps { list-style: none; padding: 0; margin: auto 0; display: grid; gap: 4px; }
.rail-steps li {
  position: relative; display: flex; align-items: center; gap: 14px;
  padding: 12px 0; color: var(--muted); font-size: 15px; font-weight: 400;
  transition: color .3s var(--ease);
}
.rail-steps li::before {
  content: ''; position: absolute; inset-inline-start: 11px; top: 38px; bottom: -10px;
  border-inline-start: 2px dotted var(--line-2);
}
.rail-steps li:last-child::before { display: none; }
.rail-dot {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--line-2); background: var(--paper);
  font-size: 11px; font-weight: 600; color: var(--muted);
  transition: all .35s var(--ease);
}
.rail-dot svg { width: 12px; height: 12px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.rail-steps li.is-current { color: var(--ink); font-weight: 500; }
.rail-steps li.is-current .rail-dot { border-color: transparent; background: var(--ink); color: #fff; box-shadow: 0 0 0 5px rgba(29,26,43,.07); }
.rail-steps li.is-done { color: var(--ink-2); }
.rail-steps li.is-done .rail-dot { border-color: transparent; background: var(--brand); }
.rail-foot { margin: 0; font-size: 12px; line-height: 1.6; color: var(--muted); }

/* ---------- stage ---------- */
.stage { position: relative; display: flex; flex-direction: column; min-height: 100dvh; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 26px 48px 0;
}
.top-logo { display: none; width: 104px; height: auto; margin-inline-end: auto; }
.counter {
  margin-inline-end: auto;
  font-size: 13px; font-weight: 500; letter-spacing: .08em; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.counter b { color: var(--ink); font-weight: 600; }

.viewport {
  flex: 1; display: grid; align-items: center;
  padding: 24px 48px 40px; outline: none;
}
.screen {
  width: 100%; max-width: 640px; margin: 0 auto;
  animation: enter .55s var(--ease) both;
}
.screen.is-leaving { animation: leave .22s ease-in both; }
.screen.back { animation-name: enter-back; }
@keyframes enter { from { opacity: 0; transform: translateY(28px); } }
@keyframes enter-back { from { opacity: 0; transform: translateY(-28px); } }
@keyframes leave { to { opacity: 0; transform: translateY(-14px); } }

.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  margin: 0 0 18px; font-size: 13px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-2);
}
.eyebrow i {
  font-style: normal; font-weight: 600;
  background: var(--brand); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.q {
  margin: 0; font-size: clamp(27px, 3.4vw, 40px); line-height: 1.18; font-weight: 500; letter-spacing: -.02em;
  text-wrap: balance;
}
.help { margin: 14px 0 0; font-size: 17px; line-height: 1.55; color: var(--ink-2); font-weight: 300; max-width: 52ch; }
.opt-tag {
  display: inline-block; margin-inline-start: 10px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; letter-spacing: .02em; vertical-align: 6px;
  background: rgba(29,26,43,.06); color: var(--ink-2);
}

/* ---------- inputs ---------- */
.fields { display: grid; gap: 30px; margin-top: 40px; }
.field label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.field small { display: block; margin-top: 8px; font-size: 13px; color: var(--muted); }
.input {
  width: 100%; border: 0; border-bottom: 2px solid var(--line-2); border-radius: 0;
  background: transparent; padding: 12px 0 12px; outline: none;
  font: inherit; font-size: clamp(21px, 2.4vw, 26px); font-weight: 400; color: var(--ink);
  transition: border-color .25s;
  background-image: var(--brand); background-repeat: no-repeat; background-position: 0 100%;
  background-size: 0 2px;
  transition: background-size .45s var(--ease), border-color .25s;
}
.input::placeholder { color: #c4bcb8; font-weight: 300; }
.input:focus { background-size: 100% 2px; border-bottom-color: transparent; }
.input[aria-invalid="true"] { border-bottom-color: var(--error); }
textarea.input { resize: none; min-height: 132px; line-height: 1.5; font-size: 20px; }
.input[type="tel"] { direction: ltr; }

.err {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  font-size: 14px; color: var(--error); animation: shake .35s;
}
.err::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.same { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-top: 18px; font-size: 14px; }
.same button {
  border: 0; background: none; padding: 0; font: inherit; font-weight: 500; color: var(--ink);
  text-decoration: underline; text-decoration-color: #dc5fbb; text-decoration-thickness: 1.5px; text-underline-offset: 4px;
  transition: color .2s, text-decoration-color .2s;
}
.same button:hover { color: #dc5fbb; }
.same span { color: var(--muted); }

/* ---------- choices ---------- */
.choices { display: grid; gap: 10px; margin-top: 36px; }
.choices.two { grid-template-columns: 1fr 1fr; }
.choices.three { grid-template-columns: repeat(3, 1fr); }
.choice {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%;
  text-align: start; padding: 15px 18px; border-radius: 16px;
  border: 1.5px solid var(--line); background: var(--card);
  font-size: 16px; line-height: 1.35;
  transition: border-color .2s, transform .2s var(--ease), box-shadow .25s, background .25s;
}
.choice:hover { border-color: var(--line-2); transform: translateY(-1px); box-shadow: 0 6px 18px -10px rgba(29,26,43,.25); }
.choice:active { transform: scale(.985); }
.choice .tick {
  margin-inline-start: auto; flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--line-2); display: grid; place-items: center;
  transition: all .25s var(--ease);
}
.choice.square .tick { border-radius: 7px; }
.choice .tick svg { width: 12px; height: 12px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(.5); transition: all .25s var(--ease); }
.choice[aria-checked="true"] {
  border-color: transparent;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    var(--brand) border-box;
  box-shadow: 0 10px 24px -14px rgba(220,95,187,.55);
}
.choice[aria-checked="true"]::after {
  content: ''; position: absolute; inset: 0; border-radius: 15px; background: var(--brand-soft); pointer-events: none;
}
.choice[aria-checked="true"] .tick { border-color: transparent; background: var(--brand); }
.choice[aria-checked="true"] .tick svg { opacity: 1; transform: none; }
.choice.big { padding: 22px 20px 22px 24px; font-size: 18px; font-weight: 500; }

.other-wrap { grid-column: 1 / -1; display: grid; gap: 0; }
.other-input { margin: 4px 18px 6px; font-size: 18px; padding: 8px 0; }

/* ---------- ratings ---------- */
.ratings { margin-top: 36px; display: grid; gap: 8px; }
.rating-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 20px;
  padding: 14px 18px; border-radius: 16px; background: var(--card); border: 1.5px solid var(--line);
  transition: border-color .25s;
}
.rating-row.is-set { border-color: var(--line-2); }
.rating-row[aria-invalid="true"] { border-color: var(--error); }
.rating-label { font-size: 16px; font-weight: 500; }
.scale { display: flex; gap: 6px; direction: ltr; }
.scale button {
  width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--paper); font-size: 16px; font-weight: 500; color: var(--ink-2);
  transition: all .2s var(--ease);
}
.scale button:hover { border-color: var(--ink-2); color: var(--ink); }
.scale button.fill { background: rgba(220,95,187,.1); border-color: transparent; color: var(--ink); }
.scale button.on { --a: #f57072; --b: #e866a0; background: linear-gradient(135deg, var(--a), var(--b)); border-color: transparent; color: #fff; transform: scale(1.06); box-shadow: 0 8px 18px -8px var(--b); }
.scale button:nth-child(2).on { --a: #ec6893; --b: #dc5fbb; }
.scale button:nth-child(3).on { --a: #dc5fbb; --b: #b46cd6; }
.scale button:nth-child(4).on { --a: #b46cd6; --b: #9777e9; }
.scale button:nth-child(5).on { --a: #9777e9; --b: #6a93f1; }
.scale-legend {
  display: flex; justify-content: space-between; margin: 10px 4px 0; font-size: 13px; color: var(--muted);
}

/* ---------- welcome ---------- */
.welcome { max-width: 680px; }
.sticker {
  width: min(300px, 62vw); height: auto; margin: 0 0 38px;
  transform: rotate(-4deg);
  filter:
    drop-shadow(4px 0 0 #fff) drop-shadow(-4px 0 0 #fff)
    drop-shadow(0 4px 0 #fff) drop-shadow(0 -4px 0 #fff)
    drop-shadow(0 18px 22px rgba(151,119,233,.28));
  animation: peel .9s var(--ease) both .1s;
  transition: transform .5s var(--ease);
}
.sticker:hover { transform: rotate(-1deg) scale(1.03); }
@keyframes peel { from { opacity: 0; transform: rotate(-14deg) scale(.86) translateY(14px); } }
.welcome h1 {
  margin: 0; font-size: clamp(36px, 5.2vw, 60px); line-height: 1.04; font-weight: 600; letter-spacing: -.035em;
}
.welcome .lede { margin: 20px 0 0; font-size: 19px; line-height: 1.55; font-weight: 300; color: var(--ink-2); max-width: 46ch; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 34px; font-size: 14px; color: var(--muted); }
.meta span { display: inline-flex; align-items: center; gap: 8px; }
.meta svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- review ---------- */
.review { margin-top: 32px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); overflow: hidden; }
.review-group + .review-group { border-top: 1px solid var(--line); }
.review-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 6px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.review-head button {
  border: 0; background: none; padding: 4px 0; font-size: 13px; font-weight: 500; letter-spacing: 0; text-transform: none;
  color: var(--magenta); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.review-rows { padding: 0 8px 8px; }
.review-row {
  display: grid; grid-template-columns: minmax(130px, 38%) 1fr 20px; gap: 16px; align-items: start;
  width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: none; text-align: start;
  font-size: 15px; line-height: 1.45; transition: background .2s;
}
.review-row + .review-row { box-shadow: 0 -1px 0 var(--line); }
button.review-row:hover { background: var(--paper); }
.review-row .rl { color: var(--muted); }
.review-row .rv { color: var(--ink); overflow-wrap: anywhere; }
.review-row .re svg { width: 15px; height: 15px; margin-top: 3px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linejoin: round; opacity: 0; transition: opacity .2s; }
button.review-row:hover .re svg, button.review-row:focus-visible .re svg { opacity: 1; stroke: var(--magenta); }
.review .empty { color: #c4bcb8; }

/* ---------- sign ---------- */
.declare {
  display: flex; gap: 16px; align-items: flex-start; margin-top: 34px; width: 100%;
  padding: 20px; border-radius: 18px; text-align: start;
  border: 1.5px solid var(--line); background: var(--card); font-size: 16px; line-height: 1.55;
  transition: border-color .2s, box-shadow .25s;
}
.declare .tick { flex: none; margin-top: 2px; width: 24px; height: 24px; border-radius: 8px; border: 1.5px solid var(--line-2); display: grid; place-items: center; transition: all .25s var(--ease); }
.declare .tick svg { width: 13px; height: 13px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity .2s; }
.declare[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 10px 24px -16px rgba(29,26,43,.5); }
.declare[aria-checked="true"] .tick { background: var(--ink); border-color: var(--ink); }
.declare[aria-checked="true"] .tick svg { opacity: 1; }
.declare[aria-invalid="true"] { border-color: var(--error); }

.sigpad {
  position: relative; margin-top: 14px; padding: 22px 24px 18px; border-radius: 18px;
  background:
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(29,26,43,.035) 31px 32px),
    var(--card);
  border: 1.5px solid var(--line);
}
.sigpad label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); }
.sigpad .input { font-size: 20px; }
.sig-preview {
  height: 86px; display: flex; align-items: flex-end; padding: 6px 4px 0;
  font-family: 'Mrs Saint Delafield', cursive; font-size: 58px; line-height: 1; color: #2b2a6b;
  white-space: nowrap; overflow: hidden; text-overflow: clip;
}
.sig-preview.ar { font-family: 'Aref Ruqaa', serif; font-size: 40px; }
.sig-preview:empty::before { content: attr(data-placeholder); color: #d6cfcb; }
.sig-line { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; padding-top: 10px; border-top: 1.5px solid var(--ink); font-size: 13px; color: var(--muted); }

.send-error {
  margin-top: 18px; padding: 14px 16px; border-radius: 14px; background: rgba(217,54,54,.07);
  color: #9c2424; font-size: 15px; line-height: 1.5;
}
.send-error a { color: inherit; font-weight: 500; }

/* ---------- done ---------- */
.done { text-align: center; max-width: 560px; }
.seal {
  width: 112px; height: 112px; margin: 0 auto 34px; border-radius: 50%;
  display: grid; place-items: center; background: var(--brand);
  box-shadow: 0 0 0 10px #fff, 0 22px 40px -14px rgba(220,95,187,.6);
  animation: pop .7s var(--ease) both;
}
.seal svg { width: 48px; height: 48px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .5s .35s ease-out forwards; }
@keyframes pop { from { transform: scale(.4) rotate(-20deg); opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.done h1 { margin: 0; font-size: clamp(32px, 4.4vw, 48px); font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }
.done p { margin: 18px auto 0; font-size: 18px; line-height: 1.6; font-weight: 300; color: var(--ink-2); max-width: 44ch; }
.next-steps { list-style: none; padding: 0; margin: 36px 0 0; display: grid; gap: 10px; text-align: start; }
.next-steps li { display: flex; gap: 14px; align-items: center; padding: 14px 18px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); font-size: 15px; line-height: 1.45; }
.next-steps b { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); border: 1px solid var(--line-2); font-size: 13px; font-weight: 600; }

/* ---------- dock ---------- */
.dock {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 18px 48px 32px; max-width: calc(640px + 96px); width: 100%; margin: 0 auto;
  background: linear-gradient(to top, var(--paper) 72%, rgba(251,248,246,0));
}
.spacer { margin-inline-start: auto; }
.primary, .ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 54px; border-radius: 999px; font-size: 16px; font-weight: 500; white-space: nowrap;
  transition: transform .2s var(--ease), box-shadow .25s, background .25s, opacity .2s;
}
.primary svg, .ghost svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s var(--ease); }
.primary {
  padding: 0 26px 0 30px; border: 0; color: #fff; font-weight: 600;
  background: linear-gradient(90deg, #f57072 0%, #dc5fbb 35%, #9777e9 65%, #41aff8 100%);
  background-size: 160% 100%; background-position: 0 0;
  box-shadow: 0 12px 26px -12px rgba(220,95,187,.8);
  transition: transform .2s var(--ease), box-shadow .25s, background-position .5s var(--ease), opacity .2s;
}
.primary:hover { transform: translateY(-1px); background-position: 100% 0; box-shadow: 0 14px 30px -12px rgba(151,119,233,.85); }
.primary:hover svg { transform: translateX(3px); }
.primary:active { transform: scale(.97); }
.primary.send { padding: 0 34px; }
.primary[disabled] { opacity: .55; cursor: progress; }
.primary .spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ghost { padding: 0 18px 0 12px; border: 0; background: transparent; color: var(--ink-2); }
.ghost:hover { color: var(--ink); background: rgba(29,26,43,.05); }

:focus-visible { outline: 2px solid var(--violet); outline-offset: 3px; border-radius: 10px; }
.input:focus-visible, .viewport:focus-visible, .done h1:focus-visible { outline: none; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  :root { --rail: 0px; }
  .shell { display: block; }
  .rail { display: none; }
  .top-logo { display: block; }
  .counter { margin-inline: auto; }
  [data-step="welcome"] .top-logo { visibility: hidden; }
}
@media (max-width: 640px) {
  .topbar { padding: 18px 16px 0; }
  .top-logo { width: 92px; }
  .viewport { align-items: start; padding: 28px 16px 120px; }
  .dock {
    position: fixed; inset: auto 0 0 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--paper) 70%, rgba(251,248,246,0));
  }
  .primary { flex: 1; }
  .help { font-size: 16px; }
  .fields { margin-top: 30px; }
  .choices.two, .choices.three { grid-template-columns: 1fr; }
  .rating-row { grid-template-columns: 1fr; gap: 12px; padding: 14px; }
  .scale { justify-content: space-between; }
  .scale button { flex: 1; height: 46px; width: auto; }
  .welcome h1 { font-size: 38px; }
  .sticker { margin-bottom: 30px; }
  .review-row { grid-template-columns: 1fr 16px; gap: 2px 12px; }
  .review-row .rl { grid-column: 1; font-size: 13px; }
  .review-row .rv { grid-column: 1; }
  .review-row .re { grid-column: 2; grid-row: 1 / span 2; }
  .review-row .re svg { opacity: 1; }
  .sig-preview { font-size: 48px; height: 74px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
