:root {
  --green: #1f6f5c;
  --green-soft: #e3f1ec;
  --ink: #1d2320;
  --muted: #69746f;
  --line: #e3e7e5;
  --bg: #f6f8f7;
  --card: #ffffff;
  --tmap: #ef3f3f;
  --kakao: #fee500;
  --naver: #03c75a;
  --radius: 14px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
/* height: 100%로 고정하면 body가 화면 높이에서 끝나서, 그보다 아래로 스크롤하면 sticky 상단바가 같이 밀려 올라간다 */
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.break { word-break: break-all; }

/* 상단바 */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; color: var(--green); }
.tabs { display: flex; gap: 4px; }
.tab {
  border: 0; background: transparent; padding: 8px 12px; border-radius: 999px;
  font-weight: 600; color: var(--muted); cursor: pointer;
}
.tab.is-active { background: var(--green-soft); color: var(--green); }
.icon-btn {
  border: 0; background: transparent; width: 36px; height: 36px; border-radius: 50%;
  font-size: 18px; cursor: pointer;
}
.icon-btn:hover { background: var(--bg); }
@media (max-width: 400px) { .brand span { display: none; } }

/* 사용량 */
.usage { margin: 14px 0 10px; }
.usage-today { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.usage-today b { font-size: 32px; color: var(--green); }
.usage-bar { height: 10px; margin: 8px 0 4px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.usage-bar > i { display: block; height: 100%; min-width: 2px; background: var(--green); border-radius: inherit; }
.usage-month { margin: 12px 0 0; font-size: 14px; }
.usage-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 120px; margin: 16px 0 6px; }
.usage-week .col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; font-size: 11px; color: var(--muted); }
.usage-week .bar { width: 100%; max-width: 28px; min-height: 2px; background: #8fd1b8; border-radius: 6px 6px 0 0; }
.usage-week .col.is-today .bar { background: var(--green); }
.usage-week .col.is-today { color: var(--ink); font-weight: 700; }
.usage-note { line-height: 1.6; margin: 12px 0 !important; }
.usage-section + .usage-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.usage-section h3 { margin: 0 0 6px; font-size: 15px; }

.count {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 2px;
  border-radius: 999px; background: var(--green); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}

.banner {
  padding: 10px 16px; font-size: 13px; line-height: 1.5;
  background: #fff6db; color: #6b5200; border-bottom: 1px solid #f1e2b0;
}

/* 레이아웃: PC는 좌측 목록 + 우측 지도, 모바일은 지도 위 / 목록 아래 */
.layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  height: calc(100vh - var(--topbar-h));
}
.panel { overflow-y: auto; border-right: 1px solid var(--line); background: var(--bg); }
.map-wrap { position: relative; }
#map { position: absolute; inset: 0; }

@media (max-width: 899px) {
  .layout { display: flex; flex-direction: column-reverse; height: auto; }
  .map-wrap { height: 42vh; position: sticky; top: var(--topbar-h); z-index: 500; border-bottom: 1px solid var(--line); }
  .panel { overflow: visible; border-right: 0; }
}

/* 필터 */
.filters { padding: 14px 16px 8px; background: var(--card); border-bottom: 1px solid var(--line); }
.search {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
  outline: none;
}
.search:focus { border-color: var(--green); background: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; background: #fff; cursor: pointer; user-select: none;
}
.chip input:checked + span { background: var(--green); border-color: var(--green); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.radius { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.radius select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
#originLabel { margin: 8px 0 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--green);
  background: var(--green); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.ghost { background: #fff; color: var(--green); border-color: var(--line); }
.btn.is-on { background: #fff4c2; border-color: #e7c64a; color: #6b5200; }

/* 목록 */
.result-info { margin: 12px 16px 4px; font-size: 13px; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 4px 12px 24px; }
.card {
  display: flex; gap: 12px; padding: 12px; margin-bottom: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.card:hover, .card.is-focus { border-color: var(--green); }
.card .thumb {
  flex: 0 0 72px; height: 72px; border-radius: 10px; background: var(--green-soft) center/cover no-repeat;
  display: grid; place-items: center; font-size: 28px;
}
.card .body { min-width: 0; flex: 1; }
.card h3 { margin: 0 0 2px; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .addr { margin: 0 0 6px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .dist { float: right; font-size: 12px; font-weight: 700; color: var(--green); margin-left: 6px; }
.card .dist.straight { color: var(--muted); font-weight: 600; }
.route-line { margin: 2px 0 10px !important; font-size: 14px; }
.route-line b { color: var(--green); }
.route-line small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); color: #37413c; }
.badge.key { background: var(--green-soft); border-color: transparent; color: var(--green); font-weight: 700; }
.badge.warn { background: #fdecec; border-color: transparent; color: #a33; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); line-height: 1.6; }

/* 상세 시트 */
.sheet { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(15, 20, 18, .45); }
.sheet-body {
  position: relative; width: min(520px, 100%); max-height: 90vh; overflow-y: auto;
  background: #fff; border-radius: 18px; padding: 22px 20px 20px;
}
@media (max-width: 899px) {
  .sheet { align-items: flex-end; }
  .sheet-body { border-radius: 18px 18px 0 0; max-height: 88vh; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
.sheet-close {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: var(--bg); cursor: pointer; font-size: 15px; z-index: 1;
}
.d-image { height: 180px; margin: -22px -20px 14px; background: var(--green-soft) center/cover no-repeat; border-radius: 18px 18px 0 0; }
.sheet-body h2 { margin: 0 40px 4px 0; font-size: 20px; }
.sheet-body > p { margin: 0 0 10px; }
.d-intro { font-size: 14px; line-height: 1.6; margin-top: 12px !important; }
.nav-title { margin: 18px 0 8px; font-size: 14px; color: var(--muted); }
.nav-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 6px; border: 0; border-radius: 12px; cursor: pointer; font-weight: 700; font-size: 14px;
}
.nav-btn b {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 16px; background: rgba(255,255,255,.9);
}
.nav-btn.tmap { background: var(--tmap); color: #fff; }
.nav-btn.tmap b { color: var(--tmap); }
.nav-btn.kakao { background: var(--kakao); color: #3a1d1d; }
.nav-btn.naver { background: var(--naver); color: #fff; }
.nav-btn.naver b { color: var(--naver); }
.nav-btn:active { transform: scale(.97); }
.nav-btn.pulse { animation: pulse 1.2s ease-in-out 3; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(239, 63, 63, .25); } }
#navHint { margin-top: 8px; }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.qr-body { text-align: center; }
.qr-box { display: grid; place-items: center; margin: 16px auto; min-height: 200px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 3000; max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 10px; background: rgba(20, 26, 23, .92); color: #fff; font-size: 14px;
}

/* 목록 머리 · 버튼 변형 */
.result-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 16px; }
.result-row .result-info { margin: 12px 0 4px; }
.small-btn { padding: 6px 10px; font-size: 13px; white-space: nowrap; flex-shrink: 0; }
.btn.danger { color: #c0392b; }
.btn.full { width: 100%; padding: 12px; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.icon-btn { position: relative; }
.sync-dot { position: absolute; top: 6px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: #2ecc71; border: 2px solid #fff; }
.sync-dot.error { background: #e74c3c; }
.badge.mine { background: #fdebd8; color: #a55a12; border-color: transparent; font-weight: 700; }

a.brand { text-decoration: none; cursor: pointer; }
a.brand:active { opacity: .7; }

/* 지도 위 도구: 이 근처 화장실 · 편의점 · 주유소 · 맛집 */
.map-tools {
  /* 지도 아래쪽 한 줄 (위쪽은 지도/스카이뷰 버튼, 오른쪽은 확대 버튼이 차지) */
  position: absolute; left: 10px; right: 10px; bottom: 26px; z-index: 10;
  display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px;
}
.map-tools::-webkit-scrollbar { display: none; }
.map-tools-label { flex: 0 0 auto; font-size: 12px; font-weight: 700; color: var(--ink); background: rgba(255,255,255,.9); padding: 4px 8px; border-radius: 999px; }
.map-tool {
  flex: 0 0 auto; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 11px;
  font-size: 13px; font-weight: 700; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.15); white-space: nowrap;
}
.map-tool.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
@media (max-width: 480px) {
  .map-tools-label { display: none; }
  .map-tools { gap: 4px; left: 6px; right: 6px; }
  .map-tool { padding: 6px 8px; font-size: 12px; }
}
.map-tool:disabled { opacity: .6; }

/* 상세: 주변 탭 */
.nearby-tabs { display: flex; gap: 6px; margin-bottom: 8px; overflow-x: auto; }
.nearby-tabs button {
  flex: 0 0 auto; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 11px; font-size: 13px; cursor: pointer;
}
.nearby-tabs button.is-on { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.toilet-item small { flex: 0 0 auto; margin-left: auto; color: var(--muted); font-size: 11px; }

/* 주소 검색 */
.row.nowrap { flex-wrap: nowrap; }
.search-results { display: grid; gap: 4px; margin-top: 6px; max-height: 190px; overflow-y: auto; }
.search-results button {
  display: grid; gap: 1px; text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-weight: 400;
}
.search-results button b { font-size: 14px; }
.search-results button span { font-size: 12px; color: var(--muted); }

/* 로그인 */
.btn.kakao-login { background: #fee500; border-color: #fee500; color: #191600; margin: 12px 0 6px; }
.account-line { font-size: 16px; margin: 12px 0 4px !important; }

/* 근처 화장실 */
.toilets { display: grid; gap: 6px; }
.toilet-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer;
}
.toilet-item b { flex: 0 0 auto; font-size: 13px; color: #2f7cf6; min-width: 52px; }
.toilet-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

/* 폼 */
.field { display: grid; gap: 4px; margin: 12px 0; font-size: 14px; font-weight: 600; border: 0; padding: 0; }
.field legend { padding: 0; margin-bottom: 4px; }
/* 글자 입력칸만 가로로 꽉 채운다 (라디오 · 체크박스까지 늘어나지 않게) */
.field input:not([type=radio]):not([type=checkbox]), .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-weight: 400; background: var(--bg);
}
.field input:not([type=radio]):not([type=checkbox]):focus, .field textarea:focus { outline: none; border-color: var(--green); background: #fff; }
.radio { display: flex; align-items: center; justify-content: flex-start; gap: 8px; font-size: 14px; font-weight: 400; margin: 6px 0; text-align: left; }
.radio input { flex: 0 0 auto; width: 18px; height: 18px; margin: 0; accent-color: var(--green); }
.req { color: #c0392b; }

/* 위치 고르는 작은 지도 */
.picker { position: relative; height: 200px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); margin-top: 4px; }
.picker-map { position: absolute; inset: 0; }
.picker-pin {
  position: absolute; left: 50%; top: 50%; z-index: 5; pointer-events: none;
  font-size: 30px; line-height: 1; transform: translate(-50%, -100%); /* 핀 끝이 정확히 가운데 */
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.35));
}
.field .row { margin-top: 6px; }
.field > span { font-weight: 600; }

/* 카테고리 */
.saved-filters { padding: 12px 16px 4px; background: var(--card); border-bottom: 1px solid var(--line); }
.saved-filters .chips { margin: 0 0 8px; }
.chip-btn {
  display: inline-block; padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; background: #fff; cursor: pointer;
}
.chip-btn.is-on { background: var(--green); border-color: var(--green); color: #fff; }
.chip-btn .n { opacity: .75; margin-left: 2px; }
.chip-community input:checked + span { background: #8e44ad; border-color: #8e44ad; }
.cat-list { display: grid; gap: 6px; margin: 10px 0; max-height: 40vh; overflow-y: auto; }
.cat-list .radio { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin: 0; }
.cat-list .radio:has(input:checked) { border-color: var(--green); background: var(--green-soft); }
.cat-manage { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 6px; }
.cat-manage li { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.cat-manage li b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.badge.cat { background: #fff4c2; color: #6b5200; border-color: transparent; }
.badge.community { background: #f1e6f7; color: #6c3483; border-color: transparent; font-weight: 700; }

/* 모두의 노지 */
.community-box { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: #f7f0fa; }
.community-box .d-actions { margin-top: 6px; }
.community-box p { margin: 0; }
.btn.is-liked { background: #8e44ad; border-color: #8e44ad; color: #fff; }
.share-name { font-size: 16px; font-weight: 700; margin: 10px 0 !important; }

/* 동기화 */
.sync-code {
  margin: 10px 0; padding: 12px; border-radius: 12px; background: var(--green-soft); color: var(--green);
  font: 700 22px/1.2 ui-monospace, "Consolas", monospace; letter-spacing: 1px; text-align: center; word-break: break-all;
}
#syncLinkForm { margin-top: 6px; flex-wrap: nowrap; }

/* 카카오맵 위 표시 */
.map-label {
  padding: 4px 9px; border-radius: 8px; background: #fff; border: 1px solid var(--green);
  font-size: 12px; font-weight: 700; color: var(--ink); white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,.15);
  margin-bottom: 16px; /* 마커와 겹치지 않게 위로 */
}
.place-label { display: grid; gap: 2px; text-align: center; }
.place-label a { color: #2f7cf6; font-weight: 700; text-decoration: none; }
.origin-dot {
  width: 16px; height: 16px; border-radius: 50%; background: #2f7cf6; border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(47, 124, 246, .25);
}
.map-error {
  position: absolute; inset: 0; margin: 0; display: grid; place-items: center; padding: 16px;
  text-align: center; line-height: 1.6; color: var(--muted); background: var(--green-soft);
}
