:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --ink: #1f2a22;
  --muted: #5b685e;
  --line: #dfdbcf;
  --forest: #2f5d3a;
  --forest-ink: #ffffff;
  --forest-soft: #e4ece1;
  --sand: #f1e8d6;
  --clay: #a4532c;
  --clay-soft: #f8e7dc;
  --sky: #2d6380;
  --sky-soft: #e1edf3;
  --shadow: 0 6px 24px rgba(31, 42, 34, .12);
  --radius: 14px;
  --top-h: 64px;
  --chips-h: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141a16; --surface: #1c241f; --surface-2: #19201b; --ink: #e8ece6; --muted: #a3afa5; --line: #2f3a33;
    --forest: #7fb98c; --forest-ink: #10180f; --forest-soft: #233528; --sand: #2c2a22; --clay: #e39a72; --clay-soft: #3a261c;
    --sky: #8cc3df; --sky-soft: #1d3039; --shadow: 0 6px 24px rgba(0,0,0,.45); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141a16; --surface: #1c241f; --surface-2: #19201b; --ink: #e8ece6; --muted: #a3afa5; --line: #2f3a33;
  --forest: #7fb98c; --forest-ink: #10180f; --forest-soft: #233528; --sand: #2c2a22; --clay: #e39a72; --clay-soft: #3a261c;
  --sky: #8cc3df; --sky-soft: #1d3039; --shadow: 0 6px 24px rgba(0,0,0,.45); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 15px; line-height: 1.5; word-break: keep-all; overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--forest); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--forest) 60%, transparent); outline-offset: 2px; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; white-space: nowrap; font-weight: 600; text-decoration: none; color: var(--ink);
}
.btn:hover { border-color: var(--forest); }
.btn.primary { background: var(--forest); color: var(--forest-ink); border-color: var(--forest); }
.btn.ghost { background: transparent; }
.btn.icon { width: 40px; padding: 0; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--forest); color: var(--forest-ink); font-size: 12px; }

/* ---------- 상단 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000; height: var(--top-h);
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--forest); text-decoration: none; font-weight: 800; font-size: 20px; letter-spacing: -.02em; flex: none; }
.brand svg { width: 26px; height: 26px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; max-width: 760px; min-width: 0; }
.search input {
  flex: 1; min-width: 0; height: 42px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2);
}
.search input:focus { border-color: var(--forest); outline: none; background: var(--surface); }
.pill { height: 42px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.pill.set { border-color: var(--forest); background: var(--forest-soft); color: var(--ink); font-weight: 600; }
.top-actions { display: flex; gap: 6px; margin-left: auto; }

.chips {
  height: var(--chips-h); display: flex; gap: 8px; align-items: center; padding: 0 20px;
  overflow-x: auto; scrollbar-width: none; background: var(--surface); border-bottom: 1px solid var(--line);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-size: 14px;
}
.chip[aria-pressed="true"] { background: var(--forest); color: var(--forest-ink); border-color: var(--forest); font-weight: 600; }

/* ---------- 본문 레이아웃 (PC: 목록 + 지도) ---------- */
.layout { display: grid; grid-template-columns: minmax(360px, 440px) 1fr; height: calc(100dvh - var(--top-h) - var(--chips-h)); }
.list-pane { overflow-y: auto; border-right: 1px solid var(--line); background: var(--bg); }
.map-pane { position: relative; }
#map { position: absolute; inset: 0; background: #e8eadf; }
.list-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.result-count { margin: 0; font-weight: 700; }
.sort select { height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); padding: 0 8px; }

.list { list-style: none; margin: 0; padding: 8px 12px; display: grid; gap: 10px; }
.card {
  display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 10px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); cursor: pointer; text-align: left; width: 100%;
}
.card:hover, .card.hl { border-color: var(--forest); box-shadow: var(--shadow); }
.thumb { width: 92px; height: 92px; border-radius: 10px; object-fit: cover; background: var(--forest-soft); display: grid; place-items: center; color: var(--forest); }
.thumb svg { width: 36px; height: 36px; opacity: .7; }
.card h3 { margin: 0 0 2px; font-size: 16px; line-height: 1.35; }
.card .loc { margin: 0; color: var(--muted); font-size: 13px; }
.card .intro { margin: 4px 0 0; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.tag.price-need { background: var(--sand); border-color: transparent; color: var(--ink); }
.tag.price-ok { background: var(--forest-soft); border-color: transparent; color: var(--forest); font-weight: 600; }
.tag.warn { background: var(--clay-soft); border-color: transparent; color: var(--clay); font-weight: 600; }
.tag.online { background: var(--sky-soft); border-color: transparent; color: var(--sky); }
.more { display: flex; margin: 4px auto 16px; }
.notice { margin: 12px; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.notice.error { border-color: var(--clay); background: var(--clay-soft); }
.notice h3 { margin: 0 0 4px; font-size: 16px; }
.notice p { margin: 0 0 10px; color: var(--muted); }
.notice .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.source-foot { padding: 8px 16px 24px; font-size: 12px; color: var(--muted); }

.float { position: absolute; z-index: 500; box-shadow: var(--shadow); }
.research { top: 14px; left: 50%; transform: translateX(-50%); background: var(--surface); }
.locate { right: 12px; bottom: 28px; width: 44px; height: 44px; padding: 0; border-radius: 12px; }
.locate svg { width: 22px; height: 22px; }
.locate.busy { opacity: .6; }

/* 지도 마커 */
.pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--forest); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); display: grid; place-items: center; }
.pin::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #fff; }
.pin.active { background: var(--clay); transform: rotate(-45deg) scale(1.2); }
.pin.osm { background: #5b7c65; }
.marker-cluster { background: color-mix(in srgb, #2f5d3a 30%, transparent); border-radius: 50%; }
.marker-cluster div { width: 32px; height: 32px; margin: 4px; border-radius: 50%; background: #2f5d3a; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.marker-cluster span { line-height: 1; }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #2d6aa6; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(45,106,166,.25); }
.leaflet-popup-content { margin: 12px 14px; font-family: inherit; }
.popup h4 { margin: 0 0 2px; font-size: 15px; }
.popup p { margin: 0 0 8px; color: #5b685e; font-size: 13px; }
.popup .btn { min-height: 32px; font-size: 13px; }

/* ---------- 상세 ---------- */
.detail {
  position: fixed; z-index: 1100; top: calc(var(--top-h) + var(--chips-h)); left: 0; bottom: 0; width: min(440px, 100%);
  background: var(--surface); border-right: 1px solid var(--line); box-shadow: var(--shadow); overflow-y: auto;
}
.detail-inner { padding: 0 0 32px; outline: none; }
.d-hero { position: relative; height: 200px; background: var(--forest-soft); display: grid; place-items: center; color: var(--forest); }
.d-hero img { width: 100%; height: 100%; object-fit: cover; }
.d-hero svg { width: 56px; height: 56px; opacity: .6; }
.d-close { position: absolute; top: 10px; left: 10px; background: var(--surface); box-shadow: var(--shadow); }
.d-share { position: absolute; top: 10px; right: 10px; background: var(--surface); box-shadow: var(--shadow); }
.d-body { padding: 16px 18px; display: grid; gap: 18px; }
.d-title h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; line-height: 1.3; }
.d-title p { margin: 4px 0 0; color: var(--muted); }
.d-section h3 { margin: 0 0 8px; font-size: 15px; }
.d-section p { margin: 0; }
.info-types { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.info-row { display: grid; grid-template-columns: 96px 1fr; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); font-size: 14px; }
.info-row:first-child { border-top: 0; }
.info-row dt { font-weight: 700; }
.info-row dd { margin: 0; }
.info-row .meta { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.status { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 6px; }
.status.ok { background: var(--forest-soft); color: var(--forest); }
.status.need { background: var(--sand); color: var(--ink); }
.status.none { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.status.warn { background: var(--clay-soft); color: var(--clay); }
.price-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.price-table th, .price-table td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.price-table .amt { font-weight: 800; white-space: nowrap; }
.book { display: grid; gap: 8px; }
.book .btn { width: 100%; justify-content: space-between; min-height: 48px; border-radius: 12px; }
.book .btn small { font-weight: 500; opacity: .8; }
.book-note { font-size: 13px; color: var(--muted); background: var(--surface-2); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.prose { white-space: pre-line; font-size: 14px; color: var(--ink); }
.prose.clamp { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.linkish { background: none; border: 0; padding: 0; color: var(--forest); cursor: pointer; font-weight: 600; text-decoration: underline; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- 시트(다이얼로그) ---------- */
.sheet { border: 0; padding: 0; border-radius: 18px; width: min(520px, calc(100% - 32px)); max-height: 86dvh; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.sheet::backdrop { background: rgba(20, 26, 22, .45); }
.sheet form { padding: 20px; display: grid; gap: 14px; }
.sheet h2 { margin: 0; font-size: 19px; }
.sheet .hint { margin: 0; color: var(--muted); font-size: 13px; }
.sheet .err { margin: 0; color: var(--clay); font-weight: 600; font-size: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.row2 input { height: 44px; border-radius: 10px; border: 1px solid var(--line); padding: 0 10px; background: var(--surface-2); }
.stepper { display: grid; grid-template-columns: 1fr 40px 40px 40px; align-items: center; gap: 6px; }
.stepper button { height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 18px; }
.stepper output { text-align: center; font-weight: 700; }
.sheet-actions { display: flex; justify-content: space-between; gap: 8px; position: sticky; bottom: 0; background: var(--surface); padding-top: 8px; }
.fgroup { border: 0; padding: 0; margin: 0; }
.fgroup legend { font-weight: 700; margin-bottom: 8px; }
.fgroup .opts { display: flex; flex-wrap: wrap; gap: 8px; }
.fgroup label.opt { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.fgroup label.opt:has(input:checked) { background: var(--forest-soft); border-color: var(--forest); font-weight: 600; }
.fgroup input { accent-color: var(--forest); }
.fgroup .desc { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
#aboutBody { display: grid; gap: 10px; font-size: 14px; }
#aboutBody h3 { margin: 8px 0 0; font-size: 15px; }
#aboutBody p, #aboutBody ul { margin: 0; }
#aboutBody ul { padding-left: 18px; }

.view-toggle { display: none; }

/* ---------- 모바일 ---------- */
@media (max-width: 860px) {
  :root { --top-h: 112px; }
  .topbar { flex-wrap: wrap; height: auto; min-height: var(--top-h); padding: 8px 16px; gap: 8px; align-content: center; }
  .brand { font-size: 18px; }
  .top-actions { order: 2; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .search input { height: 40px; }
  .pill { height: 40px; max-width: 42%; padding: 0 10px; font-size: 13px; }
  .search .btn.primary { min-height: 40px; padding: 0 12px; }
  .chips { padding: 0 16px; }
  .layout { grid-template-columns: 1fr; }
  .layout[data-view="map"] .list-pane { display: none; }
  .layout[data-view="list"] .map-pane { display: none; }
  .list-pane { border-right: 0; padding-bottom: 80px; }
  .list { padding: 8px 16px; }
  .view-toggle {
    display: inline-flex; position: fixed; z-index: 1050; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
    height: 46px; padding: 0 22px; align-items: center; border-radius: 999px; border: 0; background: var(--ink); color: var(--bg);
    font-weight: 700; box-shadow: var(--shadow); cursor: pointer;
  }
  .detail { top: 0; width: 100%; border-right: 0; z-index: 1200; padding-bottom: env(safe-area-inset-bottom); }
  .locate { bottom: 84px; }
  .sheet { width: 100%; max-width: none; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  .sheet form { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
  .card { grid-template-columns: 72px 1fr; }
  .thumb { width: 72px; height: 72px; }
}
