:root {
  --bg: #fff7fb;
  --surface: #ffffff;
  --text: #3d2b3a;
  --muted: #9b8196;
  --line: #f6dce8;
  --brand: #ff6fa8;
  --brand-strong: #ec4c8f;
  --brand-soft: #ffe4ef;
  --festival: #ff6b9d;
  --performance: #a78bfa;
  --exhibition: #60a5fa;
  --event: #fbbf24;
  --free: #22c55e;
  --radius: 20px;
  --shadow: 0 6px 18px rgba(236, 76, 143, .10);
  --font-cute: 'Jua', 'Gowun Dodum', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 'Gowun Dodum', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif;
  background-image: radial-gradient(#ffd6e7 1px, transparent 1px);
  background-size: 22px 22px;
  word-break: keep-all;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; z-index: 2000; background: #fff; padding: 8px; }

/* 상단 */
.topbar {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px 4px;
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-cute); font-size: 24px; text-decoration: none; color: var(--brand-strong); }
.brand img { align-self: center; }
.tagline { color: var(--muted); font-size: 13px; }

/* 검색 조건 */
.filters { padding: 8px 16px 4px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.filters > * { min-width: 0; }
.search-row { display: flex; gap: 8px; }
.search-row input, .search-row select {
  height: 46px; border: 2px solid var(--line); border-radius: 999px; background: var(--surface); padding: 0 18px;
}
.search-row input:focus, .search-row select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.search-row input { flex: 1; min-width: 0; }
.search-row select { flex: 0 0 auto; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; height: 36px; padding: 0 14px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--surface); cursor: pointer; white-space: nowrap;
  transition: transform .15s, background .15s;
}
.chip:hover { transform: translateY(-2px); border-color: #ffc2da; }
.chip[aria-pressed='true'] { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; box-shadow: 0 4px 10px rgba(255, 111, 168, .35); }
/* 기간·종류 버튼, 무료만, 내 주변을 한 줄에. 좁은 화면에서는 옆으로 밀어 본다 */
.filter-bar { display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-bar .chips { flex: 0 0 auto; overflow: visible; padding-bottom: 0; }
.filter-extra { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.filter-sep { flex: 0 0 2px; align-self: stretch; margin: 6px 4px; border-radius: 2px; background: var(--line); }
.toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--brand); }
.link-btn { background: none; border: 0; color: var(--brand-strong); font-weight: 700; cursor: pointer; min-height: 36px; padding: 0 4px; }

/* 지금 많이 찾는 축제 */
.hot { margin: 0 0 12px; padding: 10px 0 6px; border-radius: var(--radius); background: linear-gradient(180deg, #fff1e6, #fff 80%); border: 2px solid #ffe0c7; }
.hot[hidden] { display: none; }
.hot-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 12px; }
.hot-head h2 { margin: 0; font-family: var(--font-cute); font-weight: 400; font-size: 17px; color: #e0582b; }
.hot-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }
.hot-list {
  list-style: none; margin: 8px 0 0; padding: 0 12px 2px; display: grid; grid-auto-flow: column; grid-auto-columns: 156px;
  gap: 8px; overflow-x: auto; scrollbar-width: thin; scroll-snap-type: x proximity;
}
.hot-item {
  display: flex; gap: 8px; height: 100%; padding: 8px 10px; border-radius: 16px; background: #fff; border: 2px solid #ffe0c7;
  text-decoration: none; scroll-snap-align: start; transition: transform .15s, border-color .15s;
}
.hot-item:hover, .hot-item:focus-visible { transform: translateY(-2px); border-color: #ff9f6e; }
.hot-rank { flex: 0 0 auto; font-family: var(--font-cute); font-size: 22px; line-height: 1.1; color: #ff7a3d; min-width: 16px; text-align: center; }
.hot-list li:nth-child(n + 4) .hot-rank { color: #f3a98a; }
.hot-body { min-width: 0; display: grid; gap: 2px; }
.hot-title { font-family: var(--font-cute); font-size: 15px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hot-meta { font-size: 11px; color: var(--muted); line-height: 1.35; }
.hot-status { color: var(--brand-strong); font-weight: 700; }
.hot-status.status-upcoming { color: #7c5ce0; }

/* 목록·지도 */
.layout { padding: 0 16px 96px; }
.layout[data-view='list'] .map-pane { display: none; }
.layout[data-view='map'] .list-pane { display: none; }
.map-pane {
  height: calc(100dvh - 220px); min-height: 360px; border-radius: 28px; overflow: hidden;
  border: 4px solid #fff; box-shadow: 0 10px 30px rgba(236, 76, 143, .18);
}
#map { width: 100%; height: 100%; background: #f4f1ee; }
.list-pane h1 { font-family: var(--font-cute); font-weight: 400; font-size: 21px; margin: 12px 0 0; }
.count { margin: 2px 0 10px; color: var(--muted); font-size: 13px; }

.view-toggle {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 1000;
  display: flex; background: var(--brand); border-radius: 999px; padding: 4px; box-shadow: 0 6px 20px rgba(236, 76, 143, .4);
}
.view-toggle button { border: 0; background: none; color: #fff; height: 40px; padding: 0 20px; border-radius: 999px; cursor: pointer; font-family: var(--font-cute); font-size: 16px; }
.view-toggle button[aria-selected='true'] { background: #fff; color: var(--brand-strong); }

/* 카드 */
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.card {
  position: relative; display: flex; gap: 12px; padding: 12px; background: var(--surface);
  border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.card:hover, .card:focus-within { transform: translateY(-3px); border-color: var(--brand); box-shadow: 0 10px 22px rgba(236, 76, 143, .2); }
.thumb { flex: 0 0 72px; width: 72px; height: 72px; border-radius: 16px; background: #fdf2f8; }
img.thumb { object-fit: contain; } /* 공공누리 제3유형(변경금지) 사진은 자르지 않는다 */
.thumb-festival { background: linear-gradient(135deg, #ffe4ef, #ffc2da); }
.thumb-performance { background: linear-gradient(135deg, #f1eaff, #dccbff); }
.thumb-exhibition { background: linear-gradient(135deg, #e3f0ff, #c4defd); }
.thumb-event { background: linear-gradient(135deg, #fff6d6, #ffe59a); }
.thumb::after { display: grid; place-items: center; height: 100%; font-size: 30px; }
.thumb-festival::after { content: '🎉'; }
.thumb-performance::after { content: '🎭'; }
.thumb-exhibition::after { content: '🖼️'; }
.thumb-event::after { content: '🎈'; }
.card-body { min-width: 0; flex: 1; }

/* 티켓 날짜 칸: 시작 전이면 시작일, 진행 중이면 마감일. 본문과는 절취선으로 나뉜다 */
.card { overflow: hidden; }
.card::before, .card::after {
  content: ''; position: absolute; left: 90px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--line); transition: border-color .18s;
}
.card::before { top: -11px; }
.card::after { bottom: -11px; }
.card:hover::before, .card:hover::after, .card:focus-within::before, .card:focus-within::after { border-color: var(--brand); }
.stub {
  flex: 0 0 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 72px; border-radius: 16px; background: linear-gradient(135deg, #ffe4ef, #ffc2da); color: #c2366f;
  font-variant-numeric: tabular-nums;
}
.card[data-cat='performance'] .stub { background: linear-gradient(135deg, #f1eaff, #dccbff); color: #6a4bd1; }
.card[data-cat='exhibition'] .stub { background: linear-gradient(135deg, #e3f0ff, #c4defd); color: #2f6fc4; }
.card[data-cat='event'] .stub { background: linear-gradient(135deg, #fff6d6, #ffe59a); color: #9a6200; }
.stub-m { font-size: 12px; font-weight: 700; }
.stub-d { font-family: var(--font-cute); font-size: 30px; line-height: 1; }
.stub-w { font-size: 11px; font-weight: 700; }
.card .card-body { border-left: 2px dashed var(--line); padding-left: 12px; margin-left: 2px; }
/* 날짜 칸 아래에 지도 버튼 */
.stub-col { flex: 0 0 72px; display: flex; flex-direction: column; gap: 6px; }
.stub-col .stub { flex: 1 0 auto; }
.stub-col .map-btn { align-self: stretch; height: 30px; padding: 0; }
/* 오른쪽 사진: 카드 높이를 꽉 채운다 */
.photo {
  position: relative; flex: 0 0 84px; margin: -12px -12px -12px 0; overflow: hidden;
  background: #fdf2f8; border-left: 2px solid var(--line);
}
.photo::before { content: ''; position: absolute; inset: -16px; background: var(--img) center / cover; filter: blur(14px) saturate(1.2); opacity: .75; }
.photo img { position: relative; display: block; width: 100%; height: 100%; object-fit: contain; }
.photo-none::before { display: none; }
.photo-none::after { display: grid; place-items: center; height: 100%; font-size: 34px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.card-title { margin: 4px 0 2px; font-family: var(--font-cute); font-weight: 400; font-size: 17px; line-height: 1.35; }
.card-title a { text-decoration: none; }
.card-title a::after { content: ''; position: absolute; inset: 0; } /* 카드 전체를 눌러 상세로 */
.card-date, .card-place { margin: 0; font-size: 13px; color: var(--muted); word-break: keep-all; overflow-wrap: anywhere; } /* 기간·장소는 자르지 않고 줄을 바꿔 다 보여 준다 */
.card-date { color: var(--text); }
.card-range { white-space: nowrap; letter-spacing: -.3px; } /* 기간은 한 줄로 */
.map-btn {
  position: relative; z-index: 1; align-self: center; flex: 0 0 auto;
  border: 0; background: var(--brand-soft); color: var(--brand-strong); border-radius: 999px; height: 34px; padding: 0 12px; cursor: pointer; font-size: 13px; font-weight: 700;
}
.map-btn:hover { background: var(--brand); color: #fff; }
.dist { font-size: 12px; color: var(--brand-strong); font-weight: 700; }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #f5eef3; color: var(--muted); }
.badge.cat-festival { background: #ffe4ef; color: #e0457f; }
.badge.cat-performance { background: #f1eaff; color: #7c5ce0; }
.badge.cat-exhibition { background: #e3f0ff; color: #3b82f6; }
.badge.cat-event { background: #fff4cc; color: #b7791f; }
.badge.free { background: #dcfce7; color: #16a34a; }
.badge.status-ongoing, .badge.status-last { background: var(--brand-soft); color: var(--brand-strong); }
.badge.status-last { background: #fee2e2; color: #b91c1c; }

.empty { text-align: center; padding: 40px 0; color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px;
  border-radius: 999px; border: 2px solid var(--line); background: var(--surface); text-decoration: none; cursor: pointer; font-weight: 700;
}
.btn.primary { background: #fee500; border-color: #fee500; color: #191919; }

/* 지도 표시: 이모지 말풍선 핀 */
.pin-wrap { background: none; border: 0; }
.pin {
  position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--festival); border: 3px solid #fff; box-shadow: 0 4px 10px rgba(61, 43, 58, .25);
  transform-origin: 50% 100%; transition: transform .15s;
}
.pin::after {
  content: ''; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%);
  border: 6px solid transparent; border-top: 7px solid #fff; border-bottom: 0;
}
.pin-emoji { font-size: 19px; line-height: 1; }
.pin-performance { background: var(--performance); }
.pin-exhibition { background: var(--exhibition); }
.pin-event { background: var(--event); }
.pin-wrap:hover .pin { transform: scale(1.12); }
.bubble {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--brand); color: #fff; font-family: var(--font-cute); font-size: 17px;
  border: 4px solid #ffd1e4; box-shadow: 0 4px 12px rgba(236, 76, 143, .35);
}

/* 목록에 마우스를 올린 행사: 통통 튀고 물결이 퍼진다 */
.is-hot .pin, .is-hot .bubble { animation: hop .7s cubic-bezier(.3, 1.6, .5, 1) infinite alternate; }
.is-hot .pin::before, .is-hot .bubble::before {
  content: ''; position: absolute; inset: -6px; border-radius: 50%;
  border: 3px solid var(--brand); animation: ripple 1.1s ease-out infinite;
}
.is-hot .bubble { position: relative; }
@keyframes hop {
  from { transform: translateY(0) scale(1.15); }
  to { transform: translateY(-14px) scale(1.3); }
}
@keyframes ripple {
  from { opacity: .9; transform: scale(.8); }
  to { opacity: 0; transform: scale(1.9); }
}
@media (prefers-reduced-motion: reduce) {
  .is-hot .pin, .is-hot .bubble { animation: none; transform: scale(1.3); }
  .is-hot .pin::before, .is-hot .bubble::before { animation: none; opacity: 1; }
}
.leaflet-tile-pane { filter: saturate(.45) brightness(1.06) contrast(.92); } /* OSM의 산·숲 색을 옅게 눌러 단순하게 */
.leaflet-popup-content-wrapper { border-radius: 18px; box-shadow: var(--shadow); }
.popup { display: grid; gap: 2px; min-width: 180px; font-size: 13px; }
.popup strong { font-size: 15px; margin-top: 2px; }
.popup strong { font-family: var(--font-cute); font-weight: 400; }
.popup a { color: var(--brand-strong); }

/* 상세 페이지 */
.event { max-width: 760px; margin: 0 auto; padding: 8px 16px 40px; }
.crumbs { font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
.crumbs a { color: var(--brand-strong); text-decoration: none; }
.event h1 { font-family: var(--font-cute); font-weight: 400; font-size: 27px; line-height: 1.3; margin: 8px 0 14px; }
.event-image { margin: 0 0 14px; background: #f3f4f6; border-radius: var(--radius); overflow: hidden; text-align: center; }
.event-image img { max-width: 100%; max-height: 480px; height: auto; vertical-align: middle; } /* 원본 비율 유지 */
.info { margin: 0; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 4px 14px; }
.info div { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.info div:last-child { border-bottom: 0; }
.info dt { flex: 0 0 44px; color: var(--muted); }
.info dd { margin: 0; }
.desc { margin: 16px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.mini-map { height: 240px; border-radius: var(--radius); overflow: hidden; border: 4px solid #fff; box-shadow: var(--shadow); }

/* 광고 자리(임시 배너) */
.ad-pane { display: grid; gap: 12px; margin-top: 16px; }
.layout[data-view='map'] .ad-pane { display: none; }
.ad-slot {
  position: relative; display: grid; place-items: center; text-align: center; color: var(--muted);
  background: repeating-linear-gradient(45deg, #fff, #fff 10px, #fff3f8 10px, #fff3f8 20px);
  border: 2px dashed #ffc2da; border-radius: var(--radius);
}
.ad-slot p { margin: 0; font-family: var(--font-cute); font-size: 15px; }
.ad-label { position: absolute; top: 8px; right: 10px; font-size: 10px; font-weight: 700; color: #fff; background: #f3a6c6; padding: 1px 6px; border-radius: 999px; }
.ad-tall { display: none; height: 600px; }
.ad-square { height: 250px; }
.note { font-size: 13px; color: var(--muted); }
.related .map-btn { display: none; }
.sample-note { margin: 0; padding: 8px 16px; background: #fff4cc; color: #8a5a00; font-size: 13px; text-align: center; }
.related h2 { font-size: 18px; margin: 32px 0 10px; }

/* 날씨 카드(오른쪽 배너 자리) */
.wx-card {
  background: linear-gradient(180deg, #eaf4ff 0%, #fff 70%); border: 2px solid #d7e8fb; border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(59, 130, 246, .10); padding: 14px 14px 12px;
}
.wx-card[hidden], .wx-strip[hidden] { display: none; }
.wx-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.wx-head h2 { margin: 0; font-family: var(--font-cute); font-weight: 400; font-size: 18px; color: #2f6fc4; }
.wx-sub { font-size: 12px; color: var(--muted); }
.wx-today { display: flex; align-items: center; gap: 12px; margin: 8px 0 4px; }
.wx-big { font-size: 46px; line-height: 1; }
.wx-temp { margin: 0; font-size: 15px; color: var(--muted); }
.wx-temp b { font-family: var(--font-cute); font-weight: 400; font-size: 30px; color: var(--text); }
.wx-desc { margin: 0; font-size: 13px; }
.wx-tip { margin: 6px 0 10px; padding: 6px 10px; border-radius: 999px; background: #fff; border: 1px solid #d7e8fb; font-size: 13px; text-align: center; }
.wx-week { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: 12px; }
.wx-week li { display: grid; gap: 1px; padding: 6px 0; border-radius: 12px; }
.wx-week li.is-weekend { background: var(--brand-soft); color: var(--brand-strong); }
.wx-week .wx-ico { font-size: 18px; }
.wx-week b { font-weight: 700; }
.wx-week small { color: var(--muted); }
.wx-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 8px; }
.wx-cell {
  display: flex; align-items: center; justify-content: space-between; gap: 2px; padding: 5px 7px;
  border: 1px solid #e3eefb; border-radius: 12px; background: #fff; cursor: pointer; font-size: 12px;
}
.wx-cell:hover { border-color: var(--brand); }
.wx-cell .wx-ico { font-size: 15px; }
.wx-hint { margin: 8px 0 0; font-size: 11px; color: var(--muted); text-align: center; }

/* 좁은 화면: 목록 위 날씨 한 줄 */
.wx-strip {
  display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; white-space: nowrap;
  margin: 0 0 10px; padding: 8px 12px; border-radius: 999px; background: #eaf4ff; border: 2px solid #d7e8fb; font-size: 13px;
}
.wx-strip::-webkit-scrollbar { display: none; }
.wx-strip.is-region { flex-wrap: wrap; row-gap: 2px; white-space: normal; border-radius: 18px; }
.wx-strip-title { font-family: var(--font-cute); color: #2f6fc4; }
.wx-strip-main b { font-size: 15px; }
.wx-strip-wk { color: var(--brand-strong); font-weight: 700; }
.wx-strip .wx-cell { flex: 0 0 auto; gap: 4px; padding: 2px 8px; border-radius: 999px; }

/* 하단 */
.footer { padding: 24px 16px 110px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.footer h2 { font-size: 13px; margin: 0 0 8px; color: var(--text); }
.region-links { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.region-links a { color: var(--text); font-size: 13px; }
.attribution { margin: 4px 0; }

/* 넓은 화면: 일정 목록 · 큰 지도(가운데) · 광고 */
@media (min-width: 960px) {
  .topbar, .filters { padding-left: 24px; padding-right: 24px; }
  .topbar, .filters, .layout { max-width: 1680px; margin-left: auto; margin-right: auto; }
  /* 검색창 옆에 버튼 줄. 화면이 모자라면 버튼 줄 안에서 묶음 단위로 다음 줄로 내려간다 */
  .filters { display: flex; align-items: flex-start; gap: 12px; }
  .search-row { flex: 1 1 320px; max-width: 460px; min-width: 300px; }
  .filter-bar { flex: 0 1 auto; min-width: 0; flex-wrap: wrap; overflow: visible; gap: 6px 5px; padding: 4px 0 0; }
  .filter-bar .chips { gap: 5px; }
  .search-row input, .search-row select { height: 42px; }
  .chip { height: 34px; padding: 0 10px; font-size: 14px; }
  .filter-sep { margin: 6px 3px; }
  .view-toggle { display: none; }
  .layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 20px; padding: 0 24px 24px; align-items: start; }
  .layout[data-view] .map-pane, .layout[data-view] .list-pane { display: block; }
  .list-pane { max-height: calc(100vh - 24px); overflow-y: auto; position: sticky; top: 12px; padding: 0 6px 12px 2px; scrollbar-width: thin; }
  .map-pane { position: sticky; top: 12px; height: calc(100vh - 24px); }
  .ad-pane, .layout[data-view] .ad-pane { display: none; }
  .footer { padding-bottom: 32px; }
}
@media (min-width: 1280px) {
  .layout { grid-template-columns: 360px minmax(0, 1fr) 300px; }
  .ad-pane, .layout[data-view] .ad-pane { display: grid; margin-top: 0; position: sticky; top: 12px; align-content: start; }
  .ad-tall { display: none; } /* 날씨 카드가 위쪽을 쓰고, 아래에 300×250 배너만 남긴다 */
  .wx-strip { display: none; }
}
@media (max-width: 1279px) {
  .wx-card { display: none; }
}
