/* 카카오뱅크풍 모바일 우선 디자인 */
:root {
  --yellow: #ffe300;
  --yellow-dark: #f5d800;
  --ink: #191919;
  --gray-9: #333;
  --gray-6: #767678;
  --gray-3: #d9d9dc;
  --gray-1: #f4f4f6;
  --white: #fff;
  --red: #f04452;
  --blue: #3182f6;
  --radius: 18px;
  --hl: #fffbe0;         /* 선택·강조 배경 (연노랑) */
  --badge-up-bg: #fff4d6; --badge-up-fg: #b47d00;   /* 단기 */
  --badge-mid-bg: #e8f3ff; --badge-mid-fg: #3182f6; /* 중기 */
  --badge-on-bg: #e9f9ee; --badge-on-fg: #1aa053;   /* 작동/장기 */
  --badge-red-bg: #fdecee; --badge-red-fg: #f04452; /* 초단기 */
  --badge-ind-bg: #eef1ff; --badge-ind-fg: #4a55c7; /* 지표 */
}

/* 다크 모드: 시맨틱 변수만 재정의 (data-theme="dark" 또는 시스템 설정) */
:root[data-theme="dark"] {
  --ink: #ededed;
  --gray-9: #d0d0d2;
  --gray-6: #9a9aa0;
  --gray-3: #3a3a3f;
  --gray-1: #1c1c20;
  --white: #26262b;   /* 카드/표면 */
  --red: #ff6b76;
  --blue: #5a9dff;
  --yellow-dark: #d4bd00;
  /* 강조/뱃지: 어두운 배경 + 밝은 글자로 대비 확보 */
  --hl: #3a3320;
  --badge-up-bg: #4a3d16; --badge-up-fg: #f5c451;
  --badge-mid-bg: #1c3350; --badge-mid-fg: #7cb4ff;
  --badge-on-bg: #1c3d2a; --badge-on-fg: #5fd08a;
  --badge-red-bg: #4d2429; --badge-red-fg: #ff8a92;
  --badge-ind-bg: #262a4d; --badge-ind-fg: #9aa5ff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #ededed;
    --gray-9: #d0d0d2;
    --gray-6: #9a9aa0;
    --gray-3: #3a3a3f;
    --gray-1: #1c1c20;
    --white: #26262b;
    --red: #ff6b76;
    --blue: #5a9dff;
    --yellow-dark: #d4bd00;
    --hl: #3a3320;
    --badge-up-bg: #4a3d16; --badge-up-fg: #f5c451;
    --badge-mid-bg: #1c3350; --badge-mid-fg: #7cb4ff;
    --badge-on-bg: #1c3d2a; --badge-on-fg: #5fd08a;
    --badge-red-bg: #4d2429; --badge-red-fg: #ff8a92;
    --badge-ind-bg: #262a4d; --badge-ind-fg: #9aa5ff;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
    "Noto Sans KR", "Malgun Gothic", sans-serif;
  background: var(--gray-1);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* 금액·수치는 등폭 숫자로 자릿수 비교가 쉽게 */
.num, .stat .num, .w-stat .num, .sheet-table td, .val-col .num,
.up, .down { font-variant-numeric: tabular-nums; }

/* 로딩 스켈레톤 */
.skeleton {
  background: linear-gradient(90deg, var(--gray-1) 25%, var(--gray-3) 37%, var(--gray-1) 63%);
  background-size: 400% 100%;
  animation: skel 1.4s ease infinite;
  border-radius: 8px;
  color: transparent !important;
}
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skel-line { height: 14px; margin: 8px 0; }
.skel-line.w60 { width: 60%; }
.skel-line.w40 { width: 40%; }

/* 로딩 스피너 (조회·위젯 로딩 표현) */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--gray-3);
  border-top-color: var(--yellow-dark, #b39700);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
.spinner.lg { width: 26px; height: 26px; border-width: 3px; }
.loading-row { display: flex; align-items: center; gap: 8px; padding: 14px 12px; color: var(--gray-6); font-size: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn[disabled] { opacity: 0.6; cursor: default; }

/* 차트 공통 로딩 오버레이 — 모든 차트 영역 동일 표현 (chartLoading 헬퍼가 부착) */
.chart-loading {
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}

/* 환영 화면 항목 */
.wc-item { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--gray-1); }
.wc-item:last-child { border-bottom: none; }
.wc-emoji { font-size: 28px; flex: none; }
.wc-item b { display: block; margin-bottom: 3px; }
.wc-item p { font-size: 13px; line-height: 1.5; }

/* 빈 상태 */
.empty-state { text-align: center; padding: 28px 20px; }
.empty-state .emoji { font-size: 40px; display: block; margin-bottom: 10px; }
.empty-state .msg { color: var(--gray-6); font-size: 14px; line-height: 1.6; margin-bottom: 14px; }

/* 접근성: 키보드 포커스 링 */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 20px 20px 96px;
}
/* 고정 헤더가 있으면 바디를 그 아래에서 시작 */
.app-header ~ .app { padding-top: 74px; }
.embed .app { padding-top: 20px; }

h1 { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
h2 { font-size: 18px; font-weight: 700; margin: 24px 0 12px; }
.sub { color: var(--gray-6); font-size: 14px; line-height: 1.5; }

/* 카드 */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.card.tap { cursor: pointer; transition: transform 0.08s; }
.card.tap:active { transform: scale(0.98); }
.card-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* 버튼 */
.btn {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  background: var(--gray-1);
  transition: filter 0.1s;
}
.btn:active { filter: brightness(0.94); }
/* 노란 버튼은 항상 밝은 배경이므로 글자는 테마와 무관하게 진하게 고정 (다크모드 흰 글자 방지) */
.btn-primary { background: var(--yellow); color: #191919; }
.btn-dark { background: var(--ink); color: var(--white); }
.btn-sm { width: auto; padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.btn-danger { background: var(--badge-red-bg); color: var(--red); }
.btn:disabled { opacity: 0.4; cursor: default; }
/* 더 보기 버튼 (목록 확장) */
.more-btn {
  background: transparent; color: var(--gray-6);
  border: 1px solid var(--gray-3); border-radius: 12px;
  padding: 11px; font-size: 14px; font-weight: 600;
}

/* 입력 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--gray-6); margin-bottom: 6px; font-weight: 600; }
.field input, .field select {
  width: 100%;
  padding: 14px;
  border: 1.5px solid var(--gray-3);
  border-radius: 12px;
  font-size: 16px;
  background: var(--white);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--ink); }

/* 폼 요소는 브라우저 기본 글자색(검정)을 상속하지 않으므로 명시적으로 테마색 지정.
   (다크모드에서 입력 글자가 검정으로 나와 안 보이던 문제 방지) */
input, select, textarea { color: var(--ink); }
/* 배경도 테마색으로 고정 — 안 그러면 인라인 스타일 등에서 배경이 브라우저 기본(흰색)이 돼
   다크모드에서 흰 배경 + 밝은 글자로 안 보인다. 체크박스·라디오는 기본 모양 유지 위해 제외 */
input:not([type="checkbox"]):not([type="radio"]), select, textarea { background-color: var(--white); }
input::placeholder, textarea::placeholder { color: var(--gray-6); opacity: 1; }
/* 네이티브 컨트롤(셀렉트 화살표 등)이 테마에 맞게 렌더되도록 */
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

/* 뱃지/태그 */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--gray-1);
  color: var(--gray-6);
}
.badge.h-초단기 { background: var(--badge-red-bg); color: var(--badge-red-fg); }
.badge.h-단기 { background: var(--badge-up-bg); color: var(--badge-up-fg); }
.badge.h-중기 { background: var(--badge-mid-bg); color: var(--badge-mid-fg); }
.badge.h-장기 { background: var(--badge-on-bg); color: var(--badge-on-fg); }
.badge.on { background: var(--badge-on-bg); color: var(--badge-on-fg); }
.badge.off { background: var(--gray-1); color: var(--gray-6); }
.badge.composite { background: #2b2b30; color: var(--yellow); }
.badge.ind { background: var(--badge-ind-bg); color: var(--badge-ind-fg); }

/* 종목명 자동완성 */
.stock-suggest {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  z-index: 85;
  max-height: 260px;
  overflow-y: auto;
  margin-top: 4px;
}
.stock-suggest-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-1);
  font-size: 14px;
}
.stock-suggest-item:last-child { border-bottom: none; }
.stock-suggest-item:hover, .stock-suggest-item:active { background: var(--gray-1); }
.stock-suggest-item span { color: var(--gray-6); font-size: 12px; }

/* 데모/모의/실전 모드 배지 */
.mode-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  vertical-align: middle;
}
.mode-badge.demo { background: var(--gray-1); color: var(--gray-6); border: 1.5px dashed var(--gray-3); }
.mode-badge.paper { background: var(--badge-mid-bg); color: var(--badge-mid-fg); }
.mode-badge.real { background: var(--badge-red-bg); color: var(--badge-red-fg); }

/* 차트 시뮬레이션 헤더: 제목이 길어도 재생 컨트롤이 가려지지 않게 줄바꿈 */
#simBox .card-row, #botSimBox .card-row { flex-wrap: wrap; row-gap: 8px; }
#simBox .card-row > b, #botSimBox .card-row > b { flex: 1 1 100%; }
#simBox .card-row > div, #botSimBox .card-row > div {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
#simBox .card-row .btn-sm, #botSimBox .card-row .btn-sm { flex: none; }

/* 차트 시뮬레이션 상태 */
.sim-status { display: flex; gap: 8px; flex-wrap: wrap; }
.sim-stat {
  background: var(--gray-1);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.sim-stat span { color: var(--gray-6); font-size: 11px; }

/* 과적합 검증 비교 */
.val-compare { display: flex; gap: 10px; }
.val-col {
  flex: 1;
  background: var(--gray-1);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.val-col .num { font-size: 20px; font-weight: 800; margin: 6px 0 4px; }
.val-col p { font-size: 11px; }

.filter-row { margin-top: 8px; }
.filter-label { font-size: 12px; color: var(--gray-6); font-weight: 700; }
.mini-sort {
  padding: 8px 12px;
  border: 1.5px solid var(--gray-3);
  border-radius: 10px;
  font-size: 13px;
  background: var(--white);
}

.up { color: var(--red); }
.down { color: var(--blue); }

/* 하단 네비게이션 */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--gray-3);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--gray-6);
  text-decoration: none;
  font-weight: 600;
}
.nav-item.active { color: var(--ink); }
.nav-icon { font-size: 20px; }
.nav-cta .nav-icon {
  background: var(--yellow);
  border-radius: 50%;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  margin-top: -14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* PIN 패드 */
.pin-screen { display: flex; flex-direction: column; min-height: 80vh; justify-content: center; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 28px 0 40px; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--gray-3); transition: background 0.1s; }
.pin-dot.filled { background: var(--ink); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pin-key {
  padding: 18px;
  font-size: 22px;
  font-weight: 700;
  border: none;
  background: transparent;
  border-radius: 14px;
  cursor: pointer;
}
.pin-key:active { background: var(--gray-1); }

/* 위자드 */
.wizard-progress { display: flex; gap: 6px; margin-bottom: 24px; }
.wizard-progress .bar { flex: 1; height: 4px; border-radius: 2px; background: var(--gray-3); }
.wizard-progress .bar.done { background: var(--yellow-dark); }
.wizard-step { display: none; }
.wizard-step.active { display: block; }

.choice {
  border: 1.5px solid var(--gray-3);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  background: var(--white);
}
.choice.selected { border-color: var(--ink); background: var(--hl); }
.choice .name { font-weight: 700; margin-bottom: 3px; }
.choice .desc { font-size: 13px; color: var(--gray-6); line-height: 1.45; }

/* 리스트 */
.list-item { padding: 14px 0; border-bottom: 1px solid var(--gray-1); }
.list-item:last-child { border-bottom: none; }
.w-click { cursor: pointer; border-radius: 8px; transition: background 0.08s; }
.w-click:active { background: var(--gray-1); }

/* 탭 */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; }
.tab {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--white);
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-6);
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { background: var(--ink); color: var(--white); }

/* 토스트 */
#toast {
  position: fixed;
  bottom: 100px; left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 100;
  max-width: 90%;
  text-align: center;
}
#toast.show { opacity: 1; }

/* 맨 위로 가기 버튼 */
#scrollTopBtn {
  position: fixed; right: 16px; bottom: 84px; z-index: 80;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--white); color: var(--ink);
  border: 1.5px solid var(--gray-3);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  font-size: 20px; font-weight: 700; cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
#scrollTopBtn.show { opacity: 1; pointer-events: auto; }

/* 공통 확인·알림 다이얼로그 (네이티브 confirm/alert 대체) */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.dialog {
  background: var(--white); color: var(--ink);
  border-radius: 18px; padding: 22px 20px 16px;
  width: 100%; max-width: 360px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  animation: dialog-pop 0.15s ease;
}
@keyframes dialog-pop { from { transform: scale(0.96); opacity: 0.5; } to { transform: none; opacity: 1; } }
.dialog-title { font-weight: 800; font-size: 17px; margin-bottom: 8px; }
.dialog-msg { color: var(--gray-6); font-size: 14px; line-height: 1.6; margin-bottom: 18px; white-space: pre-line; }
.dialog-actions { display: flex; gap: 8px; }
.dialog-btn { flex: 1; padding: 13px; font-size: 15px; }

/* 바텀시트 모달 (긴 화면 대신 결과를 오버레이로) */
.sheet-modal {
  position: fixed; inset: 0; z-index: 95;
  background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-modal .sheet-panel {
  background: var(--gray-1); width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 8px 16px 24px;
  animation: sheet-up 0.2s ease;
}
@keyframes sheet-up { from { transform: translateY(30px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-head {
  position: sticky; top: 0; background: var(--gray-1); z-index: 1;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; margin-bottom: 4px;
}
.sheet-head b { font-size: 16px; }
.sheet-x { background: none; border: none; font-size: 20px; color: var(--gray-6); cursor: pointer; padding: 4px 8px; }

/* 위젯 대시보드는 PC 전용 — 모바일 폭에서는 메뉴에서 숨긴다 */
@media (max-width: 999px) { .pc-only { display: none !important; } }

/* 마우스 포인터 환경에서만 hover 피드백 — 터치에서 sticky-hover 방지 */
@media (hover: hover) and (pointer: fine) {
  .card.tap:hover,
  .w-click:hover,
  .stat.tap:hover,
  .list-item.w-click:hover { background: var(--gray-1); }
  .card.tap:hover { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); }
}

/* PC 전폭 화면: 모바일 하단바를 감추고, 목록형 화면은 폭을 넓혀 그리드로.
   (대시보드 드로어는 500px라 여기 안 걸림 — 전체 페이지 이동 시에만 적용) */
@media (min-width: 1000px) {
  .bottom-nav { display: none; }
  .app-header ~ .app { padding-bottom: 40px; }
  .app.wide { max-width: 1080px; }
  .app.wide .grid-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px; align-items: start;
  }
  .app.wide .grid-list .card { margin-bottom: 0; }
  .app.wide .grid-list .more-btn { grid-column: 1 / -1; }

  /* 설정: 섹션 묶음을 2열 메이슨리로 — 접힌 기본 상태에서 높이 균형이 좋다 */
  .app.wide .settings-cols { column-count: 2; column-gap: 20px; }
  .app.wide .settings-cols > .card,
  .app.wide .settings-cols > .acc { break-inside: avoid; }
  .app.wide .settings-cols > h2 { break-after: avoid; }
  .app.wide .settings-cols > h2:first-child { margin-top: 0; }

  /* 종목 상세: 백테스트 설정(좌)·결과(우) 2단 워크스페이스 */
  .app.wide .bt-cols {
    display: grid;
    grid-template-columns: minmax(340px, 380px) minmax(0, 1fr);
    gap: 16px; align-items: start;
  }
  .app.wide .bt-cols > .card { margin-bottom: 0; }

  /* PC 상시 사이드바 — 로그인 상태의 전체 페이지 이동 화면에서 LNB를 고정 노출.
     대시보드(별도 .dash-body)·드로어 임베드(.embed)·로그인 전(has-nav 없음)은 제외. */
  html:not(.embed) body.has-nav .lnb {
    left: 0; width: 240px; max-width: 240px;
    transition: none;
    box-shadow: none; border-right: 1px solid var(--gray-3);
  }
  html:not(.embed) body.has-nav .lnb-btn,
  html:not(.embed) body.has-nav .lnb-close { display: none; }
  html:not(.embed) body.has-nav .lnb-backdrop { display: none !important; }
  /* 헤더·본문을 사이드바 폭만큼 오른쪽으로 (헤더는 우측 전폭으로 정렬) */
  html:not(.embed) body.has-nav { padding-left: 240px; }
  html:not(.embed) body.has-nav .app-header {
    left: 240px; right: 0; max-width: none; margin: 0;
  }
}

/* 장 운영 상태 배너 */
.status-banner {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; padding: 10px 14px;
  background: var(--badge-on-bg); color: var(--badge-on-fg);
  border-radius: 12px; font-size: 13px;
}
.status-banner.closed { background: var(--gray-1); color: var(--gray-6); }
.status-banner .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; opacity: 0.7; }
.status-banner b { font-weight: 700; }
.status-banner .muted { margin-left: auto; }

.stat-row { display: flex; gap: 10px; }
.stat {
  flex: 1;
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat .num { font-size: 20px; font-weight: 800; }
.stat .lbl { font-size: 12px; color: var(--gray-6); margin-top: 2px; }

/* 툴팁 (ⓘ 아이콘 — 탭/호버로 설명 표시) */
.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--gray-3);
  color: var(--gray-9);
  font-size: 10px;
  font-weight: 800;
  cursor: help;
  vertical-align: middle;
  margin-left: 4px;
  user-select: none;
}
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 140%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(25, 25, 25, 0.94);
  color: #f4f4f6;  /* 배경이 항상 어두우므로 밝게 고정 (다크모드에서 --white 가 어두워지는 문제 방지) */
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  padding: 9px 12px;
  border-radius: 10px;
  width: max-content;
  max-width: 230px;
  white-space: normal;
  text-align: left;
  display: none;
  z-index: 60;
}
.tip:hover::after, .tip.show::after { display: block; }

/* 아코디언 (details 기반 펼치기 메뉴) */
details.acc {
  background: var(--white);
  border-radius: var(--radius);
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
details.acc > summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 20px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after {
  content: "⌄";
  color: var(--gray-6);
  font-size: 16px;
  transition: transform 0.15s;
}
details.acc[open] > summary::after { transform: rotate(180deg); }
details.acc > .acc-body { padding: 0 20px 20px; }
details.acc summary .muted { font-weight: 400; }

/* 선택 칩 (프리셋/수량) */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
/* 한 줄 가로 스크롤 칩 (관심·최근처럼 개수가 많은 목록의 세로 폭 절약) */
.chips-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.chips-row .chip { flex: 0 0 auto; white-space: nowrap; }
.chip {
  padding: 9px 14px;
  border: 1.5px solid var(--gray-3);
  border-radius: 999px;
  background: var(--white);
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-9);
  cursor: pointer;
}
.chip.selected { border-color: var(--yellow-dark); background: var(--yellow); color: #191919; }
.chip-desc { font-size: 12px; color: var(--gray-6); line-height: 1.5; min-height: 18px; }

/* 차트 */
.chart-tip {
  display: none;
  position: absolute;
  top: 8px;
  background: rgba(25, 25, 25, 0.92);
  /* 배경이 항상 어두우므로 글자는 테마와 무관하게 밝게 고정
     (--white 는 다크모드에서 카드색#26262b 로 바뀌어 어두운 글자가 돼 안 보였음) */
  color: #f4f4f6;
  font-size: 11px;
  line-height: 1.5;
  padding: 8px 10px;
  border-radius: 8px;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}
.legend { display: flex; gap: 14px; margin: 8px 0 4px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--gray-6); font-weight: 600; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* 드로어(iframe) 임베드 모드: 하단 네비 없이 콘텐츠만 */
.embed .bottom-nav { display: none; }
.embed .app { padding-bottom: 24px; }
.embed .lnb-btn { display: none; }

/* 고정 헤더 (바디와 분리) */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  height: 56px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px 0 20px;
  z-index: 72;
}
.app-title { font-size: 17px; font-weight: 800; }
.hdr-actions { display: flex; gap: 6px; }
.embed .app-header { display: none; }

/* 상단 알림 벨 + 알림 패널 */
.bell-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: transparent;
  font-size: 17px;
  cursor: pointer;
}
.bell-btn:active { background: var(--gray-1); }
.bell-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--red);
  color: var(--white);
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notif-panel {
  position: fixed;
  top: 62px;
  right: 16px;
  left: 16px;
  max-width: 400px;
  margin-left: auto;
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.2);
  z-index: 82;
  overflow: hidden;
}
.notif-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-1);
  font-size: 14px;
}
.notif-head a { color: var(--gray-6); text-decoration: none; font-size: 13px; font-weight: 700; }
.notif-item { padding: 11px 16px; border-bottom: 1px solid var(--gray-1); font-size: 13px; }
.notif-item:last-child { border-bottom: none; }
.notif-item .nt { font-weight: 700; }
.notif-item .nb { color: var(--gray-6); font-size: 12px; margin-top: 2px; }
.notif-item .nts { color: var(--gray-6); font-size: 11px; float: right; }
.notif-item.unread { background: var(--hl); }
.embed .bell-btn, .embed .notif-panel { display: none; }

/* 좌측 LNB (펼침 메뉴) — 모바일·PC 공용 */
.lnb-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: transparent;
  font-size: 19px;
  cursor: pointer;
}
.lnb-btn:active { background: var(--gray-1); }
.lnb-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.32); z-index: 94; }
.lnb {
  position: fixed;
  top: 0;
  bottom: 0; /* 100vh 대신 top/bottom 고정 — 모바일 주소창에서도 위아래 꽉 참 */
  left: -300px;
  width: 280px;
  max-width: 82vw;
  background: var(--white);
  z-index: 96;
  transition: left 0.22s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 6px 0 24px rgba(0, 0, 0, 0.15);
  padding-bottom: env(safe-area-inset-bottom);
}
.lnb.open { left: 0; }
.lnb-menu { flex: 1; overflow-y: auto; }
.lnb-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  font-weight: 800;
  font-size: 16px;
  border-bottom: 1px solid var(--gray-3);
}
.lnb-close { border: none; background: none; font-size: 22px; color: var(--gray-6); cursor: pointer; line-height: 1; }
.lnb-menu a, .lnb a {
  display: block;
  padding: 15px 20px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  border-bottom: 1px solid var(--gray-1);
}
.lnb a:active, .lnb a:hover { background: var(--gray-1); }
.lnb a.active { background: var(--hl); }
.lnb .lnb-user { padding: 14px 20px; color: var(--gray-6); font-size: 13px; margin-top: auto; border-top: 1px solid var(--gray-1); }

.muted { color: var(--gray-6); font-size: 13px; }
.mt { margin-top: 16px; }
.hidden { display: none !important; }

/* 데이터 미리받기 전역 진행 pill — 어느 화면에서든 진행 상태가 보인다 (탭하면 설정) */
.pf-pill {
  position: fixed;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(440px, calc(100% - 32px));
  background: var(--yellow);
  color: #191919;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  z-index: 71;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.embed .pf-pill { display: none; }
