/* 전쟁나면 — 색은 세 가지 뜻만: 빨강 = 위급, 초록 = 안전·완료, 회색 = 준비.
   글자 최소 16px(본문 18px), 단추 높이 최소 56px, 어두운 바탕(정전·야간·배터리). */
:root {
  --bg: #0e0f12;
  --panel: #17191e;
  --panel-2: #20232a;
  --line: #2c3038;
  --text: #f3f4f6;
  --muted: #a3a9b5;
  --red: #e5383b;
  --red-deep: #b3161a;
  --red-soft: rgba(229, 56, 59, .14);
  --amber: #f2a93b;
  --purple: #a78bfa;
  --green: #2fbf71;
  --green-soft: rgba(47, 191, 113, .14);
  --blue: #4ea1ff;
  --radius: 16px;
  --tabs-h: 68px;
  --font: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 18px/1.55 var(--font); letter-spacing: -.01em;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  word-break: keep-all; overflow-wrap: anywhere;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.3; margin: 0; }

/* 머리 */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(14, 15, 18, .94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { text-decoration: none; display: flex; flex-direction: column; min-width: 0; }
.logo { font-size: 26px; font-weight: 900; letter-spacing: -.04em; line-height: 1.1; }
.logo::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--red); margin-right: 8px; vertical-align: 5px; box-shadow: 0 0 0 4px var(--red-soft); }
.sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.net { flex: none; font-size: 13px; padding: 5px 10px; border-radius: 999px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.net.ok { color: var(--green); background: var(--green-soft); }
.net.off { color: #fff; background: var(--red-deep); }

main { max-width: 640px; margin: 0 auto; padding: 16px; outline: none; }
.sec { margin: 28px 0 0; }
.sec > h2 { font-size: 20px; margin-bottom: 12px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sec > h2 small { font-size: 14px; color: var(--muted); font-weight: 500; }
.lead { color: var(--muted); margin: 6px 0 0; }
.muted { color: var(--muted); }
.small { font-size: 15px; }

/* 큰 단추 둘 */
.hero { display: grid; gap: 12px; }
.big {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; padding: 22px 20px; border-radius: 20px;
  text-decoration: none; border: 0; width: 100%; text-align: left; cursor: pointer;
}
.big b { display: block; font-size: 26px; letter-spacing: -.03em; }
.big span { display: block; font-size: 16px; opacity: .9; margin-top: 2px; }
.big .arrow { font-size: 30px; flex: none; }
.big.red { background: linear-gradient(160deg, var(--red), var(--red-deep)); color: #fff; min-height: 150px; box-shadow: 0 10px 30px rgba(229, 56, 59, .25); }
.big.gray { background: var(--panel-2); border: 1px solid var(--line); }
.big .bar { margin-top: 10px; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.big .bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; }

/* 카드 · 목록 */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.list { display: grid; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 56px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; width: 100%; text-align: left; cursor: pointer;
}
.row .num { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); font-weight: 800; font-size: 16px; }
.row .body { flex: 1; min-width: 0; }
.row .t { font-weight: 700; display: block; }
.row .d { font-size: 15px; color: var(--muted); display: block; }
.row .r { flex: none; text-align: right; font-weight: 800; white-space: nowrap; }
.row .r small { display: block; font-weight: 500; color: var(--muted); font-size: 14px; }
.row .t .tag { white-space: nowrap; }

.tag { display: inline-block; font-size: 13px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--panel-2); color: var(--muted); vertical-align: 2px; margin-left: 4px; }
.tag.under { background: var(--green-soft); color: var(--green); }

/* 가장 가까운 대피소 */
.nearest { background: var(--panel); border: 2px solid var(--red); border-radius: 20px; padding: 18px; }
.nearest .label { color: var(--red); font-weight: 800; font-size: 15px; }
.nearest h2 { font-size: 25px; margin: 4px 0 2px; letter-spacing: -.03em; }
.nearest .addr { color: var(--muted); font-size: 15px; }
.nearest .stats { display: flex; gap: 16px; align-items: center; margin: 14px 0; }
.nearest .stats .v { font-size: 30px; font-weight: 900; letter-spacing: -.03em; line-height: 1; }
.nearest .stats .k { font-size: 14px; color: var(--muted); }
.compass { flex: none; width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; margin-left: auto; position: relative; }
.compass::before { content: "북"; position: absolute; top: -9px; font-size: 11px; background: var(--panel); padding: 0 3px; color: var(--muted); }
.compass svg { width: 34px; height: 34px; fill: var(--red); transition: transform .3s; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--panel-2); font-weight: 800; font-size: 18px; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.go { background: #fee500; border-color: #fee500; color: #191919; }
.btn.ok { background: var(--green); border-color: var(--green); color: #06120b; }
.btn.block { width: 100%; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btns.one { grid-template-columns: 1fr; }

/* 경보 칩 */
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chip {
  min-height: 64px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--panel); text-align: left; text-decoration: none; cursor: pointer; border-left-width: 6px;
}
.chip b { display: block; font-size: 19px; }
.chip span { display: block; font-size: 14px; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--panel-2); outline: 2px solid currentColor; }
.t-red { border-left-color: var(--red) !important; }
.t-amber { border-left-color: var(--amber) !important; }
.t-purple { border-left-color: var(--purple) !important; }
.t-green { border-left-color: var(--green) !important; }
.c-red { color: var(--red); } .c-amber { color: var(--amber); } .c-purple { color: var(--purple); } .c-green { color: var(--green); }

/* 행동 단계 */
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; display: grid; gap: 10px; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.steps li::before { content: counter(s); flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--red); color: #fff; font-weight: 900; display: grid; place-items: center; font-size: 16px; margin-top: 1px; }
.steps.green li::before { background: var(--green); color: #06120b; }
.steps.plain li::before { background: var(--panel-2); color: var(--text); }
.siren { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--panel-2); margin: 12px 0; font-size: 16px; }
.siren svg { flex: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.src { margin-top: 16px; font-size: 14px; color: var(--muted); }
.src a { color: var(--muted); }

/* 검색 */
.search { display: flex; gap: 8px; }
.search input {
  flex: 1; min-width: 0; min-height: 56px; padding: 0 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit;
}
.search input:focus { outline: 2px solid var(--blue); border-color: transparent; }

/* 체크리스트 */
.check { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.check input { appearance: none; flex: none; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--muted); display: grid; place-items: center; margin: 0; cursor: pointer; }
.check input:checked { background: var(--green); border-color: var(--green); }
.check input:checked::after { content: ""; width: 8px; height: 14px; border: solid #06120b; border-width: 0 3px 3px 0; transform: rotate(45deg) translate(-1px, -1px); }
.check input:checked + span { color: var(--muted); text-decoration: line-through; }
.check span { flex: 1; }
.check a { flex: none; font-size: 14px; color: var(--blue); text-decoration: none; padding: 6px; }
.progress { height: 10px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.progress i { display: block; height: 100%; background: var(--green); transition: width .3s; }

/* 입력 칸 */
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 6px; font-size: 15px; color: var(--muted); }
.form input, .form textarea, .form select {
  min-height: 52px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit; width: 100%;
}
.form textarea { min-height: 90px; resize: vertical; }
.calc { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result { font-size: 22px; font-weight: 800; margin-top: 12px; }
.result em { font-style: normal; color: var(--green); font-size: 32px; }

/* 지도 */
body[data-page="map"] { overflow: hidden; }
body[data-page="map"] main { max-width: none; padding: 0; }
.map-wrap { position: relative; }
#map { height: calc(100vh - var(--top-h, 70px) - var(--tabs-h) - env(safe-area-inset-bottom)); height: calc(100dvh - var(--top-h, 70px) - var(--tabs-h) - env(safe-area-inset-bottom)); background: #1b1d22; }
.map-ctl { position: absolute; z-index: 500; left: 12px; right: 12px; top: 12px; display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.map-ctl > * { pointer-events: auto; }
.map-ctl .btn { min-height: 44px; font-size: 15px; padding: 0 14px; background: rgba(23, 25, 30, .92); }
.map-ctl .btn[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
.map-hint { position: absolute; z-index: 500; left: 50%; bottom: 16px; transform: translateX(-50%); background: rgba(23, 25, 30, .95); border: 1px solid var(--line); padding: 8px 14px; border-radius: 999px; font-size: 15px; white-space: nowrap; }
.leaflet-container { font: 15px/1.4 var(--font); background: #1b1d22; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); }
.leaflet-popup-content { margin: 12px 14px; min-width: 200px; }
.leaflet-popup-content b { font-size: 17px; }
.leaflet-popup-content a.btn { min-height: 44px; font-size: 15px; margin-top: 8px; width: 100%; color: #191919; }
.leaflet-control-attribution { font-size: 10px; }

/* 세계 */
.world { display: grid; gap: 10px; }
.world a { display: block; text-decoration: none; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.world .n { font-weight: 800; }
.world .o { font-size: 14px; color: var(--muted); }
.world p { margin: 6px 0 0; font-size: 16px; }

.callbar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.callbar a { min-height: 56px; display: flex; align-items: center; justify-content: center; gap: 6px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); text-decoration: none; font-weight: 800; }
.callbar a b { font-size: 22px; }

.notice { font-size: 14px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 32px; padding-top: 16px; }
.notice p { margin: 0 0 6px; }

/* 아래 메뉴 */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(14, 15, 18, .97); border-top: 1px solid var(--line);
}
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 700; }
.tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tabs a.on { color: var(--text); }
.tabs a.on svg { stroke: var(--red); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 1000; background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 700; font-size: 16px; transition: .25s; width: max-content; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.install { display: flex; gap: 12px; align-items: center; }
.install .body { flex: 1; }
.install .t { font-weight: 800; }
.ios-steps { margin: 10px 0 0; padding-left: 20px; }
.empty { text-align: center; padding: 24px 16px; color: var(--muted); }
.noscript { padding: 20px; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--muted); text-decoration: none; font-size: 16px; margin: -6px 0 6px; }

@media (min-width: 720px) {
  .big.red { min-height: 180px; }
}
@media print {
  :root { --bg: #fff; --panel: #fff; --panel-2: #f2f2f2; --line: #999; --text: #000; --muted: #333; }
  .top, .tabs, .toast, .no-print { display: none !important; }
  body { padding: 0; font-size: 14pt; }
  .card { break-inside: avoid; }
}
