:root {
  --topbar-h: 30px;
  --header-h: 72px;
  --header-h-scrolled: 64px;
  --nav-h: 54px;

  --header-blue: #1456d8;
  --header-blue-soft: rgba(20, 86, 216, 0.08);

  /* Glass tokens — header / nav 공통 */
  --glass-bg-top: rgba(255, 255, 255, 0.96);
  --glass-bg-scrolled: rgba(236, 240, 245, 0.72);
  --glass-border: rgba(15, 23, 42, 0.06);
  --glass-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

html { scroll-behavior: auto; }

body {
  /* PC: topbar + header + nav 모두 fixed → 본문은 그 아래에서 시작 */
  padding-top: calc(var(--topbar-h) + var(--header-h) + var(--nav-h));
}

/* =========================================================
   Topbar (법적 고지 — 항상 솔리드, 가독성 우선)
   ========================================================= */
.site-topbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--topbar-h);
  z-index: 1200;
  background: rgba(243, 244, 246, 0.96);
  border-bottom: 1px solid rgba(15, 23, 42, 0.05);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.site-topbar__inner {
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  font-size: 0.86rem;
  color: #697586;
}

/* =========================================================
   Header — 독립 fixed 레이어 #1
   - .site-nav와 부모-자식 관계가 아닌 형제 관계로 분리
   - 자체적으로 backdrop-filter 합성 컨텍스트를 가짐
   ========================================================= */
.site-header {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  width: 100%;
  height: var(--header-h);
  z-index: 1190;
  background: var(--glass-bg-top);
  /* 헤더-네비 사이 1px 이음새 제거 — 보더는 nav-bottom에만 위치 */
  border-bottom: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  transition:
    height 0.28s ease,
    background 0.28s ease,
    backdrop-filter 0.28s ease,
    -webkit-backdrop-filter 0.28s ease,
    box-shadow 0.28s ease;
}

.site-header__inner {
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}

/* ---------- Brand (토스/금융앱 스타일 단단한 타이틀) ---------- */
.site-header__brand {
  display: inline-flex;
  align-items: center;
  font-size: clamp(1.35rem, 1.5vw, 1.65rem);
  font-weight: 900;
  letter-spacing: -0.045em;
  color: #064f9e;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.site-header__brand:hover,
.site-header__brand:focus-visible {
  color: #053a78;
  outline: none;
}

/* ---------- Right group ---------- */
.site-header__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---------- Phone pill ---------- */
.site-header__phone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #f3f6fb;
  color: #1f2937;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.site-header__phone:hover,
.site-header__phone:focus-visible {
  background: #e7eef9;
  color: #0c488f;
  transform: translateY(-1px);
  outline: none;
}

/* 구 카카오 잔존 차단 */
.site-header__kakao {
  display: none !important;
}

/* ---------- Menu button (모바일 전용) ---------- */
.site-header__menu-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
  border-radius: 12px;
  transition: background 0.18s ease;
}

.site-header__menu-btn:hover,
.site-header__menu-btn:focus-visible {
  background: #f3f6fb;
  outline: none;
}

.site-header__menu-btn span {
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: #1f2937;
  transition: transform 0.24s ease, opacity 0.24s ease;
}

.site-header__menu-btn.is-open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.site-header__menu-btn.is-open span:nth-child(2) {
  opacity: 0;
}

.site-header__menu-btn.is-open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* =========================================================
   Nav — 독립 fixed 레이어 #2 (header의 형제)
   ========================================================= */
.site-nav {
  position: fixed;
  /* -1px: 헤더 하단과 1px 겹쳐 서브픽셀 이음새 제거 */
  top: calc(var(--topbar-h) + var(--header-h) - 1px);
  left: 0;
  width: 100%;
  z-index: 1180;
  background: var(--glass-bg-top);
  /* 보더는 nav-bottom 1줄만 — header-bottom과 중복 라인 방지 */
  border-top: none;
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  transition:
    top 0.28s ease,
    max-height 0.28s ease,
    background 0.28s ease,
    backdrop-filter 0.28s ease,
    -webkit-backdrop-filter 0.28s ease,
    box-shadow 0.28s ease,
    border-color 0.28s ease;
}

.site-nav__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  box-sizing: border-box;
}

.site-nav__list {
  margin: 0;
  padding: 0;
  list-style: none;
  min-height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.site-nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #4b5563;
  text-decoration: none;
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: transparent;
  box-shadow: none;
  transform: translateY(0);
  transition:
    color 0.22s ease,
    background 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    transform 0.22s ease,
    backdrop-filter 0.22s ease,
    -webkit-backdrop-filter 0.22s ease;
}

/* PC hover/focus: 반투명 글래스 pill로 살짝 떠오름 */
.site-nav__link:hover,
.site-nav__link:focus-visible {
  color: var(--header-blue);
  background: rgba(255, 255, 255, 0.46);
  border-color: rgba(255, 255, 255, 0.62);
  box-shadow:
    0 10px 24px rgba(15, 23, 42, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
  transform: translateY(-2px);
  backdrop-filter: blur(10px) saturate(130%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  outline: none;
}

.site-nav__link:active {
  transform: translateY(0);
  box-shadow:
    0 4px 12px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.site-nav__link::after {
  display: none !important;
  content: none !important;
}

/* =========================================================
   스크롤 상태 — header / nav 동일 톤 통일
   (자체 클래스 기준만 사용, parent-child 셀렉터는 폐기)
   ========================================================= */
.site-header.is-scrolled {
  height: var(--header-h-scrolled);
  background: var(--glass-bg-scrolled) !important;
  backdrop-filter: blur(14px) saturate(135%);
  -webkit-backdrop-filter: blur(14px) saturate(135%);
  box-shadow: none;
}

.site-nav.is-scrolled {
  /* 헤더 축소에 맞춰 nav가 위로 슬라이드, -1px로 이음새 제거 유지 */
  top: calc(var(--topbar-h) + var(--header-h-scrolled) - 1px);
  background: var(--glass-bg-scrolled) !important;
  backdrop-filter: blur(14px) saturate(135%);
  -webkit-backdrop-filter: blur(14px) saturate(135%);
  border-bottom-color: var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* nav 내부 컨테이너/링크는 자체 배경 없이 nav 톤이 비치게 */
.site-nav.is-scrolled .site-nav__inner,
.site-nav.is-scrolled .site-nav__list {
  background: transparent !important;
}

/* =========================================================
   Desktop (>=1181px) — nav 항상 노출, 가로 배치
   ========================================================= */
@media (min-width: 1181px) {
  .site-nav {
    display: block !important;
    overflow: visible !important;
    max-height: none !important;
  }

  /* PC 스크롤 상태에서는 개별 링크 pill 배경 제거 → nav 톤만 보이도록 */
  .site-nav.is-scrolled .site-nav__link {
    background: transparent !important;
  }
}

/* =========================================================
   Tablet/Mobile (<=1180px)
   - 햄버거 토글 / 메뉴 버튼 노출
   - 본문 패딩에서 nav 높이 제외 (드롭다운 오버레이로 동작)
   ========================================================= */
@media (max-width: 1180px) {
  body {
    padding-top: calc(var(--topbar-h) + var(--header-h));
  }

  .site-header__menu-btn {
    display: inline-flex;
  }

  .site-nav {
    max-height: 0;
    overflow: hidden;
  }

  .site-nav.is-open {
    max-height: 480px;
    box-shadow: 0 14px 24px rgba(15, 23, 42, 0.06);
  }

  .site-nav__inner {
    padding: 8px 18px 18px;
  }

  .site-nav__list {
    min-height: auto;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 8px;
  }

  .site-nav__link {
    width: 100%;
    min-height: 52px;
    justify-content: flex-start;
    padding: 0 16px;
    border-radius: 14px;
  }

  /* 모바일에서는 PC hover의 떠오름/그림자/블러 효과 비활성화 (카드 톤만 변화) */
  .site-nav__link:hover,
  .site-nav__link:focus-visible {
    transform: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* 메뉴 카드 — 묵직한 흰박스 대신 옅은 글래스 톤 */
  .site-nav.is-open .site-nav__link {
    background: rgba(255, 255, 255, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.24);
    box-shadow: none;
  }

  .site-nav.is-open .site-nav__link:hover,
  .site-nav.is-open .site-nav__link:focus-visible {
    background: rgba(255, 255, 255, 0.36);
  }

  /* 스크롤 상태에서 메뉴 펼친 경우 — 헤더와 동일한 글래스 톤 유지 */
  .site-nav.is-open.is-scrolled {
    background: var(--glass-bg-scrolled) !important;
    backdrop-filter: blur(14px) saturate(135%);
    -webkit-backdrop-filter: blur(14px) saturate(135%);
  }

  .site-nav.is-open.is-scrolled .site-nav__link {
    background: rgba(255, 255, 255, 0.22);
  }

  .site-nav.is-open.is-scrolled .site-nav__link:hover,
  .site-nav.is-open.is-scrolled .site-nav__link:focus-visible {
    background: rgba(255, 255, 255, 0.36);
  }
}

/* =========================================================
   Small mobile (<=767px)
   ========================================================= */
@media (max-width: 767px) {
  :root {
    --topbar-h: 28px;
    --header-h: 64px;
    --header-h-scrolled: 56px;
  }

  .site-topbar__inner {
    padding: 0 14px;
    font-size: 0.78rem;
  }

  .site-header__inner {
    padding: 0 14px;
  }

  .site-header__brand {
    font-size: 1.18rem;
    letter-spacing: -0.04em;
  }

  .site-header__right {
    gap: 8px;
  }

  .site-header__phone {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 0.85rem;
  }

  .site-header__menu-btn {
    width: 36px;
    height: 36px;
  }

  .site-nav__inner {
    padding: 8px 14px 14px;
  }

  .site-nav__link {
    min-height: 50px;
    font-size: 0.94rem;
  }
}

/* =========================================================
   Floating Kakao (PC/모바일 공통, 우하단 고정)
   ========================================================= */
.floating-kakao {
  position: fixed;
  right: 24px;
  bottom: 60px;
  z-index: 2000;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: #fee500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.floating-kakao:hover,
.floating-kakao:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.24);
  outline: none;
}

.floating-kakao img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

@media (max-width: 767px) {
  .floating-kakao {
    right: 16px;
    bottom: 40px;
    width: 52px;
    height: 52px;
    border-radius: 16px;
  }

  .floating-kakao img {
    width: 25px;
    height: 25px;
  }
}
