html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#app {
  position: relative;
  display: flex;
  height: 100%;
  background: #fff;
}

[hidden] { display: none !important; }

#map {
  flex: 1;
  min-width: 0;
  background: #9ec9d8;
}

/* --- Legend / key ------------------------------------------------------ */

#legend {
  width: 232px;
  flex: none;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #e3e0d8;
  background: #fbfaf6;
  color: #22302e;
}
#legend header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
}
#legend h1 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5c6b68;
}
#legend-close {
  display: none;
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: #5c6b68;
  cursor: pointer;
  padding: 2px 6px;
}
#legend-groups {
  overflow-y: auto;
  padding-bottom: 10px;
}
.legend-cat {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 9px 14px 5px;
  font-size: 12.5px;
  font-weight: 700;
  color: #22302e;
  text-align: left;
}
.legend-cat .swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex: none;
}
.legend-cat .state {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  color: #98a5a2;
}
.legend-cat[aria-pressed="false"] { color: #98a5a2; }
.legend-cat[aria-pressed="false"] .swatch { opacity: 0.3; }
.legend-place {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  color: #45524f;
  padding: 4px 14px 4px 24px;
}
.legend-place svg {
  width: 13px;
  height: 13px;
  flex: none;
  stroke: currentColor;
  opacity: 0.75;
}
.legend-place:hover, .legend-place.active {
  background: #eef2ee;
  color: #0a5d65;
}
.legend-place:focus-visible, .legend-cat:focus-visible, .chip:focus-visible {
  outline: 2px solid #0e7c86;
  outline-offset: -2px;
}
.legend-cat.dimmed + .cat-places { display: none; }

#key-toggle {
  display: none;
  position: absolute;
  z-index: 6;
  left: 10px;
  bottom: 24px;
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  font: 600 13px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #fff;
  color: #22302e;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

/* --- Markers ---------------------------------------------------------- */

.pin {
  --pin-color: #0e7c86;
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  background: var(--pin-color);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 1px 2px 5px rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.pin svg {
  width: 17px;
  height: 17px;
  transform: rotate(45deg);
  stroke: #fff;
}
.pin:hover, .pin.active { transform: rotate(-45deg) scale(1.18); }

/* --- Place card -------------------------------------------------------- */

#place-card {
  position: absolute;
  z-index: 7;
  left: 12px;
  bottom: 34px; /* clear of Google's logo/attribution, which must stay visible */
  width: min(300px, calc(100% - 24px));
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  color: #22302e;
  box-shadow: 0 6px 24px rgba(10, 30, 30, 0.35);
  animation: card-in 0.18s ease;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
#card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 12px;
  background: var(--card-color, #0e7c86);
  color: #fff;
}
#card-icon { display: grid; place-items: center; }
#card-icon svg { width: 16px; height: 16px; stroke: #fff; }
#card-category {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
#card-close {
  margin-left: auto;
  border: 0;
  background: none;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
#card-body { padding: 12px 14px 14px; }
#card-body h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}
#card-photo {
  width: 100%;
  border-radius: 8px;
  margin-top: 10px;
  display: block;
}
#card-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--card-color, #0e7c86);
  border-radius: 6px;
  padding: 7px 12px;
  text-decoration: none;
}

/* --- Static fallback --------------------------------------------------- */

#fallback {
  position: absolute;
  inset: 0;
  overflow: auto;
  background: #fff;
  text-align: center;
}
#fallback img {
  max-width: min(100%, 640px);
  height: auto;
}

/* --- Placement mode ---------------------------------------------------- */

#editor {
  position: absolute;
  z-index: 8;
  top: 0;
  right: 0;
  bottom: 0;
  width: 250px;
  background: rgba(255, 255, 255, 0.96);
  border-left: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  font-size: 13px;
}
#editor header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #ddd;
}
#editor .hint { margin: 8px 12px; color: #666; }
#editor ol {
  margin: 0;
  padding: 0 0 12px;
  list-style: none;
  overflow-y: auto;
}
#editor li button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
#editor li button:hover { background: #eef4f4; }
#editor li button.selected {
  background: #0e7c86;
  color: #fff;
}
#editor li .placed { color: #2e8b57; margin-right: 4px; }
#export-btn {
  border: 0;
  border-radius: 5px;
  background: #0e7c86;
  color: #fff;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
}

/* --- Mobile ------------------------------------------------------------ */

@media (max-width: 719px) {
  #legend {
    position: absolute;
    z-index: 9;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 52%;
    border-left: 0;
    border-top: 1px solid #e3e0d8;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -4px 20px rgba(10, 30, 30, 0.25);
    transform: translateY(100%);
    visibility: hidden;
    transition: transform 0.22s ease, visibility 0.22s;
  }
  #legend.open {
    transform: none;
    visibility: visible;
  }
  #legend-close { display: block; }
  #key-toggle { display: block; }
  #place-card {
    left: 8px;
    right: 8px;
    bottom: 26px;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pin, #legend { transition: none; }
  #place-card { animation: none; }
}
