/* melon-seek viz: salary landscape chart (.ms-chart), job map (.ms-map) and
   the shared hover tooltip (.ms-viz-tip). Self-contained; consumes the app's
   --ms-* tokens when present and falls back to its own light/dark values. */

/* DES-12: one source for every fallback token. Colors use light-dark(), driven by
   color-scheme; the few non-color tweaks scale with a 0/1 dark flag (--_d). The only
   per-theme rules left are the two-line switches below (OS setting and data-theme). */
.ms-chart, .ms-map, .ms-viz-tip, .ms-comps {
  --_d: 0;
  color-scheme: light;
  --_bg: var(--ms-bg, light-dark(#f9f9f7, #0d0d0d));
  --_surface: var(--ms-surface, light-dark(#fcfcfb, #1a1a19));
  --_text: var(--ms-text, light-dark(#0b0b0b, #ffffff));
  --_muted: var(--ms-muted, light-dark(#5f5e5a, #a9a89f));
  --_border: var(--ms-border, light-dark(#e1e0d9, #2c2c2a));
  --_accent: var(--ms-accent, light-dark(#0b7a5c, #3ccf9a));
  --_grid: color-mix(in srgb, var(--_border) 75%, var(--_surface));
  --_axis: color-mix(in srgb, var(--_muted) 45%, var(--_surface));
  --_wash: color-mix(in srgb, var(--_text) 5%, transparent);
  --_wash-strong: var(--ms-accent-soft, color-mix(in srgb, var(--_accent) 13%, transparent));
  --_radius: var(--ms-radius, 10px);
  --_radius-sm: var(--ms-radius-sm, 7px);
  --_tip-bg: var(--ms-raised, var(--ms-surface, light-dark(#ffffff, #242423)));
  --_shadow: var(--ms-shadow-lg, 0 1px 2px light-dark(rgba(11, 11, 11, .06), rgba(0, 0, 0, .4)), 0 6px 22px light-dark(rgba(11, 11, 11, .10), rgba(0, 0, 0, .45)));
  --_map-bg: color-mix(in srgb, var(--_bg) calc(88% - 3% * var(--_d)), light-dark(#c9d6e3, #22303d));
  --_map-line: color-mix(in srgb, var(--_border) calc(80% - 10% * var(--_d)), light-dark(#9fb2c6, #3a4b5c));
  /* non-color dark tweaks: translucent fills go muddy on dark, so lift them */
  --_bar-o: calc(.5 + .22 * var(--_d));
  --_hist-o: calc(.42 + .2 * var(--_d));
  --_hist-o-c: calc(.26 + .16 * var(--_d));
  --_bin-mix: calc(30% + 22% * var(--_d));
  --_band-mix: calc(9% + 7% * var(--_d));
  --_font: var(--ms-font, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) :is(.ms-chart, .ms-map, .ms-viz-tip, .ms-comps) { --_d: 1; color-scheme: dark; }
}
:root[data-theme="dark"] :is(.ms-chart, .ms-map, .ms-viz-tip, .ms-comps) { --_d: 1; color-scheme: dark; }

/* ============================== chart ============================== */

.ms-chart {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  background: var(--_surface);
  color: var(--_text);
  font: 12px/1.35 var(--_font);
  -webkit-font-smoothing: antialiased;
}
.ms-chart *, .ms-chart *::before, .ms-chart *::after { box-sizing: border-box; }

.ms-chart__head {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 16px 8px;
}
.ms-chart__legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
}
.ms-chart__legend[hidden] { display: none; }
.ms-legend__title { color: var(--_muted); font-weight: 500; margin-right: 2px; }
.ms-legend__item { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; white-space: nowrap; }
.ms-legend__swatch { flex: none; width: 10px; height: 10px; border-radius: 2px; }
.ms-legend__key { overflow: hidden; text-overflow: ellipsis; color: var(--_text); }
.ms-legend__n { color: var(--_muted); font-variant-numeric: tabular-nums; }

.ms-chart__head[hidden] { display: none; }

/* One muted notes line under the chart. */
.ms-chart__foot {
  flex: none;
  padding: 8px 16px 10px;
  border-top: 1px solid var(--_border);
  color: var(--_muted);
  font-size: 11.5px;
  line-height: 1.4;  /* wraps rather than truncating: every note carries a number */
}
.ms-chart__foot[hidden] { display: none; }
.ms-chart--narrow .ms-chart__foot { white-space: normal; padding-left: 12px; padding-right: 12px; }

.ms-chart__scroll {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.ms-chart--flow .ms-chart__scroll { overflow: visible; }
.ms-chart__scroll[hidden] { display: none; }

.ms-chart__sticky {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--_surface);
  border-bottom: 1px solid var(--_border);
}

.ms-chart__hist { position: relative; }
.ms-hist__cap {
  position: absolute; left: 0; bottom: 3px;
  padding-left: 16px;
  line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ms-hist__title { color: var(--_muted); }
.ms-hist__sub { color: var(--_text); font-weight: 600; }
.ms-hist__bin {
  position: absolute;
  bottom: 0;
  background: var(--_accent);
  opacity: var(--_hist-o, .42);
  border-radius: 2px 2px 0 0;
  cursor: default;
  transition: opacity .12s;
}
.ms-hist__bin.is-hover { opacity: .9; }
.ms-hist__bin::after { content: ""; position: absolute; inset: -12px -1px 0; } /* bigger hit target */
.ms-hist__median {
  position: absolute; top: 4px; bottom: 0; width: 0;
  border-left: 1px solid var(--_text);
  opacity: .55;
  pointer-events: none;
}

.ms-chart__axis {
  position: relative;
  height: 24px;
  border-top: 1px solid var(--_axis);
}
.ms-axis__cap {
  position: absolute; left: 0; top: 0; bottom: 0;
  display: flex; align-items: center;
  padding-left: 16px;
  color: var(--_muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ms-axis__tick {
  position: absolute;
  top: 5px;
  transform: translateX(-50%);
  color: var(--_muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ms-axis__tick--start { transform: translateX(-4px); }
.ms-axis__tick--end { transform: translateX(calc(-100% + 4px)); }

.ms-chart__body { position: relative; outline: none; padding-bottom: 8px; }
.ms-chart__body:focus-visible { box-shadow: inset 0 0 0 2px var(--_accent); }
.ms-chart__grid { position: absolute; inset: 0; pointer-events: none; }
.ms-chart__gridline { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--_grid); }
.ms-chart__median {
  position: absolute; width: 0;
  border-left: 1px solid var(--_muted);
  opacity: .5;
}
.ms-chart__rows { position: relative; }
/* PERF-2: rows are windowed and absolutely positioned at their precomputed y. */
.ms-chart__rows > .ms-row, .ms-chart__rows > .ms-crow, .ms-chart__rows > .ms-group { position: absolute; left: 0; right: 0; }

.ms-group {
  position: relative;
  display: flex;
  align-items: flex-end;
  padding-bottom: 5px;
  border-top: 1px solid var(--_border);
}
.ms-group--first { border-top: 0; }
.ms-group__name {
  display: flex; align-items: baseline; gap: 6px;
  padding-left: 16px; padding-right: 8px;
  min-width: 0;
  white-space: nowrap;
}
.ms-group__title { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.ms-group__count { color: var(--_muted); font-variant-numeric: tabular-nums; }
.ms-group__median {
  position: absolute; bottom: 5px;
  padding-left: 6px;
  color: var(--_muted);
  white-space: nowrap;
}
.ms-group__median--left { transform: translateX(-100%); padding: 0 6px 0 0; }

.ms-row {
  position: relative;
  cursor: pointer;
}
.ms-row::before { /* hover wash spans the full row */
  content: ""; position: absolute; inset: 1px 0;
  border-radius: 4px;
  pointer-events: none;
}
.ms-row.is-hover::before { background: var(--_wash); }
.ms-row.is-active::before { box-shadow: inset 0 0 0 2px var(--_accent); } /* >= 3:1 vs surface (4.3:1 light, 4.8:1 dark) */
.ms-row.is-highlighted::before { background: var(--_wash-strong); }
.ms-row__label {
  position: absolute; left: 0; top: 0; bottom: 0;
  display: flex; align-items: center;
  padding-left: 16px; padding-right: 10px;
  overflow: hidden;
  color: var(--_muted);
  white-space: nowrap;
}
.ms-row__label { text-overflow: ellipsis; display: block; line-height: 22px; }
.ms-row.is-hover .ms-row__label, .ms-row.is-highlighted .ms-row__label { color: var(--_text); }
.ms-row.is-highlighted .ms-row__label { font-weight: 600; }
.ms-row__bar {
  position: absolute; top: 50%;
  height: 8px; margin-top: -4px;
  min-width: 2px;
  border-radius: 4px;
  background: var(--_accent);
  opacity: var(--_bar-o, .5);
  transition: opacity .12s;
}
.ms-row__dot {
  position: absolute; top: 50%;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--_accent);
  box-shadow: 0 0 0 2px var(--_surface);
}
.ms-row.is-hover .ms-row__bar, .ms-row.is-highlighted .ms-row__bar { opacity: .95; }
.ms-row__val {
  position: absolute; top: 0; line-height: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--_text);
  white-space: nowrap;
  pointer-events: none;
  visibility: hidden;
}
.ms-row.is-hover .ms-row__val, .ms-row.is-highlighted .ms-row__val { visibility: visible; }
.ms-row__bar[hidden], .ms-row__dot[hidden] { display: none; }
/* Axis-overflow chevrons (ranges): the bar continues beyond the domain. */
.ms-row__over {
  position: absolute; top: 0; width: 8px;
  line-height: 22px; text-align: center;
  color: var(--_muted); font-weight: 700; font-size: 13px;
  pointer-events: none;
}
.ms-row.is-hover .ms-row__over, .ms-row.is-highlighted .ms-row__over { color: var(--_text); }

.ms-chart--narrow .ms-row__label, .ms-chart--narrow .ms-group__name,
.ms-chart--narrow .ms-axis__cap, .ms-chart--narrow .ms-hist__cap { padding-left: 12px; }
.ms-chart--narrow .ms-chart__head { padding-left: 12px; padding-right: 12px; }

.ms-chart__empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 48px 16px;
  text-align: center;
}
.ms-chart__empty[hidden] { display: none; }
.ms-chart__empty-title { font-size: 14px; font-weight: 600; }
.ms-chart__empty-sub { color: var(--_muted); }

/* ---------- clusters view ---------- */
.ms-chart--clusters .ms-chart__sticky { border-bottom-color: var(--_grid); }
.ms-chart--clusters .ms-hist__bin { opacity: var(--_hist-o-c, .26); }
.ms-chart--clusters .ms-hist__bin.is-hover { opacity: .7; }
.ms-chart--clusters .ms-chart__body { padding-bottom: 4px; }

.ms-crow {
  --c: var(--_accent);
  --c-ink: #fff;
  position: relative;
  border-bottom: 1px solid var(--_grid);
}
.ms-crow--last { border-bottom: 0; }
/* Rows beyond the 8 palette slots are neutral; lift their tint so circles never read as holes. */
.ms-crow--other { --_bin-mix: calc(42% + 18% * var(--_d)); --_band-mix: calc(7% + 4% * var(--_d)); }
.ms-crow.is-selected { background: color-mix(in srgb, var(--c) 6%, transparent); }

.ms-crow__label {
  position: absolute; left: 0; top: 0; bottom: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px 0 16px;
  min-width: 0;
  cursor: pointer;
  border-radius: 6px;
  outline: none;
}
.ms-crow__swatch {
  flex: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c);
}
.ms-crow__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.ms-crow__name {
  font-size: 13px; font-weight: 600; color: var(--_text); line-height: 1.22;
  /* up to two lines; the column is sized so the subtitle never needs to truncate */
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden; overflow-wrap: anywhere;
}
.ms-crow__sub {
  color: var(--_muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;   /* never truncated: the JS picks the short "69 · $512K" form when needed */
}
.ms-crow__label:hover .ms-crow__name { text-decoration: underline; text-decoration-color: var(--_axis); text-underline-offset: 3px; }
.ms-crow.is-selected .ms-crow__name { text-decoration: underline; text-decoration-color: var(--c); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.ms-crow__label.is-active { box-shadow: inset 0 0 0 2px var(--_accent); }

.ms-chart--narrow .ms-crow__label {
  right: 0; bottom: auto; height: 22px;
  padding: 0 12px; gap: 8px;
  align-items: flex-end;
}
.ms-chart--narrow .ms-crow__text { flex-direction: row; align-items: baseline; gap: 8px; min-width: 0; }
.ms-chart--narrow .ms-crow__name { display: block; flex: 0 1 auto; min-width: 0; white-space: nowrap; text-overflow: ellipsis; }
.ms-chart--narrow .ms-crow__sub { flex: none; }

.ms-crow__plot { position: absolute; left: 0; right: 0; pointer-events: none; } /* spans the row; only circles take the pointer, so the label stays clickable */
.ms-crow__plot .ms-bin { pointer-events: auto; }
.ms-crow__band {
  position: absolute; top: 50%;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) var(--_band-mix, 9%), var(--_surface));
}
.ms-crow__median {
  position: absolute; top: 50%;
  width: 2px; margin-left: -1px;
  border-radius: 1px;
  background: var(--_text);
  opacity: .38;
  pointer-events: none;
}
.ms-crow__none {
  position: absolute; top: 50%; transform: translateY(-50%);
  color: var(--_muted);
  font-style: italic;
}

.ms-bin {
  position: absolute; top: 50%;
  display: flex; align-items: center; justify-content: center;
  transform: translateY(-50%);
  cursor: pointer;
  outline: none;
}
.ms-bin__dot {
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  --ring: var(--_surface);
  background: color-mix(in srgb, var(--c) var(--_bin-mix, 30%), var(--_surface));
  box-shadow: 0 0 0 2px var(--ring);
  color: var(--c-rest-ink, var(--_text)); /* A11Y-1: ink chosen in JS from the actual mixed fill */
  font-size: 11px; font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: background-color .12s, color .12s, transform .12s;
}
.ms-bin__dot--sm { font-size: 10px; }
/* Axis-overflow marker (clusters): a small neutral chip at the axis edge, "›3". */
.ms-bin__chip {
  width: auto !important; height: 18px !important;
  min-width: 18px; padding: 0 5px;
  border-radius: 9px;
  background: var(--_surface);
  box-shadow: 0 0 0 1px var(--_axis);
  color: var(--_muted);
  font-size: 11px; font-weight: 700;
}
.ms-bin--overflow.is-hover .ms-bin__chip,
.ms-bin--overflow.is-selected .ms-bin__chip,
.ms-bin--overflow.is-highlighted .ms-bin__chip { background: var(--c); color: var(--c-ink); box-shadow: 0 0 0 1px var(--c); }
.ms-bin--overflow.is-active .ms-bin__chip { box-shadow: 0 0 0 2px var(--_accent); }
/* Inside the P25–P75 band the 2px ring takes the band's tint, so circles never sit in a dark "socket". */
.ms-bin--inband .ms-bin__dot { --ring: color-mix(in srgb, var(--c) var(--_band-mix, 9%), var(--_surface)); }
.ms-bin.is-hover .ms-bin__dot,
.ms-bin.is-selected .ms-bin__dot,
.ms-bin.is-highlighted .ms-bin__dot { background: var(--c); color: var(--c-ink); }
.ms-bin.is-hover .ms-bin__dot { transform: scale(1.06); }
.ms-bin.is-selected .ms-bin__dot { box-shadow: 0 0 0 2px var(--ring), 0 0 0 3.5px var(--c); }
.ms-bin.is-highlighted .ms-bin__dot { box-shadow: 0 0 0 2px var(--ring), 0 0 0 4px var(--_text); }
.ms-bin.is-active .ms-bin__dot { box-shadow: 0 0 0 2px var(--ring), 0 0 0 4px var(--_accent); }
@media (prefers-reduced-motion: reduce) { .ms-bin__dot { transition: none; } .ms-bin.is-hover .ms-bin__dot { transform: none; } }

/* ============================== tooltip ============================== */

.ms-viz-tip {
  position: fixed; left: 0; top: 0;
  z-index: 10000;
  max-width: 300px;
  padding: 8px 10px;
  border-radius: var(--_radius-sm);
  border: 1px solid var(--_border);
  background: var(--_tip-bg);
  color: var(--_text);
  box-shadow: var(--_shadow);
  font: 12px/1.4 var(--_font);
  pointer-events: none;
}
.ms-viz-tip[hidden] { display: none; }
.ms-tip__value { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ms-tip__sub { color: var(--_muted); font-variant-numeric: tabular-nums; }
.ms-tip__title { margin-top: 4px; font-weight: 600; }
.ms-tip__meta { color: var(--_muted); }
.ms-tip__roles { list-style: none; margin: 6px 0 0; padding: 6px 0 0; border-top: 1px solid var(--_border); }
.ms-tip__roles li { display: flex; gap: 8px; justify-content: space-between; }
.ms-tip__role { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-tip__n { flex: none; color: var(--_muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ============================== map ============================== */

.ms-map {
  position: relative;
  height: 100%;
  min-height: 320px;
  background: var(--_map-bg);
  color: var(--_text);
  font: 12px/1.35 var(--_font);
  overflow: hidden;
}
.ms-map__canvas { position: absolute; inset: 0; }
.ms-map .leaflet-container {
  background: var(--_map-bg);
  font: inherit;
  outline: none;
}
/* OSM has no dark layer: invert the tile pane only (never the pins or controls). */
.ms-map--dark .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9); }
/* Tiles that "loaded" but are provider error images are hidden; the fallback shows instead. */
.ms-map--tiles-bad .leaflet-tile-pane { visibility: hidden; }
.ms-map .ms-graticule-line { stroke: var(--_map-line); stroke-opacity: .55; fill: none; }

/* Leaflet chrome */
.ms-map .leaflet-bar { border: 1px solid var(--_border); border-radius: var(--_radius-sm); box-shadow: var(--_shadow); overflow: hidden; }
.ms-map .leaflet-bar a {
  background: var(--_surface); color: var(--_text); border-bottom-color: var(--_border);
  width: 30px; height: 30px; line-height: 30px;
}
.ms-map .leaflet-bar a:hover { background: color-mix(in srgb, var(--_text) 6%, var(--_surface)); }
.ms-map .leaflet-bar a.leaflet-disabled { color: var(--_muted); opacity: .5; }
.ms-map .leaflet-control-attribution {
  background: color-mix(in srgb, var(--_surface) 80%, transparent);
  color: var(--_muted); font-size: 10px;
}
.ms-map .leaflet-control-attribution a { color: var(--_muted); }

/* Price-tag pins */
.ms-map .ms-pin-icon { background: none; border: 0; }
.ms-pin {
  --pin-bg: var(--_accent);
  --pin-fg: #fff;
  position: absolute;
  left: 0; top: 0;
  transform: translate(-50%, calc(-100% - 7px));
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: 12px;
  background: var(--pin-bg);
  color: var(--pin-fg);
  font: 700 12px/1 var(--_font);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: 0 0 0 2px var(--_surface), 0 2px 6px rgba(0, 0, 0, .22);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  transform-origin: 50% calc(100% + 7px);
}
.ms-pin::after { /* pointer */
  content: "";
  position: absolute; left: 50%; bottom: -6px;
  width: 10px; height: 10px; margin-left: -5px;
  background: var(--pin-bg);
  transform: rotate(45deg);
  border-radius: 0 0 2px 0;
  box-shadow: 2px 2px 0 0 var(--_surface);
  z-index: -1;
}
.ms-pin__count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 4px;
  margin-right: -5px;
  border-radius: 9px;
  background: var(--_surface);
  color: var(--_text);
  font-size: 10.5px; font-weight: 600;
}
.ms-pin--nosalary {
  --pin-bg: var(--_surface);
  --pin-fg: var(--_text);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--_axis), 0 2px 6px rgba(0, 0, 0, .18);
}
.ms-pin--nosalary::after { box-shadow: 1px 1px 0 0 var(--_axis); }
.ms-pin.is-hover { transform: translate(-50%, calc(-100% - 7px)) scale(1.1); box-shadow: 0 0 0 2px var(--_surface), 0 4px 12px rgba(0, 0, 0, .3); }
.ms-pin__label {
  position: absolute; left: 50%; top: calc(100% + 9px);
  transform: translateX(-50%);
  display: none;
  padding: 1px 5px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--_surface) 82%, transparent);
  color: var(--_text);
  font-size: 10.5px; font-weight: 500;
  pointer-events: none;
}
/* Offline: no basemap, so name the places under the pins. */
.ms-map--offline .ms-pin__label { display: block; }
.ms-map__offline-note {
  display: none;
  padding: 4px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--_surface) 90%, transparent);
  border: 1px solid var(--_border);
  color: var(--_muted);
  font-size: 11px;
}
.ms-map--offline .ms-map__offline-note { display: block; }

.ms-map .ms-pin-icon { outline: none; }
.ms-map .ms-pin-icon:focus-visible .ms-pin { box-shadow: 0 0 0 2px var(--_surface), 0 0 0 4px var(--_accent), 0 2px 6px rgba(0, 0, 0, .22); }
.ms-pin.is-pulse { box-shadow: 0 0 0 2px var(--_surface), 0 0 0 4px var(--_text); animation: ms-pulse 1.4s ease-out infinite; }
@keyframes ms-pulse {
  0%   { box-shadow: 0 0 0 2px var(--_surface), 0 0 0 4px var(--_text), 0 0 0 4px color-mix(in srgb, var(--_accent) 50%, transparent); }
  100% { box-shadow: 0 0 0 2px var(--_surface), 0 0 0 4px var(--_text), 0 0 0 16px transparent; }
}
@media (prefers-reduced-motion: reduce) { .ms-pin.is-pulse { animation: none; } }

/* "Pay | Juice" segmented control + Juice legend */
.ms-map .ms-modes {
  display: flex; flex-direction: column; gap: 6px;
  padding: 4px;
  border: 1px solid var(--_border);
  border-radius: var(--_radius);
  background: var(--_surface);
  color: var(--_text);
  box-shadow: var(--_shadow);
  font: 12px/1.3 var(--_font);
}
.ms-modes__seg { display: flex; gap: 2px; padding: 2px; border-radius: 7px; background: color-mix(in srgb, var(--_text) 6%, var(--_surface)); }
.ms-map .ms-modes__btn {
  flex: 1;
  min-width: 52px; height: 26px; padding: 0 10px;
  border: 0; border-radius: 5px;
  background: transparent;
  color: var(--_muted);
  font: 600 12px/1 var(--_font);
  cursor: pointer;
}
.ms-map .ms-modes__btn:hover { color: var(--_text); }
.ms-map .ms-modes__btn.is-on { background: var(--_surface); color: var(--_text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 0 0 1px var(--_border); }
.ms-map .ms-modes__btn:focus-visible { outline: 2px solid var(--_accent); outline-offset: 1px; }
.ms-modes__legend { display: none; padding: 2px 6px 4px; }
.ms-modes--juice .ms-modes__legend { display: grid; gap: 3px; }
.ms-modes__key { display: grid; grid-template-columns: 10px auto auto; align-items: center; gap: 6px; }
.ms-modes__sw { width: 10px; height: 10px; border-radius: 3px; }
.ms-modes__grade { font-weight: 600; white-space: nowrap; }
.ms-modes__net { color: var(--_muted); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.ms-modes__none { color: var(--_muted); font-size: 11px; }
.ms-pin--juice .ms-pin__price { letter-spacing: .01em; }

/* Remote control */
.ms-map .ms-remote {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--_border);
  border-radius: 16px;
  background: var(--_surface);
  color: var(--_text);
  font: 600 12px/1 var(--_font);
  box-shadow: var(--_shadow);
  cursor: pointer;
}
.ms-map .ms-remote[hidden] { display: none; }
.ms-map .ms-remote:hover { background: color-mix(in srgb, var(--_text) 5%, var(--_surface)); }
.ms-map .ms-remote:focus-visible { outline: 2px solid var(--_accent); outline-offset: 2px; }
.ms-remote__n { color: var(--_muted); font-weight: 500; }
.ms-remote__n::before, .ms-remote__price::before { content: "·"; margin-right: 6px; color: var(--_muted); }
.ms-remote.is-pulse { box-shadow: 0 0 0 2px var(--_text), var(--_shadow); }

/* Map tooltip */
.ms-map .leaflet-tooltip.ms-map-tip {
  padding: 8px 10px;
  max-width: 280px;
  min-width: 180px;
  white-space: normal;
  border-radius: var(--_radius-sm);
  border: 1px solid var(--_border);
  background: var(--_tip-bg, var(--_surface));
  color: var(--_text);
  box-shadow: var(--_shadow);
  font: 12px/1.4 var(--_font);
}
.ms-map .leaflet-tooltip-top.ms-map-tip::before { border-top-color: var(--_tip-bg, var(--_surface)); }

/* ============================== comps (same role elsewhere) ============================== */

.ms-comps {
  position: relative;
  min-width: 0;
  color: var(--_text);
  font: 12px/1.35 var(--_font);
}
.ms-comps *, .ms-comps *::before, .ms-comps *::after { box-sizing: border-box; }
.ms-comps__axis { position: relative; height: 20px; }
.ms-comps__tick {
  position: absolute; bottom: 3px;
  transform: translateX(-50%);
  color: var(--_muted); font-size: 10.5px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ms-comps__list { position: relative; outline: none; border-top: 1px solid var(--_border); }
.ms-comps__list:focus-visible { box-shadow: 0 0 0 2px var(--_accent); border-radius: 4px; }
.ms-comps__grid { position: absolute; inset: 0; pointer-events: none; }
.ms-comps__gridline { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--_grid); }
.ms-comps__row { --c: var(--_accent); position: relative; cursor: pointer; }
.ms-comps__row::before { content: ""; position: absolute; inset: 2px 0; border-radius: 5px; pointer-events: none; }
.ms-comps__row.is-hover::before { background: var(--_wash); }
.ms-comps__row.is-current::before { background: var(--_wash-strong); }
.ms-comps__row.is-active::before { box-shadow: inset 0 0 0 2px var(--_accent); }
.ms-comps__name {
  position: absolute; left: 0; top: 0; bottom: 0;
  display: flex; align-items: center; gap: 7px;
  padding: 0 6px 0 6px; min-width: 0;
}
.ms-comps__sw { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.ms-comps__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--_text); }
.ms-comps__n { flex: none; color: var(--_muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ms-comps__row.is-current .ms-comps__label { font-weight: 700; }
.ms-comps--narrow .ms-comps__n { display: none; } /* count stays in the tooltip and option name */
.ms-comps__bar {
  position: absolute; top: 50%;
  height: 8px; margin-top: -4px;
  border-radius: 4px;
  background: var(--c);
  opacity: var(--_bar-o, .5);
}
.ms-comps__row.is-current .ms-comps__bar, .ms-comps__row.is-hover .ms-comps__bar { opacity: .95; }
.ms-comps__median {
  position: absolute; top: 50%;
  width: 3px; height: 16px; margin: -8px 0 0 -1.5px;
  border-radius: 2px;
  background: var(--c);
  box-shadow: 0 0 0 2px var(--_surface);
}
.ms-comps__row.is-current .ms-comps__median { background: var(--_text); }
.ms-comps__val {
  position: absolute; right: 0; top: 0; bottom: 0;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 6px;
  color: var(--_muted); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ms-comps__row.is-current .ms-comps__val, .ms-comps__row.is-hover .ms-comps__val { color: var(--_text); font-weight: 600; }
.ms-comps__over { position: absolute; top: 0; line-height: 28px; color: var(--_muted); font-weight: 700; pointer-events: none; }
.ms-comps__nodata { position: absolute; top: 0; line-height: 28px; color: var(--_muted); font-style: italic; }
.ms-comps__empty { padding: 12px 6px; color: var(--_muted); }
.ms-comps__note { padding: 6px 6px 0; color: var(--_muted); font-size: 11px; }


/* ============================== phones (<= 860px) ==============================
   docs/QA.md "Full QA pass (mobile)": M-8 (44px touch targets, by hit slop where the
   visual stays small), M-13 (12px text floor), M-17 (Ranges titles readable). Desktop
   density is unchanged: everything here is inside the phone breakpoint. */

/* Ranges, narrow: the title gets its own full-width line above the bar (chart.js ms-chart--stack, 44px rows). */
.ms-chart--stack .ms-row__label { right: 0; bottom: auto; height: 20px; line-height: 20px; padding: 0 12px; }
.ms-chart--stack .ms-row__bar, .ms-chart--stack .ms-row__dot { top: 32px; }
.ms-chart--stack .ms-row__val, .ms-chart--stack .ms-row__over { top: 20px; line-height: 24px; }
.ms-chart--stack .ms-row::before { inset: 1px 4px; }
.ms-chart--stack .ms-group__name { max-width: calc(100% - 124px); padding-left: 12px; }
.ms-chart--stack .ms-group__title { min-width: 0; }
.ms-chart--stack .ms-group__median, .ms-chart--stack .ms-group__median--left { left: auto !important; right: 12px; transform: none; padding: 0; }

@media (max-width: 860px) {
  /* Cluster circles: a 44px-tall slop, as wide as the bin spacing allows (--ms-bin-slop, chart.js). */
  .ms-bin::before { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, var(--ms-bin-slop, 34px)); height: max(100%, 44px); transform: translate(-50%, -50%); }

  /* Map controls: zoom ± 30px and Pay|Juice 26px tall look the same, but take a 44px tap. */
  .ms-map .leaflet-bar { overflow: visible; }
  .ms-map .leaflet-bar a { position: relative; }
  .ms-map .leaflet-bar a:first-child { border-radius: var(--_radius-sm) var(--_radius-sm) 0 0; }
  .ms-map .leaflet-bar a:last-child { border-radius: 0 0 var(--_radius-sm) var(--_radius-sm); }
  .ms-map .leaflet-bar a::after { content: ""; position: absolute; inset: 0 -7px; }
  .ms-map .leaflet-bar a:first-child::after { top: -14px; }
  .ms-map .leaflet-bar a:last-child::after { bottom: -14px; }
  .ms-map .leaflet-top .leaflet-control-zoom { margin-top: 14px; }
  .ms-map .ms-modes__btn { position: relative; }
  .ms-map .ms-modes__btn::after { content: ""; position: absolute; inset: -9px 0; }
  .ms-map .ms-remote { position: relative; }
  .ms-map .ms-remote::after { content: ""; position: absolute; inset: -7px -1px; }   /* from the padding box: 30 + 14 */

  /* Same role elsewhere: 44px rows (comps.js sets --ms-comps-row). */
  .ms-comps__over, .ms-comps__nodata { line-height: var(--ms-comps-row, 28px); }

  /* 12px text floor */
  .ms-chart__foot, .ms-bin__dot, .ms-bin__dot--sm, .ms-bin__chip,
  .ms-map .leaflet-control-attribution, .ms-pin__count, .ms-pin__label, .ms-map__offline-note, .ms-modes__none,
  .ms-comps__tick, .ms-comps__n, .ms-comps__note { font-size: 12px; }
  .ms-bin__dot--sm { letter-spacing: -.03em; }

  /* M-10: landscape notch: Leaflet controls stay inside the safe area (the map itself stays full-bleed). */
  .ms-map .leaflet-left { left: env(safe-area-inset-left, 0px); }
  .ms-map .leaflet-right { right: env(safe-area-inset-right, 0px); }
}
