/* 지진 모니터 — 관측 모니터 다크 테마 */
:root {
  --bg: #0b0e14;
  --panel: rgba(20, 25, 37, .92);
  --panel-line: #232c3d;
  --text: #e6edf7;
  --muted: #8a97ad;
  --accent: #5b9dff;
  --good: #2eb67d;
  --warn: #f2a900;
  --crit: #e01e5a;
  --p-wave: #37c8ff;
  --s-wave: #ff4b3a;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #map { height: 100%; }
body {
  background: var(--bg); color: var(--text); overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 14px;
}
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
#map { position: absolute; inset: 0; background: #0b0e14; }
.leaflet-container { background: #101623; }

/* ---------- 상단 바 ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 12px; padding: 8px 14px;
}
.brand .logo {
  color: var(--crit); font-size: 20px; font-weight: 900; line-height: 1;
  text-shadow: 0 0 10px rgba(224, 30, 90, .6);
}
.brand h1 { font-size: 15px; font-weight: 700; letter-spacing: -.2px; }
.brand .sub { font-size: 11px; color: var(--muted); }
.top-status { display: flex; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--panel-line);
  padding: 7px 12px; border-radius: 999px; font-size: 12.5px; color: var(--muted);
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.up { background: var(--good); box-shadow: 0 0 6px rgba(46,182,125,.8); }
.dot.down { background: var(--crit); }

/* ---------- 테스트 배너 ---------- */
.test-banner {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  z-index: 1001; background: rgba(242, 169, 0, .95); color: #241a00;
  font-weight: 700; font-size: 13px; padding: 8px 18px; border-radius: 999px;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}

/* ---------- 발표 정보 패널 ---------- */
.event-panel {
  position: absolute; left: 14px; bottom: 46px; z-index: 1000;
  width: 320px; max-width: calc(100vw - 28px);
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 14px; padding: 14px 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.event-panel.alert { border-color: rgba(224,30,90,.6); box-shadow: 0 0 24px rgba(224,30,90,.25); }
.ep-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ep-type {
  font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 999px;
  background: rgba(91,157,255,.16); color: #8ab8ff;
}
.ep-type.warn { background: rgba(242,169,0,.16); color: #ffcf6b; }
.ep-type.crit { background: rgba(224,30,90,.18); color: #ff6b93; }
.ep-live { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: #ff6b93; font-weight: 700; }
.blink { width: 8px; height: 8px; border-radius: 50%; background: var(--crit); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .15; } }
.ep-close {
  margin-left: auto; background: none; border: none; color: var(--muted);
  font-size: 14px; cursor: pointer; padding: 2px 6px;
}
.ep-close:hover { color: var(--text); }
.ep-main { display: flex; gap: 22px; align-items: flex-end; margin-bottom: 8px; }
.m-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.m-value { font-size: 40px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.int-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 40px; padding: 0 10px; border-radius: 9px;
  font-size: 22px; font-weight: 800; background: #2a3448; color: var(--text);
}
.ep-loc { font-size: 15px; font-weight: 600; line-height: 1.45; margin-bottom: 10px; }
.ep-rows .row {
  display: flex; justify-content: space-between; font-size: 12.5px;
  padding: 4px 0; border-top: 1px solid var(--panel-line);
}
.ep-rows .row span { color: var(--muted); }
.ep-note {
  margin-top: 10px; font-size: 12px; color: var(--muted);
  background: rgba(255,255,255,.04); border-radius: 8px; padding: 8px 10px;
  line-height: 1.5;
}

/* 진도 색 (기상청 등급색 계열) */
.int-1 { background:#ffffff; color:#111; }   .int-2 { background:#a0e6ff; color:#0d3b53; }
.int-3 { background:#92d050; color:#1e3a06; } .int-4 { background:#ffff00; color:#4d3d00; }
.int-5 { background:#ffc000; color:#4a2b00; } .int-6 { background:#ff0000; color:#fff; }
.int-7 { background:#a32777; color:#fff; }   .int-8 { background:#632523; color:#fff; }
.int-9 { background:#4c2600; color:#fff; }   .int-10 { background:#000; color:#fff; }
.int-11 { background:#000; color:#ff0; }     .int-12 { background:#000; color:#f00; }

/* ---------- 최근 발표 ---------- */
.recent {
  position: absolute; right: 14px; top: 60px; z-index: 1000;
  width: 290px; max-width: calc(100vw - 28px); max-height: calc(100vh - 140px);
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 14px; display: flex; flex-direction: column; overflow: hidden;
}
.recent-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--panel-line);
}
.recent-head h2 { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
#recent-toggle { background: none; border: none; color: var(--muted); font-size: 15px; cursor: pointer; }
.recent.folded ul { display: none; }
#recent-list {
  list-style: none; overflow-y: auto;
  flex: 1; min-height: 0;                 /* flex 컬럼 안에서 스크롤 가능하게 */
  scrollbar-width: thin; scrollbar-color: #2a3448 transparent;
}
#recent-list::-webkit-scrollbar { width: 8px; }
#recent-list::-webkit-scrollbar-thumb { background: #2a3448; border-radius: 4px; }
#recent-list::-webkit-scrollbar-thumb:hover { background: #3a4a63; }
#recent-list::-webkit-scrollbar-track { background: transparent; }
#recent-list li {
  padding: 9px 14px; border-bottom: 1px solid rgba(35,44,61,.6);
  cursor: pointer; transition: background .12s;
}
#recent-list li:hover { background: rgba(91,157,255,.08); }
#recent-list li.active { background: rgba(91,157,255,.14); }
#recent-list .r1 { display: flex; align-items: center; gap: 8px; }
#recent-list .rtag { font-size: 10.5px; font-weight: 800; padding: 1px 7px; border-radius: 999px; background: rgba(91,157,255,.16); color: #8ab8ff; flex: none; }
#recent-list .rtag.warn { background: rgba(242,169,0,.16); color: #ffcf6b; }
#recent-list .rtag.crit { background: rgba(224,30,90,.18); color: #ff6b93; }
#recent-list .rtag.test { background: rgba(138,151,173,.2); color: var(--muted); }
#recent-list .rmag { margin-left: auto; font-weight: 800; font-size: 13.5px; flex: none; }
#recent-list .rloc { font-size: 12px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#recent-list .rtime { font-size: 10.5px; color: var(--muted); opacity: .75; }
#recent-list .empty { color: var(--muted); cursor: default; }

/* ---------- 진앙 X 마커 ---------- */
.epi-x {
  color: var(--crit); font-size: 40px; font-weight: 900; line-height: 40px;
  text-align: center; text-shadow: 0 0 8px rgba(224,30,90,.9), 0 0 2px #000;
  animation: epi-pulse 1.6s ease-in-out infinite;
}
.epi-x.old { color: #b7c3d6; animation: none; text-shadow: 0 0 3px #000; }
@keyframes epi-pulse { 50% { transform: scale(1.25); } }

/* ---------- 범례 ---------- */
.legend {
  position: absolute; left: 14px; bottom: 8px; z-index: 1000;
  display: flex; gap: 14px; align-items: center;
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 10px; padding: 6px 12px; font-size: 11.5px; color: var(--muted);
}
.legend i { display: inline-block; vertical-align: middle; margin-right: 5px; font-style: normal; }
.lg-x { color: var(--crit); font-weight: 900; }
.lg-p, .lg-s { width: 12px; height: 12px; border-radius: 50%; }
.lg-p { border: 2px solid var(--p-wave); }
.lg-s { border: 2px solid var(--s-wave); background: rgba(255,75,58,.25); }

/* 모바일 */
@media (max-width: 640px) {
  .recent { top: auto; bottom: 46px; right: 14px; width: 250px; max-height: 40vh; }
  .event-panel { bottom: 46px; }
  .brand h1 { font-size: 13px; }
}

/* 로컬 시뮬레이션 종료 버튼 (우측 하단 패널) */
.sim-stop {
  display: block; margin: 8px 12px 0; padding: 9px 10px;
  width: calc(100% - 24px);
  background: #3a2330; color: #ff9aa8;
  border: 1px solid #b8374b; border-radius: 6px;
  font-family: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; letter-spacing: .02em;
}
.sim-stop:hover { background: #4c2b3c; color: #ffc4cd; }

/* 시뮬레이션 재생 중 시계 (과거 시각 = 노란색) */
.pill.sim { border-color: rgba(242,169,0,.5); color: #ffcf6b; }
.big-clock.sim .bc-date, .big-clock.sim .bc-time { color: #ffcf6b; }
body.alertui .big-clock.sim .bc-date,
body.alertui .big-clock.sim .bc-time { color: #ffcf6b; }

/* ---------- 설정 모달 ---------- */
.settings-btn { cursor: pointer; font-size: 14px; border: 1px solid var(--panel-line); }
.settings-btn:hover { color: var(--text); }
.modal-back {
  position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
}
.settings-box {
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 14px; padding: 20px 22px; width: 320px; max-width: calc(100vw - 40px);
}
.settings-box h2 { font-size: 15px; margin-bottom: 14px; }
.settings-box .opt {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--panel-line); border-radius: 10px; margin-bottom: 8px;
  cursor: pointer;
}
.settings-box .opt:hover { border-color: var(--accent); }
.settings-box .opt b { display: block; font-size: 13.5px; }
.settings-box .opt small { color: var(--muted); font-size: 11.5px; }
.settings-close {
  width: 100%; margin-top: 6px; padding: 9px; border-radius: 9px; border: none;
  background: var(--accent); color: #04101f; font-weight: 700; cursor: pointer;
}

/* ---------- 범례 공통 ---------- */
.legend .lg-items { display: flex; gap: 14px; align-items: center; }
.legend .lg-int { display: none; }
.int-chip-s {
  display: flex; align-items: center; justify-content: center;
  height: 20px; min-width: 30px; border-radius: 3px;
  font-size: 12px; font-weight: 800;
}

/* ---------- 대형 시계 ---------- */
.big-clock { display: none; }

/* ============================================================
   경보 모니터 테마 (body.alertui)
   ============================================================ */
body.alertui { --panel: rgba(28,30,36,.96); --panel-line: #14161a; }
body.alertui .leaflet-container { background: #aeb9c4; }

/* 발표 패널 → 경보 박스 */
body.alertui .event-panel {
  background: #3b2a22; border: 2px solid #241812; border-radius: 5px;
  padding: 0; overflow: hidden; width: 344px; color: #fff;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
}
body.alertui .event-panel.alert { border-color: #8d1010; box-shadow: 0 0 26px rgba(200,20,20,.35); }
body.alertui .ep-head { background: #b31414; padding: 7px 12px; margin-bottom: 0; }
body.alertui .ep-type { background: transparent; color: #fff; font-size: 14px; font-weight: 800; padding: 0; }
body.alertui .ep-live { color: #ffd9d9; }
body.alertui .ep-close { color: #fff; opacity: .85; }
body.alertui .ep-main { flex-direction: row-reverse; justify-content: flex-end; padding: 12px 14px 4px; gap: 18px; }
body.alertui .int-chip { min-width: 66px; height: 62px; font-size: 38px; border-radius: 5px; }
body.alertui .m-label { color: #d9c5b8; }
body.alertui .m-value { font-size: 34px; }
body.alertui .ep-loc { padding: 4px 14px 8px; font-size: 16.5px; }
body.alertui .ep-rows { padding: 0 14px 10px; }
body.alertui .ep-rows .row { border-color: rgba(255,255,255,.14); }
body.alertui .ep-rows .row span { color: #d9c5b8; }
body.alertui .ep-note { margin: 0 14px 12px; background: rgba(0,0,0,.28); color: #e9ddd3; }

/* 사이드 패널 → 적색 타이틀 + 진도 칩 + 대형 시계 */
body.alertui .recent { background: #1c1e24; border: 2px solid #101216; border-radius: 5px; }
body.alertui .recent-head { background: #b31414; }
body.alertui .recent-head h2 { color: #fff; letter-spacing: .3px; }
body.alertui #recent-toggle { color: #fff; }
body.alertui #recent-list li { border-color: #292c33; }
body.alertui .big-clock {
  display: block; padding: 8px 14px 10px; text-align: right;
  border-top: 2px solid #101216; background: #17191e;
}
.big-clock .bc-date { font-size: 12px; color: var(--muted); }
.big-clock .bc-time {
  font-size: 30px; font-weight: 800; line-height: 1.15;
  font-variant-numeric: tabular-nums; letter-spacing: .5px;
}

/* 최근 발표 진도 칩 */
.rint {
  margin-left: 6px; flex: none; font-weight: 800; border-radius: 4px;
  padding: 1px 7px; font-size: 11.5px; background: #2a3448;
}
body.alertui .rint { font-size: 15px; min-width: 32px; text-align: center; padding: 3px 7px; }

/* 범례 → 우하단 세로 박스 (진도 스케일 포함) */
body.alertui .legend {
  left: auto; right: 14px; bottom: 100px;
  flex-direction: column; align-items: stretch; gap: 8px;
  background: rgba(28,30,36,.96); border: 2px solid #101216; border-radius: 5px;
  padding: 8px 10px;
}
body.alertui .legend .lg-int { display: flex; flex-direction: column; gap: 3px; }
body.alertui .legend .lg-items { flex-direction: column; align-items: flex-start; gap: 5px; }
body.alertui .lg-p { border-color: #1e50dc; }
body.alertui .lg-s { border-color: #dc1e28; background: rgba(220,30,40,.2); }

/* 진앙 ✕ — 흰 외곽선 */
body.alertui .epi-x {
  color: #dc1e28; text-shadow: none;
  -webkit-text-stroke: 2.5px #fff; paint-order: stroke fill;
}
body.alertui .epi-x.old { color: #6b7684; -webkit-text-stroke: 2px #fff; }

/* 상단 바/배너는 다크 패널 유지 (라이트 지도 위 가독성) */
body.alertui .topbar .brand, body.alertui .pill { border-width: 2px; }

/* ============================================================
   경보 모니터 전용 UI. 이전 덧칠 규칙은
   아래에서 클래식 요소를 통째로 숨기므로 사실상 무효.
   ============================================================ */
[hidden] { display: none !important; }   /* display 규칙이 hidden을 이기는 버그 방지 */

.q-alertbox, .q-side, .q-legend { display: none; }

body.alertui .topbar,
body.alertui .event-panel,
body.alertui .recent,
body.alertui .legend { display: none !important; }
body.alertui #map { right: 376px; }
body.alertui .test-banner { left: calc((100vw - 376px) / 2); }

/* 지도 톤: 무채색 라이트 (기상청/Natural Earth 느낌) */
body.alertui .leaflet-container { background: #93a2b5; }
body.alertui .leaflet-tile { filter: saturate(.4) brightness(.97); }

/* ---------- 좌상단 경보 박스 ---------- */
body.alertui .q-alertbox {
  display: block; position: absolute; top: 10px; left: 10px; z-index: 1100;
  min-width: 380px; max-width: min(540px, calc(100vw - 420px));
  box-shadow: 0 5px 18px rgba(0,0,0,.5); color: #fff;
}
.q-ab-head { display: flex; align-items: stretch; }
.q-ab-type { background: #8d1410; font-weight: 900; font-size: 15.5px; padding: 6px 12px; white-space: nowrap; }
.q-ab-lvl { background: #e01010; font-weight: 900; font-size: 15.5px; padding: 6px 10px; }
.q-ab-time { background: #4a3629; font-size: 16px; font-weight: 800; padding: 7px 12px; flex: 1; white-space: nowrap; display: flex; align-items: center; }
.q-ab-tag { background: #6d6152; font-size: 12px; font-weight: 700; padding: 8px 10px; }
.q-ab-close { background: #4a3629; border: none; color: #d8c9bd; padding: 0 11px; cursor: pointer; font-size: 13px; }
.q-ab-close:hover { color: #fff; }
.q-ab-body { display: flex; background: #3d2b1f; }
.q-ab-int { display: flex; align-items: center; gap: 9px; padding: 10px 14px; background: #5c1230; color: #fff; }
.q-ab-int span { font-size: 13px; font-weight: 700; line-height: 1.3; }
.q-ab-int b { font-size: 52px; font-weight: 900; line-height: 1; }
.q-ab-info { padding: 9px 14px; display: flex; flex-direction: column; justify-content: center; gap: 3px; min-width: 0; }
.q-ab-loc { font-size: 20px; font-weight: 800; line-height: 1.3; word-break: keep-all; }
.q-ab-mag { font-size: 14.5px; }
.q-ab-mag b { font-size: 19px; font-weight: 900; }
.q-ab-mag i { font-style: normal; margin-left: 10px; opacity: .9; }

/* ---------- 우측 사이드 패널 ---------- */
body.alertui .q-side {
  display: flex; flex-direction: column;
  position: absolute; top: 0; right: 0; bottom: 0; width: 376px; z-index: 1050;
  background: #26282d; border-left: 3px solid #0e0f12; color: #fff;
}
.q-title { display: flex; align-items: center; gap: 10px; background: #c01414; padding: 10px 12px; }
.q-title .dot { flex: none; }
.q-title-txt { flex: 1; text-align: center; font-size: 19px; font-weight: 900; letter-spacing: normal; }
.q-gear {
  background: rgba(255,255,255,.16); border: none; color: #fff; border-radius: 4px;
  width: 27px; height: 27px; cursor: pointer; font-size: 13px; flex: none;
}
.q-gear:hover { background: rgba(255,255,255,.3); }
#q-detail-toggle { display: none; }   /* 모바일 전용 상세 토글 */
.q-sub { display: flex; align-items: center; gap: 8px; padding: 7px 12px; background: #1c1e22; font-size: 13px; color: #cfd3da; }
.q-sub-tags { margin-left: auto; display: flex; gap: 4px; }
.q-sub-tags b { background: #8d1410; color: #fff; padding: 2px 9px; font-size: 12px; border-radius: 2px; font-weight: 800; }
.q-sub-tags b.lvl { background: #e01010; }
.q-sub-tags b.tst { background: #6d6152; }
.q-block { display: flex; background: #d01010; color: #fff; }
.q-block-int { padding: 10px 4px 10px 14px; display: flex; flex-direction: column; justify-content: center; flex: none; }
.q-block-int em { font-style: normal; font-size: 13px; font-weight: 800; }
.q-block-int b { font-size: 46px; font-weight: 900; line-height: 1.05; }
.q-block-loc { flex: 1; padding: 10px 14px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.q-block-loc b { font-size: 18.5px; font-weight: 900; line-height: 1.3; word-break: keep-all; }
.q-block-loc span { font-size: 13px; margin-top: 3px; opacity: .95; }
.q-warnstrip { background: #e05a10; color: #fff; font-weight: 800; font-size: 13.5px; text-align: center; padding: 6px 10px; }
.q-sec { background: #17181c; font-size: 13.5px; font-weight: 800; padding: 8px 12px; border-top: 2px solid #0e0f12; }
.q-rows { list-style: none; flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #3a3d45 transparent; }
.q-rows::-webkit-scrollbar { width: 8px; }
.q-rows::-webkit-scrollbar-thumb { background: #3a3d45; border-radius: 4px; }
.q-rows li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid #33363e; background: #2c2e34; }
/* 지역별 진도 행 */
.q-int-chip { min-width: 58px; height: 36px; display: flex; align-items: center; justify-content: center; font-size: 21px; font-weight: 900; border-radius: 3px; flex: none; }
.q-int-name { font-size: 17px; font-weight: 800; }
/* 최근 발표 행 (진원·진도 정보) */
.q-rows li.q-ev { cursor: pointer; }
.q-rows li.q-ev:hover { filter: brightness(1.12); }
.q-ev-l { flex: 1; min-width: 0; }
.q-ev-time { font-size: 12px; opacity: .8; }
.q-ev-loc { font-size: 15.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-ev-mag { font-size: 14px; font-weight: 800; flex: none; }
.q-ev-int { min-width: 38px; text-align: center; font-size: 23px; font-weight: 900; flex: none; }
/* 행 배경 = 진도색 */
.q-rows li.rowint-2 { background: #a0e6ff; color: #0d3b53; border-color: #86cbe6; }
.q-rows li.rowint-3 { background: #92d050; color: #1e3a06; border-color: #7cb83f; }
.q-rows li.rowint-4 { background: #ffff00; color: #4d3d00; border-color: #e0e000; }
.q-rows li.rowint-5 { background: #ffc000; color: #4a2b00; border-color: #e0a800; }
.q-rows li.rowint-6 { background: #ff0000; color: #fff; border-color: #d40000; }
.q-rows li.rowint-7 { background: #a32777; color: #fff; border-color: #8a1f63; }
.q-rows li.rowint-8 { background: #632523; color: #fff; border-color: #501c1a; }
.q-rows li.rowint-9 { background: #4c2600; color: #fff; border-color: #3a1d00; }
.q-rows li.rowint-10, .q-rows li.rowint-11, .q-rows li.rowint-12 {
  background: #000; color: #fff; border-color: #333; }
/* 대형 시계/푸터 */
body.alertui .big-clock {
  display: flex; align-items: baseline; justify-content: space-between;
  border-top: 2px solid #0e0f12; background: #1c1e22; padding: 8px 14px;
}
body.alertui .big-clock .bc-date { font-size: 14.5px; font-weight: 700; color: #e6e8ec; }
body.alertui .big-clock .bc-time { font-size: 38px; font-weight: 900; letter-spacing: 1px; font-variant-numeric: tabular-nums; line-height: 1.05; }
.q-footer { background: #17181c; color: #878d99; font-size: 11.5px; padding: 5px 12px; border-top: 1px solid #0e0f12; }

/* ---------- 세로 범례 ---------- */
body.alertui .q-legend {
  display: flex; flex-direction: column; gap: 4px;
  position: absolute; right: 392px; bottom: 38px; z-index: 1040;
  background: rgba(38,40,45,.97); border: 2px solid #0e0f12; border-radius: 4px;
  padding: 9px 11px; color: #fff;
}
.q-lg-row { display: flex; align-items: center; gap: 9px; }
.q-lg-row em { font-style: normal; font-size: 12.5px; font-weight: 700; }
.q-lg-row .int-chip-s { min-width: 36px; height: 21px; font-size: 13px; }
.q-lg-div { height: 1px; background: #3a3d45; margin: 4px 0; }
body.alertui .q-legend .lg-s { width: 15px; height: 15px; border: 2.5px solid #dc1e28; background: transparent; border-radius: 50%; }
body.alertui .q-legend .lg-p { width: 15px; height: 15px; border: 2.5px solid #1e50dc; border-radius: 50%; }
body.alertui .q-legend .lg-x { color: #dc1e28; font-weight: 900; -webkit-text-stroke: 1.5px #fff; paint-order: stroke fill; }

/* 진앙 ✕/설정 버튼 등은 공통 규칙 재사용 */
body.alertui .modal-back { z-index: 3000; }
/* 평시(비실시간) 타이틀 바 / 목록 구분 헤더 */
.q-title.calm { background: #2f3238; }
.q-rows li.q-subhead {
  background: #17181c; color: #fff; font-weight: 800; font-size: 13px;
  padding: 8px 12px; border-top: 2px solid #0e0f12; cursor: default;
}

/* ---------- 나눔스퀘어 폰트 (디자인 고정) ---------- */
body, button, input, select {
  font-family: 'NanumSquare', -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans KR", "Malgun Gothic", sans-serif;
}

/* 지도 다크 스타일 (설정) */
body.map-dark .leaflet-container { background: #101623; }
body.alertui.map-dark .leaflet-tile { filter: none; }
a.q-gear { display: flex; align-items: center; justify-content: center; text-decoration: none; font-size: 14px; }

/* ---------- 설정 오버레이 ---------- */
.stg-box {
  background: #26282d; border: 2px solid #101216; border-radius: 8px;
  width: 480px; max-width: calc(100vw - 32px); max-height: calc(100vh - 60px);
  overflow-y: auto; padding: 0 18px 18px; color: #e8eaee;
}
.stg-head {
  display: flex; align-items: center; background: #c01414;
  margin: 0 -18px 4px; padding: 12px 18px;
}
.stg-head h2 { flex: 1; text-align: center; font-size: 17px; font-weight: 900; letter-spacing: normal; color: #fff; }
.stg-close { background: rgba(255,255,255,.16); border: none; color: #fff; border-radius: 4px; width: 26px; height: 26px; cursor: pointer; }
.stg-close:hover { background: rgba(255,255,255,.3); }
.stg-box h3 { font-size: 12.5px; font-weight: 800; color: #9aa1ad; margin: 16px 0 8px; letter-spacing: .5px; }
.stg-card { background: #1f2126; border: 1px solid #101216; border-radius: 6px; overflow: hidden; }
.stg-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid #33363e; }
.stg-row:last-child { border-bottom: none; }
.stg-info { flex: 1; min-width: 0; }
.stg-info b { display: block; font-size: 14px; font-weight: 800; }
.stg-info small { color: #9aa1ad; font-size: 11.5px; line-height: 1.5; }
.stg-switch { position: relative; width: 44px; height: 25px; flex: none; }
.stg-switch input { opacity: 0; width: 0; height: 0; }
.stg-slider { position: absolute; inset: 0; border-radius: 999px; background: #3a3d45; transition: background .15s; cursor: pointer; }
.stg-slider::before { content: ""; position: absolute; width: 19px; height: 19px; border-radius: 50%; left: 3px; top: 3px; background: #9aa1ad; transition: transform .15s, background .15s; }
.stg-switch input:checked + .stg-slider { background: rgba(46,182,125,.4); }
.stg-switch input:checked + .stg-slider::before { transform: translateX(19px); background: #2eb67d; }
.stg-seg { display: flex; gap: 6px; flex: none; }
.stg-seg label { padding: 6px 14px; border-radius: 5px; border: 2px solid #3a3d45; font-size: 12.5px; font-weight: 800; cursor: pointer; color: #c9ced8; }
.stg-seg input { display: none; }
.stg-seg label:has(input:checked) { border-color: #c01414; background: rgba(192,20,20,.18); color: #fff; }
.stg-box input[type="range"] { width: 120px; accent-color: #c01414; flex: none; }
.stg-val { min-width: 42px; text-align: right; font-weight: 800; font-size: 13.5px; flex: none; }
.stg-reset { margin-top: 16px; width: 100%; padding: 11px; border-radius: 6px; border: 2px solid #3a3d45; background: none; color: #9aa1ad; font-family: inherit; font-size: 13px; font-weight: 800; cursor: pointer; }
.stg-reset:hover { border-color: #c01414; color: #ff8080; }
.stg-note { margin-top: 10px; color: #6f7683; font-size: 11.5px; text-align: center; }

.stg-btn {
  flex: none; padding: 7px 18px; border-radius: 5px; border: 2px solid #3a3d45;
  background: none; color: #e8eaee; font-family: inherit; font-size: 13px;
  font-weight: 800; cursor: pointer;
}
.stg-btn:hover { border-color: #c01414; background: rgba(192,20,20,.15); }

/* 설정 탭 */
.stg-tabs {
  display: flex; gap: 4px; margin-bottom: 14px;
  border-bottom: 2px solid #26282e;
}
.stg-tab {
  background: none; border: none; color: #9aa1ad; font-family: inherit;
  font-weight: 800; font-size: 13.5px; padding: 8px 13px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.stg-tab:hover { color: #dfe3ea; }
.stg-tab.active { color: #fff; border-bottom-color: #c01414; }

/* 경보 박스 진도 라벨: 임의 줄바꿈 방지 (예상/최대진도 2줄 고정) */
.q-ab-int { flex: none; }
.q-ab-int span { white-space: nowrap; }

/* ---------- 일본 진도색 (JMA 계열, rank 1~9 = 1,2,3,4,5약,5강,6약,6강,7) ---------- */
.jint-1 { background:#51b3fc; color:#111; } .jint-2 { background:#81d25a; color:#111; }
.jint-3 { background:#f0dc7b; color:#3d3000; } .jint-4 { background:#f57b43; color:#2d1200; }
.jint-5 { background:#ad1121; color:#fff; } .jint-6 { background:#ad1121; color:#fff; }
.jint-7 { background:#fecada; color:#a01c2f; } .jint-8 { background:#fecada; color:#a01c2f; }
.jint-9 { background:#b50068; color:#fff; }
/* 일본 발표 행 배경 (진도 3+) — NHK 배색 */
.q-rows li.jrowint-3 { background:#f0dc7b; color:#3d3000; border-color:#d6c25e; }
.q-rows li.jrowint-4 { background:#f57b43; color:#2d1200; border-color:#d96530; }
.q-rows li.jrowint-5 { background:#ad1121; color:#fff; border-color:#8d0d1a; }
.q-rows li.jrowint-6 { background:#ad1121; color:#fff; border-color:#8d0d1a; }
.q-rows li.jrowint-7 { background:#fecada; color:#a01c2f; border-color:#e5aebe; }
.q-rows li.jrowint-8 { background:#fecada; color:#a01c2f; border-color:#e5aebe; }
.q-rows li.jrowint-9 { background:#b50068; color:#fff; border-color:#960056; }

.q-sub-tags b.rep { background: #6d6152; }

/* 갱신줄: 칩 내부 줄바꿈 금지, 부족하면 칩 단위로 개행 */
.q-sub { flex-wrap: wrap; row-gap: 4px; }
.q-sub > span:first-child { white-space: nowrap; }
.q-sub-tags { flex-wrap: wrap; row-gap: 4px; }
.q-sub-tags b { white-space: nowrap; }

/* 일본 긴급지진속보(예보): 노란 테마 — 경보·국내 발표는 빨강 유지 */
.q-title.forecast { background: #e0a800; }
.q-title.forecast .q-title-txt { color: #201600; }
.q-ab-type.forecast { background: #c69100; color: #201600; }


/* 일본 세분구역 중심 진도 배지 (JMA 지도 표기) */
.jp-int-badge {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 5px; font-weight: 900; font-size: 17px; line-height: 1;
  border: 2.5px solid rgba(255,255,255,.95); box-shadow: 0 2px 6px rgba(0,0,0,.55);
  font-family: 'NanumSquare', sans-serif; letter-spacing: -0.5px;
}

/* 긴급지진속보 취소 안내 */
.q-ab-type.cancel { background: #4a4e57; }

/* 취소된 발표 목록 행 */
.q-ev.cancelled { opacity: .55; }
.q-ev .ev-cancel { background: #4a4e57; color: #fff; border-radius: 4px;
  padding: 1px 6px; font-size: 10.5px; font-weight: 800; }

/* 좌하단 실시간 관측진도(강진모니터) 패널 */
body.alertui .km-panel {
  position: fixed; left: 10px; bottom: 28px; z-index: 940;
  background: rgba(24,26,32,.92); border: 1px solid #33363e; border-radius: 8px;
  padding: 8px 12px 9px; min-width: 158px; color: #e8eaee;
  font-family: 'NanumSquare', sans-serif; box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
body.alertui .km-panel .km-title { font-size: 11.5px; font-weight: 800; color: #aab2c0;
  margin-bottom: 6px; }
body.alertui .km-panel .km-title small { font-weight: 700; color: #6d7686; margin-left: 3px; }
body.alertui .km-panel .km-row { display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px; }
body.alertui .km-panel .km-chip-s { width: 26px; height: 26px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center; flex: none;
  font-size: 13.5px; font-weight: 900; }
body.alertui .km-panel .km-reg { flex: 1; font-size: 13px; font-weight: 800; }
body.alertui .km-panel .km-row em { font-style: normal; font-size: 11.5px;
  color: #9aa3b2; font-weight: 700; }
body.alertui .km-panel .km-row.km-calm .km-reg { color: #8b93a3; font-weight: 700; }
body.alertui .km-panel .km-more { font-size: 10.5px; color: #8b93a3; margin: 2px 0 4px 34px; }
body.alertui .km-panel .km-foot { font-size: 10.5px; color: #6d7686; margin-top: 5px;
  border-top: 1px solid #2c2f37; padding-top: 5px; }
.km-panel[hidden] { display: none !important; }
@media (max-width: 900px) { body.alertui .km-panel { display: none; } }

/* 쓰나미예보 패널: 등급 헤더 + 지역 행 */
.q-rows li.tsu-head { display: block; font-weight: 900; font-size: 13px;
  padding: 5px 10px; border-radius: 5px; margin: 7px 0 3px; border: none; }
.q-rows li.tsu-row { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; background: #23262d; border: 1px solid #2e323a; padding: 6px 10px; }
.q-rows li.tsu-row .tsu-name { font-weight: 800; font-size: 13px; }
.q-rows li.tsu-row em { font-style: normal; font-size: 11.5px; color: #9aa3b2;
  font-weight: 700; white-space: nowrap; }

/* 미소지진 목록 행 */
.q-ev.micro { opacity: .6; }

/* 왼쪽 경보박스 참고사항 */
.q-ab-note { background: #2c2620; color: #e8d9b8; font-size: 14.5px; font-weight: 700;
  padding: 7px 12px; line-height: 1.5; border-top: 1px solid rgba(255,255,255,.08); }

/* 추가 지진속보 스택 (주 경보박스 바로 아래) */
body.alertui .q-substack { position: fixed; left: 10px; z-index: 949;
  top: 148px; display: flex; flex-direction: column; gap: 6px; max-width: 460px; }
body.alertui .q-substack[hidden] { display: none !important; }
body.alertui .q-sub-alert { display: flex; align-items: center; gap: 10px;
  background: #b01214; color: #fff; border-radius: 6px; padding: 7px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.45); font-family: 'NanumSquare', sans-serif; }
body.alertui .q-sub-alert.forecast { background: #c98a00; color: #241a00; }
body.alertui .q-sub-alert .qsa-type { font-size: 12px; font-weight: 900;
  background: rgba(0,0,0,.25); border-radius: 4px; padding: 2px 7px; white-space: nowrap; }
body.alertui .q-sub-alert .qsa-loc { font-size: 14px; font-weight: 800; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.alertui .q-sub-alert .qsa-meta { font-size: 12.5px; font-weight: 800; white-space: nowrap; }

/* 스택 내 경보박스: 주 박스와 동일 레이아웃, 컨테이너 안에 정적 배치 */
body.alertui .q-substack .q-alertbox.in-stack { position: static; display: block; }

/* 경보박스 태그·배지 줄바꿈 방지 (테스/트 분리 현상) */
.q-ab-tag, .q-ab-type, .q-ab-lvl { white-space: nowrap; flex: none; }
.q-ab-head { flex-wrap: nowrap; }
.q-ab-head .q-ab-time { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* 다중 스택: 현재 화면 소유자(최신 지진속보) 강조 */
body.alertui .q-substack .q-alertbox.in-stack.owner {
  outline: 2.5px solid rgba(255,255,255,.55); }

/* 해일예보 전용 왼쪽 스택 박스 (지진속보 스택과 분리, 발보~해제 상시) */
body.alertui .q-tsubox { position: fixed; left: 10px; top: 10px; z-index: 948;
  min-width: 380px; max-width: min(540px, calc(100vw - 420px));
  border-radius: 6px; overflow: hidden; box-shadow: 0 5px 18px rgba(0,0,0,.5);
  font-family: 'NanumSquare', sans-serif; }
body.alertui .q-tsubox[hidden] { display: none !important; }
body.alertui .q-tsubox .qtb-head { display: flex; align-items: center; gap: 10px;
  background: #7c00b8; color: #fff; padding: 7px 12px; }
body.alertui .q-tsubox .qtb-type { font-size: 14px; font-weight: 900; }
body.alertui .q-tsubox .qtb-time { font-size: 12.5px; font-weight: 800; opacity: .9;
  margin-left: auto; white-space: nowrap; }
body.alertui .q-tsubox .qtb-row { display: flex; align-items: center;
  justify-content: space-between; padding: 6px 12px; font-size: 13.5px; }
body.alertui .q-tsubox .qtb-row b { font-weight: 900; }
body.alertui .q-tsubox .qtb-row span { font-weight: 800; }

/* 해일예보 발효 중 축소 진도 배지 (해안선 가림 최소화) */
.jp-int-badge.small { width: 20px; height: 20px; font-size: 11.5px;
  border-radius: 4px; border-width: 1.5px; letter-spacing: -0.3px;
  box-shadow: 0 1px 4px rgba(0,0,0,.5); }

/* 효과음 테스트 버튼 그리드 */
.stg-sndgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  padding: 2px 0 4px; }
.stg-sndgrid .snd { width: 100%; font-size: 12.5px; padding: 8px 6px; }

/* ============ 모바일/좁은 화면 레이아웃 ============
   구성: 상단 경보 카드(전체폭) — 지도 — 하단 정보 시트(38vh).
   지도 컨테이너 자체를 시트 높이만큼 줄여, 진앙·파형이 시트에
   가려지지 않고 지도 중심 계산도 보이는 영역 기준이 되게 한다. */
@media (max-width: 900px) {
  /* 모바일 기본: 상단 경보 카드 + 지도 + 시계 바. ☰ 버튼(.mob-detail)을
     누르면 우측 패널의 상세(경보 정보·지역별 진도·최근 발표)가 시트로 펼쳐짐 */
  body.alertui #map { right: 0; bottom: calc(58px + env(safe-area-inset-bottom)); }
  /* 시계 바에 가리지 않게 줌 컨트롤을 살짝 띄움 */
  body.alertui .leaflet-bottom.leaflet-right .leaflet-control { margin-bottom: 12px; }
  body.alertui .q-side {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: auto;
    border-left: none; border-top: 3px solid #0e0f12;
    padding-bottom: env(safe-area-inset-bottom);
    position: absolute;
  }
  body.alertui.mob-detail .q-side { height: 62vh; }
  /* 접힘 상태에서는 시계 바만 남긴다 */
  body:not(.mob-detail).alertui .q-side .q-sub,
  body:not(.mob-detail).alertui .q-side .q-block,
  body:not(.mob-detail).alertui .q-side .q-warnstrip,
  body:not(.mob-detail).alertui .q-side .q-sec,
  body:not(.mob-detail).alertui .q-side .q-rows { display: none; }
  body.alertui .q-side .q-footer { display: none; }
  body.alertui #q-detail-toggle { display: inline-flex; align-items: center; justify-content: center; }
  /* 설정·상세 버튼은 시계 바 왼쪽에 고정 (펼침 상태에서도 같은 자리) */
  body.alertui .q-side .q-title {
    display: flex; position: absolute; left: 8px;
    bottom: calc(14px + env(safe-area-inset-bottom)); top: auto; z-index: 2;
    background: none; padding: 0; gap: 6px;
  }
  body.alertui .q-side .q-title .dot,
  body.alertui .q-side .q-title .q-title-txt { display: none; }
  body.alertui .big-clock { padding: 0 12px; height: 55px; align-items: center; }
  body.alertui .big-clock .bc-date { padding-left: 74px; }
  /* 진도 배지: 좁은 화면에서는 축소 (중심 앵커라 위치 변화 없음) */
  .jp-int-badge { transform: scale(.62); }
  .jp-int-badge.small { transform: scale(.8); }
  body.alertui .q-side .sim-stop { margin: 8px 12px; }
  body.alertui .q-legend { display: none; }
  body.alertui .q-alertbox { max-width: calc(100vw - 16px); min-width: 0; }
  body.alertui .test-banner {
    left: 8px; right: 8px; transform: none; width: auto;
    font-size: 12px; text-align: center;
  }
}

@media (max-width: 740px) {
  /* ── 경보 카드: 전체폭 + 축소 ── */
  body.alertui .q-alertbox { left: 8px; right: 8px; top: 8px; }
  .q-ab-type { font-size: 12px; padding: 5px 8px; }
  .q-ab-lvl { font-size: 12px; padding: 5px 8px; }
  .q-ab-time { font-size: 12px; padding: 5px 8px; }
  .q-ab-tag { font-size: 10px; padding: 6px 7px; }
  .q-ab-int { padding: 7px 10px; gap: 7px; }
  .q-ab-int span { font-size: 10.5px; }
  .q-ab-int b { font-size: 32px; }
  .q-ab-loc { font-size: 15px; }
  .q-ab-mag { font-size: 12px; }
  .q-ab-mag b { font-size: 14.5px; }
  .q-ab-note { font-size: 11.5px; }

  /* ── 하단 시트 내부 축소 ── */
  .q-title { padding: 7px 10px; }
  .q-title-txt { font-size: 15px; }
  .q-sub { padding: 5px 10px; font-size: 11.5px; }
  .q-block-int { padding: 8px 4px 8px 12px; }
  .q-block-int em { font-size: 11px; }
  .q-block-int b { font-size: 32px; }
  .q-block-loc { padding: 8px 12px; }
  .q-block-loc b { font-size: 15.5px; }
  .q-block-loc span { font-size: 11.5px; }
  .q-warnstrip { font-size: 12px; padding: 5px 8px; }
  .q-sec { font-size: 12px; padding: 6px 10px; }
  .q-rows li { padding: 6px 10px; gap: 8px; }
  .q-int-chip { min-width: 46px; height: 30px; font-size: 17px; }
  .q-ev-time { font-size: 10.5px; }
  .q-ev-loc { font-size: 13.5px; }
  .q-ev-mag { font-size: 12.5px; }
  .q-ev-int { min-width: 30px; font-size: 19px; }
  .q-footer { font-size: 10px; }
  body.alertui .big-clock .bc-date { font-size: 12px; }
  body.alertui .big-clock .bc-time { font-size: 26px; letter-spacing: .5px; }

  /* ── 설정 모달: 전체폭 시트 ── */
  .stg-box { width: calc(100vw - 20px) !important; max-height: 86vh; }
}

/* 언어 선택 활성 버튼 */
#stg-lang { display: flex; gap: 6px; }
.stg-btn.on { border-color: #c01414; background: rgba(192,20,20,.25); color: #fff; }
