/* ══ 드로어 기본 숨김 (hidden 속성·FOUC 이중 방어) ══ */
.nhx2-drawer[hidden] {
  display: none !important;
  pointer-events: none !important;
}

/* ══ 모바일 전용 — 769px+ 데스크탑에서는 완전 숨김 ══ */
@media (min-width: 769px) {
  .nhx2-root, .nhx2-drawer { display: none !important; }
}

/* ══ 기본 리셋 ══ */
.nhx2-root *, .nhx2-drawer * { box-sizing: border-box; }
.nhx2-root a, .nhx2-drawer a { color: inherit; text-decoration: none; }
.nhx2-root button, .nhx2-drawer button {
  background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer;
}

/* ══ 헤더 루트 — sticky 고정 ══ */
.nhx2-root {
  position: sticky;
  top: 0;
  z-index: 9900;
  background: #fff;
  box-shadow: 0 1px 8px rgba(0,0,0,.08);
  overflow-anchor: none;
  /* safe-area: 노치/Dynamic Island 대응 */
  padding-top: env(safe-area-inset-top);
}

/* ══ ① 공지 티커 — 컴팩트 ══ */
.nhx2-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 26px;
  padding: 0 12px;
  background: var(--nhx-accent);
  overflow: hidden;
}
.nhx2-notice-label {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: rgba(255,255,255,.2);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}
.nhx2-notice-vp { flex: 1; overflow: hidden; position: relative; height: 26px; }
.nhx2-notice-track {
  display: flex;
  gap: 32px;
  position: absolute;
  top: 0; left: 0;
  height: 26px;
  align-items: center;
  white-space: nowrap;
  animation: nhx2-scroll 14s linear infinite;
}
.nhx2-notice-track a { font-size: 14px; color: rgba(255,255,255,.95); white-space: nowrap; }
@keyframes nhx2-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ══ ② 메인 바 ══ */
.nhx2-main {
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 8px;
  gap: 4px;
  background: #fff;
}

/* 아이콘 버튼 — 44px 터치 타깃 */
.nhx2-iconbtn {
  position: relative;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 20px;
  color: #374151;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s;
}
.nhx2-iconbtn:active { background: #f3f4f6; }

/* 배지 (알림 수) */
.nhx2-iconbtn .nhx2-badge {
  position: absolute;
  top: 6px; right: 6px;
  min-width: 16px; height: 16px;
  background: #ef4444;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border-radius: 999px;
  padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}

/* 로고 */
.nhx2-logo {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  max-height: 44px;
  padding: 0 6px;
  font-weight: 900;
  font-size: 18px;
  color: var(--nhx-accent);
  letter-spacing: -.5px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.nhx2-logo-mark {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--nhx-accent);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px;
}
.nhx2-logo-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
}
.nhx2-logo-img { height: 28px !important; max-height: 28px !important; width: auto !important; max-width: 140px; object-fit: contain; display: block; }

/* nhx2-iconbtn 내부 텍스트 숨김 — 아이콘만 표시, 텍스트는 aria-label로 대체 */
.nhx2-iconbtn .np-txt { display: none; }
/* 카테고리 전체버튼 텍스트도 숨김 */
.nhx2-cats-allbtn .np-txt { display: none; }

/* 우측 아이콘 묶음 */
.nhx2-actions { display: flex; align-items: center; gap: 0; flex-shrink: 0; }

/* ══ ③ 카테고리 스크롤 바 ══ */
.nhx2-cats {
  display: flex;
  align-items: center;
  height: 42px;
  border-top: 1px solid #f1f5f9;
  background: #fff;
  position: relative;
}
.nhx2-cats-allbtn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 52px;
  height: 42px;
  font-size: 14px;
  font-weight: 600;
  color: #4b5563;
  border-right: 1px solid #f1f5f9;
  -webkit-tap-highlight-color: transparent;
}
.nhx2-cats-allbtn i { font-size: 16px; }
.nhx2-cats-scroller {
  flex: 1;
  display: flex;
  align-items: center;
  overflow-x: auto;
  scroll-behavior: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  height: 42px;
  padding: 0 6px;
  gap: 2px;
}
.nhx2-cats-scroller::-webkit-scrollbar { display: none; }
.nhx2-cats-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  height: 42px;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 500;
  color: #6b7280;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: color .12s, border-color .12s;
}
.nhx2-cats-chip.is-active {
  color: var(--nhx-accent);
  font-weight: 800;
  border-bottom-color: var(--nhx-accent);
}
.nhx2-cats::after {
  content: "";
  position: absolute; right: 0; top: 0;
  width: 28px; height: 42px;
  background: linear-gradient(90deg, rgba(255,255,255,0), #fff);
  pointer-events: none;
}

/* ══ ④ 검색 패널 ══ */
.nhx2-search-panel {
  display: none;
  padding: 10px 12px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}
.nhx2-search-panel.is-open { display: block; }
.nhx2-search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 0 8px 0 14px;
  height: 46px;        /* 44px+ */
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  transition: border-color .15s;
}
.nhx2-search-form:focus-within { border-color: var(--nhx-accent); }
.nhx2-search-form input {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 16px;      /* iOS zoom 방지 */
  height: 100%;
  outline: 0;
  color: #1e293b;
}
.nhx2-search-form button[type="submit"] {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--nhx-accent);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

/* ══ ⑤ 드로어 ══ */
.nhx2-drawer {
  position: fixed; inset: 0;
  z-index: 9980;
  display: none; pointer-events: none;
}
.nhx2-drawer.is-open { display: block; pointer-events: auto; }
.nhx2-drawer-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45);
  opacity: 0;
  transition: opacity .25s;
}
.nhx2-drawer.is-open .nhx2-drawer-backdrop { opacity: 1; }
.nhx2-drawer-panel {
  position: absolute; top: 0; left: 0;
  width: 88vw; max-width: 340px;
  height: 100%;
  background: #fff;
  transform: translateX(-100%);
  transition: transform .26s cubic-bezier(.22,.61,.36,1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.nhx2-drawer.is-open .nhx2-drawer-panel { transform: translateX(0); }

/* 드로어 헤더 */
.nhx2-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px;
  background: linear-gradient(135deg, var(--nhx-accent) 0%, color-mix(in srgb,var(--nhx-accent) 70%,#000) 100%);
  color: #fff;
  flex-shrink: 0;
}
.nhx2-drawer-head .user { display: flex; align-items: center; gap: 12px; }
.nhx2-drawer-head .avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.nhx2-drawer-head .user-name { font-size: 16px; font-weight: 700; }
.nhx2-drawer-head .user-sub { display: block; font-size: 14px; opacity: .85; margin-top: 2px; }
.nhx2-drawer-head .user-sub a { color: rgba(255,255,255,.9); }
.nhx2-drawer-head .close {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; color: rgba(255,255,255,.85);
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}
.nhx2-drawer-head .close:active { background: rgba(255,255,255,.15); }

/* 빠른 이동 — 4열 */
.nhx2-drawer-quick {
  display: grid; grid-template-columns: repeat(4,1fr);
  gap: 4px; padding: 12px 10px 14px;
  border-bottom: 6px solid #f3f4f6;
}
.nhx2-drawer-quick a {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 4px; border-radius: 10px;
  color: #374151; font-size: 14px; font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.nhx2-drawer-quick a:active { background: #f3f4f6; }
.nhx2-drawer-quick a i { font-size: 24px; color: var(--nhx-accent); }

/* 드로어 섹션 */
.nhx2-drawer-sec { padding: 14px 16px 6px; border-bottom: 6px solid #f3f4f6; }
.nhx2-drawer-sec h2 { margin: 0 0 10px; font-size: 14px; font-weight: 700; color: #9ca3af; letter-spacing: .5px; text-transform: uppercase; }

/* 포털 그리드 — 3열 */
.nhx2-cat-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; padding-bottom: 10px; }
.nhx2-cat-grid a {
  display: flex; align-items: center; justify-content: center;
  padding: 12px 4px; border-radius: 10px;
  font-size: 15px; font-weight: 500;
  background: #f8fafc; color: #374151; text-align: center;
  border: 1px solid #f1f5f9;
  -webkit-tap-highlight-color: transparent;
}
.nhx2-cat-grid a.is-active { background: var(--nhx-accent); color: #fff; font-weight: 700; border-color: var(--nhx-accent); }
.nhx2-cat-grid a:active { opacity: .8; }

/* 트리 — 1차 */
.nhx2-tree { display: flex; flex-direction: column; padding-bottom: 8px; }
.nhx2-tree details { border-bottom: 1px solid #f1f5f9; }
.nhx2-tree details[open] > summary .nhx2-tree-caret { transform: rotate(180deg); }
.nhx2-tree summary { list-style: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.nhx2-tree summary::-webkit-details-marker { display: none; }
.nhx2-tree-1 > summary {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 4px;
  font-size: 16px; color: #1f2937;
}
.nhx2-tree-1 > summary .nhx2-tree-label { display: flex; align-items: center; gap: 10px; }
.nhx2-tree-1 > summary .nhx2-tree-icon { width: 22px; color: var(--nhx-accent); text-align: center; font-size: 16px; }
.nhx2-tree-1.is-active > summary { color: var(--nhx-accent); font-weight: 700; }
.nhx2-tree-caret { color: #d1d5db; font-size: 14px; transition: transform .18s; flex-shrink: 0; }

/* 2차 */
.nhx2-tree-2 {
  background: #fafbfc;
  padding: 6px 0 8px 16px;
  border-left: 3px solid color-mix(in srgb,var(--nhx-accent) 30%,#fff);
  margin-left: 6px;
}
.nhx2-tree-2-home {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 4px;
  font-size: 15px; color: var(--nhx-accent); font-weight: 600;
}
.nhx2-tree-2-leaf {
  display: block; padding: 10px 4px;
  font-size: 15px; color: #374151;
  border-top: 1px dashed #e5e7eb;
  -webkit-tap-highlight-color: transparent;
}
.nhx2-tree-2-leaf:active { color: var(--nhx-accent); }
.nhx2-tree-2-group { border-top: 1px dashed #e5e7eb; }
.nhx2-tree-2-group > summary {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 4px; font-size: 15px; color: #374151;
}
.nhx2-tree-2-name { flex: 1; }

/* 3차 */
.nhx2-tree-3 {
  display: flex; flex-direction: column;
  padding: 4px 0 6px 12px;
  border-left: 2px solid #e5e7eb;
  margin: 0 0 4px 8px;
}
.nhx2-tree-3 a {
  padding: 8px 4px; font-size: 15px; color: #6b7280;
  -webkit-tap-highlight-color: transparent;
}
.nhx2-tree-3 a:active { color: var(--nhx-accent); }
.nhx2-tree-3 a + a { border-top: 1px dotted #e5e7eb; }

/* 드로어 하단 */
.nhx2-drawer-foot {
  margin-top: auto;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  font-size: 14px; color: #9ca3af;
  display: flex; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
}
.nhx2-drawer-foot a { color: #94a3b8; }
.nhx2-drawer-foot a:hover { color: var(--nhx-accent); }

/* 드로어 열림 시 스크롤 잠금 */
body.nhx2-lock { overflow: hidden; }

/* 모바일: 포털 헤더(nhx2) 아래에 개별포털 서브헤더(nph) sticky — top:0 겹침·스크롤 점프 방지 */
@media (max-width: 768px) {
  html.layout-mobile .nph-root,
  html.layout-mobile [data-nph-root] {
    top: var(--nhx2-sticky-bottom, 120px);
    overflow-anchor: none;
  }
}
