.saved-page .topbar .sp-back {
  display: inline-flex;
  text-decoration: none;
  color: var(--text);
}

.saved-page .sp-back:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.sp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem 1.5rem;
}

/* Desktop matches the plot locator: full width, same rail and map height. */
@media (min-width: 900px) {
  .sp-layout {
    grid-template-columns: clamp(430px, 42vw, 580px) minmax(0, 1fr);
    align-items: start;
    max-width: none;
    padding-inline: 1.5rem;
    padding-bottom: 1rem;
  }

  .sp-panel {
    overflow: visible;
  }

  .sp-map-card {
    position: sticky;
    top: 1rem;
    height: calc(100vh - 6.25rem);
    height: calc(100dvh - 6.25rem);
    min-height: 420px;
  }
}

.sp-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  overflow-y: auto;
}

.sp-card,
.sp-map-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sp-card {
  padding: 1rem 1.1rem;
}

.sp-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.sp-card h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.sp-count {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.sp-note,
.sp-empty {
  margin: 0.4rem 0 0.6rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.sp-empty a {
  color: var(--primary);
  font-weight: 600;
}

.sp-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sp-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.15rem 0.75rem;
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.sp-item:hover,
.sp-item.is-selected {
  border-color: var(--primary);
  background: #f0fdfa;
}

.sp-no {
  grid-row: span 2;
  align-self: center;
  min-width: 2.4rem;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.sp-title {
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-code {
  margin: 0.4rem 0 0;
  padding: 0.65rem 0.75rem;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  background: #0f172a;
  color: #e2e8f0;
  font: 0.76rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.sp-response {
  max-height: 320px;
}

.sp-map-card {
  min-height: 0;
  overflow: hidden;
}

.sp-map {
  width: 100%;
  height: 100%;
  min-height: 320px;
}

.sp-label {
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  box-shadow: none;
  color: #fff;
  font-weight: 800;
  padding: 1px 6px;
}

.sp-label::before {
  display: none;
}

@media (max-width: 899px) {
  .sp-map-card {
    order: -1;
    height: 55vh;
  }

  .sp-panel {
    overflow: visible;
  }
}

.sp-actions {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.sp-actions .sp-note {
  margin: 0.5rem 0 0;
}

.sp-danger {
  width: 100%;
  color: var(--red);
  border-color: #fecaca;
}

.sp-danger:hover:not(:disabled) {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.sp-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
