:root {
  --ink: #102033;
  --muted: #66758a;
  --line: #dce3eb;
  --surface: #ffffff;
  --soft: #f3f6f9;
  --accent: #1769e0;
  --accent-dark: #0d52b7;
  --ok: #117a4d;
  --warn: #a45a00;
  --danger: #b42318;
}

* { box-sizing: border-box; }
html { background: #edf2f7; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #eef3f8 0, #f7f9fb 34rem, #edf2f7 100%);
}
button, input, textarea { font: inherit; }
button { touch-action: manipulation; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 70px;
  padding: 12px max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(16, 32, 51, .96);
  color: white;
  box-shadow: 0 8px 25px rgba(16, 32, 51, .16);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 39px; height: 39px; border-radius: 12px;
  display: grid; place-items: center; background: white; color: var(--ink); font-weight: 900;
}
.brand strong, .brand span { display: block; }
.brand strong { font-size: 17px; }
.brand span { font-size: 12px; opacity: .72; margin-top: 2px; }
.test-pill { font-size: 11px; font-weight: 800; letter-spacing: .12em; padding: 7px 10px; border-radius: 999px; background: #28415e; }

.shell { width: min(760px, 100%); margin: 0 auto; padding: 28px 16px 48px; }
.intro { padding: 8px 2px 24px; }
.eyebrow, .step-label { color: var(--accent); font-weight: 800; letter-spacing: .1em; font-size: 11px; }
.intro h1 { font-size: clamp(30px, 8vw, 48px); line-height: 1.02; letter-spacing: -.04em; margin: 9px 0 13px; }
.intro p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }

.card {
  background: var(--surface); border: 1px solid rgba(16,32,51,.08); border-radius: 22px;
  padding: 20px; box-shadow: 0 16px 50px rgba(33, 53, 75, .09);
}
.step { display: none; }
.step.active { display: block; animation: reveal .22s ease; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } }
.card-head { display: flex; justify-content: space-between; gap: 15px; align-items: flex-start; margin-bottom: 20px; }
.card-head h2 { margin: 5px 0 0; font-size: 23px; line-height: 1.15; }

.field { display: block; margin-bottom: 17px; }
.field > span, .choice-block > span { display: block; font-weight: 780; font-size: 14px; margin-bottom: 7px; }
.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; line-height: 1.4; }
input, textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 13px; background: #fff; color: var(--ink);
  padding: 13px 14px; outline: none; transition: border-color .16s, box-shadow .16s;
}
input { min-height: 48px; }
textarea { resize: vertical; min-height: 180px; line-height: 1.5; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(23,105,224,.11); }
.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 4px rgba(180,35,24,.08) !important; }
.input-with-mic { display: grid; grid-template-columns: 1fr 49px; gap: 8px; }
.mini-mic { border: 0; border-radius: 13px; background: #e8f0fd; color: var(--accent); display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none; }
.mini-mic svg { width: 23px; height: 23px; fill: currentColor; }
.mini-mic.listening { background: #fee4e2; color: var(--danger); animation: pulse 1s infinite; }

.mic-button {
  width: 100%; border: 0; border-radius: 16px; padding: 13px 15px; margin: -4px 0 18px;
  display: flex; align-items: center; gap: 12px; text-align: left; color: white; background: var(--ink);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.mic-button strong, .mic-button small { display: block; }
.mic-button strong { font-size: 15px; }
.mic-button small { opacity: .72; font-size: 12px; margin-top: 2px; line-height: 1.35; }
.mic-icon { width: 43px; height: 43px; border-radius: 50%; background: white; color: var(--accent); display: grid; place-items: center; flex: 0 0 auto; }
.mic-icon svg { width: 23px; height: 23px; fill: currentColor; }
.mic-button.listening { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { filter: brightness(1.12); } }

.choice-block { margin: 2px 0 18px; }
.choice-block[hidden] { display: none; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.segmented button { border: 1.5px solid var(--line); border-radius: 13px; min-height: 49px; background: white; color: var(--ink); font-weight: 750; }
.segmented button.selected[data-outcome="ok"] { background: #e7f5ed; border-color: #6fc299; color: var(--ok); }
.segmented button.selected[data-outcome="problem"] { background: #fff1e6; border-color: #e4a15e; color: #8c4800; }
.activity-choice { margin-bottom: 22px; }
.activity-segmented button { min-height: 56px; padding: 11px 10px; display: flex; align-items: center; justify-content: center; text-align: center; }
.activity-segmented button strong { font-size: 14px; }
.activity-segmented button.selected { background: #eaf2fb; border-color: #5f94c7; color: #174d7c; }

.optional-note-toggle { margin: -2px 0 17px; padding: 4px 0; border: 0; background: transparent; color: var(--accent); font-size: 13px; font-weight: 760; text-align: left; }
.incident-suggestion { margin: -2px 0 18px; padding: 13px; border: 1px solid #efbd83; border-radius: 14px; background: #fff7ed; }
.incident-suggestion[hidden], #narrativeBlock[hidden], .optional-note-toggle[hidden] { display: none; }
.incident-suggestion strong, .incident-suggestion span { display: block; }
.incident-suggestion strong { color: #8c4800; font-size: 14px; }
.incident-suggestion span { margin-top: 4px; color: #75543a; font-size: 12px; line-height: 1.4; }
.incident-suggestion button { width: 100%; margin-top: 10px; background: #fff; }

.gps-card { display: grid; grid-template-columns: 38px 1fr; gap: 11px; border: 1px solid var(--line); border-radius: 16px; background: var(--soft); padding: 14px; margin-bottom: 17px; }
.gps-card > button { grid-column: 1 / -1; width: 100%; }
.gps-card.captured { background: #edf8f2; border-color: #a9d5bd; }
.gps-dot { width: 38px; height: 38px; border-radius: 50%; background: white; display: grid; place-items: center; font-size: 22px; }
.gps-card strong { font-size: 14px; }
.gps-card p { margin: 4px 0 2px; color: var(--ink); font-size: 13px; }
.gps-card small { color: var(--muted); font-size: 12px; line-height: 1.4; }

.photo-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 3px 0 11px; }
.photo-row strong, .photo-row span { display: block; }
.photo-row strong { font-size: 14px; }
.photo-row span { color: var(--muted); font-size: 12px; margin-top: 2px; }
.upload-label { display: inline-grid; place-items: center; }
.photo-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 10px; margin-bottom: 18px; }
.photo-item { min-width: 0; }
.photo-frame { aspect-ratio: 1; position: relative; border-radius: 12px; overflow: hidden; background: var(--soft); }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.photo-stamp { position: absolute; left: 0; right: 0; bottom: 0; padding: 5px 6px; color: white; background: transparent; font-size: 9px; line-height: 1.25; text-shadow: 0 1px 3px #000, 0 0 4px #000; }
.photo-frame button { position: absolute; right: 5px; top: 5px; width: 28px; height: 28px; border: 0; border-radius: 50%; color: white; background: rgba(0,0,0,.65); font-size: 19px; }
.photo-category-label { display: block; margin-top: 7px; }
.photo-category-label > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; }
.photo-category { width: 100%; min-height: 40px; padding: 8px 30px 8px 9px; border: 1.5px solid var(--line); border-radius: 10px; background: white; color: var(--ink); font-size: 12px; }

button, .upload-label { cursor: pointer; }
.primary-button, .secondary-button, .ghost-button {
  min-height: 48px; border-radius: 13px; padding: 11px 16px; font-weight: 790; border: 0;
}
.primary-button { background: var(--accent); color: white; }
.primary-button:hover { background: var(--accent-dark); }
.secondary-button { background: #e8eef5; color: var(--ink); }
.ghost-button { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button:disabled { opacity: .48; cursor: not-allowed; }
.actions { display: flex; gap: 9px; margin-top: 20px; }
.actions.right { justify-content: flex-end; }
.actions.between { justify-content: space-between; }

.badge { border-radius: 999px; padding: 7px 9px; font-size: 10px; font-weight: 900; letter-spacing: .06em; background: #edf0f4; color: #64748b; }
.badge.ready { background: #e7f5ed; color: var(--ok); }
.summary-box { border-radius: 16px; background: var(--soft); padding: 15px; margin-bottom: 16px; scroll-margin-top: 82px; }
.summary-box h3 { margin: 0 0 8px; font-size: 16px; }
.summary-box p { margin: 0; color: var(--muted); line-height: 1.48; font-size: 13px; }
.questions-area { display: grid; gap: 13px; }
.question-card { border: 1px solid var(--line); border-radius: 15px; padding: 13px; }
.question-card label { display: block; font-size: 13px; font-weight: 780; margin-bottom: 7px; }
.question-card textarea { min-height: 92px; }
.report-preview { border: 1px solid var(--line); border-radius: 17px; overflow: hidden; }
.report-preview header { background: var(--ink); color: white; padding: 17px; }
.report-preview header strong { display: block; font-size: 21px; }
.report-preview header span { opacity: .72; font-size: 12px; }
.report-section { padding: 15px 17px; border-top: 1px solid var(--line); }
.report-section:first-of-type { border-top: 0; }
.report-section h3 { margin: 0 0 10px; font-size: 12px; color: var(--accent); letter-spacing: .08em; }
.report-grid { display: grid; gap: 8px; }
.report-row { display: grid; grid-template-columns: minmax(110px, 35%) 1fr; gap: 12px; font-size: 13px; }
.report-row span { color: var(--muted); }
.report-text { white-space: pre-wrap; line-height: 1.55; font-size: 13px; }
.report-answers { display: grid; gap: 13px; }
.report-answer span, .report-answer strong { display: block; }
.report-answer span { margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.report-answer strong { color: var(--ink); font-size: 13px; line-height: 1.45; }
.report-photos { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.report-photo-card > strong { display: block; margin-bottom: 5px; color: var(--ink); font-size: 11px; }
.report-photo { position: relative; overflow: hidden; border-radius: 9px; }
.report-photo img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.report-photo span { position: absolute; left: 0; right: 0; bottom: 0; padding: 5px 6px; color: white; background: transparent; font-size: 8px; line-height: 1.35; text-shadow: 0 1px 3px #000, 0 0 4px #000; }
.pdf-buttons { margin-top: 17px; }
.pdf-buttons button { width: 100%; }
.status-line { min-height: 20px; color: var(--muted); font-size: 12px; line-height: 1.4; }

footer { width: min(760px, 100%); margin: 0 auto; padding: 0 18px 28px; display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
footer strong { color: var(--ink); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 50; width: min(90vw, 520px); border-radius: 12px; padding: 12px 14px; color: white; background: var(--ink); font-size: 13px; box-shadow: 0 12px 40px rgba(0,0,0,.25); transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 620px) {
  .card { padding: 28px; }
  .gps-card { grid-template-columns: 42px 1fr auto; align-items: center; }
  .gps-card > button { grid-column: auto; width: auto; }
}
