.history-map-canvas {
  --history-map-sea: #ead8bb;
  --history-map-sea-wash: rgba(243, 227, 203, 0.54);
  --history-map-land: #dcc6a4;
  --history-map-land-line: #59617a;
  --history-map-point: #963d2b;
  --history-map-point-stroke: #f4e3c8;
  --history-map-point-active: #252d46;
  --history-map-national: #963d2b;
  --history-map-focus-ring: #21180f;
  --history-map-tooltip-bg: #f7e9d3;

  width: 100%;
  min-height: 610px;
  background-color: var(--history-map-sea);
  background-image: linear-gradient(var(--history-map-sea-wash), var(--history-map-sea-wash));
  font-family: var(--ho-font-ui);
  transition: background-color 360ms cubic-bezier(0.22, 1, 0.36, 1);
}

.history-map-canvas[data-map-theme="today"] {
  --history-map-sea: var(--today-map-sea, #d8e7e7);
  --history-map-sea-wash: color-mix(in srgb, var(--today-map-sea, #d8e7e7) 78%, transparent);
  --history-map-land: var(--today-map-land, #f3f1e8);
  --history-map-land-line: var(--today-muted, #52686c);
  --history-map-point: var(--today-accent, #286c73);
  --history-map-point-stroke: var(--today-panel, #f7faf8);
  --history-map-point-active: var(--today-focus, #174f58);
  --history-map-focus-ring: var(--today-focus, #174f58);
  --history-map-tooltip-bg: var(--today-panel, #f7faf8);
}

.history-map-canvas .leaflet-pane,
.history-map-canvas .leaflet-control {
  z-index: auto;
}

.history-map-canvas .leaflet-overlay-pane {
  z-index: 400;
}

.history-map-canvas .leaflet-tooltip-pane {
  z-index: 650;
}

.history-map-canvas .leaflet-control-container {
  position: relative;
  z-index: 4;
}

.history-map-canvas .leaflet-control-zoom {
  margin: 18px;
  overflow: hidden;
  border: 1px solid var(--ho-line-strong);
  border-radius: var(--ho-radius-control);
  box-shadow: none;
}

.history-map-canvas .leaflet-control-zoom a {
  width: 44px;
  height: 44px;
  border: 0;
  border-bottom: 1px solid var(--ho-line);
  background: var(--ho-paper-raised);
  color: var(--ho-indigo);
  font-family: var(--ho-font-ui);
  font-size: 1.3rem;
  line-height: 44px;
}

.history-map-canvas .leaflet-control-zoom a:last-child {
  border-bottom: 0;
}

.history-map-canvas .leaflet-control-zoom a:hover,
.history-map-canvas .leaflet-control-zoom a:focus-visible {
  background: color-mix(in srgb, var(--ho-paper-raised) 84%, var(--ho-paper-deep));
  color: var(--ho-ink);
}

.history-map-canvas .leaflet-control-attribution {
  margin: 0;
  padding: 4px 7px;
  background: color-mix(in srgb, var(--ho-paper-raised) 90%, transparent);
  color: var(--ho-ink-muted);
  font-size: 0.7rem;
}

.history-map-canvas .leaflet-control-attribution a {
  color: var(--ho-indigo);
}

.history-map-canvas .history-map-land {
  fill: var(--history-map-land);
  stroke: var(--history-map-land-line);
  transition:
    fill 360ms cubic-bezier(0.22, 1, 0.36, 1),
    stroke 360ms cubic-bezier(0.22, 1, 0.36, 1);
}

.history-map-canvas.is-national-preview .history-map-land,
.history-map-canvas.is-national-selected .history-map-land {
  fill: color-mix(in srgb, var(--history-map-national) 12%, var(--history-map-land));
  stroke: var(--history-map-national);
  stroke-width: 1.8px;
}

.history-map-canvas.is-national-selected .history-map-land {
  fill: color-mix(in srgb, var(--history-map-national) 18%, var(--history-map-land));
  stroke-width: 2.2px;
}

.history-map-point {
  cursor: pointer;
  fill: var(--history-map-point);
  stroke: var(--history-map-point-stroke);
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
  transition:
    fill 360ms ease,
    opacity 180ms ease,
    stroke 360ms ease,
    stroke-width 180ms ease;
}

.history-map-point.is-filtered-out,
.history-map-route.is-filtered-out {
  opacity: 0;
  pointer-events: none;
}

.history-map-route {
  cursor: pointer;
  fill: none;
  opacity: 0.64;
  stroke: var(--history-map-point);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2px;
  vector-effect: non-scaling-stroke;
  transition: opacity 160ms ease, stroke 300ms ease, stroke-width 160ms ease;
}

.history-map-route:hover,
.history-map-route.is-preview {
  opacity: 0.9;
  stroke: var(--history-map-point-active);
  stroke-width: 3px;
}

.history-map-route.is-selected {
  opacity: 1;
  stroke: var(--history-map-point-active);
  stroke-width: 3.5px;
}

.history-map-canvas.is-theme-switching .history-map-point {
  opacity: 0;
}

.history-map-point:hover,
.history-map-point.is-preview {
  fill: var(--history-map-point-active);
  stroke-width: 3px;
}

.history-map-point.is-selected {
  fill: var(--history-map-point-active);
  stroke: var(--history-map-point-stroke);
  stroke-width: 3.5px;
}

.history-map-point:focus {
  outline: none;
}

.history-map-point:focus-visible {
  fill: var(--history-map-point-active);
  stroke: var(--history-map-point-stroke);
  stroke-width: 4px;
  filter:
    drop-shadow(0 0 1px var(--history-map-focus-ring))
    drop-shadow(0 0 3px var(--history-map-focus-ring));
}

.history-map-tooltip.leaflet-tooltip {
  width: min(300px, calc(100vw - 44px));
  max-width: 300px;
  padding: 0;
  border: 1px solid var(--ho-line-strong);
  border-radius: var(--ho-radius-control);
  opacity: 1 !important;
  background-color: var(--history-map-tooltip-bg) !important;
  background-image: none !important;
  box-shadow: 0 9px 24px color-mix(in srgb, var(--ho-ink) 16%, transparent);
  color: var(--ho-ink);
  backdrop-filter: none;
  pointer-events: none;
  white-space: normal !important;
}

.history-map-tooltip.leaflet-tooltip-top::before {
  border-top-color: var(--history-map-tooltip-bg) !important;
}

.history-map-tooltip-content {
  display: grid;
  gap: 2px;
  padding: 11px 13px 12px;
  line-height: 1.3;
}

.history-map-tooltip-content strong {
  font-family: var(--ho-font-reading);
  font-size: 0.98rem;
  font-weight: 600;
}

.history-map-tooltip-content > span {
  color: var(--ho-ink-muted);
  font-size: var(--ho-type-meta);
}

.history-map-tooltip-meta {
  color: var(--ho-vermilion) !important;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.history-map-tooltip-description {
  display: -webkit-box;
  margin-top: 5px;
  padding-top: 6px;
  overflow: hidden;
  border-top: 1px solid var(--ho-line);
  color: var(--ho-ink) !important;
  font-family: var(--ho-font-reading);
  font-size: 0.84rem !important;
  line-height: 1.38;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.history-map-tooltip-location {
  margin-top: 4px;
  color: var(--ho-ink) !important;
  font-family: var(--ho-font-ui);
  font-size: 0.74rem !important;
  font-weight: 670;
}

.history-map-tooltip-label {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--ho-line);
  color: var(--ho-ink-muted) !important;
  font-family: var(--ho-font-ui);
  font-size: 0.72rem !important;
  font-weight: 680;
}

.history-map-tooltip-place-list {
  display: grid;
  gap: 5px;
  margin: 2px 0 0;
  padding: 0;
  color: var(--ho-ink);
  list-style: none;
}

.history-map-tooltip-place-list li {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 9px;
  margin: 0;
  align-items: center;
}

.history-map-tooltip-place-list a,
.history-map-tooltip-place-list span {
  display: block;
  color: var(--ho-ink) !important;
  font-family: var(--ho-font-reading);
  font-size: 0.88rem !important;
  line-height: 1.35;
}

.history-map-tooltip-place-list a {
  text-decoration-color: var(--today-line, var(--ho-line-strong));
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.history-map-place-thumb {
  display: grid !important;
  width: 38px;
  height: 30px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--ho-line);
  background: color-mix(in srgb, var(--today-accent-soft, var(--ho-paper-deep)) 64%, var(--ho-paper-raised));
  color: var(--ho-ink-muted) !important;
  font-family: var(--ho-font-ui) !important;
  font-size: 0.58rem !important;
  font-weight: 720;
  object-fit: cover;
}

.history-map-place-copy {
  display: grid !important;
  min-width: 0;
  gap: 1px;
}

.history-map-place-copy small {
  color: var(--ho-ink-muted);
  font-size: 0.72rem;
  line-height: 1.25;
}

.history-map-tooltip.leaflet-tooltip:has(.history-map-tooltip-content.is-pinned) {
  pointer-events: auto;
}

@media (max-width: 860px) {
  .history-map-canvas {
    min-height: min(66vh, 560px);
  }
}

@media (max-width: 520px) {
  .history-map-canvas {
    min-height: 440px;
  }

  .history-map-canvas .leaflet-control-zoom {
    margin: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .history-map-canvas,
  .history-map-canvas .history-map-land,
  .history-map-point {
    transition: none;
  }
}
