.spatial-map-shell {
  --spatial-sheet-occlusion: 0px;
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  overflow: hidden;
  background: #dfe8e3;
}

.spatial-map-stage {
  position: absolute;
  inset: 0;
  min-width: 0;
  overflow: hidden;
  background: #e8efe9;
}

.spatial-map-canvas,
.spatial-local-map-canvas {
  position: absolute;
  top: 0;
  right: 0;
  bottom: var(--spatial-sheet-occlusion);
  left: 0;
  touch-action: none;
  transition: bottom .2s ease;
}

.spatial-local-map-canvas svg { width: 100%; height: 100%; }
.spatial-map-canvas[hidden], .spatial-local-map-canvas[hidden] { display: none; }

.spatial-map-control {
  position: absolute;
  z-index: 8;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid rgba(15, 23, 42, .14);
  border-radius: 12px;
  background: rgba(255, 255, 255, .94);
  color: #0f172a;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .16);
  font-size: 12px;
  font-weight: 800;
}

.spatial-map-back {
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
}

.spatial-fit-control {
  top: calc(max(12px, env(safe-area-inset-top)) + 52px);
  left: max(12px, env(safe-area-inset-left));
  width: 44px;
  height: 44px;
  padding: 10px;
  border-radius: 50%;
}

.spatial-fit-control svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.spatial-provider-attribution {
  position: absolute;
  z-index: 7;
  left: max(8px, env(safe-area-inset-left));
  bottom: calc(var(--spatial-sheet-occlusion) + max(8px, env(safe-area-inset-bottom)));
  max-width: calc(100% - 420px);
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .88);
  color: #334155;
  font-size: 9px;
}

.spatial-provider-attribution a { color: inherit; text-decoration: underline; }

.spatial-result-card {
  position: absolute;
  z-index: 9;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100dvh - max(32px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 16px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 16px 40px rgba(15, 23, 42, .2);
  backdrop-filter: blur(12px);
}

.spatial-sheet-toggle {
  display: flex;
  width: 100%;
  min-height: 50px;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid rgba(226, 232, 240, .8);
  border-radius: 0;
  background: transparent;
  color: #0f172a;
  box-shadow: none;
  text-align: left;
  font-weight: 900;
}

.spatial-review-compact {
  padding: 3px 7px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
}

.spatial-sheet-chevron {
  margin-left: auto;
  color: #64748b;
  transition: transform .18s ease;
}

.spatial-sheet-toggle[aria-expanded="false"] .spatial-sheet-chevron { transform: rotate(180deg); }

.spatial-result-details {
  max-height: calc(100dvh - 98px);
  padding: 12px 14px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.spatial-sheet-toggle[aria-expanded="false"] ~ .spatial-result-details { display: none; }

.spatial-detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.spatial-detail-heading strong { color: #64748b; font-size: 11px; }
.spatial-geometry-type { padding: 5px 8px; border-radius: 999px; background: #e9f5f0; color: #0f766e; font-size: 11px; font-weight: 800; }

@media (max-width: 640px) {
  .spatial-result-card {
    top: auto;
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    width: auto;
    max-height: min(40dvh, 420px);
    border-radius: 16px;
  }

  .spatial-result-card > .spatial-map-failure {
    margin: 0 12px 8px;
    padding: 5px 8px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.3;
  }
  .spatial-result-card > .spatial-map-failure button {
    min-height: 30px;
    padding: 4px 9px;
    font-size: 12px;
  }
  .spatial-result-details { max-height: calc(40dvh - 50px); padding-bottom: max(14px, env(safe-area-inset-bottom)); overflow-y: auto; }
  .spatial-result-card[data-provider-unavailable="true"] .spatial-result-details { max-height: calc(40dvh - 94px); }
  .spatial-provider-attribution {
    left: max(6px, env(safe-area-inset-left));
    bottom: calc(var(--spatial-sheet-occlusion) + max(8px, env(safe-area-inset-bottom)));
    max-width: calc(100% - 12px);
  }
  .spatial-map-failure { min-width: 0; padding: 7px 8px; }
  .spatial-map-failure strong { min-width: 0; }
}

@media (width: 390px) {
  .spatial-map-shell { max-width: 100vw; overflow: hidden; }
  .spatial-facts strong { overflow-wrap: anywhere; }
}
