.atlas-mapapp {
  --am-green: #1f3d2b;
  --am-ochre: #b5651d;
  --am-line: #d8d1bf;
  --am-soft: #f3efe4;
  --am-card: #fffdf7;
  --am-ink: #1f3d2b;
  --am-muted: #6e7a6c;
  --am-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  background: var(--am-card);
  color: var(--am-ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.atlas-mapapp [hidden] { display: none !important; }

.am-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--am-line);
  background: var(--am-soft);
}

.am-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 280px;
  min-width: 180px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--am-line);
  border-radius: 7px;
  background: var(--am-card);
}
.am-search svg { width: 18px; height: 18px; flex: none; color: var(--am-muted); }
.am-search input {
  width: 100%;
  height: 100%;
  padding: 0 0 0 9px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--am-ink);
  font-size: 14px;
}
.am-search input::placeholder { color: #8c9589; }
.am-search:focus-within { border-color: var(--am-ink); box-shadow: 0 0 0 2px rgba(181, 101, 29, 0.14); }

.am-field {
  display: grid;
  gap: 4px;
  flex: 0 1 180px;
  min-width: 132px;
}
.am-field span {
  color: var(--am-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.am-field select {
  height: 44px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--am-line);
  border-radius: 7px;
  background: var(--am-card);
  color: var(--am-ink);
  font-size: 12px;
  font-weight: 600;
  outline: 0;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--am-muted) 50%), linear-gradient(135deg, var(--am-muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 19px, calc(100% - 9px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.am-field select:focus { border-color: var(--am-ink); box-shadow: 0 0 0 2px rgba(181, 101, 29, 0.14); }

.am-reset {
  flex: none;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--am-ink);
  border-radius: 7px;
  background: transparent;
  color: var(--am-ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.am-reset:hover { background: var(--am-ink); color: #fffdf7; }

.am-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  min-height: 36px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--am-line);
  background: var(--am-card);
  font-size: 12px;
}
.am-count { color: var(--am-ink); font-weight: 700; letter-spacing: 0.02em; }
.am-hint { color: var(--am-muted); }

.am-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  min-height: 0;
}

.am-mapbox {
  position: relative;
  height: 590px;
  overflow: hidden;
  background: #6f939f;
}

.am-map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #6f939f;
}

.am-map .leaflet-tile-pane {
  filter: sepia(0.2) saturate(0.72) contrast(0.97) brightness(1.04);
}

.am-map .leaflet-container { background: #6f939f !important; }

.am-canvas {
  position: absolute;
  inset: 0;
  z-index: 410;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.am-paper {
  position: absolute;
  inset: 0;
  z-index: 420;
  pointer-events: none;
  opacity: 0.28;
  mix-blend-mode: multiply;
  background-image:
    repeating-linear-gradient(0deg, rgba(31, 61, 43, 0.045) 0 1px, transparent 1px 31px),
    repeating-linear-gradient(90deg, rgba(31, 61, 43, 0.035) 0 1px, transparent 1px 31px),
    radial-gradient(circle at 70% 20%, rgba(181, 101, 29, 0.06), transparent 55%);
}

.am-tools {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  display: grid;
  overflow: hidden;
  border: 1px solid rgba(31, 61, 43, 0.3);
  border-radius: 7px;
  background: rgba(255, 253, 247, 0.94);
  box-shadow: 0 2px 8px rgba(31, 61, 43, 0.12);
}
.am-tools button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-bottom: 1px solid rgba(31, 61, 43, 0.15);
  background: transparent;
  color: var(--am-ink);
  font-size: 18px;
  line-height: 1;
}
.am-tools button:last-child { border-bottom: 0; }
.am-tools button:hover { background: var(--am-green); color: #fffdf7; }

.am-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  max-width: calc(100% - 24px);
  padding: 7px 9px;
  border: 1px solid rgba(31, 61, 43, 0.22);
  border-radius: 6px;
  background: rgba(255, 253, 247, 0.9);
  color: var(--am-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.am-legend span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.am-legend i { width: 6px; height: 6px; border-radius: 50%; }

.am-tip {
  position: absolute;
  z-index: 540;
  max-width: 230px;
  padding: 6px 9px;
  border-radius: 5px;
  background: rgba(31, 61, 43, 0.95);
  color: #fffdf7;
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
  transform: translate(10px, -50%);
}

.am-detail {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 520;
  width: min(320px, calc(100% - 24px));
  padding: 17px 18px 15px;
  border: 1px solid var(--am-ink);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.97);
  box-shadow: 0 10px 30px rgba(31, 61, 43, 0.2);
}
.am-detail__close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--am-muted);
  font-size: 20px;
}
.am-detail__close:hover { background: var(--am-soft); color: var(--am-ink); }
.am-detail__kicker {
  margin: 0 0 5px;
  padding-right: 26px;
  color: var(--am-ochre);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.am-detail h3 {
  margin: 0 0 10px;
  padding-right: 24px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.am-detail__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin: 0 0 10px;
}
.am-detail__grid dt {
  color: var(--am-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.am-detail__grid dd {
  margin: 2px 0 0;
  color: var(--am-ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}
.am-detail__coords {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin: 0 0 12px;
  padding: 8px 0;
  border-top: 1px solid var(--am-line);
  border-bottom: 1px solid var(--am-line);
}
.am-detail__coords span {
  color: var(--am-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.am-detail__coords strong {
  color: var(--am-ink);
  font-family: var(--am-mono);
  font-size: 13px;
  letter-spacing: 0.02em;
}
.am-detail__actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.am-copy {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--am-ink);
  border-radius: 6px;
  background: var(--am-ink);
  color: #fffdf7;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.am-copy:hover { background: #2b5139; }
.am-copy.is-copied { background: var(--am-ochre); border-color: var(--am-ochre); }
.am-detail__link { color: var(--am-ink); font-size: 12px; font-weight: 600; text-decoration: none; }
.am-detail__link:hover { color: var(--am-ochre); }

.am-side {
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-left: 1px solid var(--am-line);
  background: var(--am-card);
}
.am-side__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--am-line);
  color: var(--am-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.am-side__head span:last-child { color: var(--am-ochre); font-family: var(--am-mono); letter-spacing: 0; }
.am-list {
  overflow-y: auto;
  max-height: 510px;
  overscroll-behavior: contain;
}
.am-row {
  display: grid;
  width: 100%;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid #ece6d7;
  background: transparent;
  text-align: left;
}
.am-row:hover, .am-row.is-active { background: #f2efe4; }
.am-row__dot { width: 7px; height: 7px; border-radius: 50%; }
.am-row__name {
  display: block;
  overflow: hidden;
  color: var(--am-ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.am-row__meta {
  display: block;
  overflow: hidden;
  color: var(--am-muted);
  font-size: 11px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.am-row__xy {
  color: #8c9589;
  font-family: var(--am-mono);
  font-size: 10px;
  white-space: nowrap;
}
.am-more {
  min-height: 40px;
  margin: 10px 12px 12px;
  border: 1px solid var(--am-line);
  border-radius: 6px;
  background: transparent;
  color: var(--am-ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.am-more:hover { border-color: var(--am-ink); }
.am-empty {
  padding: 28px 16px;
  color: var(--am-muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.am-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 20px;
  padding: 8px 12px;
  border-top: 1px solid var(--am-line);
  color: var(--am-muted);
  font-size: 10px;
  line-height: 1.4;
}
.am-foot a { color: inherit; }

.atlas-mapapp[data-mode="location"] .am-mapbox { height: 470px; }
.atlas-mapapp[data-mode="location"] .am-main { grid-template-columns: minmax(0, 1fr); }
.atlas-mapapp[data-mode="location"] .am-bar { padding-bottom: 10px; }
.atlas-mapapp[data-mode="location"] [data-full-only] { display: none; }

@media (max-width: 900px) {
  .am-main { grid-template-columns: minmax(0, 1fr) 270px; }
  .am-mapbox { height: 500px; }
  .am-legend { max-width: 230px; }
}

@media (max-width: 760px) {
  .am-bar { flex-wrap: wrap; align-items: stretch; gap: 8px; }
  .am-search { flex: 1 1 100%; }
  .am-field { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .am-reset { flex: 1 1 100%; }
  .am-main { grid-template-columns: minmax(0, 1fr); }
  .am-mapbox { height: 54vh; min-height: 360px; max-height: 520px; }
  .atlas-mapapp[data-mode="location"] .am-mapbox { height: 48vh; min-height: 330px; }
  .am-side { border-left: 0; border-top: 1px solid var(--am-line); }
  .am-list { max-height: 300px; }
  .am-hint { display: none; }
  .am-legend { max-width: calc(100% - 72px); gap: 3px 8px; font-size: 8px; }
  .am-detail { left: 8px; bottom: 8px; width: calc(100% - 16px); }
  .am-detail h3 { font-size: 20px; }
}

@media (max-width: 430px) {
  .am-field { flex: 1 1 100%; }
  .am-subbar { align-items: flex-start; }
  .am-legend { max-width: calc(100% - 64px); }
  .am-detail__grid { grid-template-columns: 1fr; gap: 6px; }
  .am-detail__actions { gap: 8px; }
}
