/* ── 색·크기 토큰 ───────────────────────────── */
:root {
  --bg: #f6faf8;
  --surface: #ffffff;
  --surface-2: #f1f5f4;
  --line: #e2e8f0;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #94a3b8;
  --brand: #10b981;
  --brand-strong: #059669;
  --brand-soft: #ecfdf5;
  --edupark: #f59e0b;
  --edupark-soft: #fef3c7;
  --dark-btn: #0f172a;
  --warn: #b45309;
  --shadow: 0 10px 30px rgba(15, 23, 42, .10);
  --radius: 22px;
  --top-h: 68px;
  --gap: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --surface: #111a2b; --surface-2: #1a2438; --line: #26324a;
    --text: #e2e8f0; --text-2: #b6c2d4; --muted: #7c8aa3;
    --brand-soft: rgba(16, 185, 129, .15); --edupark-soft: rgba(245, 158, 11, .18);
    --dark-btn: #334155; --warn: #fbbf24; --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #111a2b; --surface-2: #1a2438; --line: #26324a;
  --text: #e2e8f0; --text-2: #b6c2d4; --muted: #7c8aa3;
  --brand-soft: rgba(16, 185, 129, .15); --edupark-soft: rgba(245, 158, 11, .18);
  --dark-btn: #334155; --warn: #fbbf24; --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

/* ── 기본 ─────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Malgun Gothic", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
  -webkit-font-smoothing: antialiased; word-break: keep-all;
}
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }

/* ── 상단바 ───────────────────────────────── */
.topbar {
  position: fixed; top: var(--gap); left: var(--gap); right: var(--gap); z-index: 1000;
  height: var(--top-h); padding: 0 12px 0 18px;
  display: flex; align-items: center; gap: 12px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 800; font-size: 18px; white-space: nowrap; }
.brand-mark { font-size: 22px; }
.tabs { display: flex; gap: 6px; margin: 0 auto; }
.tab {
  display: flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 999px;
  text-decoration: none; font-weight: 700; font-size: 14px; background: var(--surface-2); color: var(--text-2);
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(16, 185, 129, .35); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 999px; border: 0; background: var(--surface-2);
  display: inline-grid; place-items: center; font-size: 15px; flex: none;
}
.icon-btn:hover { background: var(--line); }
.pill-btn {
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--brand); background: var(--brand-soft);
  color: var(--brand-strong); font-weight: 700; font-size: 14px; text-decoration: none; white-space: nowrap;
}
.pill-btn.dark { background: var(--dark-btn); border-color: var(--dark-btn); color: #fff; }

/* ── 화면 전환 ─────────────────────────────── */
.home, .online, .map-wrap, .panel, .mobile-switch { display: none; }
body[data-view="home"] .home { display: block; }
body[data-view="online"] .online { display: block; }
body[data-view="visit"] .map-wrap, body[data-view="roadmap"] .map-wrap { display: block; }
body[data-view="visit"] .panel, body[data-view="roadmap"] .panel { display: flex; }

/* ── 홈 ───────────────────────────────────── */
.home { padding: calc(var(--top-h) + 48px) 16px 48px; max-width: 1080px; margin: 0 auto; }
.hero { text-align: center; padding: 24px 0 8px; }
.hero-kicker { margin: 0 0 12px; color: var(--brand-strong); font-weight: 700; }
.hero h1 { margin: 0; font-size: clamp(28px, 5vw, 46px); line-height: 1.25; letter-spacing: -.02em; }
.hero h1 em { font-style: normal; color: var(--brand); }
.hero-sub { color: var(--text-2); margin: 16px auto 28px; max-width: 560px; }
.hero-search {
  display: flex; align-items: center; gap: 10px; max-width: 560px; margin: 0 auto; padding: 0 20px;
  height: 56px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.hero-search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; min-width: 0; }
.stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.stat {
  min-width: 120px; padding: 12px 20px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line);
}
.stat b { font-size: 24px; color: var(--brand-strong); }
.stat span { margin-left: 2px; font-size: 14px; color: var(--text-2); }
.stat small { display: block; color: var(--text-2); }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 40px; }
.quick-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 12px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none;
  transition: transform .15s, box-shadow .15s;
}
.quick-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.quick-ico { font-size: 30px; }
.quick-card small { color: var(--text-2); }
.data-status { text-align: center; color: var(--muted); font-size: 13px; margin-top: 28px; }
.data-status.is-warn { color: var(--warn); }
.site-footer { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); text-align: center; color: var(--text-2); font-size: 14px; }
.site-footer p { margin: 4px 0; }

/* ── 지도 ─────────────────────────────────── */
.map-wrap { position: fixed; inset: 0; z-index: 1; }
#map { width: 100%; height: 100%; background: var(--surface-2); }
.pin-wrap { background: none; border: 0; }
.pin {
  width: 36px; height: 36px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--brand); border: 3px solid #fff; box-shadow: 0 4px 10px rgba(0, 0, 0, .3);
  display: grid; place-items: center; transition: transform .15s;
}
.pin span { transform: rotate(45deg); font-size: 16px; line-height: 1; }
.pin-edupark { background: var(--edupark); }
.pin.is-selected { transform: rotate(-45deg) scale(1.25); background: #2563eb; }
.marker-cluster { background: rgba(16, 185, 129, .28); border-radius: 50%; background-clip: padding-box; }
.marker-cluster div {
  width: 30px; height: 30px; margin: 5px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 13px; box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.leaflet-container { font-family: inherit; }

/* ── 왼쪽 목록 패널 ────────────────────────── */
.panel {
  position: fixed; z-index: 500; left: var(--gap); top: calc(var(--top-h) + var(--gap) * 2); bottom: var(--gap);
  width: 360px; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: 28px; box-shadow: var(--shadow); overflow: hidden; transition: transform .25s;
}
body.panel-collapsed .panel { transform: translateX(calc(-100% + 44px)); }
body.panel-collapsed .panel-toggle { transform: rotate(180deg); }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 18px 18px 8px; }
.panel-head h2 { margin: 0; font-size: 16px; }
.count { background: var(--brand); color: #fff; font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 999px; }
.panel-toggle { margin-left: auto; }
.filters { padding: 4px 18px 10px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  border: 0; padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: var(--surface-2); color: var(--text-2);
}
.chip:hover { color: var(--text); }
.chip.is-active { background: var(--brand); color: #fff; }
.chip[data-action="edupark"].is-active { background: var(--edupark); }
.select { padding: 7px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 700; }
.card-list { list-style: none; margin: 0; padding: 4px 12px 16px; overflow-y: auto; flex: 1; }
.card {
  width: 100%; display: flex; gap: 12px; padding: 10px; margin-bottom: 8px; text-align: left;
  border: 1px solid transparent; border-radius: 18px; background: transparent; transition: background .15s;
}
.card:hover { background: var(--surface-2); }
.card.is-active { background: var(--brand-soft); border-color: var(--brand); }
.card-thumb, .grid-thumb, .detail-hero {
  position: relative; display: grid; place-items: center; overflow: hidden; flex: none;
  background: linear-gradient(135deg, var(--thumb, var(--brand)), color-mix(in srgb, var(--thumb, var(--brand)) 55%, #fff));
}
.card-thumb { width: 72px; height: 72px; border-radius: 14px; font-size: 30px; }
.card-thumb img, .grid-thumb img, .detail-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-body { min-width: 0; }
.card-body h3 { margin: 0 0 4px; font-size: 15px; }
.dist { font-size: 12px; color: var(--brand-strong); font-weight: 700; margin-left: 4px; }
.card-desc, .card-topic { margin: 4px 0 0; font-size: 12px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-topic { color: var(--brand-strong); font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-weight: 600; }
.tag-strong { background: var(--line); color: var(--text); }
.tag-warn { background: var(--edupark-soft); color: var(--warn); }
.badge-edupark { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--edupark-soft); color: var(--warn); font-weight: 800; }
.empty { list-style: none; padding: 32px 12px; text-align: center; color: var(--muted); }

/* ── 온라인 ───────────────────────────────── */
.online { padding: calc(var(--top-h) + 40px) 16px 48px; }
.online-inner { max-width: 1120px; margin: 0 auto; }
.online h2 { margin: 0 0 4px; font-size: 26px; }
.online .filters { padding: 16px 0; }
.grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.grid-card {
  width: 100%; height: 100%; padding: 0; text-align: left; overflow: hidden; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: transform .15s, box-shadow .15s;
}
.grid-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.grid-thumb { height: 110px; font-size: 42px; }
.grid-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.grid-body h3 { margin: 0; font-size: 16px; }
.grid-body p { margin: 0; font-size: 13px; color: var(--text-2); flex: 1; }

/* ── 상세 ─────────────────────────────────── */
.detail {
  position: fixed; z-index: 900; right: var(--gap); top: calc(var(--top-h) + var(--gap) * 2);
  width: 400px; max-height: calc(100vh - var(--top-h) - var(--gap) * 3); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow);
  animation: pop .2s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }
.detail-hero { height: 170px; font-size: 64px; }
.detail-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .55), transparent 60%); }
.detail-bar { position: sticky; top: 0; height: 0; z-index: 3; } /* 스크롤해도 닫기 버튼이 보이게 */
.detail-close { position: absolute; top: 12px; right: 12px; background: rgba(15, 23, 42, .55); color: #fff; }
.detail-title { position: relative; margin-top: -76px; padding: 0 20px 14px; z-index: 1; color: #fff; }
.detail-title h2 { margin: 6px 0 0; font-size: 22px; text-shadow: 0 2px 6px rgba(0, 0, 0, .4); }
.kind { display: inline-block; font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: var(--brand); margin-right: 4px; }
.kind-edupark { background: var(--edupark); }
.detail-body { padding: 16px 20px 20px; }
.detail-desc { background: var(--surface-2); border-radius: 16px; padding: 14px 16px; margin: 12px 0; font-size: 14px; }
.detail-meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; margin: 0 0 14px; }
.detail-meta dt { color: var(--muted); font-weight: 700; }
.detail-meta dd { margin: 0; }
.grade-pill { background: var(--brand-soft); color: var(--brand-strong); font-weight: 800; padding: 2px 10px; border-radius: 999px; }
.detail-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; margin-bottom: 8px; }
.btn { display: flex; justify-content: center; align-items: center; gap: 6px; padding: 14px; border-radius: 18px; font-weight: 800; font-size: 14px; text-decoration: none; color: #fff; }
.btn-dark { background: var(--dark-btn); }
.btn-green { background: var(--brand); }
.btn:hover { filter: brightness(1.08); }
.topics-title { font-size: 16px; margin: 20px 0 10px; }
.topic { border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; margin-bottom: 10px; font-size: 13px; }
.topic-head { display: flex; gap: 8px; align-items: center; font-weight: 700; color: var(--text-2); }
.topic-grade { background: var(--brand); color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 12px; }
.topic h4 { margin: 8px 0 4px; font-size: 15px; }
.topic h5 { margin: 10px 0 4px; font-size: 13px; }
.topic p { margin: 0; color: var(--text-2); }
.topic ul { margin: 0; padding-left: 18px; color: var(--text-2); }
.topic a { color: var(--brand-strong); font-weight: 700; }

/* ── 모달 ─────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(15, 23, 42, .45); backdrop-filter: blur(4px); display: grid; place-items: start center; padding: 80px 16px 16px; overflow-y: auto; }
.modal-box { width: 100%; max-width: 620px; background: var(--surface); border-radius: 28px; box-shadow: var(--shadow); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-body { padding: 8px 24px 16px; font-size: 14px; }
.modal-body h3 { font-size: 16px; margin: 18px 0 8px; }
.help-list { padding-left: 20px; margin: 0; display: grid; gap: 6px; color: var(--text-2); }
.help-list b { color: var(--text); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface-2); }
.search-row { display: flex; align-items: center; gap: 10px; padding: 12px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.search-row input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 17px; padding: 8px 0; min-width: 0; }
.search-results { list-style: none; margin: 0; padding: 8px; max-height: 60vh; overflow-y: auto; }
.search-item { width: 100%; display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 0; background: transparent; border-radius: 14px; text-align: left; }
.search-item:hover { background: var(--surface-2); }
.search-item small { display: block; color: var(--muted); }
.search-emoji { font-size: 24px; }

.toast {
  position: fixed; z-index: 3000; left: 50%; bottom: 28px; transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--dark-btn); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow);
}

/* ── 휴대폰 ───────────────────────────────── */
@media (max-width: 768px) {
  :root { --top-h: 104px; --gap: 8px; }
  .topbar { flex-wrap: wrap; border-radius: 24px; padding: 10px 12px; row-gap: 8px; align-content: center; }
  .tabs { order: 3; width: 100%; margin: 0; }
  .tab { flex: 1; justify-content: center; padding: 8px 6px; font-size: 13px; gap: 4px; }
  .topbar-actions { margin-left: auto; }
  .quick { grid-template-columns: repeat(2, 1fr); }
  .panel, body.panel-collapsed .panel { left: var(--gap); right: var(--gap); width: auto; transform: translateY(110%); bottom: 72px; }
  body.list-open .panel { transform: none; }
  .select { font-size: 16px; } /* iOS 입력 시 자동 확대 방지 */
  .panel-toggle { display: none; }
  body[data-view="visit"] .mobile-switch, body[data-view="roadmap"] .mobile-switch { display: block; }
  .mobile-switch {
    position: fixed; z-index: 950; left: 50%; bottom: 16px; transform: translateX(-50%);
    padding: 12px 26px; border-radius: 999px; border: 0; background: var(--dark-btn); color: #fff; font-weight: 800; box-shadow: var(--shadow);
  }
  .detail { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 72vh; border-radius: 28px 28px 0 0; z-index: 960; }
  body.list-open .detail { display: none; }
}
