:root {
  --teal: #1f7a6e;
  --teal-soft: #e6f2f0;
  --ink: #1d2327;
  --muted: #69737a;
  --line: #e3e7ea;
  --bg: #f6f8f9;
  --ad-h: 0px;
  --anchor-top: 0px;     /* 구글 자동 앵커 광고가 위에 떴을 때 비켜 줄 높이 */
  --anchor-bottom: 0px;  /* 아래에 떴을 때 */
  --bar-h: 52px;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); padding-top: calc(var(--ad-h) + var(--bar-h)); overflow: hidden; }
body[data-ad="1"] { --ad-h: 60px; }
button { font: inherit; cursor: pointer; }

/* 상단 고정 배너 광고: 높이를 미리 잡아 화면이 밀리지 않게, 지도·버튼과 겹치지 않게 */
.ad { display: none; }
body[data-ad="1"] .ad {
  display: flex; align-items: center; justify-content: center;
  position: fixed; top: 0; left: 0; right: 0; height: var(--ad-h); z-index: 30;
  background: #fff; border-bottom: 1px solid var(--line); overflow: hidden;
}

.bar {
  position: fixed; top: calc(var(--ad-h) + var(--anchor-top)); left: 0; right: 0; height: var(--bar-h); z-index: 25;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 12px; background: var(--teal); color: #fff;
}
.title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 17px; font-weight: 700; min-width: 0; white-space: nowrap; }
.title img { flex: none; }
@media (max-width: 380px) { .title { font-size: 15px; gap: 6px; } .bar-actions { gap: 4px; } }
.title img { border-radius: 7px; background: #fff; }
.bar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn.only { padding: 7px; }
.icon-btn span { white-space: nowrap; }
.icon-btn {
  display: flex; align-items: center; gap: 4px; padding: 6px 10px; border: 0; border-radius: 999px;
  background: rgba(255, 255, 255, .16); color: #fff; font-size: 14px; text-decoration: none;
}

/* 네이버 지도처럼: 지도가 화면 전체, 목록은 아래에서 끌어 올리는 칸(화면 절반까지) */
main { position: fixed; left: 0; right: 0; top: calc(var(--ad-h) + var(--bar-h) + var(--anchor-top)); bottom: var(--anchor-bottom); --sheet-h: 34vh; background: #e9eeec; }
.map-wrap { position: absolute; left: 0; right: 0; top: 0; bottom: var(--sheet-h); }
.map { position: absolute; inset: 0; z-index: 0; background: #dde5e3; }
.fuel {
  position: absolute; top: 10px; right: 10px; z-index: 1; display: flex; padding: 3px;
  border-radius: 999px; background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .25);
}
.fuel button { padding: 7px 11px; border: 0; border-radius: 999px; background: none; color: var(--muted); font-size: 14px; font-weight: 600; }
.fuel button[aria-pressed="true"] { background: var(--teal); color: #fff; }
/* 처음 들어왔을 때 지도가 뜨기 전까지 */
.map-loading {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: #e9eeec; color: var(--muted); font-size: 14px; transition: opacity .3s;
}
.map-loading.done { opacity: 0; pointer-events: none; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid #cfd8d5; border-top-color: var(--teal); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } }
.fab.on svg { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.fab {
  position: absolute; right: 10px; bottom: 26px; z-index: 1; display: grid; place-items: center;
  width: 42px; height: 42px; border: 0; border-radius: 50%; background: #fff; color: #1971c2;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .25);
}
.fab.on { color: #fff; background: #1971c2; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; height: var(--sheet-h);
  display: flex; flex-direction: column; max-width: 720px; margin: 0 auto;
  background: var(--bg); border-radius: 16px 16px 0 0; box-shadow: 0 -3px 14px rgba(0, 0, 0, .14);
}
.sheet-head { flex: 0 0 auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.grip { display: block; width: 100%; height: 20px; padding: 0; border: 0; background: none; cursor: grab; }
.grip span { display: block; width: 40px; height: 5px; margin: 8px auto 0; border-radius: 3px; background: #c3cacf; }
.panel { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

.chips {
  display: flex; gap: 8px; padding: 6px 12px 10px; overflow-x: auto;
}
.chips button {
  flex: 0 0 auto; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--ink); font-size: 14px;
}
.chips button[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }

.notice { margin: 0 12px 8px; padding: 10px 12px; border-radius: 10px; background: #fff7e0; color: #6b5200; font-size: 13px; }

.list { list-style: none; margin: 0; padding: 0 12px 8px; }
.item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center;
  margin-bottom: 8px; padding: 12px 14px; border-radius: 12px; background: #fff;
  border: 1px solid var(--line); cursor: pointer;
}
.item { scroll-margin-top: 8px; }
.item:active { background: var(--teal-soft); }
.item.on { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.item .detail { grid-column: 1 / -1; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); cursor: default; }
.item .name { font-weight: 600; font-size: 15px; }
.item .dist { color: var(--muted); font-size: 13px; text-align: right; }
.item .meta { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.item .price { color: var(--ink); font-weight: 600; }
.item .cb { color: var(--teal); }
.empty { padding: 24px; text-align: center; color: var(--muted); }

.foot { padding: 16px 16px 40px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.foot p { margin: 0 0 4px; }
.foot a { color: var(--muted); }

/* 지도 표시 */
.pin {
  position: relative; transform: translate(-50%, -50%); padding: 3px 7px; border-radius: 10px; background: var(--teal); color: #fff;
  font-size: 12px; font-weight: 700; white-space: nowrap; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); cursor: pointer;
}
.pin.none { background: #8a9499; }
/* 고른 주유소: 크게, 아래 꼬리를 달아 자리에 꽂힌 핀처럼 */
.pin.on { background: #e8590c; padding: 5px 10px; font-size: 14px; transform: translate(-50%, calc(-100% - 7px)); box-shadow: 0 2px 8px rgba(0, 0, 0, .4); }
.pin.on::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%);
  border: 7px solid transparent; border-bottom: 0; border-top-color: #e8590c;
}
.me { width: 16px; height: 16px; border-radius: 50%; background: #1971c2; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(25, 113, 194, .25); }

/* 고른 주유소 상세 (목록 안에서 펼침) */
.badge { display: inline-block; margin: 0 0 12px; padding: 3px 8px; border-radius: 6px; background: var(--teal-soft); color: var(--teal); font-size: 12px; font-weight: 700; }
.prices { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 14px; }
.prices th { text-align: left; font-weight: 400; color: var(--muted); padding: 6px 0; }
.prices td { text-align: right; padding: 6px 0; }
.prices td.cb { color: var(--teal); }
.info { display: grid; grid-template-columns: 48px 1fr; gap: 6px 8px; margin: 0 0 14px; font-size: 14px; }
.info dt { color: var(--muted); }
.info dt { align-self: center; }
.info dd { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.info a { color: var(--teal); }
.addr-text {
  padding: 0; border: 0; background: none; color: var(--ink, #1d2327); font: inherit; text-align: left;
  text-decoration: underline dotted #9aa5ab; text-underline-offset: 3px; cursor: copy;
}
.copy-btn, .call-btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--teal); background: #fff; color: var(--teal); font-size: 13px; font-weight: 600; text-decoration: none;
}
.call-btn { padding: 6px 12px; }
.copy-btn:active, .call-btn:active { background: var(--teal-soft); }
.nav-label { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.nav-btn { padding: 12px 0; border-radius: 10px; text-align: center; text-decoration: none; font-weight: 700; font-size: 14px; }
.nav-btn.naver { background: #03c75a; color: #fff; }
.nav-btn.kakao { background: #fee500; color: #191919; }
.nav-btn.tmap { background: #3b5bdb; color: #fff; }

/* 홈 화면 추가 안내 */
.install {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--anchor-bottom) + env(safe-area-inset-bottom)); z-index: 35;
  max-width: 696px; margin: 0 auto; padding: 14px 16px; border-radius: 14px; background: #fff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .2);
}
.install-q { margin: 0 0 4px; font-weight: 700; }
.install-hint { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.install-hint:empty { display: none; }
.install-actions { display: flex; justify-content: flex-end; gap: 8px; }
.install-actions button { padding: 8px 16px; border-radius: 8px; border: 0; background: var(--teal); color: #fff; font-weight: 600; }
.install-actions .ghost { background: none; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--anchor-bottom)); transform: translateX(-50%); z-index: 50;
  padding: 10px 16px; border-radius: 999px; background: rgba(29, 35, 39, .9); color: #fff; font-size: 14px;
}

/* 설정 */
.modal { position: fixed; inset: 0; z-index: 45; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, .35); }
.modal[hidden] { display: none; }
.modal-card {
  position: relative; width: 100%; max-width: 560px; max-height: 85vh; overflow: auto;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; background: #fff;
}
.modal-close { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 28px; color: var(--muted); }
.modal-card h2 { margin: 0 0 12px; font-size: 19px; }
.set { padding: 14px 0; border-top: 1px solid var(--line); }
.set h3 { margin: 0 0 4px; font-size: 16px; }
.set-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.set-desc { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.set-status { margin: 8px 0 0; font-size: 13px; font-weight: 600; color: var(--teal); }
.set-status.warn { color: #b35c00; }
.set-btn { margin-top: 10px; padding: 10px 16px; border: 0; border-radius: 10px; background: var(--teal); color: #fff; font-weight: 700; }
.set-links { margin: 6px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.set-links a { color: var(--muted); }
.switch { flex: 0 0 auto; position: relative; width: 50px; height: 30px; margin-top: 2px; border: 0; border-radius: 999px; background: #c3cacf; transition: background .15s; }
.switch span { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--teal); }
.switch[aria-checked="true"] span { transform: translateX(20px); }

/* 목록 가격 줄: 고른 기름 가격과 캐시백 적용가, 그 아래 다른 기름 */
.item .meta .cb { color: var(--teal); }
.item .meta .cb b { font-weight: 700; }
.item .meta.other { font-size: 12px; color: var(--muted); }

/* 내 위치 찾는 동안 내 위치 버튼 바로 왼쪽 안내 (눌러도 지도는 그대로 움직인다) */
.geo-status {
  position: absolute; right: 60px; bottom: 30px; z-index: 3; white-space: nowrap;
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: rgba(25, 113, 194, .92); color: #fff; font-size: 14px; font-weight: 600; pointer-events: none;
}
.geo-status[hidden] { display: none; }
.spinner.small { width: 16px; height: 16px; border-width: 3px; border-color: rgba(255, 255, 255, .35); border-top-color: #fff; }
.map-loading:not(.done) ~ .geo-status { display: none; } /* 지도 로딩 표시가 떠 있는 동안은 겹치지 않게 */

/* 목록 위 한 줄 요약 (곳 수·최저가·기준 시각) */
.summary { margin: 0 14px 8px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.summary:empty { display: none; }
