:root {
  --bg: #ffffff;
  --bg2: #f2f4f8;
  --line: #e4e8ef;
  --tx: #1e2532;
  --tx2: #7b8494;
  --acc: #d97a2e;
  --acc2: #3182f6;
  font-size: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  display: flex;
  font-family: Pretendard, "Pretendard Variable", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  background: var(--bg); color: var(--tx);
}

/* ── 로딩 ── */
#loading {
  position: fixed; inset: 0; z-index: 99; background: var(--bg);
  display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center;
  color: var(--tx2); letter-spacing: .05em; transition: opacity .5s;
}
#loading.out { opacity: 0; pointer-events: none; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--acc); animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ── 사이드바 ── */
#sidebar {
  width: 264px; flex: 0 0 264px; height: 100%; overflow-y: auto;
  background: var(--bg); border-right: 1px solid var(--line);
  padding: 18px 16px 12px; display: flex; flex-direction: column; gap: 14px;
}
#sidebar header h1 { font-size: 21px; letter-spacing: .02em; }
#sidebar header h1 span { font-size: 13px; font-weight: 500; color: var(--tx2); margin-left: 2px; }
#sidebar .sub { font-size: 11px; color: var(--tx2); margin-top: 4px; }

#layer-tabs { display: flex; gap: 6px; }
.ltab {
  flex: 1; padding: 8px 4px 7px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--tx2); cursor: pointer; text-align: center;
  display: flex; flex-direction: column; gap: 1px; font-family: inherit; transition: all .15s;
}
.ltab b { font-size: 12px; }
.ltab small { font-size: 10px; }
.ltab.active { border-color: var(--acc2); color: var(--tx); background: #eaf2ff; }
.ltab[data-layer="l2"].active { border-color: var(--acc2); background: #eaf2ff; }
.ltab[data-layer="l3"].active { border-color: #b07aa1; background: #f6eef7; }

.lpanel { display: flex; flex-direction: column; gap: 8px; }
.lpanel.hidden { display: none; }
/* 섹션 소제목 — 위에 연한 구분선으로 종류 구획 */
.lpanel h3 { font-size: 14px; color: #48505e; font-weight: 700; margin-top: 6px; border-top: 1px solid var(--line); padding-top: 13px; }
.lpanel h3 small { font-weight: 400; margin-left: 4px; }

.radio-col, .check-col { display: flex; flex-direction: column; gap: 2px; }
.radio-col label, .check-col label {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px;
  font-size: 13px; cursor: pointer; color: var(--tx2);
}
.radio-col label:hover, .check-col label:hover { background: var(--bg2); }
.radio-col label.on, .check-col label.on { color: var(--tx); background: var(--bg2); }
.radio-col .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: 0 0 8px; }
.radio-col label.on .dot { background: var(--acc2); }
.check-col input, .radio-col input { display: none; }
.check-col .box { width: 13px; height: 13px; border-radius: 4px; border: 1.5px solid var(--line); flex: 0 0 13px; position: relative; }
.check-col label.on .box { background: var(--acc2); border-color: var(--acc2); }
.check-col label.on .box::after { content: ""; position: absolute; inset: 3px; border-radius: 2px; background: var(--bg); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  padding: 4px 9px; border-radius: 20px; font-size: 11.5px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--tx2); font-family: inherit;
  display: flex; align-items: center; gap: 5px; transition: all .12s;
}
.chip .sw { width: 8px; height: 8px; border-radius: 50%; }
.chip.on { color: var(--tx); border-color: color-mix(in srgb, var(--c) 70%, transparent); background: color-mix(in srgb, var(--c) 16%, transparent); }
.chip:not(.on) .sw { opacity: .25; }

.preset-col { display: flex; flex-direction: column; gap: 5px; }
.preset {
  text-align: left; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--tx); cursor: pointer; font-family: inherit; transition: border-color .15s;
}
.preset:hover { border-color: var(--acc2); }
.preset b { font-size: 12.5px; display: block; }
.preset small { font-size: 11px; color: var(--tx2); }

.pill {
  padding: 7px 12px; border-radius: 20px; border: 1px solid #b07aa1; background: transparent;
  color: #9c5f8d; cursor: pointer; font-family: inherit; font-size: 12px;
}
.pill.on { background: #b07aa1; color: #fff; font-weight: 700; }
.morph-row { display: flex; flex-direction: column; gap: 8px; }
.mock-note { font-size: 10.5px; color: #9a7b3f; line-height: 1.5; border: 1px dashed #e6d9bd; background: #fcf8ef; border-radius: 8px; padding: 8px 10px; }

#side-foot { margin-top: auto; font-size: 10px; color: var(--tx2); line-height: 1.6; padding-top: 10px; }

/* ── 지도 ── */
#map-wrap { flex: 1; position: relative; height: 100%; }
#map { position: absolute; inset: 0; }
.maplibregl-canvas { transition: filter 1.2s ease; }
.maplibregl-ctrl-attrib { font-size: 9px; opacity: .6; }

/* HUD */
#hud-hour {
  position: absolute; top: 14px; left: 14px; z-index: 5; pointer-events: none;
  font-size: 30px; font-weight: 300; letter-spacing: .06em; color: #1e2532;
  text-shadow: 0 1px 8px rgba(255,255,255,.85), 0 0 2px rgba(255,255,255,.9); font-variant-numeric: tabular-nums;
}
#hud-hour small { font-size: 12px; font-weight: 500; display: block; letter-spacing: .12em; opacity: .85; }
#hud-hour.hidden { display: none; }

#legend {
  position: absolute; right: 14px; bottom: 20px; z-index: 5;
  background: rgba(255,255,255,.94); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 12px; padding: 13px 16px;
  font-size: 12.5px; color: var(--tx2); max-width: 280px;
  box-shadow: 0 4px 16px rgba(23,30,45,.10);
}
#legend.lifted { bottom: 84px; }
#legend.hidden { display: none; }
#legend h4 { font-size: 14px; color: var(--tx); margin-bottom: 8px; font-weight: 700; }
#legend .row { display: flex; align-items: center; gap: 8px; margin: 3.5px 0; }
#legend .sw { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 14px; }
#legend .swl { width: 18px; height: 0; flex: 0 0 18px; }   /* 점선 스와치 */
#legend .bar { height: 10px; border-radius: 5px; width: 210px; margin: 5px 0 3px; }
#legend .lbls { display: flex; justify-content: space-between; width: 210px; font-size: 11px; }

.map-btn {
  position: absolute; right: 10px; z-index: 6;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(255,255,255,.96);
  color: #4a5261; font-size: 12.5px; font-weight: 700; cursor: pointer;
  box-shadow: 0 2px 8px rgba(23,30,45,.10);
  display: flex; align-items: center; justify-content: center;
}
.map-btn svg { width: 19px; height: 19px; display: block; }
.map-btn:hover { border-color: var(--acc2); color: var(--acc2); }
.map-btn.on { border-color: var(--acc2); background: #eaf2ff; color: var(--acc2); }
#view-toggle { top: 108px; }
#street-btn { top: 152px; }
#survey-btn { top: 196px; }
#sat-btn { top: 240px; }
#geo-btn { top: 284px; }
#v3d-btn { top: 372px; }   /* AI 챗봇(328px) 바로 아래 */

#mode-toast {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 7;
  background: rgba(255,255,255,.96); border: 1px solid var(--acc); border-radius: 20px;
  padding: 8px 18px; font-size: 12.5px; color: var(--tx); pointer-events: none;
  box-shadow: 0 4px 14px rgba(23,30,45,.12); white-space: nowrap;
}
#mode-toast.hidden { display: none; }

#survey-bar {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%); z-index: 7;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 12px; font-size: 12px; color: var(--tx2);
}
#survey-bar.hidden { display: none; }

/* 로드뷰 패널 */
/* ── V-World 실사 3D 패널 — 분할 화면 (body flex의 형제: 지도가 왼쪽으로 밀림) ── */
#v3d-panel {
  flex: 0 0 46%; min-width: 320px; height: 100%;
  display: flex; flex-direction: column;
  background: #f2f4f8; border-left: 1px solid var(--line);
  overflow: hidden;
}
#v3d-panel.hidden { display: none; }
#v3d-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; font-size: 12px; color: var(--tx); border-bottom: 1px solid var(--line);
}
#v3d-head small { color: var(--tx2); margin-left: 4px; }
#v3d-head button { background: none; border: 0; color: var(--tx2); cursor: pointer; font-size: 12px; }
#v3d-head button:hover { color: var(--tx); }
#v3d-frame { flex: 1; min-height: 0; border: 0; width: 100%; background: #dfe3ea; }

#rv-panel {
  position: absolute; left: 14px; bottom: 84px; z-index: 8;
  width: 420px; height: 320px; display: flex; flex-direction: column;
  background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; box-shadow: 0 8px 24px rgba(23,30,45,.14);
}
#rv-panel.hidden { display: none; }
#rv-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; font-size: 12px; color: var(--tx); border-bottom: 1px solid var(--line);
}
#rv-head button { background: none; border: 0; color: var(--tx2); cursor: pointer; font-size: 13px; }
#rv-view { flex: 1; min-height: 0; }
#rv-empty {
  position: absolute; inset: 37px 0 0; display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: 12.5px; color: var(--tx2); background: var(--bg2); line-height: 1.7;
}
#rv-empty.hidden { display: none; }
#survey-bar button {
  padding: 4px 10px; border-radius: 7px; border: 1px solid var(--line);
  background: transparent; color: var(--tx); font-size: 11.5px; cursor: pointer; font-family: inherit;
}
#survey-bar button:hover { border-color: var(--acc2); color: var(--acc2); }
#survey-count { color: var(--acc); font-weight: 700; }

/* 조사 입력 폼 */
.svy-form { display: flex; flex-direction: column; gap: 9px; }
.svy-form label.f { font-size: 11px; color: var(--tx2); display: flex; flex-direction: column; gap: 4px; }
.svy-form input[type="text"], .svy-form select, .svy-form textarea {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 7px;
  color: var(--tx); padding: 7px 9px; font-size: 13px; font-family: inherit; width: 100%;
}
.svy-form textarea { resize: vertical; min-height: 52px; }
.svy-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.svy-check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--tx); cursor: pointer; }
.svy-check input { accent-color: #e57373; }
.svy-actions { display: flex; gap: 8px; margin-top: 2px; }
.btn-primary {
  flex: 1; padding: 9px; border-radius: 8px; border: 0; cursor: pointer; font-family: inherit;
  background: var(--acc2); color: #fff; font-weight: 700; font-size: 13px;
}
.btn-ghost {
  padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); cursor: pointer;
  background: transparent; color: var(--tx2); font-family: inherit; font-size: 12px;
}
.svy-saved { font-size: 11.5px; color: var(--acc2); }

/* 전역 검색 */
#search-wrap {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 12;
  width: min(420px, calc(100% - 220px));
}
#search-input {
  width: 100%; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
  color: var(--tx); font-size: 13px; font-family: inherit; outline: none;
  box-shadow: 0 4px 16px rgba(23,30,45,.10);
}
#search-input:focus { border-color: var(--acc2); }
#search-results {
  margin-top: 6px; max-height: 46vh; overflow-y: auto;
  background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(23,30,45,.14);
}
#search-results.hidden { display: none; }
.sr-item {
  display: flex; align-items: center; gap: 9px; padding: 9px 12px; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.sr-item:last-child { border-bottom: 0; }
.sr-item:hover, .sr-item.active { background: #f2f4f8; }
.sr-badge {
  flex: 0 0 auto; font-size: 10px; padding: 2px 7px; border-radius: 9px; font-weight: 700;
  color: #fff;
}
.sr-main { min-width: 0; }
.sr-label { font-size: 13px; color: var(--tx); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-sub { font-size: 11px; color: var(--tx2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 인터뷰 뷰어 모달 */
#iv-modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(20, 26, 38, .45); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
#iv-modal.hidden { display: none; }
#iv-sheet {
  position: relative; width: min(760px, calc(100% - 48px)); height: min(84vh, 900px);
  background: #ffffff; border: 1px solid var(--line); border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 70px rgba(23,30,45,.22);
}
#iv-close { position: absolute; top: 14px; right: 16px; z-index: 2; background: none; border: 0; color: var(--tx2); font-size: 16px; cursor: pointer; }
#iv-head { padding: 22px 26px 0; }
#iv-head h2 { font-size: 21px; margin-bottom: 8px; }
#iv-head .meta { display: flex; flex-wrap: wrap; gap: 6px; }
#iv-summary {
  margin: 14px 26px 0; padding: 12px 14px; border-radius: 10px;
  background: #f2f6fd; border-left: 3px solid var(--acc2);
  font-size: 13px; line-height: 1.7; color: var(--tx);
}
#iv-summary b { color: var(--acc2); }
#iv-body {
  flex: 1; overflow-y: auto; padding: 18px 26px 30px; margin-top: 12px;
  font-size: 13.5px; line-height: 1.85; color: #3c4454;
  border-top: 1px solid var(--line);
}
#iv-body .spk { color: var(--acc); font-weight: 700; }
#iv-body .ts { color: #98a0ad; font-size: 11px; margin-left: 6px; }
#iv-body .wl { color: #2b7de0; }
#iv-body p { margin: 0 0 10px; }
#iv-body blockquote { color: var(--tx2); border-left: 2px solid var(--line); padding-left: 10px; margin: 8px 0; font-size: 12.5px; }
#iv-body hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.iv-loading { color: var(--tx2); text-align: center; padding: 40px 0; }

a.plink {
  display: inline-block; font-size: 12px; color: #c9791e; text-decoration: none;
  border: 1px solid #ead9bd; border-radius: 8px; padding: 6px 10px; margin-top: 2px;
}
a.plink:hover { background: #fdf3e6; border-color: #c9791e; }

/* ── 타임바 ── */
#timebar {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 6;
  width: min(680px, calc(100% - 48px));
  background: rgba(255,255,255,.94); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px;
  display: flex; align-items: center; gap: 12px;
  transition: opacity .3s, transform .3s;
}
#timebar.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(12px); }

/* ── 준공연도 히스토그램 브러시 (연대기 모드) — Urban Layers식 범위 필터 ── */
#yr-histo {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 84px; z-index: 6;
  width: min(680px, calc(100% - 48px)); height: 74px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 14px; padding: 8px 14px 6px;
  transition: opacity .3s, transform .3s;
}
/* 숨김 시 자식(pointer-events:auto인 #yh-count 등)까지 확실히 차단 —
   부모의 none은 auto 자식에 뚫려 투명한 채 지도 조작을 가로챈다 */
#yr-histo.hidden, #yr-histo.hidden * { opacity: 0; pointer-events: none !important; }
#yr-histo.hidden { transform: translateX(-50%) translateY(12px); }
#yr-histo.solo { bottom: 16px; }   /* 준공연도 단독 선택 — 타임바 자리로 내려앉음 */
#yh-canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
#yh-play {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%); z-index: 3;
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--acc2);
  background: rgba(255,255,255,.92); color: var(--acc2); font-size: 10px; cursor: pointer;
}
#yh-play.on { background: var(--acc2); color: #fff; }
.yh-handle {
  position: absolute; top: 4px; bottom: 4px; width: 18px; margin-left: -9px;
  cursor: ew-resize; touch-action: none; z-index: 2;
}
.yh-handle::after {           /* 세로 그립선 */
  content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px;
  background: var(--acc2); border-radius: 1px; box-shadow: 0 0 6px rgba(49,130,246,.45);
}
.yh-handle .flag {            /* 연도 깃발 (Urban Layers의 1766/1946 태그) */
  position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  background: var(--acc2); color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 1px 5px; border-radius: 4px; font-variant-numeric: tabular-nums;
  white-space: nowrap; pointer-events: none;
}
#yh-count {
  position: absolute; right: 12px; top: 6px; font-size: 11px; color: var(--tx2);
  background: rgba(255,255,255,.9); padding: 2px 7px; border-radius: 6px; pointer-events: auto;
}
#play-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--acc2);
  background: transparent; color: var(--acc2); font-size: 13px; cursor: pointer; flex: 0 0 36px;
}
#play-btn.on { background: var(--acc2); color: #fff; }
#timebar.chrono #day-strip {
  background: linear-gradient(90deg, #3a3f52 0%, #4a4160 40%, #7c5a86 70%, #e8a25c 100%);
}
/* 시간축 4단 — 주간(평일 블루→주말 호박)·한달(계절 순환)·일년(연대기와 동일 톤) 트랙 */
#timebar.wk #day-strip {
  background: linear-gradient(90deg, #7ea4e8 0%, #7ea4e8 62%, #e8a25c 74%, #e0906a 100%);
}
#timebar.mo #day-strip {
  background: linear-gradient(90deg, #9db8e6 0%, #a8d29a 26%, #f2c66d 52%, #e09b52 76%, #9db8e6 100%);
}
#timebar.yrx #day-strip {
  background: linear-gradient(90deg, #3a3f52 0%, #4a4160 40%, #7c5a86 70%, #e8a25c 100%);
}
#slider-wrap { flex: 1; position: relative; height: 42px; }
#day-strip {
  position: absolute; left: 0; right: 0; bottom: 5px; height: 6px; border-radius: 3px; pointer-events: none;
  background: linear-gradient(90deg,
    #1b2440 0%, #1b2440 18%, #7a5a86 25%, #f2c66d 33%,
    #cfe3ee 50%, #f2c66d 71%, #b95f6a 79%, #1b2440 88%, #1b2440 100%);
  opacity: .8;
}
/* 트랙 배경 곡선 — 공공: 생활인구 / 현장: 영업 중 점포 수 / 연대기: 영업 점포 수 추이 */
#track-curve { position: absolute; inset: 0 0 12px; width: 100%; height: calc(100% - 12px); pointer-events: none; }
/* 썸(원)이 하단 색상바 위에 딱 얹히도록 — 입력을 바닥 정렬 16px로 (썸 18px 중심 ≈ 바닥 8px = 색띠 중앙) */
#time-slider { position: absolute; left: 0; right: 0; bottom: 0; top: auto; height: 16px; width: 100%; -webkit-appearance: none; background: transparent; cursor: pointer; }
#time-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--acc2), 0 2px 6px rgba(23,30,45,.28);
  margin-top: 0;
}
#time-label { font-size: 16px; font-variant-numeric: tabular-nums; width: 52px; text-align: center; font-weight: 300; }
#daytype { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
#daytype button { padding: 6px 10px; font-size: 11.5px; border: 0; background: transparent; color: var(--tx2); cursor: pointer; font-family: inherit; }
#daytype button.active { background: var(--bg2); color: var(--acc2); }

/* ── 우측 컨텍스트 패널 (그래프 확대 — 폭 352px, 카드 여백 확대) ── */
#context {
  width: 352px; flex: 0 0 352px; height: 100%; overflow-y: auto;
  background: var(--bg); border-left: 1px solid var(--line); position: relative;
  padding: 18px 16px;
}
#context.hidden { display: none; }
#ctx-close { position: absolute; top: 10px; right: 10px; z-index: 2; background: none; border: 0; color: var(--tx2); font-size: 14px; cursor: pointer; }
#ctx-body { display: flex; flex-direction: column; gap: 14px; }
#ctx-body h2 { font-size: 17px; line-height: 1.3; padding-right: 20px; }
#ctx-body .tag { display: inline-block; font-size: 10.5px; padding: 2px 8px; border-radius: 10px; background: var(--bg2); color: var(--tx2); margin-right: 4px; }
#ctx-body .desc { font-size: 12.5px; color: var(--tx2); line-height: 1.65; }
#ctx-body .kv { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#ctx-body .kv > div { background: var(--bg2); border-radius: 8px; padding: 8px 10px; }
#ctx-body .kv b { display: block; font-size: 15px; font-weight: 600; }
#ctx-body .kv span { font-size: 10px; color: var(--tx2); }
#ctx-body canvas { width: 100%; border-radius: 10px; background: var(--bg2); }
#ctx-body h4 { font-size: 14px; color: #48505e; font-weight: 700; margin-top: 6px; }
/* 카드 출처 각주 — 카드 캔버스 바로 아래에 붙는 작은 글씨 */
#ctx-body .srcnote { font-size: 11px; color: #8a8f9a; line-height: 1.5; margin-top: -6px; }
/* HTML 시간축 카드 (행사 목록·사진 그리드) */
#ctx-body .tx-html { border-radius: 10px; background: var(--bg2); padding: 10px 12px; }
.tx-evhead { font-size: 12px; font-weight: 700; color: var(--acc2); margin-bottom: 6px; }
.tx-evlist { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.tx-evlist li { font-size: 12.5px; color: var(--tx); line-height: 1.5; padding-left: 14px; position: relative; }
.tx-evlist li::before { content: "•"; position: absolute; left: 2px; color: #d97a2e; }
.tx-photogrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tx-photogrid img { width: 100%; height: 74px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; background: #e8eaef; }
.tx-photogrid img:hover { outline: 2px solid var(--acc2); }

.edge-card {
  border: 1px solid var(--line); border-left: 3px solid var(--c, #888);
  border-radius: 8px; padding: 8px 10px; cursor: pointer; transition: background .12s;
}
.edge-card:hover { background: var(--bg2); }
.edge-card .eh { display: flex; justify-content: space-between; font-size: 11px; color: var(--tx2); margin-bottom: 3px; }
.edge-card .et { font-weight: 600; color: var(--c, #aaa); }
.edge-card .target { font-size: 13px; font-weight: 600; }
.edge-card .st { font-size: 11.5px; color: var(--tx2); line-height: 1.5; margin-top: 3px; }
.edge-card .src { font-size: 10px; color: #7b8494; margin-top: 4px; }

/* ── 스토리 오버레이 ── */
#story-ov {
  position: absolute; left: 18px; top: 18px; bottom: 90px; z-index: 7; width: 330px;
  background: rgba(20,21,26,.93); backdrop-filter: blur(10px);
  border: 1px solid #34384a; color: #e8e6e0; border-radius: 14px; padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
#story-ov.hidden { display: none; }
#story-close { position: absolute; top: 12px; right: 12px; background: none; border: 0; color: var(--tx2); cursor: pointer; font-size: 14px; }
#story-head h2 { font-size: 19px; margin-bottom: 6px; }
#story-head p { font-size: 12px; color: var(--tx2); line-height: 1.6; }
#story-body { flex: 1; overflow-y: auto; }
#story-body .step-text { font-size: 14.5px; line-height: 1.8; color: var(--tx); }
#story-body .step-node { font-size: 11px; color: var(--acc); margin-bottom: 8px; letter-spacing: .05em; }
#story-nav { display: flex; align-items: center; justify-content: space-between; }
#story-nav button { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg2); color: var(--tx); cursor: pointer; font-size: 15px; }
#story-nav button:disabled { opacity: .3; cursor: default; }
#story-dots { display: flex; gap: 6px; }
#story-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
#story-dots i.on { background: var(--acc); }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* ── AI 챗봇 ── */
#chat-btn { top: 328px; }
#chat-panel {
  position: absolute; right: 10px; top: 376px; bottom: 70px; width: 360px; z-index: 8;
  display: flex; flex-direction: column;
  background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 6px 22px rgba(23,30,45,.13);
}
#chat-panel.hidden { display: none; }
#chat-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--line); font-weight: 700; font-size: 13px;
}
#chat-head small { color: var(--tx2); font-weight: 400; margin-left: 2px; }
#chat-cost { margin-left: auto; color: var(--acc2); font-size: 11px; font-weight: 400; }
#chat-close { background: none; border: none; color: var(--tx2); cursor: pointer; font-size: 14px; }
#chat-close:hover { color: var(--tx); }
#chat-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 92%; padding: 8px 11px; border-radius: 11px; font-size: 12.5px; line-height: 1.55; }
.chat-msg.user { align-self: flex-end; background: #e7f0ff; }
.chat-msg.bot { align-self: flex-start; background: var(--bg2); border: 1px solid var(--line); }
.chat-msg.bot.err { border-color: #e5a1a1; color: #b3402e; }
.chat-msg.chips { align-self: flex-start; background: none; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.chat-chip {
  font-size: 11px; padding: 3px 8px; border-radius: 20px;
  background: #eaf2ff; border: 1px solid #cadefb; color: #2465c8;
}
.chat-msg .cq { color: var(--acc); font-style: normal; }
.chat-msg.typing { align-self: flex-start; background: var(--bg2); border: 1px solid var(--line); }
.dots i { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--tx2); margin: 0 2px; animation: chatdot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes chatdot { 0%, 60%, 100% { opacity: .3 } 30% { opacity: 1 } }
#chat-inputrow { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
#chat-input {
  flex: 1; resize: none; background: var(--bg); color: var(--tx);
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font-size: 12.5px;
  font-family: inherit; outline: none;
}
#chat-input:focus { border-color: var(--acc2); }
#chat-send {
  width: 40px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--acc2); cursor: pointer; font-size: 14px;
}
#chat-send:disabled { opacity: .4; cursor: default; }

/* ── 용적률 출처·결측 사유 표기 ── */
.fsrc {
  margin-top: 8px; padding: 8px 10px; border-radius: 8px;
  font-size: 11.5px; line-height: 1.5; color: var(--tx2);
  border: 1px solid var(--line); border-left-width: 3px;
}
.fsrc.ledger { border-left-color: #3182f6; }
.fsrc.est { border-left-color: #e8a25c; }
.fsrc.missing { border-left-color: #8a8f9c; background: rgba(138,143,156,.07); }
.fsrc b { color: var(--tx); }
#legend .lnote { font-size: 10.5px; color: var(--tx2); line-height: 1.5; margin-top: 4px; }

/* ── 데이터 출처 ⓘ 아이콘 + 호버 툴팁 ─────────────────────── */
.info-i {
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; margin-left: 5px; flex: none;
  border: 1px solid var(--tx2); border-radius: 50%;
  font: italic bold 9px/1 Georgia, serif; color: var(--tx2);
  cursor: help; vertical-align: 1px; user-select: none;
}
.info-i:hover { color: var(--acc2); border-color: var(--acc2); }
#tipbox {
  position: fixed; z-index: 99; max-width: 276px;
  background: #20222a; border: 1px solid #3a3d47; border-radius: 8px;
  padding: 9px 11px; font-size: 11.5px; line-height: 1.6; color: #d8dae0;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45); pointer-events: none;
}
#tipbox b { color: #fff; }
#tipbox.hidden { display: none; }

/* ── 현장조사 지도 모드 ─────────────────────────────────── */
.ltab.fw b { color: var(--acc); }
.ltab.fw.active { border-color: var(--acc); }
#panel-fw .chips { display: flex; flex-wrap: wrap; gap: 5px; }
#panel-fw .chip.off { opacity: .38; cursor: default; }
#panel-fw .chip small { margin-left: 3px; color: var(--tx2); }
#fw-zonemap { margin-top: 10px; }
#fw-zonemap img { display: block; }
.fw-hours { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.fw-hours td { padding: 3px 6px 3px 0; border-bottom: 1px solid var(--line); }
.fw-hours td:first-child { color: var(--tx2); white-space: nowrap; width: 40%; }

/* ── 데이터 모드 토글 (공공 ⇄ 현장) ───────────────────────── */
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#mode-toggle { display: flex; align-items: center; gap: 7px; flex: none; }
#mode-toggle .mt-label {
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  color: var(--tx2); cursor: pointer; transition: color .25s; user-select: none;
}
#mode-toggle .mt-label.on[data-mode="public"] { color: var(--acc2); }
#mode-toggle .mt-label.on[data-mode="field"] { color: var(--acc); }
#mode-switch {
  position: relative; width: 40px; height: 22px; flex: none;
  border-radius: 999px; border: 1px solid rgba(49, 130, 246, .5);
  background: rgba(49, 130, 246, .18); cursor: pointer; padding: 0;
  transition: background .28s, border-color .28s;
}
#mode-switch .knob {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--acc2);
  box-shadow: 0 1px 4px rgba(23, 30, 45, .3);
  transition: transform .28s cubic-bezier(.34, 1.3, .5, 1), background .28s;
}
#mode-switch.field { background: rgba(232, 162, 92, .25); border-color: rgba(232, 162, 92, .6); }
#mode-switch.field .knob { transform: translateX(18px); background: var(--acc); }
#mode-switch:hover .knob { box-shadow: 0 1px 6px rgba(23, 30, 45, .35), 0 0 0 4px rgba(49, 130, 246, .12); }

/* ── 카드 슬라이드 인 ─────────────────────────────────────── */
@keyframes ctx-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
#context.pop { animation: ctx-in .22s cubic-bezier(.25,.8,.35,1); }

/* ── 사진 스켈레톤 (로드 전 시머) ─────────────────────────── */
.fw-photo {
  height: 190px; object-fit: cover; object-position: center 35%;
  background: linear-gradient(100deg, #e9ecf2 40%, #f5f7fb 50%, #e9ecf2 60%);
  background-size: 220% 100%;
  animation: ph-shimmer 1.3s linear infinite;
  cursor: zoom-in;
}
.fw-photo.ld { animation: none; background: #e9ecf2; }
@keyframes ph-shimmer { from { background-position: 130% 0; } to { background-position: -90% 0; } }

/* ── 라이트박스 ───────────────────────────────────────────── */
#lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(8, 9, 12, .88); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
#lightbox.hidden { display: none; }
#lb-img {
  max-width: 86vw; max-height: 86vh; border-radius: 12px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .6); animation: ctx-in .18s ease-out;
}
#lb-close, #lb-prev, #lb-next {
  position: absolute; background: rgba(30, 32, 40, .8); color: #e8eaf0;
  border: 1px solid rgba(255, 255, 255, .14); border-radius: 50%;
  width: 44px; height: 44px; font-size: 20px; cursor: pointer; z-index: 2;
  display: flex; align-items: center; justify-content: center;
}
#lb-close { top: 22px; right: 24px; }
#lb-prev { left: 26px; top: 50%; transform: translateY(-50%); font-size: 26px; }
#lb-next { right: 26px; top: 50%; transform: translateY(-50%); font-size: 26px; }
#lb-close:hover, #lb-prev:hover, #lb-next:hover { background: rgba(60, 64, 78, .9); }
#lb-cap {
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  color: #dde0e8; font-size: 13px; background: rgba(14, 15, 20, .72);
  padding: 7px 14px; border-radius: 999px; white-space: nowrap;
}
#lb-cap span { color: var(--tx2); margin-left: 6px; }
#lb-cap a { color: var(--acc2); text-decoration: none; }

/* 현장조사 요약 한 줄 */
.fw-stats { font-size: 12.5px; color: var(--tx2); display: flex; align-items: center; }
.fw-stats b { color: var(--tx); font-size: 15px; margin: 0 3px; }

/* ── 잉크 번짐 전환 + 현장 출처 칩 ─────────────────────────── */
.mode-sweep {
  position: absolute; top: -12%; bottom: -12%; left: 0; width: 46%;
  z-index: 60; pointer-events: none; will-change: transform;
  backdrop-filter: blur(5px) saturate(1.25) brightness(1.06);
  -webkit-backdrop-filter: blur(5px) saturate(1.25) brightness(1.06);
}
.mode-sweep.to-field {
  background: linear-gradient(90deg,
    rgba(232, 162, 92, 0) 0%, rgba(232, 162, 92, .16) 26%,
    rgba(255, 244, 226, .34) 50%,
    rgba(232, 162, 92, .16) 74%, rgba(232, 162, 92, 0) 100%);
}
.mode-sweep.to-public {
  background: linear-gradient(90deg,
    rgba(77, 208, 196, 0) 0%, rgba(77, 208, 196, .15) 26%,
    rgba(228, 250, 248, .32) 50%,
    rgba(77, 208, 196, .15) 74%, rgba(77, 208, 196, 0) 100%);
}
.fw-srcs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.fw-src {
  font-size: 10.5px; padding: 3px 9px; border-radius: 999px;
  background: #f6f8fb; border: 1px solid var(--line); color: var(--tx2);
  white-space: nowrap;
}
.fw-src.ok { color: #2465c8; border-color: rgba(49, 130, 246, .35); background: rgba(49, 130, 246, .07); }
.fw-src.dim { opacity: .62; }
/* 현장 사진 캡션 정리 */

/* ── 인사이트 (자동 해석 문장 — 카드·범례) ── */
.insight {
  background: #f2f6fd; border-left: 3px solid var(--acc2); border-radius: 8px;
  padding: 9px 11px; font-size: 12px; line-height: 1.7; color: #2b3242;
}
.insight .ln + .ln { margin-top: 6px; padding-top: 6px; border-top: 1px dashed #d8e2f3; }
.insight b { color: #2465c8; }
#legend .insight-ln { color: #3c4454; background: #f2f6fd; border-radius: 6px; padding: 6px 8px; margin: 6px 0 2px; }
#legend .insight-ln b { color: #2465c8; }

/* ── L2 기준 시간 단위 세그먼트 (하루/한달/일년) ── */
#l2-scale { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 2px; }
#l2-scale button {
  flex: 1; padding: 6px 0; font-size: 12px; border: 0; background: transparent;
  color: var(--tx2); cursor: pointer; font-family: inherit;
}
#l2-scale button + button { border-left: 1px solid var(--line); }
#l2-scale button.on { background: #eaf2ff; color: var(--acc2); font-weight: 700; }
#l2-scale button:disabled { opacity: .38; cursor: default; }

/* 업종 필터 — '점포 점등/소등' 항목 하위 접이식 영역 (항목 바로 아래, 들여쓰기) */
#cat-filter-wrap { margin: 2px 0 6px 24px; padding: 6px 0 4px 10px; border-left: 2px solid var(--line); }
#cat-filter-wrap.hidden { display: none; }
.cfw-head { font-size: 11.5px; font-weight: 700; color: #48505e; margin-bottom: 6px; }

/* ── 업종의 강 (연대기 스트림그래프) ── */
#stream-band {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 84px; z-index: 6;
  width: min(680px, calc(100% - 48px)); height: 158px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 14px; padding: 8px 14px 6px;
  transition: opacity .3s, transform .3s;
}
#stream-band.hidden, #stream-band.hidden * { opacity: 0; pointer-events: none !important; }
#stream-band.hidden { transform: translateX(-50%) translateY(12px); }
#sb-canvas { width: 100%; height: 100%; display: block; cursor: pointer; }
#sb-tip {
  position: absolute; pointer-events: none; z-index: 3;
  background: #1e2532; color: #f2f4f8; font-size: 11px; border-radius: 6px;
  padding: 3px 8px; white-space: nowrap; transform: translate(-50%, -130%);
}
#sb-tip.hidden { display: none; }

#sb-mode {
  position: absolute; right: 10px; top: 7px; z-index: 3;
  font-size: 10.5px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--tx2);
  cursor: pointer; font-family: inherit;
}
#sb-mode:hover { color: var(--acc2); border-color: var(--acc2); }
