/* ══════════════════════════════════════════════
   앱 셸 (App Shell) — Sidebar + Main 구조
   데스크탑: 좌측 사이드바 + 우측 콘텐츠
   모바일:   상단 탑바 + 하단 네비게이션
══════════════════════════════════════════════ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ══════════════════════════════════════════════
   사이드바 (데스크탑 전용)
══════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: var(--z-sidebar);
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.28s var(--ease-out);
}

/* 모바일에서 사이드바 숨기기 */
@media (max-width: 1023px) {
  .sidebar { display: none; }
}

/* ── 사이드바 브랜드 영역 ── */
.sidebar-brand {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
  transition: opacity var(--duration);
}
.sidebar-brand:hover { opacity: 0.75; }

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent) 0%, #1faa6b 100%);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(62, 207, 142, 0.2);
  position: relative;
}
.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.brand-icon::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 55%);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
.brand-name {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-service {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  color: var(--text3);
  letter-spacing: 1.6px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ── 사이드바 상태 영역 ── */
.sidebar-status {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.update-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text3);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px 10px;
  white-space: nowrap;
  width: 100%;
}
.update-chip::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: livePulse 2.5s ease-in-out infinite;
}

/* 레짐 배지 */
.regime-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  white-space: nowrap;
  text-transform: uppercase;
  width: fit-content;
}
.regime-bullish {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(62, 207, 142, 0.25);
}
.regime-bearish {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(245, 101, 101, 0.25);
}
.regime-sideways {
  background: var(--yellow-bg);
  color: var(--yellow);
  border: 1px solid rgba(246, 201, 14, 0.25);
}
.regime-unknown,
.regime-conservative {
  background: rgba(160, 160, 160, 0.06);
  color: var(--text3);
  border: 1px solid var(--border);
}

/* ── 사이드바 네비게이션 메뉴 ── */
.sidebar-nav {
  flex: 1;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

/* 사이드바 섹션 라벨 */
.sidebar-section-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--text4);
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 10px 8px 6px;
  margin-top: 6px;
}
.sidebar-section-label:first-child { margin-top: 0; }

/* 사이드바 탭 아이템 */
.sidebar-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text3);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all var(--duration) var(--ease-out);
  position: relative;
}
.sidebar-tab:hover {
  background: var(--surface);
  color: var(--text2);
}
.sidebar-tab.active {
  background: var(--accent-dim2);
  color: var(--accent);
  font-weight: 600;
}
.sidebar-tab.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.sidebar-tab-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-tab-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 사이드바 접이식 그룹 */
.sidebar-group { }
.sidebar-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 8px 6px;
  margin-top: 6px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--text4);
  letter-spacing: 2px;
  text-transform: uppercase;
  border-radius: var(--r-sm);
  transition: color var(--duration) var(--ease-out), background var(--duration) var(--ease-out);
}
.sidebar-group-header:hover { color: var(--text2); background: var(--surface); }
.sidebar-group:first-child .sidebar-group-header { margin-top: 0; }

.sidebar-group-chevron {
  flex-shrink: 0;
  color: var(--text4);
  transition: transform .2s ease;
}
.sidebar-group.collapsed .sidebar-group-chevron { transform: rotate(-90deg); }

.sidebar-group-body {
  overflow: hidden;
  max-height: 500px;
  opacity: 1;
  transition: max-height .25s ease-out, opacity .18s ease-out;
}
.sidebar-group.collapsed .sidebar-group-body {
  max-height: 0;
  opacity: 0;
}

/* 사이드바 하단 푸터 */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  /* disclaimer-bar(약 36px) 위에 겹치지 않도록 */
  margin-bottom: 36px;
}
.sidebar-footer-text {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text4);
  line-height: 1.6;
  text-align: center;
}
.sidebar-footer-text a {
  color: var(--accent);
  text-decoration: none;
}
.sidebar-footer-text a:hover { opacity: 0.7; }

.sidebar-footer-links {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text4);
  text-align: center;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}
.sidebar-footer-links a {
  color: var(--text3);
  text-decoration: none;
  transition: color var(--duration);
}
.sidebar-footer-links a:hover { color: var(--accent); }
.sidebar-footer-sep { color: var(--border); }

.toss-donate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  padding: 7px 0;
  margin-bottom: 10px;
  border-radius: var(--r-sm);
  background: rgba(62, 207, 142, 0.08);
  border: 1px solid rgba(62, 207, 142, 0.2);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background var(--duration), border-color var(--duration), opacity var(--duration);
}
.toss-donate-btn:hover {
  background: rgba(62, 207, 142, 0.15);
  border-color: rgba(62, 207, 142, 0.4);
}

/* 커피 후원 모달 */
.donation-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(2px);
  z-index: 3000;
}
.donation-modal-backdrop.open { display: block; }
.donation-modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 24px 20px;
  z-index: 3001;
  text-align: center;
  width: 300px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.donation-modal.open { display: block; }
.donation-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.6;
  transition: opacity var(--duration);
}
.donation-modal-close:hover { opacity: 1; }
.donation-modal-header { margin-bottom: 14px; }
.donation-modal-badge {
  display: inline-block;
  background: #FEE500;
  color: #3A1D1D;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 8px;
}
.donation-modal-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px;
}
.donation-modal-amount {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  margin: 0;
}
.donation-qr-wrap {
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  display: inline-block;
  line-height: 0;
}
.donation-qr-img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  display: block;
}
.donation-modal-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin: 12px 0 0;
}
/* PC/모바일 표시 분기 */
@media (max-width: 1023px) {
  .donation-pc-only { display: none !important; }
}
@media (min-width: 1024px) {
  .donation-mobile-only { display: none !important; }
}
/* 모바일 카카오페이 버튼 */
.donation-kakao-btn {
  display: block;
  margin: 14px 0 0;
  padding: 10px 0;
  background: #FEE500;
  color: #3A1D1D;
  font-size: 13px;
  font-weight: 700;
  border-radius: 10px;
  text-decoration: none;
}
.donation-kakao-btn:hover { opacity: 0.88; }
/* 텔레그램 혜택 섹션 */
.donation-benefit {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.donation-benefit-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.donation-benefit-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0 0 10px;
  line-height: 1.5;
}
.donation-tg-btn {
  display: block;
  padding: 9px 0;
  background: #229ED9;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  border-radius: 10px;
  text-decoration: none;
}
.donation-tg-btn:hover { opacity: 0.88; }


/* ══════════════════════════════════════════════
   메인 콘텐츠 영역
══════════════════════════════════════════════ */
.main-content {
  flex: 1;
  min-width: 0;
}

/* 모바일: topbar(52px) 상단 여백 */
@media (max-width: 1023px) {
  .main-content {
    padding-top: 52px;
  }
}

/* 데스크탑: 사이드바 너비만큼 왼쪽 margin */
@media (min-width: 1024px) {
  .main-content {
    margin-left: var(--sidebar-w);
  }
}



/* ══════════════════════════════════════════════
   모바일 탑바
   (모바일/태블릿에서만 표시)
══════════════════════════════════════════════ */
.mobile-topbar {
  display: none;
}

@media (max-width: 1023px) {
  .mobile-topbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    /* sticky → fixed: iOS Safari 스크롤 떨림 방지 */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    padding: 0 16px;
    z-index: var(--z-topbar);
    background: rgba(15, 15, 15, 0.94);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    /* iOS GPU 레이어 — fixed + backdrop-filter 깜빡임 방지 */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
  }
}

.mobile-topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.mobile-topbar-brand .brand-name {
  font-size: 13px;
}

/* 모바일 탑바 센터 타이틀 */
.mobile-topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.mobile-topbar-title {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 2px;
}

.mobile-topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}


/* ══════════════════════════════════════════════
   페이지 헤더 (각 탭 상단 — 데스크탑 탑바 역할)
══════════════════════════════════════════════ */
.page-header {
  display: none; /* 데스크탑에서만 표시 */
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  background: rgba(15, 15, 15, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  padding: 0 28px;
  height: var(--topbar-h);
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

@media (min-width: 1024px) {
  .page-header { display: flex; }
}

.page-header-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.page-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}


/* ══════════════════════════════════════════════
   콘텐츠 패딩 래퍼
══════════════════════════════════════════════ */
.content-wrap {
  padding: 20px 16px;
  max-width: 1400px;
  margin: 0 auto;
  /* 모바일에서 자식 요소가 화면 밖으로 나가는 것 차단 */
  overflow-x: hidden;
  box-sizing: border-box;
  min-width: 0;
}

@media (min-width: 768px) {
  .content-wrap { padding: 24px 24px; }
}

@media (min-width: 1024px) {
  .content-wrap { padding: 28px 32px; }
}


/* ══════════════════════════════════════════════
   모바일 바텀 네비게이션
   구조:
     <nav.bottom-nav>               ← fixed, flex-column
       <div.disclaimer-bar-inline>  ← 투자 경고 한 줄
       <div.bottom-nav-tabs>        ← 탭 버튼 가로 배열
══════════════════════════════════════════════ */
.bottom-nav {
  display: none;
}

@media (max-width: 1023px) {
  .bottom-nav {
    display: flex;
    flex-direction: column;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-topbar);
    background: rgba(15, 15, 15, 0.97);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    padding-bottom: env(safe-area-inset-bottom);
    /* iOS GPU 레이어 — fixed + backdrop-filter 깜빡임 방지 */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
  }
}

@media (min-width: 1024px) {
  .bottom-nav { display: none; }
}

/* ── 투자 경고 줄 ── */
.disclaimer-bar-inline {
  display: none;
}

@media (max-width: 1023px) {
  .disclaimer-bar-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 4px 16px;
    border-bottom: 1px solid var(--border);
  }
  .disclaimer-bar-inline .disclaimer-bar-text {
    text-align: center;
  }
}

/* ── 모바일 후원바 ── */
.donate-bar {
  display: none;
}
@media (max-width: 1023px) {
  .donate-bar {
    display: block;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.35s ease, opacity 0.28s ease, border-color 0.35s ease;
    border-bottom: 1px solid transparent;
  }
  .donate-bar.visible {
    max-height: 38px;
    opacity: 1;
    border-bottom-color: var(--border);
  }
  .donate-bar-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    padding: 9px 0;
    background: none;
    border: none;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
    text-decoration: none;
    cursor: pointer;
  }
}

/* ── 탭 버튼 행 ── */
.bottom-nav-tabs {
  display: flex;
  align-items: stretch;
  height: var(--bottom-nav-h);   /* 60px */
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.bottom-nav-tabs::-webkit-scrollbar { display: none; }

/* ── 탭 버튼 ── */
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  min-width: 60px;
  padding: 8px 4px 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text4);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: color var(--duration) var(--ease-out);
  position: relative;
  white-space: nowrap;
}
.bottom-nav-item:hover { color: var(--text2); }
.bottom-nav-item.active {
  color: var(--accent);
  font-weight: 600;
}
.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 3px 3px;
}

.bottom-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.bottom-nav-icon svg { transition: transform var(--duration) var(--ease-out); }
.bottom-nav-item.active .bottom-nav-icon svg { stroke: var(--accent); }
.bottom-nav-item:hover .bottom-nav-icon svg { transform: translateY(-1px); }

.bottom-nav-label {
  font-size: 9.5px;
  letter-spacing: 0.3px;
  white-space: nowrap;
  line-height: 1;
}


/* ══════════════════════════════════════════════
   탭 그룹 서브메뉴 (바텀 네비 위에 슬라이드업)
══════════════════════════════════════════════ */
.tab-group-sheet {
  display: none;
}

@media (max-width: 1023px) {
  .tab-group-sheet {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: calc(var(--z-topbar) - 1);
    transform: translateY(100%) translateZ(0);
    -webkit-transform: translateY(100%) translateZ(0);
    transition: transform 0.22s var(--ease-out), opacity 0.22s;
    opacity: 0;
    pointer-events: none;
    will-change: transform;
  }
  .tab-group-sheet.open {
    transform: translateY(0) translateZ(0);
    -webkit-transform: translateY(0) translateZ(0);
    opacity: 1;
    pointer-events: auto;
  }
}

.tab-group-sheet-inner {
  background: rgba(20, 20, 20, 0.98);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  padding: 8px 12px 10px;
}

.tab-group-items {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tab-group-items::-webkit-scrollbar { display: none; }

.tab-group-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--duration) var(--ease-out);
}
.tab-group-item:hover {
  color: var(--text2);
  background: var(--surface2);
  border-color: var(--border2);
}
.tab-group-item.active {
  color: var(--accent);
  background: var(--accent-dim2);
  border-color: rgba(62, 207, 142, 0.3);
  font-weight: 600;
}
.tab-group-item svg { flex-shrink: 0; stroke: currentColor; }


.tab-sheet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px 0;
}

.tab-sheet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text2);
  transition: all var(--duration) var(--ease-out);
}
.tab-sheet-item:hover,
.tab-sheet-item:active {
  background: var(--surface3);
  border-color: var(--border2);
}
.tab-sheet-item.active {
  background: var(--accent-dim2);
  border-color: rgba(62, 207, 142, 0.3);
  color: var(--accent);
}
.tab-sheet-item .icon {
  font-size: 22px;
  line-height: 1;
}
.tab-sheet-item .label {
  text-align: center;
  line-height: 1.3;
}


