/* 共通mainの余白を二重適用せず、固定ヘッダー直下を地図に使う。 */
.map-page main {
  max-width: none;
  padding: var(--topbar-h) 0 0;
}

.map-page main > .container {
  max-width: none;
  margin: 0;
}

.map-workbench {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--topbar-h));
  background: #f6f8fb;
}

.map-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid #dfe5ee;
  background: #fff;
}

.map-title-row h1 {
  margin: 0;
  color: #0a1224;
  font-size: 20px;
  line-height: 1.3;
}

.map-title-row p {
  margin: 2px 0 0;
  color: #5d6878;
  font-size: 13px;
}

.map-layer-button,
.map-panel-close {
  border: 1px solid #c8d2df;
  background: #fff;
  color: #0a1224;
  font: inherit;
  cursor: pointer;
}

.map-layer-button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  font-weight: 600;
}

.map-layer-button:hover,
.map-layer-button:focus-visible,
.map-panel-close:hover,
.map-panel-close:focus-visible {
  border-color: #2478ff;
  outline: none;
}

.map-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: clamp(420px, calc(100dvh - var(--topbar-h) - 96px), 720px);
  overflow: hidden;
  background: #e9eef5;
}

.map-canvas {
  position: absolute;
  inset: 0;
}

.map-layer-panel,
.map-detail {
  position: absolute;
  z-index: 5;
  top: 12px;
  right: 12px;
  width: min(320px, calc(100% - 24px));
  border: 1px solid #cfd8e5;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 8px 24px rgba(20, 35, 58, 0.12);
}

.map-layer-panel[hidden],
.map-detail[hidden] {
  display: none;
}

.map-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 8px 10px;
  border-bottom: 1px solid #e0e6ef;
}

.map-panel-close {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 4px;
  font-size: 20px;
  line-height: 1;
}

.map-layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  color: #152033;
  font-size: 14px;
}

.map-layer-row input {
  width: 16px;
  height: 16px;
  accent-color: #2478ff;
}

.map-layer-note {
  min-height: 18px;
  margin: 0;
  padding: 0 10px 10px;
  color: #657184;
  font-size: 12px;
}

.map-message {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  max-width: min(560px, calc(100% - 32px));
  padding: 10px 12px;
  border: 1px solid #d7dfea;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  color: #28364b;
  font-size: 13px;
}

.map-detail {
  top: auto;
  bottom: 54px;
  left: 12px;
  right: auto;
}

.map-detail dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 10px;
  margin: 0;
  padding: 10px;
  font-size: 13px;
}

.map-detail dt {
  color: #657184;
}

.map-detail dd {
  margin: 0;
  color: #152033;
}

.map-detail-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 16px;
}

.map-legal {
  position: absolute;
  z-index: 4;
  left: 8px;
  right: auto;
  bottom: 6px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 2px 8px;
  width: fit-content;
  max-width: min(520px, calc(100% - 84px));
  padding: 2px 4px;
  background: rgba(255, 255, 255, 0.9);
  color: #556176;
  font-size: 9px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
}

.map-legal span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-legal a {
  color: inherit;
}

.maplibregl-ctrl-bottom-right {
  bottom: 34px;
}

@media (max-width: 720px) {
  .map-page main {
    padding: var(--topbar-h) 0 0;
  }

  .map-workbench {
    min-height: calc(100dvh - var(--topbar-h));
  }

  .map-title-row {
    padding: 8px 10px;
  }

  .map-title-row h1 {
    font-size: 18px;
  }

  .map-title-row p {
    display: none;
  }

  .map-stage {
    min-height: max(420px, calc(100dvh - var(--topbar-h) - 52px));
  }

  .map-legal {
    left: 4px;
    bottom: 4px;
    max-width: calc(100% - 64px);
    padding: 2px 3px;
    font-size: 8px;
  }

  .map-layer-panel,
  .map-detail {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 48dvh;
    overflow: auto;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 10px 10px 0 0;
  }

  .map-detail {
    z-index: 7;
  }

  .map-legal {
    bottom: 4px;
    right: auto;
    max-width: calc(100% - 84px);
  }

  .maplibregl-ctrl-bottom-right {
    bottom: 42px;
  }
}
