:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #16181d;
  --ink-2: #4b5260;
  --ink-3: #8a91a0;
  --line: #e6e8ec;
  --brand: #1f6feb;
  --brand-ink: #ffffff;
  --brand-soft: #e8f0fe;
  --accent: #0e9f6e;
  --radius: 14px;
  --top-h: 56px;
  --bar-h: 50px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
button, input, select { font: inherit; color: inherit; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* 상단 */
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 10px; padding: 0 12px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); flex-shrink: 0; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); font-weight: 800; }
.brand-text { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand-text b { color: var(--brand); }
.view-toggle { display: flex; margin-left: auto; padding: 3px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); flex-shrink: 0; }
.vt { height: 32px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; font-weight: 700; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.vt.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* 거르기 줄 */
.filters { position: fixed; top: var(--top-h); left: 0; right: 0; z-index: 29; height: var(--bar-h); display: flex; align-items: center; gap: 8px; padding: 0 12px; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .06); overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.pills { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.pills-label { font-size: 13px; font-weight: 700; color: var(--ink-3); margin-right: 2px; }
.pill { flex-shrink: 0; height: 32px; padding: 0 13px; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.pill.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.pill.loan.on, #onlyPhoto.on { background: var(--accent); border-color: var(--accent); }
.bar-sep { width: 1px; height: 22px; background: var(--line); flex-shrink: 0; }
.filters select { flex-shrink: 0; height: 32px; padding: 0 8px; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px; font-weight: 600; color: var(--ink-2); }
body.mode-map .list-only { display: none; }
.pill.drop.set { background: var(--brand); border-color: var(--brand); color: #fff; }

/* 보증금·동 설정 창 (거르기 줄 바로 아래) */
.fdrop { position: fixed; top: calc(var(--top-h) + var(--bar-h)); left: 0; right: 0; z-index: 28; display: none; max-height: 60vh; overflow-y: auto; padding: 14px 16px 12px; background: #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, .13); }
.fdrop.open { display: block; }
@media (min-width: 700px) { .fdrop { left: 12px; right: auto; width: 440px; border-radius: 0 0 14px 14px; } }
.fdrop-label { margin-bottom: 8px; font-size: 12px; font-weight: 700; color: var(--ink-3); }
.fdrop-range { display: flex; align-items: center; gap: 8px; }
.fdrop-range input { flex: 1; min-width: 0; height: 40px; padding: 0 10px; border: 1.5px solid var(--line); border-radius: 9px; font-size: 15px; outline: none; }
.fdrop-range input:focus { border-color: var(--brand); }
.fdrop-range .sep { color: var(--ink-3); }
.fdrop-hint { margin: 6px 2px 12px; font-size: 12px; color: var(--ink-3); }
.fdrop-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.dchip { height: 32px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.dchip small { margin-left: 3px; color: var(--ink-3); font-weight: 500; }
.dchip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.fdrop-actions { position: sticky; bottom: -12px; display: flex; gap: 8px; margin: 0 -16px -12px; padding: 10px 16px 12px; background: #fff; border-top: 1px solid var(--line); }
.fdrop-actions button { flex: 1; height: 42px; border: 0; border-radius: 10px; font-size: 14px; font-weight: 700; cursor: pointer; }
.btn-reset { background: var(--bg); color: var(--ink-2); }
.btn-apply { background: var(--brand); color: #fff; }

/* 지도 */
.map-view { position: fixed; top: calc(var(--top-h) + var(--bar-h)); left: 0; right: 0; bottom: 0; }
#map { width: 100%; height: 100%; background: #eef0f3; }
body.mode-list .map-view { display: none; }
.count-badge { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 5; padding: 5px 14px; border-radius: 999px; background: rgba(0, 0, 0, .65); color: #fff; font-size: 12px; white-space: nowrap; pointer-events: none; }
.map-notice { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 6; width: min(320px, 90vw); padding: 18px; border-radius: 14px; background: #fff; box-shadow: var(--shadow); text-align: center; color: var(--ink-2); }
.map-notice button { margin-top: 12px; }
.mk { display: flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 999px; background: var(--brand); border: 2.5px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .28); color: #fff; font-weight: 800; font-size: 13px; cursor: pointer; user-select: none; white-space: nowrap; }
.mk.nophoto { background: #7b8494; }
.mk.sel { background: #e8590c; transform: scale(1.12); }
.mk:active { transform: scale(.92); }

/* 아래에서 올라오는 목록 */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 10; max-height: 62%; display: flex; flex-direction: column; background: #fff; border-radius: 18px 18px 0 0; box-shadow: 0 -4px 24px rgba(0, 0, 0, .14); transform: translateY(105%); transition: transform .3s cubic-bezier(.32, .72, 0, 1); }
.sheet.open { transform: translateY(0); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 8px; }
.sheet-head strong { font-size: 17px; }
.sheet-head span { margin-left: 6px; color: var(--ink-3); font-size: 13px; }
.sheet-close { width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--bg); font-size: 22px; line-height: 1; cursor: pointer; }
.sheet-list { overflow-y: auto; padding: 4px 12px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 8px; }
.row-card { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; text-align: left; cursor: pointer; }
.row-card img { width: 96px; height: 72px; border-radius: 8px; object-fit: cover; background: #eef0f3; }
.row-card .price { font-size: 16px; }
@media (min-width: 900px) {
  .sheet { left: auto; right: 16px; bottom: 16px; top: 16px; width: 380px; max-height: none; border-radius: 18px; transform: translateX(calc(100% + 24px)); }
  .sheet.open { transform: translateX(0); }
}

/* 목록 보기 */
.list-view { display: none; padding-top: calc(var(--top-h) + var(--bar-h) + 8px); }
body.mode-list .list-view { display: block; }
.count { margin: 10px 2px; color: var(--ink-2); font-size: 14px; }
.count b { color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; text-align: left; padding: 0; box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; }
.card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(16, 24, 40, .06), 0 10px 28px rgba(16, 24, 40, .1); }
.card:focus-visible, .row-card:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.thumb { position: relative; aspect-ratio: 4 / 3; background: #eef0f3; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .n { position: absolute; right: 8px; bottom: 8px; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 12px; font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.thumb .badge { position: absolute; left: 8px; top: 8px; }
.badge.real { background: var(--accent); color: #fff; }
.badge.ref { background: #fff; color: var(--ink-2); border: 1px solid var(--line); }
.badge.none { background: #fff; color: var(--ink-3); border: 1px solid var(--line); }
.info { padding: 12px 14px 14px; display: grid; gap: 4px; }
.row-card .info { padding: 0; gap: 2px; }
.price { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.price .deal { margin-right: 6px; color: var(--brand); }
.meta { color: var(--ink-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { color: var(--ink-3); font-size: 13px; }
.loan-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.loan-tag { padding: 1px 7px; border-radius: 6px; background: #e7f6ef; color: #0b7a55; font-size: 12px; font-weight: 700; }
.empty { padding: 48px 0; text-align: center; color: var(--ink-3); }
.foot { padding: 32px 0 48px; color: var(--ink-3); font-size: 12px; }
.foot p { margin: 2px 0; }

/* 상세 */
dialog { width: min(760px, 100vw); max-height: 100dvh; margin: auto; padding: 0; border: 0; border-radius: 18px; background: var(--card); color: var(--ink); overflow: auto; }
dialog::backdrop { background: rgba(10, 12, 16, .6); }
.d-box { position: relative; }
.d-close { position: absolute; right: 10px; top: 10px; z-index: 3; width: 38px; height: 38px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; font-size: 24px; line-height: 1; cursor: pointer; }
.gallery { position: relative; background: #0f1115; }
.g-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; aspect-ratio: 4 / 3; }
.g-track::-webkit-scrollbar { display: none; }
.g-track img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: contain; scroll-snap-align: center; }
.g-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .85); font-size: 26px; line-height: 1; cursor: pointer; }
.g-nav.prev { left: 10px; }
.g-nav.next { right: 10px; }
.g-count { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); padding: 2px 10px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 12px; }
.d-body { padding: 18px 20px 22px; }
.d-body h2 { margin: 0 0 2px; font-size: 22px; letter-spacing: -.02em; }
.d-addr { margin: 0; color: var(--ink-2); }
.d-sec { margin: 22px 0 -8px; font-size: 15px; }
.d-sec small { margin-left: 4px; color: var(--ink-3); font-weight: 500; font-size: 12px; }
.d-info { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 16px 0; padding: 14px 16px; border-radius: 12px; background: var(--bg); }
.d-info dt { color: var(--ink-3); }
.d-info dd { margin: 0; font-weight: 600; }
.d-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; height: 44px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--brand); color: var(--brand-ink); font-weight: 700; text-decoration: none; cursor: pointer; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.inquiry { width: 100%; height: 52px; margin: 14px 0 10px; font-size: 17px; background: #fee500; color: #191919; }

@media (max-width: 640px) {
  .brand-text { display: none; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .info { padding: 10px 11px 12px; }
  .price { font-size: 16px; }
  .meta { font-size: 13px; }
  dialog { border-radius: 0; height: 100dvh; }
  .g-nav { display: none; }
}
@media (max-width: 360px) {
  .grid { grid-template-columns: 1fr; }
}

/* ⭐ 추천 매물 - 빨간색 강조 */
.card.rec, .row-card.rec { border: 2px solid #e03131; box-shadow: 0 0 0 3px rgba(224, 49, 49, .12), var(--shadow); }
.rec-badge { position: absolute; right: 8px; top: 8px; padding: 3px 9px; border-radius: 6px; background: #e03131; color: #fff; font-size: 12px; font-weight: 800; }
.rec-inline { display: inline-block; margin-right: 6px; padding: 1px 7px; border-radius: 6px; background: #e03131; color: #fff; font-size: 12px; font-weight: 800; vertical-align: 2px; }
.mk.rec { background: #e03131; }
