/* 약국 찾기 스타일 (er-finder 복제, 색상 포인트만 초록으로): 모바일(390px) 우선, 대비 4.5:1 이상, 터치 영역 44px 이상 */
:root {
  /* 약국 팔레트: 따뜻한 크림 배경 + 부드러운 민트·청록 + 캡슐 코랄 포인트 (대비 4.5:1 이상 확인) */
  --primary: #0E7C66;      /* 청록 (흰 글자 5.1:1, 크림 배경 4.8:1) */
  --primary-soft: #E8F6F0; /* 민트 연한 배경 */
  --mint: #2FC4A0;         /* 장식용 민트 (글자에는 쓰지 않음) */
  --coral: #FF8A6B;        /* 캡슐 포인트 (장식용) */
  --coral-fg: #B4492E;     /* 코랄 글자 (흰 배경 5.3:1) */
  --red: #C8261B;
  --bg: #FBF7F0;           /* 따뜻한 크림 */
  --card: #FFFFFF;
  --text: #1F2A27;
  --sub: #5C574F;          /* 흰 배경 7.2:1 */
  --line: #ECE6DC;
  --shadow: 0 1px 2px rgba(60, 50, 30, .04), 0 4px 14px rgba(60, 50, 30, .06);
  --ok-bg: #DDF3EA; --ok-fg: #0A6350;     /* 영업 중 */
  --full-bg: #EFECE6; --full-fg: #59554E; /* 영업 종료 */
  --over-bg: #FFEFD6; --over-fg: #8A4B00; /* 30분 내 마감·지연 */
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Noto Sans KR', system-ui, -apple-system, sans-serif;
  font-size: 15px; line-height: 1.5;
}
a { color: var(--primary); }
button, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* 시각적으로 숨김 (스크린리더·검색엔진에는 노출) */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ── 상단 고정 헤더 ── */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  /* 넓은 화면에서는 본문(640px) 열에 맞춰 헤더 내용을 가운데 정렬 */
  padding-left: max(12px, calc((100% - 640px) / 2 + 12px));
  padding-right: max(12px, calc((100% - 640px) / 2 + 12px));
  background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line);
}
.logo {
  font-weight: 900; font-size: 22px; letter-spacing: -0.5px; text-decoration: none;
  color: #fff; border-radius: 13px;
  min-width: 44px; height: 44px; display: grid; place-items: center;
}
.logo img { width: 44px; height: 44px; display: block; border-radius: 13px; box-shadow: 0 2px 6px rgba(14, 124, 102, .25); }
.loc {
  flex: 1; min-width: 0; min-height: 44px; text-align: left;
  background: none; border: 0; padding: 0 4px; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center;
}
.loc-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc-name::after { content: ' ▾'; color: var(--sub); font-weight: 400; font-size: 12px; }
.loc-sub { font-size: 12px; color: var(--sub); }
.reload {
  min-width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--primary-soft); border: 0; border-radius: 14px;
  color: var(--primary); cursor: pointer; padding: 0;
}
.reload:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.reload[aria-busy="true"] svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .reload[aria-busy="true"] svg { animation: none; opacity: 0.5; } }
.call119 {
  background: var(--red); color: #fff; text-decoration: none; font-weight: 900;
  font-size: 18px; border-radius: 10px; min-height: 44px; min-width: 64px;
  display: grid; place-items: center; padding: 0 12px;
}
.call119.small { min-width: 56px; font-size: 16px; }

main { max-width: 640px; margin: 0 auto; padding: 12px 12px 24px; }

.notice {
  margin: 0 0 12px; padding: 10px 14px 10px 38px; border-radius: 14px; position: relative;
  background: var(--primary-soft); font-size: 13.5px; color: var(--ok-fg);
}
/* 상단 고정 안내 문구: 헤더(약 61px) 바로 아래에 붙는다 */
.notice::before { content: '💊'; position: absolute; left: 12px; top: 9px; font-size: 16px; }
.sticky-notice { position: sticky; top: calc(61px + env(safe-area-inset-top)); z-index: 9; box-shadow: 0 2px 8px rgba(251, 247, 240, .9); }
/* 최신 정보 갱신 지연 배지 */
.lag-badge {
  display: inline-block; margin: 0 0 8px; padding: 4px 10px; border-radius: 14px;
  background: var(--over-bg); color: var(--over-fg); font-size: 13px; font-weight: 700;
}
.lag-badge::before { content: '⚠ '; }
.warn {
  margin: 0 0 10px; padding: 12px; border-radius: 10px;
  background: var(--over-bg); color: var(--over-fg); font-size: 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.warn a { color: var(--over-fg); font-weight: 700; }

/* ── 지역 선택 (위치 거부) ── */
.region { background: #fff; border-radius: 20px; padding: 18px; margin-bottom: 12px; box-shadow: var(--shadow); }
.region h2 { margin: 0 0 4px; font-size: 17px; }
.region p { margin: 0 0 12px; color: var(--sub); font-size: 14px; }
.selects { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.selects label { font-size: 13px; color: var(--sub); display: flex; flex-direction: column; gap: 4px; }
.region .search { width: 100%; margin-top: 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.selects select {
  min-height: 44px; border: 1px solid #CFC7BA; border-radius: 12px; padding: 0 10px; background: #fff;
}

/* ── 버튼 ── */
.btn {
  min-height: 44px; padding: 0 18px; border-radius: 22px; border: 1px solid #CFC7BA;
  background: #fff; font-weight: 700; cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.more { width: 100%; margin-top: 12px; }

/* ── 필터 칩 ── */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 44px; padding: 0 14px; border-radius: 22px;
  border: 1px solid #DCD4C7; background: #fff; font-weight: 500; cursor: pointer; white-space: nowrap; color: var(--text);
}
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.chip[aria-pressed="true"]::before { content: '✓ '; }
.chip[aria-pressed="true"] { box-shadow: 0 3px 10px rgba(14, 124, 102, .28); }
.count { margin: 4px 2px 8px; font-size: 13px; color: var(--sub); }

/* ── 카드 ── */
.list { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border-radius: 20px; border: 0; overflow: hidden; box-shadow: var(--shadow); }
.card-main {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 14px 14px 10px; cursor: pointer;
}
.card-main:focus-visible, .btn:focus-visible, .chip:focus-visible, .act:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.meta { display: block; font-size: 13px; color: var(--sub); }
.name { display: block; font-size: 17px; font-weight: 700; margin: 2px 0; word-break: keep-all; }
.input-age { display: block; font-size: 12.5px; color: var(--sub); }
.input-age.old { color: var(--over-fg); font-weight: 700; }

/* 병상 배지: 숫자 + 상태 글자 병기 */
.badge {
  flex: none; min-width: 72px; border-radius: 20px; padding: 6px 8px; text-align: center; line-height: 1.2;
}
.badge b { display: block; font-size: 20px; font-weight: 900; }
.badge span { font-size: 12px; font-weight: 700; }
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.closed { background: var(--full-bg); color: var(--full-fg); }
.badge.soon { background: var(--over-bg); color: var(--over-fg); }
/* 약국 상태 배지는 글자만 (영업 중 / 30분 내 마감 / 영업 종료) */
.badge > span:only-child { font-size: 13px; display: block; padding: 3px 4px; white-space: nowrap; }
/* 상태 점: 영업 중 초록, 마감 임박 주황, 종료 회색 */
.badge > span:only-child::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 5px; vertical-align: 2px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { font-size: 12.5px; padding: 3px 8px; border-radius: 6px; background: #F0F2F5; color: #2E353D; }
.tag.peds { background: #E8F5EC; color: #1C5E33; }
.tag.no { text-decoration: line-through; color: var(--sub); }

.block {
  display: block; margin-top: 8px; padding: 8px 10px; border-radius: 8px;
  background: var(--over-bg); color: var(--over-fg); font-size: 13px;
}
.block b { font-weight: 700; }

.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; border-top: 1px solid #F2EDE4; }
.act {
  min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 4px;
  background: none; border: 0; border-left: 1px solid #F2EDE4; font-size: 13.5px; font-weight: 700;
  text-decoration: none; color: var(--text); cursor: pointer; padding: 0 4px; text-align: center;
}
.act:first-child { border-left: 0; color: var(--primary); }

.empty, .loading { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 24px 16px; text-align: center; color: var(--sub); }

/* ── 상세 화면 ── */
.detail { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto; overscroll-behavior: contain; }
.detail-bar {
  position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: rgba(255, 255, 255, .95); border-bottom: 1px solid var(--line);
  /* 상세 상단 바도 본문 열에 맞춤 */
  padding-left: max(12px, calc((100% - 640px) / 2 + 12px));
  padding-right: max(12px, calc((100% - 640px) / 2 + 12px));
}
.back { min-height: 44px; padding: 0 12px; background: none; border: 0; font-weight: 700; font-size: 16px; cursor: pointer; }
.detail-body { max-width: 640px; margin: 0 auto; padding: 12px 12px 32px; }
.d-head { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 16px; margin-bottom: 10px; }
.d-head h1 { font-size: 20px; margin: 2px 0 4px; word-break: keep-all; }
.d-head .addr { font-size: 13.5px; color: var(--sub); margin: 4px 0 0; }
.d-head .actions { margin: 12px -16px -16px; }
.panel { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 10px; }
.panel h2 { font-size: 16px; margin: 0 0 8px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 0; margin: 0; }
.kv dt, .kv dd { margin: 0; padding: 9px 0; border-bottom: 1px solid #F2EDE4; font-size: 14.5px; }
.kv dd { text-align: right; font-weight: 700; }
.kv dd small { font-weight: 400; color: var(--sub); }
.st-ok { color: var(--ok-fg); font-weight: 700; } .st-closed { color: var(--full-fg); font-weight: 700; } .st-soon { color: var(--over-fg); font-weight: 700; }
/* 상세 운영시간: 오늘 행 강조 */
.kv .today { color: var(--primary); font-weight: 700; }
.sevs { display: flex; flex-wrap: wrap; gap: 6px; }
.blk-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.blk-list li { background: var(--over-bg); color: var(--over-fg); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; }
.blk-list small { display: block; opacity: .95; margin-top: 2px; }
.muted { color: var(--sub); font-size: 14px; margin: 0; }

/* ── 바텀시트 ── */
.sheet {
  width: 100%; max-width: 640px; max-height: 85vh; margin: auto auto 0; padding: 0;
  border: 0; border-radius: 16px 16px 0 0; background: #fff;
}
.sheet::backdrop { background: rgba(0,0,0,.45); }
.sheet-body { display: flex; flex-direction: column; max-height: 85vh; }
.sheet-head { position: relative; padding: 16px 60px 8px 16px; border-bottom: 1px solid var(--line); }
/* 시트 닫기(X) 버튼: 터치 영역 44px */
.sheet-close {
  position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; border: 0; border-radius: 22px;
  background: none; font-size: 20px; line-height: 1; color: var(--sub); cursor: pointer;
}
.sheet-close:hover { background: #F0F2F5; }
.sheet-close:focus-visible { outline: 3px solid var(--primary); outline-offset: 0; }
.sheet-head h2 { margin: 0; font-size: 17px; }
.sheet-head p { margin: 4px 0 0; font-size: 13px; color: var(--sub); }
/* 목록 끝에서 더 스크롤해도 뒤 페이지로 스크롤이 넘어가지 않게 */
.sheet-list { overflow-y: auto; padding: 4px 8px; overscroll-behavior: contain; }
.sheet-list label {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 8px; border-radius: 8px; cursor: pointer;
}
.sheet-list input { width: 20px; height: 20px; accent-color: var(--primary); }
.sheet-foot {
  display: grid; grid-template-columns: 1fr 2fr; gap: 8px; padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
}

.foot { text-align: center; font-size: 12.5px; color: var(--sub); padding: 16px 12px 32px; }

/* 상세 화면·바텀시트가 열려 있는 동안 뒤 페이지 스크롤 잠금 (scroll chaining 방지) */
html.scroll-lock, html.scroll-lock body { overflow: hidden; overscroll-behavior: none; }
/* 하단 링크(응급실 찾기·119)도 터치 영역 44px 이상 */
.foot a { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; font-weight: 700; }

/* ── 응급실 찾기 연결 카드 ── */
.er-link {
  display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 14px 16px;
  background: #fff; border-radius: 20px; box-shadow: var(--shadow); text-decoration: none; color: var(--text);
  border: 1px solid #F6D9CF; min-height: 64px;
}
.er-link .er-ic {
  flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(#E23A2E, #B71E14); color: #fff; font-weight: 900; font-size: 14px; letter-spacing: -.3px;
}
.er-link b { display: block; font-size: 15px; }
.er-link small { display: block; color: var(--sub); font-size: 12.5px; }
.er-link .go { margin-left: auto; color: var(--coral-fg); font-weight: 700; font-size: 18px; }
.er-link:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
