:root {
  --bg: #fffaf5;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --accent: #c2410c;
  --accent-soft: #ffedd5;
  --jjimjil: #ea580c;
  --kiln: #b91c1c;
  --spring: #0d9488;
  --sauna: #7c3aed;
  --bath: #0284c7;
  --me: #16a34a;
  --map-empty: #ece7e1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1917; --surface: #262220; --text: #f5f5f4; --muted: #a8a29e; --line: #3f3a36;
    --accent: #fb923c; --accent-soft: #3b2415; --map-empty: #2a2622;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1917; --surface: #262220; --text: #f5f5f4; --muted: #a8a29e; --line: #3f3a36;
  --accent: #fb923c; --accent-soft: #3b2415; --map-empty: #2a2622;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }

.top { position: fixed; inset: 0 0 auto 0; z-index: 1000; padding: calc(env(safe-area-inset-top) + 8px) 12px 6px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.row { display: flex; gap: 8px; align-items: center; }
#q { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); font-size: 16px; }
.icon { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 20px; }
.icon.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.chips { overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
/* 유형 버튼: 지도 점과 같은 색. 켜짐=색 채움, 꺼짐=흐린 빈 동그라미 */
.chip[data-type="숯가마"] { --c: var(--kiln); }
.chip[data-type="찜질방"] { --c: var(--jjimjil); }
.chip[data-type="사우나"] { --c: var(--sauna); }
.chip[data-type="온천"] { --c: var(--spring); }
.chip[data-type="목욕탕"] { --c: var(--bath); }
.chip[data-type] { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.chip[data-type]::before { content: ''; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--c); box-sizing: border-box; }
.chip[data-type].on { color: var(--c); border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, var(--surface)); }
.chip[data-type].on::before { background: var(--c); }
.chip[data-type]:not(.on) { opacity: .55; text-decoration: line-through; }
.chip[data-type] small { font-weight: 500; opacity: .8; }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 6px; margin-left: 4px; vertical-align: 1px; }
.tag.warm { background: #fee2e2; color: #b91c1c; }
.tag.src { background: var(--line); color: var(--muted); }
.pop .power { font-size: 12px; margin-top: 6px; padding: 6px 8px; border-radius: 8px; background: #fef2f2; color: #991b1b; }
.pop .power.no { background: #f5f5f4; color: #57534e; }
/* 유형 버튼: 한눈에 다 보이게 줄바꿈, 손가락으로 누르기 쉽게 크게 */
.types { flex-wrap: wrap; overflow: visible; gap: 6px; padding-top: 10px; }
.types .chip { font-size: 14px; padding: 8px 12px; min-height: 38px; }
/* 보조 줄: #키워드 검색 + 규모 */
.kw { padding-top: 6px; }
.kwlist { display: flex; gap: 6px; flex: none; }
.kw .lbl { flex: none; font-size: 12px; color: var(--muted); }
.kw .chip { font-size: 13px; padding: 6px 11px; min-height: 32px; background: transparent; }
.kw .chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pop .route { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: #eff6ff; color: #1e3a8a; font-size: 13px; }
.pop .route b { font-size: 18px; color: #1d4ed8; }
.pop .route small { color: #64748b; }
.item .eta b { color: var(--text); }
.sep { flex: none; width: 1px; height: 20px; background: var(--line); }
.status { font-size: 12px; color: var(--muted); padding-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status b { color: var(--text); }
.badge { display: inline-block; padding: 0 6px; border-radius: 6px; font-size: 11px; font-weight: 700; margin-right: 4px; }
.badge.off { background: #fee2e2; color: #b91c1c; }
.badge.onl { background: #dcfce7; color: #15803d; }

#map { position: fixed; inset: 0; background: var(--map-empty); }
.leaflet-container { background: var(--map-empty); }

.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; height: 42vh; max-height: calc(100vh - 140px);
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: 0 -4px 24px rgba(0,0,0,.15);
  display: flex; flex-direction: column; transition: height .2s; padding-bottom: env(safe-area-inset-bottom); }
.sheet.min { height: 96px; }
.sheet.max { height: calc(100vh - 140px); }
.grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 4px; flex: none; cursor: grab; }
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tab { flex: 1; padding: 10px 0; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.pane { display: none; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.pane.on { display: block; }

.item { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:active { background: var(--accent-soft); }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; }
.item .main { flex: 1; min-width: 0; }
.item .name { font-weight: 600; }
.item .sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .eta { flex: none; text-align: right; font-size: 13px; }
.item .eta b { display: block; font-size: 16px; color: var(--accent); }

.crumbs { padding: 10px 16px; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.crumbs button { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; }
.total { padding: 4px 16px 12px; font-size: 22px; font-weight: 700; }
.total small { font-size: 13px; color: var(--muted); font-weight: 400; }
.rrow { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.rrow .lbl { width: 92px; flex: none; }
.rrow .bar { flex: 1; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.rrow .bar i { display: block; height: 100%; background: var(--accent); }
.rrow .cnt { width: 54px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.empty, .about { padding: 16px; color: var(--muted); font-size: 14px; }
.about h3 { color: var(--text); margin: 12px 0 4px; font-size: 15px; }
.about p { margin: 0 0 8px; }

.pop h4 { margin: 0 0 4px; font-size: 16px; }
.pop .kv { font-size: 13px; margin: 2px 0; }
.pop .kv { display: flex; gap: 6px; }
.pop .kv span { color: #78716c; flex: none; width: 64px; }
.pop .acts { display: flex; gap: 6px; margin-top: 8px; }
.pop .acts a { flex: 1; text-align: center; padding: 6px; border-radius: 8px; background: #ffedd5; color: #c2410c; text-decoration: none; font-weight: 600; font-size: 13px; }
.pop .note { font-size: 11px; color: #a8a29e; margin-top: 6px; }

/* 길 안내 */
.navbox { padding: 12px 16px; }
.navbox .dest { font-weight: 700; font-size: 17px; }
.navbox .dest small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.navrow { display: flex; align-items: center; gap: 16px; margin: 12px 0; }
.arrow { width: 72px; height: 72px; flex: none; display: grid; place-items: center; font-size: 40px; color: #fff;
  background: #2563eb; border-radius: 50%; transition: transform .25s; }
.navnum { font-size: 13px; color: var(--muted); }
.navnum b { display: block; font-size: 30px; color: var(--text); line-height: 1.1; }
.navnum small { display: block; }
.nextg { padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); font-size: 14px; margin-bottom: 8px; }
.routebox { font-size: 13px; padding: 8px 10px; border-radius: 10px; background: #eff6ff; color: #1e3a8a; }
.routebox b { font-size: 18px; color: #1d4ed8; }
.navbox .acts { display: flex; gap: 6px; margin: 10px 0; }
.navbox .acts a { flex: 1; text-align: center; padding: 8px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); text-decoration: none; font-weight: 600; font-size: 13px; }
.guides { margin: 0; padding-left: 22px; font-size: 13px; }
.guides li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.guides li.cur { font-weight: 700; color: var(--accent); }
.guides small { color: var(--muted); }
.share { padding: 10px 16px; }
.sharebtn { display: block; text-align: center; padding: 10px; border-radius: 10px; background: #16a34a; color: #fff; text-decoration: none; font-weight: 700; }
.tab { font-size: 13px; }

/* 오프라인 지도 */
.maphead { padding: 12px 16px 4px; font-weight: 700; }
.maphead small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.maprow { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.maprow .mine { font-size: 11px; color: #fff; background: var(--me); padding: 1px 6px; border-radius: 6px; }
.mapbtn { position: relative; overflow: hidden; min-width: 104px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--accent); background: var(--surface); color: var(--accent); font-size: 13px; font-weight: 600; text-align: center; }
.mapbtn.done { border-color: var(--me); color: var(--me); }
.mapbtn.busy { display: inline-block; color: var(--text); }
.mapbtn.busy i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-soft); z-index: -1; }
.mapbtn.busy { z-index: 0; }
.pop .route a.kroute { color: #1d4ed8; font-weight: 700; text-decoration: none; }
