/* ═══════════════════════════════════════════════════════════
   WILDFIRE MONITORING SYSTEM · v6
   ForeFlight-style · Map-first · Dark/Light themes
   Desktop / iPad / Phone (portrait + landscape)
   ═══════════════════════════════════════════════════════════ */

/* ─── Global: hide scrollbars everywhere (스크롤 기능은 유지) ─── */
* {
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE/old Edge */
}
*::-webkit-scrollbar {           /* WebKit (Chrome/Safari/Edge) */
  width: 0 !important;
  height: 0 !important;
  display: none !important;
  background: transparent !important;
}
html, body {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
html::-webkit-scrollbar,
body::-webkit-scrollbar { display: none !important; width:0; height:0; }

/* ─── Theme variables ─── */
:root,
body[data-theme="dark"] {
  /* Bootstrap gray scale — 다크/위성 모드: 텍스트는 상단 톤, 캡션은 중간 톤 */
  --bg:              #0a0d12;
  --panel-bg:        rgba(33,37,41,0.72);        /* #212529 기반 */
  --panel-border:    rgba(248,249,250,0.08);
  --panel-shadow:    0 8px 24px rgba(0,0,0,0.4);
  --text:            #F8F9FA;
  --text-sub:        #CED4DA;
  --text-caption:    #ADB5BD;
  --divider:         rgba(248,249,250,0.08);
  --hover:           rgba(248,249,250,0.06);
  --input-bg:        rgba(33,37,41,0.55);
  --popup-bg:        rgba(33,37,41,0.95);
  --brand:           #F3722C;
  --red:             #F94144;
  --amb:             #F9844A;
  --yel:             #F9C74F;
  --grn:             #90BE6D;
  --blu:             #277DA1;
  --pur:             #577590;
  --cya:             #4D908E;
  --gry:             #ADB5BD;
  --mis:             #F9C74F;
  --ora:             #F8961E;
}

body[data-theme="light"] {
  /* Bootstrap gray scale — 라이트/일반지도 모드: 텍스트는 하단 톤, 캡션은 중간 톤 */
  --bg:              #F8F9FA;
  --panel-bg:        rgba(248,249,250,0.96);
  --panel-border:    rgba(33,37,41,0.15);
  --panel-shadow:    0 6px 22px rgba(33,37,41,0.14);
  --text:            #212529;
  --text-sub:        #495057;
  --text-caption:    #6C757D;
  --divider:         rgba(33,37,41,0.10);
  --hover:           rgba(33,37,41,0.06);
  --input-bg:        rgba(33,37,41,0.05);
  --popup-bg:        rgba(248,249,250,0.98);
  --brand:           #F3722C;
  --red:             #F94144;
  --amb:             #F8961E;
  --yel:             #F9C74F;
  --grn:             #90BE6D;
  --blu:             #277DA1;
  --pur:             #577590;
  --cya:             #4D908E;
  --gry:             #6C757D;
  --mis:             #F9844A;
  --ora:             #F3722C;
}

*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }

/* 통합 폰트 스택 — 한글은 전역에서 'Pretendard > Noto Sans KR > Malgun Gothic' 로 일관 */
:root {
  --font-sans: 'Pretendard','Noto Sans KR','-apple-system','SF Pro Display','Inter','Malgun Gothic',sans-serif;
  /* 모노: 영문/숫자는 SF Mono · 한글은 Pretendard로 폴백돼 본문과 동일 자형 유지 */
  --font-mono: 'SF Mono','Consolas','Pretendard','Noto Sans KR','Malgun Gothic',monospace;
}

html,body {
  height:100%; overflow:hidden;
  background:var(--bg); color:var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing:antialiased; touch-action:manipulation;
  transition: background 0.25s ease, color 0.25s ease;
}
.hidden { display:none !important; }

/* ─── Map ─── */
#map { position:fixed; inset:0; background:var(--bg); z-index:0; }
.leaflet-container { background:var(--bg); }

/* ─── Glassmorphism base ─── */
.glass {
  background: var(--panel-bg);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border:1px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
}

/* ─── Top bar — v6.1: 3-zone 투명 + 중앙 KPI만 배경 ─── */
.topbar {
  position:fixed; top:12px; left:12px; right:12px; height:64px;
  z-index:500;
  display:grid;
  grid-template-columns: 1fr auto 1fr;
  align-items:center; gap:16px;
  padding:0 8px;
  background:transparent;           /* 전체는 투명 */
  border:none; box-shadow:none;
  pointer-events:none;              /* 자식 요소들만 클릭 허용 */
}
.topbar > * { pointer-events:auto; }

/* 좌: brand — 시스템답게 크게, 배경 없음. 다크/라이트 모두 어울리는 색. */
.brand {
  color:var(--text);
  font-family: var(--font-sans);
  font-weight:800; font-size:19px; letter-spacing:1.8px;
  white-space:nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,0.45);
  justify-self:start; padding-left:8px;
}
body[data-theme="light"] .brand {
  color:#212529;
  text-shadow: 0 1px 1px rgba(33,37,41,0.08);
}

/* 중: KPI 래퍼 — 유일하게 배경 보유 */
.kpis-wrap {
  border-radius:12px; padding:6px 16px;
  justify-self:center;
}
.kpis { display:flex; gap:0; align-items:stretch; font-family:var(--font-mono); }
.kpi {
  box-sizing:border-box;                                /* border 포함 너비 — 모든 셀 완전 동일 */
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  text-align:center; line-height:1.15;
  padding:4px 10px;
  /* 5칸 균등 너비 — HELICOPTER(10자) 수용 가능한 min-width */
  flex:1 1 0; min-width:130px;
  border-left:1px solid var(--panel-border);
}
.kpi:first-child { border-left:1px solid transparent; } /* 구분선만 숨기고 너비는 유지 */
.kpi .l {
  color:var(--text); font-size:12px; font-weight:800;     /* 식별 강화 */
  letter-spacing:1.2px; text-transform:uppercase;
  opacity:0.95;
  white-space:nowrap;
}
.kpi .v {
  color:var(--text); font-size:20px; font-weight:900;
  margin-top:3px; text-shadow:0 1px 2px rgba(0,0,0,0.3);
}
body[data-theme="light"] .kpi .v { text-shadow:none; }
.kpi .v.red { color:var(--red); }
.kpi .v.amb { color:var(--amb); }
.kpi .v.yel { color:var(--yel); }
.kpi .v.grn { color:var(--grn); }
.kpi .v.blu { color:var(--blu); }
.kpi .v.gry { color:var(--gry); }

/* 우: 언어 세그먼트 + 시간 — 배경 없음 · 우측정렬 */
.right {
  display:flex; flex-direction:column; align-items:flex-end; gap:4px;
  justify-self:end; padding-right:8px;
  text-align:right;
}
.time {
  font-family:var(--font-mono);
  color:var(--text-sub); font-size:12px;
  text-shadow:0 1px 2px rgba(0,0,0,0.35);
  text-align:right;
  padding-right:2px;    /* 언어 세그먼트 내부 여백(2px)과 맞춤 */
  letter-spacing:0.3px;
}
body[data-theme="light"] .time { text-shadow:none; color:var(--text-caption); }

/* ─── API 연결 상태 배지 (LIVE / OFFLINE) ─── */
.connBadge {
  display:inline-flex; align-items:center;
  font-family:var(--font-mono);
  font-size:10px; font-weight:700; letter-spacing:0.6px;
  padding:2px 8px; border-radius:10px;
  background:rgba(0,0,0,0.25);
  border:1px solid var(--panel-border);
  color:var(--text-sub);
  white-space:nowrap;
}
.connBadge[data-mode="live"]    { color:#2ed573; }
.connBadge[data-mode="offline"] { color:#ff4757; }

/* ─── Language segmented toggle (KOR | ENG) ─── */
.langSeg {
  display:inline-flex; gap:0;
  background:var(--hover);
  border:1px solid var(--panel-border); border-radius:14px;
  overflow:hidden; padding:2px;
}
.langSeg .seg-opt {
  background:transparent; border:none;
  color:var(--text-sub);
  font-family:var(--font-mono);
  font-weight:700; font-size:11px; letter-spacing:0.8px;
  padding:4px 12px; border-radius:10px;
  cursor:pointer; user-select:none; transition: all 0.15s ease;
}
.langSeg .seg-opt:hover { color:var(--text); }
.langSeg .seg-opt.active {
  background:var(--brand); color:#0a0d12;
  box-shadow: 0 1px 4px rgba(255,107,53,0.4);
}
body[data-theme="light"] .langSeg .seg-opt.active { color:#fff; }

/* 기존 .langBtn 호환 (뒤에서 제거하지 않고 유지) */
.langBtn { display:none; }

/* ─── Mobile/iPad 3-KPI bar (기본 숨김, 반응형에서 표시) ─── */
.kpis-mobile {
  display:none;
  position:fixed; z-index:550;
  border-radius:10px;
  border:1px solid var(--panel-border);
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  font-family: var(--font-mono);
}
.kpis-mobile .mkpi {
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  text-align:center; line-height:1.15;
  flex:1 1 0;        /* 3칸 균등 너비 */
  min-width:0;
  border-left:1px solid var(--panel-border);
  padding:4px 2px;
}
.kpis-mobile .mkpi:first-child { border-left:none; }
.kpis-mobile .mkpi .l {
  color:var(--text); font-weight:800;
  letter-spacing:1px; text-transform:uppercase;
  opacity:0.95; white-space:nowrap;
}
.kpis-mobile .mkpi .v {
  display:inline-flex;
  align-items:baseline;
  justify-content:center;
  gap:3px;                /* 숫자-괄호 붙임 */
  color:var(--text); font-weight:900;
  margin-top:2px; text-shadow:0 1px 2px rgba(0,0,0,0.3);
  white-space:nowrap;
}
body[data-theme="light"] .kpis-mobile .mkpi .v { text-shadow:none; }
.kpis-mobile .mkpi .v.red { color:var(--red); }
.kpis-mobile .mkpi .v.blu { color:var(--blu); }
.kpis-mobile .mkpi .v.gry { color:var(--gry); }
.kpis-mobile .mkpi .v .unc {
  color:var(--yel);
  font-weight:900;        /* 메인 숫자와 동일 두께·크기 */
  font-size:inherit;      /* 동일 폰트 크기 */
}

/* ─── 레거시 .chips (뷰포트에서 사용 안 함, 호환 유지) ─── */
.chips { display:none !important; }
.chip { display:none; }

/* ─── Left rail (7 tools) ─── */
.leftrail {
  position:fixed; top:88px; left:12px; width:48px; border-radius:10px; z-index:500;
  padding:6px; display:flex; flex-direction:column; gap:4px;
}
.leftrail .tool {
  width:36px; height:36px; display:flex; align-items:center; justify-content:center;
  border-radius:7px; font-size:18px; cursor:pointer; color:var(--text-sub); user-select:none;
  transition: background 0.12s ease, color 0.12s ease;
}
.leftrail .tool.active { background:var(--brand); color:#000; }
.leftrail .tool:not(.active):hover { background:var(--hover); color:var(--text); }
.leftrail .sep { height:1px; background:var(--divider); margin:2px 0; }

/* ─── Layers panel ─── */
.layers {
  position:fixed; top:88px; left:68px; width:240px;
  max-height: calc(100vh - 100px); overflow-y:auto;
  border-radius:10px; z-index:500;
  padding:12px; font-size:12.5px;
}
.layers h3 { color:var(--text-sub); font-size:10px; letter-spacing:1.2px; margin-bottom:6px; text-transform:uppercase; }
.layers label {
  display:flex; align-items:center; gap:8px; padding:6px 4px; border-radius:5px; cursor:pointer; user-select:none;
}
.layers label:hover { background:var(--hover); }
.layers label input { accent-color:var(--brand); }
.layers .dot { width:8px; height:8px; border-radius:50%; display:inline-block; flex-shrink:0; }

/* ─── Map (basemap) popover menu — 지도 탭 ─── */
.mapmenu {
  position:fixed; top:88px; left:68px; width:220px;
  border-radius:10px; z-index:550;
  padding:12px; font-size:12.5px;
}
.mapmenu h3 {
  color:var(--text-sub); font-size:10px; letter-spacing:1.2px;
  margin-bottom:6px; text-transform:uppercase;
}
.mapmenu label {
  display:flex; align-items:center; gap:8px;
  padding:6px 4px; border-radius:5px; cursor:pointer; user-select:none;
}
.mapmenu label:hover { background:var(--hover); }
.mapmenu label input { accent-color:var(--brand); }

/* ─── Share popover menu ─── */
.share-menu {
  position:fixed; top:88px; left:68px; min-width:180px;
  border-radius:10px; z-index:550;
  padding:6px; display:flex; flex-direction:column; gap:2px;
}
.share-opt {
  background:transparent; border:none; color:var(--text);
  font-family:inherit; font-size:12px; text-align:left;
  padding:8px 10px; border-radius:6px; cursor:pointer;
  display:flex; align-items:center; gap:8px;
}
.share-opt:hover { background:var(--hover); }

/* ─── Measure hint bar ─── */
.measure-hint {
  position:fixed; top:88px; left:50%; transform:translateX(-50%);
  border-radius:20px; padding:8px 16px; z-index:550;
  font-size:12px; display:flex; align-items:center; gap:12px;
}
.measure-hint button {
  background:var(--red); color:#fff; border:none;
  padding:4px 10px; border-radius:10px;
  font-family:inherit; font-size:11px; cursor:pointer;
}

/* ─── Right panel (Desktop/iPad) ─── */
.rightpanel {
  position:fixed; top:88px; right:12px; width:360px;
  /* top(88) + ticker bottom(12) + ticker height(32) + gap(12) = 144 */
  max-height: calc(100vh - 144px);
  border-radius:10px; z-index:500;
  display:flex; flex-direction:column; overflow:hidden;
}
.rightpanel .body {
  flex:1 1 auto; min-height:0;
}
.rightpanel .head {
  padding:6px 12px; height:52px;             /* 대칭 padding + 높이 소폭 증가 → 아이콘 여유 확보, 내용 자연 중앙 */
  background:linear-gradient(135deg, rgba(87,117,144,0.55), rgba(87,117,144,0.30));
  border-bottom:1px solid var(--panel-border);
  border-radius:10px 10px 0 0;               /* 웹 패널 기준 라운드(10px) 명시 — 모바일과 동일 형태 보장 */
  display:flex; justify-content:space-between; align-items:center;
  flex-shrink:0;
  backdrop-filter: blur(6px) saturate(140%);
  -webkit-backdrop-filter: blur(6px) saturate(140%);
}
/* 우리헬기(FIRECATS · 미션 헬기)는 호기/등록부호/상태 3줄이므로 살짝 높이 증가 */
.rightpanel .head:has(.title-card.mission-card),
.sheet-head:has(.title-card.mission-card) {
  height:62px;
}
/* Head text — 양 모드 공통: 흰색 + 그림자로 어떤 팔레트 배경에도 또렷하게 */
.rightpanel .head .title,
body[data-theme="light"] .rightpanel .head .title {
  color:#F8F9FA; text-shadow:0 1px 2px rgba(0,0,0,0.40);
}
body[data-theme="light"] .rightpanel .head .close,
.rightpanel .head .close {
  color:rgba(248,249,250,0.92);
}
body[data-theme="light"] .rightpanel .head {
  border-bottom:1px solid rgba(33,37,41,0.18);
}
.rightpanel .head .title {
  font-weight:700; font-size:13px;
  display:flex; align-items:center; gap:10px;
  flex:1; min-width:0;
}
.rightpanel .head .close { cursor:pointer; font-size:16px; padding:2px 6px; }
.rightpanel .body { padding:12px 14px; overflow-y:auto; font-size:12px; }

/* Detail content styles */
.kv { display:grid; grid-template-columns: 96px 1fr; gap:4px 10px; }
.kv dt { color:var(--text-sub); font-size:11px; font-weight:600; letter-spacing:0.2px; }
.kv dd { color:var(--text); font-family:var(--font-mono); font-size:11.5px; word-break:break-all; }
.kv dd b { color:var(--red); }
body[data-theme="light"] .kv dt { color:#495057; font-weight:700; }
body[data-theme="light"] .kv dd { color:#212529; }
body[data-theme="dark"] .kv dt { color:#CED4DA; font-weight:700; }
body[data-theme="dark"] .kv dd { color:#F8F9FA; }
.section { margin-top:12px; padding-top:10px; border-top:1px dashed var(--divider); }
.section .label {
  color:var(--amb); font-size:10px; letter-spacing:1px; text-transform:uppercase; margin-bottom:5px;
}
/* Current weather — 2-column grid (2단 배열) of row frames · 톤 조화 · 내용은 제목보다 작게 */
.wx {
  display:grid; grid-template-columns: 1fr 1fr; gap:4px 6px;
  font-family:var(--font-mono); font-size:11px;
}
.wx .row {
  display:grid; grid-template-columns: 48px 1fr;
  align-items:center; gap:8px;
  padding:5px 8px; border-radius:5px;
  background: linear-gradient(180deg,
                rgba(248,249,250,0.05),
                rgba(248,249,250,0.02));
  border:1px solid rgba(248,249,250,0.10);
  min-width:0;
}
.wx .row span {
  color:#ADB5BD; font-weight:800; letter-spacing:0.4px; margin-right:0;
}
.wx .row b {
  color:#F8F9FA; font-weight:700; word-break:break-word;
}
body[data-theme="light"] .wx .row {
  background: linear-gradient(180deg,
                rgba(33,37,41,0.05),
                rgba(33,37,41,0.02));
  border:1px solid rgba(33,37,41,0.12);
}
body[data-theme="light"] .wx .row span { color:#495057; font-weight:900; }
body[data-theme="light"] .wx .row b    { color:#212529; }
.code {
  font-family:var(--font-mono); font-size:11px; color:var(--mis);
  background:var(--input-bg); padding:6px 8px; border-radius:4px;
  word-break:break-all; line-height:1.5;
}
body[data-theme="light"] .code { color:#5a3f00; background:rgba(184,66,18,0.06); }

/* Progress bar (fire suppression %) */
.progress-bar {
  width:100%; height:8px; background:var(--input-bg); border-radius:4px; overflow:hidden;
  margin-top:4px;
}
.progress-bar .fill {
  height:100%; background:linear-gradient(90deg, var(--red), var(--amb), var(--grn));
  border-radius:4px; transition: width 0.3s ease;
}
.progress-text { font-family:var(--font-mono); font-size:11px; color:var(--text); }

/* Forecast rows (3h/6h/12h) */
.forecast-list { display:grid; gap:4px; }
.forecast-row {
  display:grid; grid-template-columns:48px 1fr; gap:8px;
  padding:4px 6px; background:var(--input-bg); border-radius:4px;
  font-family:var(--font-mono); font-size:11px;
}
.forecast-row .ft { color:var(--amb); font-weight:700; }
.forecast-row .fc { color:var(--text); }

/* Nearby (BASE/FA) list */
.nearby-list { display:grid; gap:4px; }
.nearby-row {
  display:grid; grid-template-columns:1fr auto; gap:8px; align-items:center;
  padding:4px 8px; background:var(--input-bg); border-radius:4px;
  font-family:var(--font-mono); font-size:11px;
}
.nearby-row .n-name { color:var(--text); }
.nearby-row .n-dist { color:var(--amb); font-weight:700; white-space:nowrap; }

/* Airport frequency blocks */
.freq-block { display:grid; gap:4px; font-family:var(--font-mono); font-size:11.5px; }
.freq-row {
  display:grid; grid-template-columns:48px 1fr; gap:8px; align-items:start;
  padding:3px 6px; background:var(--input-bg); border-radius:4px;
}
.freq-row .freq-label {
  color:var(--ora); font-weight:700; font-size:10.5px; letter-spacing:0.5px; padding-top:1px;
}
.freq-row .freq-vals { color:var(--text); line-height:1.5; word-break:break-all; }

.heli-list { display:grid; gap:4px; }
.heli-list .row-h {
  display:flex; justify-content:space-between; padding:4px 6px; border-radius:4px;
  font-size:11px; background:var(--input-bg);
}
.heli-list .row-h .s { color:var(--grn); }

/* Toggle switch (flight track) */
.toggle-row {
  display:flex; justify-content:space-between; align-items:center;
  padding:6px 0; font-size:11.5px;
}
.toggle-sw {
  position:relative; width:36px; height:20px; background:var(--input-bg);
  border-radius:10px; cursor:pointer; transition: background 0.2s ease;
}
.toggle-sw::after {
  content:""; position:absolute; top:2px; left:2px;
  width:16px; height:16px; background:var(--text-sub); border-radius:50%;
  transition: transform 0.2s ease, background 0.2s ease;
}
.toggle-sw.on { background:var(--brand); }
.toggle-sw.on::after { transform: translateX(16px); background:#fff; }

/* ─── Bottom sheet (Phone) — 3단 스냅(peek/half/full) ─── */
.sheet {
  position:fixed; left:0; right:0; bottom:0;
  border-radius:18px 18px 0 0;
  padding:0 16px calc(20px + env(safe-area-inset-bottom));  /* top:0 — handle이 sheet-head 위에 overlay */
  height: auto;                                  /* max-height로 높이 제어 — 하단은 CSS bottom 고정 */
  max-height: 85vh;
  overflow:hidden;                               /* 내부 sheet-body가 스크롤 담당 */
  z-index:600;
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  border-top:1px solid var(--panel-border);
  box-shadow:0 -8px 32px rgba(0,0,0,0.25);
  transition: max-height 0.28s cubic-bezier(0.32, 0.72, 0, 1),
              transform  0.28s cubic-bezier(0.32, 0.72, 0, 1);
  transform: translateY(0);
  touch-action: pan-y;
  display:flex; flex-direction:column;
  will-change: max-height;
}
/* 상태별 max-height — 시트 하단은 CSS bottom에 고정이므로 상단만 변하고 KPI는 절대 가리지 않음 */
.sheet.hidden     { max-height:85vh; transform: translateY(100%); display:flex !important; }
.sheet.sheet-peek { max-height: 100px; transform: translateY(0); }
.sheet.sheet-half { max-height: 42vh;  transform: translateY(0); }
.sheet.sheet-full { max-height: 85vh;  transform: translateY(0); }
.sheet.is-dragging { transition:none; }
.sheet .handle {
  width:40px; height:4px;
  background:rgba(248,249,250,0.70);            /* 라이트 컬러 — 슬레이트 그라디언트 위에서도 또렷함 */
  border-radius:2px;
  cursor:grab;
  position:absolute;                             /* sheet-head 위에 overlay */
  left:50%; top:5px; transform:translateX(-50%);
  margin:0;
  z-index:3;                                     /* sheet-head(z:auto)보다 위 */
  box-shadow:0 1px 2px rgba(0,0,0,0.18);
}
.sheet .handle::before {
  /* 터치 히트 영역 확대 */
  content:""; position:absolute; left:50%; top:-10px;
  width:120px; height:28px; transform:translateX(-50%);
}
.sheet-body {
  font-size:12px;
  overflow-y:auto;
  flex:1 1 auto; min-height:0;
  -webkit-overflow-scrolling: touch;
  padding-bottom:24px;                           /* 마지막 항목이 시트 하단 안쪽 여유 */
  overscroll-behavior:contain;                   /* iOS 스크롤이 부모로 전파되지 않도록 */
}

/* Sheet inner head — sheet 직속 자식(sheet-body 밖), overflow 클리핑 영향 없음 */
.sheet-head {
  margin:0 -16px 10px;                         /* 가로: 폰 sheet padding(16px) 상쇄 — iPad 세로에서 -18px로 override */
  padding:12px 12px 4px;                        /* 핸들(y=5-9) 아래 3px 여유 + 콘텐츠를 핸들 아래 중앙에 */
  height:52px;                                  /* 52px 컴팩트 — 핸들 포함 높이 */
  flex:0 0 52px;
  box-sizing:border-box;
  background:linear-gradient(135deg, rgba(87,117,144,0.55), rgba(87,117,144,0.30));
  border-bottom:1px solid var(--panel-border);
  border-radius:10px 10px 0 0;                 /* 웹 .rightpanel .head와 동일한 10px 라운드 */
  display:flex; justify-content:space-between; align-items:center;
  backdrop-filter: blur(6px) saturate(140%);
  -webkit-backdrop-filter: blur(6px) saturate(140%);
}
.sheet-head:has(.title-card.mission-card) {
  flex-basis:62px; height:62px;                /* 미션카드는 +10px */
}
.sheet-head .sheet-title {
  font-weight:700; font-size:13px;
  color:#F8F9FA; text-shadow:0 1px 2px rgba(0,0,0,0.40);
  display:flex; align-items:center; gap:10px; flex:1; min-width:0;
}
.sheet-head .sheet-close {
  cursor:pointer; font-size:16px; padding:2px 6px;
  color:rgba(248,249,250,0.92);
}

/* ─── Bottom ticker ─── */
.ticker {
  position:fixed; bottom:12px; left:12px; right:12px; height:32px;
  border-radius:10px; z-index:500;
  display:flex; align-items:center; padding:0 12px;
  font-family:var(--font-mono); font-size:11px;
}
.ticker .tag {
  background:var(--red); color:#fff; padding:2px 8px; border-radius:12px;
  font-weight:700; font-size:10px; margin-right:10px;
  animation:blink 1.5s infinite; flex-shrink:0;
}
@keyframes blink { 50%{opacity:0.5;} }
.ticker .stream { flex:1; overflow:hidden; white-space:nowrap; position:relative; }
.ticker .stream-inner { display:inline-block; padding-left:100%; animation: tick 40s linear infinite; }
@keyframes tick { 100% { transform: translateX(-100%); } }
.ticker .e { margin-right:28px; color:var(--text-sub); }
.ticker .e .t { color:var(--text-caption); margin-right:4px; }
.ticker .e.red { color:var(--red); }
.ticker .e.amb { color:var(--amb); }
.ticker .e.yel { color:var(--yel); }
.ticker .e.grn { color:var(--grn); }
.ticker .e.blu { color:var(--blu); }

/* ─── Toasts ─── (좌측 하단 · LIVE 티커 위) */
.toasts {
  position:fixed; bottom:56px; left:12px;
  display:flex; flex-direction:column-reverse; gap:8px; z-index:900; max-width:320px;
  pointer-events:none;
}
.toasts .toast { pointer-events:auto; }
.toast {
  background: var(--panel-bg);
  -webkit-backdrop-filter:blur(14px); backdrop-filter:blur(14px);
  border:1px solid var(--panel-border);
  border-left:3px solid var(--red);
  border-radius:8px; padding:10px 14px; font-size:12px; color:var(--text);
  animation: slidein 0.3s ease;
}
.toast.amb { border-left-color:var(--amb); }
.toast.grn { border-left-color:var(--grn); }
.toast.blu { border-left-color:var(--blu); }
.toast.yel { border-left-color:var(--yel); }
@keyframes slidein { from{transform:translateX(-100%); opacity:0;} to{transform:translateX(0); opacity:1;} }
.toast b { color:var(--text); }

/* ─── Modal (CCTV) ─── */
.modal {
  position:fixed; inset:0; background:rgba(0,0,0,0.7); z-index:1000;
  display:flex; align-items:center; justify-content:center;
  padding: max(12px, env(safe-area-inset-top)) 12px
           max(12px, env(safe-area-inset-bottom)) 12px;
}
.modal-box {
  background:var(--panel-bg); color:var(--text);
  border:1px solid var(--panel-border); border-radius:12px;
  padding:14px; max-width:720px; width:100%;
  max-height: calc(100vh - 24px);
  overflow-y:auto;
}
.modal-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px;
              color:var(--text); font-weight:700; font-size:13px; }
.modal-head .close {
  cursor:pointer; font-size:18px; color:var(--text-sub);
  min-width:32px; min-height:32px;
  display:flex; align-items:center; justify-content:center;
}
#cctvCanvas { width:100%; height:auto; background:#000; border-radius:6px; aspect-ratio: 16/9; }
.modal-caption { font-size:11px; color:var(--text-caption); margin-top:8px; text-align:center; }

/* 모바일/아이패드용 CCTV 모달 반응형 */
@media (max-width:1279px) {
  .modal-box { padding:10px; }
  .modal-box.fire-cctv-box { max-width:none; max-height:none; }
}
@media (max-width:767px) {
  .modal { padding:6px; padding-top:max(6px, env(safe-area-inset-top)); }
  .modal-box { padding:8px; border-radius:10px; }
  .modal-head { font-size:12px; }
}

/* ─── Tab bar (Phone) ─── */
.tabbar {
  position:fixed; left:12px; right:12px; bottom:52px; height:56px;
  border-radius:28px; z-index:500;
  display:none; justify-content:space-around; align-items:center; padding:0 8px;
}
.tabbar .tab {
  display:flex; flex-direction:column; align-items:center; font-size:10px;
  color:var(--text-sub); gap:2px;
  cursor:pointer; min-width:44px; padding:6px 4px; user-select:none;
}
.tabbar .tab .icon { font-size:20px; }
.tabbar .tab.active { color:var(--ora); }
.tabbar .tab.active .icon { filter:drop-shadow(0 0 5px var(--brand)); }

/* ═══════════ Leaflet markers ═══════════ */
/* 산불 — 🔥 이모지 마커 (진화중=빨강, 진화완료=파랑) */
.fire-emoji {
  width:26px; height:26px;
  display:flex; align-items:center; justify-content:center;
  font-size:22px; line-height:1;
  user-select:none;
  text-shadow:
    0 0 4px rgba(0,0,0,0.6),
    0 1px 2px rgba(0,0,0,0.8);
}
.fire-emoji.active {
  filter: drop-shadow(0 0 6px rgba(255,71,87,0.95))
          drop-shadow(0 0 10px rgba(255,71,87,0.6));
  animation: fireGlow 1.4s infinite;
}
.fire-emoji.extinguished {
  /* 파란색 — hue-rotate로 🔥을 파랑 계열로 이동 */
  filter: hue-rotate(200deg) saturate(1.15)
          drop-shadow(0 0 5px rgba(112,161,255,0.85));
  opacity:0.95;
}
@keyframes fireGlow {
  0%,100% { filter: drop-shadow(0 0 6px rgba(255,71,87,0.95))
                    drop-shadow(0 0 10px rgba(255,71,87,0.6)); }
  50%     { filter: drop-shadow(0 0 10px rgba(255,71,87,1))
                    drop-shadow(0 0 18px rgba(255,71,87,0.55)); }
}
.fire-div.unconfirmed {
  width:18px; height:18px; border-radius:50%;
  background:rgba(255,177,66,0.25);
  border:2px dashed var(--amb);
  color:var(--amb); font-size:11px; font-weight:700;
  display:flex; align-items:center; justify-content:center;
  animation: unconfpulse 1.8s infinite;
}
@keyframes unconfpulse {
  0%,100% { box-shadow:0 0 0 2px rgba(255,177,66,0.15); }
  50%     { box-shadow:0 0 0 8px rgba(255,177,66,0.02); }
}

/* FIRMS satellite hotspot */
.firms-div {
  width:12px; height:12px; border-radius:50%;
  background:#ff4500;
  box-shadow:0 0 0 3px rgba(255,69,0,0.3), 0 0 10px #ff4500;
}

/* NOTAM icon */
.notam-div {
  width:24px; height:24px; border-radius:4px;
  background:#ffd700; color:#000;
  display:flex; align-items:center; justify-content:center;
  font-size:12px; font-weight:700;
  box-shadow:0 0 0 2px rgba(0,0,0,0.4);
}

/* 임무 헬기 — 이미지 마커 */
.heli-img {
  width:34px; height:34px; display:flex; align-items:center; justify-content:center;
  transition: transform 0.2s ease;
}
.heli-img img { width:100%; height:100%; object-fit:contain; pointer-events:none; }
.heli-img.mission { filter: drop-shadow(0 0 8px var(--mis)); }
.heli-img.other   {
  width:26px; height:26px;
  /* 라이트 기본 — 원본 유지, 검은 그림자 */
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.55));
  opacity:0.95;
}
/* 다크/위성 — 검은 헬기가 어두운 지도에 묻혀서 안 보이는 문제.
   brightness(0) + invert(1)로 실루엣을 흰색으로 전환 + 파란 글로우(레이어 범례 색) */
body[data-theme="dark"] .heli-img.other img {
  filter: brightness(0) invert(1);
}
body[data-theme="dark"] .heli-img.other {
  filter:
    drop-shadow(0 0 3px rgba(39,125,161,0.90))
    drop-shadow(0 0 6px rgba(39,125,161,0.55));
  opacity:1;
}

/* 산림항공관리소 */
.base-div {
  width:30px; height:30px; display:flex; align-items:center; justify-content:center;
  background:rgba(255,255,255,0.92); border:1.5px solid var(--grn); border-radius:50%;
  box-shadow:0 0 0 2px rgba(46,213,115,0.35), 0 2px 8px rgba(0,0,0,0.55);
  overflow:hidden;
}
.base-div img { width:80%; height:80%; object-fit:contain; pointer-events:none; }

/* BASE 포인트 — 번호 뱃지 */
.base-point-div {
  position:relative;
  width:30px; height:30px; display:flex; align-items:center; justify-content:center;
  border-radius:6px; overflow:visible;
  filter:drop-shadow(0 2px 6px rgba(0,0,0,0.65));
}
.base-point-div img {
  width:100%; height:100%; object-fit:contain; border-radius:5px; pointer-events:none;
}
.base-point-div .bp-num {
  position:absolute; top:-6px; right:-6px;
  min-width:16px; height:16px; padding:0 4px;
  display:flex; align-items:center; justify-content:center;
  font-family:var(--font-mono); font-weight:700; font-size:10px;
  color:#fff; background:var(--brand); border:1.5px solid #fff; border-radius:50%;
  box-shadow:0 1px 3px rgba(0,0,0,0.5);
  line-height:1; pointer-events:none;
}

/* 공항 — 민/군 구분 */
.airport-img { width:28px; height:28px; display:flex; align-items:center; justify-content:center; }
.airport-img img {
  width:100%; height:100%; object-fit:contain;
  filter:drop-shadow(0 0 3px #000); pointer-events:none;
}

/* CCTV — SVG 마커 */
.cctv-img { width:22px; height:22px; display:flex; align-items:center; justify-content:center; }
.cctv-img img { width:100%; height:100%; filter:drop-shadow(0 0 3px #000); pointer-events:none; }

/* Measurement polyline label (centered on line midpoint) */
.measure-label {
  background:#00d8ff; color:#0a0d12;
  padding:4px 10px; border-radius:12px;
  font-family:var(--font-mono); font-size:11.5px; font-weight:800;
  border:1.5px solid #0a0d12;
  white-space:nowrap;
  box-shadow:0 2px 6px rgba(0,0,0,0.35);
  transform:translate(-50%, -50%);
  display:inline-block;
}
body[data-theme="light"] .measure-label {
  background:#0088a0; color:#fff; border-color:#fff;
}

/* Leaflet popup override */
.leaflet-popup-content-wrapper {
  background: var(--popup-bg); color:var(--text);
  border:1px solid var(--panel-border); border-radius:8px;
  box-shadow:0 8px 24px rgba(0,0,0,0.5);
}
.leaflet-popup-tip { background: var(--popup-bg); }
.leaflet-popup-content { margin:10px 12px; font-size:12px; font-family: inherit; }
.leaflet-control-zoom a {
  background: var(--panel-bg) !important; color:var(--text) !important;
  border-color: var(--panel-border) !important;
}
/* Leaflet 저작권(© Esri)은 기본 위치(우측하단) 유지 — LIVE와 겹쳐도 OK
   줌 컨트롤만 LIVE 티커 위로 마진으로 밀어올림 */
.leaflet-control-zoom { margin-bottom: 56px !important; }
.leaflet-control-attribution {
  background: var(--panel-bg) !important;
  color:var(--text-caption) !important; font-size:10px !important;
}
.leaflet-control-attribution a { color:var(--text-sub) !important; }

/* ═══ v6.1 ADDITIONS ═══ */

/* Title card in right panel head: icon + name · 모든 카드 좌우/상하 위치 통일 */
.title-card {
  display:flex; align-items:center; gap:10px;
  min-width:0; flex:1 1 auto;
  padding:0;                                 /* 헤더 padding 사용 — 카드간 좌측 시작 위치 통일 */
  border-radius:6px;
  transition: background 0.25s ease;
  /* height:100% 제거 — align-items:center 로 자연 중앙 정렬 */
}
/* 헤더 내부 타이틀 컨테이너 — title-card + CCTV 버튼 자동 정렬 */
.sheet-head .sheet-title > .title-card,
.rightpanel .head .title > .title-card {
  flex:1 1 auto; min-width:0;
}
.sheet-head .sheet-title > .fire-cctv-btn,
.rightpanel .head .title > .fire-cctv-btn {
  flex:0 0 auto;
  align-self:center;
  margin-left:auto;                          /* 제목 옆 자동 간격 후 우측 정렬 */
}
.title-card .ticon {
  width:32px; height:32px; flex-shrink:0;    /* 모든 일반 카드 동일 크기 */
  aspect-ratio:1 / 1;                         /* 어떤 레이아웃에서도 원형 비율 유지 */
  display:flex; align-items:center; justify-content:center;
  background:transparent; border:none;
  font-size:22px; line-height:1;
  /* overflow:hidden 제거 — 아이콘 이미지의 drop-shadow가 잘리지 않도록 */
}
/* 베이스(basepoint) — 같은 32px 박스 안에서 이미지를 꽉 채움 (크기 통일) */
.title-card.tc-bp .ticon {
  width:32px; height:32px;
}
.title-card.tc-bp .ticon img {
  width:100%; height:100%; object-fit:contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
}
/* 진화된 산불 — 내부 bg 없음 (외부 rpHead bg 통일) · 파란 불꽃 아이콘만 유지 */
.title-card.extinguished-card,
body[data-theme="light"] .title-card.extinguished-card {
  background: transparent;
  border: none;
  box-shadow: none;
}
.title-card.extinguished-card .tname { color:#F8F9FA; }
body[data-theme="light"] .title-card.extinguished-card .tname { color:#F8F9FA; }
.title-card .ticon.blue-flame {
  filter: hue-rotate(185deg) saturate(1.6) brightness(1.1)
          drop-shadow(0 0 6px rgba(112,161,255,0.55));
}
.title-card .ticon img {
  width:100%; height:100%; object-fit:contain; pointer-events:none;
  display:block;                              /* inline 베이스라인 여백 제거 → 32px 안에 정확히 */
}
body[data-theme="light"] .title-card .ticon {
  background:transparent; border:none;
}
.title-card .tname {
  font-weight:800; font-size:14px; letter-spacing:0.3px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.title-card .tsub {
  font-size:11px; color:var(--text-caption); margin-top:2px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}

/* Mission heli title card: 헬기 사진(좌) + FCT/reg/status(우) · 아이콘/텍스트 시작 위치 통일 */
.title-card.mission-card { gap:10px; }    /* 다른 타이틀 카드와 동일한 gap */
.title-card.mission-card .mc-photo {
  width:32px; height:32px; flex-shrink:0;  /* .ticon과 동일 크기 → 텍스트 시작 x위치 통일 */
  aspect-ratio:1 / 1;                      /* 어떤 레이아웃에서도 정사각 유지 */
  display:flex; align-items:center; justify-content:center;
  background:transparent;
}
.title-card.mission-card .mc-info { gap:3px; }
.title-card.mission-card .mc-photo img {
  max-width:100%; max-height:100%; object-fit:contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.45));
}
.title-card.mission-card .mc-info {
  min-width:0; display:flex; flex-direction:column; gap:2px;
}
.title-card.mission-card .mc-tid {
  font-weight:800; font-size:14px; color:#F8F9FA;
  letter-spacing:0.8px; line-height:1.1;
  text-shadow:0 1px 2px rgba(0,0,0,0.35);
}
.title-card.mission-card .mc-reg {
  font-family:var(--font-mono);
  font-weight:700; font-size:11px; color:#E9ECEF;
  letter-spacing:0.5px;
}
.title-card.mission-card .mc-type {
  font-size:10.5px; color:#DEE2E6;
  font-weight:600; letter-spacing:0.2px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.title-card.mission-card .mc-status {
  display:inline-flex; align-items:center; gap:4px;
  font-size:10.5px; font-weight:800;
  color:#F8F9FA; letter-spacing:0.4px;
  margin-top:2px;
}
/* 공통: rpHead 안의 부제(tsub)도 헤더 팔레트 위에서 밝게 */
.title-card .tsub,
body[data-theme="light"] .title-card .tsub {
  color: rgba(248,249,250,0.82);
}
.title-card.mission-card .mc-status::before {
  content:"●"; font-size:10px;
}

/* FCT body header chip row (호기 + BASE + AIR/GROUND) */
.mission-chip-row {
  display:flex; gap:6px; flex-wrap:wrap;
  margin:0 0 8px;
}
.mission-chip {
  display:inline-flex; align-items:center; gap:5px;
  padding:4px 9px; border-radius:12px;
  background:var(--input-bg);
  font-family:var(--font-mono);
  font-size:11px; color:var(--text);
  border:1px solid var(--panel-border);
}
.mission-chip .mc-k {
  color:var(--text-caption); font-weight:700;
  font-size:10px; letter-spacing:0.4px;
}
.mission-chip .mc-v { color:var(--text); font-weight:700; }
.mission-chip.air .mc-v    { color:var(--blu); }
.mission-chip.ground .mc-v { color:var(--grn); }

/* Fire title CCTV button (inline in head) — 흰색 배경 고정 */
.fire-cctv-btn {
  display:inline-flex; align-items:center; justify-content:center;
  height:32px; line-height:1;                /* 타이틀 아이콘(32px)과 완전 일치 */
  box-sizing:border-box;
  background:#FFFFFF; color:#212529;
  border:1px solid #DEE2E6; border-radius:16px;
  font-family:var(--font-mono);
  font-weight:800; font-size:11px; letter-spacing:0.6px;
  padding:0 14px; cursor:pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
  white-space:nowrap;
  vertical-align:middle;
}
.fire-cctv-btn:hover { transform: translateY(-1px); background:#F8F9FA; box-shadow: 0 4px 10px rgba(0,0,0,0.30); }
.fire-cctv-btn:active { transform: translateY(0); }

/* Section heading — Bootstrap 그레이 스케일 뉴트럴 (section 안쪽은 다크/라이트 공통 톤) */
.section-head {
  display:block;
  font-size:13px; font-weight:800; letter-spacing:1.2px; text-transform:uppercase;
  color:#DEE2E6;
  padding:7px 12px; margin-bottom:8px;
  background: linear-gradient(90deg,
                rgba(248,249,250,0.08),
                rgba(248,249,250,0.02));
  border-left: 3px solid #ADB5BD;
  border-radius: 4px;
}
body[data-theme="light"] .section-head {
  color:#343A40;
  background: linear-gradient(90deg,
                rgba(33,37,41,0.08),
                rgba(33,37,41,0.02));
  border-left: 3px solid #6C757D;
}

/* Station / obs time — wx .row 와 동일한 박스칸 형식 (2열 grid) */
.wx.wx-meta-grid { margin-top:4px; }
.wx.wx-meta-grid .row { grid-template-columns: 60px 1fr; }

/* Hourly forecast — 각 시간마다 카드 1장 (1컬럼 스택), 카드 내부는 시간 헤더 + 2열 페어 */
.fc-list {
  display:flex; flex-direction:column; gap:5px;
  font-family:var(--font-mono); font-size:11px;
}
.fc-list .fc-row {
  display:flex; flex-direction:column; gap:4px;
  padding:6px 10px; border-radius:5px;
  background: linear-gradient(180deg,
                rgba(248,249,250,0.05),
                rgba(248,249,250,0.02));
  border:1px solid rgba(248,249,250,0.10);
  min-width:0;
}
.fc-list .fc-hh {
  font-weight:800; color:#F8F9FA;
  letter-spacing:0.4px; text-align:left;
  font-size:11.5px;
  padding-bottom:3px; margin-bottom:2px;
  border-bottom:1px dashed rgba(248,249,250,0.20);
}
.fc-list .fc-grid {
  display:grid; grid-template-columns: 1fr 1fr; gap:3px 12px;
  color:#F8F9FA;
}
.fc-list .fc-cell {
  display:flex; justify-content:space-between; align-items:baseline;
  gap:6px; min-width:0;
}
.fc-list .fc-k {
  color:#ADB5BD; font-weight:600; letter-spacing:0.2px;
  white-space:nowrap;
}
.fc-list .fc-v {
  color:#F8F9FA; word-break:keep-all; text-align:right;
  min-width:0; overflow:hidden; text-overflow:ellipsis;
}
.fc-list .fc-v b { font-weight:700; color:#F8F9FA; }
.fc-list .fc-v.fc-cloud-clear  b { color:#F9C74F; }
.fc-list .fc-v.fc-cloud-few    b { color:#90BE6D; }
.fc-list .fc-v.fc-cloud-partly b { color:#F8961E; }
.fc-list .fc-v.fc-cloud-cloudy b { color:#ADB5BD; }

body[data-theme="light"] .fc-list .fc-row {
  background: linear-gradient(180deg,
                rgba(33,37,41,0.05),
                rgba(33,37,41,0.02));
  border:1px solid rgba(33,37,41,0.12);
}
body[data-theme="light"] .fc-list .fc-hh { color:#212529; border-bottom-color:rgba(33,37,41,0.18); }
body[data-theme="light"] .fc-list .fc-grid { color:#212529; }
body[data-theme="light"] .fc-list .fc-k { color:#495057; font-weight:700; }
body[data-theme="light"] .fc-list .fc-v { color:#212529; }
body[data-theme="light"] .fc-list .fc-v b { color:#212529; }
body[data-theme="light"] .fc-list .fc-v.fc-cloud-clear b { color:#277DA1; }
body[data-theme="light"] .fc-list .fc-v.fc-cloud-few   b { color:#43AA8B; }
body[data-theme="light"] .fc-list .fc-v.fc-cloud-partly b { color:#F8961E; }
body[data-theme="light"] .fc-list .fc-v.fc-cloud-cloudy b { color:#6C757D; }

/* Nearby BASE/FA dual 2-column layout */
.nearby-dual {
  display:grid; grid-template-columns: 1fr 1fr; gap:8px;
}
.nearby-dual .nearby-col .col-head {
  font-size:10px; letter-spacing:0.8px; text-transform:uppercase;
  color:var(--text-caption); font-weight:700; margin-bottom:4px;
}
.nearby-dual .nearby-list { grid-auto-rows:min-content; }

/* ─── Fire-CCTV grid modal ─── */
.modal-box.fire-cctv-box {
  max-width:1040px; max-height:90vh; overflow-y:auto;
  padding:16px;
}
.cctv-live-grid {
  display:grid; grid-template-columns: repeat(3, 1fr); gap:8px;
  margin-bottom:14px;
}
.cctv-live-cell {
  position:relative; background:#000; border-radius:6px; overflow:hidden;
  aspect-ratio: 16 / 9;
  border:1px solid var(--panel-border);
}
.cctv-live-cell canvas {
  width:100%; height:100%; display:block;
}
.cctv-live-cell .cell-name {
  position:absolute; top:6px; left:6px;
  background:rgba(0,0,0,0.55); color:#fff;
  padding:2px 8px; border-radius:4px;
  font-family:var(--font-mono); font-size:10.5px;
  font-weight:600;
  max-width:calc(100% - 60px);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.cctv-live-cell .cell-live {
  position:absolute; top:6px; right:6px;
  background:var(--red); color:#fff;
  padding:2px 6px; border-radius:4px;
  font-size:9.5px; font-weight:800; letter-spacing:0.6px;
  font-family:var(--font-mono);
  animation: blink 1.2s infinite;
  display:flex; align-items:center; gap:4px;
}
.cctv-live-cell .cell-live::before {
  content:""; width:6px; height:6px; background:#fff; border-radius:50%;
}
.cctv-live-cell .cell-dist {
  position:absolute; bottom:6px; right:6px;
  background:rgba(0,0,0,0.55); color:var(--cya);
  padding:2px 6px; border-radius:4px;
  font-family:var(--font-mono); font-size:10px; font-weight:700;
}
.cctv-live-cell:hover { box-shadow: 0 0 0 2px var(--cya); cursor:pointer; }

.cctv-thumbs-head {
  font-size:11px; color:var(--text-caption); font-weight:700;
  margin:4px 0 6px; letter-spacing:0.4px;
}
.cctv-thumbs {
  display:grid; grid-template-columns: repeat(6, 1fr); gap:6px;
}
.cctv-thumb {
  position:relative; aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #2c3e50, #1e272e);
  border-radius:5px; border:1px solid var(--panel-border);
  cursor:pointer; overflow:hidden;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
  display:flex; align-items:center; justify-content:center;
  color:var(--text-sub); font-size:14px;
}
.cctv-thumb:hover { transform: scale(1.04); box-shadow: 0 2px 8px rgba(0,216,214,0.3); }
.cctv-thumb .thumb-label {
  position:absolute; bottom:3px; left:4px; right:4px;
  font-family:var(--font-mono);
  font-size:9px; color:#fff;
  background:rgba(0,0,0,0.6); padding:2px 4px; border-radius:3px;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.cctv-thumb .thumb-dist {
  position:absolute; top:3px; right:4px;
  font-family:var(--font-mono);
  font-size:9px; color:var(--cya);
  background:rgba(0,0,0,0.6); padding:2px 4px; border-radius:3px;
}
.cctv-no-result {
  padding:24px; text-align:center; color:var(--text-caption);
  font-size:12.5px;
}

/* CCTV radius circle marker hint on zoom-in */
.cctv-hover-ring {
  border-radius:50%; border:2px solid var(--cya);
  background:rgba(0,216,214,0.08);
  pointer-events:none;
}

/* ═════════════ Responsive ═════════════ */

/* ═════════════ 공통: 폰 + 아이패드 (≤1279px) — 웹 5칸 KPI 숨김, 모바일 3칸 표시 ═════════════ */
@media (max-width:1279px) {
  /* 상단 topbar에서 중앙 KPI 자리 비우기 — 좌/우 2-zone로 재배치 */
  .topbar {
    grid-template-columns: auto 1fr;
    height:48px;
  }
  .topbar .brand { justify-self:start; }
  .topbar .right { justify-self:end; }

  /* 웹 5칸 KPI 완전 숨김 */
  .kpis-wrap { display:none !important; }

  /* 모바일 3칸 KPI 바 표시 — LIVE 티커 바로 위, 동일 너비 */
  .kpis-mobile {
    display:flex !important;
    bottom: calc(52px + env(safe-area-inset-bottom));   /* LIVE(32) + gap(12) + margin(8) */
    box-sizing:border-box;
    align-items:stretch;
  }
}

/* ═════════════ iPad (768~1279px) — 가로/세로 공통 ═════════════ */
@media (min-width:768px) and (max-width:1279px) {
  .topbar { height:48px; padding:0 8px; }
  .brand { font-size:14px; letter-spacing:0.8px; }
  .leftrail { top:112px; padding:7px; gap:5px; width:52px; }
  .leftrail .tool { width:40px; height:40px; font-size:19px; }
  .layers { top:112px; left:74px; width:260px; font-size:12.5px; }
  .mapmenu { top:112px; left:74px; }
  .share-menu { top:112px; }
  .measure-hint { top:112px; }
  .rightpanel { top:112px; }
  /* LIVE 티커: 최하단 (둥근 + 마진, 데스크톱 스타일) */
  .ticker {
    bottom: calc(10px + env(safe-area-inset-bottom));
    left:12px; right:12px;
    height:30px; font-size:10.5px;
    border-radius:10px;
    padding:0 12px;
  }
  /* 알림(토스트)이 KPI/LIVE 위에 겹치지 않도록 — LIVE(10+30) + gap(12) + KPI(~60) + gap(8) */
  .toasts { top:auto; bottom: calc(120px + env(safe-area-inset-bottom)); left:12px; right:auto; }

  /* Leaflet 컨테이너: 저작권(우측하단)은 기본 위치 유지 */
  .leaflet-bottom.leaflet-right,
  .leaflet-bottom.leaflet-left { bottom: 0 !important; }

  /* 줌 컨트롤: 좌측 레일 새로고침(🔄) 바로 아래로 강제 배치 — fixed 로 컨테이너 무시 */
  .leaflet-top.leaflet-left {
    top: 0 !important; left: 0 !important;
    pointer-events: none;
  }
  .leaflet-control-zoom {
    position: fixed !important;
    top: calc(112px + 342px) !important;
    left: 12px !important;
    margin: 0 !important;
    border-radius: 10px !important;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.28);
    pointer-events: auto;
    z-index: 600;
  }
  .leaflet-control-zoom a {
    width:40px !important; height:40px !important; line-height:40px !important;
    font-size:18px !important;
  }

  .cctv-live-grid { grid-template-columns: repeat(2, 1fr); }

  /* 모바일 3칸 KPI 바 = LIVE 티커와 완전 동일 너비 (좌우 12px, 동일 폭 3칸) */
  .ticker,
  .kpis-mobile {
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    box-sizing: border-box !important;
  }
  .kpis-mobile {
    bottom: calc(52px + env(safe-area-inset-bottom)) !important;
    padding: 4px 0 5px;
    border-radius:10px;
  }
  .kpis-mobile .mkpi { padding: 4px 6px; }
  .kpis-mobile .mkpi .l { font-size:11px; letter-spacing:1.2px; }
  .kpis-mobile .mkpi .v { font-size:22px; }
}

/* iPad 가로 (landscape) — 우측 패널 유지 */
@media (min-width:768px) and (max-width:1279px) and (orientation:landscape) {
  .rightpanel { width:360px; max-height: calc(100vh - 228px); }
  .sheet { display:none !important; }
}

/* iPad 세로 (portrait) — 우측 패널 대신 바텀시트 사용 */
@media (min-width:768px) and (max-width:1279px) and (orientation:portrait) {
  .rightpanel { display:none !important; }
  .sheet {
    display:block;
    left:12px; right:12px;
    bottom: calc(120px + env(safe-area-inset-bottom));  /* LIVE(40) + gap(12) + KPI(~60) + gap(8) */
    border-radius:14px;
    max-height:54vh;
    padding:0 18px 22px;                                  /* top:0 — handle overlay */
    box-shadow:0 -8px 32px rgba(0,0,0,0.25);
  }
  /* iPad 세로 상태별 max-height — 하단 KPI/LIVE 라인 위에서 위만 변화 */
  .sheet.sheet-full { max-height:54vh; }
  .sheet.sheet-half { max-height:32vh; }
  .sheet.sheet-peek { max-height:80px;  }
  /* iPad 세로: sheet padding(18px)에 맞춰 sheet-head 가로 margin override */
  .sheet-head { margin:0 -18px 10px; }
  .sheet.hidden { transform: translateY(calc(100% + 120px)); }
  .tabbar { display:none; }
  .layers, .mapmenu, .share-menu, .measure-hint {
    bottom: calc(120px + env(safe-area-inset-bottom));
  }
}


/* ═════════════ Phone (<768px) ═════════════
   Layout:
   ┌──────────────────────┐
   │ topbar (brand)       │  44px
   ├─┬────────────────────┤
   │L│                    │
   │e│     MAP            │
   │f│                    │
   │t│                    │
   ├─┴────────────────────┤
   │ LIVE ticker          │  26px   (KPI 위)
   ├──────────────────────┤
   │ KPI chip bar         │  44px   (하단 고정)
   └──────────────────────┘
*/
@media (max-width:767px) {
  .topbar { height:44px; padding:0 10px; padding-top:env(safe-area-inset-top); }
  .brand  { font-size:12px; letter-spacing:0.4px; }
  /* KOR/ENG + 시간은 우측 상단 유지 */
  .right  { display:flex; gap:2px; }
  .right .time { font-size:11px; }
  .langSeg .seg-opt { padding:2px 8px; font-size:10.5px; }

  /* 폰 하단 3칸 KPI 바 = LIVE 티커와 완전 동일 너비 */
  .ticker,
  .kpis-mobile {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    box-sizing: border-box !important;
  }
  .kpis-mobile {
    bottom: calc(42px + env(safe-area-inset-bottom)) !important;  /* LIVE(28) + gap(6) + margin(8) */
    padding: 3px 0 4px;
    border-radius:10px;
  }
  .kpis-mobile .mkpi { padding: 3px 4px; }
  .kpis-mobile .mkpi .l { font-size:10px; letter-spacing:0.8px; }
  .kpis-mobile .mkpi .v { font-size:18px; }

  /* ── 좌측 레일 (폰에서도 노출, 아이콘만) ── */
  .leftrail {
    display:flex !important;
    top: calc(52px + env(safe-area-inset-top));
    left:8px;
    width:40px;
    padding:4px; gap:3px;
    border-radius:10px;
  }
  .leftrail .tool {
    width:32px; height:32px; font-size:16px; border-radius:6px;
  }
  .leftrail .sep { margin:1px 0; }

  /* ── 플로팅 팝업(레이어/맵/공유 등) — LIVE(36) + gap(6) + KPI(~50) + gap(8) = 100px ── */
  .layers {
    position:fixed; top:auto;
    bottom: calc(100px + env(safe-area-inset-bottom));
    left:12px; right:12px; width:auto;
    max-height: 48vh;
  }
  .mapmenu      { top:auto; bottom: calc(100px + env(safe-area-inset-bottom)); left:12px; right:12px; width:auto; }
  .share-menu   { top:auto; bottom: calc(100px + env(safe-area-inset-bottom)); left:12px; right:12px; }
  .measure-hint { top:auto; bottom: calc(100px + env(safe-area-inset-bottom)); }

  /* ── 바텀시트: KPI + LIVE 위에 ── */
  .rightpanel { display:none !important; }
  .sheet {
    display:flex;
    bottom: calc(100px + env(safe-area-inset-bottom));
  }
  .sheet.hidden { transform: translateY(calc(100% + 120px)); }

  /* ── LIVE 티커: 최하단 (둥근 모서리 + 마진) ── */
  .ticker {
    bottom: calc(8px + env(safe-area-inset-bottom));
    left:10px; right:10px;
    height:28px; font-size:10px;
    border-radius:10px;
    padding:0 12px;
  }

  /* ── 탭바 제거 (좌측 레일로 일원화) ── */
  .tabbar { display:none !important; }

  /* ── 토스트(알림): KPI + LIVE 위로 ── */
  .toasts {
    top:auto;
    bottom: calc(100px + env(safe-area-inset-bottom));
    left:12px; right:auto; max-width: calc(100% - 24px);
  }

  /* ── 지도 컨트롤: Leaflet 저작권은 기본 위치(우측하단) 유지 ── */
  .leaflet-bottom.leaflet-right,
  .leaflet-bottom.leaflet-left { bottom: 0 !important; }

  /* 줌 컨트롤: 좌측 레일 🔄 바로 아래로 강제 배치 — fixed 사용으로 컨테이너 영향 차단 */
  .leaflet-top.leaflet-left {
    top: 0 !important; left: 0 !important;
    pointer-events: none;
  }
  .leaflet-control-zoom {
    position: fixed !important;
    top: calc(52px + env(safe-area-inset-top) + 262px) !important;
    left: 8px !important;
    margin: 0 !important;
    border-radius: 8px !important;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    pointer-events: auto;
    z-index: 600;
  }
  .leaflet-control-zoom a {
    width:32px !important; height:32px !important; line-height:32px !important;
    font-size:15px !important;
  }

  /* ── 상세 컨텐츠 ── */
  .cctv-live-grid { grid-template-columns: repeat(2, 1fr); }
  .cctv-thumbs    { grid-template-columns: repeat(4, 1fr); }
  .nearby-dual    { grid-template-columns: 1fr 1fr; gap:6px; }
  .nearby-dual .nearby-row { padding:3px 6px; font-size:10.5px; }
  .nearby-dual .n-dist { font-size:10px; }
  .fc-list        { font-size:10.5px; }
  .fc-list .fc-hh { font-size:11px; }
  .fc-list .fc-grid { gap:3px 8px; }
  .wx             { grid-template-columns: 1fr 1fr; font-size:10.5px; }
}

/* Phone landscape — 가로 모드 최적화 */
@media (max-width:926px) and (orientation:landscape) and (max-height:500px) {
  .topbar { height:38px; }
  .brand { font-size:11px; }
  .leftrail { top:42px; width:36px; padding:3px; gap:2px; }
  .leftrail .tool { width:30px; height:30px; font-size:15px; }
  .sheet { height:auto; max-height:80vh; bottom:64px; }
  /* 폰 가로 상태별 max-height — 하단 KPI 라인 위에서 위만 변화 */
  .sheet.sheet-full { max-height:80vh; transform:translateY(0); }
  .sheet.sheet-half { max-height:42vh; transform:translateY(0); }
  .sheet.sheet-peek { max-height:80px; transform:translateY(0); }
  .tabbar { display:none !important; }
  /* 폰 가로: LIVE/KPI 동일 폭 강제 */
  .ticker,
  .kpis-mobile {
    left: 6px !important;
    right: 6px !important;
    width: auto !important;
    box-sizing: border-box !important;
  }
  .ticker { bottom: calc(6px + env(safe-area-inset-bottom)) !important; height:22px; font-size:9.5px; }
  .kpis-mobile { bottom: calc(34px + env(safe-area-inset-bottom)) !important; padding: 2px 0 3px; border-radius:8px; }
  .kpis-mobile .mkpi { padding: 2px 3px; }
  .kpis-mobile .mkpi .l { font-size:9px; letter-spacing:0.5px; }
  .kpis-mobile .mkpi .v { font-size:14px; }
  .layers, .mapmenu, .share-menu, .measure-hint {
    bottom: calc(80px + env(safe-area-inset-bottom));
  }
  .toasts { bottom: calc(80px + env(safe-area-inset-bottom)); }
  /* 저작권 기본 위치, 줌은 레일 하단 바로 아래 — fixed 강제 */
  .leaflet-bottom.leaflet-right,
  .leaflet-bottom.leaflet-left { bottom: 0 !important; }
  .leaflet-top.leaflet-left { top:0 !important; left:0 !important; pointer-events:none; }
  .leaflet-control-zoom {
    position: fixed !important;
    top: calc(42px + 240px) !important;
    left: 6px !important;
    margin: 0 !important;
    border-radius: 6px !important;
    overflow: hidden;
    pointer-events: auto;
    z-index: 600;
  }
  .leaflet-control-zoom a {
    width:30px !important; height:30px !important; line-height:30px !important;
    font-size:14px !important;
  }
}

/* Very small */
@media (max-width:380px) {
  .brand { font-size:10px; }
  .kpis-mobile .mkpi .l { font-size:9px; letter-spacing:0.4px; }
  .kpis-mobile .mkpi .v { font-size:16px; }
  .cctv-thumbs { grid-template-columns: repeat(3, 1fr); }
}

/* Light theme — specific overrides */
body[data-theme="light"] .leaflet-control-zoom a { background:#fff !important; }
body[data-theme="light"] .modal { background:rgba(30,50,80,0.4); }
