.sage-map-backdrop {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: none;
  align-items: stretch;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 0.35rem;
  padding-bottom: calc(0.35rem + env(safe-area-inset-bottom));
  box-sizing: border-box;
}

.sage-map-backdrop.open {
  display: flex;
}

.sage-map-sheet {
  width: min(1100px, 100%);
  height: min(96dvh, 980px);
  max-height: min(96dvh, 980px);
  margin: auto;
  background: #fff;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}

.sage-map-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.85rem 0.35rem;
}

.sage-map-top h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #3f3b28;
}

.sage-map-close {
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  color: #555;
}

.sage-map-search {
  display: flex;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem 0.5rem;
}

.sage-map-search input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid #c9c2b4;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font: inherit;
  font-size: 1rem;
  background: #faf8f3;
}

.sage-map-search button {
  border: none;
  border-radius: 10px;
  padding: 0 0.9rem;
  background: #8b8356;
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.sage-map-hint {
  padding: 0 0.85rem 0.45rem;
  font-size: 0.85rem;
  color: #666;
}

.sage-map-boundary-tip {
  background: rgba(20, 28, 40, 0.92) !important;
  border: 1px solid #FFB020 !important;
  color: #fff !important;
  font-size: 0.75rem !important;
  padding: 0.2rem 0.45rem !important;
  border-radius: 6px !important;
  box-shadow: none !important;
}

.sage-map-boundary-tip::before {
  border-top-color: rgba(20, 28, 40, 0.92) !important;
}

.sage-map-canvas {
  flex: 1 1 auto;
  min-height: 420px;
  height: auto;
  background: #1a1a1a;
}

.sage-map-result {
  flex: 0 0 auto;
  margin: 0.55rem 0.85rem 0;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: #f3efe6;
  border: 1px solid #d9d3c6;
  white-space: normal;
  font-size: 1rem;
  line-height: 1.45;
  color: #222;
  max-height: min(28vh, 16rem);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.sage-map-line {
  margin: 0 0 0.15rem;
}

.sage-map-k {
  font-weight: 800;
  color: #1a1a1a;
}

.sage-map-status {
  margin-top: 0.35rem;
  color: #555;
  font-size: 0.92rem;
}

.sage-map-status--rate-limit {
  color: #c62828;
  font-weight: 800;
  font-size: 1.15rem;
  line-height: 1.35;
}

.sage-map-contact {
  margin: 0.45rem 0.85rem 0;
  padding: 0.55rem 0.65rem 0.65rem;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #d9d3c6;
}

.sage-map-contact-title {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6a6348;
  margin-bottom: 0.4rem;
}

.sage-map-contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.sage-map-contact-btn {
  border: 1.5px solid #c9c2b4;
  border-radius: 9px;
  min-height: 40px;
  padding: 0.35rem 0.65rem;
  background: #faf8f3;
  color: #3f3b28;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.sage-map-contact-btn.primary {
  background: #8b8356;
  border-color: #8b8356;
  color: #fff;
}

.sage-map-contact-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sage-map-contact-fields {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.sage-map-contact-fields input {
  min-width: 0;
  border: 1.5px solid #c9c2b4;
  border-radius: 9px;
  min-height: 40px;
  padding: 0.35rem 0.55rem;
  font: inherit;
  font-size: 0.9rem;
  background: #faf8f3;
}

.sage-map-contact-note {
  margin-top: 0.45rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #666;
}

@media (max-width: 640px) {
  .sage-map-backdrop {
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .sage-map-sheet {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .sage-map-canvas {
    min-height: 48vh;
  }

  .sage-map-result {
    max-height: min(32vh, 14rem);
    font-size: 0.98rem;
  }

  .sage-map-contact-fields {
    grid-template-columns: 1fr;
  }
}

.sage-map-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem 0.95rem;
}

.sage-map-actions button {
  flex: 1;
  border: none;
  border-radius: 12px;
  min-height: 48px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.sage-map-use {
  background: #0a7ea4;
  color: #fff;
}

.sage-map-use:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sage-map-cancel {
  background: #f3efe6;
  color: #222;
}

.hub-map-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 560px;
  margin: 0 auto 0.85rem;
  border: 1.5px solid #c9c2b4;
  border-radius: 12px;
  min-height: 52px;
  background: #fff;
  color: #3f3b28;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.hub-map-btn:active {
  transform: scale(0.985);
}

.hub-map-pick {
  max-width: 560px;
  margin: -0.35rem auto 0.95rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: rgba(139, 131, 86, 0.12);
  border: 1px solid #d4c9b0;
  font-size: 0.88rem;
  line-height: 1.35;
  color: #3f3b28;
  white-space: pre-wrap;
}

.panel-map-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.65rem;
  border: 1.5px solid #c9c2b4;
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  background: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: #3f3b28;
}

.panel-seed-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 0.85rem;
  max-width: 560px;
}

.panel-seed-actions .panel-map-btn {
  flex: 1 1 180px;
  margin: 0;
  justify-content: center;
  min-height: 48px;
  font-size: 0.95rem;
}

.panel-seed-actions .panel-pdf-btn {
  background: #faf8f3;
}
