/* Shared responsive guardrails. Loaded after page-specific styles. */
html, body { min-width: 0; overflow-x: hidden; }
img, video, svg, canvas { max-width: 100%; }

@media (max-width: 720px) {
  /* The home hero should follow the video height instead of filling the viewport. */
  .firstpage { min-height: 0 !important; }
  .firstpage { height: auto !important; }
  .hero-visual { height: auto; aspect-ratio: auto; }
  .portfolio-main-img { height: auto; aspect-ratio: 16 / 9; object-fit: contain; object-position: center; }

  /* Keep profile imagery compact on small screens. */
  #about.about-section { padding-top: 48px !important; }
  #about.about-section { padding-bottom: 48px !important; }
  .about-feature { gap: 28px !important; }
  .about-feature-photo { width: min(140px, 42vw) !important; height: 192px !important; min-height: 0 !important; }
  .intro-photo { width: min(128px, 42vw) !important; height: 180px !important; }

  /* Reset the desktop grid tracks; otherwise each mobile card keeps a 360px row. */
  .project-gallery {
    grid-template-rows: repeat(4, auto) !important;
    grid-auto-rows: auto !important;
    gap: 10px !important;
  }

  #MainProjects.section-light { padding-top: 64px !important; }

  #SubProjects .mini-text,
  #SubProjects .about-me {
    padding-left: 0 !important;
    margin-left: 0 !important;
  }

  #SubProjects .about-me h2 {
    text-align: left !important;
  }

  #endpage .endfage-main-text {
    margin: 36px 16px 0 !important;
  }

  #endpage .endfage-main-text1 {
    margin-top: 24px !important;
    margin-bottom: 8px !important;
    font-size: clamp(34px, 10vw, 52px) !important;
  }

  #endpage .endfage-main-text3 {
    margin-bottom: 12px !important;
    font-size: clamp(36px, 11vw, 58px) !important;
  }

  #endpage {
    min-height: 0 !important;
    padding-bottom: 32px !important;
  }

  #endpage .endfage-mini-text {
    padding-left: 16px !important;
    justify-content: flex-start !important;
    text-align: left !important;
  }

  #endpage .endfage-main-text1,
  #endpage .endfage-main-text3 {
    margin-top: 16px !important;
    margin-left: 0 !important;
    text-align: center !important;
  }

  #endpage .endfage-main-text1 h1,
  #endpage .endfage-main-text3 h1 {
    width: 100%;
    font-size: clamp(30px, 10vw, 44px) !important;
    line-height: 1 !important;
    white-space: nowrap;
    text-align: center;
  }

  #endpage .endfage-main-text3 h1 span { display: inline; }
  #endpage .endfage-main-text3 h1 .desktop-only-break { display: none; }

  #endpage .end-note {
    margin: 28px 0 0 !important;
    padding: 0 16px !important;
    text-align: center !important;
  }

  #endpage .end-note-final-line { display: block; }

  #endpage .endfage-footer-text {
    position: static !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) !important;
    column-gap: clamp(12px, 3vw, 24px) !important;
    width: calc(100% - 32px) !important;
    margin: 72px 16px 0 !important;
    transform: none !important;
    align-items: center !important;
    justify-content: stretch !important;
    text-align: left !important;
  }

  #endpage .endfage-footer-text1 {
    justify-self: start !important;
    text-align: left !important;
  }

  #endpage .endfage-footer-text2 {
    justify-self: center !important;
    text-align: center !important;
  }

  #endpage .endfage-footer-text3 {
    justify-self: end !important;
    text-align: right !important;
  }

  /* Keep home navigation usable on mobile: links, brand, and theme control. */
  .topbar-inner {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) !important;
    gap: 4px !important;
    padding: 0 8px !important;
  }

  .topbar-nav--left {
    display: flex !important;
    gap: 1px !important;
    min-width: 0 !important;
    overflow: visible !important;
  }

  .topbar-nav--left > a,
  .topbar-nav--left > a:not(.topbar-about-toggle) {
    display: inline-flex !important;
    padding: 7px 5px !important;
    font-size: 10px !important;
    white-space: nowrap !important;
  }

  .topbar .topbar-brand {
    display: block !important;
    font-size: 10px !important;
    white-space: nowrap !important;
  }

  .topbar-nav--right {
    display: flex !important;
    justify-content: flex-end !important;
    min-width: 0 !important;
  }

  .topbar-nav--right > a:not(.topbar-theme-toggle) {
    display: none !important;
  }

  .topbar-theme-toggle {
    display: grid !important;
    width: 32px !important;
    height: 32px !important;
    flex: 0 0 32px !important;
  }

  body:not(.is-light-theme) .topbar .topbar-theme-toggle::before {
    content: none !important;
    display: none !important;
  }

  body:not(.is-light-theme) .topbar .topbar-theme-toggle.is-current::before {
    content: none !important;
    display: none !important;
    background: none !important;
  }

  /* Match project and About headers to the compact home header. */
  body header.page-shared-header:not(.topbar),
  body > header:not(.topbar),
  body > .nav {
    position: fixed !important;
    z-index: 1000 !important;
    top: 8px !important;
    left: 50% !important;
    width: calc(100% - 16px) !important;
    height: 58px !important;
    margin: 0 !important;
    padding: 0 8px !important;
    transform: translateX(-50%) !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) !important;
    gap: 4px !important;
  }

  /* About has a more specific top-state rule; keep its frame on the home size. */
  body header.nav.page-shared-header:not(.topbar):not(.is-scrolled) {
    position: fixed !important;
    top: 8px !important;
    left: 50% !important;
    width: calc(100% - 16px) !important;
    height: 58px !important;
    margin: 0 !important;
    padding: 0 8px !important;
    transform: translateX(-50%) !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) !important;
    border: 0 !important;
    border-radius: 999px !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }

  body header.page-shared-header:not(.topbar) > nav,
  body > header:not(.topbar) nav,
  body > .nav nav {
    display: flex !important;
    min-width: 0 !important;
    gap: 1px !important;
    overflow: visible !important;
    font-size: 10px !important;
  }

  body header.page-shared-header:not(.topbar) > nav a,
  body > header:not(.topbar) nav a,
  body > .nav nav a {
    display: inline-flex !important;
    padding: 7px 5px !important;
    font-size: 10px !important;
    white-space: nowrap !important;
  }

  body header.page-shared-header:not(.topbar) > a:first-child,
  body > header:not(.topbar) > a,
  body > .nav .brand {
    position: static !important;
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: center !important;
    transform: none !important;
    font-size: 10px !important;
    white-space: nowrap !important;
  }

  body header.page-shared-header:not(.topbar) > .project-theme-toggle,
  body header.page-shared-header:not(.topbar) > .theme,
  body > header:not(.topbar) > .project-theme-toggle,
  body > .nav > .theme {
    position: static !important;
    grid-column: 3 !important;
    grid-row: 1 !important;
    justify-self: end !important;
    width: 32px !important;
    height: 32px !important;
    flex: 0 0 32px !important;
    transform: none !important;
  }

  .project-gallery-card {
    height: auto !important;
    aspect-ratio: 16 / 9;
  }

  .hero { height: 78vw; min-height: 340px; max-height: 560px; }
  .hero-copy { left: 20px; right: 20px; bottom: 42px; min-width: 0; }
  .hero h1 { font-size: clamp(48px, 16vw, 82px); overflow-wrap: anywhere; }
  main { min-width: 0; }
  .intro { min-width: 0; overflow-wrap: anywhere; }
  .screens { min-width: 0; }

  .hero-visual { width: 100%; aspect-ratio: 16 / 10; overflow: hidden; }
  .portfolio-main-img { display: block; width: 100%; height: 100%; max-width: 100%; object-fit: cover; }
  .sub-projects-grid, .project-gallery, .activity-grid, .value-grid, .stack-details, .credential-layout,
  .sub-card, .project-gallery-card, .activity-card, .value-grid article, .education-card, .license-list { min-width: 0; }
  .sub-card-title, .sub-card-desc, .project-gallery-card h3, .project-gallery-card p,
  .activity-card strong, .value-grid p, .license-list strong, .license-list p { overflow-wrap: anywhere; }

  #Download .sub-projects-grid, #SubProjects .sub-projects-grid {
    width: 100% !important; grid-template-columns: minmax(0, 1fr) !important; gap: 16px !important; margin-top: 32px !important;
  }

  #projectModal { width: calc(100% - 16px) !important; height: calc(100dvh - 16px) !important; max-height: calc(100dvh - 16px) !important; overflow: hidden !important; }
  #projectModal .modal-inner { height: 100% !important; overflow-y: auto !important; overflow-x: hidden !important; overscroll-behavior: contain !important; }
  #projectModal .modal-header { width: 100% !important; padding: 62px 24px 18px !important; }
  #projectModal .modal-title { font-size: clamp(38px, 13vw, 58px) !important; overflow-wrap: anywhere; }
  #projectModal .modal-content-grid { display: block !important; padding: 0 24px 44px !important; overflow: visible !important; }
  #projectModal .modal-visual { position: relative !important; width: 100% !important; height: auto !important; aspect-ratio: 16 / 10; margin-bottom: 28px !important; }
  #projectModal .modal-visual img { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; }
  #projectModal .modal-body { padding: 0 !important; overflow: visible !important; }
  #projectModal .modal-quick-summary dl { grid-template-columns: 1fr !important; margin-top: 36px !important; }
  #projectModal .modal-close { top: 14px !important; right: 14px !important; }
}

@media (max-width: 420px) {
  .project-row { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .project-row img { height: auto !important; aspect-ratio: 16 / 10; }
  .project-row strong { font-size: clamp(32px, 11vw, 40px); }
  .links a, .links .contact-phone { max-width: 100%; overflow-wrap: anywhere; }
}

/* Keep the About menu spacing aligned with Projects on compact screens. */
@media (max-width: 800px) {
  body header.nav.page-shared-header:not(.topbar) > nav {
    gap: 1px !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}

/* 모바일 테마 아이콘은 실제 심볼만 사용하고, 호버 커서가 덮지 않게 합니다. */
@media (max-width: 900px) {
  .topbar .topbar-theme-toggle,
  body header.page-shared-header:not(.topbar) > .project-theme-toggle,
  body header.page-shared-header:not(.topbar) > .theme,
  body > header:not(.topbar) > .project-theme-toggle,
  body > .nav > .theme {
    width: 32px !important;
    height: 32px !important;
    flex: 0 0 32px !important;
    display: grid !important;
    place-items: center !important;
    padding: 0 !important;
    margin: 0 !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: 20px 20px !important;
    filter: none !important;
  }

  body:not(.is-light-theme) .topbar .topbar-theme-toggle,
  body:not(.is-light-theme) header.page-shared-header:not(.topbar) > .project-theme-toggle,
  body:not(.is-light-theme) header.page-shared-header:not(.topbar) > .theme,
  body:not(.is-light-theme) > header:not(.topbar) > .project-theme-toggle,
  body:not(.light) > .nav > .theme {
    background-image: url("./img/moon.png") !important;
  }

  body.is-light-theme .topbar .topbar-theme-toggle,
  body.is-light-theme header.page-shared-header:not(.topbar) > .project-theme-toggle,
  body.is-light-theme header.page-shared-header:not(.topbar) > .theme,
  body.is-light-theme > header:not(.topbar) > .project-theme-toggle,
  body.light > .nav > .theme {
    background-image: url("./img/sun-black.svg") !important;
  }

  /* 홈 테마 버튼의 is-current 전용 규칙보다 우선해 심볼을 유지합니다. */
  body:not(.is-light-theme) .topbar nav.topbar-nav--right a.topbar-theme-toggle.is-current,
  body:not(.is-light-theme) .topbar nav.topbar-nav--right a.topbar-theme-toggle.is-current:hover,
  body:not(.is-light-theme) .topbar nav.topbar-nav--right a.topbar-theme-toggle.is-current:focus-visible {
    background: transparent url("./img/moon.png") center / 20px 20px no-repeat !important;
  }

  body.is-light-theme .topbar nav.topbar-nav--right a.topbar-theme-toggle.is-current,
  body.is-light-theme .topbar nav.topbar-nav--right a.topbar-theme-toggle.is-current:hover,
  body.is-light-theme .topbar nav.topbar-nav--right a.topbar-theme-toggle.is-current:focus-visible {
    background: transparent url("./img/sun-black.svg") center / 20px 20px no-repeat !important;
  }

  .topbar .topbar-theme-toggle::before,
  .topbar .topbar-theme-toggle::after,
  body header.page-shared-header:not(.topbar) > .project-theme-toggle::before,
  body header.page-shared-header:not(.topbar) > .project-theme-toggle::after,
  body header.page-shared-header:not(.topbar) > .theme::before,
  body header.page-shared-header:not(.topbar) > .theme::after {
    content: none !important;
    display: none !important;
  }

  body .topbar nav.topbar-nav--right a.topbar-theme-toggle.is-current::before,
  body .topbar nav.topbar-nav--right a.topbar-theme-toggle.is-current::after {
    content: none !important;
    display: none !important;
  }

  .universal-glass-cursor.is-theme-target {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }
}

/* 홈 헤더를 기준으로 태블릿·큰 모바일 폭의 공통 헤더 값을 통일합니다. */
@media (min-width: 721px) and (max-width: 900px) {
  body header.page-shared-header:not(.topbar),
  body > header:not(.topbar),
  body > .nav {
    height: 82px !important;
    padding: 0 16px !important;
  }

  body header.page-shared-header:not(.topbar) > nav,
  body > header:not(.topbar) nav,
  body > .nav nav {
    gap: 10px !important;
    padding: 0 !important;
  }

  body header.page-shared-header:not(.topbar) > nav a,
  body > header:not(.topbar) nav a,
  body > .nav nav a {
    padding: 12px 14px !important;
    font-size: 13px !important;
  }

  body header.page-shared-header:not(.topbar) > a:first-child,
  body > header:not(.topbar) > a,
  body > .nav .brand {
    font-size: 17px !important;
  }

  body header.page-shared-header:not(.topbar) > .project-theme-toggle,
  body header.page-shared-header:not(.topbar) > .theme,
  body > header:not(.topbar) > .project-theme-toggle,
  body > .nav > .theme {
    width: 44px !important;
    height: 44px !important;
    flex-basis: 44px !important;
  }
}

/* 모바일 다크 모드에서는 모든 헤더의 달 아이콘을 흰색으로 표시합니다. */
@media (max-width: 900px) {
  /* 홈 기준 모바일 헤더: 테마 버튼 크기와 세로 정렬을 통일합니다. */
  body .topbar-theme-toggle,
  body header.page-shared-header:not(.topbar) > .project-theme-toggle,
  body header.page-shared-header:not(.topbar) > .theme,
  body > header:not(.topbar) > .project-theme-toggle,
  body > .nav > .theme {
    width: 32px !important;
    height: 32px !important;
    flex: 0 0 32px !important;
    align-self: center !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 32px !important;
    display: grid !important;
    place-items: center !important;
    background-size: 20px 20px !important;
    transform: translateY(-3px) !important;
  }

  body .topbar-nav--right {
    align-items: center !important;
  }

  body:not(.is-light-theme) .topbar-theme-toggle,
  body:not(.is-light-theme) .project-theme-toggle,
  body:not(.light) .theme {
    background-image: url("./img/moon.png") !important;
    filter: brightness(0) invert(1) !important;
  }

  body.is-light-theme .topbar-theme-toggle::after {
    font-size: 18px !important;
    line-height: 28px !important;
  }
}

/* Final mobile video rule: preserve the complete 16:9 frame. */
@media (min-width: 721px) {
  #endpage .endfage-main-text3 h1 .desktop-only-break { display: block !important; }
  #endpage .endfage-main-text1 { transform: translateX(140px); }
  #endpage .endfage-main-text3 h1 span:first-child { position: relative; left: -80px; }
}

@media (max-width: 720px) {
  /* Keep the fixed mobile header clear of the first video frame. */
  .firstpage .hero-visual {
    margin-top: 64px !important;
  }

  /* In light mode the mobile header should meet the video with no visible gap. */
  body.is-light-theme .topbar {
    background: #fff !important;
    border-color: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .hero-visual { height: auto !important; }
  .portfolio-main-img {
    height: auto !important;
    aspect-ratio: 16 / 9;
    object-fit: contain !important;
    object-position: center !important;
  }
}

/* 모바일 테마 심볼은 글래스 포인터와 이전의 아이콘 효과를 적용하지 않습니다. */
@media (max-width: 900px) {
  body .topbar .topbar-theme-toggle,
  body .topbar .topbar-theme-toggle.is-current,
  body header.page-shared-header:not(.topbar) > .project-theme-toggle,
  body header.page-shared-header:not(.topbar) > .theme,
  body > header:not(.topbar) > .project-theme-toggle,
  body > .nav > .theme {
    width: 32px !important;
    height: 32px !important;
    flex: 0 0 32px !important;
    display: grid !important;
    place-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: translateY(2px) !important;
    background-color: transparent !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: 20px 20px !important;
    border: 0 !important;
    box-shadow: none !important;
    filter: none !important;
  }

  body:not(.is-light-theme) .topbar .topbar-theme-toggle,
  body:not(.is-light-theme) .topbar .topbar-theme-toggle:hover,
  body:not(.is-light-theme) .topbar .topbar-theme-toggle:focus-visible,
  body:not(.is-light-theme) .topbar .topbar-theme-toggle.is-current:hover,
  body:not(.is-light-theme) header.page-shared-header:not(.topbar) > .project-theme-toggle,
  body:not(.is-light-theme) header.page-shared-header:not(.topbar) > .theme,
  body:not(.is-light-theme) > header:not(.topbar) > .project-theme-toggle,
  body:not(.light) > .nav > .theme {
    background-image: url("./img/moon.png") !important;
  }

  body.is-light-theme .topbar .topbar-theme-toggle,
  body.is-light-theme .topbar .topbar-theme-toggle:hover,
  body.is-light-theme .topbar .topbar-theme-toggle:focus-visible,
  body.is-light-theme .topbar .topbar-theme-toggle.is-current,
  body.is-light-theme .topbar .topbar-theme-toggle.is-current:hover,
  body.is-light-theme header.page-shared-header:not(.topbar) > .project-theme-toggle,
  body.is-light-theme header.page-shared-header:not(.topbar) > .theme,
  body.is-light-theme > header:not(.topbar) > .project-theme-toggle,
  body.light > .nav > .theme {
    background-image: url("./img/sun-black.svg") !important;
  }

  body .topbar .topbar-theme-toggle::before,
  body .topbar .topbar-theme-toggle::after,
  body header.page-shared-header:not(.topbar) > .project-theme-toggle::before,
  body header.page-shared-header:not(.topbar) > .project-theme-toggle::after,
  body header.page-shared-header:not(.topbar) > .theme::before,
  body header.page-shared-header:not(.topbar) > .theme::after {
    content: none !important;
    display: none !important;
  }

  .universal-glass-cursor.is-theme-target {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }
}

/* 어바웃의 기존 텍스트 태양·달 배경이 겹치지 않도록 모바일 화이트 모드를 고정합니다. */
@media (max-width: 900px) {
  body.light > .nav > button.theme,
  body.light > .nav > button.theme:hover,
  body.light > .nav > button.theme:focus-visible {
    background: transparent url("./img/sun-black.svg") center / 20px 20px no-repeat !important;
    color: transparent !important;
    transform: translateY(2px) !important;
  }

  body.light > .nav > button.theme::before,
  body.light > .nav > button.theme::after {
    content: none !important;
    display: none !important;
  }
}

/* 어바웃 전용 스타일보다 높은 우선순위로 화이트 모드 심볼을 하나만 표시합니다. */
@media (max-width: 900px) {
  html body.light header.nav.page-shared-header > button.theme,
  html body.light header.nav.page-shared-header > button.theme:hover,
  html body.light header.nav.page-shared-header > button.theme:focus-visible {
    background: transparent url("./img/sun-black.svg") center / 20px 20px no-repeat !important;
    background-image: url("./img/sun-black.svg") !important;
    color: transparent !important;
    font-size: 0 !important;
    line-height: 0 !important;
  }

  html body.light header.nav.page-shared-header > button.theme::before,
  html body.light header.nav.page-shared-header > button.theme::after {
    content: none !important;
    display: none !important;
  }
}

/* 프로젝트 목록 헤더도 화이트 모드에서는 태양 SVG 하나만 표시합니다. */
@media (max-width: 900px) {
  html body.is-light-theme header.page-shared-header:not(.topbar) > button.project-theme-toggle,
  html body.is-light-theme header.page-shared-header:not(.topbar) > button.project-theme-toggle:hover,
  html body.is-light-theme header.page-shared-header:not(.topbar) > button.project-theme-toggle:focus-visible {
    background: transparent url("./img/sun-black.svg") center / 20px 20px no-repeat !important;
    background-image: url("./img/sun-black.svg") !important;
    color: transparent !important;
    font-size: 0 !important;
    line-height: 0 !important;
    transform: translateY(2px) !important;
  }

  html body.is-light-theme header.page-shared-header:not(.topbar) > button.project-theme-toggle::before,
  html body.is-light-theme header.page-shared-header:not(.topbar) > button.project-theme-toggle::after {
    content: none !important;
    display: none !important;
  }
}

/* 모바일 테마 아이콘 hover는 아이콘 위를 채우지 않고 투명한 글래스 링만 표시합니다. */
@media (max-width: 900px) {
  html .universal-glass-cursor.is-targeting.is-theme-target {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, .72) !important;
    box-shadow: 0 0 10px rgba(174, 220, 255, .08) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  html body.is-light-theme .universal-glass-cursor.is-targeting.is-theme-target {
    background: transparent !important;
    border-color: rgba(17, 21, 34, .32) !important;
    box-shadow: 0 0 10px rgba(17, 21, 34, .08) !important;
  }

  /* 테마 아이콘에는 커서의 내부 프리즘 레이어·그림자·중복 outline을 쓰지 않습니다. */
  html .universal-glass-cursor.is-targeting.is-theme-target,
  html body.is-light-theme .universal-glass-cursor.is-targeting.is-theme-target {
    background: transparent !important;
    box-shadow: none !important;
  }

  html .universal-glass-cursor.is-targeting.is-theme-target::before,
  html .universal-glass-cursor.is-targeting.is-theme-target::after {
    content: none !important;
    display: none !important;
    opacity: 0 !important;
  }

  body .topbar .topbar-theme-toggle:hover,
  body .topbar .topbar-theme-toggle:focus-visible,
  body header.page-shared-header:not(.topbar) > .project-theme-toggle:hover,
  body header.page-shared-header:not(.topbar) > .project-theme-toggle:focus-visible,
  body header.page-shared-header:not(.topbar) > .theme:hover,
  body header.page-shared-header:not(.topbar) > .theme:focus-visible {
    outline: none !important;
  }

  /* 커서 이벤트가 늦어도 CSS hover만으로 아이콘 주변 링이 즉시 보이게 합니다. */
  body .topbar .topbar-theme-toggle:hover,
  body .topbar .topbar-theme-toggle:focus-visible,
  body header.page-shared-header:not(.topbar) > .project-theme-toggle:hover,
  body header.page-shared-header:not(.topbar) > .project-theme-toggle:focus-visible,
  body header.page-shared-header:not(.topbar) > .theme:hover,
  body header.page-shared-header:not(.topbar) > .theme:focus-visible {
    outline: 1px solid rgba(255, 255, 255, .72) !important;
    outline-offset: 5px !important;
  }

  body.is-light-theme .topbar .topbar-theme-toggle:hover,
  body.is-light-theme .topbar .topbar-theme-toggle:focus-visible,
  body.is-light-theme header.page-shared-header:not(.topbar) > .project-theme-toggle:hover,
  body.is-light-theme header.page-shared-header:not(.topbar) > .project-theme-toggle:focus-visible,
  body.light header.page-shared-header:not(.topbar) > .theme:hover,
  body.light header.page-shared-header:not(.topbar) > .theme:focus-visible {
    outline-color: rgba(17, 21, 34, .35) !important;
  }

  /* 아이콘 뒤의 hover 채움은 제거하고 외곽 글래스 링만 유지합니다. */
  body .topbar .topbar-theme-toggle:hover,
  body .topbar .topbar-theme-toggle:focus-visible,
  body header.page-shared-header:not(.topbar) > .project-theme-toggle:hover,
  body header.page-shared-header:not(.topbar) > .project-theme-toggle:focus-visible,
  body header.page-shared-header:not(.topbar) > .theme:hover,
  body header.page-shared-header:not(.topbar) > .theme:focus-visible {
    background-color: transparent !important;
  }

  /* 테마 버튼은 커스텀 글래스 링만 사용하므로 CSS outline은 끕니다. */
  body .topbar .topbar-theme-toggle:hover,
  body .topbar .topbar-theme-toggle:focus-visible,
  body header.page-shared-header:not(.topbar) > .project-theme-toggle:hover,
  body header.page-shared-header:not(.topbar) > .project-theme-toggle:focus-visible,
  body header.page-shared-header:not(.topbar) > .theme:hover,
  body header.page-shared-header:not(.topbar) > .theme:focus-visible {
    outline: none !important;
  }
}

/* 홈 헤더 기준: 어바웃·프로젝트도 같은 모바일 프레임과 간격을 사용합니다. */
@media (max-width: 720px) {
  html body header.page-shared-header:not(.topbar),
  html body > header:not(.topbar),
  html body > .nav {
    position: fixed !important;
    z-index: 1000 !important;
    top: 8px !important;
    left: 50% !important;
    width: calc(100% - 16px) !important;
    height: 58px !important;
    margin: 0 !important;
    padding: 0 13px !important;
    transform: translateX(-50%) !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) !important;
    gap: 4px !important;
    align-items: center !important;
  }

  html body header.page-shared-header:not(.topbar) > nav,
  html body > header:not(.topbar) nav,
  html body > .nav nav {
    grid-column: 1 !important;
    grid-row: 1 !important;
    display: flex !important;
    align-items: center !important;
    gap: 1px !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  html body header.page-shared-header:not(.topbar) > nav a,
  html body > header:not(.topbar) nav a,
  html body > .nav nav a,
  html body .topbar-nav--left > a {
    display: inline-flex !important;
    align-items: center !important;
    padding: 7px 5px !important;
    margin: 0 !important;
    border-radius: 999px !important;
    font-size: 10px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  /* 현재 페이지 링크도 별도 강조 패딩을 사용하지 않아 모든 메뉴 폭을 동일하게 유지합니다. */
  html body header.page-shared-header:not(.topbar) > nav a.is-current,
  html body > header:not(.topbar) nav a.is-current,
  html body > .nav nav a.is-current,
  html body .topbar-nav--left > a.is-current {
    padding: 7px 5px !important;
    margin: 0 !important;
    border-radius: 999px !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  html body header.page-shared-header:not(.topbar) > a:first-child,
  html body > header:not(.topbar) > a,
  html body > .nav > .brand {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: center !important;
    position: static !important;
    transform: none !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 10px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  html body header.page-shared-header:not(.topbar) > .project-theme-toggle,
  html body header.page-shared-header:not(.topbar) > .theme,
  html body > header:not(.topbar) > .project-theme-toggle,
  html body > .nav > .theme {
    grid-column: 3 !important;
    grid-row: 1 !important;
    justify-self: end !important;
    position: static !important;
    width: 32px !important;
    height: 32px !important;
    flex: 0 0 32px !important;
    margin: 0 !important;
    transform: translateY(2px) !important;
  }
}

/* 페이지별 CSS보다 우선해 홈 헤더의 모바일 간격을 공통으로 유지합니다. */
@media (max-width: 720px) {
  html body header.page-shared-header:not(.topbar),
  html body > header:not(.topbar),
  html body > .nav {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  html body header.nav.page-shared-header:not(.topbar):not(.is-scrolled) > nav,
  html body header.page-shared-header:not(.topbar):not(.is-scrolled) > nav,
  html body > header:not(.topbar) nav,
  html body > .nav nav,
  html body .topbar-nav--left {
    gap: 4px !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* 홈의 상단 헤더 프레임까지 동일하게 맞춥니다. */
  html body header.page-shared-header:not(.topbar),
  html body > header:not(.topbar),
  html body > .nav {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 64px !important;
    transform: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }

  html body header.nav.page-shared-header:not(.topbar):not(.is-scrolled) {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 64px !important;
    transform: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }
}
