* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #10131a;
  color: #e6e8ee;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#map { position: absolute; inset: 0; background: #10131a; z-index: 1; }
/* Leaflet's CRS.Simple has no tiles; hide attribution box visually small */
.leaflet-container { background: #10131a; outline: none; }
.leaflet-control-attribution { display: none; }

/* Top bar */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(#10131aee, #10131a00);
}
#title { font-weight: 700; font-size: 16px; color: #8ab4ff; white-space: nowrap; }
#search {
  flex: 1; min-width: 0;
  padding: 9px 12px; border-radius: 8px;
  border: 1px solid #2a3346; background: #171c27; color: #e6e8ee;
  font-size: 15px; outline: none;
}
#search:focus { border-color: #4f7cff; }
#legendToggle, #resetPos {
  padding: 9px 12px; border-radius: 8px; border: 1px solid #2a3346;
  background: #171c27; color: #e6e8ee; font-size: 14px; cursor: pointer; white-space: nowrap;
}
#resetPos { font-size: 16px; }
#legendToggle:hover, #resetPos:hover { border-color: #4f7cff; }

/* Legend */
#legend {
  position: absolute; top: 56px; right: 10px; z-index: 1000;
  width: 240px; max-height: calc(100% - 72px);
  background: #171c27ee; border: 1px solid #2a3346; border-radius: 10px;
  display: flex; flex-direction: column; backdrop-filter: blur(6px);
}
#legend.hidden, #detail.hidden { display: none; }
.legend-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid #2a3346; font-weight: 600;
}
.legend-head button { background: none; border: none; color: #9aa3b5; font-size: 16px; cursor: pointer; }
#legendList { overflow-y: auto; padding: 6px; }
.legend-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 8px;
  border-radius: 7px; cursor: pointer; font-size: 13px;
}
.legend-item:hover { background: #1f2636; }
.legend-item.active { background: #28324a; }
.legend-item .dot { width: 13px; height: 13px; border-radius: 50%; flex: none; }
.legend-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-item .cnt { color: #8a93a6; font-variant-numeric: tabular-nums; }

/* Detail panel */
#detail {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  z-index: 1000; width: min(360px, calc(100% - 24px));
  background: #171c27f2; border: 1px solid #2a3346; border-radius: 12px;
  padding: 14px; box-shadow: 0 8px 30px #0008;
}
#detailClose { position: absolute; top: 8px; right: 10px; background: none; border: none; color: #9aa3b5; font-size: 18px; cursor: pointer; }
#detailImg img { width: 100%; max-height: 220px; object-fit: contain; border-radius: 8px; background: #0c0f15; }
#detailImg:empty { display: none; }
#detailCat { display: inline-block; margin-top: 10px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #0c0f15; }
#detailLabel { margin-top: 8px; font-size: 15px; line-height: 1.4; color: #e6e8ee; }

/* Status toast */
#status {
  position: absolute; bottom: 14px; left: 14px; z-index: 1000;
  background: #171c27cc; border: 1px solid #2a3346; border-radius: 8px;
  padding: 6px 11px; font-size: 12px; color: #9aa3b5;
}
#status.hidden { display: none; }

@media (max-width: 560px) {
  #title { display: none; }
  #legend { width: calc(100% - 20px); }
}
