body.history-map .site-main {
  max-width: 92rem;
}
body.history-map .page-layout--full,
body.history-map .page-main {
  max-width: none;
}

.hm-page h1 {
  font-size: 1.7rem;
  line-height: 1.2;
  margin-bottom: 0.35rem;
}
.hm-note {
  background: var(--color-warning-bg);
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin: 0.8rem 0 1rem;
  color: #78350f;
}

.hm-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  gap: 1rem;
  align-items: stretch;
}
.hm-map-wrap {
  background: #d7eef8;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 28rem;
}
#history-map-canvas {
  height: min(68vh, 40rem);
  min-height: 28rem;
  background: #d7eef8;
}
.hm-side {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  max-height: min(68vh, 40rem);
  overflow: auto;
}
.hm-year {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 600;
  line-height: 1;
}
.hm-polity {
  font-weight: 700;
  margin: 0.35rem 0;
}
.hm-change {
  margin-bottom: 0.8rem;
}
.hm-events {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.hm-event {
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.55rem 0.65rem;
  cursor: pointer;
}
.hm-event.is-active {
  border-color: var(--color-primary);
  background: #e0f2fe;
}
.hm-event__year {
  font-family: var(--font-mono);
  font-weight: 600;
  margin-right: 0.4rem;
}
.hm-event__title {
  font-weight: 700;
}
.hm-event__people,
.hm-event__text {
  display: block;
}
.hm-event__people {
  color: var(--color-primary-dark);
  font-size: 0.92em;
}
.hm-event__text {
  margin-top: 0.2rem;
}

.hm-controls {
  margin-top: 0.9rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.8rem 0.9rem;
}
.hm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}
.hm-chip {
  font: inherit;
  font-family: var(--font-mono);
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  cursor: pointer;
}
.hm-chip[aria-current="true"] {
  background: var(--color-header);
  color: #fff;
  border-color: var(--color-header);
}
.hm-slider {
  width: 100%;
  margin: 0.2rem 0 0.7rem;
}
.hm-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.hm-buttons button,
.hm-speed {
  font: inherit;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}
.hm-buttons button:disabled {
  opacity: 0.45;
  cursor: default;
}
#hm-play {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary-dark);
}
.hm-speed {
  margin-left: auto;
}
.hm-counter {
  font-family: var(--font-mono);
}
.hm-key {
  margin: 0.7rem 0 0.35rem;
  color: var(--color-muted);
}
.hm-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  list-style: none;
  margin-top: 0.7rem;
}
.hm-legend__item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.hm-legend__item::before {
  content: "";
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 2px;
  background: #38bdf8;
  border: 1px solid #075985;
}
.hm-legend__item--neighbor::before {
  background: #fdba74;
  border-color: #9a3412;
}
.leaflet-tooltip.hm-neighbor-label {
  background: rgba(255, 251, 235, 0.94);
  border: 1px solid #9a3412;
  color: #7c2d12;
  box-shadow: none;
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  font: 600 0.72rem/1.25 var(--font-base);
  white-space: normal;
  width: max-content;
  max-width: 8.5rem;
  text-align: center;
  pointer-events: none;
}
.leaflet-tooltip.hm-neighbor-label::before {
  display: none;
}

@media (max-width: 860px) {
  .hm-stage {
    grid-template-columns: 1fr;
  }
  .hm-side,
  #history-map-canvas {
    max-height: none;
    height: auto;
  }
  #history-map-canvas {
    height: 22rem;
    min-height: 22rem;
  }
  .hm-speed {
    margin-left: 0;
  }
}
