.map-shell, .map-viewport { position: relative; width: 100%; height: 100%; }

.map-shell {
  overflow: hidden;
  background: #fff;
}

.map-viewport {
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.map-viewport.is-dragging { cursor: grabbing; }
.map-viewport.is-annotating { cursor: crosshair; }

.map-viewer {
  position: absolute;
  z-index: 1;
  inset: 0;
  visibility: hidden;
  background: #fff url("../assets/map/huanglian-map-placeholder.webp") 45% 45% / cover no-repeat;
}
.map-tiles-active .map-viewer { visibility: visible; }
.map-tiles-ready .map-viewer { background-image: none; }
.map-tiles-active .map-canvas { pointer-events: none; }
.map-tiles-active .map-canvas .map-image { display: none; }
.map-tiles-active .map-canvas .site-record { pointer-events: auto; }

.map-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 8091px;
  height: 5669px;
  transform-origin: 0 0;
}

.map-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
.hotspot-layer {
  position: absolute;
  z-index: 6;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.hotspot-anchor, .hotspot { pointer-events: auto; }

.hotspot-anchor {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 2;
  scale: var(--hotspot-group-scale, 1);
  transform-origin: 0 0;
  transition: opacity 180ms ease;
}

.hotspot {
  position: absolute;
  z-index: 2;
  left: 0;
  top: 0;
  width: 48px;
  height: 48px;
  padding: 0;
  transform: translate(-50%, -72%) rotate(-45deg);
  border: 3px solid rgba(255,255,255,0.96);
  border-radius: 50% 50% 50% 15%;
  color: white;
  background: var(--brick);
  box-shadow: 0 7px 18px rgba(28,52,41,0.3);
  font-size: 15px;
  cursor: pointer;
  transition: opacity 180ms ease, background 180ms ease;
}
.hotspot::after {
  content: "";
  position: absolute;
  width: 34%;
  height: 34%;
  left: 33%;
  top: 33%;
  border-radius: 50%;
  background: rgba(255,255,255,0.96);
}

/* 手绘地图图钉：珊瑚色水滴承托圆形景点插画。 */
.hotspot.has-icon {
  width: 64px;
  height: 64px;
  padding: 0;
  transform: translate(-50%, -82%);
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
}
.hotspot.has-icon::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 4px;
  top: 4px;
  box-sizing: border-box;
  width: 56px;
  height: 56px;
  transform: rotate(-45deg);
  border: 3px solid rgba(255,255,255,0.98);
  border-radius: 50% 50% 50% 15%;
  background: #e56e55;
  box-shadow: -7px 8px 16px rgba(67,52,37,0.3);
}
.hotspot.has-icon::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: 9px;
  top: 9px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff9ec;
}
.hotspot-icon {
  position: absolute;
  z-index: 2;
  left: 12px;
  top: 12px;
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 50%;
}
.hotspot.has-icon:hover::before,
.hotspot.has-icon:focus-visible::before,
.hotspot.has-icon.is-dragging::before {
  background: #c64f3e;
}
.hotspot.has-icon:focus-visible::before {
  box-shadow: 0 0 0 4px rgba(32,104,139,0.42), -7px 8px 16px rgba(67,52,37,0.3);
}
.hotspot:not(.has-icon):hover,
.hotspot:not(.has-icon):focus-visible { background: var(--water-deep); }
.hotspot:not(.has-icon).is-dragging { background: var(--water-deep); }

.hotspot-label {
  position: absolute;
  z-index: 1;
  min-width: max-content;
  transform: translate(-50%, calc(-100% - 47px));
  padding: 5px 9px;
  border: 1px solid rgba(63,99,60,0.34);
  border-radius: 8px 8px 8px 2px;
  color: var(--ink);
  background: rgba(250,252,248,0.94);
  box-shadow: 0 5px 15px rgba(28,52,41,0.18);
  font-family: STKaiti, KaiTi, "Microsoft YaHei", sans-serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 180ms ease, border-color 180ms ease;
}
.hotspot-label::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 8px;
  height: 8px;
  transform: translateX(-50%) rotate(45deg);
  border-right: 1px solid rgba(63,99,60,0.34);
  border-bottom: 1px solid rgba(63,99,60,0.34);
  background: rgba(250,252,248,0.94);
}
.hotspot-label.is-below { transform: translate(-50%, 27px); }
.hotspot-label.is-below::after {
  top: -5px;
  bottom: auto;
  transform: translateX(-50%) rotate(225deg);
}
.hotspot-label.has-icon {
  transform: translate(40px, calc(-50% - 20px));
  transform-origin: 0 50%;
}
.hotspot-label.has-icon::after {
  top: 50%;
  right: auto;
  bottom: auto;
  left: -5px;
  border-top: 1px solid rgba(63,99,60,0.34);
  border-right: 0;
  border-bottom: 0;
  border-left: 1px solid rgba(63,99,60,0.34);
  transform: translateY(-50%) rotate(-45deg);
}

.map-toolbar {
  position: absolute;
  z-index: 10;
  top: 50%;
  right: max(18px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transform: translateY(-50%);
  padding: 6px;
  border: 1px solid rgba(255,255,255,0.76);
  border-radius: 18px;
  background: rgba(245,247,242,0.9);
  box-shadow: 0 12px 32px rgba(28,52,41,0.2);
  backdrop-filter: blur(14px);
}
.map-toolbar button {
  display: grid;
  place-items: center;
  width: 42px;
  min-height: 42px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}
.map-toolbar button:hover { color: white; background: var(--moss-dark); }
.map-toolbar button span { font-size: 1.25rem; line-height: 1; }
.map-toolbar output {
  min-width: 42px;
  padding: 3px 0;
  color: var(--ink-soft);
  text-align: center;
  font: 700 0.63rem Bahnschrift, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
.toolbar-rule { width: 24px; height: 1px; margin: 2px 0; background: var(--line); }
.map-toolbar .reset-button { font-size: 0.75rem; font-weight: 700; }

.spot-card[hidden] { display: none; }
.spot-card {
  position: absolute;
  z-index: 14;
  left: 50%;
  bottom: max(23px, calc(env(safe-area-inset-bottom) + 16px));
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: min(650px, calc(100% - 150px));
  min-height: 72px;
  transform: translateX(-50%);
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: 20px;
  background: rgba(245,247,242,0.95);
  box-shadow: 0 18px 48px rgba(28,52,41,0.24);
  backdrop-filter: blur(16px) saturate(1.08);
  animation: spot-card-arrive 220ms ease-out both;
}
.spot-card-sign {
  position: relative;
  width: 34px;
  height: 48px;
  border-radius: 7px 7px 3px 3px;
  background: var(--moss-dark);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.24);
}
.spot-card-sign::before, .spot-card-sign::after, .spot-card-sign span {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  height: 3px;
  border-radius: 999px;
  background: #e0b649;
}
.spot-card-sign::before { top: 11px; }
.spot-card-sign span { top: 21px; }
.spot-card-sign::after { top: 31px; }
.spot-card-copy { min-width: 0; }
.spot-card-copy p { margin: 0 0 2px; color: var(--brick); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.12em; }
.spot-card-copy h2 { overflow: hidden; margin: 0; font-family: STKaiti, KaiTi, "Microsoft YaHei", sans-serif; font-size: 1.12rem; text-overflow: ellipsis; white-space: nowrap; }
.spot-card-actions { display: flex; gap: 8px; }
.spot-card-actions button {
  min-height: 42px;
  border-radius: 999px;
  padding: 0.68rem 1rem;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}
.spot-card-secondary { border: 1px solid rgba(63,99,60,0.28); color: var(--moss-dark); background: transparent; }
.spot-card-primary { border: 0; color: white; background: var(--brick); box-shadow: 0 8px 18px rgba(185,78,61,0.22); }
.spot-card-primary.has-no-coordinate::after { content: " · 待接入"; opacity: 0.72; font-size: 0.66rem; }
.spot-card-close { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; color: var(--ink-soft); background: rgba(36,52,47,0.07); font-size: 1.25rem; cursor: pointer; }

@keyframes spot-card-arrive {
  from { transform: translate(-50%, 12px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
.map-hint, .placeholder-notice {
  position: absolute;
  z-index: 8;
  margin: 0;
  color: rgba(36,52,47,0.76);
  font-size: 0.68rem;
  text-shadow: 0 1px 5px rgba(255,255,255,0.92);
  pointer-events: none;
}
.map-hint { right: max(18px, env(safe-area-inset-right)); bottom: max(16px, calc(env(safe-area-inset-bottom) + 10px)); }
.placeholder-notice { left: max(18px, env(safe-area-inset-left)); bottom: max(16px, calc(env(safe-area-inset-bottom) + 10px)); }

.map-load-status {
  position: absolute;
  z-index: 18;
  left: 50%;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px));
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  padding: 0.55rem 0.85rem;
  border: 1px solid rgba(255,255,255,0.78);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(245,247,242,0.94);
  box-shadow: 0 8px 24px rgba(28,52,41,0.18);
  font-size: 0.72rem;
  white-space: nowrap;
}
.map-load-status[hidden] { display: none; }

@media (max-width: 720px) {
  .map-toolbar { top: auto; right: max(10px, env(safe-area-inset-right)); bottom: calc(100px + env(safe-area-inset-bottom)); transform: none; }
  .map-toolbar button { width: 40px; min-height: 40px; }
  .map-toolbar output, .toolbar-rule { display: none; }
  .spot-card {
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(10px + env(safe-area-inset-bottom));
    grid-template-columns: 30px minmax(0, 1fr) auto;
    width: auto;
    transform: none;
    gap: 9px;
    padding: 10px;
    border-radius: 18px;
    animation-name: spot-card-arrive-mobile;
  }
  .spot-card-sign { width: 30px; height: 44px; }
  .spot-card-copy h2 { font-size: 1rem; }
  .spot-card-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1.25fr; width: 100%; }
  .spot-card-actions button { min-height: 40px; padding: 0.58rem 0.7rem; }
  .spot-card-close { position: absolute; right: 8px; top: 8px; width: 30px; height: 30px; }
  .spot-card-copy { padding-right: 32px; }
  .map-hint, .placeholder-notice { display: none; }
}

@keyframes spot-card-arrive-mobile {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
