:root {
  --c-water: #1e88e5;
  --c-camping: #2e7d32;
  --c-playground: #ef6c00;
  --c-bg: #f7f9fb;
  --c-panel: #ffffff;
  --c-border: #e2e8f0;
  --c-text: #1f2937;
  --c-muted: #6b7280;
  --topbar-h: 56px;
  --sidebar-w: 340px;
  --detail-w: 400px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
  color: var(--c-text);
  background: var(--c-bg);
}

/* ---------- top bar ---------- */
#topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--c-border);
  position: relative;
  z-index: 1100;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 24px; }
.brand h1 { font-size: 18px; margin: 0; white-space: nowrap; }
.brand-tagline { font-size: 12.5px; color: var(--c-muted); white-space: nowrap; margin-left: 2px; }
.footer-links a { color: var(--c-muted); }
.topbar-tools { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; }
#search-input {
  width: min(320px, 50vw);
  padding: 8px 12px;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  font-size: 14px;
}
#locate-btn, #sidebar-toggle {
  padding: 8px 12px;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}
#locate-btn:hover, #sidebar-toggle:hover { background: #f1f5f9; }
#locate-btn.active { background: #e3f2fd; border-color: var(--c-water); }
#sidebar-toggle { display: none; }

/* ---------- layout ---------- */
#layout {
  display: flex;
  height: calc(100% - var(--topbar-h));
  position: relative;
}

/* ---------- sidebar ---------- */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--c-panel);
  border-right: 1px solid var(--c-border);
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-group { padding: 8px 0; border-bottom: 1px solid var(--c-border); }
.filter-group h2, #place-list-section h2 {
  font-size: 13px;
  color: var(--c-muted);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cat-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  cursor: pointer;
  font-size: 15px;
  border-radius: 6px;
}
.cat-toggle:hover { background: #f1f5f9; }
.cat-toggle .count { margin-left: auto; color: var(--c-muted); font-size: 13px; }

#season-hint {
  margin: 8px 4px 0;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
}

.dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-water { background: var(--c-water); }
.dot-camping { background: var(--c-camping); }
.dot-playground { background: var(--c-playground); }
.dot-restaurant { background: #8e24aa; }
.dot-waterpark { background: #00acc1; }
.dot-free-sample { background: #64748b; }
.dot-paid-sample { background: #fff; border: 3px solid #64748b; width: 8px; height: 8px; }

.segmented { display: flex; border: 1px solid var(--c-border); border-radius: 8px; overflow: hidden; }
.segmented button {
  flex: 1;
  padding: 7px 0;
  border: none;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}
.segmented button + button { border-left: 1px solid var(--c-border); }
.segmented button.active { background: var(--c-text); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 4px 10px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}
.chip.active { background: #e0f2fe; border-color: var(--c-water); color: #075985; }

.check-line { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }

/* 사이드바 지역 필터 */
#region-hint { margin: 0; font-size: 12.5px; color: var(--c-muted); line-height: 1.5; }
#region-filter-btn { font-weight: 700; color: #0284c7; border-color: #7dd3fc; background: #f0f9ff; }
#region-filter-btn:hover { background: #e0f2fe; }

/* 광고 자리: 내용이 있을 때만 표시 (비워두면 완전히 숨김) */
.ad-slot { display: none; }
.ad-slot:has(*) {
  display: block;
  margin: 12px 0;
  min-height: 90px;
  border-radius: 10px;
  overflow: hidden;
}
#ad-detail { margin: 0 20px 20px; }

/* ---------- place list ---------- */
#place-list-section { flex: 1; padding-top: 10px; }
#list-count { color: var(--c-muted); font-weight: normal; }
#place-list { list-style: none; margin: 0; padding: 0; }
.place-item {
  padding: 10px 8px;
  border-radius: 8px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}
.place-item:hover { background: #f1f5f9; }
.place-item.selected { background: #e0f2fe; }
.place-item .pi-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.place-item .pi-meta { font-size: 13px; color: var(--c-muted); margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-free { background: #dcfce7; color: #166534; }
.badge-paid { background: #fef3c7; color: #92400e; }
.badge-open { background: #dbeafe; color: #1e40af; }
.badge-closed { background: #f3f4f6; color: #6b7280; }
.badge-year { background: #ede9fe; color: #5b21b6; }

#list-more {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}
#list-more:hover { background: #f1f5f9; }

.sidebar-footer { padding: 12px 4px; font-size: 12px; color: var(--c-muted); }

/* ---------- map ---------- */
#map-wrap { flex: 1; position: relative; min-width: 0; }
#map { width: 100%; height: 100%; background: #dbeafe; }

.sgg-boundary { cursor: default; }

.sgg-label {
  background: transparent;
  border: none;
  box-shadow: none;
  font-size: 11px;
  color: #475569;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
  font-weight: 600;
  pointer-events: none;
}
.sgg-label::before { display: none; }
#map .sgg-label { display: none; }
#map.show-labels .sgg-label { display: block; }

/* 시도(광역시·도) 라벨 — 줌아웃 상태에서 항상 표시 */
.sido-label {
  background: transparent;
  border: none;
  box-shadow: none;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
  pointer-events: none;
}
.sido-label::before { display: none; }
#map.ext-labels .sido-label { display: none !important; }
/* 타일이 자체 지명 라벨을 가진 경우(일반 지도)만 시군구 라벨 숨김 */
#map.ext-labels .sgg-label { display: none !important; }
/* 밝은 타일 위에서 라벨 가독성 보강 */
#map.tile-mode .sgg-label { color: #334155; }

#legend {
  position: absolute;
  bottom: 16px;
  left: 12px;
  z-index: 1000;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
#legend > div { display: flex; align-items: center; gap: 8px; }
.legend-sep { border-top: 1px solid var(--c-border); margin: 3px 0; }

/* place markers */
.place-marker-selected { filter: drop-shadow(0 0 6px rgba(0,0,0,0.6)); }

/* 줌인 시 마커 옆 장소 이름 라벨 (클릭 가능) */
.place-label {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 600;
  color: #1f2937;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  cursor: pointer;
  pointer-events: auto;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.place-label::before { display: none; }
.place-label-water { border-left: 3px solid var(--c-water); }
.place-label-camping { border-left: 3px solid var(--c-camping); }
.place-label-playground { border-left: 3px solid var(--c-playground); }
.place-label-restaurant { border-left: 3px solid #8e24aa; }
.place-label-waterpark { border-left: 3px solid #00acc1; }
.place-label.label-hidden { display: none; }

/* ---------- detail slide panel ---------- */
#detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: var(--detail-w);
  max-width: 92vw;
  background: var(--c-panel);
  border-left: 1px solid var(--c-border);
  box-shadow: -6px 0 18px rgba(0,0,0,0.08);
  transform: translateX(105%);
  transition: transform 0.25s ease;
  z-index: 1050;
  overflow-y: auto;
}
#detail-panel.open { transform: translateX(0); }
#detail-close {
  position: absolute;
  top: 10px; right: 10px;
  border: 1px solid var(--c-border);
  background: #fff;
  border-radius: 12px;
  width: 44px; height: 44px;
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
  color: #374151;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  z-index: 5;
}
#detail-close:hover { background: #f1f5f9; }
#detail-close:active { transform: scale(0.94); }
#detail-content { padding: 20px; }
#detail-content h2 { margin: 0 0 8px; font-size: 21px; padding-right: 52px; }
.detail-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-desc { font-size: 14px; line-height: 1.6; color: #374151; margin-bottom: 16px; }

.detail-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.detail-row { display: flex; gap: 10px; font-size: 14px; }
.detail-row .dr-label { width: 74px; flex-shrink: 0; color: var(--c-muted); }
.detail-row .dr-value { flex: 1; }

.detail-features { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-features .tag {
  background: #f1f5f9;
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 12.5px;
}

.detail-section-title {
  font-size: 13px;
  color: var(--c-muted);
  margin: 20px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.link-buttons { display: flex; flex-direction: column; gap: 8px; }
.link-buttons a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--c-text);
  font-size: 14px;
  background: #fff;
}
.link-buttons a:hover { background: #f1f5f9; }
.link-buttons a .ext { margin-left: auto; color: var(--c-muted); font-size: 12px; }

.detail-note {
  margin-top: 18px;
  font-size: 12px;
  color: var(--c-muted);
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.5;
}

/* 모바일 좌하단 상시 노출 필터 버튼 (데스크톱에서는 숨김) */
#filter-fab {
  display: none;
  position: absolute;
  left: 12px;
  bottom: 24px;
  z-index: 1040;
  padding: 13px 18px;
  border: none;
  border-radius: 999px;
  background: var(--c-text);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  cursor: pointer;
}
#filter-fab:active { transform: scale(0.96); }

/* 시군구 선택 필터 칩 (지도 상단) */
#region-chip {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1040;
  padding: 9px 14px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
  color: #0284c7;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  cursor: pointer;
  white-space: nowrap;
}
#region-chip:hover { background: #f0f9ff; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .brand h1 { display: none; }
  #sidebar-toggle { display: block; }
  #filter-fab { display: block; }
  #legend { display: none; } /* 마커 색은 필터 패널의 레이어 목록에서 확인 가능 */
  #sidebar {
    position: absolute;
    top: 0; left: 0;
    height: 100%;
    z-index: 1060;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: 6px 0 18px rgba(0,0,0,0.08);
    width: min(var(--sidebar-w), 88vw);
  }
  #sidebar.open { transform: translateX(0); }
}
