.workspace {
  display: grid;
  align-items: start;
}

.map-panel {
  position: relative;
  overflow: hidden;
  /* Backwards fill only: a held translateY(0) would keep the panel a stacking
     context, trapping header popovers (Settings, Line, Depart) under the
     981–1120px dossier. */
  animation: page-in var(--motion-duration-scene) var(--motion-duration-micro) var(--ease) backwards;
}

@media (max-width: 980px) {
  /* The fixed mobile sheet is framed by this panel, inside the page gutter,
     so the panel stays its containing block on small screens. */
  .map-panel {
    transform: translateY(0);
  }
}

body.is-map-active .map-panel {
  container: map-panel / inline-size;
}

.map-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  display: block;
  z-index: 0;
  pointer-events: none;
}

.map-frame {
  /* Keep transient map pixels below canvas annotations and every DOM control. */
  --map-z-preview: 1;
  --map-z-annotations: 3;
  --map-z-chrome: 4;
  position: relative;
  contain: layout paint;
  /* Focus must not scroll the retained canvas margin or displace map tools. */
  overflow: clip;
  overscroll-behavior: contain;
  touch-action: none;
}

/* The plate is the frame's paper. Painting canvases too made every layered
 * canvas opaque, so the top layer hid the heat and lines beneath it. */
body.is-rail-plate .map-frame {
  background: #f1ecde;
}

body.is-inspect-mode .map-frame {
  background: #e8ebe7;
}

.map-frame::before,
.map-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  display: block;
  z-index: 2;
  pointer-events: none;
}

.map-paper-grain {
  position: absolute;
  inset: 0;
  z-index: 2;
  contain: paint;
  pointer-events: none;
  opacity: var(--paper-grain-map-opacity);
  background-image: var(--paper-grain-image);
  background-position: 0 0;
  background-repeat: repeat;
  background-size: var(--paper-grain-size);
}

.map-daypart-tint {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0;
  transition: opacity var(--motion-duration-canvas) var(--motion-ease-standard);
}

body[data-daypart="evening"] .map-daypart-tint {
  opacity: 1;
  background: linear-gradient(180deg, rgba(255, 196, 120, 0.1), rgba(214, 116, 73, 0.13));
}

body[data-daypart="late"] .map-daypart-tint {
  opacity: 1;
  background: linear-gradient(180deg, rgba(64, 74, 110, 0.17), rgba(43, 50, 78, 0.21));
}

.plate-coords {
  position: absolute;
  z-index: 3;
  display: flex;
  pointer-events: none;
  color: rgba(12, 12, 12, 0.42);
  font-family: var(--font-atlas-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.plate-coords span {
  line-height: 1;
}

.plate-coords-x {
  top: 4px;
  right: 15px;
  left: 15px;
  justify-content: space-around;
}

.plate-coords-y {
  top: 15px;
  bottom: 15px;
  left: 5px;
  flex-direction: column;
  justify-content: space-around;
}

.map-data-attribution { position:absolute; right:7px; bottom:6px; z-index:var(--map-z-chrome); display:block; padding:2px 4px; border-radius:2px; background:rgba(255,253,247,.78); color:rgba(17,16,14,.72); font:normal 600 9px/1.2 var(--font-mono); letter-spacing:.01em; white-space:nowrap; }

.map-data-attribution a { color:inherit; text-decoration:underline; text-decoration-color:rgba(17,16,14,.42); text-underline-offset:1px; }

.map-data-attribution a:hover,
.map-data-attribution a:focus-visible {
  color: var(--ink);
  text-decoration-color: currentColor;
}

body.is-time-rings-view .map-data-attribution {
  display: none;
}

@media (max-width: 980px) {
  .plate-coords {
    display: none;
  }

  .map-data-attribution {
    right: 14px;
    bottom: calc(var(--mobile-map-bottom-clearance) + 2px);
    font-size: 8px;
  }
}

.map-frame::before {
  background:
    linear-gradient(90deg, var(--ink) 0 18px, transparent 18px calc(100% - 18px), var(--ink) calc(100% - 18px) 100%) left 14px top 14px / 100% 1px no-repeat,
    linear-gradient(90deg, var(--ink) 0 18px, transparent 18px calc(100% - 18px), var(--ink) calc(100% - 18px) 100%) left 14px bottom 14px / 100% 1px no-repeat,
    linear-gradient(var(--ink) 0 18px, transparent 18px calc(100% - 18px), var(--ink) calc(100% - 18px) 100%) left 14px top 14px / 1px 100% no-repeat,
    linear-gradient(var(--ink) 0 18px, transparent 18px calc(100% - 18px), var(--ink) calc(100% - 18px) 100%) right 14px top 14px / 1px 100% no-repeat;
}

body.is-inspect-mode .map-frame::after {
  opacity: 0.14;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 253, 247, 0.9), transparent 28%),
    linear-gradient(90deg, rgba(111, 125, 85, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(139, 91, 63, 0.1) 1px, transparent 1px);
  background-size: auto, 82px 82px, 82px 82px;
}

canvas {
  display: block;
  width: 100%;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.map-hover-canvas {
  position: absolute;
  inset: 0;
  z-index: var(--map-z-annotations);
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  background: transparent;
  pointer-events: none;
  cursor: inherit;
}

.atlas-reveal-canvas {
  position: absolute;
  z-index: var(--map-z-annotations);
  display: none;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  background: transparent;
  pointer-events: none;
}

.atlas-layer-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  background: transparent;
  pointer-events: none;
}

.atlas-preview-canvas {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
  aspect-ratio: auto;
  display: none;
  background: transparent;
  pointer-events: none;
  transform-origin: 0 0;
  will-change: transform;
  z-index: var(--map-z-preview);
}

.atlas-preview-canvas.is-visible {
  display: block;
}

.atlas-station-marker-canvas {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  background: transparent;
  pointer-events: none;
}

body.is-layered-map .map-frame > #mapCanvas {
  position: relative;
  z-index: 1;
  background: transparent;
}

body.is-layered-map .map-frame > .atlas-layer-canvas {
  z-index: 0;
}

body.is-layered-map .map-frame > .atlas-preview-canvas {
  z-index: var(--map-z-preview);
}

body.is-composited-map-preview .map-frame > .atlas-layer-base,
body.is-composited-map-preview .map-frame > .atlas-layer-network,
body.is-composited-map-preview .map-frame > .atlas-layer-labels,
body.is-composited-map-preview .map-frame > .atlas-layer-overlays {
  visibility: hidden;
}

body.is-map-interacting canvas {
  cursor: grabbing;
}

body.is-commute-fit-candidate-hover:not(.is-map-interacting) .map-frame > #mapCanvas {
  cursor: pointer;
}

body.is-time-rings-view #mapCanvas,
body.is-time-rings-view .map-hover-canvas {
  cursor: crosshair;
}

body.is-reach-mode:not(.is-map-interacting) #mapCanvas,
body.is-reach-mode:not(.is-map-interacting) .map-hover-canvas {
  cursor: crosshair;
}

body.is-time-rings-view .distance-legend,
body.is-time-rings-view .map-hub-tray {
  display: none;
}

/* The top-left registration corner sat directly beneath the rounded spatial
   toggle and made that control read as square. Preserve the other three atlas
   corners while leaving this control lane visually clean. */
body.is-time-rings-view .map-frame::before {
  background:
    linear-gradient(90deg, transparent 0 calc(100% - 18px), var(--ink) calc(100% - 18px) 100%) left 14px top 14px / 100% 1px no-repeat,
    linear-gradient(90deg, var(--ink) 0 18px, transparent 18px calc(100% - 18px), var(--ink) calc(100% - 18px) 100%) left 14px bottom 14px / 100% 1px no-repeat,
    linear-gradient(transparent 0 calc(100% - 18px), var(--ink) calc(100% - 18px) 100%) left 14px top 14px / 1px 100% no-repeat,
    linear-gradient(var(--ink) 0 18px, transparent 18px calc(100% - 18px), var(--ink) calc(100% - 18px) 100%) right 14px top 14px / 1px 100% no-repeat;
}

body.is-time-rings-view .legend {
  border-color: rgba(100, 55, 25, 0.46);
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.9), rgba(239, 230, 210, 0.86));
  box-shadow:
    inset 3px 0 0 rgba(201, 53, 43, 0.74),
    var(--shadow-soft);
}

body.is-inspect-mode .legend.is-daily-life {
  border-color: rgba(111, 125, 85, 0.42);
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.93), rgba(242, 236, 220, 0.88));
  box-shadow: var(--shadow-soft);
}

.legend-texture-dots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 8px;
  height: auto;
  min-height: 24px;
}

.legend-texture-dots span {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 5px;
  color: rgba(17, 16, 14, 0.68);
  font-size: 0.58rem;
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1.1;
  text-transform: none;
}

.legend-texture-dots b {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border: 1px solid rgba(17, 16, 14, 0.18);
  background: var(--texture-color, rgba(111, 125, 85, 0.8));
}

.legend-texture-dots em {
  overflow: hidden;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-texture-dots.is-empty {
  grid-template-columns: minmax(0, 1fr);
}

.time-ring-symbol-key {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: rgba(17, 16, 14, 0.66);
  font: 760 0.52rem/1 var(--font-mono);
  letter-spacing: 0.025em;
  white-space: nowrap;
}

.time-ring-symbol-key span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.time-ring-symbol-key b {
  display: inline-block;
  width: 7px;
  height: 7px;
  border: 1px solid rgba(17, 16, 14, 0.68);
  border-radius: 50%;
  background: rgba(17, 16, 14, 0.66);
  box-sizing: border-box;
}

.time-ring-symbol-key b.is-one,
.time-ring-symbol-key b.is-multiple {
  background: rgba(247, 243, 233, 0.92);
}

.time-ring-symbol-key b.is-multiple {
  box-shadow: 0 0 0 2px rgba(247, 243, 233, 0.92), 0 0 0 3px rgba(17, 16, 14, 0.44);
}

.time-ring-route-key {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  padding-top: 5px;
  border-top: 1px solid rgba(88, 65, 35, 0.16);
  color: rgba(17, 16, 14, 0.7);
  font: 720 0.5rem/1.15 var(--font-mono);
}

.time-ring-route-key span {
  display: grid;
  gap: 3px;
}

.time-ring-route-key b {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: rgba(47, 127, 137, 0.88);
}

.time-ring-route-key b.is-transfer {
  height: 0;
  border-top: 2px dotted rgba(159, 107, 47, 0.94);
  background: transparent;
}

.time-ring-route-note {
  display: block;
  color: rgba(17, 16, 14, 0.58);
  font: 620 0.5rem/1.3 var(--font-main);
}

.map-state-pill,
.toast,
.legend,
.map-hub-tray,
.distance-legend {
  position: absolute;
  z-index: var(--map-z-chrome);
  border: 1px solid rgba(12, 12, 12, 0.42);
  background: rgba(247, 245, 236, 0.82);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

/*
 * Blur is scoped to the transient chrome only. The pill, legend and distance
 * legend sit on opaque paper per the material refresh, so declaring a blur for
 * them here only to force it back off in the final cascade is dead weight.
 */
.toast,
.map-hub-tray {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

body.is-map-interacting .map-state-pill,
body.is-map-hovering .map-state-pill,
body.is-map-interacting .toast,
body.is-map-hovering .toast,
body.is-map-interacting .legend,
body.is-map-hovering .legend,
body.is-map-interacting .map-hub-tray,
body.is-map-hovering .map-hub-tray,
body.is-map-interacting .distance-legend,
body.is-map-hovering .distance-legend{
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.map-state-pill {
  text-overflow: ellipsis;
}

.map-state-pill[hidden] {
  display: none;
}

.state-pill-place {
  min-width: 0;
}

.state-pill-detail {
  min-width: 0;
}

.map-state-pill::after,
.distance-legend::after,
.legend::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 5px;
  width: 16px;
  height: 1px;
  background: rgba(12, 12, 12, 0.22);
  transform: rotate(-24deg);
  transform-origin: right center;
}

.toast {
  left: 50%;
  bottom: 16px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  pointer-events: none;
  text-transform: uppercase;
  transform: translateX(-50%);
  animation: toast-in var(--motion-duration-base) var(--motion-ease-enter) both;
}

.toast.is-exiting {
  animation: toast-out var(--motion-duration-fast) var(--motion-ease-exit) both;
}

/* An action toast (Undo) is the one toast a pointer can use. */
.toast.has-action:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding-block: 0;
  pointer-events: auto;
  white-space: nowrap;
}

.toast-action {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--accent, #b4422b);
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  text-decoration: underline;
  text-transform: inherit;
  text-underline-offset: 3px;
}

.toast-action:focus-visible {
  outline: 2px solid var(--accent, #b4422b);
  outline-offset: -6px;
}

.legend {
  box-sizing: border-box;
  width: min(304px, calc(100% - 28px));
  font-family: var(--font-mono);
}

.legend-gradient-time {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
}

.legend-gradient-time span {
  min-width: 0;
  width: auto;
  font-variant-numeric: tabular-nums lining-nums;
  text-align: center;
}

.legend-gradient-time span:first-child {
  text-align: left;
}

.legend-gradient-time span:last-child {
  text-align: right;
}

.legend-gradient-time.has-train {
  overflow: visible;
  margin-top: 18px;
}

.legend-isochrone-bands {
  display: grid;
  grid-template-columns: repeat(var(--isochrone-band-columns, var(--isochrone-band-count, 4)), minmax(0, 1fr));
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legend-isochrone-bands li {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.legend-isochrone-bands li i {
  box-sizing: border-box;
  display: block;
  height: 11px;
  border: 1px solid color-mix(in srgb, var(--isochrone-band-color) 72%, #11100e);
  background: var(--isochrone-band-color);
  box-shadow:
    inset 0 1px 0 rgba(255, 253, 247, 0.36),
    0 0 0 1px rgba(255, 253, 247, 0.5);
}

.legend-isochrone-bands li span {
  overflow: hidden;
  color: rgba(22, 20, 15, 0.74);
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 760;
  letter-spacing: 0.01em;
  line-height: 1;
  text-align: center;
  text-overflow: clip;
  white-space: nowrap;
}

.legend-isochrone-bands .legend-band-unit {
  display: block;
  font: inherit;
  line-height: 1.2;
}

.legend .legend-pixel-train {
  position: absolute;
  left: 2px;
  bottom: calc(100% - 1px);
  z-index: 2;
  width: 44px;
  height: 22px;
  background: url("./assets/sf-transit-pixel.svg") center / var(--legend-train-width, 40px) var(--legend-train-height, 20px) no-repeat;
  image-rendering: pixelated;
  pointer-events: none;
  transform: translate3d(0, 0, 0);
  will-change: transform;
}

@media (prefers-reduced-motion: no-preference) {
  .legend-pixel-train {
    animation: legend-train-trundle var(--legend-train-duration, 64s) steps(var(--legend-train-steps, 120), end) infinite;
    animation-delay: var(--legend-train-phase, 0ms);
  }
}

@keyframes legend-train-trundle {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(var(--legend-train-distance, 0px), 0, 0);
  }
}

.map-hub-tray {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  align-items: stretch;
  width: 132px;
  padding: 6px;
  box-sizing: border-box;
  font-family: var(--font-mono);
}

.map-hub-tray:not(.is-expanded) {
  padding: 0;
}

.map-hub-tray[hidden] {
  display: none;
}

.map-hub-tray-toggle,
.map-hub-chip {
  border: 1px solid rgba(17, 16, 14, 0.2);
  background: rgba(255, 253, 247, 0.72);
  color: var(--plate-ink);
  cursor: pointer;
}

.map-hub-tray-toggle {
  position: relative;
  display: grid;
  gap: 2px;
  min-width: 0;
  min-height: 38px;
  padding: 6px 24px 6px 8px;
  box-sizing: border-box;
  text-align: left;
  text-transform: uppercase;
}

.map-hub-tray-toggle span {
  min-width: 0;
  overflow: hidden;
  color: rgba(17, 16, 14, 0.48);
  font: 850 0.52rem/1 var(--font-main);
  letter-spacing: 0.12em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-hub-tray-toggle strong {
  min-width: 0;
  overflow: hidden;
  color: var(--plate-ink);
  font: 760 0.58rem/1 var(--font-main);
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-hub-tray-toggle::before {
  content: "+";
  position: absolute;
  right: 7px;
  top: 5px;
  color: var(--plate-rail-red);
  font: 900 0.72rem/1 var(--font-main);
}

.map-hub-tray.is-expanded .map-hub-tray-toggle::before {
  content: "-";
}

.map-hub-chip-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  min-width: 0;
  max-height: min(340px, calc(100vh - 190px));
  overflow: auto;
}

.map-hub-tray:not(.is-expanded) .map-hub-chip-list {
  display: none;
}

.map-hub-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 7px;
  align-items: baseline;
  min-width: 0;
  max-width: none;
  min-height: 38px;
  padding: 6px 7px;
  box-sizing: border-box;
  text-align: left;
  box-shadow: inset 3px 0 0 rgba(48, 116, 138, 0.65);
}

.map-hub-tray.is-expanded {
  width: min(246px, calc(100% - 150px));
}

.map-hub-chip strong {
  min-width: 0;
  overflow: hidden;
  color: var(--plate-ink);
  font: 780 0.62rem/1.05 var(--font-main);
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-hub-chip span {
  color: rgba(17, 16, 14, 0.62);
  font: 760 0.58rem/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.map-hub-chip.is-origin {
  box-shadow: inset 3px 0 0 var(--plate-rail-red);
}

.map-hub-chip.is-out,
.map-hub-chip.is-far {
  opacity: 0.52;
  box-shadow: inset 3px 0 0 rgba(17, 16, 14, 0.22);
}

.map-hub-tray-toggle:hover,
.map-hub-tray-toggle:focus-visible,
.map-hub-chip:hover,
.map-hub-chip:focus-visible {
  background: rgba(255, 253, 247, 0.94);
  border-color: rgba(17, 16, 14, 0.38);
}

.legend-kicker {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1;
}

.legend-mid {
  color: rgba(12, 12, 12, 0.36);
  font-weight: 600;
}

.legend-bands {
  display: grid;
  gap: 5px;
  border: 0;
  background: transparent;
}

.legend-gradient {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  overflow: hidden;
}

.legend-gradient span {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  line-height: 1;
  text-transform: uppercase;
}

body.is-car-surface .legend-gradient-time {
  background: linear-gradient(
    90deg,
    #528e8f 0%,
    #72b4a4 22%,
    #e0c788 46%,
    #dea38b 72%,
    #b99798 100%
  );
}

.legend-gradient-walk {
  background: linear-gradient(
    90deg,
    #5e8e73 0%,
    #84b794 20%,
    #dacd8b 42%,
    #e5bb94 66%,
    #dea8a0 84%,
    #b7a6b0 100%
  );
}

.legend-gradient-compare {
  background: linear-gradient(
    90deg,
    #c64a2d 0%,
    rgba(112, 128, 152, 0.78) 50%,
    #2f7f89 100%
  );
}

.legend-gradient-compare::after {
  content: "";
  position: absolute;
  inset: 0 0 0 50%;
  background: repeating-linear-gradient(
    135deg,
    rgba(18, 74, 88, 0.34) 0 1px,
    transparent 1px 7px
  );
  pointer-events: none;
  z-index: 0;
}

.legend-foot {
  line-height: 1.3;
}

body.is-route-mode .legend {
  display: none;
}

.distance-legend {
  display: grid;
  gap: 5px;
  padding: 7px 9px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  line-height: 1;
  text-transform: uppercase;
}

.distance-legend div {
  position: relative;
  box-sizing: border-box;
  height: 8px;
  min-width: 0;
  max-width: 100%;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  border-left: 2px solid var(--ink);
}

.map-zoom-controls,
.map-corner-actions {
  position: absolute;
  z-index: var(--map-z-chrome);
  display: grid;
  gap: 7px;
}

.map-zoom-controls {
  left: 12px;
  bottom: 12px;
}

.mobile-reach-time-control {
  display: none;
}

.map-corner-actions {
  right: 12px;
  top: 12px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
}

.icon-button:hover {
  color: var(--paper);
}

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

body.is-map-fullscreen {
  overflow: hidden;
}

.map-panel:fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  border: 0;
  border-radius: 0;
  margin: 0;
  padding: 0;
  transform: none;
  animation: none;
}

.map-panel:fullscreen .panel-header{
  display: none;
}

.map-panel:fullscreen .map-frame {
  flex: 1;
  min-height: 0;
  margin: 0;
  border: 0;
}

.map-panel:fullscreen canvas {
  height: 100%;
  aspect-ratio: auto;
}

.map-frame.is-immersive,
.map-frame:fullscreen {
  border: 0;
  box-shadow: none;
}

body.is-map-fullscreen .map-frame.is-immersive,
body:has(.map-frame:fullscreen) .map-frame:fullscreen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  width: 100vw;
  height: 100dvh;
  margin: 0;
  transform: none;
}

.map-frame.is-immersive canvas,
.map-frame:fullscreen canvas {
  height: 100%;
  aspect-ratio: auto;
}

.map-frame.is-immersive .map-corner-actions,
.map-frame:fullscreen .map-corner-actions {
  z-index: 20;
}


@media (max-width: 980px) {
.workspace {
      display: block;
      height: 100dvh;
    }

  .map-panel {
      height: 100dvh;
      border: 0;
      box-shadow: none;
    }

  .map-frame {
      height: 100%;
      border: 0;
    }

  canvas {
      height: 100%;
    }

  .map-state-pill {
      left: 12px;
      top: calc(env(safe-area-inset-top) + 12px);
    }

  body.is-mobile-sheet-expanded .distance-legend {
      opacity: 0;
      pointer-events: none;
      transform: translateY(8px);
    }

  .map-corner-actions {
      top: calc(env(safe-area-inset-top) + 12px);
      right: 12px;
      z-index: 5;
    }

  .map-panel.is-immersive canvas,
    .map-panel:fullscreen canvas {
      height: 100%;
    }
}


@media (max-width: 560px) {
.legend {
      font-size: 0.68rem;
    }
}

.workspace {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.map-panel {
  border: 1px solid var(--material-molded-edge);
  background: var(--material-molded);
  box-shadow: var(--material-raised);
}

.map-panel::before {
  opacity: 0.16;
  background:
    linear-gradient(90deg, rgba(17, 16, 14, 0.026) 1px, transparent 1px),
    linear-gradient(rgba(17, 16, 14, 0.018) 1px, transparent 1px);
  background-size: 48px 48px;
}

body.is-inspect-mode .map-frame::after {
  mix-blend-mode: multiply;
}

canvas {
  background: var(--water);
}

.map-state-pill,
.toast,
.legend,
.distance-legend {
  box-shadow: 0 12px 28px rgba(36, 30, 20, 0.08);
}

.map-state-pill::after {
  display: none;
}

.icon-button {
  width: 44px;
  height: 44px;
  min-height: 44px;
  border-color: rgba(17, 16, 14, 0.5);
  background: rgba(251, 250, 244, 0.9);
  box-shadow: 3px 3px 0 rgba(17, 16, 14, 0.1);
}

.icon-button:hover {
  background: #11100e;
}

.legend div {
  height: 10px;
}

body.is-car-surface .legend .legend-gradient-time {
  background: linear-gradient(
    90deg,
    #528e8f 0%,
    #72b4a4 22%,
    #e0c788 46%,
    #dea38b 72%,
    #b99798 100%
  );
}

.legend .legend-gradient-walk {
  background: linear-gradient(
    90deg,
    #5e8e73 0%,
    #84b794 20%,
    #dacd8b 42%,
    #e5bb94 66%,
    #dea8a0 84%,
    #b7a6b0 100%
  );
}

.distance-legend {
  left: 62px;
  top: auto;
  bottom: 14px;
  width: max-content;
  max-width: 136px;
  min-width: 0;
}


@media (max-width: 1180px) {
.workspace {
      grid-template-columns: minmax(0, 1fr) 330px;
    }
}


@media (max-width: 980px) {
.workspace {
      grid-template-columns: 1fr;
    }
}


@media (max-width: 980px) {
.map-frame {
      margin: 0;
      box-shadow: none;
    }

  .legend {
      min-width: 0;
    }
}

.map-frame {
  border-color: rgba(17, 16, 14, 0.5);
}

.map-state-pill,
.toast,
.legend,
.distance-legend{
  background: rgba(251, 250, 244, 0.94);
  border-color: rgba(17, 16, 14, 0.42);
}

.legend div {
  box-shadow: none;
}


@media (max-width: 980px) {
.map-state-pill {
      max-width: min(176px, calc(100% - 132px));
      padding: 8px 9px;
    }

  body.is-route-mode .map-state-pill {
      grid-template-columns: 1fr;
      gap: 3px;
      align-items: start;
      max-width: min(238px, calc(100% - 164px));
      padding: 8px 10px;
    }

  .state-pill-mode {
      font-size: 0.62rem;
    }

  body.is-route-mode .state-pill-mode {
      font-size: 0.58rem;
      line-height: 1;
    }

  .state-pill-place {
      font-size: 0.68rem;
    }

  body.is-route-mode .state-pill-place {
      display: -webkit-box;
      overflow: hidden;
      font-size: 0.66rem;
      line-height: 1.16;
      text-overflow: clip;
      white-space: normal;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
    }

  .state-pill-detail {
      font-size: 0.58rem;
    }

  body.is-route-mode .state-pill-detail {
      grid-column: auto;
      font-size: 0.56rem;
      line-height: 1;
    }
}

.layers-disclosure {
  position: relative;
}

.layers-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.layers-button .layers-chevron {
  display: inline-block;
  transform: translateY(-1px);
  font-size: 0.85rem;
  line-height: 1;
  transition: transform var(--motion-duration-base) var(--motion-ease-enter);
}

.layers-button.is-active .layers-chevron {
  transform: translateY(-1px) rotate(180deg);
}

.layers-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 80;
  min-width: 180px;
  animation: layers-pop-in var(--motion-duration-base) var(--motion-ease-enter) both;
}

.layers-panel[hidden] {
  display: none;
}

.layers-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--rule-gradient);
}

.layers-panel-kicker {
  margin-bottom: 2px;
  color: var(--muted);
  font-family: var(--font-main);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  line-height: 1;
  text-transform: uppercase;
}

.layers-panel .toggle-control {
  width: 100%;
  border: 1px solid var(--line-soft);
}

.map-loading {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  /* Neutralise the boot-critical inline rule (fixed + centered card):
     without these resets its width/transform leak through and the cover
     renders as a half-offscreen slab over the map's top-left corner. */
  width: auto;
  transform: none;
  padding: 32px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.96), rgba(247, 243, 233, 0.92)),
    linear-gradient(rgba(12, 12, 12, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(12, 12, 12, 0.028) 1px, transparent 1px);
  background-size: auto, 38px 38px, 38px 38px;
  pointer-events: none;
  transition: opacity var(--motion-duration-slow) var(--motion-ease-enter);
}

.map-loading.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.map-loading-track {
  width: min(420px, 80%);
  height: auto;
  margin-bottom: 10px;
  overflow: visible;
}

.map-loading-track .map-loading-shadow,
.map-loading-track .map-loading-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-loading-track .map-loading-shadow {
  stroke: rgba(12, 12, 12, 0.1);
  stroke-width: 7;
}

.map-loading-track .map-loading-line {
  stroke: var(--accent);
  stroke-width: 3;
  stroke-dasharray: 720;
  stroke-dashoffset: 720;
  animation: map-loading-draw var(--motion-duration-loading-loop) var(--ease) infinite;
}

.map-loading-dot {
  fill: var(--paper);
  stroke: rgba(12, 12, 12, 0.62);
  stroke-width: 1.4;
  opacity: 0;
  animation: map-loading-dot var(--motion-duration-loading-loop) var(--ease) infinite;
}

.map-loading-dot:nth-of-type(2) { animation-delay: calc(var(--motion-duration-loading-loop) * 0.2); }

.map-loading-dot:nth-of-type(3) { animation-delay: calc(var(--motion-duration-loading-loop) * 0.4); }

.map-loading-dot:nth-of-type(4) { animation-delay: calc(var(--motion-duration-loading-loop) * 0.6); }

.map-loading-dot-terminal {
  fill: var(--accent);
  stroke: var(--paper);
}

.map-loading-title {
  color: var(--ink);
  font-family: var(--font-serif-ja, var(--font-serif));
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 680;
  letter-spacing: 0.1em;
  line-height: 1;
}

.map-loading-kicker {
  color: rgba(12, 12, 12, 0.62);
  font-family: var(--font-mono);
  font-size: clamp(0.68rem, 1.25vw, 0.82rem);
  font-weight: 800;
  letter-spacing: 0.18em;
  line-height: 1;
  text-transform: uppercase;
}

.map-loading-subtitle {
  margin-top: 2px;
  color: rgba(12, 12, 12, 0.5);
  font-family: var(--font-ui);
  font-size: clamp(0.58rem, 1vw, 0.68rem);
  font-weight: 680;
  letter-spacing: 0.16em;
  line-height: 1;
  text-transform: uppercase;
}

.map-loading-ticker {
  margin-top: 10px;
  color: var(--ink-soft);
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.2;
}

.map-loading-ticker.is-swapping {
  animation: map-loading-ticker-swap var(--motion-duration-fast) var(--motion-ease-quiet) both;
}

@keyframes map-loading-ticker-swap {
  from {
    opacity: 0.45;
    filter: blur(1px);
    transform: translateY(var(--motion-nudge-micro));
  }

  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
  }
}


@media (prefers-reduced-motion: reduce) {
  .map-loading-track .map-loading-line {
      animation: none;
      stroke-dashoffset: 0;
    }

  .map-loading-dot {
      animation: none;
      opacity: 1;
    }

  .map-loading-ticker.is-swapping {
    animation: none;
  }
}

.layers-panel{
  transform-origin: top right;
  animation-duration: var(--motion-duration-base);
}

.toast {
  animation-duration: var(--motion-duration-base);
  animation-timing-function: var(--motion-soft);
}

.toast.is-exiting {
  animation-duration: var(--motion-duration-fast);
  animation-timing-function: var(--motion-exit);
}

.map-state-pill,
.legend,
.distance-legend{
  transition:
    opacity var(--duration-base) var(--motion-snap),
    transform var(--duration-base) var(--motion-snap),
    box-shadow var(--duration-base) var(--motion-snap);
}

.workspace {
  gap: 14px;
}

.map-frame {
  margin: 10px 12px 12px;
}

canvas {
  aspect-ratio: 1.6 / 1;
}


@media (max-width: 980px) {
canvas {
      aspect-ratio: auto;
    }
}


@media (prefers-reduced-motion: no-preference) {
.map-panel { animation-delay: var(--motion-duration-micro); }
}


@media (max-width: 980px) {
.legend {
      display: none;
    }

  .distance-legend {
      left: 60px;
      right: auto;
      top: auto;
      bottom: var(--mobile-map-bottom-clearance);
      z-index: 5;
      display: grid;
      max-width: 96px;
      min-width: 74px;
      padding: 6px 8px;
      font-size: 0.62rem;
    }

  .map-zoom-controls {
      left: 12px;
      bottom: var(--mobile-map-bottom-clearance);
      z-index: 5;
      transition:
        opacity var(--duration-base) var(--motion-snap),
        transform var(--duration-base) var(--motion-snap);
    }

  body.is-reach-mode .mobile-reach-time-control {
      position: absolute;
      right: 12px;
      bottom: calc(var(--mobile-map-bottom-clearance) + 56px);
      z-index: 5;
      display: grid;
      grid-template-columns: 34px minmax(0, 1fr) 34px;
      gap: 6px;
      align-items: center;
      width: min(238px, calc(100% - 112px));
      min-height: 54px;
      border: 1px solid rgba(17, 16, 14, 0.46);
      padding: 7px;
      background: rgba(251, 250, 244, 0.94);
      color: var(--ink);
      transition:
        opacity var(--duration-base) var(--motion-snap),
        transform var(--duration-base) var(--motion-snap);
    }

  body.is-mobile-sheet-expanded .distance-legend,
    body.is-mobile-sheet-expanded .map-zoom-controls,
    body.is-mobile-sheet-expanded .mobile-reach-time-control {
      opacity: 0;
      pointer-events: none;
      transform: translateY(8px);
    }
}

.map-state-pill,
.legend,
.distance-legend,
.icon-button{
  border-color: var(--atlas-border);
  border-radius: 0;
  background: var(--atlas-paper);
  box-shadow: none;
}

.map-state-pill,
.legend,
.distance-legend {
  font-family: var(--font-mono);
}

.map-state-pill::after,
.legend::after {
  background: rgba(17, 16, 14, 0.22);
}

.legend {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/*
 * A hairline, not a rainbow. This stripe ran red → orange → teal, which is a
 * coloured top stripe of the kind the design system rules out, and its teal
 * stop encoded nothing — the legend below it only ever shows the two warm
 * isochrone bands. An ink rule does the same separating job and lets the
 * swatches be the only colour on the card.
 */
.legend::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 0;
  height: 1px;
  background: rgba(17, 16, 14, 0.22);
  pointer-events: none;
}

.legend-kicker {
  font-family: var(--font-caps);
  text-transform: uppercase;
}

.legend-gradient {
  border: 1px solid rgba(17, 16, 14, 0.6);
}

.legend-gradient span {
  font-family: var(--font-mono);
  color: rgba(255, 253, 247, 0.95);
  text-shadow: 0 0 2px rgba(17, 16, 14, 0.6);
}

.legend-foot {
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: uppercase;
}

.map-state-pill {
  border-color: var(--plate-ink);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  --stub-paper: var(--plate-ink);
  --stub-bg: transparent;
  -webkit-mask-composite: source-over;
  mask-composite: add;
}

.map-state-pill::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  width: 3px;
  height: 3px;
  background: var(--plate-rail-red);
  border-radius: 50%;
  transform: translateY(-50%);
}

.layers-button {
  font-family: var(--font-caps);
  font-size: 0.66rem;
  font-weight: 720;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.layers-panel {
  display: grid;
  grid-template-columns: minmax(140px, 1fr);
  gap: 10px;
  padding: 14px 14px 12px;
  border: 1px solid rgba(17, 16, 14, 0.32);
  background: rgba(255, 253, 247, 0.97);
  box-shadow:
    inset 0 2px 0 var(--plate-ink),
    0 8px 22px rgba(17, 16, 14, 0.06);
}

.layers-panel .layers-panel-kicker {
  font-family: var(--font-caps);
  font-size: 0.6rem;
  font-weight: 720;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid rgba(17, 16, 14, 0.18);
  padding-bottom: 6px;
}

.layers-panel .select-control {
  width: 100%;
  min-height: 30px;
  padding: 0 8px;
  background: transparent;
  border: 1px solid rgba(17, 16, 14, 0.28);
}

.layers-panel .select-control > span {
  font-family: var(--font-caps);
  font-size: 0.6rem;
  font-weight: 720;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.layers-panel .select-control select {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  background: transparent;
  border: 0;
  letter-spacing: 0.02em;
}

.layers-panel .surface-control {
  border-top: 0;
}

.layers-panel .surface-control > span::before {
  content: "Model variants";
  display: block;
  margin-bottom: 6px;
  font-size: 0.56rem;
  font-weight: 720;
  letter-spacing: 0.2em;
  color: rgba(17, 16, 14, 0.36);
}

.panel-controls > .layers-disclosure {
  order: 1;
}

.map-frame::before {
  opacity: 0.42;
}

.legend-kicker .legend-kicker-pair {
  flex-basis: 100%;
  margin-left: 0;
  margin-top: 1px;
}

.panel-controls .layers-panel .surface-control > span::before {
  font-family: var(--font-main);
  font-weight: 700;
  letter-spacing: 0;
}

body.is-map-active .workspace {
  gap: 10px;
}

@media (min-width: 981px), (min-width: 761px) and (max-width: 980px) and (min-height: 600px) and (orientation: landscape) {
  body.is-map-active .workspace {
    align-items: stretch;
  }
}

@media (min-width: 981px), (min-width: 761px) and (max-width: 980px) and (min-height: 600px) and (orientation: landscape) {

  body.is-map-active .map-panel {
    height: 100%;
    min-height: 0;
    max-height: 100%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  body.is-map-active .map-frame {
    display: block;
    position: relative;
    height: auto;
    min-height: 0;
    max-height: 100%;
    aspect-ratio: auto;
  }

  body.is-map-active .map-frame > #mapCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
  }
}

@media (min-width: 981px) and (max-width: 1240px), (min-width: 761px) and (max-width: 980px) and (min-height: 600px) and (orientation: landscape) {
  body.is-map-active .map-panel {
    height: auto;
    min-height: 0;
    max-height: 100%;
  }
}

@media (max-width: 980px) {
  body.is-map-active .map-frame {
    width: 100%;
    height: 100%;
    min-height: 0;
  }
}


@media (min-width: 981px), (min-width: 761px) and (max-width: 980px) and (min-height: 600px) and (orientation: landscape) {
body.is-map-active .panel-controls > .layers-disclosure {
      grid-area: layers;
      justify-self: start;
    }
}

.map-state-pill,
.legend-gradient span,
.legend-gradient-time span,
.legend-foot,
.range-control strong {
  font-family: var(--font-metric);
  font-variant-numeric: tabular-nums;
}

.map-state-pill {
  left: 14px;
  top: 14px;
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 7px;
  width: max-content;
  max-width: min(292px, calc(100% - 174px));
  overflow: hidden;
  border: 1px solid rgba(17, 16, 14, 0.24);
  background: rgba(255, 253, 247, 0.78);
  box-shadow: 0 8px 20px rgba(36, 30, 20, 0.07);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.map-state-pill::before,
.map-state-pill::after {
  content: none;
  display: none;
}

.map-state-pill > * {
  min-width: 0;
  color: inherit;
}

.state-pill-mode {
  flex: 0 0 auto;
  color: rgba(17, 16, 14, 0.82);
  font-size: inherit;
  font-weight: 850;
  letter-spacing: 0.065em;
}

.state-pill-place {
  flex: 1 1 auto;
  max-width: 15ch;
  overflow: hidden;
  color: rgba(17, 16, 14, 0.72);
  font-size: inherit;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-pill-detail {
  grid-column: auto;
  flex: 1 1 auto;
  max-width: none;
  overflow: hidden;
  color: rgba(17, 16, 14, 0.54);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.is-reach-mode .map-state-pill {
  max-width: min(246px, calc(100% - 174px));
}

body.is-reach-mode .state-pill-detail::before {
  content: "/";
  margin-right: 7px;
  color: rgba(17, 16, 14, 0.28);
}

.legend {
  border: 1px solid rgba(17, 16, 14, 0.22);
  background: rgba(255, 253, 247, 0.76);
  box-shadow: 0 8px 20px rgba(36, 30, 20, 0.07);
}

.legend::before {
  left: 10px;
  right: 10px;
  height: 1px;
  opacity: 0.78;
}

.legend::after,
.distance-legend::after {
  content: none;
  display: none;
}

.legend-kicker {
  color: rgba(17, 16, 14, 0.72);
  font-size: 0.56rem;
  font-weight: 760;
  letter-spacing: 0.12em;
}

.legend-gradient {
  border-color: rgba(17, 16, 14, 0.44);
  box-shadow:
    inset 0 0 0 1px rgba(255, 253, 247, 0.42),
    0 0 0 3px rgba(255, 253, 247, 0.52);
}

.legend-gradient span {
  font-size: 0.54rem;
  font-weight: 760;
  letter-spacing: 0.045em;
}

.legend-foot {
  min-height: 0;
  color: rgba(17, 16, 14, 0.42);
  font-size: 0.54rem;
  letter-spacing: 0.08em;
}

.distance-legend {
  border-color: rgba(17, 16, 14, 0.22);
  background: rgba(255, 253, 247, 0.74);
  box-shadow: 0 8px 20px rgba(36, 30, 20, 0.06);
}

.map-hub-tray {
  right: 60px;
  top: 14px;
  bottom: auto;
  max-width: min(246px, calc(100% - 156px));
  border-color: rgba(17, 16, 14, 0.2);
  background: rgba(255, 253, 247, 0.76);
  box-shadow: 0 8px 20px rgba(36, 30, 20, 0.07);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.map-hub-tray:not(.is-expanded) {
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.is-map-interacting .map-state-pill,
body.is-map-hovering .map-state-pill,
body.is-map-interacting .legend,
body.is-map-hovering .legend,
body.is-map-interacting .map-hub-tray,
body.is-map-hovering .map-hub-tray,
body.is-map-interacting .distance-legend,
body.is-map-hovering .distance-legend {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}

.map-frame {
  border: 1px solid rgba(17, 16, 14, 0.56);
  background: var(--water);
  box-shadow:
    inset 0 0 0 8px rgba(17, 16, 14, 0.045),
    inset 0 0 0 9px rgba(255, 253, 247, 0.42),
    0 1px 0 rgba(255, 253, 247, 0.82);
}

body.is-map-active .map-frame {
  margin: 8px;
}

@media (max-width: 980px) {
  body.is-map-active .map-frame {
    margin: 0;
  }
}

.map-frame::after {
  opacity: 0.045;
  /* Black source-over preserves the faint survey grid without a full-map blend pass. */
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.0933333333) 1px, transparent 1px),
    linear-gradient(rgba(0, 0, 0, 0.0746666667) 1px, transparent 1px);
  background-size: 120px 120px;
}

.map-state-pill,
.legend,
.distance-legend,
.map-hub-tray {
  border-color: var(--material-acrylic-edge);
  background: var(--material-acrylic);
  box-shadow: 0 6px 16px rgba(24, 20, 15, 0.055);
}

.map-state-pill {
  min-height: 32px;
  padding: 7px 10px 7px 12px;
  border-left: 3px solid var(--material-signal-red);
  color: rgba(17, 16, 14, 0.78);
  letter-spacing: 0.055em;
  -webkit-mask: none;
  mask: none;
}

.legend-gradient {
  height: 12px;
}

@media (max-width: 980px) {
  body.is-map-active .map-frame .map-state-pill {
    left: 10px;
    top: calc(env(safe-area-inset-top) + 10px);
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    gap: 4px;
    width: auto;
    min-width: 0;
    max-width: min(252px, calc(100vw - 118px));
    min-height: 28px;
    padding: 5px 8px 5px 10px;
    white-space: nowrap;
  }

  .map-state-pill {
    font-size: 0.625rem;
    line-height: 1;
    letter-spacing: 0.04em;
  }

  body.is-map-active .map-frame .map-state-pill::after {
    content: none;
  }

  body.is-map-active .map-frame .map-state-pill .state-pill-mode,
  body.is-map-active .map-frame .map-state-pill .state-pill-detail {
    display: block;
    grid-column: auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .map-state-pill .state-pill-mode,
  .map-state-pill .state-pill-detail {
    line-height: 1;
  }

  body.is-map-active .map-frame .map-state-pill .state-pill-mode {
    flex: 0 0 auto;
    max-width: none;
    min-width: max-content;
  }

  .map-state-pill .state-pill-mode {
    font-size: 0.625rem;
  }

  body.is-map-active .map-frame .map-state-pill .state-pill-detail {
    flex: 0 1 auto;
    max-width: 78px;
  }

  .map-state-pill .state-pill-detail {
    font-size: 0.625rem;
    letter-spacing: 0.035em;
  }

  body.is-map-active .map-frame .map-state-pill .state-pill-detail::before {
    content: "/";
    margin-right: 4px;
  }

  .map-state-pill .state-pill-detail::before {
    color: rgba(17, 16, 14, 0.34);
  }

  body.is-time-rings-view.is-map-active .map-frame .map-state-pill {
    max-width: min(178px, calc(100vw - 212px));
  }

  body.is-time-rings-view.is-map-active .map-frame .map-state-pill .state-pill-detail {
    max-width: 108px;
  }

  body.is-map-active .map-frame .map-corner-actions {
    top: calc(env(safe-area-inset-top) + 10px);
    right: 10px;
    z-index: 7;
  }

  body.is-map-active .map-frame .map-corner-actions .icon-button {
    width: 36px;
    height: 34px;
    min-height: 34px;
    padding: 0;
  }

  .map-hub-tray {
    top: calc(env(safe-area-inset-top) + 10px);
    right: 54px;
    width: 112px;
    max-width: 112px;
    z-index: 6;
  }

  .map-hub-tray.is-expanded {
    width: min(230px, calc(100vw - 20px));
    max-width: min(230px, calc(100vw - 20px));
    z-index: 9;
  }

  .map-hub-tray-toggle {
    min-height: 34px;
    padding: 5px 8px;
  }

  .map-hub-tray-toggle span {
    font-size: 0.47rem;
    letter-spacing: 0.06em;
  }

  .map-hub-tray-toggle strong {
    font-size: 0.52rem;
    letter-spacing: 0.04em;
  }
}

@media (max-width: 374px) {
  body.is-map-active .map-frame .map-state-pill {
    max-width: min(218px, calc(100vw - 118px));
  }

  .map-hub-tray {
    width: 104px;
    max-width: 104px;
  }
}

/* Map flat controls. Absorbed from refinements.css; command-bar.css owns
   corner and zoom utility chrome later in the cascade. */
:is( .icon-button:not(:where(.map-corner-actions *, .map-zoom-controls *))) {
  position: relative;
  border-color: var(--button-flat-border);
  background: var(--button-flat-bg);
  box-shadow: none;
  text-shadow: none;
  transform: none;
  animation: none;
}

:is(.icon-button:not(:where(.map-corner-actions *, .map-zoom-controls *))) {
  background: transparent;
  color: var(--ink);
}

:is( .icon-button:not(:where(.map-corner-actions *, .map-zoom-controls *))):hover {
  border-color: var(--ink);
  background: var(--button-flat-bg-hover);
  color: var(--ink);
  box-shadow: none;
  transform: none;
  animation: none;
}


/* Mobile: keep a compact legend visible so the reach heat and
   rail-vs-car surfaces carry their color key on small screens.
   The minute ramp renders as an 11px strip with its labels on a
   separate row below, so nothing has to live inside a squashed bar. */
@media (max-width: 980px) {
  .legend {
    display: grid;
    right: 12px;
    left: auto;
    top: calc(env(safe-area-inset-top) + 60px);
    bottom: auto;
    min-width: 0;
    max-width: min(220px, calc(100vw - 150px));
    padding: 6px 8px 7px;
    gap: 3px;
    font-size: 0.6rem;
    z-index: 4;
  }

  .legend .legend-kicker,
  .legend .legend-foot {
    font-size: 0.58rem;
  }

  .legend .legend-bands {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .legend .legend-gradient-time {
    box-sizing: border-box;
    align-items: end;
    height: auto;
    min-height: 24px;
    padding: 0;
    border: 0;
    box-shadow: none;
    background-position: left top;
    background-repeat: no-repeat;
    background-size: 100% 11px;
    overflow: visible;
  }

  .legend .legend-gradient-time::after {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    box-sizing: border-box;
    height: 11px;
    border: 1px solid rgba(12, 12, 12, 0.42);
    pointer-events: none;
  }

  .legend .legend-gradient-time span {
    color: rgba(22, 20, 15, 0.72);
    font-size: 0.55rem;
    font-weight: 740;
    line-height: 1;
    text-shadow: none;
  }

  .legend .legend-gradient-compare {
    height: 16px;
  }

  .legend .legend-isochrone-bands {
    gap: 3px;
  }

  .legend .legend-isochrone-bands li {
    gap: 3px;
  }

  .legend .legend-isochrone-bands li i {
    height: 9px;
  }

  .legend .legend-isochrone-bands li span {
    font-size: 0.5rem;
  }

  body.is-mobile-sheet-expanded .legend,
  body.is-route-mode .legend,
  body.is-time-rings-view .legend {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
  }
}

body.is-map-active.is-inspect-mode #legend.legend.is-daily-life {
  display: grid;
  right: 14px;
  bottom: 14px;
  left: auto;
  top: auto;
  width: min(304px, calc(100% - 28px));
  min-width: 0;
  max-width: 326px;
  gap: 7px;
  border-color: rgba(47, 127, 137, 0.32);
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.94), rgba(238, 242, 226, 0.9));
  box-shadow: 0 10px 24px rgba(36, 30, 20, 0.09);
}

body.is-map-active.is-inspect-mode #legend.legend.is-daily-life .legend-bands,
body.is-map-active.is-inspect-mode #legend.legend.is-daily-life .legend-texture-dots {
  height: auto;
  min-height: 0;
  overflow: visible;
}

body.is-map-active.is-inspect-mode #legend.legend.is-daily-life .legend-texture-dots b {
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(17, 16, 14, 0.08);
}

body.is-map-active.is-inspect-mode #legend.legend.is-daily-life .legend-foot {
  letter-spacing: 0;
  text-transform: none;
}

@media (max-width: 980px) {

  body.is-map-active.is-inspect-mode #legend.legend.is-daily-life {
    display: grid;
    top: auto;
    right: calc(env(safe-area-inset-right) + 10px);
    bottom: calc(env(safe-area-inset-bottom) + var(--mobile-sheet-peek, 138px) + 10px);
    left: calc(env(safe-area-inset-left) + 10px);
    width: auto;
    max-width: none;
    padding: 9px 10px;
    gap: 6px;
    z-index: 4;
  }

  body.is-map-active.is-inspect-mode #legend.legend.is-daily-life .legend-kicker,
  body.is-map-active.is-inspect-mode #legend.legend.is-daily-life .legend-foot {
    font-size: 0.6rem;
    line-height: 1.2;
  }

  body.is-map-active.is-inspect-mode #legend.legend.is-daily-life .legend-texture-dots {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px 8px;
  }

  body.is-map-active.is-inspect-mode #legend.legend.is-daily-life .legend-texture-dots span {
    font-size: 0.6rem;
  }

  body.is-mobile-sheet-expanded.is-inspect-mode #legend.legend.is-daily-life {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
  }
}

/* Explore's color key belongs with the map, opposite the distance scale and
   below the control cluster. Compact-landscape tablets use the desktop shell,
   so they share the same lower-right placement. */
@media (min-width: 981px), (min-width: 761px) and (max-width: 980px) and (min-height: 600px) and (orientation: landscape) {
  body.is-map-active.is-reach-mode .map-data-attribution {
    right: 14px;
    bottom: 6px;
  }

  body.is-map-active.is-reach-mode #legend.legend {
    top: auto;
    right: 14px;
    bottom: 32px;
    left: auto;
  }
}

/* Keep a small but legible key on true mobile layouts. It clears the 44px map
   settings affordance above and the time instrument / sheet below, while the
   one-line title and compact ramp leave most of the map unobscured. */
@media (max-width: 760px), (max-width: 980px) and (orientation: portrait), (max-width: 980px) and (max-height: 599px) {
  body.is-map-active.is-reach-mode.has-origin:not(.is-time-rings-view) #legend.legend {
    display: grid;
    top: auto;
    right: calc(env(safe-area-inset-right) + 14px);
    bottom: calc(var(--mobile-map-bottom-clearance, 162px) + 72px);
    left: auto;
    width: min(194px, calc(100vw - 96px));
    min-width: 0;
    max-width: 194px;
    gap: 3px;
    padding: 6px 8px 7px;
  }

  body.is-map-active.is-reach-mode.has-origin:not(.is-time-rings-view) #legend.legend .legend-kicker {
    display: block;
    overflow: hidden;
    font-size: 0.52rem;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.is-map-active.is-reach-mode.has-origin:not(.is-time-rings-view) #legend.legend .legend-foot {
    display: none;
  }

  body.is-map-active.is-reach-mode.has-origin:not(.is-time-rings-view) #legend.legend .legend-gradient-time {
    min-height: 22px;
  }
}
