:root {
  --green: #1D9E75;
  --blue: #2563EB;
  --orange: #EA580C;
  --pink: #DB2777;
  --yellow: #D97706;
  --purple: #7C3AED;
  --slate: #475569;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #0F172A;
  --text2: #64748B;
  --text3: #94A3B8;
  --accent: #2563EB;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ヘッダー */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  z-index: 1000;
  min-height: 52px;
  flex-wrap: nowrap;
  overflow: hidden;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}
.logo-text { line-height: 1.2; white-space: nowrap; }
.logo-title { font-size: 14px; font-weight: 700; color: var(--text); }
.logo-sub { font-size: 10px; color: var(--text2); }
.badge {
  font-size: 10px; font-weight: 700;
  background: #FEF3C7; color: #92400E;
  padding: 2px 6px; border-radius: 20px;
  border: 1px solid #FDE68A;
  flex-shrink: 0;
  white-space: nowrap;
}
.header-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
#locBtn {
  padding: 6px 12px; font-size: 12px; font-weight: 500;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px; cursor: pointer;
  font-family: inherit;
  display: flex; align-items: center; gap: 4px;
  white-space: nowrap;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
#locBtn:hover { opacity: 0.85; }
#locBtn:disabled { opacity: 0.6; cursor: not-allowed; }
#locLabel { font-size: 11px; color: var(--text2); white-space: nowrap; }

/* メインレイアウト */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* サイドパネル */
.side {
  width: 320px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 統計 */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.stat {
  padding: 10px 8px;
  text-align: center;
  border-right: 1px solid var(--border);
}
.stat:last-child { border-right: none; }
.stat-num { font-size: 18px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 10px; color: var(--text2); margin-top: 1px; }

/* 検索・フィルター */
.filters {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-row {
  display: flex; gap: 6px; margin-bottom: 10px;
}
.search-row input {
  flex: 1; padding: 8px 10px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; color: var(--text);
  background: var(--bg);
}
.search-row input:focus { outline: none; border-color: var(--accent); }
.search-row select {
  padding: 8px 6px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; color: var(--text);
  background: var(--bg); cursor: pointer;
}
.reset-btn {
  padding: 8px 10px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text2);
  cursor: pointer; font-family: inherit;
  white-space: nowrap;
}
.reset-btn:hover { background: var(--border); }

/* カテゴリチップ */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font-size: 11px; padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--bg); color: var(--text2);
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.chip.active {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
}
.chip:hover:not(.active) { border-color: var(--text3); }

/* プログレス */
.progress { height: 3px; background: var(--border); flex-shrink: 0; }
.progress-bar { height: 100%; background: var(--accent); width: 0%; transition: width 0.4s ease; }

/* ステータス */
.status-bar {
  padding: 6px 12px;
  font-size: 12px; color: var(--text2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 28px;
}

/* 店舗リスト */
.store-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.store-list::-webkit-scrollbar { width: 4px; }
.store-list::-webkit-scrollbar-track { background: transparent; }
.store-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.store-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.store-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(37,99,235,0.1); }
.store-card.active { border-color: var(--accent); background: #EFF6FF; }
.card-top { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.card-num { font-size: 11px; font-weight: 700; color: var(--text2); min-width: 18px; margin-top: 1px; }
.card-name { font-size: 13px; font-weight: 500; color: var(--text); flex: 1; line-height: 1.4; }
.card-bottom { display: flex; align-items: center; gap: 6px; padding-left: 26px; }
.cat-tag { font-size: 10px; padding: 2px 7px; border-radius: 20px; font-weight: 500; }
.card-city { font-size: 11px; color: var(--text2); }
.card-dist { font-size: 11px; color: var(--accent); margin-left: auto; font-weight: 500; }

.loading-msg {
  text-align: center; padding: 2rem 1rem;
  color: var(--text2); font-size: 13px; line-height: 1.8;
}
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.more-msg {
  text-align: center; padding: 12px;
  font-size: 12px; color: var(--text2);
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* 地図 */
#map { flex: 1; z-index: 1; position: relative; }

/* 地図拡大ボタン */
#expandBtn {
  position: absolute;
  bottom: 40px; right: 10px;
  z-index: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px; height: 36px;
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  transition: background 0.15s;
}
#expandBtn:hover { background: var(--bg); }

/* 地図フルスクリーンモード */
body.map-fullscreen .main {
  position: relative;
}
body.map-fullscreen #map {
  position: fixed !important;
  top: 0; left: 0;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 2000;
}
body.map-fullscreen #expandBtn {
  position: fixed;
  bottom: 40px; right: 10px;
  z-index: 2100;
}
body.map-fullscreen .legend {
  position: fixed;
  z-index: 2050;
}

/* 凡例 */
.legend {
  position: absolute;
  bottom: 40px; left: 10px;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  z-index: 500;
  font-size: 11px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  pointer-events: none;
  max-height: 200px;
  overflow-y: auto;
}
.legend-title { font-weight: 700; margin-bottom: 6px; font-size: 11px; color: var(--text); }
.legend-item { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; color: var(--text2); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* モバイル対応 */
@media (max-width: 640px) {
  .logo-sub { display: none; }
  #locLabel { display: none; }

  /* サイドパネルを下部ドロワーに */
  .side {
    width: 100%;
    position: absolute;
    bottom: 0; left: 0;
    z-index: 900;
    height: auto;
    max-height: 55vh;
    border-right: none;
    border-top: 2px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    transition: max-height 0.3s ease;
  }

  /* ドロワーハンドル */
  .side::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  .stats { display: none; }

  /* 地図は全画面上部 */
  #map {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: calc(100% - 0px);
  }

  .main {
    position: relative;
    height: 100%;
  }

  #expandBtn {
    bottom: calc(55vh + 50px);
  }

  .legend {
    bottom: calc(55vh + 10px);
    left: 10px;
    max-height: 120px;
    font-size: 10px;
  }
}
