/* ─────────────────────────────────────────────────────────────────────────────
   Design system.
   Built thumb-first: every primary control sits in the lower third of the screen,
   every target is at least 44px, and nothing essential depends on a pinch gesture.
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  --ink:        #05080C;
  --surface:    #0C121A;
  --raised:     #141D28;
  --raised-2:   #1C2836;
  --line:       #22303F;
  --line-soft:  #18222E;

  --text:       #EDF3F8;
  --text-dim:   #93A6B8;
  --text-faint: #5D7186;

  /* Status. Chosen to stay separable under deuteranopia and protanopia, and always
     paired with a distinct glyph — colour is never the only carrier of meaning. */
  --works:      #17D6A3;
  --works-bg:   rgba(23, 214, 163, .13);
  --patchy:     #F5A524;
  --patchy-bg:  rgba(245, 165, 36, .13);
  --broken:     #FF5C7A;
  --broken-bg:  rgba(255, 92, 122, .13);
  --unknown:    #7E93A8;
  --unknown-bg: rgba(126, 147, 168, .12);

  --accent:     #4CC9F0;
  --accent-2:   #7B61FF;

  --r-sm: 10px; --r: 16px; --r-lg: 22px; --r-xl: 28px;
  --pad: 16px;
  --sheet-shadow: 0 -18px 48px rgba(0,0,0,.55);
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body {
  font-family: var(--font);
  background: var(--ink);
  color: var(--text);
  font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }

/* ── App frame ─────────────────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100dvh; }

.topbar {
  padding: calc(var(--safe-t) + 10px) var(--pad) 10px;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, var(--ink) 60%, transparent);
  position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 680; letter-spacing: -.02em; font-size: 17px; }
.brand .mark {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #06121A; font-weight: 900; font-size: 15px;
}

.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--raised); border: 1px solid var(--line-soft);
  border-radius: 999px; padding: 0 14px; height: 42px;
}
.search input { flex: 1; background: none; border: 0; outline: 0; font-size: 15px; min-width: 0; }
.search input::placeholder { color: var(--text-faint); }

/* ── Map ───────────────────────────────────────────────────────────────────── */
#map { position: absolute; inset: 0; }
.mapwrap { position: relative; flex: none; height: 38dvh; transition: height .28s cubic-bezier(.4,0,.2,1); }
.mapwrap.tall { height: 100dvh; }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* Deliberately large, thumb-reachable zoom controls: a driver should never be
   forced into a two-finger gesture to answer "what is near me". */
.mapctl { position: absolute; right: 10px; bottom: 12px; display: flex; flex-direction: column; gap: 8px; z-index: 5; }
.mapctl button {
  width: 46px; height: 46px; border-radius: 14px;
  background: rgba(12,18,26,.86); backdrop-filter: blur(14px);
  border: 1px solid var(--line); color: var(--text);
  display: grid; place-items: center; font-size: 20px; font-weight: 600;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
.mapctl button:active { background: var(--raised-2); transform: scale(.94); }

/* ── The range dial: the primary way to explore, instead of pinch-zoom ─────── */
.dial {
  display: flex; gap: 6px; padding: 10px var(--pad) 6px;
  overflow-x: auto; scrollbar-width: none;
}
.dial::-webkit-scrollbar { display: none; }
.dial button {
  flex: none; padding: 9px 15px; border-radius: 999px;
  background: var(--raised); border: 1px solid var(--line-soft);
  color: var(--text-dim); font-size: 13.5px; font-weight: 560; white-space: nowrap;
}
.dial button[aria-pressed="true"] {
  background: var(--text); color: var(--ink); border-color: var(--text); font-weight: 640;
}
.dial .sep { width: 1px; background: var(--line); margin: 6px 4px; flex: none; }

/* ── Result list ───────────────────────────────────────────────────────────── */
.sheet {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sheet-shadow);
  padding-bottom: calc(84px + var(--safe-b));
  position: relative; z-index: 10;
}
.grabber { width: 38px; height: 4px; border-radius: 3px; background: var(--line); margin: 9px auto 4px; }

.listhead {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 6px var(--pad) 10px;
}
.listhead h2 { margin: 0; font-size: 15px; font-weight: 640; letter-spacing: -.01em; }
.listhead .meta { font-size: 12.5px; color: var(--text-faint); }

.card {
  display: grid; grid-template-columns: 46px 1fr auto; gap: 12px;
  align-items: center; padding: 13px var(--pad);
  border-top: 1px solid var(--line-soft);
  width: 100%; text-align: left;
}
.card:active { background: var(--raised); }
.card .glyph {
  width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; letter-spacing: -.02em;
}
.card .title { font-weight: 610; font-size: 15px; letter-spacing: -.01em; }
.card .sub { font-size: 12.5px; color: var(--text-faint); margin-top: 2px;
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card .dist { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-dim); text-align: right; font-weight: 560; }
.card .dist small { display: block; font-size: 11px; color: var(--text-faint); font-weight: 460; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 620;
  letter-spacing: .01em; line-height: 1.5;
}
.pill.works   { background: var(--works-bg);   color: var(--works); }
.pill.patchy  { background: var(--patchy-bg);  color: var(--patchy); }
.pill.broken  { background: var(--broken-bg);  color: var(--broken); }
.pill.unknown { background: var(--unknown-bg); color: var(--unknown); }
.pill.kw      { background: rgba(76,201,240,.13); color: var(--accent); font-variant-numeric: tabular-nums; }

.g-works   { background: var(--works-bg);   color: var(--works); }
.g-patchy  { background: var(--patchy-bg);  color: var(--patchy); }
.g-broken  { background: var(--broken-bg);  color: var(--broken); }
.g-unknown { background: var(--unknown-bg); color: var(--unknown); }

/* ── Bottom tab bar ────────────────────────────────────────────────────────── */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(8,12,18,.92); backdrop-filter: blur(20px) saturate(160%);
  border-top: 1px solid var(--line-soft);
  padding-bottom: var(--safe-b);
}
.tabs button {
  padding: 9px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-faint); font-size: 10.5px; font-weight: 560; letter-spacing: .01em;
}
.tabs button[aria-selected="true"] { color: var(--text); }
.tabs svg { width: 22px; height: 22px; }

/* ── Detail sheet ──────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end;
  background: rgba(2,5,9,.62); backdrop-filter: blur(3px);
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0 } }
.modal .panel {
  width: 100%; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sheet-shadow);
  padding-bottom: calc(20px + var(--safe-b));
  animation: rise .26s cubic-bezier(.32,.72,0,1);
}
@keyframes rise { from { transform: translateY(6%) } }
@media (min-width: 720px) {
  .modal { align-items: center; justify-content: center; }
  .modal .panel { max-width: 560px; border-radius: var(--r-lg); max-height: 86dvh; }
}

.detail-head { padding: 4px var(--pad) 14px; }
.detail-head h1 { font-size: 21px; margin: 6px 0 4px; letter-spacing: -.025em; font-weight: 680; line-height: 1.2; }
.detail-head .op { color: var(--text-dim); font-size: 13.5px; }

.statusbar {
  margin: 0 var(--pad) 14px; padding: 13px 14px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--raised);
}
.statusbar .big { font-size: 16px; font-weight: 660; display: flex; align-items: center; gap: 8px; }
.statusbar .why { font-size: 12.5px; color: var(--text-faint); margin-top: 5px; }
.confbar { height: 4px; border-radius: 3px; background: var(--line); margin-top: 9px; overflow: hidden; }
.confbar i { display: block; height: 100%; border-radius: 3px; }

.rows { padding: 0 var(--pad); }
.row { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-top: 1px solid var(--line-soft); font-size: 14px; }
.row .k { color: var(--text-faint); flex: none; }
.row .v { text-align: right; font-weight: 520; }
.row .v .dimnote { display: block; font-size: 11.5px; color: var(--text-faint); font-weight: 420; margin-top: 2px; }

.section-title { padding: 20px var(--pad) 8px; font-size: 12px; font-weight: 680;
  letter-spacing: .09em; text-transform: uppercase; color: var(--text-faint); }

.report {
  padding: 12px var(--pad); border-top: 1px solid var(--line-soft);
  display: grid; grid-template-columns: 34px 1fr; gap: 11px;
}
.report .av { width: 34px; height: 34px; border-radius: 11px; background: var(--raised-2);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--text-dim); }
.report .who { font-size: 13px; font-weight: 600; display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.report .when { font-size: 11.5px; color: var(--text-faint); font-weight: 440; }
.report .body { font-size: 14px; margin-top: 4px; color: var(--text); }
.report .facts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.report .acts { display: flex; gap: 8px; margin-top: 8px; }
.report .acts button { font-size: 12px; color: var(--text-dim); padding: 5px 10px;
  border: 1px solid var(--line); border-radius: 999px; }
.report .acts button:active { background: var(--raised-2); }
.verified { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px;
  color: var(--works); background: var(--works-bg); padding: 1px 6px; border-radius: 999px; font-weight: 650; }

/* ── Buttons and forms ─────────────────────────────────────────────────────── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 18px; border-radius: var(--r); font-weight: 640; font-size: 15px;
  background: var(--raised-2); border: 1px solid var(--line); width: 100%;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--text); color: var(--ink); border-color: var(--text); }
.btn.good { background: var(--works); color: #04140F; border-color: var(--works); }
.btn.bad  { background: var(--broken); color: #1A0409; border-color: var(--broken); }
.btnrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px var(--pad) 4px; }

.field { padding: 8px var(--pad); }
.field label { display: block; font-size: 12px; color: var(--text-faint); margin-bottom: 6px;
  font-weight: 600; letter-spacing: .02em; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 12px 13px; outline: 0; font-size: 15px;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field textarea { min-height: 84px; resize: vertical; }
.hint { font-size: 12px; color: var(--text-faint); padding: 4px var(--pad) 0; }

.chiprow { display: flex; gap: 7px; flex-wrap: wrap; padding: 4px var(--pad); }
.chip { padding: 9px 13px; border-radius: 999px; background: var(--raised);
  border: 1px solid var(--line-soft); font-size: 13.5px; color: var(--text-dim); font-weight: 540; }
.chip[aria-pressed="true"] { background: var(--accent); color: #04141C; border-color: var(--accent); font-weight: 640; }

/* ── States ────────────────────────────────────────────────────────────────── */
.empty { padding: 46px var(--pad); text-align: center; color: var(--text-faint); }
.empty strong { display: block; color: var(--text-dim); font-size: 15px; margin-bottom: 6px; font-weight: 600; }
.skeleton { padding: 13px var(--pad); border-top: 1px solid var(--line-soft); display: flex; gap: 12px; align-items: center; }
.skeleton i { display: block; background: var(--raised); border-radius: 10px; animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45 } }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + var(--safe-b)); z-index: 90;
  background: var(--raised-2); border: 1px solid var(--line);
  padding: 11px 17px; border-radius: 999px; font-size: 13.5px; font-weight: 560;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: rise .2s ease;
  max-width: calc(100vw - 32px); text-align: center;
}

.banner {
  margin: 10px var(--pad); padding: 11px 13px; border-radius: var(--r-sm);
  background: rgba(76,201,240,.09); border: 1px solid rgba(76,201,240,.24);
  font-size: 12.5px; color: var(--text-dim); line-height: 1.5;
}
.banner b { color: var(--accent); font-weight: 640; }

/* ── Route plan ────────────────────────────────────────────────────────────── */
.leg { display: grid; grid-template-columns: 26px 1fr; gap: 12px; padding: 0 var(--pad); }
.leg .rail { display: flex; flex-direction: column; align-items: center; }
.leg .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); margin-top: 15px; flex: none; }
.leg .dot.stop { background: var(--works); }
.leg .dot.end { background: var(--text); }
.leg .line { flex: 1; width: 2px; background: var(--line); margin: 3px 0; }
.leg .content { padding: 12px 0 4px; }
.leg .content .lbl { font-weight: 620; font-size: 14.5px; }
.leg .content .det { font-size: 12.5px; color: var(--text-faint); margin-top: 3px; }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--line-soft); margin: 12px var(--pad); border-radius: var(--r); overflow: hidden; }
.summary div { background: var(--raised); padding: 13px 10px; text-align: center; }
.summary .n { font-size: 19px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.summary .l { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .07em; margin-top: 3px; font-weight: 620; }

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

/* MapLibre's attribution sits bottom-right by default, directly under the zoom
   controls. Move it left so neither obscures the other. */
.maplibregl-ctrl-bottom-right { right: 66px; }
.maplibregl-ctrl-attrib.maplibregl-compact { background: rgba(12,18,26,.8); }
.maplibregl-ctrl-attrib a { color: var(--text-dim); }

/* Provenance affordance: a value you can interrogate says so quietly. */
.prov { color: var(--accent); font-size: 11px; opacity: .75; margin-left: 2px; }
.statusbar { cursor: pointer; }
