/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; color: var(--ink); margin: 0; line-height: 1.15; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: 2px; border-radius: 6px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== App frame ===== */
#app { min-height: 100dvh; display: flex; flex-direction: column; }
.page {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s4) var(--s5) calc(120px + var(--safe-bottom));
  flex: 1;
}

/* Top bar: logo + progress */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  padding: calc(var(--s3) + var(--safe-top)) var(--s5) var(--s3);
}
.topbar-inner { max-width: var(--page-max); margin: 0 auto; }
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 36px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .brand-name { font-size: var(--text-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { height: 34px; width: auto; max-width: 150px; object-fit: contain; }
.brand-name { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; }
.step-count { font-size: var(--text-xs); color: var(--ink-soft); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.progress { margin-top: var(--s3); height: 4px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--brand); border-radius: inherit; transition: width var(--dur) var(--ease); }

/* Section header */
.section-head { margin: var(--s6) 0 var(--s6); }
.eyebrow { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--brand); margin-bottom: var(--s2); }
.section-head h1 { font-size: var(--text-2xl); }
.section-head p { margin-top: var(--s3); color: var(--ink-soft); font-size: var(--text-sm); max-width: 44ch; }

/* Step transitions */
.step { animation: step-in var(--dur) var(--ease) both; }
.step.back { animation-name: step-in-back; }
@keyframes step-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes step-in-back { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }

/* ===== Fields ===== */
.field { margin-bottom: var(--s6); scroll-margin-top: 110px; }
.field-label { display: block; font-weight: 600; font-size: var(--text-md); line-height: 1.35; margin-bottom: var(--s2); }
.field-label .opt { font-weight: 400; color: var(--ink-soft); font-size: var(--text-sm); }
.field-hint { font-size: var(--text-xs); font-style: italic; color: var(--ink-soft); margin: calc(-1 * var(--s1)) 0 var(--s2); }
.req { color: var(--brand); font-weight: 700; margin-left: 3px; }
.required-key { font-size: var(--text-sm); color: var(--ink-soft); margin: calc(-1 * var(--s3)) 0 var(--s5); }
.field-error { display: none; align-items: center; gap: 6px; margin-top: var(--s2); font-size: var(--text-sm); color: var(--error); font-weight: 500; }
.field.has-error .field-error { display: flex; }
.field-error svg { width: 17px; height: 17px; flex: none; }
.field.has-error .input, .field.has-error .chips, .field.has-error .scale, .field.has-error .consent-box { --line: var(--error); }

.input {
  width: 100%;
  min-height: var(--tap);
  padding: 13px var(--s4);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--text-md);
  line-height: 1.4;
  transition: border-color 150ms, box-shadow 150ms, background 150ms;
  appearance: none; -webkit-appearance: none;
}
.input::placeholder { color: color-mix(in srgb, var(--ink) 40%, var(--bg)); }
.input:hover { border-color: var(--line-strong); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); background: #fff; }
textarea.input { resize: vertical; min-height: 96px; }
textarea.input[rows="2"] { min-height: 76px; }
input[type="date"].input { min-height: var(--tap); display: block; }
input[type="date"].input::-webkit-date-and-time-value { text-align: left; }

/* Number with unit (kg, cm, hours) */
.unit-group { display: flex; gap: var(--s3); }
.unit-input { position: relative; flex: 1; min-width: 0; }
.unit-input .input { padding-right: 52px; font-variant-numeric: tabular-nums; }
.unit-input .unit { position: absolute; right: var(--s4); top: 50%; transform: translateY(-50%); font-size: var(--text-sm); color: var(--ink-soft); pointer-events: none; }

/* Choice chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  position: relative;
  flex: 1 1 0;
  min-width: 96px;
  min-height: var(--tap);
  padding: 10px var(--s4);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
  text-align: center;
  transition: border-color 150ms, background 150ms, transform 120ms;
  user-select: none;
}
.chips.compact .chip { min-width: 0; flex: 1 1 0; padding: 10px 0; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip small { font-weight: 400; font-size: var(--text-xs); color: var(--ink-soft); margin-top: 2px; }
.chip:active { transform: scale(0.98); }
.chip:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.chip:has(input:checked) small { color: inherit; opacity: 0.85; }
.chip:has(input:focus-visible) { box-shadow: 0 0 0 4px var(--brand-ring); }
.other-input { margin-top: var(--s3); }

/* Tap scale (1-10, 1-5) */
.scale { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 6px; }
.scale .chip { min-width: 0; padding: 0; font-variant-numeric: tabular-nums; font-size: var(--text-md); }
.scale.n10 { grid-template-columns: repeat(5, 1fr); }
.scale.n10 .chip { min-height: 48px; border-radius: var(--radius-sm); }
.scale-ends { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--ink-soft); margin-top: var(--s2); }

/* Consent */
.consent-box { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s4); background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.consent-box input { width: 24px; height: 24px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.consent-box p { font-size: var(--text-sm); }
.consent-box p + p { margin-top: var(--s2); }

/* ===== Photos ===== */
.photo-tips { list-style: none; margin: 0 0 var(--s6); padding: var(--s4); background: var(--surface-2); border-radius: var(--radius); display: grid; gap: var(--s2); font-size: var(--text-sm); }
.photo-tips li { display: flex; gap: var(--s2); align-items: flex-start; }
.photo-tips li::before { content: ''; flex: none; width: 6px; height: 6px; margin-top: 8px; border-radius: 50%; background: var(--brand); }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.photo-slot { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.photo-slot .field-label { margin: 0; font-size: var(--text-sm); text-align: center; }
.photo-tile {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  border: 1.5px dashed var(--line-strong);
  background: var(--surface);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color 150ms, transform 120ms;
}
.photo-tile:active { transform: scale(0.98); }
.photo-tile svg.pose { width: 46%; height: auto; color: var(--accent); }
.photo-tile .add { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); font-size: var(--text-xs); font-weight: 600; color: var(--brand); white-space: nowrap; }
.photo-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-tile.filled { border-style: solid; border-color: var(--brand); }
.photo-tile .busy { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.photo-slot input[type="file"] { display: none; }
.photo-actions { display: flex; flex-wrap: wrap; justify-content: center; column-gap: var(--s2); font-size: var(--text-xs); min-height: 30px; }
.link-btn { background: none; border: 0; padding: 6px 4px; color: var(--brand); font-weight: 600; font-size: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.photo-note { margin-top: var(--s4); font-size: var(--text-sm); color: var(--ink-soft); text-align: center; }

/* ===== Bottom action bar ===== */
.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: var(--s3) var(--s5) calc(var(--s3) + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 70%, color-mix(in srgb, var(--bg) 0%, transparent));
}
.actions-inner { max-width: var(--page-max); margin: 0 auto; display: flex; gap: var(--s3); }
.btn {
  min-height: var(--tap);
  padding: 0 var(--s6);
  border-radius: 999px;
  border: 0;
  font-weight: 600;
  font-size: var(--text-md);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  transition: transform 120ms, box-shadow 150ms, background 150ms, opacity 150ms;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn-primary { flex: 1; background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow); }
.btn-primary:hover { box-shadow: var(--shadow-lift); }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); }
.btn[disabled] { opacity: 0.6; pointer-events: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Welcome ===== */
.welcome { text-align: center; padding-top: var(--s8); }
.welcome .hero-logo { width: min(240px, 66vw); max-height: 170px; object-fit: contain; margin: 0 auto var(--s8); }
.welcome h1 { font-size: var(--text-2xl); }
.welcome .lead { margin: var(--s4) auto 0; color: var(--ink-soft); max-width: 34ch; }
.welcome-list { list-style: none; padding: 0; margin: var(--s8) auto 0; max-width: 360px; display: grid; gap: var(--s3); text-align: left; }
.welcome-list li { display: flex; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4); background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); font-size: var(--text-sm); }
.welcome-list .ico { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.welcome-list .ico svg { width: 18px; height: 18px; }
.resume-note { margin-top: var(--s6); font-size: var(--text-sm); color: var(--ink-soft); }

/* ===== Review ===== */
.review-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s4) var(--s5); margin-bottom: var(--s4); }
.review-section header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s2); }
.review-section h2 { font-size: var(--text-lg); }
.review-section dl { margin: 0; }
.review-item { padding: var(--s3) 0; border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.review-item:first-child { border-top: 0; }
.review-item dt { font-size: var(--text-xs); color: var(--ink-soft); margin-bottom: 2px; }
.review-item dd { margin: 0; font-size: var(--text-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.review-item dd.empty { color: color-mix(in srgb, var(--ink) 40%, var(--bg)); font-style: italic; }
.review-photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.review-photos figure { margin: 0; }
.review-photos img, .review-photos .none { aspect-ratio: 3/4; width: 100%; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); }
.review-photos figcaption { font-size: var(--text-xs); text-align: center; color: var(--ink-soft); margin-top: 4px; }

/* ===== Banners & states ===== */
.banner { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s4); border-radius: var(--radius); font-size: var(--text-sm); margin-bottom: var(--s5); }
.banner svg { flex: none; width: 20px; height: 20px; margin-top: 1px; }
.banner.error { background: var(--error-soft); color: var(--error); }
.banner.info { background: var(--surface-2); color: var(--ink); }
.center-state { min-height: 70dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: var(--s4); padding: var(--s8) var(--s5); }
.center-state h1 { font-size: var(--text-xl); }
.center-state p { color: var(--ink-soft); max-width: 34ch; }
.loader-dots { display: flex; gap: 8px; }
.loader-dots span { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); animation: pulse 1.1s var(--ease) infinite; }
.loader-dots span:nth-child(2) { animation-delay: 0.15s; }
.loader-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: none; } }

/* Thank-you */
.done { text-align: center; padding-top: var(--s12); }
.done .tick { width: 84px; height: 84px; margin: 0 auto var(--s6); border-radius: 50%; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; animation: pop 500ms var(--ease) both; }
.done .tick svg { width: 40px; height: 40px; }
.done .tick path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw 420ms 220ms var(--ease) forwards; }
.done h1 { font-size: var(--text-2xl); }
.done p { margin: var(--s4) auto 0; color: var(--ink-soft); max-width: 34ch; }
.done .hero-logo { width: 140px; max-height: 100px; object-fit: contain; margin: var(--s12) auto 0; opacity: 0.9; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Toast (draft saved etc.) */
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translate(-50%, 12px); opacity: 0; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: var(--text-xs); font-weight: 500; transition: opacity 200ms, transform 200ms var(--ease); pointer-events: none; z-index: 20; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Mock-mode badge (testing only) */
.mock-badge { position: fixed; bottom: calc(84px + var(--safe-bottom)); left: 8px; z-index: 30; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; background: #111; color: #fff; padding: 3px 8px; border-radius: 99px; opacity: 0.75; }

@media (min-width: 700px) {
  .page { padding-top: var(--s8); }
  .section-head h1 { font-size: 2.5rem; }
}

/* ===== Dropdown ===== */
.select-wrap { position: relative; }
.select-wrap::after { content: ''; position: absolute; right: 18px; top: 50%; width: 9px; height: 9px; border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
select.input { padding-right: 44px; cursor: pointer; }
select.input:has(option[value=""]:checked) { color: color-mix(in srgb, var(--ink) 45%, var(--bg)); }

/* ===== Phone with country code ===== */
.phone-row { display: flex; gap: var(--s2); }
.country-pick { position: relative; flex: none; min-width: 104px; min-height: var(--tap); display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 28px 0 12px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); font-variant-numeric: tabular-nums; cursor: pointer; }
.country-pick::after { content: ''; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft); transform: translateY(-70%) rotate(45deg); }
.country-pick:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
.country-pick select { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; font-size: 16px; }
.phone-row .input { flex: 1; min-width: 0; }

/* ===== Slider ===== */
.slider { padding: var(--s2) 0 0; }
.slider-value { display: block; text-align: center; font-family: var(--font-display); font-size: 2.5rem; font-weight: 600; line-height: 1; color: var(--line-strong); margin-bottom: var(--s1); font-variant-numeric: tabular-nums; transition: color 150ms; }
.slider.set .slider-value { color: var(--brand); }
.slider input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; background: transparent; margin: 0; cursor: pointer; touch-action: pan-y; }
.slider input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 99px; background: linear-gradient(to right, var(--line) 0 100%); }
.slider.set input[type=range]::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--brand) 0 var(--pct), var(--surface-2) var(--pct) 100%); }
.slider input[type=range]::-moz-range-track { height: 8px; border-radius: 99px; background: var(--surface-2); }
.slider.set input[type=range]::-moz-range-progress { height: 8px; border-radius: 99px; background: var(--brand); }
.slider input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; margin-top: -11px; border-radius: 50%; background: #fff; border: 2px solid var(--line-strong); box-shadow: var(--shadow); transition: transform 120ms, border-color 150ms; }
.slider.set input[type=range]::-webkit-slider-thumb { border-color: var(--brand); }
.slider input[type=range]:active::-webkit-slider-thumb { transform: scale(1.12); }
.slider input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 2px solid var(--brand); }
.slider input[type=range]:focus-visible { outline: none; }
.slider input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px var(--brand-ring); }
.slider .scale-ends { margin-top: 2px; }
.slider-tip { text-align: center; font-size: var(--text-xs); font-style: italic; color: var(--ink-soft); margin-top: var(--s2); }
.field.has-error .slider input[type=range]::-webkit-slider-runnable-track { background: var(--error-soft); }

/* ===== ft/in to cm helper ===== */
.converter { margin-top: var(--s3); }
.converter summary { cursor: pointer; color: var(--brand); font-size: var(--text-sm); font-weight: 600; list-style: none; padding: 4px 0; }
.converter summary::-webkit-details-marker { display: none; }
.converter summary::before { content: '+ '; }
.converter[open] summary::before { content: '– '; }
.converter .unit-group { margin-top: var(--s2); }
.converter .field-hint { margin-top: var(--s2); }

/* Multi-select chips */
.chips.multi .chip { flex: 1 1 calc(33% - 8px); min-width: 0; }

/* Slider description under the number */
.slider-desc { text-align: center; font-size: var(--text-sm); font-weight: 600; color: var(--brand); min-height: 1.4em; margin-bottom: var(--s2); }

/* Single-choice list with tick boxes */
.option-list { display: grid; gap: var(--s2); }
.list-option { display: flex; align-items: center; gap: var(--s3); min-height: var(--tap); padding: 10px var(--s4); background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; font-weight: 500; transition: border-color 150ms, background 150ms; }
.list-option input { position: absolute; opacity: 0; pointer-events: none; }
.list-option .tickbox { flex: none; width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line-strong); background: #fff; display: grid; place-items: center; transition: background 150ms, border-color 150ms; }
.list-option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.list-option:has(input:checked) .tickbox { background: var(--brand); border-color: var(--brand); }
.list-option:has(input:checked) .tickbox::after { content: ''; width: 6px; height: 11px; border: solid var(--on-brand); border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }
.list-option:has(input:focus-visible) { box-shadow: 0 0 0 4px var(--brand-ring); }
.field.has-error .option-list { --line: var(--error); }

/* Login */
.login-form { display: flex; flex-direction: column; gap: var(--s4, 16px); margin-top: var(--s5, 24px); }
.login-form.has-error .login-error { display: flex; }
.login-form .btn { width: 100%; }
.login-help { text-align: center; }
