* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  color: #1a1a1a;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

#topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: #1e2a24;
  color: #fff;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  flex-wrap: wrap;
}

#brand { display: flex; flex-direction: column; line-height: 1.2; margin-right: 4px; }
#brand-title { font-size: 16px; font-weight: 700; letter-spacing: 0.02em; }
#brand-sub { font-size: 11px; color: #b9c9c0; }

#search-wrap {
  position: relative;
  flex: 1 1 320px;
  min-width: 220px;
  max-width: 480px;
}
#search-input {
  width: 100%;
  padding: 8px 34px 8px 10px;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  outline: none;
}
#search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #888;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
}
#search-clear:hover { color: #333; }

#search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  color: #1a1a1a;
  border-radius: 6px;
  max-height: 340px;
  overflow-y: auto;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  z-index: 20;
}
#search-results .result-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  font-size: 13px;
}
#search-results .result-item:last-child { border-bottom: none; }
#search-results .result-item:hover,
#search-results .result-item.active { background: #eef5f0; }
#search-results .result-main { font-weight: 600; }
#search-results .result-sub { color: #777; font-size: 11px; }
#search-results .result-empty { padding: 10px 12px; color: #888; font-size: 13px; }
#search-results .result-more { padding: 6px 12px; color: #999; font-size: 11px; text-align: center; }

#town-toggle { display: flex; gap: 6px; }
.town-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.12);
  padding: 6px 10px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.town-chip input { cursor: pointer; }

#info-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
#info-btn:hover { background: rgba(255,255,255,0.15); }

#map {
  flex: 1;
  position: relative;
}

#loading {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
}
.loading-box {
  background: #1e2a24;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
}

#hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: rgba(30,42,36,0.85);
  color: #fff;
  padding: 6px 14px;
  border-radius: 14px;
  font-size: 12px;
  z-index: 8;
  pointer-events: none;
}

#tile-busy {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  background: rgba(30,42,36,0.85);
  color: #fff;
  padding: 5px 14px;
  border-radius: 14px;
  font-size: 12px;
  z-index: 8;
  pointer-events: none;
}

#no-data-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  max-width: 90%;
  text-align: center;
  background: rgba(107,74,23,0.92);
  color: #fff;
  padding: 6px 14px;
  border-radius: 14px;
  font-size: 12px;
  z-index: 8;
  pointer-events: none;
}

.hidden { display: none !important; }

/* --- modal --- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-card {
  background: #fff;
  max-width: 520px;
  width: 92%;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 10px;
  padding: 22px 26px;
  position: relative;
  line-height: 1.7;
}
.modal-card h2 { margin-top: 0; font-size: 18px; }
.modal-card h3 { font-size: 14px; margin-bottom: 4px; color: #2c4a3a; }
.modal-card ul { margin: 4px 0 14px; padding-left: 20px; font-size: 13px; }
.modal-card p { font-size: 13px; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  color: #666;
}

/* --- maplibre popup --- */
.maplibregl-popup-content {
  padding: 10px 12px;
  font-size: 13px;
}
.maplibregl-popup-content table { border-collapse: collapse; }
.maplibregl-popup-content th {
  text-align: left;
  color: #666;
  font-weight: 500;
  padding: 2px 10px 2px 0;
  white-space: nowrap;
  vertical-align: top;
}
.maplibregl-popup-content td {
  padding: 2px 0;
  font-weight: 600;
}

@media (max-width: 720px) {
  #topbar { gap: 8px; }
  #brand-sub { display: none; }
  #search-wrap { flex-basis: 100%; order: 3; max-width: none; }
  #town-toggle { order: 2; }
}
