/* ============================================================
   港·深 식보 — 통합 스타일시트
============================================================ */
:root {
  --ink: #1a1a1a;
  --paper: #ffffff;
  --bg: #f7f7f5;
  --red: #b91c1c;
  --red-dark: #7f1d1d;
  --gold: #b8860b;
  --gold-bright: #d4a017;
  --muted: #6b6b6b;
  --line: #e5e5e0;
  --me: #2563eb;
  --hk-blue: #1a73e8;
  --sz-red: #c8302c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Noto Sans KR', -apple-system, 'Apple SD Gothic Neo', 'Noto Sans SC', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* ====== HEADER ====== */
header {
  background: var(--hk-blue);
  color: white;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
  z-index: 100;
  transition: background 0.3s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
body.city-shenzhen header { background: var(--sz-red); }
h1.brand {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.brand-cn {
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 900;
  margin-right: 4px;
}

.city-tabs {
  display: flex;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  overflow: hidden;
}
.city-tab {
  background: transparent;
  border: none;
  padding: 5px 12px;
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.city-tab.active {
  background: white;
  color: var(--hk-blue);
}
body.city-shenzhen .city-tab.active { color: var(--sz-red); }

.header-spacer { flex: 1; }

.stats {
  font-size: 11px;
  opacity: 0.95;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}
.stats b { font-weight: 700; }

.hdr-btn {
  padding: 4px 10px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  color: white;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}
.hdr-btn:hover { background: rgba(255,255,255,0.3); }
.hdr-btn.active {
  background: white;
  color: var(--hk-blue);
}
body.city-shenzhen .hdr-btn.active { color: var(--sz-red); }

.michelin-btn {
  border-color: rgba(255,255,255,0.5) !important;
  background: rgba(255,255,255,0.15) !important;
}
.michelin-btn:hover { background: rgba(255,215,0,0.28) !important; }
.michelin-btn.active {
  background: var(--gold-bright) !important;
  color: white !important;
  border-color: var(--gold-bright) !important;
}

.btn-group {
  display: flex;
  background: rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 2px;
  gap: 2px;
}
.btn-group .hdr-btn {
  background: transparent;
  border: none;
  padding: 4px 8px;
}
.btn-group .hdr-btn.active {
  background: white;
  color: var(--hk-blue);
}
body.city-shenzhen .btn-group .hdr-btn.active { color: var(--sz-red); }

/* 카테고리 6개는 좁은 화면에서 가로 스크롤 */
.mode-group { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
.mode-group::-webkit-scrollbar { height: 3px; }
.mode-group::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 2px; }

/* ====== LAYOUT ====== */
.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}
#mapWrap {
  flex: 1;
  position: relative;
  min-width: 0;
}
#mapGoogle, #mapLeaflet { position: absolute; inset: 0; }
.hidden { display: none !important; }

.map-notice {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(6px);
  padding: 7px 11px;
  border-left: 3px solid var(--gold);
  font-size: 11px;
  color: #555;
  z-index: 500;
  border-radius: 2px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.1);
  pointer-events: none;
  max-width: 540px;
}
.map-notice b { color: var(--ink); }

.me-marker {
  width: 18px;
  height: 18px;
  background: var(--me);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35); }
  50% { box-shadow: 0 0 0 10px rgba(37, 99, 235, 0); }
}

/* ====== API 경고 ====== */
.api-warning {
  position: absolute;
  inset: 0;
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  z-index: 600;
}
.api-warning-inner {
  max-width: 460px;
  background: white;
  border: 1px solid var(--line);
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  padding: 24px 28px;
  border-radius: 4px;
}
.api-warning h3 { font-size: 15px; margin-bottom: 12px; color: var(--red-dark); }
.api-warning p { font-size: 13px; margin-bottom: 8px; color: #444; }
.api-warning code {
  background: #f0f0f0;
  padding: 1px 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  border-radius: 2px;
}
.api-warning ol { margin: 8px 0 0 20px; font-size: 12px; color: #555; }
.api-warning ol li { margin-bottom: 4px; }
.api-warning a { color: var(--hk-blue); text-decoration: none; font-weight: 600; }
.api-warning a:hover { text-decoration: underline; }

/* ====== SIDEBAR ====== */
#sidebar {
  width: 380px;
  overflow-y: auto;
  background: #fafafa;
  border-left: 1px solid #ddd;
  flex-shrink: 0;
}
.empty {
  padding: 40px 20px;
  text-align: center;
  color: #888;
  font-size: 13px;
}

.item {
  padding: 11px 14px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background 0.1s;
}
.item:hover { background: #eef4fc; }
body.city-shenzhen .item:hover { background: #fcecec; }
.item.active {
  background: #e3f2fd;
  border-left: 3px solid var(--hk-blue);
  padding-left: 11px;
}
body.city-shenzhen .item.active {
  background: #ffe6e4;
  border-left-color: var(--sz-red);
}

.item-row1 {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.item-name {
  font-size: 14px;
  font-weight: 700;
  color: #222;
  line-height: 1.3;
  flex: 1;
}
.item-name .kr {
  color: #666;
  font-weight: 400;
  font-size: 11px;
  margin-left: 4px;
}

/* === 우측: 언급 배지 + 거리 === */
.item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

/* === 언급 횟수 큰 배지 (인기 등급별 색상) === */
.mention-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  background: #eef2f7;
  color: #475569;
  font-weight: 700;
  border: 1px solid #d6dde7;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.mention-badge .m-icon { font-size: 11px; }
.mention-badge .m-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.mention-badge .m-label {
  font-size: 9px;
  opacity: 0.75;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.mention-badge.tier-0 { background:#f1f5f9; color:#94a3b8; border-color:#e2e8f0; }
.mention-badge.tier-1 { background:#fef9c3; color:#854d0e; border-color:#fde047; }
.mention-badge.tier-2 { background:#fed7aa; color:#9a3412; border-color:#fb923c; }
.mention-badge.tier-3 { background:#fecaca; color:#991b1b; border-color:#f87171; }
.mention-badge.tier-4 {
  background: #dc2626;
  color: #fff;
  border-color: #b91c1c;
  box-shadow: 0 2px 6px rgba(220,38,38,0.35);
}
.mention-badge.tier-5 {
  background: linear-gradient(135deg, #f59e0b, #dc2626);
  color: #fff;
  border-color: #b45309;
  box-shadow: 0 2px 8px rgba(220,38,38,0.4);
}

/* === 거리 표시 === */
.item-dist {
  padding: 4px 10px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  background: var(--me);
  color: white;
  border-radius: 5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 5px;
  font-size: 10px;
  align-items: center;
}
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid;
  background: white;
}
.badge.cat { color: white; }
.badge.area {
  background: #eef2f7;
  border-color: #d6dde7;
  color: #333;
}
.badge.price {
  background: #fff8e1;
  border-color: #f3deaa;
  color: #826200;
  font-family: 'JetBrains Mono', monospace;
}
.badge.michelin {
  background: var(--red);
  color: white;
  border-color: var(--red);
}
.badge.rank {
  background: var(--gold-bright);
  color: white;
  border-color: var(--gold-bright);
  margin-right: 5px;
  font-family: 'JetBrains Mono', monospace;
}
.badge.rank-1 { background: #d4a017; }
.badge.rank-2 { background: #b8a878; }
.badge.rank-3 { background: #a08e6c; }

.item-tip {
  font-size: 12px;
  color: #444;
  line-height: 1.45;
  margin: 3px 0;
}
.item-dishes {
  font-size: 11px;
  color: #777;
  margin-bottom: 6px;
}

.item-btns {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.item-btn {
  padding: 3px 9px;
  font-size: 10px;
  background: white;
  border: 1px solid #ccc;
  color: #444;
  text-decoration: none;
  border-radius: 3px;
  font-weight: 600;
  font-family: inherit;
}
.item-btn:hover {
  background: #f0f0f0;
  border-color: #888;
}
.item-btn.naver {
  background: #03c75a;
  color: white;
  border-color: #03c75a;
}
.item-btn.naver:hover { background: #02a347; }
.item-btn.youtube {
  background: #ff0000;
  color: white;
  border-color: #ff0000;
}
.item-btn.youtube:hover { background: #cc0000; }

/* ====== POPUP ====== */
.gm-pop {
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 12px;
  line-height: 1.45;
  max-width: 280px;
}
.gm-pop h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}
.pop-meta { font-size: 11px; color: #666; margin-bottom: 4px; }
.pop-michelin { color: var(--red); font-weight: 700; }
.pop-row { margin: 4px 0; font-size: 11px; color: #444; }
.pop-menu { color: #666; font-size: 10px; }
.pop-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.pop-actions a {
  padding: 3px 8px;
  font-size: 10px;
  background: var(--hk-blue);
  color: white;
  text-decoration: none;
  border-radius: 3px;
  font-weight: 600;
}
.pop-actions a.naver-btn { background: #03c75a; }
.pop-actions a.youtube-btn { background: #ff0000; }
.pop-actions a:hover { opacity: 0.85; }

/* ====== MOBILE ====== */
.toggle-sidebar {
  display: none;
  position: absolute;
  bottom: 18px;
  right: 18px;
  z-index: 700;
  background: var(--hk-blue);
  color: white;
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
body.city-shenzhen .toggle-sidebar { background: var(--sz-red); }

@media (max-width: 768px) {
  /* 헤더 매우 컴팩트하게 — 헤더 영역 최소화 */
  header { 
    padding: 4px 8px !important; 
    gap: 3px !important;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: wrap !important;
    align-items: center;
  }
  h1.brand { 
    display: none !important;  /* 브랜드 타이틀 숨김 (공간 절약) */
  }
  .stats { font-size: 10px; padding: 2px 4px; }
  .hdr-btn { 
    padding: 4px 8px !important; 
    font-size: 11px !important;
    border-radius: 6px !important;
  }
  .city-tab { font-size: 12px !important; padding: 4px 10px !important; }
  /* 버튼 그룹들도 간격 줄임 */
  .btn-group { gap: 2px !important; }
  /* 서브카테고리 바 컴팩트 */
  .subcat-bar { padding: 4px 8px !important; gap: 4px !important; }
  .sub-chip { padding: 3px 8px !important; font-size: 11px !important; }
  .sub-count { padding: 0 4px !important; font-size: 9px !important; }
  /* header-spacer 숨김 */
  .header-spacer { display: none !important; }
  
  #sidebar {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 100%;
    z-index: 800;
    transform: translateX(100%);
    transition: transform 0.25s;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
  }
  body.mobile-sidebar-open #sidebar { transform: translateX(0); }
  .toggle-sidebar { display: block; }
  body.mobile-sidebar-open .toggle-sidebar { display: none; }
}

/* 호텔 버튼 (헤더) */
.hotel-btn {
  background: rgba(255,255,255,0.25) !important;
  border-color: rgba(255,255,255,0.5) !important;
}
.hotel-btn:hover { background: rgba(255,255,255,0.4) !important; }
.hotel-btn.active {
  background: #fff !important;
  color: var(--hk-blue) !important;
}
body.city-shenzhen .hotel-btn.active { color: var(--sz-red) !important; }

/* ===== 맛집 서브카테고리 바 ===== */
.subcat-bar {
  background: white;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.sub-chip {
  padding: 5px 12px;
  font-size: 12px;
  border: 1px solid #ccc;
  background: white;
  cursor: pointer;
  border-radius: 16px;
  font-family: inherit;
  color: var(--ink);
  transition: all 0.12s;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.sub-chip:hover { border-color: #888; background:#f4f4f4; }
.sub-chip.active {
  background: var(--hk-blue);
  border-color: var(--hk-blue);
  color: white;
}
body.city-shenzhen .sub-chip.active {
  background: var(--sz-red);
  border-color: var(--sz-red);
}
.sub-count {
  background: rgba(0,0,0,0.08);
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}
.sub-chip.active .sub-count {
  background: rgba(255,255,255,0.3);
  color: white;
}

/* ===== v12: 모바일 지도+리스트 분할 화면 + 닫기 버튼 ===== */
.sidebar-close {
  display: none;
  position: sticky;
  top: 0;
  width: 100%;
  padding: 10px;
  background: var(--hk-blue);
  color: white;
  border: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 10;
}
body.city-shenzhen .sidebar-close { background: var(--sz-red); }

@media (max-width: 768px) {
  /* 모바일: 위 45% 지도, 아래 55% 리스트 (리스트 더 잘 보이게) */
  .layout { flex-direction: column !important; }
  #mapWrap { 
    flex: 0 0 45vh !important; 
    min-height: 45vh !important;
    max-height: 45vh !important;
  }
  #sidebar {
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    flex: 1 1 auto !important;
    transform: none !important;
    border-left: none !important;
    border-top: 2px solid #ddd !important;
    box-shadow: none !important;
    overflow-y: auto !important;
  }
  /* 모바일 사이드바 토글 버튼은 숨김 (이미 분할 화면) */
  .toggle-sidebar { display: none !important; }
  /* 닫기 버튼도 분할 화면에서는 숨김 */
  .sidebar-close { display: none !important; }
}

/* ============================================================
   Anchor markers — 호텔/컨벤션/공항 (항상 표시)
   ============================================================ */
.anchor-marker { background: transparent !important; border: none !important; }
.anchor-pin {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 33px; height: 33px;
  font-size: 20px;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  box-shadow: 0 3px 8px rgba(0,0,0,0.35);
  border: 3px solid white;
}
.anchor-pin .anchor-emoji { font-size: 20px; line-height: 1; }
.anchor-wrap {
  position: relative;
  width: 33px; height: 33px;
}
.anchor-label {
  position: absolute;
  top: 36px; left: 50%; transform: translateX(-50%);
  white-space: nowrap;
  font-size: 9px; font-weight: 700;
  color: #111; background: rgba(255,255,255,0.95);
  padding: 2px 6px; border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.15);
  pointer-events: none;
  text-shadow: none;
  font-family: 'Noto Sans KR', sans-serif;
}
/* 호텔 = 사각형, 파랑 */
.anchor-hotel {
  background: #1d4ed8;
  border-radius: 6px;
}
/* 컨벤션 = 다이아몬드, 빨강 */
.anchor-convention {
  background: #d32f2f;
  transform: rotate(45deg);
  border-radius: 4px;
}
.anchor-convention .anchor-emoji { transform: rotate(-45deg); }
/* 공항 = 삼각형, 하늘색 */
.anchor-airport {
  background: #0288d1;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  border: none;
  width: 36px; height: 33px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
.anchor-airport .anchor-emoji {
  margin-top: 8px;
  font-size: 16px;
}


/* Meituan / Dianping 버튼 (source: "meituan" 가게용) */
.meituan-btn, .item-btn.meituan {
  background: #ffc300 !important;
  color: #000 !important;
}
.dianping-btn, .item-btn.dianping {
  background: #ff4d4f !important;
  color: white !important;
}

/* confidence:low 마커 — 점선 테두리로 "추정 위치" 표시 */
.marker-low-confidence {
  filter: opacity(0.7);
}

/* ============================================================
   v33: 뷰모드 토글 (모바일 전용) — 분할/지도만/리스트만
   ============================================================ */
.mobile-only { display: none !important; }
@media (max-width: 768px) {
  .mobile-only { display: inline-flex !important; }
  
  /* 지도만 모드 */
  body.view-map #sidebar { display: none !important; }
  body.view-map #mapWrap { 
    flex: 1 1 100% !important; 
    max-height: 100% !important;
    min-height: 100% !important;
  }
  
  /* 리스트만 모드 */
  body.view-list #mapWrap { display: none !important; }
  body.view-list #sidebar { 
    flex: 1 1 100% !important; 
    max-height: 100% !important;
  }
}
.view-mode-btn { font-weight: 700 !important; }

/* 작성자 크레딧 (우측 상단, 아주 작게) */
.credit {
  position: absolute;
  top: 4px; right: 8px;
  font-size: 9px;
  color: rgba(255,255,255,0.6);
  font-weight: 500;
  pointer-events: none;
  z-index: 50;
  font-family: 'JetBrains Mono', monospace;
}

/* 미슐랭 ⭐ 별 마커 (Leaflet) */
.star-marker {
  font-size: 24px;
  line-height: 1;
  color: #fbbf24;
  text-align: center;
  text-shadow:
    -1px -1px 0 #fff, 1px -1px 0 #fff,
    -1px 1px 0 #fff, 1px 1px 0 #fff,
    0 -1px 0 #fff, 0 1px 0 #fff,
    -1px 0 0 #fff, 1px 0 0 #fff;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
