/* ============================================================
   Beacon — 화면별 스타일 (명세서 §5 모바일 · §6 데스크톱)
   ============================================================ */

/* ============================================================
   §5.1 홈
   ============================================================ */
.red-shortcut-card {
  width: 100%;
  background: var(--red-fill);
  border: none;
  border-radius: var(--radius-card);
  padding: 15px;
  text-align: left;
  color: var(--red-on);
}
.red-shortcut-card:hover { background: var(--red-hover); }
/* 상황 카드 레벨별 색 — 현재 위협 수준을 한눈에 (RED=기본) */
.red-shortcut-card.sit-yellow { background: var(--yellow-fill); color: var(--yellow-on); }
.red-shortcut-card.sit-yellow:hover { background: #E59A1F; }
.red-shortcut-card.sit-green { background: var(--green-fill); color: var(--green-on); }
.red-shortcut-card.sit-green:hover { background: #276B2A; }
.red-shortcut-card.sit-black { background: var(--black-fill); color: var(--black-on); border: 1px solid var(--black-border); }
.red-shortcut-card.sit-black:hover { background: #2A2F36; }
.red-shortcut-card.sit-black .rc-chip { background: rgba(255, 255, 255, 0.10); }
.red-shortcut-card .rc-sub { display: block; font-size: 12.5px; line-height: 1.45; opacity: 0.92; margin-top: 7px; }
.red-shortcut-card .rc-top { display: flex; align-items: center; gap: 11px; }
.red-shortcut-card .rc-top svg { width: 26px; height: 26px; flex-shrink: 0; }
.red-shortcut-card .rc-title { font-size: 16px; font-weight: 700; flex: 1; min-width: 0; }
.red-shortcut-card .rc-tap {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px;
  opacity: 0.85; white-space: nowrap;
}
.red-shortcut-card .rc-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 11px; }
.red-shortcut-card .rc-chip {
  background: rgba(0, 0, 0, 0.30);
  border-radius: 5px;
  font-size: 11px;
  padding: 4px 9px;
  white-space: nowrap;
}

/* 비상 도구 3버튼 그리드 */
.tool-trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tool-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  min-height: 76px;
  font-size: 12px; font-weight: 600;
  color: var(--text-body);
  padding: 10px 4px;
  min-width: 0;
}
.tool-tile:hover { background: var(--surface2); border-color: var(--border-hover); }
.tool-tile svg { width: 22px; height: 22px; }
.tool-tile span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* 상황 정보 스트립 (홈) — 일몰·좌표 */
.sit-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sit-cell {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 11px 13px;
  text-align: left;
  min-width: 0;
}
.sit-cell:hover { border-color: var(--border-hover); background: var(--surface2); }
.sit-icon { color: var(--text-secondary); flex-shrink: 0; display: flex; }
.sit-icon svg { width: 20px; height: 20px; }
.sit-icon.urgent { color: var(--yellow-text); }
.sit-main { min-width: 0; }
.sit-label { display: block; font-size: 14px; font-weight: 700; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sit-label.urgent { color: var(--yellow-text); }
.sit-label.mono { font-family: var(--font-mono); font-size: 12.5px; }
.sit-sub { display: block; font-size: 11px; color: var(--text-tertiary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 준비 점검 체크 행 */
.check-row {
  display: flex; align-items: center; gap: 11px;
  width: 100%; text-align: left;
  min-height: var(--touch-min);
  padding: 8px 2px;
}
.check-row + .check-row { border-top: 1px solid var(--border); }
.check-box {
  width: 22px; height: 22px; flex-shrink: 0;
  border-radius: 6px;
  border: 1.5px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  color: var(--green-on);
}
.check-box.on { background: var(--green-fill); border-color: var(--green-fill); }
.check-box svg { width: 14px; height: 14px; }

/* 조기 경보 상황판 */
.alert-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0;
  font-size: 13px;
}
.alert-row + .alert-row { border-top: 1px solid var(--border); }
.alert-row .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.alert-row .dot.green { background: var(--green-text); }
.alert-row .dot.yellow { background: var(--yellow-text); }
.alert-row .dot.red { background: var(--red-text); }
.alert-row .a-text { flex: 1; min-width: 0; color: var(--text-body); }
.alert-row .a-time { font-family: var(--font-mono); font-size: 10px; color: var(--text-tertiary); white-space: nowrap; }
.alert-disclaimer {
  font-size: 11px; color: var(--text-tertiary);
  border-top: 1px solid var(--border);
  padding-top: 9px; margin-top: 4px;
}
/* 라이브 조기경보 */
.alert-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; padding: 4px 0 9px;
  border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.alert-status .a-text { color: var(--text-secondary); }
.alert-status.off .a-text { color: var(--yellow-text); }
.alert-item { text-decoration: none; }
.alert-item .row-title.urgent { color: var(--red-text); font-weight: 700; }
.type-badge.sev-urgent { background: var(--red-fill); color: var(--red-on); border-color: var(--red-fill); }

/* ============================================================
   §5.2 지도
   ============================================================ */
.map-screen { position: relative; height: 100%; overflow: hidden; }
.map-canvas-wrap { position: absolute; inset: 0; background: var(--map-bg); }
/* 폴백 도식 캔버스에만 적용 — Leaflet 타일 canvas(256px)에는 적용 금지 */
#map-canvas { width: 100%; height: 100%; display: block; }
#real-map { width: 100%; height: 100%; }
.map-canvas-wrap .leaflet-tile { width: 256px; height: 256px; }
.map-banner-slot { position: absolute; top: 0; left: 0; right: 0; z-index: 5; }

/* 지도 검색 (도로명·주소·지역 — 오프라인 대피소 주소 색인) */
.map-search { padding: 8px 8px 0; }
.map-search-bar {
  display: flex; align-items: center; gap: 8px;
  background: rgba(13, 17, 23, 0.95);
  border: 1px solid var(--border-strong, #444c56);
  border-radius: 10px; padding: 8px 10px;
  backdrop-filter: blur(3px);
}
.map-search-bar svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-dim, #8B949E); }
.map-search-bar input {
  flex: 1; min-width: 0; background: none; border: none; outline: none;
  color: var(--text, #C9D1D9); font-size: 13px; font-family: inherit;
}
.map-search-bar input::placeholder { color: var(--text-dim, #6e7681); }
.map-search-clear { background: none; border: none; color: var(--text-dim, #8B949E); font-size: 14px; line-height: 1; cursor: pointer; padding: 2px 4px; }
.map-search-results {
  display: none; margin-top: 6px;
  background: rgba(13, 17, 23, 0.97);
  border: 1px solid var(--border, #30363d); border-radius: 10px;
  max-height: 46vh; overflow-y: auto;
}
.map-search-results.show { display: block; }
.geo-row {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: none; border: none; border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding: 9px 11px; cursor: pointer;
}
.geo-row:last-child { border-bottom: none; }
.geo-row:hover { background: rgba(255, 255, 255, 0.05); }
.geo-ic { flex-shrink: 0; display: flex; color: var(--green-text, #7BC67E); }
.geo-ic svg { width: 16px; height: 16px; }
.geo-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.geo-name { font-size: 12.5px; font-weight: 600; color: var(--text, #C9D1D9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.geo-addr { font-size: 11px; color: var(--text-dim, #8B949E); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 결과 출처 배지 */
.geo-kind { font-size: 9.5px; font-weight: 700; padding: 1px 5px; border-radius: 3px; vertical-align: middle; white-space: nowrap; }
.geo-kind.k-addr { color: #5EEAD4; border: 1px solid #2DD4BF; }
.geo-kind.k-place { color: #9FD0FF; border: 1px solid #58A6FF; }
.geo-kind.k-shelter { color: var(--green-text, #7BC67E); border: 1px solid var(--green-fill, #2E7D32); }
.geo-kind.k-pin { color: var(--accent-info, #58A6FF); border: 1px solid var(--accent-info, #58A6FF); }
.geo-empty { padding: 12px; font-size: 12px; color: var(--text-dim, #8B949E); text-align: center; }
.geo-empty.geo-more { padding: 7px; font-size: 11px; opacity: 0.8; border-top: 1px solid rgba(255,255,255,0.05); }
.lmk-search {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  color: #fff; background: var(--accent-info, #58A6FF);
  border: 2px solid #fff; border-radius: 50%; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}
.lmk-search svg { width: 16px; height: 16px; }
/* 재해위험지구(지정) 주의 마커 — 라이브 경보가 아닌 상시 위험지역 표시 */
.lmk-hazard {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  color: #1F1500; background: var(--yellow-fill, #F9A825);
  border: 2px solid rgba(0, 0, 0, 0.35); border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.lmk-hazard svg { width: 17px; height: 17px; }
.map-layers {
  position: absolute; left: 12px; bottom: 46px; z-index: 5;
  display: flex; flex-direction: column; gap: 7px;
}
/* 지도 보조 툴바 (상단 우측 — 지도를 가리지 않게, §5.2) */
.map-toolbar {
  position: absolute; top: 56px; right: 12px; z-index: 800;
  display: flex; flex-direction: column; gap: 6px;
}
.map-tool-btn {
  width: 40px; height: 40px;
  border-radius: 9px;
  background: rgba(13, 17, 23, 0.85);
  border: 1px solid var(--border-strong);
  color: var(--text-body);
  display: flex; align-items: center; justify-content: center;
}
.map-tool-btn svg { width: 19px; height: 19px; }
.map-tool-btn:hover { border-color: var(--border-hover); background: var(--surface2); }
.map-tool-btn.on { border-color: var(--accent-info); color: var(--accent-info); background: #11253a; }

/* 방위 오버레이 */
.map-orient {
  position: absolute; left: 12px; top: 56px; z-index: 800;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.map-orient-hint {
  font-size: 9px; line-height: 1.3; text-align: center;
  color: var(--text-secondary);
  background: rgba(13, 17, 23, 0.8); border-radius: 5px; padding: 3px 6px;
}
/* 슬롯은 지도 전체를 덮되 클릭은 통과 — 내부 위젯만 위치/클릭 활성 */
#map-orient-slot, #map-measure-slot { position: absolute; inset: 0; z-index: 800; pointer-events: none; }
#map-orient-slot > *, #map-measure-slot > * { pointer-events: auto; }

/* 측정 카드 (상단 중앙) */
.map-measure-card {
  position: absolute; top: 56px; left: 50%; transform: translateX(-50%); z-index: 810;
  background: rgba(13, 17, 23, 0.92); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 9px 12px; min-width: 200px; text-align: center;
}
.map-measure-card .section-label { display: block; margin-bottom: 5px; }
.map-measure-card .mm-hint { font-size: 11.5px; color: var(--text-secondary); margin-bottom: 6px; }
.map-measure-card .mm-result { display: flex; flex-direction: column; gap: 1px; margin-bottom: 6px; }
.map-measure-card .mm-dist { font-family: var(--font-mono); font-size: 20px; font-weight: 600; color: var(--yellow-text); }
.map-measure-card .mm-brg { font-family: var(--font-mono); font-size: 12px; color: var(--text-body); }

.map-fab {
  position: absolute; right: 14px; bottom: 56px; z-index: 5;
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--text-primary);
  color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
.map-fab svg { width: 22px; height: 22px; }
.map-coord-strip {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  background: rgba(13, 17, 23, 0.88);
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--text-secondary);
  padding: 8px 14px;
  display: flex; justify-content: space-between; gap: 10px;
  white-space: nowrap; overflow: hidden;
}
.map-marker {
  position: absolute; z-index: 4;
  transform: translate(-50%, -50%);
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--bg);
  border: 1.5px solid var(--green-fill);
  display: flex; align-items: center; justify-content: center;
  color: var(--green-text);
  cursor: pointer;
  padding: 0;
}
.map-marker svg { width: 15px; height: 15px; }
.map-marker.selected { border-color: var(--text-primary); }
.map-me {
  position: absolute; z-index: 4;
  transform: translate(-50%, -50%);
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent-info);
  border: 2px solid var(--bg);
  pointer-events: none;
}
.map-me::after {
  content: '';
  position: absolute; inset: -14px;
  border-radius: 50%;
  border: 1px solid var(--accent-info);
  opacity: 0.35;
}
.hazard-tag {
  position: absolute; z-index: 4;
  font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.5px;
  padding: 2px 6px; border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
}
.map-info-card {
  position: absolute; left: 12px; right: 12px; bottom: 46px; z-index: 6;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 11px;
}
.map-info-card .row-main { flex: 1; min-width: 0; }

/* ============================================================
   §5.3 위키
   ============================================================ */
.zim-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px;
}
.zim-card + .zim-card { margin-top: 8px; }
.zim-card .zim-icon {
  width: 38px; height: 38px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.zim-card .zim-icon svg { width: 19px; height: 19px; }
.zim-card .zim-main { flex: 1; min-width: 0; }
.zim-card .zim-title { font-size: 14.5px; font-weight: 500; color: var(--text-body); }
.zim-card .zim-meta { font-family: var(--font-mono); font-size: 9px; color: var(--text-tertiary); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   §5.4 가이드
   ============================================================ */
.guide-title { font-size: 19px; font-weight: 700; color: var(--text-primary); }
.guide-subtitle {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 1.8px;
  color: var(--text-secondary);
  margin: 3px 0 14px;
}
.level-stack { display: flex; flex-direction: column; gap: 9px; }

.doc-list-header { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; }
.doc-list-header .h-name { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.doc-list-header .h-en { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 1.5px; color: var(--text-secondary); }

.doc-row {
  display: flex; align-items: center; gap: 11px;
  width: 100%; text-align: left;
  min-height: 54px;
  padding: 9px 2px;
  color: var(--text-body);
}
.doc-row + .doc-row { border-top: 1px solid var(--border); }
.doc-row .d-title { flex: 1; font-size: 14.5px; font-weight: 500; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-row .d-read { font-family: var(--font-mono); font-size: 10px; color: var(--text-tertiary); white-space: nowrap; }
.doc-row svg.chev { width: 16px; height: 16px; color: var(--text-tertiary); flex-shrink: 0; }

/* 보호장비 도감 그리드 */
.equip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.equip-card {
  aspect-ratio: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 12px;
  text-align: center;
  min-width: 0;
  color: var(--text-body);
}
.equip-card:hover { background: var(--surface2); border-color: var(--border-hover); }
.equip-card svg { width: 44px; height: 44px; color: var(--text-body); }
.equip-card .eq-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.equip-card .eq-grade { font-family: var(--font-mono); font-size: 9px; color: var(--text-tertiary); }

/* ============================================================
   §5.5 도구
   ============================================================ */
.tools-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tools-grid .tool-tile { min-height: 92px; }
.tool-section { margin-bottom: 18px; }
.tool-section .section-label { display: block; margin-bottom: 9px; }

/* 계산기 화면 */
.calc-screen { max-width: 560px; }
.calc-field-label {
  display: block;
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  margin: 16px 0 7px;
}
.timer-btn {
  width: 100%; min-height: 52px;
  border-radius: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  font-size: 15px; font-weight: 700;
  color: var(--text-primary);
  margin-top: 12px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.timer-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.timer-btn.running { border-color: var(--yellow-fill); color: var(--yellow-text); }
.timer-btn.done { border-color: var(--green-fill); color: var(--green-text); }
.calc-footer {
  font-family: var(--font-mono); font-size: 9px; line-height: 1.8;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border);
  margin-top: 18px; padding-top: 10px;
}

/* 나침반 */
.compass-wrap { display: flex; flex-direction: column; align-items: center; padding: 18px 0; }
.compass-dial {
  width: 240px; height: 240px;
  position: relative;
}
.compass-dial svg { width: 100%; height: 100%; }
.compass-heading {
  font-family: var(--font-mono); font-size: 34px; font-weight: 700;
  color: var(--text-primary);
  margin-top: 14px;
}
.compass-sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* 야외 항법 (천체) */
.fmfig {
  display: block; width: 100%; max-width: 320px; height: auto;
  margin: 2px auto 10px; padding: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.fieldnav-steps { padding-left: 4px; }
.fieldnav-steps li {
  font-size: 13.5px; line-height: 1.6; color: var(--text-body);
  padding: 4px 0 4px 22px; position: relative; counter-increment: fnstep;
}
.fieldnav-steps { counter-reset: fnstep; }
.fieldnav-steps li::before {
  content: counter(fnstep);
  position: absolute; left: 0; top: 4px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  color: var(--accent-info);
  width: 16px; text-align: center;
}
.nav-rose-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.nav-rose {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 10px 6px; text-align: center;
}
.nav-rose svg { width: 100%; max-width: 200px; height: auto; }
.nav-rose-title { font-size: 12px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.nav-rose-sub { font-family: var(--font-mono); font-size: 10px; color: var(--text-secondary); margin-top: 2px; }
@media (max-width: 420px) { .nav-rose-row { grid-template-columns: 1fr; } }

/* 가족 카드 / 주파수 */
.kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 13.5px; }
.kv-row + .kv-row { border-top: 1px solid var(--border); }
.kv-row .k { color: var(--text-secondary); white-space: nowrap; }
.kv-row .v { color: var(--text-body); text-align: right; min-width: 0; }
.kv-row .v.mono { font-family: var(--font-mono); font-size: 12.5px; white-space: nowrap; }

/* ============================================================
   폼 입력 (가족 카드 등)
   ============================================================ */
.form-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  padding: 10px 12px;
  min-height: 44px;
  margin-bottom: 8px;
}
.form-input:focus { outline: none; border-color: var(--border-hover); }
.form-input::placeholder { color: var(--text-tertiary); }
select.form-input { appearance: none; }
.fam-member { padding: 10px 0 2px; }
.fam-member + .fam-member { border-top: 1px solid var(--border); }
.fam-row { display: flex; gap: 8px; }
.fam-row .fam-name { flex: 1.4; }
.fam-row .fam-blood { flex: 0.9; }
.fam-row .fam-phone { flex: 1; }
.fam-row .fam-meds { flex: 1.4; }
.fam-del {
  width: 40px; height: 44px; flex-shrink: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text-tertiary);
  display: flex; align-items: center; justify-content: center;
}
.fam-del svg { width: 15px; height: 15px; }
.fam-del:hover { color: var(--red-text); border-color: var(--red-fill); }

/* ============================================================
   위키 뷰어 (실 ZIM)
   ============================================================ */
.wiki-viewer { display: flex; flex-direction: column; height: 100%; }
.wiki-toolbar {
  display: flex; align-items: center; gap: 7px;
  padding: 10px var(--pad-screen);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.wk-tool {
  min-width: 38px; height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text-body);
  font-size: 13px;
  font-family: var(--font-mono);
  padding: 0 8px;
}
.wk-tool:disabled { opacity: 0.35; cursor: default; }
.wk-tool.on { color: var(--yellow-text); border-color: var(--yellow-tint-border); }
.wk-title { flex: 1; font-size: 14px; font-weight: 700; color: var(--text-primary); min-width: 0; }
.wiki-article {
  flex: 1; overflow-y: auto;
  padding: 16px var(--pad-screen) 40px;
  line-height: 1.7;
}
.wiki-article.wk-dark { background: var(--bg); color: var(--text-body); }
.wiki-article.wk-light { background: #FFFFFF; color: #1c1e21; }
.wiki-article h1, .wiki-article h2, .wiki-article h3 { margin: 18px 0 8px; line-height: 1.35; }
.wiki-article.wk-dark h1, .wiki-article.wk-dark h2, .wiki-article.wk-dark h3 { color: var(--text-primary); }
.wiki-article p, .wiki-article li { margin: 7px 0; }
.wiki-article ul, .wiki-article ol { padding-left: 22px; }
.wiki-article ul li { list-style: disc; }
.wiki-article ol li { list-style: decimal; }
.wiki-article a[data-zim] { color: var(--accent-info); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.wiki-article.wk-light a[data-zim] { color: #0645ad; }
.wiki-article .wk-ext { color: var(--text-tertiary); text-decoration: line-through; cursor: not-allowed; }
.wiki-article .wk-img-off {
  display: inline-block;
  font-size: 11.5px; color: var(--text-tertiary);
  border: 1px dashed var(--border-strong);
  border-radius: 5px; padding: 3px 8px; margin: 4px 0;
}
.wiki-article img { max-width: 100%; height: auto; border-radius: 6px; }
.wiki-article table { border-collapse: collapse; max-width: 100%; overflow-x: auto; display: block; font-size: 0.9em; }
.wiki-article td, .wiki-article th { border: 1px solid var(--border-strong); padding: 5px 8px; }
.wiki-article.wk-light td, .wiki-article.wk-light th { border-color: #c8ccd1; }
.wiki-article .wk-err { color: var(--red-text); }

/* ============================================================
   실제 지도 (Leaflet) 보조
   ============================================================ */
.map-canvas-wrap .leaflet-container { background: var(--map-bg); font-family: var(--font-sans); }
.lmk {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--bg);
  border: 1.5px solid var(--green-fill);
  display: flex; align-items: center; justify-content: center;
  color: var(--green-text);
}
.lmk svg { width: 15px; height: 15px; }
.lmk.lmk-pin { border-color: var(--accent-info); color: var(--accent-info); border-radius: 50% 50% 50% 4px; }
/* 대피소 유형별 색: 민방위=녹색(주력), 지진·해일=청록, 한파=파랑, 무더위=주황 */
.lmk.lmk-quake { border-color: #2DD4BF; color: #5EEAD4; }
.lmk.lmk-cold { border-color: #58A6FF; color: #58A6FF; }
.lmk.lmk-heat { border-color: #F9A825; color: #F9A825; }
/* 의료 인프라(재난 시): 병원=분홍, 약국=보라 — 위험 4색 문법과 분리된 별도 색 */
.lmk.lmk-hospital { border-color: #F472B6; color: #F9A8D4; }
.lmk.lmk-pharmacy { border-color: #A78BFA; color: #C4B5FD; }
.lp-tel { color: var(--accent-info); text-decoration: none; font-family: var(--font-mono); font-size: 12px; }
/* ============================================================
   AI 도우미 (PC 전용 브라우저 LLM)
   ============================================================ */
.ai-screen { display: flex; flex-direction: column; gap: 14px; }
.ai-disclaimer {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--yellow-chip-tint); border: 1px solid rgba(249, 168, 37, 0.55);
  border-radius: 10px; padding: 10px 12px; font-size: 12.5px; color: var(--text-body); line-height: 1.5;
}
.ai-disclaimer svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--yellow-text); margin-top: 1px; }
.ai-empty { text-align: center; padding: 36px 16px; }
.ai-empty-title { font-size: 16px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.ai-empty-body { font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; max-width: 520px; margin: 0 auto 4px; }
.ai-ready { text-align: center; padding: 28px 16px; }
.ai-model-card {
  max-width: 440px; margin: 16px auto; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px;
}
.ai-model-name { font-size: 14.5px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.ai-model-meta { color: var(--text-tertiary); margin-bottom: 12px; }
.ai-dl-btn {
  width: 100%; min-height: 48px; border-radius: 8px; font-size: 14px; font-weight: 700;
  background: var(--text-primary); color: var(--bg); border: none; cursor: pointer;
}
.ai-dl-btn:disabled { background: var(--surface2); color: var(--text-tertiary); border: 1px solid var(--border-strong); cursor: default; }
.ai-spinner { width: 28px; height: 28px; margin: 0 auto 14px; border: 3px solid var(--border-strong); border-top-color: var(--text-primary); border-radius: 50%; animation: ai-spin 0.8s linear infinite; }
.ai-dl-track { max-width: 440px; margin: 14px auto 8px; height: 10px; background: var(--surface2); border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
.ai-dl-fill { height: 100%; background: var(--accent-info); transition: width 0.2s ease; }
/* 해외 속보 태그 (국내 우선·해외는 지도 제외) */
.ovr-tag { display: inline-block; font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 4px; background: var(--surface2); color: var(--text-tertiary); border: 1px solid var(--border-strong); margin-right: 3px; vertical-align: middle; }
.alert-item.is-overseas { opacity: 0.7; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
/* 채팅 */
.ai-chat { display: flex; flex-direction: column; gap: 10px; height: calc(100dvh - 180px); min-height: 360px; }
.ai-msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px 2px; }
.ai-msg { display: flex; flex-direction: column; gap: 3px; }
.ai-msg-role { color: var(--text-tertiary); }
.ai-msg-user { align-items: flex-end; }
.ai-msg-user .ai-msg-text { background: var(--surface2); border: 1px solid var(--border-strong); }
.ai-msg-text { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 13px; font-size: 14.5px; line-height: 1.65; word-break: keep-all; max-width: 88%; }
.ai-msg-user .ai-msg-text { white-space: pre-wrap; }
.ai-msg-text p { margin: 0 0 7px; } .ai-msg-text p:last-child { margin-bottom: 0; }
.ai-msg-text ul, .ai-msg-text ol { margin: 4px 0 8px; padding-left: 20px; }
.ai-msg-text li { margin: 2px 0; }
.ai-msg-text .ai-h { font-weight: 700; color: var(--text-primary); margin: 11px 0 4px; }
.ai-msg-text .ai-h:first-child { margin-top: 0; }
.ai-msg-text code { background: var(--surface2); border-radius: 4px; padding: 1px 5px; font-family: var(--font-mono); font-size: 0.88em; }
.ai-msg-text pre { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; overflow-x: auto; font-family: var(--font-mono); font-size: 12.5px; white-space: pre-wrap; margin: 6px 0; }
.ai-msg-text hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.ai-msg-text strong { font-weight: 700; color: var(--text-primary); }
/* 접이식 섹션([근거]·[참고] 등 — 클릭 시 펼침) */
.ai-fold { margin: 8px 0 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface2); overflow: hidden; }
.ai-fold > summary { cursor: pointer; padding: 6px 11px; font-size: 12.5px; color: var(--text-secondary); user-select: none; list-style: none; }
.ai-fold > summary::-webkit-details-marker { display: none; }
.ai-fold > summary::before { content: "▸ "; opacity: 0.6; }
.ai-fold[open] > summary::before { content: "▾ "; }
.ai-fold-body { padding: 0 13px 9px; font-size: 13px; color: var(--text-secondary); }
.ai-fold-body p { margin: 0 0 6px; } .ai-fold-body p:last-child { margin-bottom: 0; }
.ai-input-row { display: flex; gap: 8px; padding-top: 4px; }
.ai-input { flex: 1; min-height: 46px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; padding: 0 14px; color: var(--text-primary); font-size: 14.5px; font-family: var(--font-sans); }
.ai-input:focus { outline: none; border-color: var(--accent-info); }
.ai-send { width: 46px; min-height: 46px; border-radius: 10px; background: var(--text-primary); color: var(--bg); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ai-send:disabled { background: var(--surface2); color: var(--text-tertiary); cursor: default; }
.ai-send svg { width: 20px; height: 20px; }

/* 대피소 유형 필터 칩(대피소 레이어 하위) */
.stype-row { display: flex; flex-wrap: wrap; gap: 5px; max-width: 250px; margin: 1px 0 2px 4px; }
.stype-chip {
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 12px;
  background: rgba(13, 17, 23, 0.85); border: 1px solid var(--border, #30363d);
  color: var(--text-dim, #8B949E); cursor: pointer; white-space: nowrap;
}
.stype-chip.on.st-civil { border-color: var(--green-fill); color: var(--green-text); background: rgba(46, 125, 50, 0.18); }
.stype-chip.on.st-quake { border-color: #2DD4BF; color: #5EEAD4; background: rgba(45, 212, 191, 0.16); }
.stype-chip.on.st-cold  { border-color: #58A6FF; color: #9FD0FF; background: rgba(88, 166, 255, 0.16); }
.stype-chip.on.st-heat  { border-color: #F9A825; color: #F9C74F; background: rgba(249, 168, 37, 0.16); }
.stype-chip.on.st-etc   { border-color: var(--border-strong, #444c56); color: var(--text-body); }
.stype-chip:not(.on) { opacity: 0.55; text-decoration: line-through; }
.lmk-me {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent-info);
  border: 2px solid var(--bg);
}
/* 한글 지도 라벨 (직접 렌더) */
.mlbl {
  font-family: var(--font-sans);
  font-size: 11px; font-weight: 500;
  color: #E6EDF3;
  white-space: nowrap;
  text-shadow: 0 0 2px #0D1117, 0 0 3px #0D1117, 0 0 4px #0D1117, 1px 1px 2px #0D1117;
  transform: translate(-50%, -50%);
  display: inline-block;
  pointer-events: none;
}
.mlbl-city { font-size: 13.5px; font-weight: 700; color: #FFFFFF; }
.mlbl-place { color: #E6EDF3; }
.mlbl-water { color: #6Fb6e8; font-style: italic; font-size: 10.5px; }
.mlbl-road { color: #AAB4C0; font-size: 10px; font-weight: 400; }
.leaflet-marker-icon.leaflet-div-icon { background: none; border: none; }
.lpopup { font-size: 13px; color: var(--text-body); min-width: 180px; }
.lpopup .mono-s { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); }
.lp-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 12.5px;
  padding: 7px 9px;
  margin: 8px 0 6px;
}
.lp-row { display: flex; gap: 6px; }
.lp-btn {
  flex: 1;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text-body);
  font-size: 12px; font-weight: 600;
  padding: 7px 8px;
  margin-top: 2px;
}
.lp-btn:hover { border-color: var(--border-hover); }
.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  color: var(--text-body) !important;
  border: 1px solid var(--border-strong);
  border-radius: 10px !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5) !important;
}
.leaflet-popup-tip { background: var(--surface) !important; }
.leaflet-popup-close-button { color: var(--text-tertiary) !important; }
.map-pin-dot {
  position: absolute; z-index: 4;
  transform: translate(-50%, -90%);
  color: var(--accent-info);
  pointer-events: none;
}
.map-pin-dot svg { width: 20px; height: 20px; }
.layer-chip.on-blue { background: #11253a; border-color: var(--accent-info); color: var(--accent-info); }

/* 지도 오버레이는 Leaflet 패널(z≤700) 위에 */
.map-banner-slot { z-index: 800; }
.map-layers { z-index: 800; }
.map-fab { z-index: 800; }
.map-coord-strip { z-index: 800; }
.map-info-card { z-index: 810; }

/* ============================================================
   다운로드 행 보조
   ============================================================ */
.row-actions { display: flex; gap: 5px; flex-shrink: 0; align-items: center; }
.dl-progress { display: block; margin-top: 6px; }
.dl-progress .gauge-bar { display: block; height: 5px; }
.dl-meta {
  display: block;
  font-family: var(--font-mono); font-size: 9.5px;
  color: var(--text-secondary); margin-top: 4px;
}

/* ============================================================
   §6 데스크톱 어댑테이션 (breakpoint 840px)
   ============================================================ */
@media (min-width: 840px) {
  /* 타이틀바 느낌의 상단 보더 라인 — 데스크톱 윈도우 프레임 */
  .app { background: var(--bg); }

  /* 좌측 레일 */
  #rail {
    display: flex;
    flex-direction: column;
    width: var(--rail-w);
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: var(--bg);
    padding: 14px 12px;
    gap: 4px;
  }
  .rail-wordmark {
    font-family: var(--font-mono); font-weight: 600;
    font-size: 14px; letter-spacing: 3px;
    color: var(--text-primary);
    display: flex; align-items: center; gap: 9px;
    padding: 6px 8px 14px;
  }
  .rail-status {
    display: grid; grid-template-columns: 1fr 1fr; gap: 5px;
    padding: 0 4px 14px;
  }
  .rail-status .status-pill { text-align: center; font-size: 9.5px; }
  .rail-item {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px; font-weight: 500;
    width: 100%; text-align: left;
  }
  .rail-item svg { width: 17px; height: 17px; flex-shrink: 0; }
  .rail-item:hover { background: var(--surface); color: var(--text-body); }
  .rail-item.active { background: var(--surface2); color: var(--text-primary); }
  .rail-spacer { flex: 1; }
  .rail-emergency {
    width: 100%;
    background: var(--red-fill);
    color: var(--red-on);
    border-radius: 8px;
    padding: 12px;
    font-size: 13.5px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; gap: 8px;
  }
  .rail-emergency:hover { background: var(--red-hover); }
  .rail-emergency .key {
    font-family: var(--font-mono); font-size: 8.5px; font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 3px; padding: 1px 5px;
    white-space: nowrap;
  }

  /* 모바일 전용 요소 숨김 */
  .tabbar { display: none; }
  .status-strip .wordmark, .status-strip .emergency-btn { display: none; }
  .status-strip { padding: 0 var(--pad-screen-desktop); justify-content: flex-end; }

  #screen { background: var(--bg-canvas); }
  /* 와이드(QHD 등)에서 콘텐츠가 좌측 1280px만 쓰고 우측이 비던 문제 →
     넓히고 가운데 정렬. 모니터가 작으면 자연히 가용 폭까지만 찬다. */
  .screen-pad { padding: 20px var(--pad-screen-desktop) 32px; max-width: 1920px; margin: 0 auto; }

  .search-field .key-hint { display: block; }

  /* 홈 — 3열 대시보드 그리드 §6 */
  .home-grid {
    display: grid;
    grid-template-columns: 1.1fr 1fr 1.05fr;
    gap: 12px;
    align-items: start;
  }
  .home-grid > * { min-width: 0; margin-top: 0 !important; }
  .home-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
  .home-col > * { margin-top: 0 !important; }

  /* 가이드 — 레벨 카드 4열 */
  .level-stack {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }
  .level-card { flex-direction: column; align-items: flex-start; gap: 10px; }
  .level-card .lv-count { align-self: flex-end; }
  .level-card.ring-1 { border: 1.5px solid var(--green-fill); }
  .level-card.ring-2 { border: 1.5px solid var(--yellow-fill); }
  .level-card.ring-3 { border: 1.5px solid var(--red-fill); }
  .level-card.ring-4 { border: 1.5px solid var(--black-border); }

  /* 가이드 문서 테이블 */
  .doc-table { width: 100%; border-collapse: collapse; }
  .doc-table th {
    font-family: var(--font-mono); font-size: 9.5px; font-weight: 500;
    letter-spacing: 1.5px; text-align: left;
    color: var(--text-tertiary);
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
  }
  .doc-table td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-body);
  }
  .doc-table td.mono { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
  .doc-table tr { cursor: pointer; }
  .doc-table tbody tr:hover td { background: var(--surface); }

  /* 도구 그리드 넓게 */
  .tools-grid { grid-template-columns: repeat(5, 1fr); }
  .equip-grid { grid-template-columns: repeat(4, 1fr); }

  /* 비상 모드 — 3×2 */
  .em-grid { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); max-width: 1100px; margin: 0 auto; width: 100%; }
  .emergency-overlay { padding: 22px; }
  .em-header, .em-notice, .em-exit { max-width: 1100px; margin-left: auto; margin-right: auto; width: 100%; }
  .em-exit { margin-top: 14px; }
}

/* 모바일 — 상태 스트립 공간 확보: SYNC 필은 두 번째 우선순위로 숨김 */
@media (max-width: 480px) {
  .status-pills .status-pill:nth-last-child(2) { display: none; }
}
