:root {
  --asphalt: #191815;
  --asphalt-2: #24221d;
  --paper: #f4efe3;
  --paper-2: #ebe4d2;
  --ink: #1d1b18;
  --ink-soft: #5b554a;
  --line: #d8cfbb;
  --stamp: #c2410c;
  --stamp-soft: #fbe3d6;
  --ok: #2f6b3a;
  --ok-soft: #dcebd9;
  --warn: #9a6512;
  --warn-soft: #f6e6c3;
  --curb: #f2c230;
  --radius: 10px;
  --body: "Atkinson Hyperlegible", "Segoe UI", sans-serif;
  --display: Fraunces, Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 10% -10%, #2d2a24 0%, transparent 60%),
    repeating-linear-gradient(115deg, rgba(255,255,255,.012) 0 2px, transparent 2px 6px),
    var(--asphalt);
  color: var(--paper);
  font: 17px/1.5 var(--body);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.08; margin: 0 0 .4em; letter-spacing: -.01em; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; margin-top: 1.8rem; }

/* Header */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(25,24,21,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #2f2c26;
}
.brand { font-family: var(--mono); font-weight: 600; font-size: .95rem; text-decoration: none; letter-spacing: .02em; }
.brand span { color: var(--curb); }
.steps { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.steps li {
  width: 22px; height: 6px; border-radius: 3px; background: #3a362f;
  font-size: 0; overflow: hidden; transition: background .3s;
}
.steps li.done { background: #8a8170; }
.steps li.current { background: var(--curb); }

main { max-width: 560px; margin: 0 auto; padding: 20px 16px 40px; }
.view { animation: enter .45s cubic-bezier(.2,.8,.2,1) both; }
@keyframes enter { from { opacity: 0; transform: translateY(14px); } }

/* Home */
.hero { padding: 18px 0 10px; }
.kicker { font-family: var(--mono); font-size: .78rem; letter-spacing: .16em; text-transform: uppercase; color: var(--curb); margin: 0 0 12px; }
.hero h1 { font-size: clamp(2.3rem, 10vw, 3.2rem); }
.lede { color: #d9d2c2; margin: 0 0 24px; }
.how { list-style: none; counter-reset: how; padding: 0; margin: 34px 0 0; display: grid; gap: 2px; }
.how li {
  counter-increment: how;
  display: grid; grid-template-columns: 38px 1fr; column-gap: 8px;
  padding: 14px 0; border-top: 1px dashed #3d392f;
  animation: enter .5s both; animation-delay: calc(var(--i, 0) * 80ms + 150ms);
}
.how li:nth-child(1) { --i: 1; } .how li:nth-child(2) { --i: 2; } .how li:nth-child(3) { --i: 3; } .how li:nth-child(4) { --i: 4; }
.how li::before { content: "0" counter(how); grid-row: span 2; font-family: var(--mono); color: var(--curb); padding-top: 2px; }
.how b { font-family: var(--display); font-size: 1.15rem; }
.how span { color: #bdb5a4; font-size: .95rem; }
.facts { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 26px 0; }
.facts div { background: var(--asphalt-2); border: 1px solid #34302a; border-radius: var(--radius); padding: 12px 14px; display: flex; gap: 12px; align-items: baseline; }
.facts strong { font-family: var(--mono); color: var(--curb); min-width: 76px; }
.facts span { color: #cfc7b6; font-size: .93rem; }
.disclaimer { color: #8f8777; font-size: .82rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 52px; padding: 12px 18px; margin: 6px 0;
  border: 2px solid var(--paper); border-radius: var(--radius);
  background: transparent; color: var(--paper);
  font: 700 1.02rem/1.2 var(--body); text-decoration: none; cursor: pointer;
  transition: transform .12s, background .2s, opacity .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--curb); border-color: var(--curb); color: var(--ink); }
.btn.big { min-height: 64px; font-size: 1.15rem; }
.btn.ghost { border-color: #4a453b; color: #d9d2c2; }
.btn[disabled], .btn.busy { opacity: .5; pointer-events: none; }
.btn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.link { background: none; border: 0; color: #a49b89; font: inherit; font-size: .9rem; text-decoration: underline; padding: 12px 0; cursor: pointer; }
.link.danger { color: #e39c7b; margin-top: 28px; }
.actions { margin-top: 18px; }
.fine-print { font-size: .82rem; color: #a49b89; margin: 8px 0; }

.sub { color: #c9c1b0; margin: 0 0 16px; }

/* Paper surfaces */
.stub, .shots li, .finding, .ground, .q, .letter, .faces label {
  background: var(--paper); color: var(--ink); border-radius: var(--radius);
}
.stub { padding: 18px 16px; position: relative; }
.stub label, .own { display: block; font-family: var(--mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 12px; }
.own { color: #c9c1b0; margin-top: 18px; }
.own span { text-transform: none; letter-spacing: 0; }
.stub input, .own textarea, .own input, .q textarea, .q input {
  display: block; width: 100%; margin-top: 4px; padding: 11px 12px;
  font: 500 1rem var(--mono); color: var(--ink); text-transform: none; letter-spacing: 0;
  background: #fffdf7; border: 1.5px solid var(--line); border-radius: 8px; outline: none;
  -webkit-appearance: none; appearance: none; min-height: 46px;
}
.own textarea, .own input { background: var(--paper); }
.stub input:focus, .own textarea:focus, .q textarea:focus, .q input:focus { border-color: var(--ink); }
.stub input.low { border-color: var(--warn); background: var(--warn-soft); }
.stub input.missing { border-style: dashed; }
.stub label.low::after { content: " · check this"; color: var(--warn); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row.three { grid-template-columns: 1.4fr .7fr 1fr; }
.ticket-thumb { display: block; width: 100%; max-height: 180px; object-fit: cover; object-position: top; border-radius: var(--radius); margin-bottom: 12px; opacity: .9; }
.deadline { font-family: var(--mono); font-size: .9rem; background: var(--stamp-soft); color: var(--stamp); border-radius: 8px; padding: 10px 12px; margin: 6px 0 12px; }

.scan-wait { display: flex; align-items: center; gap: 10px; font-family: var(--mono); color: var(--curb); margin: 10px 0 16px; }
.spinner { width: 18px; height: 18px; border: 3px solid #4a453b; border-top-color: var(--curb); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Map + blockfaces */
.map-wrap { background: #22201b; border: 1px solid #34302a; border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.map { display: block; width: 100%; aspect-ratio: 4 / 3; touch-action: manipulation; }
.map .street { stroke: #57513f; stroke-width: 9; stroke-linecap: round; fill: none; }
.map .face { stroke: #8a8170; stroke-width: 4; stroke-linecap: round; fill: none; }
.map .face.on { stroke: var(--curb); stroke-width: 6; }
.map .hit { stroke: transparent; stroke-width: 22; fill: none; cursor: pointer; }
.map text { fill: #bdb5a4; font: 600 10px var(--mono); paint-order: stroke; stroke: #22201b; stroke-width: 3px; }
.map .car { fill: #6fb1ff; stroke: #fff; stroke-width: 2; }
.map .addr { fill: var(--stamp); stroke: #fff; stroke-width: 1.5; }
.faces { display: grid; gap: 8px; }
.faces label { display: grid; grid-template-columns: 26px 1fr; gap: 6px 10px; padding: 12px 14px; cursor: pointer; border: 2px solid transparent; transition: border-color .2s; }
.faces label:has(input:checked) { border-color: var(--curb); box-shadow: 0 0 0 3px rgba(242,194,48,.25); }
.faces input {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; margin: 2px 0 0; grid-row: span 3;
  border: 2px solid var(--ink); border-radius: 50%; background: #fffdf7; transition: box-shadow .15s;
}
.faces input:checked { box-shadow: inset 0 0 0 5px #fffdf7; background: var(--ink); }
.faces input:focus-visible { outline: 3px solid var(--curb); outline-offset: 2px; }
.faces b { font-family: var(--display); font-size: 1.05rem; }
.faces small { font-family: var(--mono); font-size: .78rem; color: var(--ink-soft); }
.faces .tag { grid-column: 2; font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ok); }

/* Scene shots */
.shots { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.shots li { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 12px 12px 12px 16px; }
.shots b { display: block; font-family: var(--display); font-size: 1.05rem; }
.shots small { color: var(--ink-soft); font-size: .88rem; }
.shots .take { width: auto; min-height: 48px; margin: 0; border-color: var(--ink); color: var(--ink); padding: 8px 14px; }
.shots .take svg { width: 22px; height: 22px; }
.shots li.done { background: var(--ok-soft); }
.shots .thumbs { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { position: relative; width: 74px; height: 74px; border-radius: 8px; overflow: hidden; background: var(--paper-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 3px; right: 3px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(29,27,24,.8); color: #fff; font-size: 15px; line-height: 1; cursor: pointer; }
.thumb.uploading::after { content: ""; position: absolute; inset: 0; background: rgba(244,239,227,.6) linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent) 0 0 / 200% 100%; animation: shimmer 1s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.more-photo { margin-top: 14px; color: #c9c1b0; }
.more-photo summary { cursor: pointer; padding: 10px 0; }
.kind-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.kind-picker button { border: 1px solid #4a453b; background: var(--asphalt-2); color: var(--paper); border-radius: 999px; padding: 9px 14px; font: inherit; font-size: .9rem; cursor: pointer; }

/* Questions */
.q { padding: 16px; margin: 0 0 10px; border: 0; min-width: 0; }
.q p { margin: 0 0 4px; font-weight: 700; }
.q .why { font-size: .88rem; color: var(--ink-soft); margin: 0 0 12px; font-weight: 400; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices label { flex: 1 1 auto; position: relative; }
.choices input { position: absolute; opacity: 0; pointer-events: none; }
.choices span {
  display: block; text-align: center; padding: 11px 12px; border-radius: 8px;
  border: 1.5px solid var(--line); background: #fffdf7; font-weight: 700; cursor: pointer; transition: all .15s;
}
.choices input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.choices input:focus-visible + span { outline: 3px solid var(--curb); }
.q .note { margin-top: 12px; font-size: .85rem; color: var(--ink-soft); }
.q .hint-ev { margin-top: 8px; font-size: .85rem; color: var(--warn); }

/* Findings */
.findings { display: grid; gap: 10px; }
.finding { padding: 16px; position: relative; overflow: hidden; }
.finding h4 { margin: 0 0 6px; font-family: var(--display); font-size: 1.12rem; padding-right: 96px; }
.finding p { margin: 0; font-size: .95rem; }
.finding details { margin-top: 10px; font-size: .84rem; color: var(--ink-soft); }
.finding details summary { cursor: pointer; font-family: var(--mono); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; }
.finding details ul { padding-left: 18px; margin: 8px 0; }
.finding details a { word-break: break-all; }
.stamp {
  position: absolute; top: 14px; right: 12px;
  font: 600 .66rem/1 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  border: 2px solid currentColor; padding: 5px 7px; border-radius: 4px; transform: rotate(-5deg);
  animation: stamp .45s cubic-bezier(.3,1.6,.5,1) both; animation-delay: calc(var(--i, 0) * 120ms + 200ms);
}
@keyframes stamp { from { opacity: 0; transform: rotate(-5deg) scale(1.8); } }
.stamp.supports { color: var(--ok); }
.stamp.contradicts { color: var(--stamp); }
.stamp.unknown { color: var(--warn); }
.stamp.neutral { color: var(--ink-soft); }
.finding.supports { box-shadow: inset 5px 0 0 var(--ok); }
.finding.contradicts { box-shadow: inset 5px 0 0 var(--stamp); }

.grounds { display: grid; gap: 8px; }
.ground { padding: 14px 16px; display: grid; grid-template-columns: 26px 1fr; gap: 4px 10px; }
.ground input { width: 20px; height: 20px; margin: 3px 0 0; accent-color: var(--ok); }
.ground b { font-size: 1rem; }
.ground small { grid-column: 2; color: var(--ink-soft); font-size: .86rem; }
.ground .missing { grid-column: 2; color: var(--warn); font-size: .86rem; }
.ground.against, .ground.option { grid-template-columns: 1fr; background: var(--paper-2); }
.ground.against small, .ground.option small, .ground.against .missing { grid-column: 1; }
.group-label { font-family: var(--mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: #a49b89; margin: 14px 0 2px; }

/* Package */
.letter { padding: 20px 18px; font-size: .92rem; white-space: pre-wrap; font-family: var(--body); line-height: 1.55; margin: 0 0 14px; }
.letter.preview { position: relative; max-height: 360px; overflow: hidden; }
.letter.preview::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 150px; background: linear-gradient(transparent, var(--paper) 80%); }
.letter .blur { filter: blur(4px); user-select: none; }
.contents { padding-left: 20px; color: #d9d2c2; }
.contents li { margin: 4px 0; }
.downloads { display: grid; gap: 0; }
.filing { padding-left: 20px; color: #d9d2c2; }
.filing li { margin: 8px 0; }
.check { display: flex; gap: 10px; align-items: center; margin: 16px 0; font-weight: 700; }
.check input { width: 22px; height: 22px; accent-color: var(--curb); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 10;
  max-width: 528px; margin: 0 auto; padding: 14px 16px; border-radius: var(--radius);
  background: var(--paper); color: var(--ink); font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,.45);
  animation: enter .3s both;
}
.toast.error { background: var(--stamp); color: #fff; }

.foot { max-width: 560px; margin: 0 auto; padding: 20px 16px 40px; font-size: .82rem; color: #8f8777; border-top: 1px dashed #34302a; }
.foot p { margin: 6px 0 0; }

@media (min-width: 720px) {
  main { padding-top: 40px; }
  .facts { grid-template-columns: repeat(3, 1fr); }
  .facts div { flex-direction: column; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
