:root {
  --asphalt: #26282b;
  --asphalt-soft: #3a3d41;
  --lane: #f7f6f2;
  --sign-green: #006b54;
  --sign-blue: #4a6785;
  --warning: #ffcc00;
  --cone: #e8590c;
  --ink: #1b1c1e;
  --muted: #5f6368;
  --radius-sign: 10px;
  --radius-card: 10px;
  --radius-control: 8px;
  --hairline: #e3e1d9;
  --card-bg: #fff;
  --shadow-card: 0 1px 2px rgba(27, 28, 30, 0.06), 0 4px 12px rgba(27, 28, 30, 0.05);
  --shadow-raised: 0 2px 4px rgba(27, 28, 30, 0.12), 0 8px 20px rgba(27, 28, 30, 0.10);
  --shadow-float: 0 4px 10px rgba(27, 28, 30, 0.14), 0 16px 40px rgba(27, 28, 30, 0.16);
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --panel-w: 380px;
  --panel-ease: 300ms cubic-bezier(0.32, 0.72, 0.24, 1);
}

* { box-sizing: border-box; }

/* No display rule anywhere (form's grid, #results' mobile flex, ...) may
   defeat the hidden attribute app.js toggles. */
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  font-family: "Overpass", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--lane);
  line-height: 1.5;
  overflow: hidden;
}

/* ---- Full-viewport map; everything else floats over it ------------------- */
#map {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: #dfe3e6;
}

/* Emblem watermark, always centred in the viewport. It lives in a custom
   Leaflet pane (z 350: above tiles at 200, below overlays/markers/popups)
   and app.js re-centres it on every map move. */
.map-watermark {
  position: absolute;
  width: 480px;
  max-width: 65vw;
  opacity: 0.085;
  pointer-events: none;
  user-select: none;
}

/* ---- Floating search pill (Apple Maps / Google Maps style) ---------------- */
.search-pill {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: min(460px, calc(100vw - 24px));
  padding: 0.45rem 0.5rem 0.45rem 0.9rem;
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  box-shadow: var(--shadow-float);
}

.pill-logo { flex: none; width: 28px; height: auto; }

input#pill-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-weight: 600;
  border: 0;
  background: transparent;
  padding: 0.35rem 0;
  color: var(--ink);
}

input#pill-input::placeholder { color: #7a7f85; font-weight: 600; }
input#pill-input:focus { outline: none; }
.search-pill:focus-within {
  border-color: var(--asphalt);
  box-shadow: var(--shadow-float), 0 0 0 2px rgba(38, 40, 43, 0.25);
}

#pill-go {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--ink);
  background: var(--warning);
  border: 2px solid var(--asphalt);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 0 var(--asphalt);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}
#pill-go:hover { filter: brightness(1.04); transform: translateY(-1px); box-shadow: 0 2px 0 var(--asphalt); }
#pill-go:active { transform: translateY(1px); box-shadow: 0 0 0 var(--asphalt); }

/* ---- Docked popout tab: toggles the panel open AND closed ------------------ */
/* It never disappears — it rides the panel's right edge as it slides, so the
   same control that opens the panel is the one that tucks it away again. */
.panel-tab {
  position: fixed;
  left: 0;
  top: 50%;
  z-index: 1060; /* above the panel, so it stays clickable riding its edge */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 104px;
  padding: 0;
  color: var(--asphalt);
  background: var(--warning);
  border: 2px solid var(--asphalt);
  border-left: 0;
  border-radius: 0 10px 10px 0;
  cursor: pointer;
  box-shadow: var(--shadow-raised);
  transform: translateY(-50%);
  transition: transform var(--panel-ease), filter 120ms ease;
}

.panel-tab:hover { transform: translateY(-50%) translateX(3px); filter: brightness(1.04); }

.panel-tab svg { transition: transform var(--panel-ease); }

/* Docks flush against the open panel's right edge instead of hiding. */
body.panel-open .panel-tab { transform: translateY(-50%) translateX(var(--panel-w)); }
body.panel-open .panel-tab svg { transform: rotate(180deg); }
body.panel-open .panel-tab:hover { transform: translateY(-50%) translateX(calc(var(--panel-w) - 3px)); }

/* ---- Slide-in trip panel --------------------------------------------------- */
.panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1050;
  width: var(--panel-w);
  max-width: calc(100vw - 16px);
  display: flex;
  flex-direction: column;
  border-right: 6px solid var(--asphalt);
  /* dashed centre line down the panel edge, like a lane marking */
  background:
    linear-gradient(var(--warning) 50%, transparent 50%) right -6px top / 2px 36px repeat-y,
    var(--lane);
  box-shadow: var(--shadow-float);
  transform: translateX(calc(-100% - 24px));
  transition: transform var(--panel-ease);
  visibility: hidden;
}

body.panel-open .panel { transform: translateX(0); visibility: visible; }

/* keep it discoverable to transition back out */
.panel { transition: transform var(--panel-ease), visibility 0s linear 320ms; }
body.panel-open .panel { transition: transform var(--panel-ease), visibility 0s; }

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-5) var(--space-5) var(--space-4);
}

.sheet-handle { display: none; }

/* ---- Masthead: emblem + wordmark on one baseline, tagline underneath ------- */
.masthead {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: var(--space-3);
  row-gap: var(--space-1);
}

.masthead .logo {
  grid-column: 1;
  grid-row: 1;
  width: 52px;
  height: auto;
}

h1 {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 1.8rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* "jawn" gets the hazard-yellow warning-plate treatment. */
.wordmark .jawn {
  background: var(--warning);
  color: var(--ink);
  padding: 0 0.12em;
  margin-left: 0.02em;
  border-radius: 5px;
  box-shadow: 0 1px 0 var(--asphalt);
}

.tagline {
  grid-column: 1 / 3;
  grid-row: 2;
  margin: 0;
  padding-top: var(--space-1);
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

/* ---- Segmented mode switch: unifies "plan a trip" and "ask 311 data" ------- */
.mode-switch {
  display: flex;
  gap: 3px;
  margin-top: var(--space-4);
  padding: 3px;
  background: rgba(38, 40, 43, 0.06);
  border: 1.5px solid var(--asphalt);
  border-radius: 999px;
}

.mode-tab {
  flex: 1;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.62rem 0.5rem;
  color: var(--asphalt-soft);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.mode-tab:hover { color: var(--ink); }

.mode-tab[aria-selected="true"] {
  color: var(--ink);
  background: var(--warning);
  box-shadow: 0 1px 0 var(--asphalt);
}

.mode-panel {
  margin-top: var(--space-4);
  animation: mode-in 180ms ease both;
}

@keyframes mode-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.fine-print {
  margin: var(--space-5) 0 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--hairline);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
}

h2 {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--asphalt-soft);
  margin: var(--space-5) 0 var(--space-2);
}

form { display: grid; gap: var(--space-1); } /* [hidden] guard is global, at the top */

label { font-weight: 600; font-size: 0.85rem; margin-top: var(--space-2); color: var(--asphalt-soft); }

input[type="text"] {
  font: inherit;
  padding: 0.65rem 0.8rem;
  border: 2px solid var(--asphalt);
  border-radius: var(--radius-control);
  background: #fff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input[type="text"]:hover { border-color: var(--asphalt-soft); }

input[type="text"]::placeholder { color: #9aa0a6; }

button#go, button#ask-go {
  margin-top: var(--space-4);
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.01em;
  padding: 0.8rem;
  color: var(--ink);
  background: var(--warning);
  border: 2px solid var(--asphalt);
  border-radius: var(--radius-control);
  cursor: pointer;
  box-shadow: 0 2px 0 var(--asphalt);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

button#go:hover:not(:disabled), button#ask-go:hover:not(:disabled) {
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow: 0 3px 0 var(--asphalt);
}

button#go:active:not(:disabled), button#ask-go:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--asphalt);
  filter: brightness(0.97);
}

button#go:disabled, button#ask-go:disabled {
  opacity: 0.55;
  cursor: progress;
  transform: none;
  box-shadow: 0 2px 0 var(--asphalt);
}

input:focus-visible, button:focus-visible, summary:focus-visible, .route-sign:focus-visible, a:focus-visible {
  outline: 3px solid var(--cone);
  outline-offset: 2px;
}

.status {
  min-height: 1.4rem;
  margin: var(--space-3) 0 0;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.status.error { color: #a61b1b; }

/* Spinner shown while an agent request is in flight. */
.status.busy::before {
  content: "";
  flex: none;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  border: 2.5px solid var(--asphalt);
  border-top-color: var(--warning);
  animation: spin 700ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.briefing {
  margin-top: var(--space-4);
  padding: var(--space-4) 1.1rem;
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-left: 6px solid var(--sign-green);
  border-radius: 0 var(--radius-card) var(--radius-card) 0;
  box-shadow: var(--shadow-card);
  white-space: pre-wrap;
  font-size: 0.95rem;
}

.briefing .mode {
  display: block;
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--hairline);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.routes { display: grid; gap: var(--space-3); margin-top: var(--space-4); }

/* Route cards look like highway guide signs: solid fill, white inset border. */
.route-sign {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  padding: 0.85rem 1rem;
  font: inherit;
  text-align: left;
  color: #fff;
  background: var(--sign-blue);
  border: 0;
  border-radius: var(--radius-sign);
  box-shadow: inset 0 0 0 3px var(--sign-blue), inset 0 0 0 5px #fff, var(--shadow-card);
  cursor: pointer;
  opacity: 0.82;
  transition: opacity 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.route-sign:hover {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 3px var(--sign-blue), inset 0 0 0 5px #fff, var(--shadow-raised);
}

.route-sign:active { transform: translateY(0); }

.route-sign.recommended {
  background: var(--sign-green);
  box-shadow: inset 0 0 0 3px var(--sign-green), inset 0 0 0 5px #fff, var(--shadow-card);
}

.route-sign.recommended:hover {
  box-shadow: inset 0 0 0 3px var(--sign-green), inset 0 0 0 5px #fff, var(--shadow-raised);
}

.route-sign.active { opacity: 1; box-shadow: inset 0 0 0 3px var(--sign-blue), inset 0 0 0 5px #fff, var(--shadow-raised); }
.route-sign.recommended.active { box-shadow: inset 0 0 0 3px var(--sign-green), inset 0 0 0 5px #fff, var(--shadow-raised); }

.route-letter { font-size: 2rem; font-weight: 800; line-height: 1; }
.route-meta { font-size: 0.85rem; opacity: 0.92; }
.route-meta strong { display: block; font-size: 1.05rem; letter-spacing: 0.01em; }
.route-count { text-align: center; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; line-height: 1.2; opacity: 0.92; }
.route-count b { display: block; font-size: 1.7rem; font-weight: 800; letter-spacing: 0; text-transform: none; color: var(--warning); }

details {
  margin-top: var(--space-5);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  background: var(--card-bg);
  box-shadow: var(--shadow-card);
}

summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-card);
  transition: background-color 120ms ease;
}

summary:hover { background: rgba(38, 40, 43, 0.04); }

details[open] summary { border-bottom: 1px solid var(--hairline); border-radius: var(--radius-card) var(--radius-card) 0 0; }

/* On desktop the pothole-list disclosure is invisible chrome: the summary is
   hidden and the wrapper adds nothing, so the panel renders exactly as before.
   Mobile restyles it into a real collapsed disclosure card below. */
.list-disclosure,
details.list-disclosure[open] {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.list-disclosure > summary { display: none; }

/* Mobile-only affordances; inert on desktop. */
.peek-summary, .trip-summary { display: none; }

details ol { margin: var(--space-2) 0 var(--space-3); }

#live, #ask-live {
  margin-top: var(--space-4);
  padding: var(--space-2) var(--space-4) var(--space-3);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  background: var(--card-bg);
  box-shadow: var(--shadow-card);
}

#steps, #live-steps, #ask-live-steps {
  padding-left: 1.4rem;
  font-size: 0.85rem;
  color: var(--asphalt-soft);
}
#steps { margin: var(--space-3) var(--space-4); }
#steps li, #live-steps li, #ask-live-steps li { margin: 0.35rem 0; overflow-wrap: anywhere; }
#live-steps li, #ask-live-steps li { animation: step-in 260ms ease both; }
#steps li.error, #live-steps li.error, #ask-live-steps li.error { color: #a61b1b; }

@keyframes step-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Ask-the-analyst tab ---------------------------------------------------- */
.ask-explainer {
  margin: 0 0 var(--space-3);
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--muted);
}

.ask-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-2);
  margin: 0 calc(-1 * var(--space-5)) var(--space-2);
  padding: 2px var(--space-5) 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.ask-chips::-webkit-scrollbar { display: none; }

.ask-chip {
  flex: none;
  max-width: 100%;
  white-space: nowrap;
  scroll-snap-align: start;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  color: var(--asphalt-soft);
  background: var(--card-bg);
  border: 1.5px solid var(--asphalt);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 1px 0 var(--asphalt);
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease, color 120ms ease;
}

.ask-chip:hover {
  background: var(--warning);
  color: var(--ink);
  transform: translateY(-1px);
  box-shadow: 0 2px 0 var(--asphalt);
}

.ask-chip:active { transform: translateY(1px); box-shadow: 0 0 0 var(--asphalt); }

/* ---- Location autocomplete dropdown --------------------------------------- */
.ac-list {
  position: fixed;
  z-index: 1300;
  max-height: 42vh;
  overflow-y: auto;
  padding: 4px;
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-float);
}

.ac-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

.ac-item:hover, .ac-item.active { background: rgba(255, 204, 0, 0.2); }

.ac-glyph { flex: none; width: 1.25rem; text-align: center; }
.ac-text { display: flex; flex-direction: column; min-width: 0; }
.ac-label { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-sub { font-size: 0.76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Entrance only — plays once when the dropdown opens, never on a per-
   keystroke re-render, so results updating while typing never jitters. */
.ac-list.ac-open { animation: ac-in 140ms ease both; }
@keyframes ac-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Trailing "still looking" row while a Photon request is in flight. */
.ac-loading {
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
  animation: hazard 1.2s ease-in-out infinite;
}

/* ---- Use-my-location button inside the start input ------------------------- */
.input-geo { position: relative; }
.input-geo input { width: 100%; padding-right: 2.6rem; }

.geo-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.25rem 0.35rem;
  font-size: 1.02rem;
  line-height: 1;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.geo-btn:hover { background: rgba(38, 40, 43, 0.08); }

.live-title {
  font-size: 0.75rem;
  margin: var(--space-2) 0 var(--space-1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Blinking hazard dot next to the live activity title. */
.live-title::before {
  content: "";
  flex: none;
  width: 0.55rem;
  height: 0.55rem;
  background: var(--warning);
  border: 1.5px solid var(--asphalt);
  transform: rotate(45deg);
  animation: hazard 1.2s ease-in-out infinite;
}

@keyframes hazard {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.pothole-list { list-style: none; margin: 0; padding: 0; }
.pothole-list li {
  display: grid;
  grid-template-columns: 3.6rem 1fr auto;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2);
  margin: 0 calc(-1 * var(--space-2));
  border-bottom: 1px solid var(--hairline);
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 120ms ease;
}
.pothole-list li:hover { background: rgba(255, 204, 0, 0.14); }
.pothole-list .mile { font-weight: 800; font-variant-numeric: tabular-nums; }
.pothole-list .age { color: var(--muted); white-space: nowrap; font-size: 0.82rem; }
.pothole-list .age.old { color: var(--cone); font-weight: 600; }

footer {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--hairline);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
}

footer p { margin: 0 0 var(--space-2); }

footer a { color: var(--sign-blue); font-weight: 600; text-decoration-thickness: 1px; text-underline-offset: 2px; }
footer a:hover { color: var(--sign-green); }

.footer-credit { letter-spacing: 0.01em; }

/* Mute the basemap so routes and warning signs carry the colour. */
.leaflet-tile-pane { filter: grayscale(0.9) contrast(0.92) brightness(1.06); }

/* Pothole markers: yellow diamond warning signs. Orange when open 90+ days. */
.pothole-marker {
  width: 18px; height: 18px;
  background: var(--warning);
  border: 2px solid var(--ink);
  border-radius: 3px;
  transform: rotate(45deg);
  box-shadow: 0 1px 3px rgba(27, 28, 30, 0.35);
}
.pothole-marker.old { background: var(--cone); }

/* Count of citywide open reports currently in view (Leaflet control). */
.citywide-badge {
  padding: 0.3rem 0.65rem;
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-left: 4px solid var(--warning);
  border-radius: 6px;
  box-shadow: var(--shadow-card);
  font-family: "Overpass", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--asphalt-soft);
}

/* Landmark chips: tiny emoji in a white circle, quiet enough to sit under routes. */
.landmark-chip {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(27, 28, 30, 0.25);
  cursor: pointer;
}

.landmark-popup strong { font-size: 0.9rem; }

.landmark-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.landmark-btn {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  color: var(--ink);
  background: var(--warning);
  border: 1.5px solid var(--asphalt);
  border-radius: var(--radius-control);
  cursor: pointer;
  box-shadow: 0 1px 0 var(--asphalt);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.landmark-btn:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow: 0 2px 0 var(--asphalt);
}

.landmark-btn:active {
  transform: translateY(1px);
  box-shadow: 0 0 0 var(--asphalt);
}

.endpoint-marker {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 5px solid var(--asphalt);
  box-shadow: 0 1px 3px rgba(27, 28, 30, 0.35);
}

/* ---- Mobile: bottom sheet (Waze / Google Maps pattern) --------------------- */
/* Three snap states — peek (handle + trip-summary strip), half (map + routes
   both visible), full (reading/typing) — driven by .sheet-peek/.sheet-half/
   .sheet-full from app.js, with a real touch drag on the handle. */
@media (max-width: 768px) {
  .map-watermark { width: 200px; }

  /* The bottom sheet's peek strip and the pill cover this role on mobile. */
  .panel-tab { display: none; }

  /* Map-first, one-hand reachable: the pill rides the bottom edge (Google
     Maps style). app.js lifts it above the keyboard via visualViewport. */
  .search-pill {
    top: auto;
    bottom: max(14px, calc(env(safe-area-inset-bottom, 0px) + 8px));
    left: 50%;
    transform: translateX(-50%);
    width: min(460px, calc(100vw - 24px));
    padding: 0.4rem 0.4rem 0.4rem 0.9rem;
  }

  /* The sheet's form takes over while the sheet is up (any state): no
     overlapping inputs at the bottom edge. */
  body.panel-open .search-pill { display: none; }

  /* Comfortable thumb target on the pill's action button. */
  #pill-go { width: 44px; height: 44px; }

  /* With the pill at the bottom, the zoom control keeps its normal top spot
     (just clear of a notch). The citywide badge docks under it via app.js. */
  .leaflet-top.leaflet-left { top: env(safe-area-inset-top, 0px); }

  /* Attribution clears the bottom pill (the sheet simply covers it when open). */
  .leaflet-bottom.leaflet-right {
    bottom: calc(max(14px, env(safe-area-inset-bottom, 0px) + 8px) + 62px);
  }

  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    height: 92vh;
    height: 92dvh;
    border-right: 0;
    border-top: 6px solid var(--asphalt);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -6px 16px rgba(27, 28, 30, 0.14), 0 -18px 44px rgba(27, 28, 30, 0.20);
    /* lane marking runs along the top edge on mobile */
    background:
      linear-gradient(90deg, var(--warning) 50%, transparent 50%) left top -6px / 36px 2px repeat-x,
      var(--lane);
    transform: translateY(calc(100% + 24px));
  }

  /* Open with no state class = full, so pre-existing code paths that only
     toggle body.panel-open still land somewhere sensible. */
  body.panel-open .panel { transform: translateY(0); }
  body.panel-open .panel.sheet-half {
    transform: translateY(calc(100% - 55vh));
    transform: translateY(calc(100% - 55dvh));
  }
  body.panel-open .panel.sheet-peek,
  body.panel-open .panel.collapsed {
    transform: translateY(calc(100% - 120px - env(safe-area-inset-bottom, 0px)));
  }

  /* While a finger owns the sheet, position is inline and transitions pause. */
  .panel.dragging { transition: none !important; }

  .sheet-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 100%;
    height: 44px;
    padding: 0;
    background: transparent;
    border: 0;
    cursor: grab;
    touch-action: none; /* the drag gesture owns this surface */
  }

  .sheet-handle span {
    display: block;
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: rgba(38, 40, 43, 0.28);
    transition: background-color 150ms ease;
  }

  .panel.dragging .sheet-handle { cursor: grabbing; }
  .panel.dragging .sheet-handle span { background: rgba(38, 40, 43, 0.5); }

  .panel-scroll {
    padding: 0 var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
    overflow-x: hidden; /* no sideways leaks on a narrow viewport */
  }

  /* No scroll-trap at peek: the strip is a grab surface, not a viewport, and
     its content fades out so the summary strip reads as the minimized face. */
  .panel.sheet-peek .panel-scroll {
    overflow-y: hidden;
    opacity: 0;
    pointer-events: none; /* faded-out controls must not stay tappable */
    transition: opacity 150ms ease;
  }

  /* Content fades in as the sheet expands out of peek. Toggling between half
     and full computes the same animation value, so it never restarts mid-drag. */
  .panel.sheet-half .panel-scroll,
  .panel.sheet-full .panel-scroll { animation: sheet-content-in 220ms ease both; }

  /* The pill already brands the app on mobile — the masthead is desktop
     furniture that pushed real content below the fold. Visually hidden (not
     display:none) so the page keeps its h1 for screen readers. */
  .masthead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .mode-switch { margin-top: var(--space-3); }

  /* 16px inputs so iOS Safari never zooms the page on focus. */
  input[type="text"] { font-size: 1rem; }

  /* Thumb-sized touch targets throughout the sheet. */
  .geo-btn { min-width: 44px; min-height: 44px; }
  .mode-tab { min-height: 44px; }

  /* Analyst chips wrap into full-width tappable rows instead of a
     horizontal scroller that hides two of the three examples. */
  .ask-chips {
    flex-wrap: wrap;
    overflow-x: visible;
    margin: 0 0 var(--space-2);
    padding: 0;
  }
  .ask-chip {
    flex: 1 1 100%;
    white-space: normal;
    text-align: left;
    min-height: 44px;
    padding: 0.55rem 0.85rem;
    line-height: 1.35;
  }

  /* Autocomplete dropdown never overflows a small viewport. */
  .ac-list { max-width: calc(100vw - 16px); max-height: 38vh; }

  /* ---- Mobile results spacing. The answer-first order (routes, briefing,
     agent log, pothole list) now lives in the DOM itself so focus and
     screen-reader order match the visual order — no flex `order` here. */
  #results { display: flex; flex-direction: column; min-width: 0; }
  #results .routes { margin-top: var(--space-3); }
  #results #activity { margin-top: var(--space-4); }

  /* Pothole list collapses under a "9 reports along Route A" disclosure. */
  .list-disclosure,
  details.list-disclosure[open] {
    margin: var(--space-4) 0 0;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-card);
    background: var(--card-bg);
    box-shadow: var(--shadow-card);
  }
  .list-disclosure > summary { display: block; min-height: 44px; }
  .list-disclosure #list-title { display: none; }
  .list-disclosure .pothole-list { padding: var(--space-1) var(--space-4) var(--space-2); }
  .list-disclosure .pothole-list li { margin: 0; }

  /* ---- Compact trip summary row replaces the spent form after results ------- */
  .trip-summary:not([hidden]) {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    min-height: 44px;
    padding: 0.55rem 0.85rem;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    text-align: left;
    color: var(--ink);
    background: var(--card-bg);
    border: 1.5px solid var(--asphalt);
    border-radius: var(--radius-control);
    cursor: pointer;
    box-shadow: 0 1px 0 var(--asphalt);
  }
  .trip-summary-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .trip-summary-edit {
    flex: none;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink);
    background: var(--warning);
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    box-shadow: 0 1px 0 var(--asphalt);
  }

  /* ---- Informative peek strip: the sheet's "minimized" face ----------------- */
  .panel.sheet-peek .peek-summary:not([hidden]) { display: flex; }
  .peek-summary {
    align-items: center;
    gap: 0.6rem;
    margin: -4px var(--space-4) 0;
    padding: 0 0 var(--space-2);
    font: inherit;
    background: transparent;
    border: 0;
    text-align: left;
    cursor: pointer;
  }
  .peek-chip {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 1rem;
    color: #fff;
    background: var(--sign-blue);
    box-shadow: inset 0 0 0 1.5px #fff, 0 1px 0 var(--asphalt);
  }
  .peek-chip.recommended { background: var(--sign-green); }
  .peek-meta {
    flex: 1;
    min-width: 0;
    font-weight: 700;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .peek-hint {
    flex: none;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
  }
  .peek-hint::before { content: "\2191\00a0"; }

  /* ---- Live agent steps as a compact one-line ticker ------------------------
     Smaller type, single-line rows, capped height with its own scroll (the
     existing scrollIntoView keeps it pinned to the newest step), so the map
     stays visible above the half sheet during a run. */
  #live, #ask-live { padding: var(--space-2) var(--space-3); }
  #live-steps, #ask-live-steps {
    max-height: 24vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-left: 1.1rem;
    font-size: 0.78rem;
  }
  #live-steps li, #ask-live-steps li {
    margin: 0.14rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: normal;
  }

  /* Analyst answer stays comfortably readable on a phone. */
  #answer { font-size: 0.95rem; line-height: 1.55; }
}

@keyframes sheet-content-in {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
