.map-wrapper > .map-switches {
  position: absolute;
  z-index: 510;
  bottom: 10px;
  left: 10px;
  width: 154px;
  display: grid;
  gap: 4px;
  pointer-events: none;
}

.map-switches > .map-view-switch,
.terrain-source-field > .terrain-source-switch {
  position: static;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 20px;
  background: #242422;
  pointer-events: auto;
}

.map-switches .map-view-btn,
.terrain-source-field .map-view-btn {
  min-width: 0;
  min-height: 28px;
  padding: 2px 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
}

.map-switches .map-view-btn:focus-visible,
.terrain-source-field .map-view-btn:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -3px;
}

.terrain-source-field > .terrain-source-switch {
  width: 154px;
}

/* Keep the SDK's original credit and its existing info button together on
   a solid edge, clear of the capture area and the location text. */
.map-selector .mapboxgl-ctrl-bottom-right {
  z-index: 580;
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-height: 30px;
  padding: 2px 7px;
  box-sizing: border-box;
  background: #171715;
  border-radius: 6px 0 0;
}

.map-selector .mapboxgl-ctrl-bottom-right > .mapboxgl-ctrl {
  float: none;
  margin: 0;
}

.map-selector .mapboxgl-ctrl-bottom-right > .mapboxgl-ctrl-attrib {
  order: 1;
  min-width: 0;
}

@media (max-width: 1023px) {
  .map-selector > .map-wrapper::after {
    content: '';
    position: absolute;
    z-index: 505;
    inset: auto 0 0;
    height: 30px;
    background: #171715;
    pointer-events: none;
  }

  .map-wrapper > .map-switches {
    bottom: 35px;
    left: 8px;
  }

  .map-selector > .map-footer {
    bottom: 0;
    left: 8px;
    max-width: calc(100% - 150px);
    height: 30px;
    box-sizing: border-box;
    padding: 0;
    display: flex;
    align-items: center;
    pointer-events: none;
  }

  .map-selector .map-footer .map-place-row {
    max-width: 100%;
    margin: 0;
    gap: 6px;
  }

  .map-selector .leaflet-bottom.leaflet-right {
    z-index: 580;
  }
}

@media (max-width: 420px) {
  .map-selector .map-footer .map-place-row {
    display: grid;
    gap: 0;
    line-height: 1.2;
  }
  .map-selector .map-footer .map-place { font-size: 11px; }
  .map-selector .map-footer .map-coords { font-size: 9px; }
}

/* The fixed next-step bar otherwise clips the second switch on short phones.
   Reserve room for the step heading and the map, letting the ring view flex. */
@media (max-width: 1023px) and (max-height: 740px) {
  .app--location .viewer-section {
    flex: 0 1 42vh;
    min-height: 112px;
  }
  .app--location .controls-section {
    min-height: 279px;
  }
}

@media (max-width: 1023px) and (max-height: 480px) {
  .app--location .viewer-section { position: relative; }
}
