:root {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #0f172a;
  background: #f1f5f9;
  font-synthesis: none;
  --app-max-width: 480px;
  --line: #e2e8f0;
  --line-subtle: #f1f5f9;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --accent-border: #bfdbfe;
  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --card-bg: #ffffff;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: #f1f5f9;
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* 모바일 퍼스트 앱 셸 (PC에서는 480px 스마트폰 프레임, 모바일은 100% 핏) */
.site-header, main, footer {
  width: 100%;
  max-width: var(--app-max-width);
  background: #ffffff;
  box-sizing: border-box;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 56px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-subtle);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

main {
  flex: 1;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.03);
}

footer {
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-top: 1px solid var(--line-subtle);
  padding: 24px 16px 48px;
  font-size: 12px;
  color: var(--text-muted);
  background: #f8fafc;
  text-align: center;
}

@media (max-width: 480px) {
  body { background: #ffffff; }
  .site-header, main, footer {
    border-left: none;
    border-right: none;
    box-shadow: none;
  }
}

@media (max-width: 380px) {
  main {
    padding: 12px;
  }
  .site-header.list-header {
    padding: 0 10px;
    gap: 8px;
  }
  .site-header.list-header .brand-text {
    font-size: 16px;
  }
  .site-header.list-header .search-input-wrap input {
    font-size: 12.5px;
    padding: 0 30px 0 10px;
  }
}

/* 본문 인라인 링크만 밑줄 */
a { color: inherit; text-decoration: none; }
p a, dd a, .attribution a, .information-page a {
  text-decoration: underline;
  text-underline-offset: 3px;
}
p a:hover, dd a:hover, .attribution a:hover, .information-page a:hover {
  color: var(--accent);
}

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button, input { font: inherit; }
button { cursor: pointer; }

/* 브랜드 로고 (배경·테두리 없는 선명한 검정 볼드 텍스트) */
.brand, .brand-compact {
  font-weight: 900;
  font-size: 18px;
  letter-spacing: -0.6px;
  color: #0f172a;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  background: transparent;
  border: none;
  padding: 0;
}
.brand:hover, .brand-compact:hover {
  color: #0f172a;
  text-decoration: none;
}
.brand-text {
  font-weight: 900;
  font-size: 18px;
  letter-spacing: -0.6px;
  color: #0f172a;
  background: transparent;
  border: none;
  padding: 0;
}

/* 헤더 우측 메뉴 */
.site-header a:not(.brand) {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-body);
  background: #ffffff;
  text-decoration: none;
  transition: all 0.15s ease;
}
.site-header a:not(.brand):hover {
  background: var(--accent-light);
  border-color: var(--accent-border);
  color: var(--accent);
  text-decoration: none;
}

/* 모바일 앱 통합 헤더: 로고 + 검색창 */
.site-header.list-header {
  gap: 10px;
  padding: 0 14px;
}
.site-header.list-header .header-search {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}
.site-header.list-header .search-input-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
}
.site-header.list-header .search-input-wrap input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 34px 0 12px;
  border-radius: 9999px;
  border: 1px solid var(--line);
  background: #f1f5f9;
  font-size: 13px;
  color: var(--text-main);
  box-sizing: border-box;
  transition: all 0.15s ease;
}
.site-header.list-header .search-input-wrap input:focus {
  background: #ffffff;
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.site-header.list-header .search-submit-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: #64748b;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.site-header.list-header .search-submit-btn:hover {
  color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
}
.site-header.list-header .search-icon {
  display: block;
}

/* 히어로 섹션 (모바일 홈) */
.hero {
  padding: 16px 0 20px;
}
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 4px;
  letter-spacing: 0.3px;
}
.hero h1 {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.35;
  margin: 4px 0 8px;
  letter-spacing: -0.5px;
  color: var(--text-main);
}
.hero p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 16px;
}

/* 모바일 검색 폼 */
.hero .search div, .list-page form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.hero .search input, .list-page input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: #f8fafc;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.15s ease;
}
.hero .search input:focus, .list-page input:focus {
  background: #ffffff;
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.hero .search button, .list-page button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.hero .search button:hover, .list-page button:hover {
  background: var(--accent-hover);
  text-decoration: none;
}
.hero .search label, .list-page form label, .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;
}

/* 디렉터리 섹션 (홈 빠른 탐색) */
.directory {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line-subtle);
}
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 12px;
}
.section-heading h2 {
  font-size: 16px;
  font-weight: 800;
  margin: 2px 0 0;
  color: var(--text-main);
}
.section-heading a {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.section-heading a:hover {
  text-decoration: underline;
}

/* 지역 그리드 (모바일 4열) */
.region-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
}
.region-grid li {
  min-width: 0;
}
.region-grid li a {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 4px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-body);
  text-decoration: none;
  box-sizing: border-box;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}
.region-grid li a span { display: none; }
.region-grid li a:active {
  background: #f1f5f9;
}

/* 진료과 그리드 (모바일 3열, 360px 안전 반응형) */
.department-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
}
.department-grid li {
  min-width: 0;
}
.department-grid li a {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 10px 4px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-body);
  text-decoration: none;
  min-height: 44px;
  line-height: 1.25;
  word-break: break-all;
  overflow-wrap: break-word;
  box-sizing: border-box;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}
.department-grid li a:active {
  background: #f1f5f9;
}

/* 홈 병원 목록 피드 */
.hospital-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.hospital-grid li {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
}
.hospital-grid li a.hospital-card {
  position: relative;
  overflow: hidden;
  display: block;
  padding: 14px;
  text-decoration: none;
  color: inherit;
}
.hospital-grid li a.hospital-card::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 23, 42, 0.08) 0%, rgba(15, 23, 42, 0.03) 50%, transparent 70%);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.4s ease-out;
}
.hospital-grid li a.hospital-card:active::after {
  transform: translate(-50%, -50%) scale(2.8);
  opacity: 1;
  transition: transform 0.25s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.1s ease-in;
}
.hospital-grid li h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text-main);
}
.hospital-grid li p { margin: 2px 0 0; color: var(--text-muted); font-size: 12px; }
.hospital-grid .status { color: #dc2626; font-weight: 700; }

.notice {
  margin-top: 24px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* =========================================
   목록 페이지 (List Page)
   ========================================= */
.list-page h1 {
  font-size: 18px;
  font-weight: 800;
  margin: 4px 0 16px;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

/* 활성 필터 바 */
.active-filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.active-filter-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.active-filter-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  list-style: none;
  padding: 0;
  margin: 0;
}
.active-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.active-filter-chip:hover {
  background: #dbeafe;
}
.chip-remove {
  font-size: 10px;
  font-weight: 800;
  opacity: 0.7;
}
.active-filter-reset {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.active-filter-reset:hover {
  color: #dc2626;
}

/* 필터 제어 영역 */
.filter-controls {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.filter-group {
  margin: 0;
}
.filter-header {
  margin-bottom: 4px;
  padding: 0 2px;
}
.filter-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

/* 가로 스크롤 칩 바 & 페이드 힌트 */
.filter-chips {
  list-style: none;
  padding: 0;
  margin: 0;
}

.filter-scroll-wrapper {
  position: relative;
  width: 100%;
}
/* 우측 페이드 힌트 ('뒤에 더 있음' 시각적 안내) */
.filter-scroll-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 32px;
  background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, #ffffff 95%);
  pointer-events: none;
  z-index: 2;
}

/* 수평 스크롤 칩 바 (스크롤바 완전 숨김, 모바일/PC 네이티브 스와이프 핏) */
.scroll-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  padding: 2px 28px 4px 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}
.scroll-chips::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
.scroll-chips li {
  flex-shrink: 0;
}
.scroll-chips li a, .scroll-chips li strong {
  display: inline-block;
  padding: 6px 13px;
  border-radius: 9999px;
  font-size: 13px;
  line-height: 1.3;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
}
.scroll-chips li a {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid transparent;
}
.scroll-chips li a:hover {
  background: #e2e8f0;
  color: var(--text-main);
  text-decoration: none;
}
.scroll-chips li strong {
  background: var(--accent);
  color: #ffffff;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

/* 검색 안내 및 에러 알림 */
.search-notice {
  margin: 4px 0 12px;
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 600;
}

/* 활성 필터 검색어 칩 */
.active-filter-search {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--accent);
}

/* 총 병원 수 안내 */
.hospital-total-count, .list-page > p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 6px 0 12px;
}

/* 모바일 1열 카드 피드 */
.list-page > ul {
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 20px;
}
.list-page > ul > li {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-body);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}
.list-page > ul > li > a.hospital-item-link {
  position: relative;
  overflow: hidden;
  display: block;
  padding: 16px;
  overflow-wrap: anywhere;
  color: inherit;
  text-decoration: none;
}
.list-page > ul > li > a.hospital-item-link::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 23, 42, 0.08) 0%, rgba(15, 23, 42, 0.03) 50%, transparent 70%);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.4s ease-out;
}
.list-page > ul > li > a.hospital-item-link:active::after {
  transform: translate(-50%, -50%) scale(2.8);
  opacity: 1;
  transition: transform 0.25s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.1s ease-in;
}
.list-page > ul > li .hospital-item-name {
  display: block;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 4px;
  color: var(--text-main);
}
.list-page > ul > li strong {
  color: #dc2626;
  font-weight: 500;
}

/* 페이지네이션 */
.list-page nav[aria-label="페이지"] ul {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
  list-style: none;
  padding: 0;
  margin: 20px 0 0;
}
.list-page nav[aria-label="페이지"] li a,
.list-page nav[aria-label="페이지"] li strong {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  border-radius: 8px;
  font-size: 13px;
  text-decoration: none;
  transition: all 0.15s ease;
}
.list-page nav[aria-label="페이지"] li a {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text-body);
}
.list-page nav[aria-label="페이지"] li a:hover {
  border-color: var(--accent-border);
  color: var(--accent);
}
.list-page nav[aria-label="페이지"] li strong {
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--accent);
  font-weight: 700;
}

/* =========================================
   상세 페이지 (Detail Page)
   ========================================= */
.detail-page nav[aria-label="breadcrumb"] ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.detail-page nav[aria-label="breadcrumb"] li:not(:last-child)::after {
  content: '›';
  margin-left: 4px;
  color: var(--text-light);
}
.detail-page h1 {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 14px;
  color: var(--text-main);
  letter-spacing: -0.5px;
}
.detail-page section {
  margin-top: 14px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.detail-page section h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-subtle);
  color: var(--text-main);
}
.detail-page dl {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 8px 10px;
  margin: 0;
  font-size: 13px;
}
.detail-page dt {
  color: var(--text-muted);
  font-weight: 600;
}
.detail-page dd {
  margin: 0;
  color: var(--text-body);
}
.detail-page .tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.detail-page .tag-list li, .detail-page .tag-list li a {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-body);
  text-decoration: none;
  transition: all 0.15s ease;
}
.detail-page .tag-list li a:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-light);
}
.detail-page table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}
.detail-page th, .detail-page td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line-subtle);
  text-align: left;
}
.detail-page th {
  color: var(--text-muted);
  font-weight: 600;
  width: 32%;
}
.lifecycle-alert {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.attribution {
  margin-top: 24px;
  font-size: 11px;
  color: var(--text-light);
  line-height: 1.5;
}
