.accident-map-popup a {
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 5px;
  background: #075aa3;
  color: #fff;
  text-decoration: none;
}

.accident-map-popup a:hover { background: #064779; }
.accident-map-legend { right: 12px; left: auto; }
.accident-map-controls { right: auto; left: 12px; }
.accident-map-legend[data-collapsed="true"] { width: auto; }
.accident-map-legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  padding-left: 6px;
  color: #163859;
  font-size: 13px;
  white-space: nowrap;
}
.accident-map-legend-toggle {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: #eaf3f9;
  color: #163859;
  cursor: pointer;
}
.accident-map-legend-toggle::before { content: '−'; font-size: 24px; line-height: 1; }
.accident-map-legend-toggle[aria-expanded="false"]::before { content: '+'; }
.accident-map-legend-toggle:hover { background: #d9eaf5; }
.accident-map-legend-toggle:focus-visible { outline: 3px solid #ffbf47; outline-offset: 2px; }
.accident-map-mobile-legend-label { display: none; }
.accident-map-mobile-tools { display: none; }
.accident-map-popup.accident-map-popup--multi h3 {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 4px 32px 8px 0;
  border-bottom: 1px solid #dce5ee;
  background: #fff;
}
.accident-map-popup-entries { max-height: 248px; margin-top: 0; overflow-y: auto; }
.accident-map-popup-entry {
  margin: 0;
  padding: 8px 0 10px;
  border-bottom: 1px solid #e4ebf1;
}
.accident-map-popup-entry:last-child { border-bottom: 0; }
.accident-map-popup-grouped-list { margin: 5px 0; }
.accident-map-popup--single .accident-map-popup-body { max-height: 250px; overflow-y: auto; }
.accident-map-popup .accident-map-popup-summary { margin: 0 0 4px; }
.accident-map-popup-entry-actions { margin-top: 4px; }
.accident-map-popup-entry-actions a { margin-top: 0; }
.accident-map-popup h3 { padding-right: 24px; }
.accident-map-popup-layer .maplibregl-popup-tip {
  align-self: flex-start;
  margin-left: calc(var(--popup-tip-offset, 50%) - 10px);
}
.accident-map-popup-layer .maplibregl-popup-close-button {
  z-index: 2;
  width: 36px;
  height: 36px;
  font-size: 23px;
}

@media (max-width: 767px) {
  .accident-map-legend { right: 9px; left: auto; }
  .accident-map-controls { right: auto; left: 9px; }
  .accident-map-legend-header { min-height: 44px; padding-left: 0; }
  .accident-map-legend-header strong { display: none; }
  .accident-map-legend-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-width: 44px;
    height: 44px;
    padding: 0 10px;
    background: #fff;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
  }
  .accident-map-legend[data-collapsed="true"] .accident-map-legend-toggle { width: auto; }
  .accident-map-legend-toggle::before { content: none; }
  .accident-map-legend-toggle[aria-expanded="false"]::before { content: none; }
  .accident-map-legend-toggle::after {
    content: '';
    display: block;
    flex: none;
    width: 0;
    height: 0;
    border-right: 5px solid transparent;
    border-left: 5px solid transparent;
    border-top: 6px solid #111;
  }
  .accident-map-legend-toggle[aria-expanded="true"]::after {
    border-top: 0;
    border-bottom: 6px solid #111;
  }
  .accident-map-mobile-legend-label { display: inline; }
  .accident-map-mobile-tools { display: block; padding: 4px; }
  .accident-map-mobile-tools output { display: block; color: #35516c; font-size: 11px; line-height: 1.35; }
  .accident-map-settings-toggle {
    display: block;
    width: 100%;
    min-height: 44px;
    margin-top: 6px;
    padding: 8px 10px;
    border: 1px solid #bad4e7;
    border-radius: 6px;
    background: #eaf3f9;
    color: #163859;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
  }
  .accident-map-settings-toggle::after { content: ' ▾'; }
  .accident-map-settings-toggle[aria-expanded="true"]::after { content: ' ▴'; }
  .accident-map-settings-toggle:focus-visible { outline: 3px solid #ffbf47; outline-offset: 2px; }
  .accident-map-popup-layer .maplibregl-popup {
    position: absolute !important;
    top: auto !important;
    right: 12px !important;
    bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    left: 12px !important;
    width: auto !important;
    max-width: none !important;
    transform: none !important;
    z-index: 5;
  }

  .accident-map-popup-layer .maplibregl-popup-tip { display: none; }
  .accident-map-popup-layer .maplibregl-popup-content {
    width: 100%;
    box-sizing: border-box;
    max-height: min(220px, 48vh);
    overflow: auto;
    padding: 13px 14px 14px;
    border-radius: 12px;
    box-shadow: 0 3px 18px rgba(10, 30, 55, .32);
  }

  .accident-map-popup { max-width: none; padding-right: 31px; }
  .accident-map-popup-entries { max-height: none; overflow: visible; }
  .accident-map-popup--single {
    display: flex;
    flex-direction: column;
    max-height: min(193px, calc(48vh - 27px));
    padding-right: 0;
  }
  .accident-map-popup--single .accident-map-popup-body {
    min-height: 0;
    overflow: auto;
    padding-right: 31px;
  }
  .accident-map-popup--single .accident-map-popup-actions { flex: none; }
  .accident-map-popup h3 { padding-right: 0; }
  .accident-map-popup.accident-map-popup--multi h3 { position: static; padding-right: 34px; }
  .accident-map-popup a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    margin-top: 10px;
    padding: 10px 12px;
    text-align: center;
  }

  .accident-map-popup-layer .maplibregl-popup-close-button {
    width: 44px;
    height: 44px;
    font-size: 25px;
  }
}
