:root {
  /* 검정이 기본색, 라임은 강조색. 라임은 흰 바탕 위 글자로 쓰면 안 읽히니 칠로만 쓰고 그 위 글자는 검정으로 한다. */
  --accent: #c8ff00;
  --accent-soft: #f1ffc2;
  --ink: #0a0a0a;
  --sub: #6b7280;
  --line: #e5e7eb;
  --bg: #ffffff;
  --soft: #f3f4f6;
  --sheet-h: 0px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ── 틀: 넓은 화면은 왼쪽 목록 + 오른쪽 지도 ── */
#app { display: grid; grid-template-columns: 400px 1fr; grid-template-rows: auto 1fr; height: 100dvh; }
#top {
  grid-column: 1; grid-row: 1;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 10px; border-right: 1px solid var(--line);
  position: relative; z-index: 5; background: var(--bg);
}
#sheet {
  grid-column: 1; grid-row: 2;
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line); background: var(--bg);
}
#map { grid-column: 2; grid-row: 1 / 3; min-width: 0; background: #eef0f2; }
#map.nomap { display: grid; place-items: center; padding: 24px; color: var(--sub); text-align: center; font-size: 14px; }
#scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#handle { display: none; }

/* ── 이름표와 지역 찾기 ── */
#brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); flex: none; }
#brand .mark { display: block; width: 30px; height: 30px; }
#brand .word { font-weight: 800; font-size: 19px; letter-spacing: -0.02em; }
#search { position: relative; flex: 1; min-width: 0; }
#q {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--soft); font: inherit; font-size: 14px; color: var(--ink); -webkit-appearance: none; appearance: none;
}
#q::placeholder { color: #9ca3af; }
#q:focus { background: #fff; border-color: var(--ink); outline: none; }
#suggest {
  position: absolute; top: 44px; left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  max-height: 320px; overflow-y: auto;
}
#suggest li { display: flex; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 8px; font-size: 14px; cursor: pointer; }
#suggest li[aria-selected="true"], #suggest li:hover { background: var(--accent-soft); }
#suggest li small { color: var(--sub); font-size: 12px; }
#suggest li.none { color: var(--sub); cursor: default; background: none; }

/* ── 범위와 주제 ── */
#filters { padding: 6px 16px 10px; border-bottom: 1px solid var(--line); flex: none; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; background: var(--soft); border-radius: 10px; }
.seg button { border: 0; background: none; height: 32px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--sub); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }
#saved-n { color: var(--ink); font-weight: 700; }
.chips { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: none; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font-size: 13px; font-weight: 600; color: #374151;
}
.chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ── 목록 머리 ── */
#head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 16px 8px; }
#head-eyebrow { display: inline-block; margin: 0 0 4px; padding: 1px 7px; border-radius: 5px; background: var(--accent); font-size: 12px; font-weight: 700; color: var(--ink); }
#head-eyebrow:empty { display: none; }
#head-title { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
#head-sub { margin: 4px 0 0; font-size: 13px; color: var(--sub); line-height: 1.45; }
#head-actions { display: flex; gap: 6px; flex: none; }
#head-actions button { height: 32px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 600; }
#save { padding: 0 12px; }
#save[aria-pressed="true"] { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
#clear { width: 32px; color: var(--sub); }

/* ── 소식 카드 ── */
#list { list-style: none; margin: 0; padding: 0 16px; }
.card { padding: 14px 0; border-bottom: 1px solid var(--line); }
.card .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
.card .tags:empty { display: none; }
.topic, .rchip { height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; }
.topic.t-transit { background: #e0edff; color: #1d4ed8; }
.topic.t-redevelop { background: #ffedd5; color: #b45309; }
.topic.t-supply { background: #ecfccb; color: #3f6212; }
.topic.t-policy { background: #ede9fe; color: #6d28d9; }
.topic.t-market { background: #fce7f3; color: #be185d; }
.topic.t-other { background: var(--soft); color: #4b5563; }
.rchip { border: 0; background: var(--soft); color: #374151; font-weight: 600; }
.rchip:hover { background: var(--accent-soft); color: var(--ink); }
.card a.title { display: block; color: var(--ink); text-decoration: none; font-size: 15.5px; font-weight: 600; line-height: 1.45; letter-spacing: -0.01em; word-break: keep-all; overflow-wrap: anywhere; }
.card a.title:hover { text-decoration: underline; }
.card a.title:visited { color: #4b5563; }
.card .meta { margin-top: 7px; font-size: 12.5px; color: var(--sub); }

#status { margin: 0; padding: 28px 16px; text-align: center; color: var(--sub); font-size: 14px; line-height: 1.6; white-space: pre-line; }
#status:empty { display: none; }
#more { display: block; width: calc(100% - 32px); margin: 14px 16px 0; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 14px; font-weight: 600; }
footer { padding: 22px 16px 28px; }
footer p { margin: 0 0 6px; font-size: 12px; line-height: 1.55; color: #9ca3af; }
footer .credit { margin-top: 12px; }

/* ── 지도 위 말풍선 ── */
.bubble-wrap { transition: opacity 0.15s; }
.bubble-wrap.hide { opacity: 0; pointer-events: none; }
.bubble {
  display: flex; align-items: center; gap: 5px; white-space: nowrap;
  border: 1px solid rgba(15, 23, 42, 0.14); background: rgba(255, 255, 255, 0.94); color: #374151;
  border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.bubble .n { display: none; }
.bubble.has {
  background: var(--accent); color: var(--ink); border-color: transparent;
  padding: 4px 11px 4px 5px; font-size: 13px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.bubble.has .n {
  display: inline-grid; place-items: center; min-width: 21px; height: 21px; padding: 0 5px;
  border-radius: 999px; background: var(--ink); color: var(--accent); font-size: 12px; font-weight: 800;
}
.bubble.saved::before { content: "★"; font-size: 11px; color: #f59e0b; }
.bubble.has.saved::before { color: var(--ink); margin-left: 4px; }
/* 고른 지역은 라임으로 칠해지니, 그 위의 말풍선은 검정이어야 보인다. */
.bubble.selected { background: var(--ink); color: #fff; border-color: transparent; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35); }
.bubble.selected .n { background: var(--accent); color: var(--ink); }
.bubble.selected.saved::before { color: var(--accent); }
.bubble:hover { filter: brightness(1.06); }
.maplibregl-ctrl-attrib { font-size: 11px; }

/* ── 좁은 화면: 지도가 바탕이고 목록은 아래에서 올라오는 판 ── */
@media (max-width: 767px) {
  #app { display: block; }
  #map { position: fixed; inset: 0; }
  #top {
    position: fixed; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px;
    padding: 7px 8px 7px 12px; border: 0; border-radius: 14px; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.16);
  }
  #brand .word { display: none; }
  #q { background: #fff; border-color: transparent; padding-left: 4px; font-size: 16px; }
  #q:focus { border-color: transparent; }
  #sheet {
    position: fixed; left: 0; right: 0; bottom: 0; height: var(--sheet-h); z-index: 4;
    border: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.14);
    transition: height 0.22s ease;
  }
  #sheet.dragging { transition: none; }
  #handle { display: grid; place-items: center; width: 100%; height: 22px; border: 0; background: none; flex: none; touch-action: none; }
  #handle span { width: 38px; height: 4px; border-radius: 4px; background: #d1d5db; }
  #filters { padding-top: 2px; }
  /* 주제 칩은 검색창 아래, 지도 위에 띄운다. */
  #topics {
    position: fixed; top: calc(max(10px, env(safe-area-inset-top)) + 62px); left: 0; right: 0;
    margin: 0; padding: 0 10px 6px; z-index: 3;
  }
  #topics button { border-color: transparent; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.16); height: 32px; }
  #scroll { padding-bottom: env(safe-area-inset-bottom); }
  .maplibregl-ctrl-top-right { display: none; }
  .maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { bottom: var(--sheet-h); transition: bottom 0.22s ease; }
  /* 판을 끝까지 펴면 출처 표시가 주제 칩과 겹친다. 같은 내용이 목록 맨 아래에 있다. */
  #sheet[data-state="full"] ~ #map .maplibregl-ctrl-bottom-right { display: none; }
}
