:root {
  --ink:      #0E1116;
  --surface:  #171B22;
  --surface2: #1E232C;
  --border:   #262C36;
  --text:     #E8EAED;
  --muted:    #8B93A0;
  --amber:    #F5A524;
  --amber-dim:#B8791A;
  --green:    #21C08B;
  --red:      #F0576B;

  --shadow: 0 18px 50px -20px rgba(0,0,0,.7);
  --r: 14px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 82% -8%, rgba(245,165,36,.10), transparent 60%),
    var(--ink);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---------- masthead ---------- */
.masthead {
  display: flex; align-items: center; gap: 18px;
  max-width: 940px; margin: 0 auto; padding: 34px 24px 22px;
}
.mark {
  width: 54px; height: 54px; flex: none;
  display: block;
  /* favicon.svg already draws the rounded amber square; drop-shadow follows its
     shape (box-shadow would render a square glow behind the transparent corners) */
  filter: drop-shadow(0 7px 12px rgba(245, 165, 36, .45));
}
.mast-text { flex: 1; }
.masthead h1 {
  font-family: "Archivo", sans-serif; font-weight: 900;
  font-size: clamp(26px, 4vw, 38px); letter-spacing: -1.2px;
  margin: 0; line-height: 1;
}
.masthead p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.mast-dt {
  text-align: right; flex: none;
  border-left: 1px solid var(--border); padding-left: 18px;
}
.dt-label { display: block; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.dt-value { font-family: "JetBrains Mono", monospace; font-size: 13px; color: var(--amber); font-weight: 600; }

/* ---------- banner ---------- */
.banner {
  max-width: 940px; margin: 0 auto 4px; padding: 12px 18px;
  border: 1px solid var(--amber-dim); background: rgba(245,165,36,.08);
  border-radius: 10px; color: #F2C879; font-size: 13.5px;
}
.banner code { font-family: "JetBrains Mono", monospace; color: var(--amber); }

/* ---------- steps ---------- */
main { max-width: 940px; margin: 0 auto; padding: 8px 24px 40px; }
.step {
  background: linear-gradient(180deg, var(--surface), var(--ink));
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 26px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  transition: opacity .3s ease, filter .3s ease;
}
.step.locked { opacity: .4; filter: saturate(.4); pointer-events: none; }
.step-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 20px; }
.step-head .idx {
  font-family: "JetBrains Mono", monospace; font-weight: 600;
  color: var(--amber); font-size: 13px; letter-spacing: .1em;
}
.step-head h2 {
  font-family: "Archivo", sans-serif; font-weight: 700;
  font-size: 20px; margin: 0; letter-spacing: -.4px;
}
.optional-note, .step-head .optional-note {
  margin-left: auto; color: var(--muted); font-size: 12px; font-style: italic;
}

/* ---------- capture ---------- */
.capture { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 22px; }
.dropzone {
  position: relative; overflow: hidden;
  border: 1.5px dashed var(--border); border-radius: 12px;
  background: var(--surface2);
  padding: 34px 22px; text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s, transform .1s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--amber); background: #20252F; outline: none; }
.dropzone.drag { border-color: var(--amber); background: #23282F; transform: scale(1.005); }
.qr-glyph { width: 40px; height: 40px; color: var(--amber); opacity: .9; margin-bottom: 8px; }
.drop-title { margin: 0; font-weight: 600; font-size: 15px; }
.drop-sub { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.scanline {
  position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
  box-shadow: 0 0 12px 2px rgba(245,165,36,.5);
  opacity: 0; animation: scan 2.6s ease-in-out infinite;
}
.dropzone:hover .scanline { opacity: 1; }
@keyframes scan { 0%,100% { top: 6%; } 50% { top: 94%; } }

.or { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; }
.camera-wrap { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.camera-stage { position: relative; width: 260px; }
.camera-stage.hidden { display: none; }
#video { width: 260px; height: 195px; object-fit: cover; border-radius: 10px; background: #000; display: block; }
.reticle {
  position: absolute; inset: 28px; border: 2px solid rgba(245,165,36,.8);
  border-radius: 10px; pointer-events: none;
}
.camera-stage .tiny { position: absolute; bottom: 8px; right: 8px; }

/* ---------- rewrite ---------- */
.rewrite-grid { display: grid; grid-template-columns: 1fr 300px; gap: 22px; align-items: start; }
.dt-diff { margin-bottom: 14px; }
.diff-row {
  display: flex; align-items: center; justify-content: space-between;
  font-family: "JetBrains Mono", monospace; font-size: 13px;
  padding: 9px 13px; border-radius: 9px; border: 1px solid var(--border);
}
.diff-row .k { color: var(--muted); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.diff-row.from { background: rgba(240,87,107,.06); }
.diff-row.from .v { color: var(--red); text-decoration: line-through; opacity: .85; }
.diff-row.to { background: rgba(33,192,139,.07); }
.diff-row.to .v { color: var(--green); font-weight: 600; }
.diff-arrow { text-align: center; color: var(--muted); font-size: 14px; line-height: 1.6; }

.payload {
  margin: 0; padding: 16px; border-radius: 10px;
  background: #0B0E12; border: 1px solid var(--border);
  font-family: "JetBrains Mono", monospace; font-size: 12.5px; line-height: 1.7;
  color: #C9D2DE; white-space: pre-wrap; word-break: break-all;
  max-height: 320px; overflow: auto;
}
.payload .hl { color: var(--green); font-weight: 600; background: rgba(33,192,139,.12); border-radius: 4px; padding: 0 2px; }
.payload .key { color: var(--amber); }

.qr-col { margin: 0; text-align: center; }
.qr-col img {
  width: 260px; height: 260px; border-radius: 12px;
  background: #fff; padding: 12px; border: 1px solid var(--border);
}
.qr-col figcaption { margin-top: 10px; color: var(--muted); font-size: 12px; }

/* ---------- form ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 13px; font-weight: 600; color: #C9D2DE; }
.field small { color: var(--muted); font-size: 12px; }
input[type=text] {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 11px 13px; font-size: 14px; font-family: inherit; width: 100%;
  transition: border-color .15s;
}
input[type=text]:focus { outline: none; border-color: var(--amber); }
input::placeholder { color: #5A626F; }

.photo-row { display: flex; align-items: center; gap: 14px; }
.photo-preview {
  width: 62px; height: 62px; border-radius: 12px; flex: none;
  background: var(--surface2) center/cover no-repeat;
  border: 1px solid var(--border);
}
.photo-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.geo-row { display: flex; gap: 8px; }
.geo-row input { flex: 1; }
.latlng { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }

/* ---------- buttons ---------- */
.btn {
  font-family: "Inter", sans-serif; font-weight: 600; font-size: 14px;
  border-radius: 10px; border: 1px solid var(--border);
  padding: 11px 18px; cursor: pointer; color: var(--text);
  background: var(--surface2); transition: transform .08s, border-color .15s, background .15s;
}
.btn:hover { border-color: var(--amber); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn.small { padding: 9px 14px; font-size: 13px; }
.btn.tiny { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn.ghost { background: transparent; }
.btn.primary {
  background: var(--amber); color: var(--ink); border-color: var(--amber);
  font-weight: 700; font-size: 15px; padding: 14px 26px;
  box-shadow: 0 10px 26px -10px rgba(245,165,36,.6);
}
.btn.primary:hover { background: #FFB534; }
.btn.primary:disabled { background: var(--surface2); color: var(--muted); border-color: var(--border); box-shadow: none; cursor: not-allowed; }

/* ---------- generate bar ---------- */
.step[data-step="4"] { background: none; border: none; box-shadow: none; padding: 4px; }
.generate-bar { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

/* ---------- messages ---------- */
.msg { font-size: 13.5px; margin: 12px 0 0; }
.msg.ok { color: var(--green); }
.msg.err { color: var(--red); }
.msg.info { color: var(--muted); }
.hidden { display: none !important; }

.foot {
  max-width: 940px; margin: 0 auto; padding: 8px 24px 40px;
  color: var(--muted); font-size: 12.5px; text-align: center;
}

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .capture { grid-template-columns: 1fr; }
  .or { text-align: center; }
  .rewrite-grid { grid-template-columns: 1fr; }
  .qr-col img, .camera-stage, #video { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .mast-dt { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .scanline { animation: none; }
  * { transition: none !important; }
}

/* ---------- public deployment additions ---------- */
.turnstile { margin-top: 4px; }
.turnstile:empty { display: none; }

.pass-link {
  display: inline-block; margin-top: 10px;
  color: var(--amber); font-weight: 600; font-size: 14px;
  text-decoration: underline; text-underline-offset: 3px;
}

/* QR preview is now inline SVG rather than an <img> */
.qr-col #qr-preview {
  width: 260px; height: 260px; border-radius: 12px;
  background: #fff; padding: 12px; border: 1px solid var(--border);
  display: inline-block; box-sizing: border-box;
}
.qr-col #qr-preview svg { width: 100%; height: 100%; display: block; }
@media (max-width: 760px) { .qr-col #qr-preview { width: 100%; } }

/* Address block carries lat/lng, so it spans the grid rather than leaving a gap */
.form-grid .field.span2 { grid-column: 1 / -1; }
@media (max-width: 760px) { .form-grid .field.span2 { grid-column: auto; } }