:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --ink: #1b1c33;
  --muted: #6b7096;
  --accent: #4f46e5;
  --accent-soft: #edeefc;
  --accent-ink: #3a32c4;
  --flag: #d98e04;
  --flag-soft: #fdf4e3;
  --danger: #dc2626;
  --line: #e7e9f4;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(27, 28, 51, .04), 0 8px 24px rgba(27, 28, 51, .06);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 18px 64px;
}

/* ---------- Header ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.topbar .brand {
  font-weight: 700;
  letter-spacing: -.01em;
  font-size: 18px;
}
.topbar .brand small { color: var(--muted); font-weight: 500; }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card + .card { margin-top: 16px; }

.lead { color: var(--muted); margin: 4px 0 0; }

h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 20px; font-weight: 700; margin: 0; }

/* ---------- Form fields ---------- */
.field { margin-top: 18px; }
.field label.q {
  display: block;
  font-weight: 600;
  font-size: 19px;
  margin-bottom: 4px;
}
.field .hint { color: var(--muted); font-size: 15px; margin-bottom: 12px; }

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 13px 14px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%236b7096' stroke-width='2'><path d='M5 8l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 40px;
}

.err { color: var(--danger); font-size: 14px; margin-top: 6px; }
.field.invalid input,
.field.invalid select { border-color: var(--danger); }

/* ---------- Yes/No + radio option buttons ---------- */
.yesno { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.optbtn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.optbtn input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.optbtn:hover { border-color: #cfd3ea; }
.optbtn:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.radio-list { display: grid; gap: 10px; }
.radio-list .optbtn { justify-content: flex-start; text-align: right; }
.radio-list .optbtn .dot {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid #c3c7e0; flex: 0 0 auto;
  display: grid; place-items: center;
}
.radio-list .optbtn:has(input:checked) .dot { border-color: var(--accent); }
.radio-list .optbtn:has(input:checked) .dot::after {
  content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 22px;
  font: inherit; font-weight: 700;
  border-radius: 12px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: transform .04s, background .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(79,70,229,.3); width: 100%; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--accent); font-weight: 600; padding: 10px 6px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- Wizard ---------- */
.section-head { display: flex; align-items: center; gap: 10px; color: var(--accent); margin-bottom: 14px; }
.section-head h2 { color: var(--accent); }
.section-head .ic { display: grid; place-items: center; }
.section-head svg { width: 26px; height: 26px; }

.progress { display: flex; gap: 6px; margin-bottom: 26px; }
.progress .seg { height: 5px; flex: 1; border-radius: 99px; background: var(--line); transition: background .25s; }
.progress .seg.on { background: var(--accent); }

.step { display: none; }
.step.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.wizard-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 36px;
}
.wizard-nav .back { color: var(--muted); }

/* ---------- Done / QR ---------- */
.success-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; margin: 0 auto 16px;
}
.qr-box { text-align: center; }
.qr-box img {
  width: 230px; height: 230px; image-rendering: pixelated;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; background: #fff;
}
.link-pill {
  display: block; margin-top: 14px; word-break: break-all;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 13px; color: var(--muted);
}

/* ---------- View (read-only) ---------- */
.id-banner {
  background: var(--accent); color: #fff;
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 19px;
  box-shadow: 0 6px 18px rgba(79,70,229,.28);
}
.id-banner .meta { font-weight: 500; font-size: 14px; opacity: .85; }

.flag-note {
  display: flex; align-items: center; gap: 8px;
  color: var(--flag); font-size: 15px; margin: 14px 2px 0;
}

.answers .grp { margin-top: 18px; }
.answers .grp > .section-head { margin-bottom: 8px; }
.answers .row {
  padding: 14px 2px; border-bottom: 1px solid var(--line);
}
.answers .row:last-child { border-bottom: none; }
.answers .row .q { color: var(--muted); font-size: 15px; }
.answers .row .a { font-weight: 600; margin-top: 2px; display: flex; align-items: center; gap: 8px; }
.answers .row.flagged .a { color: var(--flag); }
.warn {
  width: 22px; height: 22px; flex: 0 0 auto;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--flag-soft); color: var(--flag);
}
.warn svg { width: 15px; height: 15px; }

.footer-note { color: var(--muted); font-size: 13px; text-align: center; margin-top: 28px; }

/* ---------- Review sections ---------- */
textarea {
  width: 100%;
  padding: 13px 14px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  resize: vertical;
  min-height: 96px;
  transition: border-color .15s, box-shadow .15s;
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.stamp { color: var(--muted); font-size: 13px; margin-top: 10px; }

.optbtn.ok:has(input:checked)  { background: #e9f8ef; border-color: #16a34a; color: #15803d; }
.optbtn.bad:has(input:checked) { background: #fdecec; border-color: #dc2626; color: #b91c1c; }

.review-actions {
  display: flex; gap: 12px; margin-top: 18px;
}
.review-actions .btn { flex: 1; width: auto; }
.btn-secondary {
  background: var(--surface); color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-secondary:hover { background: var(--accent-soft); }

/* ---------- Toast ---------- */
.toast {
  position: sticky; top: 10px; z-index: 20;
  margin: 0 auto 14px; max-width: max-content;
  background: #11331f; color: #d7f5e3;
  padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 15px;
  box-shadow: 0 6px 18px rgba(0,0,0,.15);
  transition: opacity .4s, transform .4s;
}
.toast.hide { opacity: 0; transform: translateY(-6px); }
