/* GachaLive — 모바일 우선. PC에서는 가운데 폰 크기 한 칸으로 보인다. */
:root {
  --bg: #f0eeff;          /* 바깥 연한 푸른 보라 (가챠맵 톤) */
  --surface: #ffffff;
  --surface-2: #f7f6fd;
  /* 로고 색: 빨강(Gacha) + 노랑·주황(Live) */
  --primary: #e8262f;
  --primary-soft: #ffeceb;
  --accent: #fbb80f;
  --accent-strong: #f08c00;
  --accent-soft: #fff5d6;
  --live: #e8262f;
  --text: #1a1a2e;
  --sub: #6b6b80;
  --line: #ebeaf2;
  --chip: #eeedf5;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(60, 50, 140, 0.07);
  --topbar-h: 60px;
  --tabbar-h: 64px;
  --col: 480px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* 브라우저 기본 "당기면 페이지 새로고침"을 막는다 (우리 당겨서 새로고침과 겹치지 않게) */
html, body { overscroll-behavior-y: contain; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--sub); }
.small { font-size: 13px; }

/* 가운데 폰 화면 한 칸 */
.app {
  position: relative;
  max-width: var(--col);
  min-height: 100%;
  margin: 0 auto;
  background: var(--surface-2);
  box-shadow: 0 0 0 1px rgba(60, 50, 140, 0.04);
}

/* ── 상단바 ─────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(60, 50, 140, 0.06);
}
.logo { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
/* 로고 이미지: 높이 기준으로 맞춤 (원본 635×120) */
.logo-img { display: block; height: 26px; width: auto; }
@media (max-width: 360px) { .logo-img { height: 22px; } }
.search {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px;
  background: var(--chip); border-radius: 999px; color: var(--sub);
}
.search svg { width: 18px; height: 18px; flex-shrink: 0; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 14px; color: var(--text);
}
.search input::placeholder { color: #a3a3b5; }

/* ── 화면 공통 ─────────────────────────── */
.view { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); }

/* ── 피드: 얇은 LIVE 바 (위에 고정) ───── */
.livebar {
  position: sticky; top: var(--topbar-h); z-index: 900;
  padding: 10px 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.livebar-row { display: flex; align-items: center; gap: 8px; }
.livebar-text { font-size: 15px; font-weight: 600; }
.livebar-text b { color: var(--primary); font-size: 17px; font-weight: 800; }
#live-updated { margin-left: auto; }
/* 밤사이(데이터가 어제 것) — 회색, 점 깜빡임 없음 */
.live-pill.is-off { background: var(--chip); color: var(--sub); }
.live-pill.is-off .dot { background: #a3a3b5; animation: none; }
.live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 999px;
  background: var(--primary-soft); color: var(--live);
  font-size: 12px; font-weight: 800; letter-spacing: 0.5px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); animation: pulse 1.6s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(232, 38, 47, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(232, 38, 47, 0); }
  100% { box-shadow: 0 0 0 0 rgba(232, 38, 47, 0); }
}
/* ── 칩 버튼 (지도 목록에서 사용) ───── */
.chip {
  flex-shrink: 0;
  height: 32px; padding: 0 13px;
  border-radius: 999px;
  background: var(--surface); color: var(--sub);
  border: 1px solid var(--line);
  font-size: 14px; font-weight: 600;
}
.chip.is-on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── 리스트 ────────────────────────────── */
.list { background: var(--surface); }

/* 애니메이션은 새로 들어온 글에만 (탭 전환·다시 그리기 때 반복 재생되지 않게) */
.row { border-bottom: 1px solid var(--line); }
.row.is-new { animation: rise 0.35s ease both, flash 2.4s ease 1; }
@keyframes rise { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes flash { 0%, 40% { background: var(--accent-soft); } 100% { background: transparent; } }

.row-main { display: flex; gap: 12px; padding: 12px 16px; align-items: flex-start; cursor: pointer; }

/* 썸네일: 누르면 크게 보기 */
.thumb {
  position: relative; flex-shrink: 0;
  width: 76px; height: 76px; border-radius: 12px; overflow: hidden;
  background: var(--chip);
  display: grid; place-items: center; font-size: 28px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-more {
  position: absolute; right: 4px; bottom: 4px;
  padding: 0 6px; border-radius: 6px;
  background: rgba(26, 26, 46, 0.7); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px;
}

.row-body { flex: 1; min-width: 0; }
.row-meta { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--sub); }
.row-meta .ago { font-weight: 800; color: var(--text); }
.row-meta .ago.hot { color: var(--live); }
.row-meta .src { display: inline-flex; align-items: center; gap: 4px; }
.row-meta .src i { width: 7px; height: 7px; border-radius: 50%; }
.new-badge {
  padding: 0 6px; border-radius: 5px; line-height: 17px;
  background: var(--live); color: #fff; font-size: 11px; font-weight: 800;
}
.row-title {
  margin: 3px 0 0; font-size: 15px; font-weight: 700; line-height: 1.38; letter-spacing: -0.2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.row-where {
  display: flex; align-items: center; gap: 4px; margin-top: 4px;
  font-size: 14px; font-weight: 700; color: var(--accent-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-where.none { color: #a3a3b5; font-weight: 500; }

/* 오른쪽 길찾기 버튼 */
.go-btn {
  flex-shrink: 0; align-self: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 54px; height: 54px; border-radius: 14px;
  background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 800;
}
.go-btn svg { width: 20px; height: 20px; stroke-width: 2.2; }
.go-btn.area { background: var(--accent-soft); color: #b45f00; }

/* 펼친 상세 */
.row-detail { padding: 0 16px 14px 104px; }
.row-detail[hidden] { display: none; }
.detail-text { margin: 0; font-size: 14px; color: #45455a; line-height: 1.55; }
.detail-thumbs { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.detail-thumbs::-webkit-scrollbar { display: none; }
.detail-thumbs button { flex-shrink: 0; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; background: var(--chip); }
.detail-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.detail-actions a, .detail-actions button {
  display: inline-flex; align-items: center; height: 34px; padding: 0 12px; border-radius: 9px;
  font-size: 13px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
}
.detail-actions .kakao { background: #fee500; border-color: #fee500; color: #191919; }
.detail-actions .naver { background: #03c75a; border-color: #03c75a; color: #fff; }

.empty {
  margin: 24px 16px; padding: 36px 20px; text-align: center;
  background: var(--surface); border-radius: var(--radius); color: var(--sub);
}
.empty b { display: block; margin-bottom: 4px; font-size: 16px; color: var(--text); }

/* 당겨서 새로고침 */
.ptr {
  height: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--sub);
  background: var(--surface-2);
}
.ptr.is-anim { transition: height 0.25s ease; }
.ptr-icon { display: inline-block; font-size: 16px; transition: transform 0.2s ease; }
.ptr.is-ready .ptr-icon { transform: rotate(180deg); color: var(--primary); }
.ptr.is-loading .ptr-icon { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 무한 스크롤 목록 끝 안내 */
.feed-more { padding: 18px 16px 8px; text-align: center; font-size: 13px; color: var(--sub); }
.feed-more[hidden] { display: none; }

/* ── 사진 크게 보기 ────────────────────── */
.viewer {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; flex-direction: column;
  background: rgba(10, 10, 20, 0.96); color: #fff;
}
.viewer[hidden] { display: none; }
.viewer-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; font-size: 14px; font-weight: 600; }
.viewer-top button { width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, 0.12); color: #fff; font-size: 18px; }
.viewer-track {
  flex: 1; display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
}
.viewer-track::-webkit-scrollbar { display: none; }
.viewer-track figure { flex: 0 0 100%; margin: 0; display: grid; place-items: center; scroll-snap-align: center; }
.viewer-track img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-caption { padding: 12px 16px calc(16px + var(--safe-b)); font-size: 14px; line-height: 1.45; color: rgba(255, 255, 255, 0.85); }

/* ── 지도 ──────────────────────────────── */
#view-map { padding-bottom: 0; }
.map {
  position: fixed; z-index: 1;
  top: var(--topbar-h); bottom: calc(var(--tabbar-h) + var(--safe-b));
  left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--col);
  background: #e8e6f5;
}
.fab {
  position: fixed; z-index: 900;
  right: max(16px, calc(50% - var(--col) / 2 + 16px));
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 228px);
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--primary); box-shadow: 0 4px 14px rgba(26, 26, 46, 0.18);
}

/* 가챠 핀 (Leaflet divIcon) */
.pin { position: relative; width: 36px; height: 44px; }
.pin-body {
  position: absolute; left: 0; top: 0; width: 36px; height: 36px;
  border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--primary); box-shadow: 0 3px 8px rgba(232, 38, 47, 0.4);
  border: 2px solid #fff;
}
.pin.area .pin-body { background: var(--accent-strong); }
.pin-count {
  position: absolute; left: 0; top: 0; width: 36px; height: 36px;
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 14px;
}
.pin.is-fresh::after {
  content: ""; position: absolute; left: 4px; top: 4px; width: 28px; height: 28px;
  border-radius: 50%; animation: ring 1.8s infinite;
}
@keyframes ring {
  0% { box-shadow: 0 0 0 0 rgba(251, 184, 15, 0.7); }
  100% { box-shadow: 0 0 0 16px rgba(251, 184, 15, 0); }
}
.pin.is-active .pin-body { background: #9b1219; }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #2f80ff; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(47, 128, 255, 0.2); }

/* 아래에서 올라오는 목록 시트 */
.sheet {
  position: fixed; z-index: 950;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b));
  width: 100%; max-width: var(--col);
  height: 212px;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -6px 24px rgba(26, 26, 46, 0.12);
  transition: height 0.25s ease;
}
.sheet.is-open { height: min(70vh, 560px); }
.sheet-handle { display: grid; place-items: center; height: 22px; flex-shrink: 0; }
.sheet-handle span { width: 40px; height: 4px; border-radius: 4px; background: #d6d4e4; }
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 16px 8px; }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.sheet-body { flex: 1; overflow-y: auto; padding: 0 16px 16px; -webkit-overflow-scrolling: touch; }

.place {
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.place:last-child { border-bottom: 0; }
.place-head { display: flex; align-items: center; gap: 8px; }
.place-name { font-weight: 700; font-size: 15px; }
.place-badge { padding: 1px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 700; }
.place-badge.area { background: var(--chip); color: var(--sub); }
.place-post { display: block; margin-top: 6px; font-size: 14px; color: #45455a; }
.place-post b { color: var(--text); }
.go { display: flex; gap: 8px; margin-top: 10px; }
.go a {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; border-radius: 10px; font-size: 14px; font-weight: 700;
}
.go .kakao { background: #fee500; color: #191919; }
.go .naver { background: #03c75a; color: #fff; }
.unlocated { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2); font-size: 13px; color: var(--sub); }

/* ── 하단 탭바 ─────────────────────────── */
.tabbar {
  position: fixed; z-index: 1000; bottom: 0;
  left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--col);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: #9a9aae; font-size: 12px; font-weight: 600;
}
.tab.is-on { color: var(--primary); }
.tab.is-on svg { stroke-width: 2.2; }

/* ── 토스트 ────────────────────────────── */
.toast {
  position: fixed; z-index: 1100;
  left: 50%; transform: translateX(-50%);
  top: calc(var(--topbar-h) + 12px);
  padding: 9px 16px; border-radius: 999px;
  background: var(--text); color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 18px rgba(26, 26, 46, 0.25);
  cursor: pointer;
}

/* Leaflet 기본 스타일 다듬기 */
.leaflet-container { font-family: inherit; }
.leaflet-control-attribution { font-size: 10px; }

/* Netlify 무료 요금제가 자동으로 붙이는 "Powered by Netlify" 배지 숨김
   (설정에 끄는 스위치가 없어서 CSS 로 처리. Netlify 가 구조를 바꾸면 다시 보일 수 있음) */
#nl-badge-frame { display: none !important; }
