/* 붕세권: 화이트 베이스의 심플한 디자인
   - 바탕은 흰색, 글자는 거의 검정, 강조는 붕어빵 황금색 하나만
   - 주요 버튼은 검정, 황금색은 마커·배지·포인트에만 */
:root {
  --bg: #ffffff;
  --surface: #f5f6f7;
  --line: #ebedf0;
  --ink: #111214;
  --sub: #5b5f66;
  --muted: #8e939b;
  --accent: #ffa51f;        /* 붕어빵 황금색 */
  --accent-soft: #fff4e0;
  --accent-text: #b35f00;   /* 흰 바탕 위 강조 글자 */
  --danger: #e5484d;
  --kakao: #fee500;
  --naver: #03c75a;
  --me: #2f7bff;
  --radius: 16px;
  --shadow: 0 2px 14px rgba(17, 18, 20, 0.08);
  --shadow-lg: 0 8px 28px rgba(17, 18, 20, 0.14);
  --top: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  color: var(--ink);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { cursor: not-allowed; }
code { background: var(--surface); padding: 1px 6px; border-radius: 6px; font-size: 0.9em; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- 상단 바 ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20; height: var(--top);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand {
  margin: 0; display: flex; align-items: center; gap: 6px;
  font-size: 1.2rem; font-weight: 800; letter-spacing: -0.03em;
}
.brand img { width: 30px; height: 30px; }
.brand a { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 6px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 0.82rem; font-weight: 600; color: var(--sub); background: var(--bg);
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip__check {
  width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid #c5c9cf;
  display: grid; place-items: center;
}
.chip:has(input:checked) { border-color: var(--ink); color: var(--ink); }
.chip:has(input:checked) .chip__check { background: var(--ink); border-color: var(--ink); }
.chip:has(input:checked) .chip__check::after {
  content: ''; width: 6px; height: 3px; border: 2px solid #fff; border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px);
}
.chip:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }

.topbar__right { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 10px; background: none; color: var(--ink);
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface); }

/* ---------- 메뉴(도움말) 서랍 ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(17, 18, 20, 0.35); }
.drawer {
  position: fixed; z-index: 61; top: 0; right: 0; bottom: 0; width: min(320px, 86vw);
  background: var(--bg); box-shadow: var(--shadow-lg); overflow-y: auto;
  padding: 10px 20px calc(24px + var(--safe-b));
  display: flex; flex-direction: column; animation: slide 0.2s ease-out;
}
.drawer[hidden], .drawer-backdrop[hidden] { display: none; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer__head { display: flex; align-items: center; justify-content: space-between; height: 46px; }
.drawer__head .brand { font-size: 1.1rem; font-weight: 800; }
.drawer__intro { margin: 12px 0 8px; color: var(--sub); font-size: 0.9rem; line-height: 1.55; }
.drawer__links { list-style: none; margin: 8px 0 0; padding: 0; }
.drawer__links a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 0; border-bottom: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: 0.98rem;
}
.drawer__links a::after { content: '›'; color: #b8bcc2; font-size: 1.3rem; line-height: 1; }
.drawer__legal { margin-top: auto; padding-top: 24px; font-size: 0.8rem; color: var(--muted); line-height: 1.8; }
.drawer__legal a { color: var(--sub); text-decoration: none; }

.map { position: fixed; inset: var(--top) 0 0 0; }

/* ---------- 가장 가까운 집 카드 ---------- */
.nearest {
  position: fixed; z-index: 15; top: calc(var(--top) + 12px); left: 12px; right: 12px;
  max-width: 520px; margin: 0 auto; padding: 14px;
  background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.nearest__empty { margin: 0; font-size: 0.9rem; color: var(--sub); line-height: 1.45; }
.nearest__main {
  display: grid; grid-template-columns: 52px 1fr 16px; align-items: center; gap: 12px;
  width: 100%; padding: 0; border: 0; background: none; text-align: left;
}
.thumb {
  width: 52px; height: 52px; border-radius: 12px; background: var(--accent-soft);
  display: grid; place-items: center;
}
.thumb img { width: 38px; height: 38px; }
.nearest__text { display: grid; gap: 2px; min-width: 0; }
.nearest__label { font-size: 0.75rem; font-weight: 700; color: var(--accent-text); }
.nearest__name { font-size: 1.05rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nearest__meta { font-size: 0.82rem; color: var(--sub); }
.nearest__meta b { color: var(--ink); font-weight: 700; }
.chevron { width: 16px; height: 16px; color: #b8bcc2; }
.nearest .dir-btns { margin-top: 12px; }
body.add-mode .nearest, body.has-sheet .nearest { display: none; }

/* ---------- 마커 ---------- */
.pin {
  position: relative; display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0; margin-bottom: 9px;
  border: 2px solid var(--accent); border-radius: 50%; background: var(--bg);
  box-shadow: 0 3px 10px rgba(17, 18, 20, 0.22);
  transition: transform 0.15s;
}
.pin::after { /* 아래 뾰족한 꼬리 */
  content: ''; position: absolute; bottom: -8px; left: 50%;
  width: 12px; height: 12px; background: inherit;
  border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
  transform: translateX(-50%) rotate(45deg);
}
.pin img { width: 32px; height: 32px; position: relative; z-index: 1; }
.pin--stale { border-color: #c5c9cf; }
.pin--stale::after { border-color: #c5c9cf; }
.pin--stale img { filter: saturate(0.35); opacity: 0.85; }
.pin--gone { border-color: #d6d9dd; opacity: 0.75; }
.pin--gone::after { border-color: #d6d9dd; }
.pin--gone img { filter: grayscale(1); opacity: 0.6; }
.pin--selected { background: var(--accent); border-color: var(--accent); transform: scale(1.15); z-index: 2; }
.pin--selected::after { border-color: var(--accent); }

.me-dot {
  width: 18px; height: 18px; border-radius: 50%; background: var(--me);
  border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(47, 123, 255, 0.2), 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* ---------- 내 위치 버튼 / 제보 버튼 ---------- */
.controls { position: fixed; z-index: 15; right: 14px; bottom: calc(92px + var(--safe-b)); }
.round-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.fab {
  position: fixed; z-index: 15; left: 50%; transform: translateX(-50%);
  bottom: calc(22px + var(--safe-b));
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 22px 13px 16px; border: 0; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 1rem; font-weight: 700;
  box-shadow: var(--shadow-lg); white-space: nowrap;
}
.fab img { width: 28px; height: 28px; }
.fab:active { transform: translateX(-50%) scale(0.97); }
body.add-mode .fab, body.add-mode .controls, body.has-sheet .fab, body.has-sheet .controls { display: none; }

/* ---------- 핀 등록 모드 ---------- */
.crosshair {
  position: fixed; z-index: 14; left: 50%; top: calc(var(--top) + (100% - var(--top)) / 2);
  transform: translate(-50%, -100%); pointer-events: none;
}
.crosshair .pin { transform: scale(1.25); transform-origin: bottom center; animation: bob 1.2s ease-in-out infinite; }
.crosshair .pin, .crosshair .pin::after { background: var(--accent); }
@keyframes bob { 50% { translate: 0 -6px; } }

.add-bar {
  position: fixed; z-index: 16; left: 12px; right: 12px; bottom: calc(14px + var(--safe-b));
  max-width: 520px; margin: 0 auto; padding: 16px;
  background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.add-bar__hint { margin: 0 0 12px; font-size: 0.92rem; color: var(--sub); line-height: 1.45; }
.add-bar__hint b { color: var(--ink); }
.add-bar__actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
body.has-sheet .add-bar { display: none; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font-weight: 700; font-size: 0.95rem; text-decoration: none;
}
.btn:disabled { background: var(--surface); border-color: var(--surface); color: #b8bcc2; }
.btn--primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn--block { width: 100%; }
.btn--sm { min-height: 40px; font-size: 0.86rem; border-radius: 10px; }
.dir-btns, .report-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.brand-dot {
  width: 18px; height: 18px; border-radius: 5px; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 900; line-height: 1;
}
.brand-dot--kakao { background: var(--kakao); color: #191919; }
.brand-dot--naver { background: var(--naver); color: #fff; }

/* ---------- 배지 ---------- */
.badge {
  display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 6px;
  font-size: 0.76rem; font-weight: 700; white-space: nowrap;
}
.badge--fresh { background: var(--accent-soft); color: var(--accent-text); }
.badge--stale { background: var(--surface); color: var(--sub); }
.badge--gone { background: var(--surface); color: var(--muted); }

/* ---------- 하단 시트 ---------- */
.sheet {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  max-width: 560px; margin: 0 auto; max-height: 80vh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg);
  padding: 8px 20px calc(20px + var(--safe-b));
  animation: up 0.22s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
.sheet__grip { width: 36px; height: 4px; border-radius: 4px; background: #d9dce0; margin: 2px auto 10px; }
.sheet__close {
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px;
  border: 0; border-radius: 50%; background: var(--surface); color: var(--sub);
  display: grid; place-items: center;
}
.sheet__head { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; margin: 4px 40px 16px 0; }
.sheet__head .thumb { width: 56px; height: 56px; }
.sheet__head .thumb img { width: 42px; height: 42px; }
.sheet__title { margin: 0 0 4px; font-size: 1.25rem; font-weight: 800; letter-spacing: -0.03em; }
.sheet__sub-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.85rem; color: var(--sub); }
.sheet__memo {
  margin: 0 0 14px; padding: 12px 14px; background: var(--surface); border-radius: 12px;
  font-size: 0.9rem; line-height: 1.5; white-space: pre-wrap; color: var(--sub);
}
.info { margin: 0 0 16px; padding: 0; display: grid; }
.info div { display: flex; justify-content: space-between; padding: 9px 0; font-size: 0.9rem; border-bottom: 1px solid var(--line); }
.info div:last-child { border-bottom: 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; font-weight: 600; }
.hint { margin: 8px 0 0; font-size: 0.82rem; color: var(--muted); line-height: 1.45; }
.divider { height: 8px; margin: 18px -20px; background: var(--surface); }
.section-title { margin: 0 0 6px; font-size: 1rem; font-weight: 700; }
.sheet .dir-btns { margin-top: 8px; }

.logs { list-style: none; margin: 0; padding: 0; }
.log {
  display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center;
  padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem;
}
.log:last-child { border-bottom: 0; }
.log__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.log--gone .log__dot { background: #c5c9cf; }
.log--gone span:nth-child(2) { color: var(--sub); }
.log time { color: var(--muted); font-size: 0.84rem; font-variant-numeric: tabular-nums; }
.log--empty { display: block; color: var(--muted); }

/* ---------- 폼 ---------- */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 700; font-size: 0.9rem; }
.form small { color: var(--muted); font-weight: 500; }
.form input, .form textarea {
  font: inherit; font-weight: 400; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); resize: vertical;
}
.form input:focus, .form textarea:focus { outline: none; border-color: var(--ink); background: var(--bg); }

/* ---------- 토스트 / 설정 / 캡차 ---------- */
.toast {
  position: fixed; z-index: 50; left: 50%; top: calc(var(--top) + 14px);
  transform: translate(-50%, -12px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); width: max-content;
  padding: 12px 16px; border-radius: 12px;
  background: rgba(17, 18, 20, 0.92); color: #fff; font-size: 0.9rem; font-weight: 600;
  box-shadow: var(--shadow-lg); transition: opacity 0.2s, transform 0.2s;
}
.toast--show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind='error'] { background: var(--danger); }

.setup, .captcha {
  position: fixed; inset: var(--top) 0 0 0; z-index: 40;
  display: grid; place-items: center; padding: 16px; background: rgba(255, 255, 255, 0.92);
}
.setup[hidden], .captcha[hidden] { display: none; }
.setup__card, .captcha__card {
  max-width: 440px; width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 22px;
}
.setup__card h2 { margin: 0 0 8px; font-size: 1.1rem; }
.setup__card p { margin: 0 0 12px; line-height: 1.5; font-size: 0.92rem; color: var(--sub); }
.setup__card ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 0.9rem; }
.captcha__card p { margin: 0 0 12px; font-weight: 700; }

body.busy { cursor: progress; }

/* 넓은 화면: 시트를 왼쪽 패널로 */
@media (min-width: 720px) {
  .sheet {
    left: 16px; right: auto; top: calc(var(--top) + 16px); bottom: 16px;
    width: 400px; max-height: none; border-radius: 20px;
  }
  .sheet__grip { display: none; }
  body.has-sheet .fab, body.has-sheet .controls { display: revert; }
  body.has-sheet .fab { display: inline-flex; }
}
