:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #15181d; --muted: #5f6672; --line: #e3e6eb;
  --brand: #1f6feb; --brand-ink: #ffffff; --monthly: #1f6feb; --jeonse: #0f9d77; --short: #c2410c; --type: #475467;
  --chip: #eef2f7; --shadow: 0 6px 24px rgba(20, 24, 31, 0.14);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --panel: #171b21; --text: #e8ebf0; --muted: #9aa3b0; --line: #2a3038;
    --brand: #4c8dff; --chip: #222831; --type: #6b7685; --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --panel: #171b21; --text: #e8ebf0; --muted: #9aa3b0; --line: #2a3038;
  --brand: #4c8dff; --chip: #222831; --type: #6b7685; --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: "Inter", "Pretendard", "Apple SD Gothic Neo", "Noto Sans SC", "Noto Sans", system-ui, sans-serif; }
body.app { height: 100%; overflow: hidden; }
a { color: var(--brand); }
button, select, input, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }

header.top { height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 20; }
.logo { font-weight: 800; font-size: 19px; letter-spacing: -0.3px; white-space: nowrap; color: var(--text); text-decoration: none; }
.logo b { color: var(--brand); }
.tagline { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.hbtn { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 12px; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text); font-size: 14px; }
.hbtn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
select.lang { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 10px; }

/* map app — PC: 왼쪽 위 필터 · 왼쪽 아래 목록 · 오른쪽 지도 */
.mapapp { position: absolute; top: 56px; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 380px 1fr; grid-template-rows: auto 1fr; }
#filters { grid-column: 1; grid-row: 1; background: var(--panel); border-right: 1px solid var(--line); z-index: 4; }
#side { grid-column: 1; grid-row: 2; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; z-index: 3; }
#mapwrap { grid-column: 2; grid-row: 1 / span 2; min-width: 0; position: relative; }
#map { position: absolute; inset: 0; }
.filters { padding: 12px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; position: relative; }
.searchrow { display: flex; gap: 8px; }
.more { display: grid; gap: 10px; }
.fbtn, .morehead, .done, .handle, .preview { display: none; }
.sticky-cta { position: sticky; bottom: 0; background: var(--panel); padding: 10px 16px 14px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.search { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 12px; }
.search-results { position: absolute; left: 16px; right: 16px; top: 52px; z-index: 5; background: var(--panel); border-radius: 10px; box-shadow: var(--shadow); display: grid; }
.search-results:empty { display: none; }
.search-results button { text-align: left; border: none; background: none; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.search-results button:hover { background: var(--chip); }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.chip { border: 1px solid var(--line); background: var(--chip); border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer; text-decoration: none; color: var(--text); display: inline-flex; align-items: center; gap: 4px; }
.chip.small { font-size: 12px; padding: 4px 9px; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.range { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.range input { flex: 1; min-width: 0; }
.range output { min-width: 70px; text-align: right; font-variant-numeric: tabular-nums; }
.listhead { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); }
.listhead select { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 3px 6px; }
#list { overflow-y: auto; flex: 1; min-height: 0; }
.card { width: 100%; text-align: left; border: none; border-bottom: 1px solid var(--line); background: none; padding: 12px 16px; cursor: pointer; display: grid; gap: 4px; }
.card:hover, .card.sel { background: var(--chip); }
.price { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.sub { font-size: 13px; color: var(--muted); }
.badges { display: flex; gap: 4px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 6px; color: #fff; }
.b-monthly { background: var(--monthly); } .b-jeonse { background: var(--jeonse); } .b-short { background: var(--short); } .b-type { background: var(--type); }
.empty { padding: 24px 16px; color: var(--muted); font-size: 14px; }
.note { padding: 8px 16px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); }

.maptools { position: absolute; left: 12px; top: 12px; z-index: 2; }
.maptools select { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 6px 10px; box-shadow: var(--shadow); }
.maphint { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 2; white-space: nowrap; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 12px; box-shadow: var(--shadow); pointer-events: none; }
.maphint[hidden] { display: none; }

.bubble { background: rgba(31,111,235,.92); color: #fff; border-radius: 14px; padding: 6px 10px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,.3); white-space: nowrap; cursor: pointer; }
.bubble b { display: block; font-size: 13px; } .bubble span { font-size: 11px; opacity: .9; }
.campus { background: #15181d; color: #fff; border-radius: 8px; padding: 3px 7px; font-size: 11px; font-weight: 700; white-space: nowrap; pointer-events: none; }
.campus::before { content: "🎓 "; }
.campus.work::before { content: "🏭 "; } .campus.town::before { content: "🏙️ "; } .campus.base::before { content: "🪖 "; }
.campus.work, .campus.town, .campus.base { background: #344054; }
.tabs { gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: nowrap; }
.tab { flex: 1; border: none; background: var(--panel); color: var(--text); padding: 7px 0; font-size: 14px; font-weight: 600; cursor: pointer; }
.tab + .tab { border-left: 1px solid var(--line); }
.tab.on { background: var(--brand); color: var(--brand-ink); }

#detail { position: absolute; top: 0; right: 0; bottom: 0; width: 400px; max-width: 100%; background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  transform: translateX(105%); transition: transform .25s ease; z-index: 10; overflow-y: auto; }
#detail.open { transform: none; }
.dhead { position: sticky; top: 0; background: var(--panel); display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); z-index: 1; }
.dbody { padding: 16px; display: grid; gap: 14px; }
.big { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.usd { color: var(--muted); font-size: 13px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fact { background: var(--chip); border-radius: 10px; padding: 8px 10px; }
.fact small { display: block; color: var(--muted); font-size: 11px; }
.gone { background: #fff1f0; color: #b42318; border: 1px solid #f4c7c3; border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 600; }
.compare { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; display: grid; gap: 4px; }
.orig { background: var(--chip); border-radius: 10px; padding: 10px 12px; font-size: 13px; display: grid; gap: 6px; justify-items: start; }
.orig small { color: var(--muted); }
.cta { width: 100%; border: none; background: var(--brand); color: var(--brand-ink); border-radius: 12px; padding: 12px; font-weight: 700; cursor: pointer; font-size: 15px; }
.cta.ghost { background: var(--chip); color: var(--text); border: 1px solid var(--line); }
.cta:disabled { opacity: .6; }
.x { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.agentcard { gap: 10px; }
.agent-title { font-size: 15px; color: var(--muted); }
.agent-big { font-size: 28px; font-weight: 800; }
.agent-line { font-size: 18px; }
.agentcard hr { border: none; border-top: 1px solid var(--line); width: 100%; }

#modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
#modal.open { display: flex; }
.mbox { background: var(--panel); border-radius: 16px; width: 460px; max-width: 100%; max-height: 100%; overflow-y: auto; padding: 18px; display: grid; gap: 10px; box-shadow: var(--shadow); }
.mbox h3 { margin: 0; font-size: 18px; }
.mbox p { margin: 0; color: var(--muted); font-size: 13px; }
.field { display: grid; gap: 4px; font-size: 13px; }
.field input, .field select, .field textarea { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.apps { display: flex; gap: 6px; flex-wrap: wrap; }
.consent { display: flex; gap: 8px; font-size: 12px; color: var(--muted); align-items: flex-start; }
.ok { color: var(--jeonse); font-size: 13px; font-weight: 600; }

/* content pages */
.page { padding: 24px 16px 48px; }
.page-in { max-width: 820px; margin: 0 auto; }
.page-in.wide { max-width: 1200px; }
.page h1 { font-size: 26px; line-height: 1.3; margin: 8px 0 12px; }
.page h2 { font-size: 18px; margin-top: 32px; }
.guide p, .guide li { line-height: 1.7; font-size: 16px; }
.links { padding-left: 18px; line-height: 2; }
.cta-link { display: inline-block; margin-top: 16px; background: var(--brand); color: var(--brand-ink); padding: 10px 16px; border-radius: 12px; text-decoration: none; font-weight: 700; }
.tablewrap { overflow-x: auto; }
table.stats { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--panel); border-radius: 12px; overflow: hidden; }
.stats th, .stats td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.stats th { background: var(--chip); font-weight: 600; }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px; }
.foot a { color: var(--muted); }

/* 모바일: 지도 전체 + 위 검색·빠른 필터 + 아래 목록 시트 + 미리보기 카드, 상세는 전체 화면 */
@media (max-width: 760px) {
  .tagline, .hbtn.guide { display: none; }
  header.top { height: 48px; gap: 8px; padding: 0 12px; }
  .logo { font-size: 17px; }
  .hbtn { padding: 5px 10px; font-size: 13px; }
  select.lang { padding: 5px 6px; max-width: 110px; }
  .page h1 { font-size: 22px; }

  .mapapp { top: 48px; display: block; }
  #mapwrap { position: absolute; inset: 0; }
  .maptools { display: none; }
  .maphint { top: 104px; }
  .mapboxgl-ctrl-top-right { top: 96px; }

  #filters { position: absolute; top: 0; left: 0; right: 0; background: transparent; border: none; padding: 8px 10px; gap: 6px; pointer-events: none; }
  #filters > * { pointer-events: auto; }
  .searchrow .search { box-shadow: var(--shadow); background: var(--panel); border-radius: 12px; padding: 10px 12px; }
  .fbtn { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 0 12px; box-shadow: var(--shadow); white-space: nowrap; font-weight: 600; }
  .fbtn span { font-size: 13px; }
  .search-results { left: 10px; right: 10px; top: 56px; }
  .quick { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .quick::-webkit-scrollbar { display: none; }
  .quick .chip { box-shadow: 0 2px 8px rgba(0,0,0,.15); background: var(--panel); white-space: nowrap; }
  .quick .chip.on { background: var(--brand); }
  .more { display: none; }
  /* 필터 창: 전체 화면 */
  #filters.open { position: fixed; inset: 0; z-index: 40; background: var(--panel); overflow-y: auto; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
  #filters.open .searchrow, #filters.open .quick, #filters.open .search-results { display: none; }
  #filters.open { align-content: start; }
  #filters.open .more { display: grid; gap: 14px; align-content: start; }
  .morehead { display: flex; justify-content: space-between; align-items: center; font-size: 17px; }
  .done { display: block; margin-top: 6px; }

  /* 목록 시트 */
  #side { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; border: none; border-radius: 16px 16px 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,.18);
    transition: height .25s ease; padding-bottom: env(safe-area-inset-bottom); }
  #side.sheet-peek { height: calc(68px + env(safe-area-inset-bottom)); }
  #side.sheet-half { height: 50%; }
  #side.sheet-full { height: calc(100% - 64px); }
  .handle { display: flex; justify-content: center; padding: 8px 0 2px; cursor: grab; touch-action: none; }
  .handle span { width: 38px; height: 4px; border-radius: 2px; background: var(--line); }
  .listhead { border-bottom: none; padding: 6px 16px 10px; font-weight: 600; color: var(--text); touch-action: none; }
  #side.sheet-peek #list, #side.sheet-peek .note { display: none; }

  /* 미리보기 카드 */
  .preview:not([hidden]) { display: grid; gap: 6px; position: absolute; left: 10px; right: 10px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 7;
    background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 10px; }
  .pv-main { display: flex; gap: 10px; text-align: left; border: none; background: none; padding: 0; cursor: pointer; }
  .pv-main img { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; flex: none; background: var(--chip); }
  .pv-text { display: grid; gap: 3px; min-width: 0; }
  .pv-text .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pv-nav { display: flex; justify-content: center; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }
  .pv-nav button { border: 1px solid var(--line); background: var(--chip); border-radius: 999px; width: 30px; height: 30px; font-size: 16px; }
  .pv-nav button:disabled { opacity: .35; }

  /* 상세: 전체 화면 */
  #detail { position: fixed; top: 0; width: 100%; border-left: none; z-index: 30; }
  .sticky-cta { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}

/* 주변 시세 게이지 */
.gauge-box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; display: grid; gap: 8px; }
.gauge-box small { color: var(--muted); font-size: 11px; }
.gbar { position: relative; height: 8px; border-radius: 4px; margin: 6px 0 2px; background: linear-gradient(90deg, #12b76a, #f5b301, #e5484d); }
.gmid { position: absolute; top: -3px; width: 2px; height: 14px; margin-left: -1px; background: var(--text); opacity: 0.45; }
.gdot { position: absolute; top: -5px; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; background: var(--text); border: 3px solid var(--panel); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.gscale { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--muted); }
.lvl { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 8px; }
.lvl-cheap { background: #e7f8ef; color: #067647; } .lvl-fair { background: #fdf6e3; color: #93600a; } .lvl-pricey { background: #fdecec; color: #b42318; }
.operator { font-size: 12px; color: var(--muted); text-align: center; }
.listedby { font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }

/* 매물 대표사진 */
.photo { margin: 0; }
.photo img { display: block; width: 100%; max-height: 260px; object-fit: cover; border-radius: 10px; background: var(--chip); }
.photo figcaption { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* 목록 카드 작은 사진: 왼쪽에 두고 글은 오른쪽 */
.card.has-thumb { grid-template-columns: 88px 1fr; column-gap: 12px; }
.card.has-thumb > :not(.thumb) { grid-column: 2; }
.card .thumb { grid-column: 1; grid-row: 1 / span 4; width: 88px; height: 66px; object-fit: cover; border-radius: 8px; background: var(--chip); align-self: center; }
.card.has-thumb .sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.muted.small { font-size: 12px; margin-right: 2px; }

/* 상세: 융자금, 특징 */
.loan { border-radius: 10px; padding: 10px 12px; font-size: 13px; display: grid; gap: 4px; }
.loan small { color: var(--muted); font-size: 11px; }
.loan-none { background: #e7f8ef; color: #067647; } .loan-low { background: var(--chip); }
.feats { display: grid; gap: 6px; } .feats small { color: var(--muted); font-size: 11px; }
.chip.warn { background: #fff1f0; color: #b42318; border-color: #f4c7c3; }

/* 동네·거점 시세 페이지 */
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: inherit; }
.statcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 16px 0; }
.statcards div { background: var(--chip); border-radius: 12px; padding: 12px 14px; }
.statcards span { display: block; font-size: 13px; color: var(--muted); }
.statcards b { display: block; font-size: 18px; margin-top: 4px; }
.roomcards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.roomcards a { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; color: inherit; text-decoration: none; font-size: 14px; }
.roomcards img, .roomcards .noimg { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; flex: none; background: var(--chip); display: grid; place-items: center; font-size: 28px; }
.links.cols { columns: 3 180px; }
.links.cols li { break-inside: avoid; }
details.faq { border-bottom: 1px solid var(--line); padding: 10px 0; }
details.faq summary { font-weight: 600; cursor: pointer; }
details.faq p { margin: 8px 0 0; }
