/* Built for a phone held outdoors: high contrast, large touch targets, one column.
   Green = go / done, yellow highlighter = "still needs an answer", red = wrong. */
:root {
  --paper: #fbfcfa;
  --sheet: #ffffff;
  --ink: #12251d;
  --muted: #55655d;
  --line: #cfd8d1;
  --green: #0e6b4f;
  --green-ink: #ffffff;
  --green-wash: #e3f1ea;
  --mark: #f2c230;
  --mark-wash: #fdf3cc;
  --red: #a8241c;
  --red-wash: #fbe7e4;
  --radius: 10px;
  --tap: 48px;
  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1714; --sheet: #17211d; --ink: #e9f0ec; --muted: #a3b2aa; --line: #2e3d36;
    --green: #4fc39a; --green-ink: #06231a; --green-wash: #17362b;
    --mark: #f2c230; --mark-wash: #3d3413; --red: #ff8f85; --red-wash: #3d1916;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.5 var(--font); }
h1, h2, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; }
.boot { padding: 40px 20px; color: var(--muted); }

/* buttons */
.btn { min-height: var(--tap); padding: 10px 18px; border: 2px solid var(--ink); border-radius: var(--radius); background: var(--sheet); font-weight: 700; cursor: pointer; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 15px; border-width: 1.5px; }
.btn.quiet { border-color: transparent; background: none; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.btn.wide { width: 100%; }

/* top bar */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--sheet); border-bottom: 1px solid var(--line); }
.bar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.bar-title strong, .bar-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-sub { color: var(--muted); font-size: 14px; }
.bar .back::before { content: "\2039\00a0"; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13.5px; font-weight: 700; white-space: nowrap; border: 1.5px solid currentColor; }
.pill.ok { color: var(--green); }
.pill.wait, .pill.busy { color: var(--ink); background: var(--mark-wash); border-color: var(--mark); }
.pill.down { color: var(--red); background: var(--red-wash); }

/* connect */
.connect { max-width: 440px; margin: 0 auto; padding: 48px 20px; }
.connect h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.01em; }
.lede { margin: 12px 0 28px; color: var(--muted); }
.connect-form { display: grid; gap: 6px; }
.connect-form label { font-weight: 700; margin-top: 10px; }
.form-error { color: var(--red); font-weight: 700; min-height: 1.5em; margin-top: 8px; }

/* inputs */
input[type=text], input[type=url], input[type=email], input[type=password], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; background: var(--sheet); border: 2px solid var(--ink); border-radius: var(--radius);
}
input.num { max-width: 220px; font-variant-numeric: tabular-nums; }
textarea { resize: vertical; }

/* households */
.home { max-width: 680px; margin: 0 auto; padding: 18px 14px 60px; display: grid; gap: 26px; }
.start { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 16px 18px; text-align: left; font-size: 20px; }
.start small { font-size: 13.5px; font-weight: 400; opacity: .9; }
.home h2 { font-size: 15px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-sub { color: var(--muted); }
.row-state { font-size: 14.5px; }
.row.queued .row-state { background: var(--mark-wash); align-self: flex-start; padding: 0 6px; border-radius: 4px; }
.row.rejected .row-state { color: var(--red); font-weight: 700; }
.row.sent .row-state { color: var(--green); }
.row-note { font-size: 14.5px; color: var(--muted); font-style: italic; }
.row-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.when { font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.empty { color: var(--muted); padding: 10px 0; }

/* section route: the one place the layout shows off — numbered stops along a line */
.route { position: sticky; top: 57px; z-index: 4; background: var(--paper); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.route::-webkit-scrollbar { display: none; }
.route ol { list-style: none; display: flex; align-items: center; gap: 0; margin: 0; padding: 10px 14px; width: max-content; }
.route li { display: flex; align-items: center; }
.route li + li::before { content: ""; width: 14px; height: 2px; background: var(--line); }
.stop { display: flex; align-items: center; gap: 8px; min-height: 36px; min-width: 36px; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 99px; }
.stop-n { display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 99px; border: 2px solid var(--line); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); background: var(--sheet); }
.stop.done .stop-n { border-color: var(--green); background: var(--green); color: var(--green-ink); }
.stop.issue .stop-n { border-color: var(--mark); background: var(--mark); color: #201a00; }
.stop.current { padding-right: 12px; background: var(--ink); }
.stop.current .stop-n { border-color: var(--ink); background: var(--paper); color: var(--ink); }
.stop-t { color: var(--paper); font-weight: 700; font-size: 14.5px; white-space: nowrap; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }

/* interview page */
.page { max-width: 680px; margin: 0 auto; padding: 20px 14px 120px; }
.page-title { display: flex; flex-direction: column; font-size: 26px; line-height: 1.2; letter-spacing: -.01em; margin-bottom: 22px; }
.page-num { font-size: 15px; font-weight: 700; color: var(--green); letter-spacing: 0; }
.group-title { font-size: 19px; margin: 30px 0 12px; }
.q { margin: 0 0 26px; }
.q-label { display: block; font-weight: 700; margin-bottom: 6px; }
.req { display: inline-block; margin-left: 8px; padding: 0 6px; background: var(--mark); color: #201a00; font-size: 12.5px; font-weight: 700; border-radius: 4px; vertical-align: 2px; }
.hint { color: var(--muted); font-size: 15px; margin-bottom: 8px; max-width: 62ch; }
.err { color: var(--red); font-weight: 700; margin-top: 6px; }
.q.has-error input[type=text], .q.has-error select, .q.has-error .choices { border-color: var(--red); }
.q.has-error { border-left: 4px solid var(--red); padding-left: 12px; margin-left: -16px; }
.note { margin-bottom: 20px; }
.note-body p { max-width: 62ch; margin-bottom: 8px; }
.note-body .note-head { font-weight: 700; margin-bottom: 2px; }

.choices { display: grid; border: 2px solid var(--ink); border-radius: var(--radius); overflow: hidden; background: var(--sheet); }
.choices.dense { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.choice { display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.choice:last-child { border-bottom: 0; }
.choice input { width: 22px; height: 22px; flex: none; accent-color: var(--green); margin: 0; }
.choice:has(input:checked) { background: var(--green-wash); font-weight: 700; }
.choice:has(input:focus-visible) { outline: 3px solid var(--mark); outline-offset: -3px; }

.pair { display: flex; gap: 8px; align-items: center; }
.pair input { flex: 1; min-width: 0; }
.geo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.geo-value { font-variant-numeric: tabular-nums; }
.geo-manual { margin-top: 8px; }
.geo-manual summary { cursor: pointer; color: var(--muted); padding: 6px 0; }

.repeat { margin: 0 0 26px; }
.card { background: var(--sheet); border: 1px solid var(--line); border-left: 5px solid var(--green); border-radius: var(--radius); padding: 14px 14px 0; margin-bottom: 14px; }
.card .q.has-error { margin-left: 0; }
.card-count { font-size: 14px; font-weight: 700; color: var(--green); margin-bottom: 10px; }
.repeat-actions { display: flex; gap: 8px; }

.actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; gap: 8px; justify-content: center; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--sheet); border-top: 1px solid var(--line); }
.actions .btn { flex: 1; max-width: 220px; padding-left: 8px; padding-right: 8px; }

.review { display: grid; gap: 18px; }
.review-lede { font-size: 19px; }
.summary { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 700; word-break: break-word; }

.sheet { width: min(480px, 94vw); border: 2px solid var(--ink); border-radius: 14px; padding: 20px; background: var(--sheet); color: var(--ink); }
.sheet::backdrop { background: rgba(10, 20, 15, .55); }
.sheet h2 { font-size: 22px; margin-bottom: 6px; }
.sheet label { display: block; font-weight: 700; margin: 12px 0 6px; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px); max-width: min(520px, 92vw); padding: 10px 16px; background: var(--ink); color: var(--paper); border-radius: var(--radius); font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 20; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
@media (max-width: 420px) { body { font-size: 16px; } .bar .pill.ok { font-size: 0; padding: 0; width: 14px; height: 14px; background: var(--green); } .row { align-items: flex-start; flex-direction: column; } .row-actions { justify-content: flex-start; } }

/* fully answered households, and the test-data tool */
.ready { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px; border: 2px solid var(--green); border-radius: var(--radius); background: var(--green-wash); }
.ready p { flex: 1; min-width: 200px; }
.testdata { padding-top: 18px; border-top: 2px dashed var(--line); }
.testdata form { display: grid; gap: 12px; margin-top: 10px; }
.test-fields { display: grid; grid-template-columns: max-content 1fr; gap: 8px 12px; align-items: center; }
.test-fields label { font-weight: 700; }
.testdata .btn { justify-self: start; }
.testdata .choices .hint { margin: 0; font-weight: 400; }
.clear-device { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.clear-device .hint { margin: 0; }

/* GPS capture */
.geo { gap: 8px; }
.geo-live { margin-top: 8px; max-width: 62ch; font-variant-numeric: tabular-nums; }
.geo-value { margin-top: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.geo-far { margin-top: 6px; padding: 8px 10px; background: var(--mark-wash); border-left: 4px solid var(--mark); border-radius: 4px; max-width: 62ch; }

/* keeping drafts safe on a phone */
.storage-warn { padding: 14px; border: 2px solid var(--mark); background: var(--mark-wash); border-radius: var(--radius); }
.storage-warn p { margin-top: 6px; }
