﻿/* 써드머니 시세 지도 시안
 * 팔레트: ui-ux-pro-max design-system (real estate + fintech → "Trust teal + professional blue")
 * 글꼴: Pretendard(한글) · 레이아웃: 왼쪽 목록 패널 + 오른쪽 지도(호갱노노·직방 문법), 모바일은 지도 위·목록 아래·하단 탭
 */
:root {
  --c-primary: #0F766E; --c-primary-600: #0D655E; --c-primary-50: #E6F4F2;
  --c-accent: #0369A1; --c-accent-50: #E8F2F9;
  --c-bg: #F4F6F8; --c-card: #FFFFFF; --c-line: #E3E8EE; --c-line-2: #CFD7E0;
  --c-text: #111827; --c-text-2: #374151; --c-muted: #6B7280;
  --c-danger: #DC2626; --c-danger-50: #FDECEC; --c-on: #FFFFFF;
  --font: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(17,24,39,.06), 0 2px 8px rgba(17,24,39,.06);
  --sh-2: 0 8px 24px rgba(17,24,39,.14);
  --bar-h: 60px; --panel-w: 420px; --ease: cubic-bezier(.2,.7,.2,1);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow-x: clip; }
body { font-family: var(--font); color: var(--c-text); background: var(--c-bg); font-size: 15px; line-height: 1.5; word-break: keep-all; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

/* 상단 앱바 */
.appbar { position: sticky; top: 0; z-index: 1000; height: var(--bar-h); display: flex; align-items: center; gap: 28px; padding: 0 20px; background: var(--c-card); border-bottom: 1px solid var(--c-line); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--c-primary); text-decoration: none; font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.brand span { color: var(--c-text); }
.topnav { display: flex; gap: 4px; height: 100%; }
.topnav a, .topnav .soon { display: flex; align-items: center; padding: 0 14px; color: var(--c-muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; }
.topnav a:hover { color: var(--c-text); }
.topnav a[aria-current="page"] { color: var(--c-primary); border-bottom-color: var(--c-primary); }
.topnav .soon { cursor: not-allowed; }
.topnav em, .calc h3 em { font-style: normal; font-size: 11px; font-weight: 600; margin-left: 6px; padding: 2px 6px; border-radius: var(--r-pill); background: var(--c-bg); color: var(--c-muted); }
.beta { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--c-accent); background: var(--c-accent-50); padding: 4px 10px; border-radius: var(--r-pill); }

/* 본문: 패널 + 지도 */
.shell { display: grid; grid-template-columns: var(--panel-w) minmax(0, 1fr); height: calc(100dvh - var(--bar-h)); }
.panel { position: relative; overflow-y: auto; background: var(--c-card); border-right: 1px solid var(--c-line); padding-bottom: 24px; }
.mapwrap { position: relative; min-width: 0; }
.leaflet-host { position: absolute; inset: 0; background: #E9EEF2; }
.maplegend { position: absolute; left: 16px; bottom: 16px; z-index: 500; background: var(--c-card); padding: 8px 12px; border-radius: var(--r-sm); box-shadow: var(--sh-1); font-size: 13px; color: var(--c-text-2); }

/* 검색 */
.search { position: sticky; top: 0; z-index: 5; display: grid; gap: 10px; padding: 16px; background: var(--c-card); border-bottom: 1px solid var(--c-line); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.field { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--c-muted); }
.field select, .field input:not([type=range]) { height: 44px; width: 100%; padding: 0 12px; border: 1px solid var(--c-line-2); border-radius: var(--r-sm); background: var(--c-card); font-size: 15px; color: var(--c-text); transition: border-color .15s var(--ease); }
.field select:hover, .field input:hover { border-color: var(--c-muted); }
.field select:focus-visible, .field input:focus-visible { border-color: var(--c-accent); outline: 2px solid var(--c-accent-50); outline-offset: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; background: var(--c-bg); border-radius: var(--r-md); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; justify-content: center; align-items: center; height: 36px; border-radius: var(--r-sm); font-weight: 600; color: var(--c-muted); cursor: pointer; transition: background-color .15s var(--ease), color .15s var(--ease); }
.seg input:checked + span { background: var(--c-card); color: var(--c-text); box-shadow: var(--sh-1); }
.seg input:focus-visible + span { outline: 2px solid var(--c-accent); }

.btn { height: 44px; padding: 0 18px; border: 1px solid var(--c-line-2); border-radius: var(--r-sm); background: var(--c-card); font-weight: 700; cursor: pointer; transition: background-color .15s var(--ease), transform .1s var(--ease); }
.btn:hover { background: var(--c-bg); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-on); }
.btn.primary:hover { background: var(--c-primary-600); }
.btn:disabled, .btn[aria-busy="true"] { background: var(--c-bg); border-color: var(--c-line); color: var(--c-muted); cursor: not-allowed; transform: none; }
.btn.wide { display: flex; align-items: center; justify-content: center; width: 100%; height: 52px; font-size: 16px; text-decoration: none; }
.btn.more { display: block; margin: 12px auto 0; }

/* 요약 */
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 16px; border-radius: var(--r-md); background: linear-gradient(135deg, var(--c-primary), var(--c-accent)); color: var(--c-on); }
.summary div { padding: 14px; display: grid; gap: 2px; min-width: 0; }
.summary div + div { border-left: 1px solid rgba(255,255,255,.2); }
.summary span { font-size: 12px; opacity: .85; }
.summary b { font-size: 18px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.listhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 16px 8px; flex-wrap: wrap; }
.listhead p { margin: 0; font-size: 13px; color: var(--c-muted); }
.listhead p button { border: 0; background: none; color: var(--c-accent); font-weight: 600; cursor: pointer; padding: 0 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { height: 32px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--c-line-2); background: var(--c-card); font-size: 13px; font-weight: 600; color: var(--c-text-2); cursor: pointer; }
.chips button:hover { border-color: var(--c-muted); }
.chips button[aria-pressed="true"] { background: var(--c-text); border-color: var(--c-text); color: var(--c-on); }

/* 매물 카드 */
.cards { list-style: none; margin: 0; padding: 0 16px; display: grid; gap: 10px; }
.card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; width: 100%; text-align: left; padding: 14px 16px; border: 1px solid var(--c-line); border-radius: var(--r-md); background: var(--c-card); cursor: pointer; transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.card:hover, .card.hl { border-color: var(--c-primary); box-shadow: var(--sh-1); }
.card .nm { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .pr { grid-row: span 2; align-self: center; text-align: right; font-weight: 800; font-size: 19px; color: var(--c-primary); letter-spacing: -.02em; white-space: nowrap; }
.card .lc { font-size: 13px; color: var(--c-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .tg { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.card .tg span { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--c-bg); color: var(--c-text-2); }
.card .tg .dt { margin-left: auto; background: none; color: var(--c-muted); padding-right: 0; }

.state { padding: 32px 16px; color: var(--c-muted); text-align: center; }
.state.error { display: grid; gap: 12px; justify-items: center; }
.state.error p { margin: 0; padding: 12px 14px; border-radius: var(--r-sm); background: var(--c-danger-50); color: var(--c-danger); font-weight: 600; text-align: left; }
.skel { height: 84px; margin-bottom: 10px; border-radius: var(--r-md); background: var(--c-bg); animation: pulse 1.1s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .45; } }
.src { margin: 16px; font-size: 12px; color: var(--c-muted); }

/* 상세 */
.detail { position: absolute; inset: 0; z-index: 10; overflow-y: auto; background: var(--c-card); padding: 16px 20px 32px; animation: slide .2s var(--ease); }
@keyframes slide { from { transform: translateX(-16px); opacity: 0; } }
.back { border: 0; background: none; padding: 8px 0; font-weight: 600; color: var(--c-accent); cursor: pointer; }
.back::before { content: "‹ "; }
.d-loc { margin: 8px 0 0; color: var(--c-muted); font-size: 13px; }
.detail h2 { margin: 2px 0 0; font-size: 22px; letter-spacing: -.02em; }
.d-price { margin: 6px 0 16px; font-size: 28px; font-weight: 800; color: var(--c-primary); letter-spacing: -.02em; }
.d-info { display: grid; gap: 12px; margin: 0 0 20px; }
.d-sec { padding: 14px 16px; border-radius: var(--r-md); background: var(--c-bg); font-size: 14px; }
.d-sec h3 { margin: 0 0 10px; font-size: 14px; }
.d-sec h3 em { font-style: normal; font-size: 11px; font-weight: 600; margin-left: 6px; padding: 2px 6px; border-radius: var(--r-pill); background: var(--c-accent-50); color: var(--c-accent); }
.d-sec dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.d-sec dt { color: var(--c-muted); }
.d-sec dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.same { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.same li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--c-card); }
.same span { color: var(--c-text-2); font-size: 13px; }
.same b { color: var(--c-primary); white-space: nowrap; }
.calc { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--c-line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.calc h3 { margin: 0; font-size: 17px; }
.calc input[type=range] { width: 100%; accent-color: var(--c-primary); height: 28px; }
.calc .field b { color: var(--c-primary); }
.c-out { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px; border-radius: var(--r-md); background: var(--c-primary-50); }
.c-out span { font-weight: 600; color: var(--c-text-2); }
.c-out b { font-size: 24px; font-weight: 800; color: var(--c-primary); }
.note { margin: 0; font-size: 12px; color: var(--c-muted); }

/* 지도 말풍선(동별) */
.bubble { transform: translate(-50%, -100%); display: inline-grid; justify-items: center; white-space: nowrap; cursor: pointer; }
.bubble .b { padding: 4px 10px 5px; border-radius: 10px; background: var(--c-primary); color: var(--c-on); font-weight: 800; font-size: 14px; box-shadow: var(--sh-2); line-height: 1.2; text-align: center; transition: background-color .15s var(--ease), transform .15s var(--ease); }
.bubble .b small { display: block; font-size: 11px; font-weight: 600; opacity: .85; }
.bubble::after { content: ""; width: 10px; height: 10px; margin-top: -6px; background: var(--c-primary); transform: rotate(45deg); }
.bubble.on .b, .bubble.on::after { background: var(--c-accent); }
.bubble.on .b { transform: scale(1.08); }
.leaflet-div-icon { background: none; border: 0; }

/* 하단 탭(모바일) */
.tabbar { display: none; }

@media (max-width: 900px) {
  .topnav { display: none; }
  .shell { display: flex; flex-direction: column; height: auto; }
  .mapwrap { order: -1; height: 42vh; min-height: 280px; }
  .panel { overflow: visible; border-right: 0; padding-bottom: 88px; }
  .search { top: var(--bar-h); }
  .detail { position: fixed; inset: var(--bar-h) 0 0; z-index: 1100; padding-bottom: 96px; }
  .tabbar { display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 1200; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--c-card); border-top: 1px solid var(--c-line); }
  .tabbar a, .tabbar span { display: grid; justify-items: center; align-content: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--c-muted); text-decoration: none; }
  .tabbar a[aria-current] { color: var(--c-primary); }
  .tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar span { opacity: .5; }
}
@media (max-width: 420px) {
  .row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .row .btn { grid-column: 1 / -1; }
  .summary b { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
