/* 모든 화면이 쓰는 공통 헤더. 예전에는 메인·단타 보드가 dashboard.css 안의
   규칙을 쓰고 확장앱 페이지(ticker/scalp 상세, optimize)는 web-shell.css 의
   다른 마크업을 써서 화면마다 헤더가 달랐다. 마크업은 서버가 한 곳에서
   만들고(_webShell), 모양은 이 파일 하나로만 정한다. */
.site-header {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 14, 21, .86);
  backdrop-filter: blur(20px) saturate(140%);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.site-nav { display: flex; align-items: center; gap: 4px; margin-left: 10px; }
.site-nav a {
  padding: 7px 11px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
  transition: color .2s, background .2s;
}
.site-nav a:hover { color: var(--text); background: rgba(255,255,255,.05); }
.site-nav a.current { color: #cfe0ff; background: var(--brand-soft); }
.header-search {
  margin-left: auto;
  display: flex;
  align-items: center;
  width: min(300px, 28vw);
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.header-search:focus-within { border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-soft); }
.header-search input {
  width: 100%;
  min-width: 0;
  padding: 8px 4px 8px 14px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  text-transform: uppercase;
  font: 700 12px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .04em;
}
.header-search input::placeholder { color: #667383; text-transform: none; font-family: inherit; font-weight: 500; letter-spacing: 0; }
.header-search button {
  align-self: stretch;
  border: 0;
  padding: 0 13px;
  color: #fff;
  background: var(--brand-strong);
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}
.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.refresh-button {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  margin-left: 7px;
  transition: border-color .2s, background .2s;
}
.refresh-button:hover { border-color: #536174; background: rgba(255,255,255,.04); }
.refresh-button:disabled { opacity: .55; cursor: wait; }

/* ---- optimized global toolbar ---- */
.site-header {
  height: auto;
  min-height: 70px;
  display: block;
  padding: 0;
  border-bottom: 1px solid rgba(164, 190, 226, .28);
  background: rgba(24, 34, 48, .96);
  box-shadow: 0 12px 34px rgba(4, 9, 16, .2);
  backdrop-filter: blur(24px) saturate(150%);
}
.header-inner {
  width: min(1360px, calc(100% - 48px));
  min-height: 70px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: clamp(14px, 1.8vw, 24px);
}
.header-primary, .header-actions { display: flex; align-items: center; min-width: 0; }
.header-primary { flex: 1 1 auto; gap: clamp(12px, 1.8vw, 24px); }
.header-actions { flex: 0 1 auto; gap: 16px; margin-left: auto; }
.brand {
  flex: none;
  padding: 10px 4px;
  border-radius: 8px;
}
.brand:focus-visible { outline: 2px solid var(--brand-tint); outline-offset: 4px; }
.brand-text { display: block; min-width: 0; }
.brand-wordmark {
  display: block;
  color: #f7f9fc;
  font-family: Pretendard, Inter, system-ui, sans-serif;
  font-size: 17px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: .105em;
  white-space: nowrap;
  text-rendering: geometricPrecision;
}
.brand:hover .brand-wordmark { color: #fff; }
.brand-tagline {
  display: block;
  margin-top: 5px;
  color: #aebaca;
  font-size: 9.5px;
  font-weight: 550;
  line-height: 1;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.site-nav { gap: 3px; margin-left: 0; }
.site-nav a {
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 600;
  transition: color .2s, border-color .2s, background .2s;
}
.site-nav a:hover { color: #fff; background: rgba(255,255,255,.09); }
.site-nav a.current {
  color: #fff;
  border-color: rgba(157,195,255,.62);
  background: linear-gradient(145deg, #3475d5, #235aad);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 4px 12px rgba(17,70,151,.2);
}
.header-search {
  width: min(280px, 24vw);
  height: 42px;
  margin-left: 0;
  border-color: #43526a;
  background: #243146;
  border-radius: 12px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.header-search:focus-within {
  border-color: rgba(116,174,255,.9);
  background: #2a3951;
  box-shadow: 0 0 0 3px rgba(47,116,224,.13);
}
.search-icon {
  width: 13px;
  height: 13px;
  position: relative;
  flex: none;
  margin-left: 14px;
  border: 1.5px solid #a7b6c9;
  border-radius: 50%;
}
.search-icon::after {
  content: "";
  width: 5px;
  height: 1.5px;
  position: absolute;
  right: -4px;
  bottom: -2px;
  border-radius: 2px;
  background: #a7b6c9;
  transform: rotate(45deg);
  transform-origin: left center;
}
.header-search input {
  padding: 8px 7px 8px 11px;
  font-weight: 750;
  letter-spacing: .05em;
}
.header-search input::placeholder {
  color: #9eacbf;
}
.header-search button {
  height: 34px;
  align-self: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  margin-right: 3px;
  padding: 0 11px;
  border: 1px solid rgba(143,182,247,.16);
  border-radius: 9px;
  background: linear-gradient(145deg, #3475d5, #235aad);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}
.header-search button:hover { filter: brightness(1.08); }
.header-search button i { color: #bcd3fb; font: 14px/1 system-ui, sans-serif; }
.header-status {
  min-width: 0;
  gap: 10px;
  padding-left: 16px;
  border-left: 1px solid var(--line-soft);
  color: #738196;
  font-size: 10.5px;
}
.refresh-button {
  min-width: 38px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-left: 1px;
  padding: 0 10px;
  border-radius: 9px;
  color: #aab5c5;
  background: rgba(255,255,255,.025);
  transition: color .2s, border-color .2s, background .2s, transform .2s;
}
.refresh-button > span:first-child { font-size: 15px; }
.refresh-button:hover {
  color: #fff;
  border-color: #46556b;
  background: rgba(255,255,255,.055);
  transform: translateY(-1px);
}
.refresh-button:focus-visible { outline: 2px solid var(--brand-tint); outline-offset: 2px; }
.refresh-button:disabled { transform: none; }

/* 로그인 영역. 카카오 버튼은 브랜드 노란색을 그대로 쓴다. */
.header-user { display: flex; align-items: center; gap: 8px; }
.hu-in, .hu-out {
  display: inline-flex; align-items: center; text-decoration: none;
  border-radius: 999px; padding: 8px 14px; font-size: 12.5px; font-weight: 650; white-space: nowrap;
}
.hu-in { background: #fee500; color: #191600; }
.hu-in:hover { filter: brightness(1.05); }
.hu-name { color: var(--text); font-size: 12.5px; font-weight: 650;
  max-width: 10ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hu-out { color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
.hu-out:hover { color: var(--text); border-color: #536174; }
@media (max-width: 680px) { .header-user { order: 2; } .hu-in, .hu-out { padding: 7px 12px; } }

/* ── 반응형 ────────────────────────────────────────────────────────────
   모든 웹 화면이 같은 헤더 구조와 높이를 쓴다. 900px 아래에서는
   로고·검색을 첫 줄, 메뉴를 둘째 줄에 고정해 내용에 따른 이동을 막는다. */
@media (max-width: 1100px) {
  .header-inner { width: calc(100% - 36px); gap: 12px; }
  .header-primary { gap: 12px; }
  .site-nav a { padding: 7px 8px; font-size: 11.5px; }
  .header-search { width: 240px; }
}

@media (max-width: 900px) {
  .site-header { min-height: 0; }
  .header-inner {
    width: calc(100% - 28px);
    min-height: 0;
    padding: 8px 0;
    display: grid;
    grid-template-columns: auto minmax(210px, 280px);
    align-items: center;
    gap: 8px 14px;
  }
  .header-primary { display: contents; }
  .brand { grid-column: 1; grid-row: 1; padding: 0; }
  .site-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    margin: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { flex: 0 0 auto; white-space: nowrap; }
  .header-actions {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    margin: 0;
  }
  .header-search { width: 100%; height: 40px; }
}

@media (max-width: 520px) {
  .header-inner {
    width: calc(100% - 24px);
    grid-template-columns: minmax(120px, auto) minmax(150px, 1fr);
    gap: 7px 10px;
    padding: 7px 0;
  }
  .brand-wordmark { font-size: 14.5px; letter-spacing: .08em; }
  .brand-tagline { margin-top: 4px; font-size: 8.5px; }
  .header-search { height: 38px; }
  .search-icon { margin-left: 11px; }
  .header-search input { padding-left: 9px; font-size: 11px; }
  .header-search button { height: 32px; padding: 0 9px; }
  .site-nav { gap: 2px; }
  .site-nav a { padding: 7px 9px; font-size: 12px; }
}


/* 공통 헤더의 좁은 화면 보정 */
.site-header { z-index: 100; }
.site-nav a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}
section[id],
section[class] { scroll-margin-top: 122px; }

@media (max-width: 900px) {
  .site-nav {
    scroll-snap-type: x proximity;
    overscroll-behavior-inline: contain;
    mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent);
  }
  .site-nav a { scroll-snap-align: start; }
}

@media (max-width: 520px) {
  .header-inner {
    grid-template-columns: minmax(104px, auto) minmax(0, 1fr);
  }
  .header-search button {
    width: 38px;
    justify-content: center;
    padding: 0;
  }
  .header-search button span { display: none; }
  .header-search button i { font-size: 16px; }
}

@media (max-width: 360px) {
  .header-inner { gap-inline: 8px; }
  .brand-wordmark { font-size: 13.5px; }
  .brand-tagline { display: none; }
  .search-icon { margin-left: 9px; }
  .header-search input { padding-left: 8px; font-size: 10.5px; }
}


/* 단타 화면: 자동 갱신은 중복 보조 바 대신 공통 툴바에서 알린다. */
.header-actions.scalp-tools { gap: 10px; }
.scalp-tools .header-search { flex: 1 1 180px; min-width: 160px; }
.scalp-auto-refresh {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #c5d1df;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}
.scalp-auto-refresh i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3fb950;
  box-shadow: 0 0 0 4px rgba(63,185,80,.12);
  animation: scalp-live-pulse 2.2s ease-in-out infinite;
}
.scalp-auto-refresh .auto-short { display: none; }
@keyframes scalp-live-pulse {
  50% { box-shadow: 0 0 0 6px rgba(63,185,80,.04); opacity: .76; }
}
@media (max-width: 1100px) {
  .scalp-auto-refresh .auto-wide { display: none; }
  .scalp-auto-refresh .auto-short { display: inline; }
}
@media (max-width: 900px) {
  .header-actions.scalp-tools { gap: 8px; }
  .scalp-tools .header-search { flex: 1 1 auto; width: auto; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .scalp-auto-refresh i { animation: none; }
}
