/* 앱 틀: 상단바, 필터 줄, 하단 탭바, 아래에서 올라오는 시트, 언어 선택, 모달·토스트, 전체 화면 경고, 오류 화면 */

/* ---------- 상단바 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  view-transition-name: topbar;
}
.brand {
  display: inline-flex; align-items: center; gap: 7px;
  font-weight: 800; font-size: 17px; letter-spacing: -0.3px; color: var(--blue);
}
.brand-logo { width: 24px; height: 24px; display: block; }
.top-actions { display: flex; gap: 6px; }

/* ---------- 유형 필터 줄 ---------- */
.filters {
  position: sticky; top: 53px; z-index: 900;
  display: flex; gap: 6px; overflow-x: auto;
  padding: 10px 12px; background: var(--bg);
}
.filters::-webkit-scrollbar { display: none; }
/* 지도 위에 떠 있는 필터 (메인 화면) */
body > .filters {
  position: absolute; top: var(--head-h); left: 0; right: 0; z-index: 900;
  padding: 10px 12px 6px; background: transparent; pointer-events: none;
}
body > .filters .chip { pointer-events: auto; }

/* ---------- 하단 탭바 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
  display: flex; align-items: stretch;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
  box-shadow: 0 -2px 10px rgba(0, 60, 66, 0.08);
  view-transition-name: tabbar;
}
.tabbar .tab {
  position: relative; flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 4px 2px; border: 0; background: transparent; color: var(--muted);
  font-size: 11px; font-weight: 700; line-height: 1.2; text-decoration: none; cursor: pointer;
}
.tabbar .tab:active { background: var(--blue-soft); }
.tabbar .tab-ico { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: 0.7; }
.tabbar .tab.active { color: var(--blue); }
.tabbar .tab.active .tab-ico { filter: none; opacity: 1; }
.tabbar .tab-report { color: var(--blue); }
.tabbar .tab-report .tab-ico {
  display: flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; margin-top: -18px;
  border-radius: 50%; background: var(--blue); color: #fff; border: 3px solid #fff;
  font-size: 26px; font-weight: 500; filter: none; opacity: 1;
  box-shadow: 0 4px 12px rgba(0, 143, 153, 0.45);
}
/* 역할별 탭: tabbar.js가 내 역할에 맞는 탭에 .show를 붙인다 */
.tabbar [data-roles] { display: none; }
.tabbar [data-roles].show { display: flex; }
.tab-dot { position: absolute; top: 6px; left: calc(50% + 10px); width: 10px; height: 10px; background: var(--danger); border: 2px solid #fff; border-radius: 50%; }

body.has-tabbar { padding-bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom)); }

/* ---------- 아래에서 올라오는 시트(상세·순위·설정) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10,20,40,0.45); z-index: 1500; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1600;
  background: #fff; border-radius: var(--r-lg) var(--r-lg) 0 0;
  max-height: 85vh; overflow-y: auto; box-shadow: 0 -8px 30px rgba(0,0,0,0.22);
  animation: slideUp 0.22s ease;
}
.sheet-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff; font-size: 16px;
}
.sheet-body { padding: 18px 18px 26px; }

/* ---------- 언어 선택 (떠 있는 한/EN/日) ---------- */
.lang-switch {
  position: fixed; z-index: 3000;
  display: flex; gap: 2px; padding: 3px;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-md);
}
/* 시작 화면: 오른쪽 위 */
.start-bg .lang-switch { top: 10px; right: 10px; }
/* 그 외 화면: 왼쪽 아래 (버튼들과 안 겹치게) */
body:not(.start-bg) .lang-switch {
  left: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
}
body.has-tabbar .lang-switch { bottom: calc(var(--tab-h) + 10px + env(safe-area-inset-bottom)); }
.lang-btn {
  min-width: 34px; padding: 6px 9px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); font-size: 13px; font-weight: 800;
}
.lang-btn.active { background: var(--blue); color: #fff; }

/* ---------- 모달·토스트·오프라인 표시 (static/ui.js) ---------- */
.ui-overlay { position: fixed; inset: 0; z-index: 5000; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(10, 30, 34, 0.5); animation: ui-fade .18s ease both; }
.ui-overlay.out { animation: ui-fade-out .16s ease both; }
.ui-modal { width: 100%; max-width: 340px; max-height: 86vh; overflow: auto; padding: 22px 20px 16px; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); animation: ui-pop .22s cubic-bezier(.2, .9, .3, 1.15) both; }
.ui-modal h3 { margin: 0 0 8px; font-size: 18px; color: var(--ink); }
.ui-body { font-size: 15px; line-height: 1.5; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.ui-actions { display: flex; gap: 8px; margin-top: 18px; }
.ui-btn { flex: 1; padding: 12px; font-size: 15px; font-weight: 700; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; }
.ui-btn:active { transform: scale(0.98); }
.ui-btn.primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.ui-btn.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.ui-btn:focus-visible { outline: 3px solid var(--blue-soft); outline-offset: 1px; }
body.ui-locked { overflow: hidden; }

.ui-toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tab-h, 62px) + 16px + env(safe-area-inset-bottom)); z-index: 6000; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.ui-toast { width: 100%; max-width: 420px; padding: 12px 14px; font-size: 14px; font-weight: 600; color: #fff; background: #10343a; border-radius: var(--r-md); box-shadow: var(--shadow-md); pointer-events: auto; animation: ui-toast-in .22s ease both; }
.ui-toast.error { background: var(--danger); }
.ui-toast.success { background: var(--safe); }
.ui-toast.out { animation: ui-toast-out .2s ease both; }
.ui-offline { position: fixed; top: 0; left: 0; right: 0; z-index: 5500; padding: 6px 10px; text-align: center; font-size: 13px; font-weight: 700; color: #fff; background: #c62828; transform: translateY(-100%); transition: transform .25s ease; }
.ui-offline.on { transform: translateY(0); }
@keyframes ui-fade { from { opacity: 0; } }
@keyframes ui-fade-out { to { opacity: 0; } }
@keyframes ui-pop { from { opacity: 0; transform: translateY(10px) scale(0.96); } }
@keyframes ui-toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes ui-toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- 전체 화면 경고(대피 발령/비상) ---------- */
.alert-overlay {
  position: fixed; inset: 0; z-index: 4000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(190, 20, 20, 0.92);
  animation: alertFlash 1s infinite;
}
@keyframes alertFlash {
  0%, 100% { background: rgba(190, 20, 20, 0.92); }
  50% { background: rgba(140, 10, 10, 0.95); }
}
.alert-card { width: 100%; max-width: 380px; text-align: center; color: #fff; }
.alert-emoji { font-size: 72px; animation: shake 0.5s infinite; }
.alert-card h2 { font-size: 26px; margin: 10px 0; }
.alert-card p { font-size: 16px; line-height: 1.5; margin: 0 0 22px; opacity: 0.95; }
.alert-actions { display: flex; flex-direction: column; gap: 10px; }
.alert-go {
  padding: 18px; border: 0; border-radius: 16px; font-size: 19px; font-weight: 800;
  background: #fff; color: var(--danger);
}
.alert-dismiss {
  padding: 12px; border: 2px solid rgba(255,255,255,0.7); border-radius: 14px;
  background: transparent; color: #fff; font-size: 15px; font-weight: 700;
}

/* ---------- 오류 화면 ---------- */
.err-page { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 100vh; padding: 24px; text-align: center; }
.err-code { font-size: 72px; font-weight: 800; line-height: 1; color: var(--blue); }
.err-page h1 { margin: 0; font-size: 20px; }
.err-page .primary { padding: 12px 24px; text-decoration: none; }

/* ---------- 넓은 화면(태블릿·PC): 탭바와 아래 시트를 가운데 폭으로 ---------- */
@media (min-width: 768px) {
  .tabbar, .sheet { max-width: 560px; margin: 0 auto; }
  .tabbar { border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; }
}
