/* ============================================================
   다온길 — style.css
   ============================================================ */

/* ── Reset & Variables ── */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --navy:       #0b3ba3;
  --navy-dark:  #082D82;
  --navy-light: #3A65C7;
  --safe:       #00C48C;
  --warn:       #FF7043;
  --danger:     #E53935;
  --bg:         #F4F6FB;
  --panel:      #FFFFFF;
  --text:       #1A1D2E;
  --muted:      #7B8099;
  --shadow:     0 4px 24px rgba(11, 59, 163, 0.10);
  --radius:     16px;
  --radius-sm:  10px;
  --border:     #EEF0F8;
  --input-bg:   #FAFBFF;
  --chip-off-bg:   #F5F5F5;
  --chip-off-text: #BDBDBD;
}

body.night-mode {
  --bg:            #111827;
  --panel:         #1F2937;
  --text:          #E5E7EB;
  --muted:         #9CA3AF;
  --border:        #374151;
  --input-bg:      #111827;
  --shadow:        0 4px 24px rgba(0, 0, 0, 0.40);
  --chip-off-bg:   #374151;
  --chip-off-text: #6B7280;
}

html, body {
  height: 100%;
  font-family: 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ── Layout ── */
#app      { display: flex; height: 100vh; position: relative; }
#map-wrap { flex: 1; position: relative; }
#map      { width: 100%; height: 100%; }

/* ── Sidebar ── */
#sidebar {
  width: 320px; min-width: 320px; height: 100vh;
  background: var(--panel);
  display: flex; flex-direction: column;
  z-index: 1000;
  box-shadow: 4px 0 20px rgba(0,0,0,0.08);
}

/* ── Sidebar Header ── */
.sidebar-header { padding: 20px 20px 0; border-bottom: 1px solid var(--border); flex-shrink: 0; }

.logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.logo-text { font-size: 18px; font-weight: 700; color: var(--navy); letter-spacing: -0.5px; }
.logo-sub  { font-size: 11px; color: var(--muted); font-weight: 400; }

.nav-tabs { display: flex; margin: 0 -20px; padding: 0 20px; }
.nav-tab  {
  flex: 1; text-align: center; padding: 10px 4px;
  font-size: 13px; font-weight: 500; color: var(--muted);
  cursor: pointer; border: none; background: none; font-family: inherit;
  border-bottom: 2px solid transparent; transition: all .2s;
}
.nav-tab.active { color: var(--navy); border-bottom-color: var(--navy); }
.nav-tab svg { display: block; margin: 0 auto 3px; width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* ── Tab Panels ── */
.tab-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.tab-panel.active { display: flex; }

/* 검색탭 스크롤 영역 — risk-bottom 제외하고 통째로 스크롤 */
#tab-search .scroll-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ── Search Section ── */
.search-section { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.search-label   { font-size: 11px; font-weight: 500; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }

.search-input-wrap { position: relative; margin-bottom: 10px; }
.search-dot  { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 10px; height: 10px; border-radius: 50%; z-index: 1; }
.dot-start   { background: var(--navy); }
.dot-end     { background: var(--danger); }
.search-input {
  width: 100%; padding: 10px 36px 10px 32px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; color: var(--text);
  outline: none; transition: border .2s, background .2s; background: var(--input-bg);
}
.search-input:focus       { border-color: var(--navy); background: var(--panel); }
.search-input::placeholder { color: var(--muted); font-weight: 300; }

/* 핀 버튼 */
.pin-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: background .15s; padding: 2px; z-index: 2;
}
.pin-btn:hover { background: var(--input-bg); }
.pin-btn svg   { width: 18px; height: 18px; transition: fill .2s, stroke .2s; }
.pin-btn .pin-icon        { fill: #CBD2E0; stroke: #CBD2E0; stroke-width: 0.5; }
.pin-btn.active .pin-icon { fill: var(--navy); stroke: var(--navy); }

body.picking-start #map,
body.picking-end   #map { cursor: crosshair !important; }

/* 선택 중 배너 */
.pick-banner {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: white;
  padding: 10px 20px; border-radius: 24px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 16px rgba(11,59,163,0.35);
  z-index: 1100; display: none; white-space: nowrap;
  animation: bannerIn .25s ease;
}
.pick-banner.show { display: block; }
@keyframes bannerIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Autocomplete ── */
.autocomplete-box {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--panel); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(11,59,163,0.12); z-index: 2000;
  max-height: 200px; overflow-y: auto; display: none;
}
.autocomplete-box.open { display: block; }
.autocomplete-item {
  padding: 10px 14px; font-size: 13px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  border-bottom: 1px solid var(--border); transition: background .15s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover      { background: var(--input-bg); }
.ac-name { font-weight: 600; color: var(--text); }
.ac-addr { font-size: 11px; color: var(--muted); font-weight: 400; }

/* 해결된 장소 칩 */
.resolved-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px 3px 6px; border-radius: 20px; font-size: 11px; font-weight: 600; margin-top: 4px;
}
.chip-start-res { background: #EEF2FF; color: var(--navy); }
.chip-end-res   { background: #FFEBEE; color: var(--danger); }
.chip-clear     { background: none; border: none; cursor: pointer; font-size: 13px; line-height: 1; padding: 0; color: inherit; opacity: .6; }
.chip-clear:hover { opacity: 1; }

.connector { width: 2px; height: 8px; background: #D0D5E8; margin: 0 0 0 17px; }

/* 탐색 버튼 */
.route-btn {
  width: 100%; padding: 12px; background: var(--navy); color: white;
  border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700; font-family: inherit; cursor: pointer;
  transition: all .2s; letter-spacing: 0.3px;
}
.route-btn:hover:not(:disabled)  { background: var(--navy-dark); transform: translateY(-1px); }
.route-btn:active:not(:disabled) { transform: translateY(0); }
.route-btn:disabled { background: #8BA5D4; cursor: not-allowed; }

/* ── Filter Section ── */
.filter-section { padding: 14px 20px; border-bottom: 1px solid var(--border); }
.filter-title   { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.filter-chips   { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 20px; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all .2s; border: 1.5px solid transparent; user-select: none;
}
.chip svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; }

.chip-keeper  { background: #E8F5E9; color: #2E7D32; border-color: #A5D6A7; }
.chip-keeper.off  { background: var(--chip-off-bg); color: var(--chip-off-text); border-color: var(--border); }
.chip-school  { background: #E3F2FD; color: #1565C0; border-color: #90CAF9; }
.chip-school.off  { background: var(--chip-off-bg); color: var(--chip-off-text); border-color: var(--border); }
.chip-library { background: #F3E5F5; color: #6A1B9A; border-color: #CE93D8; }
.chip-library.off { background: var(--chip-off-bg); color: var(--chip-off-text); border-color: var(--border); }
.chip-cctv    { background: #E8EAF6; color: #283593; border-color: #9FA8DA; }
.chip-cctv.off    { background: var(--chip-off-bg); color: var(--chip-off-text); border-color: var(--border); }

/* ── Result Section ── */
.result-section { padding: 16px 20px; }
.result-hidden  { display: none; }

.result-card {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  border-radius: var(--radius); padding: 18px; color: white; margin-bottom: 12px;
}
.time-row   { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.time-badge { background: rgba(255,255,255,0.18); padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.time-arrow { font-size: 14px; opacity: 0.7; }
.duration   { font-size: 32px; font-weight: 700; letter-spacing: -1px; }
.duration span { font-size: 16px; font-weight: 400; opacity: 0.8; margin-left: 4px; }
.walk-row   { display: flex; align-items: center; gap: 6px; margin-top: 6px; opacity: 0.8; font-size: 13px; }
.walk-row svg { width: 18px; height: 18px; stroke: white; fill: none; stroke-width: 1.8; }

.safety-bar   { margin-bottom: 12px; }
.safety-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; justify-content: space-between; }
.bar-track    { background: var(--border); border-radius: 4px; height: 8px; overflow: hidden; }
.bar-fill     { height: 100%; border-radius: 4px; transition: width 1.5s ease; }
.bar-safe     { background: linear-gradient(90deg, var(--safe), #00E5B2); }
.safety-score { font-weight: 700; color: var(--safe); }

/* ── Loading ── */
.inline-loading {
  display: none; flex-direction: column; align-items: center;
  justify-content: center; padding: 32px 20px; text-align: center;
}
.inline-loading.show { display: flex; }
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--navy); border-radius: 50%;
  animation: spin 0.9s linear infinite; margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; font-weight: 600; color: var(--navy); }
.loading-sub  { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Risk Bottom Bar ── */
.risk-bottom   { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--panel); flex-shrink: 0; }
.toggle-row    { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.toggle-label  { font-size: 13px; font-weight: 600; color: var(--text); }
.toggle-wrap   { display: flex; align-items: center; gap: 8px; }
.toggle        { position: relative; width: 44px; height: 24px; }
.toggle input  { opacity: 0; width: 0; height: 0; }
.slider        { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #CBD2E0; border-radius: 24px; transition: .3s; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: .3s; }
input:checked + .slider         { background: var(--navy); }
input:checked + .slider:before  { transform: translateX(20px); }
.toggle-text   { font-size: 11px; font-weight: 700; color: var(--navy); }

.risk-legend        { display: flex; align-items: center; gap: 8px; }
.risk-grad-bar      { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #43A047, #FDD835, #E53935); }
.risk-legend-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 3px; }

/* ── Map Buttons ── */
.map-btn {
  position: absolute; z-index: 900; background: white;
  border: none; border-radius: 10px; cursor: pointer;
  box-shadow: var(--shadow); transition: all .2s;
  display: flex; align-items: center; justify-content: center;
}
.map-btn:hover { transform: scale(1.05); }
.map-btn svg   { width: 20px; height: 20px; stroke: #333; fill: none; stroke-width: 1.8; }

.btn-locate { width: 44px; height: 44px; right: 16px; bottom: calc(114px + 155px + 10px); }
.btn-night  { width: 44px; height: 44px; right: 16px; bottom: 64px; }
.btn-night svg { width: 22px; height: 22px; }

/* ── Safety Weight Slider ── */
.safew-slider-wrap {
  position: absolute; z-index: 900;
  right: 16px; bottom: 114px;
  display: none; flex-direction: column; align-items: center;
  gap: 4px; height: 130px;
}.safew-label {
  font-size: 10px; font-weight: 500; color: var(--muted);
  line-height: 1; user-select: none;
}
.safew-track {
  flex: 1; position: relative; width: 44px;
  background: white; border-radius: 22px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.safew-input {
  -webkit-appearance: slider-vertical;
  appearance: slider-vertical;
  writing-mode: vertical-lr;
  direction: rtl;
  width: 6px; height: 100%;
  cursor: pointer; outline: none; border: none;
  background: transparent;
  accent-color: var(--navy);
}
/* Firefox vertical range */
@supports (-moz-appearance: none) {
  .safew-input {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 100%; height: 100%;
    -moz-orient: vertical;
  }
}
body.night-mode .safew-track { background: #1F2937; box-shadow: 0 4px 16px rgba(0,0,0,0.5); }

body.night-mode .btn-night     { background: #1F2937; box-shadow: 0 4px 16px rgba(0,0,0,0.5); }
body.night-mode .btn-night svg { stroke: #FBBF24; }

/* ── Empty State ── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 20px; text-align: center; }
.empty-icon  { width: 64px; height: 64px; background: #EEF2FF; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.empty-icon svg { width: 32px; height: 32px; stroke: var(--navy); fill: none; stroke-width: 1.5; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-desc  { font-size: 13px; color: var(--muted); line-height: 1.6; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1A1D2E; color: white;
  padding: 12px 20px; border-radius: 10px; font-size: 14px; z-index: 9999;
  opacity: 0; transform: translateY(10px); transition: all .3s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── Night Mode Overlay ──
   #map 내부로 옮겨서 zIndex로 해결하려던 시도는 카카오맵 내부 렌더링과 충돌해서
   화면 전체에 이상한 원형 패턴이 뜨는 부작용이 있었음 -> 원래대로 형제 엘리먼트로 되돌림.
   대신 시설아이콘/출발도착팝업/경로선이 안 가려지도록 nightMode.js에서
   해당 위치에도 가로등처럼 마스크 구멍을 뚫어줌. */
#night-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 500; display: none; }
#night-overlay svg { width: 100%; height: 100%; }
body.night-mode #night-overlay { display: block; }

/* ── Leaflet Overrides ── */
.leaflet-control-zoom                          { display: none; }
.leaflet-popup-content-wrapper                 { border-radius: 10px; box-shadow: var(--shadow); font-family: 'Noto Sans KR', sans-serif; }
.leaflet-popup-content                         { font-size: 13px; font-weight: 500; padding: 6px 4px; }
body.night-mode .leaflet-popup-content-wrapper { background: #1F2937; color: #E5E7EB; border: 1px solid #374151; }
body.night-mode .leaflet-popup-tip             { background: #1F2937; }
body.night-mode .map-btn                       { background: #1F2937; box-shadow: 0 4px 16px rgba(0,0,0,0.5); }

/* ============================================================
   북마크 탭
   ============================================================ */
.bm-add-section { padding: 16px 20px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.bm-add-label   { font-size: 11px; font-weight: 500; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .5px; }

.bm-meta-row   { display: flex; align-items: center; gap: 8px; margin-top: 10px; position: relative; }
.bm-color-picker { position: relative; flex-shrink: 0; }
.bm-color-btn {
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
  border: 2px solid rgba(0,0,0,0.10); transition: transform .15s, box-shadow .15s;
  flex-shrink: 0; box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.bm-color-btn:hover { transform: scale(1.06); box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.bm-color-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  background: var(--panel); border: 1.5px solid var(--border); border-radius: 10px;
  padding: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.14); z-index: 3000;
  gap: 6px; flex-wrap: nowrap; width: 172px;
}
.bm-color-dropdown.open { display: flex; }
.bm-color-swatch {
  width: 20px; height: 20px; border-radius: 5px; cursor: pointer;
  border: 2px solid transparent; transition: transform .12s, border-color .12s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.bm-color-swatch:hover    { transform: scale(1.15); }
.bm-color-swatch.selected { border-color: var(--text); transform: scale(1.12); }

.bm-name-input {
  flex: 1; padding: 8px 10px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; color: var(--text); background: var(--input-bg);
  outline: none; transition: border .2s; min-width: 0;
}
.bm-name-input:focus       { border-color: var(--navy); }
.bm-name-input::placeholder { color: var(--muted); }

.bm-add-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1.5px solid var(--border);
  background: var(--input-bg); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 22px; line-height: 1; transition: all .2s;
}
.bm-add-btn:hover { border-color: var(--navy); color: var(--navy); background: var(--panel); }

.bm-list-section { flex: 1; overflow-y: auto; padding: 10px 20px; }
.bm-empty        { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; gap: 10px; }
.bm-empty svg    { opacity: .3; }

.bm-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px;
  border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--panel); margin-bottom: 8px; transition: border-color .2s;
}
.bm-item:hover      { border-color: var(--navy); }
.bm-item-dot        { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.bm-item-info       { flex: 1; min-width: 0; }
.bm-item-name       { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 1px; }
.bm-item-addr       { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-item-actions    { display: flex; gap: 4px; flex-shrink: 0; }
.bm-icon-btn        { width: 28px; height: 28px; border-radius: 6px; border: none; background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.bm-icon-btn:hover  { background: var(--border); }
.bm-icon-btn svg    { width: 15px; height: 15px; stroke: var(--muted); fill: none; stroke-width: 1.8; }
.bm-icon-btn.del:hover svg { stroke: var(--danger); }

.bm-edit-wrap { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px 10px; border-radius: var(--radius-sm); border: 1.5px solid var(--navy); background: var(--panel); margin-bottom: 8px; }
.bm-edit-row  { display: flex; align-items: center; gap: 6px; width: 100%; box-sizing: border-box;}
.bm-edit-name { flex: 1; min-width: 0; padding: 6px 8px; border: 1.5px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit; color: var(--text); background: var(--input-bg); outline: none; }
.bm-edit-name:focus { border-color: var(--navy); }
.bm-save-btn  { padding: 5px 10px; border-radius: 6px; border: none; background: var(--navy); color: white; font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer; }

/* 자동완성 내 북마크 항목 */
.ac-bm-header { padding: 6px 14px 4px; font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: .5px; text-transform: uppercase; border-top: 1px solid var(--border); }
.ac-bm-item   { padding: 8px 14px; cursor: pointer; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); transition: background .15s; }
.ac-bm-item:last-child { border-bottom: none; }
.ac-bm-item:hover      { background: var(--input-bg); }
.ac-bm-dot             { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.ac-bm-texts           { flex: 1; min-width: 0; }
.ac-bm-name            { font-size: 13px; font-weight: 700; color: var(--text); }
.ac-bm-addr            { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   의견 탭
   ============================================================ */

/* 분류 버튼 */
.fb-cat-btn {
  flex: 1; padding: 10px 0;
  border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--input-bg); color: var(--muted);
  font-size: 13px; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: all .2s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.fb-cat-btn.fb-cat-active {
  border-color: var(--navy); background: var(--navy); color: white;
}

/* 위치 첨부 버튼 */
.fb-loc-btn {
  flex: 1; padding: 9px 0;
  border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--input-bg); color: var(--text);
  font-size: 12px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all .2s;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.fb-loc-btn:hover { border-color: var(--navy); }

/* 제목 입력 */
.fb-text-input {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; color: var(--text);
  background: var(--input-bg); outline: none; transition: border .2s;
}

/* 첨부파일 레이블 */
.fb-file-label {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 13px;
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: border .2s; background: var(--input-bg);
}
.fb-file-label:hover { border-color: var(--navy); }

/* 본문 textarea */
.fb-textarea {
  width: 100%; height: 140px; padding: 10px 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; color: var(--text);
  background: var(--input-bg); outline: none; resize: none; line-height: 1.7;
  transition: border .2s;
}

/* 전송 버튼 */
.fb-submit-btn {
  width: 100%; padding: 13px;
  background: var(--navy); color: white; border: none;
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: all .2s; letter-spacing: 0.3px;
}
.fb-submit-btn:hover { background: var(--navy-dark); transform: translateY(-1px); }

/* ============================================================
   정보 탭
   ============================================================ */
.info-scroll        { flex: 1; overflow-y: auto; padding: 20px; }
.info-section       { margin-bottom: 20px; border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.info-section-title { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .5px; text-transform: uppercase; padding: 10px 14px 8px; background: var(--input-bg); border-bottom: 1px solid var(--border); }
.info-row           { display: flex; align-items: flex-start; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-row-label     { font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap; flex-shrink: 0; min-width: 70px; margin-top: 1px; }
.info-row-value     { color: var(--text); font-weight: 500; line-height: 1.5; word-break: break-all; }
.info-row-value a   { color: var(--navy); text-decoration: none; }
.info-row-value a:hover { text-decoration: underline; }
.info-copyright     { font-size: 11px; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); line-height: 1.5; }

/* 정보 탭 — 2×2 버튼 그리드 */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 20px 20px; }
.info-grid-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  padding: 18px 10px 14px; border-radius: var(--radius); border: 1.5px solid var(--border);
  background: var(--panel); cursor: pointer; transition: all .2s; font-family: inherit; color: var(--text);
}
.info-grid-btn:hover { border-color: var(--navy); background: var(--input-bg); transform: translateY(-1px); box-shadow: var(--shadow); }
.info-grid-btn svg   { width: 26px; height: 26px; stroke: var(--navy); fill: none; stroke-width: 1.7; }
.ig-label { font-size: 13px; font-weight: 700; color: var(--text); }
.ig-sub   { font-size: 10px; color: var(--muted); font-weight: 400; text-align: center; line-height: 1.4; }

/* 정보 탭 모달 */
.info-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 9000; display: none; align-items: center; justify-content: center; }
.info-modal-overlay.open { display: flex; }
.info-modal {
  width: 340px; max-height: 80vh; background: var(--panel); border-radius: var(--radius);
  box-shadow: 0 12px 48px rgba(11,59,163,0.22); display: flex; flex-direction: column; overflow: hidden;
}
.info-modal-header  { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.info-modal-title   { font-size: 15px; font-weight: 700; color: var(--text); }
.info-modal-close   { width: 28px; height: 28px; border: none; background: none; cursor: pointer; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 20px; line-height: 1; transition: background .15s; }
.info-modal-close:hover { background: var(--border); }
.info-modal-body    { flex: 1; overflow-y: auto; padding: 16px 18px 20px; }
.info-modal-text    { font-size: 13px; color: var(--text); line-height: 1.8; white-space: pre-line; }
.info-modal-loading { font-size: 13px; color: var(--muted); text-align: center; padding: 24px 0; }

/* 데이터 출처 */
.info-datasource-item       { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 12px; }
.info-datasource-item:last-child { border-bottom: none; }
.info-datasource-name       { font-weight: 600; color: var(--text); margin-bottom: 3px; }
.info-datasource-link       { color: var(--navy); font-size: 11px; word-break: break-all; text-decoration: none; }
.info-datasource-link:hover { text-decoration: underline; }

/* 후원 */
.donate-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.donate-item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--input-bg); }
.donate-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.donate-name { font-size: 13px; font-weight: 700; color: var(--text); }
.donate-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* 패치 노트 아코디언 */
.patch-list           { display: flex; flex-direction: column; gap: 8px; }
.patch-major          { border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.patch-major-header   { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; cursor: pointer; background: var(--input-bg); transition: background .15s; user-select: none; }
.patch-major-header:hover { background: var(--border); }
.patch-major-ver      { font-size: 14px; font-weight: 700; color: var(--navy); font-family: 'Bebas Neue', sans-serif; letter-spacing: 1px; }
.patch-major-title    { font-size: 12px; font-weight: 500; color: var(--text); flex: 1; margin: 0 10px; }
.patch-chevron        { width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 2; transition: transform .25s; flex-shrink: 0; }
.patch-major.open .patch-chevron { transform: rotate(180deg); }
.patch-major-body     { display: none; padding: 0 14px 10px; }
.patch-major.open .patch-major-body { display: block; }
.patch-minor-list     { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.patch-minor-item     { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.patch-minor-item:last-child { border-bottom: none; }
.patch-minor-ver      { font-size: 10px; font-weight: 700; color: var(--muted); white-space: nowrap; font-family: 'Bebas Neue', sans-serif; letter-spacing: .5px; min-width: 32px; }
.patch-minor-desc     { font-size: 11px; color: var(--muted); line-height: 1.5; font-weight: 400; }
/* ============================================================
   모바일 바텀시트 (≤768px)
   ============================================================ */
@media (max-width: 768px) {

  #app { flex-direction: column; }

  #map-wrap {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    height: 100vh;
    width: 100%;
    z-index: 1;
  }

  #sidebar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: 100%;
    min-width: unset;
    height: 85vh;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 30px rgba(11, 59, 163, 0.15);
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  /* 드래그 핸들 */
  .sheet-handle {
    width: 40px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 10px auto 6px;
    flex-shrink: 0;
    cursor: grab;
  }

  .sidebar-header {
    padding: 4px 20px 0;
    flex-shrink: 0;
  }

  .logo-row { margin-bottom: 8px; }
  .logo-text { font-size: 16px; }

  /* 탭패널 — 남은 높이 전부 사용하며 세로 스크롤 */
  .tab-panel.active {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
  }



  /* 위험도맵 바 — 하단 고정 */
  .risk-bottom {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: var(--panel);
  }

  /* 지도 버튼 위치 */
  .btn-locate { right: 12px; bottom: calc(85vh + 16px); }
  .btn-night  { right: 12px; bottom: calc(85vh + 66px); }
  .safew-slider-wrap { right: 12px; bottom: calc(85vh + 120px); }

  /* 토스트 */
  .toast {
    bottom: calc(85vh + 10px);
    left: 16px; right: 16px;
    text-align: center;
  }

  /* 정보모달 */
  .info-modal {
    width: calc(100vw - 32px);
    max-height: 70vh;
  }
}

/* ============================================================
   시설 마커 팝업 (학교·도서관)
   ============================================================ */
.facility-popup {
  position: relative;
  background: #ffffff;
  border-radius: 14px;
  padding: 14px 16px 12px;
  min-width: 210px;
  max-width: 260px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18), 0 1px 6px rgba(0, 0, 0, 0.10);
  font-family: 'Noto Sans KR', sans-serif;
  pointer-events: auto;
  /* 아래 꼬리 */
  filter: drop-shadow(0 6px 18px rgba(0,0,0,0.13));
}

/* 말풍선 꼬리 */
.facility-popup::after {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 10px solid #ffffff;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,0.08));
}

.facility-popup-name {
  font-size: 13px;
  font-weight: 700;
  color: #1A1D2E;
  margin-bottom: 4px;
  padding-right: 20px;
  line-height: 1.4;
  word-break: keep-all;
}

.facility-popup-addr {
  font-size: 11px;
  color: #6B7280;
  margin-bottom: 12px;
  line-height: 1.5;
  word-break: keep-all;
}

.facility-popup-actions {
  display: flex;
  gap: 7px;
}

.fp-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: none;
  border-radius: 9px;
  padding: 8px 6px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer;
  transition: filter 0.15s, transform 0.12s;
  white-space: nowrap;
}
.fp-btn:hover  { filter: brightness(0.93); transform: translateY(-1px); }
.fp-btn:active { transform: translateY(0); }

.fp-btn-start {
  background: #EEF2FF;
  color: #0B3BA3;
}
.fp-btn-end {
  background: #FEF2F2;
  color: #E53935;
}

.fp-close {
  position: absolute;
  top: 8px;
  right: 9px;
  background: none;
  border: none;
  font-size: 14px;
  color: #9CA3AF;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s;
}
.fp-close:hover { color: #374151; }