/* 통근권 부동산 — 라이트/다크 양쪽에서 읽히는 단일 팔레트.
   색은 두 축을 쓴다: 통근시간(파랑 계열)과 시세(주황 계열). 같은 색조를 두 축에
   쓰면 지도에서 구분이 안 된다. */

:root {
  --bg:        #f5f6f8;
  --surface:   #ffffff;
  --surface-2: #f0f2f5;
  --line:      #dfe3e8;
  --line-soft: #e9ecf0;
  --ink:       #16191d;
  --ink-2:     #4a525c;
  --ink-3:     #7b858f;
  --accent:    #1a56b0;
  --accent-ink:#ffffff;
  --warn-bg:   #fff4e2;  --warn-line: #e8b563;  --warn-ink: #7a4b06;
  --info-bg:   #e8f0fb;  --info-line: #9dbdea;  --info-ink: #17407e;
  --err-bg:    #fdeceb;  --err-line:  #e9a9a3;  --err-ink:  #8c2a20;
  --origin:    #b3540d;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,19,23,.06), 0 6px 20px rgba(16,19,23,.08);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "IBM Plex Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101216; --surface: #171a1f; --surface-2: #1e222a;
    --line: #2b313a; --line-soft: #242932;
    --ink: #eef1f5; --ink-2: #b3bcc7; --ink-3: #7f8996;
    --accent: #5b96ee; --accent-ink: #0b1220;
    --warn-bg: #2e2413; --warn-line: #7a5a1f; --warn-ink: #f0c479;
    --info-bg: #142234; --info-line: #2f5688; --info-ink: #9cc2f4;
    --err-bg: #2f1917; --err-line: #7a3a33; --err-ink: #f0a79e;
    --origin: #f0a35c;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 26px rgba(0,0,0,.45);
  }
}
:root[data-theme="dark"] {
  --bg: #101216; --surface: #171a1f; --surface-2: #1e222a;
  --line: #2b313a; --line-soft: #242932;
  --ink: #eef1f5; --ink-2: #b3bcc7; --ink-3: #7f8996;
  --accent: #5b96ee; --accent-ink: #0b1220;
  --warn-bg: #2e2413; --warn-line: #7a5a1f; --warn-ink: #f0c479;
  --info-bg: #142234; --info-line: #2f5688; --info-ink: #9cc2f4;
  --err-bg: #2f1917; --err-line: #7a3a33; --err-ink: #f0a79e;
  --origin: #f0a35c;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans); color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.55;
}
.mono { font-family: var(--mono); font-size: .78em; letter-spacing: -.01em; }

.app { display: grid; grid-template-columns: 340px 1fr; height: 100vh; }

/* ───────────── 좌측 패널 ───────────── */
.panel {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 20px 18px 0; overflow-y: auto; display: flex; flex-direction: column; gap: 18px;
}
.masthead .eyebrow {
  margin: 0 0 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent);
}
.masthead h1 { margin: 0 0 6px; font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.masthead .lede { margin: 0; font-size: 12.5px; color: var(--ink-2); }

.step { display: flex; flex-direction: column; gap: 9px; }
.step-title {
  margin: 0; font-size: 12px; font-weight: 600; color: var(--ink-2);
  display: flex; align-items: center; gap: 7px;
}
.step-title .num {
  display: inline-grid; place-items: center; width: 17px; height: 17px;
  border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  font-size: 10px; font-weight: 700; font-family: var(--mono);
}
.step-title .opt { font-weight: 400; color: var(--ink-3); font-size: 11px; }

.search-wrap { position: relative; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
input[type="text"], input[type="number"] {
  width: 100%; font: inherit; font-size: 13px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px;
}
.search-wrap input { padding-left: 30px; }
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.results {
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  max-height: 210px; overflow-y: auto; box-shadow: var(--shadow);
}
.results button {
  display: block; width: 100%; text-align: left; border: 0; background: none;
  padding: 7px 10px; font: inherit; font-size: 12.5px; color: var(--ink); cursor: pointer;
  border-bottom: 1px solid var(--line-soft);
}
.results button:last-child { border-bottom: 0; }
.results button:hover, .results button:focus-visible { background: var(--surface-2); }
.results .line { color: var(--ink-3); font-size: 11px; margin-left: 6px; }
/* 통합 검색 결과 — 역·장소·주소 그룹, 이름 + 부가정보(주소) + 태그(노선·분류) */
.results button { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.results .main { display: flex; flex-direction: column; min-width: 0; }
.results .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .sub {
  font-size: 11px; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.results .line-tag {
  font-size: 10.5px; color: var(--ink-3); font-family: var(--mono); white-space: nowrap;
}
.results .group-title {
  font-size: 10px; font-weight: 600; letter-spacing: .04em; color: var(--ink-3);
  padding: 7px 10px 3px;
}
.results .source-note {
  font-size: 11px; color: var(--ink-3);
  border-top: 1px solid var(--line-soft); padding: 7px 10px;
}
.results .empty { padding: 10px; color: var(--ink-3); font-size: 12.5px; }

.hint { margin: 0; font-size: 11.5px; color: var(--ink-3); }

.origin {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
}
.origin .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--origin); flex: none; }
.origin-text { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.origin-text b { font-size: 13px; }
.origin-text .mono { color: var(--ink-3); }
.origin .repick {
  margin-left: auto; flex: none; font: inherit; font-size: 11px; cursor: pointer;
  padding: 4px 8px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface); color: var(--ink-2); white-space: nowrap;
}
.origin .repick:hover { border-color: var(--accent); color: var(--ink); }

.time-row { display: flex; align-items: center; gap: 12px; }
.time-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.time-out { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.time-out b { font-size: 16px; color: var(--ink); font-family: var(--mono); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: 12px; padding: 5px 10px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2);
}
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
/* 경계 데이터가 없는 단위는 누를 수 없다. 왜 안 되는지는 title 과 hint 가 말한다. */
.chip:disabled { opacity: .38; cursor: not-allowed; }
.chip:disabled:hover { border-color: var(--line); color: var(--ink-2); }

.budget { display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 10px; }
.budget label { font-size: 12px; color: var(--ink-2); }
.money { display: flex; align-items: center; gap: 6px; }
.money span { font-size: 11.5px; color: var(--ink-3); flex: none; }

.btn-primary {
  position: relative; font: inherit; font-size: 14px; font-weight: 600;
  padding: 11px; border: 0; border-radius: 9px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
}
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary .l-busy, .btn-primary .spinner { display: none; }
.btn-primary.busy .l-idle { display: none; }
.btn-primary.busy .l-busy { display: inline; }
.btn-primary.busy .spinner { display: inline-block; }

.spinner {
  width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 6px;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.banners { display: flex; flex-direction: column; gap: 7px; }
.banner {
  display: flex; gap: 8px; padding: 9px 10px; border-radius: 8px;
  font-size: 11.5px; line-height: 1.5; border: 1px solid;
}
.banner .i { flex: none; }
.banner.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.banner.info { background: var(--info-bg); border-color: var(--info-line); color: var(--info-ink); }
.banner.err  { background: var(--err-bg);  border-color: var(--err-line);  color: var(--err-ink); }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 9px 8px; text-align: center;
}
.stat .n { font-family: var(--mono); font-size: 18px; font-weight: 600; }
.stat .n small { font-size: 10px; font-weight: 400; color: var(--ink-3); }
.stat .l { font-size: 10.5px; color: var(--ink-3); margin-top: 1px; }

.region-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.region-list li button {
  width: 100%; text-align: left; font: inherit; cursor: pointer;
  border: 1px solid var(--line-soft); border-radius: 8px; background: var(--surface-2);
  padding: 8px 10px; display: grid; grid-template-columns: 42px 1fr auto; gap: 9px; align-items: center;
}
.region-list li button:hover { border-color: var(--accent); }
.region-list .rmin { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--accent); }
.region-list .rname { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.region-list .rprice { font-family: var(--mono); font-size: 12px; color: var(--ink-2); text-align: right; }
.region-list .thin { opacity: .5; }

.foot {
  margin-top: auto; padding: 12px 0 14px; border-top: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 3px; color: var(--ink-3);
}

/* ───────────── 지도 ───────────── */
.map-wrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--surface-2); }

.toolbar {
  position: absolute; z-index: 600; top: 12px; right: 12px;
  display: flex; flex-direction: column; gap: 7px; align-items: flex-end;
  transition: right .18s ease;
}
/* 상세 패널이 열리면 툴바가 가려진다. 패널 폭(380px)만큼 비켜준다. */
.map-wrap.detail-open .toolbar { right: 394px; }
.seg {
  display: flex; background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; box-shadow: var(--shadow); overflow: hidden;
}
.seg button {
  font: inherit; font-size: 12.5px; padding: 7px 13px; border: 0; cursor: pointer;
  background: none; color: var(--ink-2); border-right: 1px solid var(--line-soft);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-2); color: var(--ink); }
.seg button.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.crosshair {
  position: absolute; z-index: 600; top: 12px; left: 12px; margin: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 11px; font-size: 12px; color: var(--ink-2); box-shadow: var(--shadow);
}
.crosshair[hidden] { display: none; }

.legend {
  position: absolute; z-index: 600; left: 12px; bottom: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; box-shadow: var(--shadow); min-width: 190px;
}
.legend-title { font-size: 11px; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.ramp { display: flex; gap: 2px; }
.ramp div { flex: 1; text-align: center; }
.ramp .sw { height: 10px; border-radius: 2px; }
.ramp .lb { font-family: var(--mono); font-size: 9.5px; color: var(--ink-3); margin-top: 3px; }
.legend-foot {
  margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line-soft);
  font-size: 10.5px; color: var(--ink-3); display: flex; align-items: center; gap: 5px;
}
.sw-origin, .sw-station { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.sw-origin { background: var(--origin); }
.sw-station { background: #3987e5; margin-left: 8px; }

.overlay { position: absolute; inset: 0; z-index: 700; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 65%, transparent); }
.overlay[hidden] { display: none; }
.overlay-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 18px; box-shadow: var(--shadow); font-size: 13px;
}

/* ───────────── 상세 패널 ───────────── */
.detail {
  position: absolute; z-index: 650; top: 0; right: 0; bottom: 0; width: 380px;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -8px 0 26px rgba(16,19,23,.10);
  display: flex; flex-direction: column; padding: 18px 18px 0;
}
.detail[hidden] { display: none; }
.detail-close {
  position: absolute; top: 10px; right: 12px; width: 26px; height: 26px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2);
  color: var(--ink-2); font-size: 16px; line-height: 1; cursor: pointer;
}
.detail-head h2 { margin: 0 0 3px; font-size: 17px; letter-spacing: -.02em; padding-right: 30px; }
.d-sub { margin: 0 0 12px; font-size: 12px; color: var(--ink-3); }

.d-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 11px; }
.d-stats .cell {
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 8px; text-align: center;
}
.d-stats .cell .v { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.d-stats .cell .k { font-size: 10px; color: var(--ink-3); margin-top: 1px; }

.d-notice {
  font-size: 11.5px; line-height: 1.5; padding: 8px 10px; border-radius: 8px;
  background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink);
  margin-bottom: 11px;
}
.d-notice[hidden] { display: none; }

.btn-deeplink {
  display: block; text-align: center; text-decoration: none; font-size: 13px; font-weight: 600;
  padding: 10px; border-radius: 9px; background: #03c75a; color: #fff; margin-bottom: 13px;
}
.btn-deeplink:hover { filter: brightness(1.06); }

.d-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 9px; }
.d-tab {
  font: inherit; font-size: 12.5px; padding: 7px 11px; border: 0; background: none;
  color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.d-tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

.d-body { overflow-y: auto; flex: 1; padding-bottom: 16px; }
.d-body[hidden] { display: none; }

.deal-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px;
  padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px;
}
.deal-row .d1 { font-weight: 500; }
.deal-row .d2 { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
.deal-row .p1 { font-family: var(--mono); font-size: 13px; font-weight: 600; text-align: right; }
.deal-row .p2 { font-family: var(--mono); font-size: 11px; color: var(--ink-3); text-align: right; }
.deal-row .tag {
  display: inline-block; font-size: 9.5px; padding: 1px 5px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-3); margin-left: 5px;
}
.empty { padding: 26px 8px; text-align: center; color: var(--ink-3); font-size: 12.5px; }

/* 지도 툴팁 */
.rgn-tip {
  font-family: var(--sans); font-size: 12px; line-height: 1.5;
}
.rgn-tip b { display: block; font-size: 12.5px; }
.rgn-tip .m { font-family: var(--mono); font-size: 11px; color: #555; }

/* 시세 말풍선 핀 (네이버 부동산 참고). map.js 가 지역 중심점에 DOM 마커로 얹는다.
   .pin-wrap 의 translate 가 꼬리 끝을 좌표에 맞춘다 — 말풍선 크기는 내용마다 다르다. */
.pin-wrap {
  position: absolute; transform: translate(-50%, calc(-100% - 7px));
  cursor: pointer; z-index: 500;
}
.pin-wrap:hover { z-index: 640; }
.price-pin {
  position: relative; display: flex; flex-direction: column; align-items: center;
  background: #6a3fd6; color: #fff; border-radius: 7px; padding: 3px 9px 4px;
  box-shadow: 0 1px 1px rgba(20, 10, 50, .25), 0 3px 8px rgba(20, 10, 50, .3);
  font-family: var(--sans); line-height: 1.3; white-space: nowrap;
  transition: transform .08s ease;
}
.pin-wrap:hover .price-pin { transform: scale(1.08); background: #5730b8; }
.price-pin::after {                     /* 말풍선 꼬리 */
  content: ""; position: absolute; left: 50%; bottom: -6px;
  transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #6a3fd6; border-bottom: 0;
}
.pin-wrap:hover .price-pin::after { border-top-color: #5730b8; }
.price-pin .pp-name { font-size: 10px; opacity: .82; }
.price-pin .pp-price { font-size: 12.5px; font-weight: 700; font-family: var(--mono); }

/* 네이버 지도에는 Leaflet 툴팁이 없다 — 커서를 따라다니는 툴팁 하나로 대신한다 (map.js) */
.map-tip {
  position: absolute; z-index: 800; pointer-events: none;
  transform: translate(12px, 14px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 9px; box-shadow: var(--shadow);
  font-family: var(--sans); font-size: 12px; color: var(--ink); white-space: nowrap;
}
.map-tip[hidden] { display: none; }
.map-tip .rgn-tip .m { color: var(--ink-3); }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .panel { max-height: 46vh; }
  .detail { width: 100%; }
  .toolbar { position: static; padding: 8px; align-items: stretch; }
  .seg { overflow-x: auto; }
}
