/* 캠핑맵 — 지도를 배경으로 두고 결과가 그 위에 뜨는 구조.
   모바일: 바텀시트(3단 스냅) / 데스크톱: 좌측 패널 */
:root {
  color-scheme: light dark;
  /* 밝고 채도 높은 초록 + 따뜻한 앰버 포인트 */
  --green: #12a05f;
  --green-700: #0d8850;
  --green-50: #e3f7ec;
  --ink: #101a15;
  --ink-2: #566a5f;
  --ink-3: #8a9a91;
  --line: #e6ebe8;
  --surface: #fff;
  --surface-2: #f0f4f1;   /* 썸네일·태그 칩 배경 */
  --bg: #f2f6f3;
  --amber: #f59e0b;
  --grab: #d3dad6;
  --scrim: rgba(16, 26, 21, .38);
  --map-filter: none;
  --fill: #0d8850;        /* 초록으로 채운 버튼·칩 */
  --on-fill: #fff;
  --inverse: #101a15;     /* 지도 위 대비용 반전 배경 */
  --on-inverse: #fff;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow-1: 0 1px 2px rgba(16, 26, 21, .06), 0 2px 8px rgba(16, 26, 21, .06);
  --shadow-2: 0 4px 16px rgba(16, 26, 21, .1), 0 12px 32px rgba(16, 26, 21, .08);
  --sheet-head: 116px;
  --top-h: 112px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

/* 다크 모드 — 기기 설정을 따른다 */
@media (prefers-color-scheme: dark) {
  :root {
    --green: #24c37a;
    --green-700: #1ba468;
    --green-50: #16332a;
    --ink: #e9f0ec;
    --ink-2: #9db0a6;
    --ink-3: #74877c;
    --line: #253029;
    --surface: #151d19;
    --surface-2: #1e2823;
    --bg: #0d1310;
    --amber: #fbbf24;
    --grab: #39463f;
    --scrim: rgba(0, 0, 0, .55);
    --map-filter: brightness(.82) saturate(.85) contrast(1.05);
    --fill: #24c37a;
    --on-fill: #05231a;    /* 밝은 초록 위에는 어두운 글자라야 읽힌다 */
    --inverse: #e9f0ec;
    --on-inverse: #101a15;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 8px rgba(0, 0, 0, .3);
    --shadow-2: 0 4px 16px rgba(0, 0, 0, .5), 0 12px 32px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* display:flex/grid 가 hidden 속성을 덮어쓰지 않도록 (필터 패널·배지가 안 숨겨지는 버그) */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.02em; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 지도 ---------- */
#map { position: fixed; inset: 0; background: var(--bg); filter: var(--map-filter); }
.map-notice {
  position: fixed; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 24px; color: var(--ink-2); background: var(--bg); z-index: 1;
}
.map-notice code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: 13px; }

/* ---------- 상단 검색 ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  padding: calc(10px + var(--safe-t)) 12px 8px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.search-row { display: flex; gap: 8px; align-items: center; }
.brand {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; font-size: 20px;
  background: var(--green); border-radius: 14px; box-shadow: var(--shadow-1);
}
.search {
  flex: 1; min-width: 0; height: 44px; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border-radius: 14px; padding: 0 12px; box-shadow: var(--shadow-1);
}
.search .ico { color: var(--ink-3); flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 15px;
}
.search input::-webkit-search-cancel-button { display: none; }
.q-clear { color: var(--ink-3); font-size: 13px; padding: 4px; }
.icon-btn {
  position: relative; width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-1); color: var(--ink);
}
.icon-btn.ghost { background: none; box-shadow: none; }
.badge {
  position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--fill); color: var(--on-fill); border-radius: 9px; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}

/* 빠른 태그 */
.quick-tags {
  display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; padding-bottom: 2px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.quick-tags::-webkit-scrollbar { display: none; }
.quick-tags .chip { flex: none; box-shadow: var(--shadow-1); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 13px;
  background: var(--surface); border-radius: 999px; font-size: 13.5px; font-weight: 600;
  color: var(--ink); border: 1px solid transparent; white-space: nowrap;
}
.chip small { color: var(--ink-3); font-weight: 500; font-size: 12px; }
.chip.on { background: var(--fill); color: var(--on-fill); }
.chip.on small { color: var(--on-fill); opacity: .75; }

/* ---------- 지도 위 버튼 ---------- */
.map-fabs {  /* 시트 위쪽에 붙는다 */
  position: absolute; bottom: 100%; right: 12px; margin-bottom: 12px; z-index: 15;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.fab {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--surface); border-radius: 50%; box-shadow: var(--shadow-2); color: var(--ink);
}
.fab.on { background: var(--fill); color: var(--on-fill); }
.pill-btn {
  height: 38px; padding: 0 16px; border-radius: 999px; background: var(--inverse); color: var(--on-inverse);
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-2);
}

/* ---------- 결과 시트 ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 18;
  background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-2);
  display: flex; flex-direction: column;
  height: 100%; transform: translateY(calc(100% - var(--sheet-h, 52%)));
  transition: transform .28s cubic-bezier(.32, .72, 0, 1);
  touch-action: none;
}
.sheet.dragging { transition: none; }
.sheet[data-snap="peek"] { --sheet-h: calc(var(--sheet-head) + var(--safe-b)); }
.sheet[data-snap="half"] { --sheet-h: 52%; }
.sheet[data-snap="full"] { --sheet-h: calc(100% - 104px); }
.sheet-grab { padding: 10px 0 6px; display: grid; place-items: center; cursor: grab; flex: none; }
.sheet-grab span { width: 40px; height: 4px; border-radius: 2px; background: var(--grab); display: block; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 2px 16px 12px; flex: none; border-bottom: 1px solid var(--line);
}
.sheet-head strong { font-size: 15px; display: flex; align-items: center; gap: 7px; }
.spinner {
  width: 14px; height: 14px; flex: none; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--green); animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.sheet-actions { display: flex; align-items: center; gap: 8px; }
.toggle { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--ink-2); }
.toggle input { width: 15px; height: 15px; accent-color: var(--green); }
.select-wrap { position: relative; }
.select-wrap::after {
  content: ''; position: absolute; right: 10px; top: 50%; width: 6px; height: 6px; pointer-events: none;
  border-right: 1.6px solid var(--ink-2); border-bottom: 1.6px solid var(--ink-2);
  transform: translateY(-70%) rotate(45deg);
}
#sort {
  appearance: none; height: 32px; padding: 0 26px 0 12px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 600;
}

/* 목록 */
.list { list-style: none; margin: 0; padding: 4px 0 calc(24px + var(--safe-b)); overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.card { display: flex; gap: 12px; padding: 12px 16px; cursor: pointer; align-items: flex-start; }
.card:active { background: var(--surface-2); }
.card.active { background: var(--green-50); }
.card .thumb {
  width: 88px; height: 88px; flex: none; border-radius: var(--r-md); object-fit: cover;
  background: var(--surface-2); display: grid; place-items: center; font-size: 26px; color: var(--ink-3);
}
.card .body { min-width: 0; flex: 1; }
.card h3 { font-size: 15.5px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
/* 태그는 한 줄만, 넘치면 오른쪽으로 자연스럽게 흐려진다 */
.card .tags {
  display: flex; gap: 4px; margin-top: 7px; overflow: hidden; height: 21px;
  mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
}
.card .tags span {
  flex: none; font-size: 11.5px; font-weight: 600; color: var(--ink-2); background: var(--surface-2);
  border-radius: 6px; padding: 2px 7px;
}
.rating { color: var(--amber); font-weight: 700; }
.price { color: var(--ink); font-weight: 700; }
.price-row { margin-top: 10px; font-size: 15px; display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.price-row b { font-size: 19px; }
.price-row span { color: var(--ink-2); font-size: 13.5px; }
.price-row .note { color: var(--ink-3); }
.price-row.none { color: var(--ink-3); font-size: 13.5px; }
.price-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.price-meta a { color: var(--ink-2); }
.link-btn { color: var(--green); font-size: 13px; font-weight: 600; padding: 0 4px; }
.dot { color: var(--ink-3); }
.empty { padding: 48px 24px; text-align: center; color: var(--ink-2); }
.skeleton { padding: 12px 16px; display: flex; gap: 12px; }
.skeleton i, .skeleton u {
  display: block; background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: sk 1.2s ease infinite; border-radius: var(--r-sm);
}
.skeleton i { width: 88px; height: 88px; flex: none; border-radius: var(--r-md); }
.skeleton u { height: 13px; margin-bottom: 8px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- 필터 패널 ---------- */
.filters {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; max-height: 86%;
  background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-2);
  display: flex; flex-direction: column; animation: up .26s cubic-bezier(.32, .72, 0, 1);
}
@keyframes up { from { transform: translateY(100%); } }
.filters-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; }
.filters-top h2 { font-size: 17px; }
.tag-groups { overflow-y: auto; padding: 0 16px 12px; flex: 1; }
.tag-group { margin-bottom: 18px; }
.tag-group .g { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-3); margin-bottom: 8px; }
.tag-group .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-group .chip { border-color: var(--line); }
.filters-bottom {
  display: flex; gap: 8px; padding: 12px 16px calc(16px + var(--safe-b)); border-top: 1px solid var(--line);
}
.btn { height: 48px; border-radius: var(--r-md); font-weight: 700; font-size: 15px; }
.btn.primary { flex: 1; background: var(--fill); color: var(--on-fill); }
.btn.ghost { padding: 0 18px; background: var(--surface-2); color: var(--ink); }

/* ---------- 상세 ---------- */
.detail {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-height: 92%;
  background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-2);
  overflow-y: auto; animation: up .26s cubic-bezier(.32, .72, 0, 1); padding-bottom: calc(24px + var(--safe-b));
}
.detail-close {
  position: absolute; top: 12px; right: 12px; z-index: 2; width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); font-size: 13px;
}
.hero { width: 100%; height: 210px; object-fit: cover; display: block; background: var(--surface-2); }
.hero-empty { height: 60px; }
.detail-body { padding: 16px 18px 0; }
.detail h2 { font-size: 21px; margin-bottom: 4px; }
.detail .sub { color: var(--ink-2); font-size: 13.5px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.detail .intro { margin: 12px 0 0; color: var(--ink-2); font-size: 14px; }
.cta-row { display: flex; gap: 8px; margin: 16px 0 4px; }
.cta-row a {
  flex: 1; height: 46px; display: grid; place-items: center; border-radius: var(--r-md);
  background: var(--fill); color: var(--on-fill); text-decoration: none; font-weight: 700; font-size: 14.5px;
}
.cta-row a.sec { background: var(--surface-2); color: var(--ink); }
.sec-title { font-size: 13px; font-weight: 700; color: var(--ink-3); margin: 20px 0 8px; }
.kv { display: flex; gap: 10px; font-size: 14px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv b { width: 52px; flex: none; color: var(--ink-3); font-weight: 600; }
.kv a { color: var(--green); text-decoration: none; }
.tagline { display: flex; flex-wrap: wrap; gap: 6px; }
.tagline .chip { height: 30px; font-size: 12.5px; border-color: var(--line); }
.tagline .chip.manual { background: var(--green-50); border-color: transparent; }
.tagline .x { color: var(--ink-3); margin-left: 2px; }
.tag-add { display: flex; gap: 6px; margin-top: 10px; }
.tag-add input { flex: 1; height: 40px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 12px; outline: none; }
.tag-add input:focus { border-color: var(--green); }
.tag-add button { height: 40px; padding: 0 16px; border-radius: var(--r-sm); background: var(--fill); color: var(--on-fill); font-weight: 700; }
.review { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.review .who { font-size: 12.5px; color: var(--ink-3); margin-bottom: 3px; display: flex; gap: 6px; align-items: center; }
.sources { margin-top: 18px; font-size: 12px; color: var(--ink-3); }
.sources a { color: var(--ink-2); }

.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 35; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }

/* 내 위치 */
.me { transform: translate(-50%, -50%); width: 22px; height: 22px; position: relative; }
.me::before {
  content: ''; position: absolute; inset: -9px; border-radius: 50%;
  background: var(--green); opacity: .18; animation: pulse 2s ease-out infinite;
}
.me-dot {
  position: absolute; inset: 0; border-radius: 50%; background: #2f7ff0;
  border: 3px solid var(--surface); box-shadow: 0 2px 8px rgba(0, 0, 0, .35); display: block;
}
@keyframes pulse { 0% { transform: scale(.6); opacity: .35; } 100% { transform: scale(1.25); opacity: 0; } }

/* 지도 마커 */
.pin {
  transform: translate(-50%, -100%); background: var(--fill); color: var(--on-fill); padding: 6px 11px;
  border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap;
  box-shadow: var(--shadow-2); position: relative; border: 2px solid var(--surface);
}
.pin::after {
  content: ''; position: absolute; left: 50%; bottom: -7px; margin-left: -5px;
  border: 5px solid transparent; border-top-color: var(--surface); border-bottom: 0;
}

/* ---------- 데스크톱 ---------- */
@media (min-width: 900px) {
  :root { --panel-w: 416px; }
  .topbar { left: 0; width: var(--panel-w); padding: 14px 16px 10px; }
  .brand { display: grid; }
  .sheet {
    top: 0; left: 0; right: auto; width: var(--panel-w); height: 100%;
    border-radius: 0; transform: none; padding-top: var(--top-h);
    box-shadow: 0 0 24px rgba(20, 32, 27, .1); transition: none;
  }
  .sheet-grab { display: none; }
  .sheet-head { padding: 12px 16px; border-top: 1px solid var(--line); }
  .map-fabs { position: fixed; bottom: 24px; right: 24px; margin: 0; }
  .filters {
    left: var(--panel-w); bottom: auto; top: 50%; transform: translateY(-50%);
    width: 460px; max-height: 78%; border-radius: var(--r-lg); margin-left: 16px; animation: fade .2s;
  }
  .detail {
    left: var(--panel-w); top: 0; bottom: 0; width: 440px; max-height: none;
    border-radius: 0; animation: slide .24s cubic-bezier(.32, .72, 0, 1);
  }
  @keyframes slide { from { transform: translateX(-24px); opacity: .4; } }
  .card:hover { background: var(--surface-2); }
}
@media (max-width: 899px) {
  .sheet[data-snap="full"] .list { padding-bottom: calc(40px + var(--safe-b)); }
  .detail { max-height: 88%; }
}
