:root {
  --navy: #0f2a43;
  --navy-2: #1a3d5f;
  --navy-soft: #e8eef4;
  --ink: #13202e;
  --muted: #5b6b7c;
  --line: #d7e0e8;
  --bg: #f3f6f9;
  --card: #ffffff;
  --green: #16a34a;
  --green-soft: #e7f6ec;
  --red: #c0392b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--navy-2); }
button, input { font: inherit; color: inherit; }

/* ── Header ─────────────────────────────────────── */
.top {
  background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
}
.logo { display: flex; align-items: center; gap: 9px; line-height: 0; color: #fff; text-decoration: none; font-size: 17px; letter-spacing: -.01em; }
.logo b { font-weight: 800; }
.top-note { font-size: 13px; color: #b9c9d8; }

.wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 16px 16px 8px; flex: 1; }

/* ── Progress ───────────────────────────────────── */
.progress { margin: 2px 2px 12px; }
.progress-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 7px; min-height: 28px; }
.back { background: none; border: 0; padding: 4px 8px 4px 0; color: var(--navy-2); font-weight: 600; cursor: pointer; }
.back[hidden] { display: inline-block; visibility: hidden; }
.bar { height: 7px; background: #dce5ee; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--green); border-radius: 99px; transition: width .35s ease; }

/* ── Card ───────────────────────────────────────── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(15,42,67,.06), 0 6px 24px rgba(15,42,67,.06); padding: 22px 18px 20px; }
.card.enter { animation: enter .28s ease; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .card.enter { animation: none; } .bar i { transition: none; } }

.hero h1 { font-size: 26px; line-height: 1.18; letter-spacing: -.02em; margin: 0 0 8px; color: var(--navy); font-weight: 800; }
.hero p { margin: 0 0 18px; color: var(--muted); font-size: 15px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; padding: 0; list-style: none; }
.pills li { font-size: 13px; font-weight: 600; color: var(--navy); background: var(--navy-soft); border-radius: 99px; padding: 5px 10px; }

h2.q { font-size: 21px; line-height: 1.25; margin: 0 0 4px; color: var(--navy); letter-spacing: -.01em; }
.hint { margin: 0 0 16px; color: var(--muted); font-size: 14px; }

/* ── Answer buttons ─────────────────────────────── */
.opts { display: grid; gap: 10px; }
.opts.grid { grid-template-columns: 1fr 1fr; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 60px; padding: 14px 16px; border: 2px solid var(--line); border-radius: 12px;
  background: #fff; font-size: 16px; font-weight: 600; color: var(--ink); cursor: pointer;
  transition: border-color .15s, background .15s, transform .08s;
  -webkit-tap-highlight-color: transparent;
}
.opts.grid .opt { flex-direction: column; justify-content: center; text-align: center; gap: 8px; min-height: 108px; padding: 14px 8px; }
.opt svg { flex: none; width: 30px; height: 30px; color: var(--navy-2); }
.opts.grid .opt svg { width: 38px; height: 38px; }
.opt:hover { border-color: var(--navy-2); }
.opt:active { transform: scale(.98); }
.opt.on { border-color: var(--navy); background: var(--navy-soft); }
.opt:focus-visible, .btn:focus-visible, .back:focus-visible, input:focus-visible { outline: 3px solid #7fb0e0; outline-offset: 2px; }

/* ── Inputs / buttons ───────────────────────────── */
label.lbl { display: block; font-size: 14px; font-weight: 600; margin: 0 0 6px; }
label.lbl small { font-weight: 500; color: var(--muted); }
.field { margin-bottom: 14px; }
input.txt {
  width: 100%; height: 54px; padding: 0 14px; border: 2px solid var(--line); border-radius: 12px;
  background: #fff; font-size: 17px; transition: border-color .15s;
}
input.txt:focus { border-color: var(--navy-2); outline: none; }
input.txt.big { font-size: 22px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; text-align: center; }
input.code { font-size: 28px; letter-spacing: .4em; text-align: center; font-weight: 700; padding-left: .4em; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 56px; border: 0; border-radius: 12px; background: var(--navy); color: #fff;
  font-size: 17px; font-weight: 700; cursor: pointer; margin-top: 4px; transition: background .15s;
}
.btn:hover { background: var(--navy-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: none; color: var(--navy-2); min-height: 46px; font-weight: 600; font-size: 15px; }
.btn.ghost:hover { background: var(--navy-soft); }
.err { color: var(--red); font-size: 14px; margin: 8px 0 0; min-height: 0; }
.err:empty { display: none; }
.ok-box { display: flex; gap: 10px; align-items: flex-start; background: var(--green-soft); color: #11632f; border-radius: 12px; padding: 12px 14px; font-weight: 600; margin: 12px 0 4px; }
.ok-box svg { flex: none; width: 22px; height: 22px; margin-top: 1px; }
.spin { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* consent */
.consent { display: flex; gap: 12px; align-items: flex-start; font-size: 13.5px; line-height: 1.45; color: #34414f; background: var(--bg); border-radius: 12px; padding: 12px; margin: 4px 0 14px; cursor: pointer; }
.consent input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--navy); }

/* photos */
.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 12px; border: 2px dashed #b7c6d4; border-radius: 12px; background: #f8fafc; color: var(--navy-2); font-weight: 700; cursor: pointer; text-align: center; }
.drop small { color: var(--muted); font-weight: 500; }
.drop svg { width: 34px; height: 34px; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px; }
.thumbs:empty { display: none; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #e6ecf2; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.busy::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.55) center/22px no-repeat; }
.thumb.busy .spin { position: absolute; top: 50%; left: 50%; margin: -9px 0 0 -9px; border-color: rgba(15,42,67,.25); border-top-color: var(--navy); z-index: 1; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(15,42,67,.82); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }

/* done */
.done-icon { width: 60px; height: 60px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: grid; place-items: center; margin: 4px 0 14px; }
.done-icon svg { width: 32px; height: 32px; }
.summary { list-style: none; margin: 18px 0 0; padding: 0; border-top: 1px solid var(--line); }
.summary li { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.summary span { color: var(--muted); }
.summary b { text-align: right; font-weight: 600; }
.ref { font-size: 13px; color: var(--muted); margin: 14px 0 0; }

/* ── Trust + how it works (step 1) ──────────────── */
.trust { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 0; }
.trust div { background: #fff; border-radius: 12px; padding: 12px 8px; text-align: center; font-size: 13px; font-weight: 700; color: var(--navy); line-height: 1.3; box-shadow: 0 1px 2px rgba(15,42,67,.05); }
.trust svg { display: block; width: 24px; height: 24px; margin: 0 auto 6px; color: var(--green); }
.how { background: #fff; border-radius: var(--radius); padding: 18px; margin: 12px 0 0; box-shadow: 0 1px 2px rgba(15,42,67,.05); }
.how h3 { margin: 0 0 12px; font-size: 17px; color: var(--navy); }
.how ol { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.how li { counter-increment: s; position: relative; padding: 0 0 12px 40px; font-size: 14.5px; color: #34414f; }
.how li:last-child { padding-bottom: 0; }
.how li::before { content: counter(s); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center; }
.how li b { display: block; color: var(--ink); }

/* ── Footer ─────────────────────────────────────── */
.foot { text-align: center; padding: 22px 16px max(26px, env(safe-area-inset-bottom)); font-size: 13px; color: var(--muted); }
.foot nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-bottom: 8px; }
.foot a { color: var(--navy-2); }
.foot p { margin: 0; }

/* ── Legal / info pages ─────────────────────────── */
.doc { background: #fff; border-radius: var(--radius); padding: 22px 18px; box-shadow: 0 1px 2px rgba(15,42,67,.05); }
.doc h1 { font-size: 24px; color: var(--navy); margin: 0 0 4px; letter-spacing: -.01em; }
.doc h2 { font-size: 17px; color: var(--navy); margin: 22px 0 6px; }
.doc p, .doc li { font-size: 15px; color: #34414f; }
.doc ul { padding-left: 20px; }
.doc .muted { color: var(--muted); font-size: 13px; }

@media (min-width: 600px) {
  .wrap { padding-top: 28px; }
  .card { padding: 30px 28px 26px; }
  .hero h1 { font-size: 30px; }
  .doc { padding: 30px 28px; }
}

/* odd last option in a 2-column grid spans the row */
.opts.grid .opt:last-child:nth-child(odd) { grid-column: 1 / -1; flex-direction: row; min-height: 64px; }
.opts.grid .opt:last-child:nth-child(odd) svg { width: 30px; height: 30px; }

[hidden] { display: none !important; }
.back[hidden] { display: inline-block !important; visibility: hidden; }

/* ── Compact first screen: whole quiz card visible on load on phones ── */
@media (max-width: 599px) {
  .top { padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); }
  .top .logo img { height: 34px; width: auto; }
  .wrap { padding-top: 10px; }
  .progress { margin-bottom: 8px; }
  .progress-row { min-height: 20px; margin-bottom: 5px; }
  .card { padding: 16px 14px 14px; }
  .hero h1 { font-size: 22px; margin-bottom: 6px; }
  .hero p { font-size: 14px; margin-bottom: 10px; line-height: 1.4; }
  .pills { margin-bottom: 14px; }
  .pills li { font-size: 12px; padding: 4px 9px; }
  h2.q { font-size: 19px; }
  .hint { margin-bottom: 12px; font-size: 13.5px; }
  .opts { gap: 8px; }
  .opts.grid .opt { min-height: 84px; padding: 10px 6px; gap: 5px; font-size: 15px; }
  .opts.grid .opt svg { width: 30px; height: 30px; }
  .opt { min-height: 54px; padding: 12px 14px; }
}
@media (max-width: 599px) and (max-height: 620px) {
  .wrap { padding-top: 6px; }
  .progress-row { min-height: 18px; font-size: 12px; margin-bottom: 4px; }
  .hero h1 { font-size: 20px; }
  .pills { margin-bottom: 10px; }
  .hint { margin-bottom: 10px; }
  .opts.grid .opt { min-height: 76px; }
}

/* ── Repair problem step: 8 text buttons in two columns ── */
.opts.grid.compact .opt { min-height: 58px; padding: 10px 8px; font-size: 14.5px; line-height: 1.25; }
.opts.grid.compact .opt:last-child:nth-child(odd) { min-height: 58px; }

/* ── "Here's your message" ── */
textarea.msg { display: block; width: 100%; height: auto; min-height: 112px; padding: 12px 14px; font-size: 16px; line-height: 1.45; resize: none; overflow: hidden; font-family: inherit; }
.msg-left { margin: 6px 2px 0; font-size: 13px; color: #b45309; font-weight: 600; }
.msg-sign { margin: 8px 2px 4px; font-size: 14px; color: var(--muted); }
.linkbtn { background: none; border: 0; padding: 6px 2px; color: var(--navy-2); font-size: 14px; font-weight: 600; text-decoration: underline; cursor: pointer; }
.msg-consent { margin: 10px 2px 2px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.msg-preview { white-space: pre-wrap; word-break: break-word; font: 14px/1.45 Inter, system-ui, sans-serif; background: var(--bg); border-radius: 12px; padding: 12px 14px; margin: 6px 0 0; color: var(--ink); }
.msg-sent { white-space: pre-wrap; background: var(--bg); border-radius: 12px; padding: 12px 14px; margin: 14px 0 0; font-size: 15px; }

/* ── "Are you a garage door company?" block (homepage, under How it works) ── */
.pro { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 18px; margin: 12px 0 0; box-shadow: 0 1px 2px rgba(15,42,67,.05); }
.pro h3 { margin: 0 0 6px; font-size: 17px; color: #fff; }
.pro p { margin: 0 0 14px; font-size: 14.5px; color: #c9d6e3; }
.pro .pro-btn { display: flex; align-items: center; justify-content: center; text-decoration: none; background: var(--green); color: #fff; }
.pro .pro-btn:hover { background: #12873d; }
.pro .pro-more { display: block; text-align: center; margin-top: 10px; font-size: 14px; color: #b9c9d8; }
.nowrap { white-space: nowrap; }
