/* half — iOS 앱 스타일 */
:root {
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --label: #000000;
  --secondary: #8A8A8E;
  --tertiary: #C5C5C7;
  --separator: rgba(60, 60, 67, 0.12);
  --blue: #007AFF;
  --green: #34C759;
  --orange: #FF9500;
  --fill: rgba(120, 120, 128, 0.12);
  --tabbar-bg: rgba(249, 249, 249, 0.94);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1C1C1E;
    --label: #FFFFFF;
    --secondary: #8D8D93;
    --tertiary: #48484A;
    --separator: rgba(84, 84, 88, 0.5);
    --blue: #0A84FF;
    --green: #30D158;
    --orange: #FF9F0A;
    --fill: rgba(120, 120, 128, 0.24);
    --tabbar-bg: rgba(22, 22, 24, 0.94);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
/* 어떤 경우에도 가로로 잘리거나 밀리지 않게 한다 */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg { max-width: 100%; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro KR", "SF Pro Text", "Apple SD Gothic Neo",
    Pretendard, "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--label);
  -webkit-font-smoothing: antialiased;
}

/* 데스크톱: 아이폰 프레임 */
.phone { height: 100%; }
.screen { height: 100%; position: relative; overflow: hidden; display: flex; flex-direction: column; }
@media (min-width: 520px) {
  body:not(.raw) {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: linear-gradient(160deg, #d7e3f2 0%, #eef1f5 60%, #dfe7ef 100%);
  }
  @media (prefers-color-scheme: dark) {
    body:not(.raw) { background: linear-gradient(160deg, #101418 0%, #1a2027 60%, #12161b 100%); }
  }
  body:not(.raw) .phone {
    width: 393px; height: min(815px, 96vh); background: #0b0b0c; border-radius: 54px;
    padding: 10px; box-shadow: 0 30px 80px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.25);
    position: relative;
  }
  body:not(.raw) .phone::after { /* 다이나믹 아일랜드 */
    content: ""; position: absolute; top: 22px; left: 50%; transform: translateX(-50%);
    width: 118px; height: 34px; background: #000; border-radius: 20px; z-index: 50;
  }
  body:not(.raw) .screen { border-radius: 44px; background: var(--bg); }
}
/* 스토어 스크린샷용 전체화면 모드 (?raw) */
body.raw { background: var(--bg); }
body.raw .phone { width: 100%; height: 100vh; padding: 0; box-shadow: none; }
body.raw .nav-header { padding-top: 24px; }

/* 뷰 & 스크롤 */
.view {
  display: none; flex: 1; overflow-y: auto; padding: 16px 16px 96px;
  scrollbar-width: none;
}
.view::-webkit-scrollbar { display: none; }
.view.active { display: block; }
#view-map { padding: 0 0 0; }
#view-map .nav-header {
  position: absolute; z-index: 1000; left: 0; right: 0; padding: 14px 16px 10px;
  background: var(--tabbar-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
#map { position: absolute; inset: 0; z-index: 1; }

/* 헤더 */
.nav-header { padding: 44px 4px 14px; }
.nav-header.compact { padding: 44px 4px 10px; }
.large-title { font-size: 34px; font-weight: 700; letter-spacing: 0.2px; }
.title { font-size: 17px; font-weight: 600; text-align: center; letter-spacing: -0.4px; }
.subtitle { color: var(--secondary); font-size: 15px; margin-top: 2px; letter-spacing: -0.2px; }

/* 지역 선택 드롭다운 */
.region-picker {
  position: relative; display: flex; align-items: center;
  background: var(--card); border-radius: 12px; padding: 0 12px;
  margin-bottom: 18px; height: 48px;
}
.region-picker .rp-icon { width: 18px; height: 18px; fill: var(--blue); flex-shrink: 0; }
.region-picker .rp-caret { width: 20px; height: 20px; fill: var(--secondary); flex-shrink: 0; }
.region-picker select {
  flex: 1; min-width: 0; border: none; background: transparent; outline: none;
  font: inherit; font-size: 16px; font-weight: 600; letter-spacing: -0.3px;
  color: var(--label); padding: 0 8px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.region-picker::after {
  content: ""; position: absolute; inset: 0; border-radius: 12px; pointer-events: none;
}
.region-picker:active { opacity: .75; }

.icon-circle {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--blue); display: flex; align-items: center; justify-content: center;
}
.icon-circle svg { width: 18px; height: 18px; fill: #fff; }
.icon-circle.gray { background: var(--fill); }
.icon-circle.gray svg { fill: var(--secondary); }
.btn-filled {
  width: 100%; height: 46px; border: none; border-radius: 12px;
  background: var(--blue); color: #fff; font: inherit; font-size: 16px; font-weight: 600;
  letter-spacing: -0.3px; cursor: pointer;
}
.btn-filled:active { opacity: .75; }
.btn-filled:disabled { opacity: .5; }

/* 섹션 & 인셋 그룹 */
.section-header {
  font-size: 13px; color: var(--secondary); text-transform: none;
  padding: 0 16px 7px; letter-spacing: -0.1px;
}
.inset-group { background: var(--card); border-radius: var(--radius); overflow: hidden; margin-bottom: 22px; }

/* 업소 리스트 */
.shop-row {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; cursor: pointer;
}
.shop-row::after {
  content: ""; position: absolute; left: 66px; right: 0; bottom: 0;
  height: 0.5px; background: var(--separator);
}
.shop-row:last-child::after { display: none; }
.shop-row:active { background: var(--fill); }
.shop-badge {
  width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; letter-spacing: -0.5px;
}
.shop-info { flex: 1; min-width: 0; }
.shop-name {
  font-size: 16px; font-weight: 500; letter-spacing: -0.3px;
  /* 상호는 잘라내지 않고 최대 2줄까지 보여준다 */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: keep-all; line-height: 1.3;
}
.shop-meta {
  font-size: 13px; color: var(--secondary); margin-top: 1px;
  display: flex; align-items: center; gap: 3px; min-width: 0;
}
/* flex 컨테이너에서는 ellipsis 가 자식에게만 걸린다 */
.shop-meta > .meta-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-meta .check {
  width: 12px; height: 12px; fill: var(--green); flex-shrink: 0;
}
.shop-right { text-align: right; flex-shrink: 0; }
.shop-dist { font-size: 14px; color: var(--secondary); }
.call-btn {
  border: none; background: transparent; cursor: pointer; flex-shrink: 0;
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; text-decoration: none;
}
.call-btn svg { width: 20px; height: 20px; fill: var(--blue); }
.call-btn:active { background: var(--fill); }

/* CTA */
.cta-card { display: flex; gap: 12px; align-items: center; padding: 14px 16px; }
.cta-card strong { font-size: 15px; letter-spacing: -0.3px; }
.cta-card p { font-size: 13px; color: var(--secondary); margin-top: 2px; }
.btn-tinted {
  margin-left: auto; flex-shrink: 0; border: none;
  background: rgba(0, 122, 255, 0.12); color: var(--blue);
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 14px; border-radius: 16px; cursor: pointer;
}
.btn-tinted:active { opacity: .7; }

.footnote { font-size: 11px; color: var(--secondary); padding: 0 16px 20px; line-height: 1.5; }

/* 세그먼트 컨트롤 */
.segmented {
  display: flex; background: var(--fill); border-radius: 9px; padding: 2px; margin-bottom: 18px;
}
.seg {
  flex: 1; border: none; background: transparent; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--label); padding: 7px 0; border-radius: 7px; cursor: pointer;
}
.seg.active { background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.segmented.small { margin-top: -8px; }
.segmented.small .seg { font-size: 13px; padding: 5px 0; }

/* 폼 */
.form-group { margin-bottom: 12px; }
.form-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 14px; border-bottom: 0.5px solid var(--separator); font-size: 15px;
}
.form-row:last-child { border-bottom: none; }
.amount-wrap { display: flex; align-items: baseline; gap: 5px; }
.amount-wrap input {
  border: none; background: transparent; text-align: right; font: inherit;
  font-size: 17px; font-weight: 700; color: var(--blue); width: 130px; outline: none;
}
.amount-wrap em { font-style: normal; color: var(--secondary); font-size: 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; padding: 0 2px; }
.chips button {
  border: none; background: var(--card); color: var(--label); font: inherit; font-size: 13px;
  padding: 7px 12px; border-radius: 16px; cursor: pointer;
}
.chips button:active { background: var(--fill); }

/* 계산 결과 */
.result-group { padding: 4px 0; }
.result-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; font-size: 15px; border-bottom: 0.5px solid var(--separator);
}
.result-row:last-of-type { border-bottom: none; }
.result-row strong { font-size: 16px; font-weight: 700; }
.result-row.highlight strong { color: var(--blue); font-size: 18px; }
.result-row.highlight em { font-style: normal; font-size: 12px; color: var(--secondary); }
.result-row.saving { background: rgba(52, 199, 89, 0.1); }
.result-row.saving strong { color: var(--green); font-size: 18px; }
.result-note { font-size: 11px; color: var(--secondary); padding: 10px 14px; line-height: 1.5; }

/* 지도 오버레이 */
.map-legend {
  position: absolute; left: 14px; bottom: 108px; z-index: 1100;
  background: var(--card); border-radius: 10px; padding: 8px 12px;
  display: flex; gap: 10px; font-size: 11px; color: var(--secondary);
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.map-legend span { display: flex; align-items: center; gap: 4px; }
.map-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* 핀 마커 */
.pin-wrap { background: none !important; border: none !important; }
.pin {
  position: relative; width: 32px; height: 42px;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.3));
}
.pin svg { width: 32px; height: 42px; display: block; }
.pin .pin-label {
  position: absolute; top: 5px; left: 50%; transform: translateX(-50%);
  width: 20px; height: 20px; border-radius: 50%; overflow: hidden;
  background: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #333;
}
.pin .pin-label img { width: 100%; height: 100%; object-fit: cover; }
.pin.lead { opacity: .65; transform: scale(.85); }

/* 지도 하단 카드 */
#map-card {
  position: absolute; left: 12px; right: 12px; bottom: 104px; z-index: 1150;
  background: var(--card); border-radius: 16px; padding: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.22);
}
.mc-head { display: flex; align-items: center; gap: 10px; }
#mc-badge .shop-badge { width: 42px; height: 42px; }
.mc-info { flex: 1; min-width: 0; }
.mc-name { font-size: 16px; font-weight: 600; letter-spacing: -0.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-meta { font-size: 12px; color: var(--secondary); margin-top: 2px; display: flex; align-items: center; gap: 3px; }
.mc-meta .check { width: 12px; height: 12px; fill: var(--green); }
.mc-close {
  border: none; background: var(--fill); color: var(--secondary);
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; align-self: flex-start;
}
.mc-addr { font-size: 13px; color: var(--secondary); margin: 10px 2px; }
.mc-actions { display: flex; gap: 8px; }
.mc-actions .btn-filled { flex: 1; height: 42px; font-size: 15px; }
.mc-actions .btn-tinted {
  height: 42px; padding: 0 18px; border-radius: 12px; font-size: 15px;
  display: flex; align-items: center; text-decoration: none;
}

/* 상세정보 */
.detail-header { padding: 48px 4px 6px; }
#detail-back {
  border: none; background: transparent; color: var(--blue); font: inherit;
  font-size: 17px; display: flex; align-items: center; gap: 2px; cursor: pointer; padding: 4px 4px;
}
.detail-hero { text-align: center; padding: 8px 16px 20px; }
.detail-hero .shop-badge { width: 64px; height: 64px; border-radius: 15px; margin: 0 auto 12px; font-size: 18px; }
.detail-hero .shop-badge.img { background: #fff; }
.detail-hero h2 { font-size: 21px; font-weight: 700; letter-spacing: -0.4px; }
.d-chips { display: flex; justify-content: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.d-chip {
  display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600;
  color: var(--green); background: rgba(52, 199, 89, 0.12);
  padding: 5px 10px; border-radius: 13px;
}
.d-chip .check { width: 12px; height: 12px; fill: var(--green); }
.d-chip.pending { color: var(--secondary); background: var(--fill); }
.info-row {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 12px 16px; font-size: 15px; position: relative;
}
.info-row::after {
  content: ""; position: absolute; left: 16px; right: 0; bottom: 0;
  height: 0.5px; background: var(--separator);
}
.info-row:last-child::after { display: none; }
.info-row span { color: var(--secondary); flex-shrink: 0; }
.info-row strong { font-weight: 500; text-align: right; word-break: break-all; }
.detail-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.detail-actions .btn-filled,
.detail-actions .btn-tinted {
  display: flex; align-items: center; justify-content: center;
  text-decoration: none; height: 46px; border-radius: 12px; font-size: 16px; font-weight: 600;
}
.btn-plain {
  display: block; width: 100%; border: none; background: transparent;
  color: var(--blue); font: inherit; font-size: 15px; padding: 12px 0; cursor: pointer;
}
.btn-plain.warn { color: #FF3B30; }

/* 액션 시트 */
#action-sheet {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 1600;
  transform: translateY(110%); transition: transform .3s cubic-bezier(.32,.72,.35,1);
}
#action-sheet.show { transform: translateY(0); }
.as-group {
  background: var(--card); border-radius: 14px; overflow: hidden; margin-bottom: 8px;
}
.as-title {
  padding: 12px 16px; text-align: center; font-size: 13px; color: var(--secondary);
  border-bottom: 0.5px solid var(--separator);
}
.as-btn {
  display: block; width: 100%; border: none; background: var(--card);
  font: inherit; font-size: 18px; color: var(--blue); padding: 15px 0; cursor: pointer;
  border-bottom: 0.5px solid var(--separator);
}
.as-btn:last-child { border-bottom: none; }
.as-btn:active { background: var(--fill); }
.as-btn.as-warn { color: #FF3B30; }
.as-btn.as-cancel { border-radius: 14px; font-weight: 600; }

/* 등록 시트 폼 요소 */
.selects-row { gap: 10px; }
.selects-row select {
  flex: 1; border: none; background: var(--fill); font: inherit; font-size: 15px;
  color: var(--label); padding: 9px 10px; border-radius: 9px; outline: none;
  -webkit-appearance: none; appearance: none;
}
.search-row svg { width: 17px; height: 17px; fill: var(--tertiary); flex-shrink: 0; }
.search-row input {
  border: none; background: transparent; font: inherit; font-size: 15px;
  flex: 1; margin-left: 8px; outline: none; color: var(--label); text-align: left !important;
}
/* 명부 검색 결과 행 — 계산기의 .result-row 와 이름이 겹쳐 레이아웃이 깨져서 분리했다 */
.registry-row { padding: 11px 16px; cursor: pointer; position: relative; }
.registry-row::after {
  content: ""; position: absolute; left: 16px; right: 0; bottom: 0;
  height: 0.5px; background: var(--separator);
}
.registry-row:last-child::after { display: none; }
.registry-row:active { background: var(--fill); }
.result-name { font-size: 15px; font-weight: 500; }
.result-addr { font-size: 12px; color: var(--secondary); margin-top: 2px; }
.selected-card { padding: 14px 16px; }
.selected-name { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.selected-name .check { width: 15px; height: 15px; fill: var(--green); }
.selected-addr { font-size: 13px; color: var(--secondary); margin-top: 4px; }
.selected-reg { font-size: 12px; color: var(--green); margin-top: 6px; font-weight: 500; }
.shop-badge.img { background: #fff; border: 0.5px solid var(--separator); }
.shop-badge.img img { width: 70%; height: 70%; object-fit: contain; border-radius: 6px; }

/* 중개사 등록 시트 */
#sheet-backdrop {
  position: absolute; inset: 0; z-index: 1500;
  background: rgba(0,0,0,.4); opacity: 0; transition: opacity .25s;
}
#sheet-backdrop.show { opacity: 1; }
#broker-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1600;
  background: var(--bg); border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .3s cubic-bezier(.32,.72,.35,1);
  box-shadow: 0 -8px 40px rgba(0,0,0,.2);
  /* 검색 결과가 많아도 화면 밖으로 벌어지지 않게 한다 */
  max-height: 88%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#broker-sheet::-webkit-scrollbar { display: none; }
/* 손잡이는 스크롤해도 상단에 고정 */
#broker-sheet .grabber {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg); padding: 4px 0 10px; margin: 0 auto 12px;
  box-sizing: content-box;
}
#broker-sheet.show { transform: translateY(0); }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--tertiary); margin: 4px auto 16px; }
/* sticky grabber 가 배경을 덮도록 좌우로 넓힌다 */
#broker-sheet .grabber::before {
  /* 시트 전체 폭을 덮어야 스크롤되는 본문이 손잡이 좌우로 비쳐 지나가지 않는다 */
  content: ""; position: absolute; left: -50vw; right: -50vw; top: 0; bottom: 0;
  background: var(--bg); z-index: -1;
}
#broker-sheet h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.4px; }
.sheet-sub { font-size: 13px; color: var(--secondary); margin: 6px 0 16px; line-height: 1.45; }
#broker-sheet .form-row input {
  border: none; background: transparent; font: inherit; font-size: 15px;
  text-align: right; flex: 1; margin-left: 16px; outline: none; color: var(--label);
}
#broker-sheet .form-row input::placeholder { color: var(--tertiary); }
#broker-sheet .form-row span em { font-style: normal; color: #FF3B30; margin-left: 2px; }
.footnote.center { text-align: center; padding: 12px 0 0; }
/* 접수 완료 화면 */
.done-box { text-align: center; padding: 12px 8px 24px; }
.done-icon {
  width: 62px; height: 62px; border-radius: 50%; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
}
.done-icon svg { width: 32px; height: 32px; fill: #fff; }
.done-icon.ok { background: var(--green); }
.done-icon.wait { background: var(--orange); }
.done-box strong { display: block; font-size: 18px; font-weight: 700; letter-spacing: -0.4px; }
.done-box p { font-size: 14px; color: var(--secondary); margin-top: 8px; line-height: 1.6; }

.verify-hint { font-size: 12px; padding: 0 4px 10px; margin-top: -12px; }
.verify-hint.ok { color: var(--green); }
.verify-hint.warn { color: var(--orange); }

/* 탭바 */
.tabbar {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 1200;
  display: flex; justify-content: space-around; padding: 8px 10px calc(14px + env(safe-area-inset-bottom));
  background: var(--tabbar-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--separator);
}
.tab {
  border: none; background: transparent; color: var(--secondary); font: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 500; cursor: pointer; width: 64px;
}
.tab svg { width: 26px; height: 26px; fill: currentColor; }
.tab.active { color: var(--blue); }

/* 스켈레톤/빈 상태 */
.empty { padding: 28px 16px; text-align: center; color: var(--secondary); font-size: 14px; }

/* 토스트 */
#toast {
  position: absolute; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: rgba(30,30,32,.92); color: #fff; font-size: 14px;
  padding: 10px 18px; border-radius: 20px; opacity: 0; transition: opacity .25s; pointer-events: none;
  z-index: 2000;
  /* 긴 안내 문구가 화면 밖으로 잘리지 않도록 줄바꿈을 허용한다 */
  max-width: calc(100% - 32px); text-align: center; line-height: 1.45;
}
#toast.show { opacity: 1; }
