/*
 * Field tool, not a dashboard.
 *
 * Dark and high contrast because this is used outdoors in Takoradi sun with
 * screen brightness up and battery draining. Touch targets are deliberately
 * large — the person using it is standing at the roadside, probably one-handed,
 * possibly on a motorbike seat.
 */
:root {
  --bg: #0f1720;
  --surface: #172230;
  --raised: #1f2c3d;
  --border: #2b3a4d;
  --text: #eaf1f8;
  --muted: #93a5b8;
  --brand: #16a394;
  --brand-dim: #0d6b61;
  --accent: #f0a020;
  --danger: #e2564a;
  --ok: #34c38f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.who { font-size: 14px; color: var(--muted); }
.queue { font-size: 13px; color: var(--accent); font-variant-numeric: tabular-nums; }

main { padding: 16px; max-width: 620px; margin: 0 auto; }

/* ── GPS fix ─────────────────────────────────────────────────────────────── */
.fix {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 14px;
}
.fix-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}
/* Accuracy is the difference between a usable capture and a wrong one, so it
   is shown as a colour rather than buried in text. */
.fix-dot.good { background: var(--ok); box-shadow: 0 0 0 4px rgba(52,195,143,.18); }
.fix-dot.fair { background: var(--accent); box-shadow: 0 0 0 4px rgba(240,160,32,.16); }
.fix-dot.poor { background: var(--danger); box-shadow: 0 0 0 4px rgba(226,86,74,.16); }
.fix-text { display: flex; flex-direction: column; }
.fix-text strong { font-size: 15px; font-weight: 600; }
.fix-text span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── nearby ──────────────────────────────────────────────────────────────── */
.nearby { margin-bottom: 16px; }
.nearby h2, .recent h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 0 0 8px; font-weight: 600;
}
.nearby ul, .recent ul { list-style: none; margin: 0; padding: 0; }
.nearby li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.nearby .row { display: flex; align-items: baseline; gap: 8px; }
.nearby .nm { font-weight: 600; }
.nearby .meta { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }
.nearby .acts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.nearby button {
  font: inherit; font-size: 13px;
  background: var(--raised); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; cursor: pointer;
}
.nearby button:active { background: var(--brand-dim); }

/* ── form ────────────────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px;
}
.field em { font-style: normal; opacity: .7; }
input[type=text], input[type=email], input[type=password] {
  width: 100%; font: inherit; font-size: 17px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 13px 14px;
}
input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  font: inherit; font-size: 15px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 10px 15px; cursor: pointer;
}
.chips button[aria-pressed=true] {
  background: var(--brand); border-color: var(--brand); color: #04120f; font-weight: 600;
}

.capture {
  width: 100%; font: inherit; font-size: 19px; font-weight: 700;
  background: var(--brand); color: #04120f;
  border: 0; border-radius: 14px; padding: 20px;
  cursor: pointer; margin-top: 4px;
}
.capture:disabled { background: var(--raised); color: var(--muted); cursor: not-allowed; }
.capture.correcting { background: var(--accent); }
.capture.removing { background: var(--danger); color: #fff; }

.hint { font-size: 13px; color: var(--muted); min-height: 1.4em; margin: 10px 2px 18px; }

/* ── session list ────────────────────────────────────────────────────────── */
.recent li {
  display: flex; gap: 8px; align-items: baseline;
  padding: 8px 2px; border-bottom: 1px solid var(--border); font-size: 14px;
}
.recent .k {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
}
.recent .t { margin-left: auto; color: var(--muted); font-size: 12px; }

/* ── sign in ─────────────────────────────────────────────────────────────── */
.signin { max-width: 380px; margin: 12vh auto; padding: 0 20px; }
.signin h1 { font-size: 24px; margin: 0 0 6px; }
.signin p { color: var(--muted); margin: 0 0 18px; }
.signin input { margin-bottom: 10px; }
.signin button {
  width: 100%; font: inherit; font-size: 17px; font-weight: 600;
  background: var(--brand); color: #04120f;
  border: 0; border-radius: 10px; padding: 15px; cursor: pointer;
}
.err { color: var(--danger); font-size: 14px; min-height: 1.4em; }

/* ── toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--raised); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 11px 20px; font-size: 15px; font-weight: 600;
  box-shadow: 0 8px 28px rgba(0,0,0,.45); z-index: 10;
}
.toast.ok { border-color: var(--ok); }
.toast.bad { border-color: var(--danger); }

/* ── session list header and export tools ────────────────────────────────── */
.recent-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 8px;
}
.recent-head h2 { margin: 0; }
.tools { display: flex; gap: 8px; }
.tools button {
  font: inherit; font-size: 14px; font-weight: 600;
  background: var(--brand); color: #04120f;
  border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer;
}
.tools button.ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); font-weight: 400;
}

/* These captures exist in one browser and nowhere else. The warning grows
   louder as more work accumulates behind it. */
.warn { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.warn.loud {
  color: var(--accent); font-weight: 600;
  border: 1px solid var(--accent); border-radius: 8px; padding: 9px 11px;
}

.cancel {
  width: 100%; font: inherit; font-size: 15px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; margin-top: 10px; cursor: pointer;
}

/* Licence attribution. Required wherever the nearby index is published — OSM
   is ODbL and GeoNames is CC-BY, and both oblige us to say so. */
.attrib {
  margin: 28px 0 8px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
.attrib a { color: var(--muted); }

/* ── iOS ─────────────────────────────────────────────────────────────────── */
/* Safari zooms the page when a focused input is under 16px. Every input here
   is 17px for that reason alone — a zoom mid-capture loses your place. */
input, button, textarea { font-family: inherit; }

/* Safari applies its own rounding and inner shadow to inputs and buttons. */
input, button {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 10px;
}

/* Stops the grey flash on every tap, which on a page of chips looks broken. */
* { -webkit-tap-highlight-color: transparent; }

/* Added to the home screen there is no browser chrome, so the header has to
   clear the notch itself. */
.bar { padding-top: max(12px, env(safe-area-inset-top)); }
body { padding-bottom: max(16px, env(safe-area-inset-bottom)); }

/* The capture button is the one target that matters. Keep it reachable with a
   thumb rather than stranded at the top of a long form. */
@media (min-height: 700px) {
  .capture { padding: 22px; font-size: 20px; }
}

/* ── location permission ─────────────────────────────────────────────────── */
/* This is the first thing that has to work, so it gets the same weight as the
   capture button rather than looking like a secondary action. */
.locate {
  width: 100%; font: inherit; font-size: 18px; font-weight: 700;
  background: var(--accent); color: #1a1200;
  border: 0; border-radius: 12px; padding: 17px;
  margin: 0 0 14px; cursor: pointer;
}
.locate:active { filter: brightness(.92); }

/* Shown only once Safari has actually refused. Recovery is otherwise
   undiscoverable from inside the page — Safari never asks a second time. */
.help {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}
.help strong { display: block; margin-bottom: 6px; color: var(--accent); }
.help p { margin: 8px 0; color: var(--muted); }
.help ol { margin: 8px 0 8px 20px; padding: 0; color: var(--text); }
.help li { margin-bottom: 5px; }
.help b { color: var(--text); }
