/* Score — restaurant health inspections.
   Colour roles come from a validated palette: grade badges use the reserved
   status palette (good/warning/serious/critical) and are always rendered with
   the letter itself, so colour never carries the meaning alone. */

:root {
  color-scheme: light;
  --surface:      #fcfcfb;
  --plane:        #f9f9f7;
  --ink:          #0b0b0b;
  --ink-2:        #52514e;
  --ink-muted:    #898781;
  --grid:         #e1e0d9;
  --axis:         #c3c2b7;
  --border:       rgba(11, 11, 11, .10);
  --shadow:       0 1px 2px rgba(11,11,11,.05), 0 8px 24px rgba(11,11,11,.07);
  --accent:       #2a78d6;
  --accent-wash:  rgba(42, 120, 214, .10);
  --wash:         rgba(11, 11, 11, .045);

  /* status palette — fixed, never themed */
  --grade-a: #0ca30c;
  --grade-b: #fab219;
  --grade-c: #ec835a;
  --grade-u: #d03b3b;

  --r: 14px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface:     #1a1a19;
    --plane:       #0d0d0d;
    --ink:         #ffffff;
    --ink-2:       #c3c2b7;
    --ink-muted:   #898781;
    --grid:        #2c2c2a;
    --axis:        #383835;
    --border:      rgba(255, 255, 255, .10);
    --shadow:      0 1px 2px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.45);
    --accent:      #3987e5;
    --accent-wash: rgba(57, 135, 229, .16);
    --wash:        rgba(255, 255, 255, .06);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 400 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  overscroll-behavior-y: none;
  padding-bottom: env(safe-area-inset-bottom);
}

body.sheet-open { overflow: hidden; }

a { color: var(--accent); }

/* ------------------------------------------------------------- top bar --- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--plane) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  padding: max(8px, env(safe-area-inset-top)) 14px 8px;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 640;
  letter-spacing: -.02em;
}

.locate {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
}
.locate:active { background: var(--wash); }
.locate[data-state="on"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.locate[data-state="busy"] svg { animation: spin 1s linear infinite; }
.locate svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }

@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .locate[data-state="busy"] svg { animation: none; } }

.search-wrap { position: relative; margin-top: 10px; }

.search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  fill: none; stroke: var(--ink-muted); stroke-width: 2; stroke-linecap: round;
  pointer-events: none;
}

#search {
  width: 100%;
  height: var(--tap);
  padding: 0 14px 0 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* 16px keeps iOS from zooming on focus */
}
#search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#search::-webkit-search-cancel-button { -webkit-appearance: none; }

.chips {
  display: flex;
  gap: 7px;
  margin-top: 9px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
}
.chip.is-on {
  background: var(--accent-wash);
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  color: var(--accent);
}
.chip-star { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; }
.chip.is-on .chip-star { fill: currentColor; }
.chips-sep { flex: 0 0 auto; width: 1px; margin: 6px 3px; background: var(--border); }

/* ---------------------------------------------------------------- list --- */

main { padding: 0 14px; }

.status, .empty {
  margin: 14px 2px;
  color: var(--ink-2);
  font-size: 14px;
}
.empty { text-align: center; padding: 32px 0; }

.list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }

.card {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.card:active { background: var(--wash); }

.badge {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 12px;
  font-weight: 680;
  font-size: 19px;
  line-height: 1;
  color: #fff;
  letter-spacing: -.01em;
}
.badge small { display: block; font-size: 10px; font-weight: 600; opacity: .92; margin-top: 2px; letter-spacing: 0; }
.badge[data-g="A"] { background: var(--grade-a); }
.badge[data-g="B"] { background: var(--grade-b); color: #0b0b0b; }
.badge[data-g="C"] { background: var(--grade-c); color: #0b0b0b; }
.badge[data-g="U"] { background: var(--grade-u); }

.card-main { min-width: 0; }
.card-name {
  display: block;
  font-weight: 580;
  font-size: 15.5px;
  letter-spacing: -.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-sub {
  display: block;
  margin-top: 2px;
  color: var(--ink-2);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-meta { text-align: right; color: var(--ink-muted); font-size: 12.5px; }
.card-dist { display: block; font-weight: 600; color: var(--ink-2); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.card-dist.is-approx::after { content: "~"; opacity: .6; }
.card-star { width: 13px; height: 13px; fill: currentColor; stroke: none; color: var(--ink-muted); vertical-align: -1px; margin-right: 3px; }

.sentinel { height: 1px; }

.foot {
  margin: 26px 0 0;
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  color: var(--ink-muted);
  font-size: 12.5px;
  line-height: 1.5;
}
.foot p { margin: 0 0 6px; }

/* --------------------------------------------------------------- sheet --- */

.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(11,11,11,.42); }

.sheet-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow);
  animation: rise .22s cubic-bezier(.22,.8,.3,1);
}
@keyframes rise { from { transform: translateY(14px); opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .sheet-panel { animation: none; } }
@media (min-width: 640px) {
  .sheet-panel { left: 50%; transform: translateX(-50%); width: 560px; border-radius: 20px; bottom: 3dvh; }
}

.sheet-grab { height: 20px; display: grid; place-items: center; flex: 0 0 auto; }
.sheet-grab::before { content: ""; width: 38px; height: 4px; border-radius: 2px; background: var(--axis); }

.sheet-head { display: flex; gap: 12px; align-items: flex-start; padding: 2px 16px 0; }
.sheet-head h2 { margin: 0; font-size: 19px; font-weight: 640; letter-spacing: -.015em; }
.sheet-addr {
  display: inline-block;
  margin: 3px 0 0;
  color: var(--ink-2);
  font-size: 13.5px;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.sheet-addr::after { content: " ↗"; color: var(--ink-muted); font-size: 11px; }
.sheet-addr:active { color: var(--accent); }

.icon-btn {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.sheet-actions { display: flex; gap: 8px; padding: 12px 16px 4px; }
.action {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 560;
  text-decoration: none;
  cursor: pointer;
}
.action:active { background: var(--wash); }
.action svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; }
.action[aria-pressed="true"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 42%, var(--border)); }
.action[aria-pressed="true"] svg { fill: currentColor; }

.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px calc(22px + env(safe-area-inset-bottom)); }

.sec-title {
  margin: 20px 0 8px;
  font-size: 11.5px;
  font-weight: 640;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.sec-title:first-child { margin-top: 4px; }

/* score history chart */
.chart { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
.chart .band-label { font-size: 9px; fill: var(--ink-muted); font-weight: 600; }
.chart .tick { font-size: 10px; fill: var(--ink-muted); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .trend { fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .dot-hit { fill: transparent; cursor: pointer; }
.chart .value-label { font-size: 11px; font-weight: 650; fill: var(--ink); }
.chart .band { opacity: .085; }

.history-note { margin: 6px 2px 0; color: var(--ink-muted); font-size: 12px; }

/* inspection list inside the sheet */
.insp { display: grid; gap: 6px; }
.insp-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.insp-row[aria-expanded="true"] { background: var(--wash); }
.insp-pill {
  display: grid; place-items: center;
  width: 34px; height: 26px;
  border-radius: 7px;
  font-size: 12.5px; font-weight: 680; color: #fff;
  font-variant-numeric: tabular-nums;
}
.insp-pill[data-g="A"] { background: var(--grade-a); }
.insp-pill[data-g="B"] { background: var(--grade-b); color: #0b0b0b; }
.insp-pill[data-g="C"] { background: var(--grade-c); color: #0b0b0b; }
.insp-pill[data-g="U"] { background: var(--grade-u); }
.insp-date { font-size: 14px; font-weight: 520; }
.insp-hint { color: var(--ink-muted); font-size: 12px; }

.detail { padding: 2px 4px 12px; }
.detail-loading { color: var(--ink-muted); font-size: 13px; padding: 8px 4px; }

.viol { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 5px; }
.viol li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--wash);
  font-size: 13.5px;
  line-height: 1.4;
}
.viol li.is-risk { background: color-mix(in srgb, var(--grade-u) 11%, transparent); }
.viol-code {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
}
.viol li.is-risk .viol-code { color: var(--grade-u); }
.viol-occ { color: var(--ink-muted); font-size: 12px; }

.risk-flag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 8px 0 2px;
  padding: 7px 10px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--grade-u) 12%, transparent);
  color: var(--grade-u);
  font-size: 12.5px;
  font-weight: 580;
}
.risk-flag svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; flex: 0 0 auto; }

.clean-flag { color: var(--ink-2); font-size: 13px; padding: 6px 2px; }
.form-link { display: inline-block; margin-top: 10px; font-size: 13px; }

/* alerts */
.alerts {
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--wash);
}
.alerts h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.alerts p { margin: 0 0 10px; color: var(--ink-2); font-size: 13px; line-height: 1.45; }
.alerts .action { flex: none; padding: 0 14px; }

/* ----------------------------------------------------- location picker --- */

.sheet-compact .sheet-body { padding-top: 16px; }

.action.wide { width: 100%; min-height: 46px; font-size: 15px; }

.loc-or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  color: var(--ink-muted);
  font-size: 12.5px;
}
.loc-or::before, .loc-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.loc-form { display: flex; gap: 8px; }
.loc-form input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--plane);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming on focus */
}
.loc-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.loc-form .action { flex: 0 0 auto; padding: 0 18px; min-height: 46px; }

.loc-msg { margin: 10px 2px 0; min-height: 18px; color: var(--ink-2); font-size: 13px; }
.loc-msg.is-error { color: var(--grade-u); }

.freshness { color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------------- map --- */
/* Two panes over one dataset: the list and the map render the same filtered,
   sorted rows. On a phone they swap (the floating pill toggles); from 980px up
   there is room for both, so the toggle disappears and they sit side by side.

   --topbar-h is measured in app.js rather than hard-coded: the top bar grows
   with the safe-area inset and with wrapped chips, and the map has to start
   exactly below it or it either overlaps or leaves a gap. */

:root { --topbar-h: 132px; }

main.panes { padding: 0; }
.pane-list { padding: 0 14px; }

.pane-map {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100dvh - var(--topbar-h));
  display: none;
}
.map { width: 100%; height: 100%; background: var(--grid); }

/* Bottom-of-map furniture stacks upward: view pill, home button, note. */
.pane-map { --stack-1: calc(18px + env(safe-area-inset-bottom));
            --stack-2: calc(72px + env(safe-area-inset-bottom));
            --stack-3: calc(126px + env(safe-area-inset-bottom)); }

body[data-view="map"] .pane-list,
body[data-view="map"] .foot { display: none; }
body[data-view="map"] .pane-map { display: block; }
body[data-view="map"] { overflow: hidden; }

/* The pill sits over the content rather than in the chips row: the chips strip
   scrolls horizontally, and a primary navigation control must not be able to
   scroll out of reach. Bottom-centre is also the reachable half of a phone. */
.viewfab {
  position: fixed;
  z-index: 30;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 580;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.viewfab:active { background: var(--wash); }
.viewfab svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; stroke-linecap: round; }
.viewfab .fab-list { display: none; }
.viewfab[aria-pressed="true"] .fab-list { display: block; }
.viewfab[aria-pressed="true"] .fab-map { display: none; }
body.sheet-open .viewfab { display: none; }

/* The pill floats over the end of the page — keep it off the footer text. */
.foot { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }

/* A count of what the map is actually showing. The map caps how many pins it
   draws, so this says so out loud rather than quietly dropping places. */
.map-note {
  position: absolute;
  z-index: 900;   /* over Leaflet's own controls, which sit at 800 */
  left: 10px; right: 10px;
  bottom: var(--stack-3);
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
}

@media (min-width: 980px) {
  main.panes {
    display: grid;
    grid-template-columns: minmax(340px, 440px) 1fr;
    gap: 0;
    align-items: start;
  }
  .pane-list { padding: 0 16px; }
  .pane-map, body[data-view="map"] .pane-map { display: block; border-left: 1px solid var(--border); }
  body[data-view="map"] .pane-list, body[data-view="map"] .foot { display: block; }
  body[data-view="map"] { overflow: visible; }
  .viewfab { display: none; }
  /* No view pill up here, so everything drops one rung. */
  .pane-map { --stack-2: 34px; --stack-3: 88px; }
  .map-note { left: 16px; right: 16px; }
  .foot { grid-column: 1 / -1; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}

/* -------------------------------------------------------------- leaflet --- */
/* Leaflet ships its own chrome; these bring it into the app's palette so the
   map doesn't read as a bolted-on iframe. */

.leaflet-container {
  font: inherit;
  font-size: 12px;
  background: var(--grid);
  outline-offset: -2px;
}
.leaflet-container a { color: var(--accent); }

/* OSM's raster tiles are a light-mode design. Inverting the tile pane alone
   (markers live in a different pane and are untouched) is the standard way to
   get a dark basemap without a second tile source and a second set of
   requests. The hue-rotate puts blues back to blue after the invert. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(.93) contrast(.9) saturate(.72);
  }
}

.leaflet-bar,
.leaflet-control-attribution {
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow) !important;
  background: color-mix(in srgb, var(--surface) 92%, transparent) !important;
  color: var(--ink-2) !important;
  overflow: hidden;
}
.leaflet-control-attribution {
  padding: 3px 8px;
  font-size: 10.5px;
  border-radius: 8px 0 0 0 !important;
  border-right: 0 !important;
  border-bottom: 0 !important;
}
.leaflet-bar a {
  background: transparent !important;
  color: var(--ink) !important;
  border-bottom-color: var(--border) !important;
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
  font-size: 18px;
}
.leaflet-bar a:hover, .leaflet-bar a:active { background: var(--wash) !important; }
.leaflet-bar a.leaflet-disabled { color: var(--ink-muted) !important; }

/* ----------------------------------------------------------------- pins --- */
/* Same letter-and-colour pairing as the list badges: the grade is written on
   the pin, so colour is never the only thing carrying it. */

.pin {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 50% 50% 50% 2px;
  transform: rotate(-45deg);
  border: 1.5px solid var(--surface);
  box-shadow: 0 1px 3px rgba(11,11,11,.4);
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  color: #fff;
  cursor: pointer;
}
.pin b { transform: rotate(45deg); font-weight: inherit; }
.pin[data-g="A"] { background: var(--grade-a); }
.pin[data-g="B"] { background: var(--grade-b); color: #0b0b0b; }
.pin[data-g="C"] { background: var(--grade-c); color: #0b0b0b; }
.pin[data-g="U"] { background: var(--grade-u); }
.pin.is-approx { border-style: dashed; opacity: .82; }
.pin.is-open { box-shadow: 0 0 0 3px var(--accent), 0 1px 3px rgba(11,11,11,.4); }
.pin-wrap { background: none; border: 0; }

/* Saved places get the star, with the grade written inside it -- bigger than a
   plain pin on purpose, so a handful of them stay findable in a field of
   hundreds. Colour still never carries the grade on its own. */
.pin-star { display: block; cursor: pointer; }
.pin-star svg { display: block; width: 38px; height: 38px; overflow: visible;
                filter: drop-shadow(0 1px 2px rgba(11,11,11,.45)); }
.pin-star path { stroke: var(--surface); stroke-width: 2.2; stroke-linejoin: round; }
.pin-star text { text-anchor: middle; font: 700 15px/1 system-ui, -apple-system, sans-serif; }
.pin-star[data-g="A"] path { fill: var(--grade-a); }
.pin-star[data-g="B"] path { fill: var(--grade-b); }
.pin-star[data-g="C"] path { fill: var(--grade-c); }
.pin-star[data-g="U"] path { fill: var(--grade-u); }
.pin-star[data-g="A"] text, .pin-star[data-g="U"] text { fill: #fff; }
.pin-star[data-g="B"] text, .pin-star[data-g="C"] text { fill: #0b0b0b; }
.pin-star.is-approx path { stroke-dasharray: 3 2.5; }
.pin-star.is-open svg { filter: drop-shadow(0 0 3px var(--accent)) drop-shadow(0 0 3px var(--accent)); }

/* Home: where the sorting is measured from. Draggable, and deliberately not
   blue -- the blue dot below is the device's own idea of where you are. */
.home-pin {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 50% 50% 50% 2px;
  transform: rotate(-45deg);
  background: var(--ink);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(11,11,11,.45);
  cursor: grab;
}
.home-pin svg {
  transform: rotate(45deg);
  width: 15px; height: 15px;
  fill: none; stroke: var(--surface);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.leaflet-drag-target .home-pin { cursor: grabbing; }

/* Leaflet writes stroke/fill as presentation attributes, which can't hold a
   custom property — a class can, and CSS beats a presentation attribute. */
.approx-halo { stroke: var(--accent); fill: var(--accent); }

/* The device's actual fix. Not draggable, not the sort origin -- just a
   standing answer to "and where am I?" while you look somewhere else. */
.you-pin {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border), 0 0 0 7px var(--accent-wash),
              0 1px 5px rgba(11,11,11,.3);
}

/* ---- the centre crosshair, and the button that commits it --------------- */

.crosshair {
  position: absolute;
  z-index: 700;
  left: 50%; top: 50%;
  width: 40px; height: 40px;
  margin: -20px 0 0 -20px;
  pointer-events: none;
}
.crosshair svg {
  width: 100%; height: 100%;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linecap: round;
  opacity: .62;
  /* A pale outline keeps it legible over dark parkland and pale roads alike. */
  paint-order: stroke;
  filter: drop-shadow(0 0 1.5px var(--surface)) drop-shadow(0 0 1.5px var(--surface));
}
.crosshair .crosshair-dot { fill: var(--ink); stroke: none; }

.sethome {
  position: absolute;
  z-index: 900;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--stack-2);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 570;
  white-space: nowrap;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.sethome:active { background: var(--wash); }
.sethome svg { width: 15px; height: 15px; fill: none; stroke: currentColor;
               stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sethome.is-done { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 42%, var(--border)); }

/* ------------------------------------------------------- sheet mini-map --- */

.sheet-map {
  display: block;
  position: relative;
  height: 150px;
  margin: 0 0 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--grid);
  text-decoration: none;
}
.sheet-map-canvas { position: absolute; inset: 0; display: block; pointer-events: none; }
.sheet-map-canvas .leaflet-container { background: var(--grid); }
.sheet-map-canvas .leaflet-control-attribution { pointer-events: auto; }
.sheet-map-hit { position: absolute; inset: 0 0 17px 0; display: block; }
.sheet-map-tag {
  position: absolute;
  z-index: 500;
  left: 8px; bottom: 8px;
  padding: 4px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 560;
}
.sheet-map-tag::after { content: " ↗"; color: var(--ink-muted); }
.sheet-map-hit:active { background: var(--accent-wash); }
