/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Hiragino Sans', sans-serif; }

/* ── Header ── */
#hdr {
  position: fixed; top: 0; left: 0; right: 0;
  height: 48px; z-index: 900;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px 0 16px;
}
#logo { font-size: 15px; font-weight: 800; color: #111; letter-spacing: -0.3px; flex-shrink: 0; }
#hdr-search { display: flex; align-items: center; gap: 6px; flex: 1; margin-left: 10px; min-width: 0; }
#search-input {
  flex: 1; padding: 7px 12px; border-radius: 8px;
  border: 1.5px solid #d1d5db; font-size: 14px; outline: none;
  -webkit-appearance: none; background: #f9fafb; min-width: 0;
}
#search-input:focus { border-color: #f97316; background: #fff; box-shadow: 0 0 0 3px rgba(249,115,22,0.12); }
#search-go {
  padding: 7px 14px; border-radius: 8px;
  background: #f97316; color: white; border: none;
  font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
#search-go:active { background: #ea580c; }

/* ── Stats bar ── */
#stats-bar {
  position: fixed; top: 48px; left: 0; right: 0;
  height: 36px; z-index: 890;
  background: rgba(255,255,255,0.97);
  border-bottom: 1px solid #f3f4f6;
  display: none; align-items: center;
  padding: 0 14px; gap: 12px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#stats-bar::-webkit-scrollbar { display: none; }
.stat-label { font-size: 10px; color: #9ca3af; font-weight: 600; white-space: nowrap; }
.stat-item { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #374151; white-space: nowrap; }
.stat-item b { font-weight: 700; color: #111; }
.stat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Map ── */
#map {
  position: fixed;
  top: 48px; left: 0; right: 0; bottom: 100px;
  z-index: 0;
  transition: top 0.2s;
}
body.has-stats #map { top: 84px; }
body.has-stats #count-badge { top: 92px; }

/* ── 価格帯フィルター（⑥） ── */
#price-filter {
  position: fixed; bottom: 60px; left: 0; right: 0;
  height: 40px; z-index: 899;
  background: rgba(255,255,255,0.97);
  border-top: 1px solid #f3f4f6;
  display: flex; align-items: center;
  padding: 0 10px; gap: 6px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#price-filter::-webkit-scrollbar { display: none; }
.pbtn {
  padding: 5px 12px; border-radius: 16px;
  border: 1.5px solid #d1d5db;
  background: #fff; font-size: 12px; font-weight: 600; color: #6b7280;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent; user-select: none;
  transition: all 0.12s;
}
.pbtn.active {
  background: #111; border-color: #111; color: #fff;
}

/* ── Filter bar ── */
#filter-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 60px; z-index: 900;
  background: rgba(255,255,255,0.97);
  border-top: 1px solid #e5e7eb;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 12px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.fbtn {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 14px; border-radius: 20px;
  border: 1.5px solid #d1d5db;
  background: #fff; font-size: 13px; font-weight: 600; color: #374151;
  cursor: pointer; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.fbtn.active { background: #f9fafb; border-color: #9ca3af; color: #111; }
.fbtn:not(.active) { opacity: 0.4; }
.fbtn-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }


/* ── Loading ── */
#loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
#loading-box {
  text-align: center; background: white; border-radius: 20px;
  padding: 32px 44px; box-shadow: 0 8px 40px rgba(0,0,0,0.12); min-width: 200px;
}
#loading-spinner {
  width: 40px; height: 40px; margin: 0 auto 16px;
  border: 3px solid #f3f4f6; border-top-color: #f97316;
  border-radius: 50%; animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { font-size: 14px; color: #111; font-weight: 600; margin-bottom: 4px; }
#loading-sub { font-size: 12px; color: #9ca3af; min-height: 16px; }


/* ── 初回モーダル ── */
#intro-modal {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#intro-box {
  background: white; border-radius: 24px;
  padding: 32px 28px; max-width: 340px; width: 100%; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
#intro-emoji { font-size: 48px; margin-bottom: 12px; }
#intro-box h2 { font-size: 20px; font-weight: 800; color: #111; margin-bottom: 16px; line-height: 1.4; }
#intro-box p { font-size: 14px; color: #374151; line-height: 1.7; margin-bottom: 10px; }
#intro-legend {
  display: flex; justify-content: center; gap: 16px;
  margin: 20px 0; font-size: 13px; font-weight: 600; color: #374151;
}
#intro-legend span { display: flex; align-items: center; gap: 5px; }
.intro-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
#intro-close {
  display: block; width: 100%; padding: 14px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: white; border: none; border-radius: 14px;
  font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 2px 0 #c2410c; margin-bottom: 12px;
}
#intro-src { font-size: 11px; color: #9ca3af; }

/* ── Count badge ── */
#count-badge {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%);
  z-index: 800; background: rgba(17,17,17,0.72);
  color: white; font-size: 12px; font-weight: 600;
  padding: 5px 14px; border-radius: 20px;
  pointer-events: none; white-space: nowrap;
  backdrop-filter: blur(4px);
  transition: top 0.2s;
}

/* ── Popup ── */
.leaflet-popup-content-wrapper {
  border-radius: 16px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.16) !important;
  padding: 0 !important; overflow: hidden;
}
.leaflet-popup-content { margin: 0 !important; width: 250px !important; }
.leaflet-popup-tip-container { display: none; }
.leaflet-popup-close-button { color: #9ca3af !important; font-size: 18px !important; top: 10px !important; right: 10px !important; }

.popup-inner { padding: 16px; }
.popup-type-badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  color: white; padding: 3px 10px; border-radius: 20px; margin-bottom: 8px;
}
.popup-price { font-size: 28px; font-weight: 800; color: #111; line-height: 1.1; }
.popup-price-unit { font-size: 15px; font-weight: 600; color: #374151; }
.popup-period { font-size: 11px; color: #9ca3af; margin: 4px 0 12px; }
.popup-rows { font-size: 13px; color: #374151; display: flex; flex-direction: column; gap: 5px; margin-bottom: 4px; }
.popup-row { display: flex; gap: 6px; align-items: baseline; }
.popup-label { color: #9ca3af; flex-shrink: 0; font-size: 12px; }
.popup-cta {
  display: block; margin-top: 14px; padding: 12px 14px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: white; text-align: center; text-decoration: none;
  font-size: 13px; font-weight: 700; border-radius: 12px;
  box-shadow: 0 2px 0 #c2410c;
  -webkit-tap-highlight-color: transparent;
}
.popup-district { font-size: 11px; color: #d1d5db; margin-top: 8px; text-align: right; }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 112px; left: 50%; transform: translateX(-50%);
  z-index: 9000; background: rgba(239,68,68,0.92);
  color: white; font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: 20px;
  pointer-events: none; opacity: 0; transition: opacity 0.3s; white-space: nowrap;
}
#toast.show { opacity: 1; }

/* ── MarkerCluster ── */
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
  transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}
