:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f5f4;
  --text: #0a0a0a;
  --muted: #57534e;
  --border: #e7e5e4;
  --accent: #16a34a;
  --accent-strong: #15803d;
  --accent-soft: #dcfce7;
  --accent-text: #ffffff;
  --ink: #0a0a0a;
  --ink-text: #ffffff;
  --lime: #4cc417;
  --incident: #c2410c;
  --zone: #b91c1c;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface-2: #1c1c1c;
    --text: #fafafa;
    --muted: #a8a29e;
    --border: #262626;
    --accent: #22c55e;
    --accent-strong: #4ade80;
    --accent-soft: rgba(34, 197, 94, .14);
    --accent-text: #052e12;
    --ink: #fafafa;
    --ink-text: #0a0a0a;
    --incident: #fb923c;
    --zone: #f87171;
    --danger: #f97066;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent-strong); text-underline-offset: 2px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* Top bar */
.topbar { background: #000; color: #fff; border-bottom: 1px solid #1f1f1f; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; letter-spacing: -.01em; }
.brand img { width: 28px; height: 28px; display: block; }
.brand-accent { color: #a3e635; }
.topbar-link { color: #d6d3d1; text-decoration: none; font-size: .92rem; font-weight: 500; }
.topbar-link:hover { color: #fff; }
.topbar-nav { display: flex; gap: 18px; }
@media (max-width: 480px) {
  .brand { font-size: .92rem; gap: 8px; }
  .topbar-nav { gap: 12px; }
  .topbar-link { font-size: .85rem; }
}

/* Hero */
.hero { padding-top: 40px; padding-bottom: 32px; }
.site-header { border-bottom: 1px solid var(--border); }
.hero h1 { margin: 0; font-size: clamp(2rem, 5.5vw, 3.25rem); line-height: 1.05; letter-spacing: -.035em; font-weight: 800; }
.tagline { margin: 12px 0 0; color: var(--muted); max-width: 52ch; font-size: 1.08rem; }
.stats:empty { display: none; }
.stats { display: flex; align-items: flex-start; gap: 8px; margin: 18px 0 0; min-height: 1.5em; font-size: .92rem; font-weight: 600; color: var(--text); }
.stats:not(:empty)::before { content: ""; flex: none; margin-top: .45em; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.hero .home-link { margin-bottom: 14px; text-decoration: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

main { padding-bottom: 48px; }
section { margin-top: 36px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
h2 { font-size: 1.25rem; margin: 0; letter-spacing: -.015em; font-weight: 750; }
h3 { font-size: 1rem; margin: 20px 0 4px; }
.fine { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:hover { border-color: var(--muted); }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, .chip input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px;
}
.btn-primary { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.btn-primary svg { color: var(--accent); }
.btn-primary:hover { filter: none; background: color-mix(in srgb, var(--ink) 85%, var(--accent)); border-color: transparent; }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-big { padding: 14px 22px; font-size: 1.05rem; }
.btn-small { padding: 6px 12px; font-size: .9rem; }
.btn-icon { width: 40px; height: 40px; padding: 0; font-size: 1.5rem; line-height: 1; }
.btn-quiet { border-color: transparent; color: var(--muted); }

/* Map */
.map { height: min(62vh, 560px); min-height: 320px; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); z-index: 0; }
.layer-toggles { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .9rem; }
.layer-toggles label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.3); }
.dot-scooter { background: var(--lime); }
.dot-incident { background: var(--incident); }
.dot-corral { background: #15803d; }
.swatch { --c: var(--zone); width: 14px; height: 10px; display: inline-block; flex: none; background: color-mix(in srgb, var(--c) 30%, transparent); border: 1.5px solid var(--c); }
.swatch-no_ride { --c: #b91c1c; }
.swatch-no_parking { --c: #7c3aed; }
.swatch-slow { --c: #d97706; }
.swatch-parking_required { --c: #2563eb; background: transparent; border-style: dashed; }
.zone-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 0; padding: 0; font-size: .85rem; }
.zone-legend li { display: inline-flex; align-items: center; gap: 6px; }
.leaflet-popup-content { font: 14px/1.4 system-ui, sans-serif; }
.popup img { width: 200px; max-width: 100%; border-radius: 8px; display: block; margin-bottom: 6px; cursor: zoom-in; }
.popup .when { color: #666; font-size: 12px; }

/* Carousel */
.carousel-nav { display: flex; align-items: center; gap: 6px; }
.see-all { text-decoration: none; color: var(--text); margin-right: 4px; }
.carousel {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 240px); gap: 12px;
  overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 12px; overscroll-behavior-x: contain;
}
.carousel .empty { color: var(--muted); }
.card {
  scroll-snap-align: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); cursor: pointer; text-align: left; padding: 0; font: inherit; color: inherit;
}
.card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--border); }
.card .card-body { padding: 8px 10px 10px; }
.card .card-title { font-weight: 600; font-size: .95rem; }
.card .card-when { color: var(--muted); font-size: .8rem; }

.incident-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.incident-list li { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--incident); border-radius: 8px; padding: 10px 12px; }
.incident-list .meta { color: var(--muted); font-size: .85rem; }

.about { max-width: 70ch; }

/* Dialogs */
dialog { border: none; padding: 0; color: var(--text); background: var(--surface); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.sheet { width: min(560px, 100vw); max-height: 100dvh; border-radius: 16px; box-shadow: var(--shadow); }
@media (max-width: 600px) {
  .sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 16px 16px 0 0; max-height: 94dvh; }
}
.report-form { padding: 16px; display: grid; gap: 16px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font-size: 1.25rem; }
.field { border: none; margin: 0; padding: 0; min-width: 0; }
.field legend, .field > label { font-weight: 600; margin-bottom: 6px; padding: 0; display: block; }
input[type="text"], input[type="date"], textarea {
  width: 100%; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
}
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: 8px; }
details label { display: block; margin: 8px 0 4px; }

.photo-drop {
  display: grid; place-items: center; gap: 8px; min-height: 160px; border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--bg); cursor: pointer; text-align: center; padding: 12px; position: relative; overflow: hidden;
}
.photo-drop-small { min-height: 72px; }
.photo-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-drop-text { font-weight: 600; color: var(--accent); }
.photo-preview { max-height: 220px; max-width: 100%; border-radius: 8px; }

.location-status { margin: 0 0 8px; }
.location-status.ok { color: var(--accent); font-weight: 600; }
.location-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mini-map { height: 220px; margin-top: 10px; border-radius: 8px; border: 1px solid var(--border); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; }
.chip span {
  display: inline-block; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; background: var(--bg); font-size: .95rem;
}
.chip input:checked + span { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }

.callout { margin: 0; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--incident) 12%, transparent); font-size: .92rem; }
.form-error { color: var(--danger); margin: 0; font-weight: 600; }

.viewer { width: min(900px, 100vw); max-height: 100dvh; border-radius: 12px; overflow: auto; }
.viewer img { width: 100%; max-height: 70vh; object-fit: contain; background: #000; display: block; }
.viewer .close { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); color: #fff; border: none; }
.viewer-body { padding: 12px 16px 16px; }
.viewer-body p { margin: 0 0 8px; }
.viewer-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); z-index: 1000;
}
