:root {
  --bg: #f6f7f8;
  --card: #ffffff;
  --text: #16191d;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0f766e;
  --accent-soft: #e6f4f2;
  --star: #e8a400;
  --open: #15803d;
  --closed: #b91c1c;
  --danger-bg: #fef2f2;
  --naver-text: #038a3f;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1113;
    --card: #1a1d21;
    --text: #eceef0;
    --muted: #9aa1aa;
    --line: #2a2f35;
    --accent: #2dd4bf;
    --accent-soft: #123532;
    --star: #f5b922;
    --open: #4ade80;
    --closed: #f87171;
    --danger-bg: #2a1616;
    --naver-text: #3ddc84;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }

.screen {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 24px);
}
.screen[hidden] { display: none; }

.top h1 { font-size: 30px; margin: 8px 0 4px; letter-spacing: -0.02em; }
.sub { margin: 0; color: var(--muted); font-size: 14px; }

.block { margin-top: 28px; }
.block h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
.hint { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 4px; }
.note { color: var(--muted); font-size: 13px; margin: 8px 2px 0; line-height: 1.45; }

.seg {
  display: flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 11px 6px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) {
  .seg button[aria-pressed="true"] { color: #062a26; }
}

.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cats button {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 16px 14px;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
}
.cats .ico { font-size: 22px; }
.cats button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

.bottom { margin-top: 32px; }
.primary {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 17px;
  font-size: 17px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
}
@media (prefers-color-scheme: dark) { .primary { color: #062a26; } }
.primary:disabled { opacity: 0.4; }

/* 결과 화면 */
.bar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: calc(-1 * (env(safe-area-inset-top) + 16px)) -16px 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  z-index: 2;
}
.back {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 17px;
  font-weight: 500;
  padding: 8px 6px;
  white-space: nowrap;
}
.bar-title { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.res-tabs {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.res-tabs::-webkit-scrollbar { display: none; }
.res-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 1 0 auto;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 11px;
  padding: 9px 11px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.res-tab[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}
.res-tab .tab-cnt {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.group { margin-top: 16px; }
.group h3 { display: flex; align-items: center; gap: 8px; font-size: 18px; margin: 0 0 10px; }
.group h3 .count { font-size: 13px; color: var(--muted); font-weight: 400; }

.place {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 8px;
  overflow: hidden;
}
.place .main {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  color: inherit;
  padding: 14px 14px 12px;
}
.place .main:active { background: var(--accent-soft); }
.place .fav-mark { color: var(--star); margin-left: 6px; font-size: 14px; }
.place.fav { display: flex; align-items: stretch; }
.place.fav .main { flex: 1; min-width: 0; }
.unfav {
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--star);
  font-size: 20px;
  padding: 0 16px;
}
.place .row1 { display: flex; align-items: baseline; gap: 8px; }
.place .rank { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.place .name { font-size: 16px; font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.place .dist { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row2 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.row2 .stars { color: var(--text); font-weight: 600; }
.row2 .stars::before { content: "★ "; color: var(--star); }
.row2 .open { color: var(--open); }
.row2 .closed { color: var(--closed); }
.place .addr { margin-top: 4px; font-size: 13px; color: var(--muted); }

.empty, .error, .loading {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 16px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}
.error { background: var(--danger-bg); border-style: solid; color: var(--closed); }
.error.soft { background: var(--card); border: 1px solid var(--line); color: var(--text); }
.error small { color: var(--muted); font-size: 13px; }
.notice {
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.loading { text-align: center; padding: 40px 16px; border-style: solid; }
.attribution, .footer {
  margin: 24px 2px 8px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.footer a { color: var(--muted); }
.retry { margin-top: 10px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 12px; font-size: 14px; }

/* 검색 화면 상단 */
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fav-open {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

/* 상세 화면 */
.bar .star {
  margin-left: auto;
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  padding: 6px 8px;
  color: var(--muted);
}
.bar .star[aria-pressed="true"] { color: var(--star); }
.map {
  aspect-ratio: 16 / 10;
  min-height: 200px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--line);
  margin: 0 0 8px;
}
.map iframe { display: block; width: 100%; height: 100%; border: 0; }
.d-head { margin: 16px 0 4px; }
.d-head h1 { font-size: 24px; margin: 0; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.d-head .row2 { font-size: 14px; margin-top: 8px; }
.summary { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 10px 0 0; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 18px 0; }
.act {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 12px 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}
.act span { font-size: 22px; }
.act:active { background: var(--accent-soft); }
.act.disabled { opacity: 0.35; }
.info { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px 14px; }
.info .row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.info .row:last-child { border-bottom: 0; }
.info .k { flex: 0 0 64px; color: var(--muted); }
.info .v { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.5; }
.info .v a { color: var(--accent); }
.info .hours { display: flex; flex-direction: column; }
.local { margin-top: 12px; }
.local-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.local-row:empty { display: none; }
.local-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 13px 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.local-btn .k {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: #fee500;
  color: #191919;
  font-size: 12px;
  font-weight: 800;
}
.local-btn:active { background: var(--accent-soft); }
.naver-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 13px;
  font-size: 14px;
  font-weight: 600;
  color: var(--naver-text);
  text-decoration: none;
}
.naver-btn .n {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: #03c75a;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.loading.small { padding: 14px 16px; margin-bottom: 12px; font-size: 13px; }
.d-head + .actions + .error { margin-bottom: 12px; }
.fav-empty { text-align: center; padding: 32px 16px; margin-top: 12px; }

/* 알림 */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 10;
  max-width: calc(100% - 32px);
}
.toast[hidden] { display: none; }
