.survey-page { min-height: 100dvh; display: flex; flex-direction: column; background: var(--paper); }

.survey-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; padding-top: max(14px, env(safe-area-inset-top));
}
.survey-top .brand span { font-size: 22px; }
.progress-text { font-size: 14px; color: var(--slate); font-variant-numeric: tabular-nums; }
.progress { height: 4px; background: #EFEBE1; }
.progress-fill { height: 100%; width: 0; background: var(--yellow); transition: width .45s cubic-bezier(.2,.8,.2,1); }

.survey-main {
  flex: 1; width: 100%; max-width: 640px; margin: 0 auto;
  padding: 28px 20px calc(110px + env(safe-area-inset-bottom));
}
.q h2 { font-size: clamp(24px, 6vw, 32px); margin-bottom: 8px; }
.q .hint { color: var(--slate); margin: 0 0 18px; font-size: 15px; }
.q.enter { animation: rise .38s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.choices { display: grid; gap: 10px; margin-top: 14px; }
.choice {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 54px; padding: 12px 14px; text-align: left;
  background: var(--white); border: 1.5px solid var(--line); border-radius: 12px;
  font: inherit; font-size: 16px; color: var(--ink); cursor: pointer;
  transition: border-color .15s, background .15s, transform .08s;
  -webkit-tap-highlight-color: transparent;
}
.choice:hover { border-color: #CFC8B8; }
.choice:active { transform: scale(.99); }
.choice.on { border-color: var(--ink); background: var(--yellow-soft); }
.choice .key {
  flex: 0 0 26px; height: 26px; display: grid; place-items: center; border-radius: 7px;
  border: 1.5px solid var(--line); font-size: 13px; font-weight: 600; color: var(--slate);
}
.choice.on .key { background: var(--ink); color: var(--white); border-color: var(--ink); }
.choice .box { flex: 0 0 22px; height: 22px; border-radius: 6px; border: 1.5px solid #BDB5A3; position: relative; }
.choice.on .box { background: var(--ink); border-color: var(--ink); }
.choice.on .box::after {
  content: ""; position: absolute; left: 7px; top: 3px; width: 5px; height: 10px;
  border: solid var(--yellow); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.choice .badge {
  flex: 0 0 30px; height: 30px; display: grid; place-items: center; border-radius: 50%;
  border: 1.5px dashed #BDB5A3; font-weight: 700;
}
.choice.rank.on .badge { background: var(--ink); color: var(--yellow); border: 0; animation: pop .25s ease; }
@keyframes pop { 0% { transform: scale(.6); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }

.fields { display: grid; gap: 16px; margin-top: 10px; }
.field span { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.text {
  width: 100%; min-height: 52px; padding: 12px 14px; font: inherit; font-size: 16px;
  background: var(--white); border: 1.5px solid var(--line); border-radius: 12px; color: var(--ink);
}
.text:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px var(--yellow-soft); }
.text.area { min-height: 130px; resize: vertical; }
.other { margin-top: 10px; animation: rise .25s ease; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.consent { display: flex; gap: 12px; align-items: flex-start; padding: 14px; background: var(--white);
  border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; font-size: 16px; }
.consent input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--ink); flex: 0 0 22px; }
.consent em { font-style: normal; color: var(--slate); font-size: 14px; }

.error { color: var(--red); font-weight: 600; margin: 14px 0 0; }

.survey-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: space-between; gap: 12px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 70%, rgba(250,248,243,0));
  max-width: 640px; margin: 0 auto;
}
.survey-nav .btn { min-height: 52px; }
.survey-nav #next { margin-left: auto; }

.done-mark { width: 64px; height: 64px; border-radius: 50%; background: var(--yellow); margin-bottom: 18px; position: relative; animation: pop .4s ease; }
.done-mark::after { content: ""; position: absolute; left: 24px; top: 14px; width: 14px; height: 28px;
  border: solid var(--ink); border-width: 0 5px 5px 0; transform: rotate(45deg); }

@media (prefers-reduced-motion: reduce) {
  .q.enter, .other, .done-mark, .choice.rank.on .badge { animation: none; }
  .progress-fill { transition: none; }
}

[hidden] { display: none !important; }

/* v2.1 — calmer type on phones, extra "something else" rows, drag-to-rank, intro screen */
@media (max-width: 600px) {
  body.survey-page { font-size: 15px; }
  .q h2 { font-size: 21px; line-height: 1.25; }
  .q .hint { font-size: 14px; margin-bottom: 12px; }
  .choice { min-height: 48px; font-size: 15px; padding: 10px 12px; }
  .text { font-size: 16px; min-height: 48px; }          /* 16px keeps iOS from zooming into inputs */
  .consent { font-size: 15px; }
  .survey-main { padding-top: 20px; }
  .intro-big { font-size: 24px; }
  .lead { font-size: 16px; }
}
.other-row { display: flex; gap: 8px; margin-bottom: 8px; }
.icon-btn { flex: 0 0 40px; min-height: 40px; border: 1.5px solid var(--line); background: var(--white);
  border-radius: 10px; font-size: 18px; cursor: pointer; color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.add-btn { background: none; border: 0; padding: 6px 2px; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.rank-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.rank-item { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; background: var(--white);
  border: 1.5px solid var(--line); border-radius: 12px; touch-action: none; user-select: none; cursor: grab;
  transition: transform .18s ease, box-shadow .18s ease; }
.rank-item.dragging { transition: none; z-index: 2; position: relative; cursor: grabbing; border-color: var(--ink);
  box-shadow: 0 12px 28px rgba(21,23,26,.18); background: var(--yellow-soft); }
.rank-item.moved { animation: pop .25s ease; }
.rank-item .grip { color: #BDB5A3; letter-spacing: -2px; font-size: 16px; }
.rank-item .badge { flex: 0 0 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: var(--yellow); font-weight: 700; font-size: 14px; }
.rank-item .rank-text { flex: 1; font-size: 15px; line-height: 1.35; }
.rank-item .arrows { display: flex; gap: 6px; }
.rank-item .arrows .icon-btn { flex-basis: 34px; min-height: 34px; font-size: 15px; }
.intro-big { font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1.2; margin: 6px 0 12px; }
.intro .lead { margin-bottom: 10px; }

/* v2.2 — save as you go: a quiet "welcome back" line with a way to start over */
.resume-note { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--yellow-soft);
  font-size: 14px; color: var(--ink); }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--ink);
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* v2.3 — character counters, no rank arrows */
.count { margin-top: 4px; font-size: 12px; color: var(--slate); text-align: right; font-variant-numeric: tabular-nums; }
.other-field { flex: 1; min-width: 0; }
.other-row { align-items: flex-start; }
.rank-item:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.field-note { display: block; margin-top: 5px; font-size: 13px; color: var(--slate); }
/* v2.5 — lift Back/Next off the very bottom edge: when Safari's toolbar is collapsed, a tap in the bottom strip
   can be taken as "show the toolbar" instead of a button press. */
.survey-nav { padding-bottom: calc(26px + env(safe-area-inset-bottom)); }
.survey-main { padding-bottom: calc(130px + env(safe-area-inset-bottom)); }
