.map-settings-dialog {
  width: min(440px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: 1px solid #c7d4e2;
  border-radius: 10px;
  background: #fff;
  color: #294b73;
  box-shadow: 0 16px 60px #10243e40;
  overflow-y: auto;
  overscroll-behavior: contain;
  font: 14px/1.6 "Fira Sans", Arial, Helvetica, sans-serif;
}

.map-settings-dialog::backdrop {
  background: #10243e80;
}

.map-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px 14px 22px;
  border-bottom: 1px solid #dfe6ef;
  background: linear-gradient(to right, #294b73, #3d658e);
  color: #fff;
}

.map-settings-header h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.4;
  font-weight: 600;
}

.map-settings-close {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #fff;
  font: 28px/1 "Fira Sans", Arial, Helvetica, sans-serif;
  cursor: pointer;
}

.map-settings-close:hover {
  background: #ffffff20;
}

.map-settings-body {
  padding: 21px 22px 18px;
}

.map-settings-body > p {
  margin: 0;
}

.map-settings-view,
.map-settings-basemaps {
  min-width: 0;
  margin: 21px 0 0;
  padding: 0;
  border: 0;
}

.map-settings-view legend,
.map-settings-basemaps legend {
  margin-bottom: 11px;
  padding: 0;
  color: #294b73;
  font-size: 13px;
  font-weight: 600;
}

.map-settings-view-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  padding: 4px;
  border: 1px solid #c8d6e5;
  border-radius: 6px;
  background: #f4f7fb;
}

.map-settings-view-controls button {
  min-width: 0;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #294b73;
  font: 600 13px/1.5 "Fira Sans", Arial, Helvetica, sans-serif;
  cursor: pointer;
}

.map-settings-view-controls button:hover {
  background: #e2ebf5;
}

.map-settings-view-controls button[aria-pressed="true"] {
  background: #294b73;
  color: #fff;
}

.map-settings-view-controls button:disabled {
  cursor: not-allowed;
  opacity: .6;
}

.map-settings-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 70px;
  padding: 14px;
  border: 1px solid #c8d6e5;
  border-radius: 6px;
  background: #fff;
  color: #294b73;
  cursor: pointer;
}

.map-settings-option + .map-settings-option {
  margin-top: 10px;
}

.map-settings-option:hover {
  background: #f4f7fb;
}

.map-settings-option:has(input:checked) {
  border-color: #416a96;
  background: #edf3f9;
}

.map-settings-option input {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: #294b73;
}

.map-settings-option > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.map-settings-option strong {
  display: block;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 600;
}

.map-settings-option small {
  display: block;
  margin-top: 3px;
  color: #526176;
  font-size: 12px;
  line-height: 1.55;
}

.map-settings-basemaps:disabled .map-settings-option {
  cursor: not-allowed;
}

.map-settings-body .map-settings-status {
  min-height: 22px;
  margin-top: 13px;
  color: #294b73;
  font-size: 12px;
  line-height: 1.7;
}

.map-settings-body .map-settings-credit {
  margin-top: 9px;
  color: #526176;
  font-size: 11px;
  line-height: 1.7;
}

.map-settings-credit a {
  color: #294b73;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.map-settings-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 22px;
  border-top: 1px solid #dfe6ef;
  background: #f4f7fb;
}

.map-settings-footer p {
  margin: 0;
  color: #526176;
  font-size: 11px;
  line-height: 1.6;
}

.map-settings-done {
  flex-shrink: 0;
  min-width: 76px;
  min-height: 40px;
  padding: 8px 17px;
  border: 1px solid #294b73;
  border-radius: 5px;
  background: #294b73;
  color: #fff;
  font: 600 13px/1.4 "Fira Sans", Arial, Helvetica, sans-serif;
  cursor: pointer;
}

.map-settings-done:hover {
  background: #203c60;
}

.map-settings-dialog :focus-visible {
  outline: 2px solid #294b73;
  outline-offset: 4px;
}

.map-settings-close:focus-visible {
  outline-color: #fff;
  outline-offset: -3px;
}

@media (max-width: 440px) {
  .map-settings-header {
    padding-left: 18px;
  }

  .map-settings-body,
  .map-settings-footer {
    padding-inline: 18px;
  }

  .map-settings-option {
    gap: 10px;
    padding: 12px;
  }

  .map-settings-close,
  .map-settings-done {
    min-height: 44px;
  }
}
.map-settings-dialog { width: min(1040px, calc(100vw - 48px)); height: min(760px, calc(100dvh - 64px)); max-width: calc(100vw - 48px); background: #edf3f9f2; -webkit-backdrop-filter: blur(28px) saturate(115%); backdrop-filter: blur(28px) saturate(115%); overflow: hidden; }
.map-settings-dialog[open] { display: flex; flex-direction: column; }
.map-settings-dialog::backdrop { background: #18334b66; -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.map-settings-header { padding: 17px 24px 17px 30px; flex-shrink: 0; }
.map-settings-header h2 { font-size: 20px; }
.map-settings-body { padding: 28px 30px; flex: 1; min-height: 0; overflow-y: auto; }
.map-settings-body > * { max-width: 620px; }
.map-settings-footer { padding: 18px 30px; flex-shrink: 0; background: #edf3f9b3; }
@media (max-width: 640px) {
  .map-settings-dialog { width: calc(100vw - 24px); max-width: calc(100vw - 24px); height: calc(100dvh - 32px); }
  .map-settings-header, .map-settings-body, .map-settings-footer { padding-inline: 18px; }
}

/* Base maps of each view: three cards with a small preview, and the globe's display switches. */
.map-settings-globe { min-width: 0; margin: 21px 0 0; padding: 0; border: 0; }
.map-settings-globe legend { margin-bottom: 11px; padding: 0; color: #294b73; font-size: 13px; font-weight: 600; }
.map-settings-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.map-settings-choice {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 8px 10px 10px;
  border: 1px solid #c8d6e5;
  border-radius: 8px;
  background: #fff;
  color: #294b73;
  cursor: pointer;
}
.map-settings-choice:hover { background: #f4f7fb; }
.map-settings-choice:has(input:checked) { border-color: #294b73; box-shadow: inset 0 0 0 1px #294b73; background: #edf3f9; }
.map-settings-choice:has(input:focus-visible) { outline: 2px solid #294b73; outline-offset: 3px; }
.map-settings-choice input { position: absolute; top: 14px; right: 14px; width: 16px; height: 16px; margin: 0; accent-color: #294b73; }
.map-settings-choice strong { font-size: 13px; line-height: 1.4; font-weight: 600; }
.map-settings-choice small { color: #526176; font-size: 11.5px; line-height: 1.45; }
.map-settings-basemaps:disabled .map-settings-choice { cursor: not-allowed; opacity: .6; }
.map-settings-swatch { display: block; height: 46px; margin-bottom: 6px; border-radius: 5px; border: 1px solid #0f2c4d1f; }
.map-settings-swatch.is-flat-osm, .map-settings-swatch.is-globe-osm {
  background:
    linear-gradient(115deg, transparent 46%, #f7d69b 47%, #f7d69b 50%, transparent 51%),
    linear-gradient(25deg, transparent 58%, #ffffff 59%, #ffffff 62%, transparent 63%),
    radial-gradient(circle at 78% 30%, #aad3df 0 22%, transparent 23%),
    linear-gradient(#cfe5c4, #e9e5dc 60%);
}
.map-settings-swatch.is-flat-satellite, .map-settings-swatch.is-globe-satellite {
  background:
    radial-gradient(ellipse at 30% 60%, #6f7a45 0 24%, transparent 25%),
    radial-gradient(ellipse at 62% 40%, #b49a6a 0 20%, transparent 21%),
    radial-gradient(ellipse at 80% 72%, #ffffffcc 0 8%, transparent 14%),
    linear-gradient(160deg, #1d4b6e, #0f2c46);
}
.map-settings-swatch.is-flat-none {
  background:
    repeating-linear-gradient(90deg, transparent 0 18px, #b4c7d8 18px 19px),
    repeating-linear-gradient(0deg, transparent 0 14px, #b4c7d8 14px 15px),
    radial-gradient(ellipse at 38% 55%, #f5f8fb 0 30%, #7f97ad 31% 32%, transparent 33%),
    #dce8f1;
}
.map-settings-swatch.is-globe-none {
  background:
    radial-gradient(circle at 50% 120%, transparent 58%, #5fd7ff 60%, #5fd7ff00 66%),
    radial-gradient(#5fd7ff 1px, transparent 1.4px) 0 0 / 7px 7px,
    radial-gradient(ellipse at 50% 120%, #08213a 0 60%, #02060f 61%);
}
.map-settings-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 2px;
  border-bottom: 1px solid #dfe6ef;
  cursor: pointer;
}
.map-settings-switch:last-of-type { border-bottom: 0; }
.map-settings-switch strong { display: block; font-size: 13px; font-weight: 600; line-height: 1.4; }
.map-settings-switch small { display: block; color: #526176; font-size: 11.5px; line-height: 1.45; }
.map-settings-switch input {
  position: relative;
  flex: 0 0 40px;
  width: 40px;
  height: 22px;
  margin: 0;
  border-radius: 11px;
  background: #b7c6d6;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: background .15s;
}
.map-settings-switch input::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px #0003;
  transition: transform .15s;
}
.map-settings-switch input:checked { background: #294b73; }
.map-settings-switch input:checked::after { transform: translateX(18px); }
.map-settings-switch input:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 520px) {
  .map-settings-choices { grid-template-columns: 1fr; }
  .map-settings-choice { display: grid; grid-template-columns: 64px 1fr; column-gap: 10px; align-items: center; padding-right: 36px; }
  .map-settings-swatch { grid-row: span 2; height: 40px; margin: 0; }
  .map-settings-choice input { top: 50%; transform: translateY(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .map-settings-switch input, .map-settings-switch input::after { transition: none; }
}
