.viz-root {
    color-scheme: light;
    --surface-1: #fcfcfb;
    --plane: #f9f9f7;
    --text-primary: #0b0b0b;
    --text-secondary: #52514e;
    --muted: #898781;
    --grid: #e1e0d9;
    --axis: #c3c2b7;
    --border: rgba(11, 11, 11, 0.10);
    --s1: #2a78d6;
    --s2: #eb6834;
    --s3: #1baf7a;
    --s4: #a78bfa;
    --s5: #e0b83a;
    --s6: #ec4899;
    /* 전략 비교용 — 4개 이상 겹칠 때 쓴다 */
    --s4: #8b5cf6;
    --s5: #d4a017;
    --s6: #db2777;
    --critical: #d03b3b;
    --warning: #fab219;
    --good: #0ca30c;
    --seq-100: #cde2fb; --seq-250: #86b6ef; --seq-400: #3987e5;
    --seq-550: #1c5cab; --seq-700: #0d366b;
    --neg-1: #f6d8d8; --neg-2: #e8a5a5;
    --hm-fg-lo: #0b0b0b; --hm-fg-hi: #ffffff;
  }
  @media (prefers-color-scheme: dark) {
    :root:where(:not([data-theme=light])) .viz-root {
      color-scheme: dark;
      --surface-1: #1a1a19;
      --plane: #0d0d0d;
      --text-primary: #ffffff;
      --text-secondary: #c3c2b7;
      --muted: #898781;
      --grid: #2c2c2a;
      --axis: #383835;
      --border: rgba(255, 255, 255, 0.10);
      --s1: #3987e5;
      --s2: #d95926;
      --s3: #199e70;
      --s4: #a78bfa;
      --s5: #e0b83a;
      --s6: #ec4899;
      --seq-100: #0d366b; --seq-250: #184f95; --seq-400: #2a78d6;
      --seq-550: #6da7ec; --seq-700: #cde2fb;
      --neg-1: #4a2020; --neg-2: #8a3535;
      --hm-fg-lo: #ffffff; --hm-fg-hi: #0b0b0b;
    }
  }
  :root[data-theme=dark] .viz-root {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #a78bfa;
    --s5: #e0b83a;
    --s6: #ec4899;
    --seq-100: #0d366b; --seq-250: #184f95; --seq-400: #2a78d6;
    --seq-550: #6da7ec; --seq-700: #cde2fb;
    --neg-1: #4a2020; --neg-2: #8a3535;
    --hm-fg-lo: #ffffff; --hm-fg-hi: #0b0b0b;
  }

  .viz-root {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--plane);
    color: var(--text-primary);
    line-height: 1.5;
    padding: 32px 20px 64px;
    max-width: 1180px;
    margin: 0 auto;
    -webkit-font-smoothing: antialiased;
  }
  .viz-root * { box-sizing: border-box; }

  h1 { font-size: 26px; font-weight: 640; margin: 0 0 6px; letter-spacing: -0.02em; }
  .sub { color: var(--text-secondary); font-size: 14px; margin: 0 0 4px; }
  .meta-line { color: var(--muted); font-size: 12.5px; margin: 0 0 28px; }

  h2 {
    font-size: 12px; font-weight: 660; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--muted);
    margin: 40px 0 14px; padding-bottom: 8px;
    border-bottom: 1px solid var(--grid);
  }
  h2:first-of-type { margin-top: 32px; }

  .card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
  }
  .card-title { font-size: 15px; font-weight: 620; margin: 0 0 3px; }
  .card-note { font-size: 12.5px; color: var(--text-secondary); margin: 0 0 16px; }
  /* 데이터 한계 안내 — 결과가 틀린 건 아니지만 해석에 단서가 붙는 경우 */
  /* 금액은 숫자 중간에서 줄바꿈되면 안 된다 (₩49,572,4 / 32 처럼 쪼개짐).
     대신 원화 억 단위처럼 길어지면 글자를 줄여 한 줄에 담는다 — 잘리면 값이 틀려 보인다. */
  .tile-value, .tile-sub { overflow-wrap: normal; word-break: keep-all; }
  .tile-value { white-space: nowrap; font-variant-numeric: tabular-nums; }

  /* 기준선 이름(매수·매도)은 선 오른쪽 끝에 — y축은 값을 쓴다.
     fill은 선 색을 그대로 쓰므로 여기서 지정하지 않는다(덮어쓰면 회색이 된다). */
  .guide-name { font-size: 10px; font-weight: 620; }

  /* 지표 보조 차트 — 성과 그래프 아래 같은 x축으로 붙는다 */
  .chart-wrap.ind-pane { margin-top: 2px; margin-bottom: 10px; }
  .chart-wrap.ind-pane svg { display: block; }

  /* 스크리닝 — 종목 행 클릭으로 상세 보기 */
  tr.srow { cursor: pointer; }
  tr.srow:hover td { background: var(--surface-2); }
  tr.srow.sel td { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--s1); }
  tr.srow:focus-visible { outline: 2px solid var(--s1); outline-offset: -2px; }
  .detail-card .card-title { display: flex; align-items: center; gap: 8px; }
  .detail-card .card-title .btn-sm { margin-left: auto; margin-top: 0; }

  /* 스크리닝 — 범위 입력(최소 ~ 최대) */
  .range-in { display: inline-flex; align-items: center; gap: 5px; }
  .range-in input { width: 72px; }
  .range-in i { font-style: normal; color: var(--muted); font-size: 12px; }
  th.sortable { cursor: pointer; user-select: none; }
  th.sortable:hover { color: var(--text-primary); }
  th.sorted::after { content: " ▾"; color: var(--s1); }
  th.sorted.asc::after { content: " ▴"; }

  /* 내재가치 민감도 격자 */
  .tbl.sens th:first-child { text-align: right; color: var(--muted); font-weight: 600; }
  .tbl.sens td { font-variant-numeric: tabular-nums; }
  /* 가운데(현재 가정) 열·행을 옅게 강조 */
  .tbl.sens tbody tr:nth-child(3) td,
  .tbl.sens tbody td:nth-child(4) { background: var(--surface-2); }

  /* 운용 — 저장된 정책 고르기 */
  .policy-pick { display: flex; gap: 8px; align-items: center; }
  .policy-pick select { flex: 1; min-width: 0; }
  .policy-pick .btn-sm { margin-top: 0; flex: none; }

  /* 매매 내역 행 선택 -> 차트에 위치 표시 */
  tr.trow { cursor: pointer; }
  tr.trow:hover td { background: var(--surface-2); }
  tr.trow.sel td {
    background: var(--surface-2);
    box-shadow: inset 2px 0 0 var(--text-primary);
  }
  tr.trow:focus-visible { outline: 2px solid var(--s1); outline-offset: -2px; }
  .sel-tag { font-size: 10.5px; font-weight: 620; }

  /* 차트 기간 드래그 */
  .chart-wrap svg { cursor: crosshair; }
  .range-band { pointer-events: none; }
  .range-chip {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 6px;
    padding: 3px 6px 3px 9px; border-radius: 999px;
    background: var(--surface-2); border: 1px solid var(--border);
    font-size: 11.5px; color: var(--text-secondary); white-space: nowrap;
  }
  .range-chip button {
    all: unset; cursor: pointer; padding: 0 4px; border-radius: 999px;
    color: var(--muted); font-size: 12px; line-height: 1;
  }
  .range-chip button:hover { color: var(--text-primary); background: var(--surface-1); }

  /* 시작~끝 날짜 직접 입력 — 프리셋 세그먼트 옆에 놓인다 */
  .date-range { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; }
  .date-range input[type="date"] {
    font: inherit; font-size: 12px; padding: 4px 6px;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--plane); color: var(--text-primary);
    font-variant-numeric: tabular-nums;
  }
  .date-range input[type="date"]:focus {
    outline: none; border-color: var(--s2);
  }
  .date-sep { color: var(--muted); font-size: 12px; }

  .card-note.warn {
    color: var(--text-primary); background: var(--warn-bg, rgba(180,120,20,.10));
    border-left: 2px solid var(--warn, #b47814);
    padding: 8px 10px; border-radius: 4px; margin-bottom: 12px;
  }

  /* ---- verdict hero ---- */
  .verdict {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-left: 3px solid var(--critical);
    border-radius: 12px;
    padding: 24px 26px;
    margin-bottom: 16px;
  }
  .verdict-eyebrow {
    font-size: 11.5px; font-weight: 660; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--critical); margin-bottom: 10px;
  }
  .verdict h3 { font-size: 20px; font-weight: 640; margin: 0 0 10px; letter-spacing: -0.01em; }
  .verdict p { font-size: 14px; color: var(--text-secondary); margin: 0; max-width: 78ch; }
  .verdict p + p { margin-top: 9px; }
  .verdict strong { color: var(--text-primary); font-weight: 620; }

  .tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; margin-bottom: 16px; }
  .tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px;
          container-type: inline-size; }
  .tile-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 7px; }
  /* 원화 억 단위처럼 긴 값은 타일 폭에 맞춰 줄인다(잘리면 값이 틀려 보인다) */
  .tile-value { font-size: clamp(17px, 8cqw, 30px); font-weight: 640; letter-spacing: -0.02em; line-height: 1.1; }
  .tile-sub { font-size: 12px; color: var(--muted); margin-top: 5px; }

  /* ---- controls ---- */
  .filters {
    display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-end;
    background: var(--surface-1); border: 1px solid var(--border);
    border-radius: 12px; padding: 14px 18px; margin-bottom: 18px;
  }
  .fgroup { display: flex; flex-direction: column; gap: 6px; }
  .fgroup > span { font-size: 11px; font-weight: 620; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
  .seg { display: flex; gap: 2px; background: var(--plane); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
  .seg button {
    font: inherit; font-size: 12.5px; font-weight: 550;
    padding: 5px 11px; border: 0; border-radius: 6px; cursor: pointer;
    background: transparent; color: var(--text-secondary); white-space: nowrap;
  }
  .seg button:hover { background: var(--grid); color: var(--text-primary); }
  .seg button[aria-pressed=true] { background: var(--s1); color: #fff; }
  select {
    font: inherit; font-size: 13px; padding: 6px 10px;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--plane); color: var(--text-primary); cursor: pointer;
  }

  /* ---- chart ---- */
  .chart-wrap { position: relative; width: 100%; overflow-x: auto; }
  /* width:100% + height:auto 는 viewBox 비율대로 늘어나므로, 가로로 넓은 화면에서
     작은 차트가 과도하게 커진다. 래퍼에 최대 폭을 걸어 원래 비율을 유지한다. */
  svg { display: block; width: 100%; height: auto; }
  .chart-wrap.cap-sm { max-width: 560px; }
  .chart-wrap.cap-md { max-width: 780px; }
  .grid-line { stroke: var(--grid); stroke-width: 1; }
  .axis-line { stroke: var(--axis); stroke-width: 1; }
  .tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
  .alab { font-size: 11.5px; fill: var(--text-secondary); }
  .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
  .dlabel { font-size: 11.5px; font-weight: 620; fill: var(--text-primary); }

  .legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 14px 0 2px; }
  .lg { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-secondary); }
  .lg i { width: 13px; height: 3px; border-radius: 2px; flex: none; }
  .lg.dotk i { width: 10px; height: 10px; border-radius: 50%; }

  /* ---- tooltip ---- */
  .tip {
    position: absolute; pointer-events: none; opacity: 0; transition: opacity .1s;
    /* 배경을 살짝 비친다 — 툴팁이 차트 위에 뜨는 구조라 완전 불투명이면
       가려진 구간이 안 보인다("포인트 값이 그래프를 가린다"는 제보).
       blur를 함께 걸어 글자 대비는 유지한다. */
    background: color-mix(in oklab, var(--surface-1) 88%, transparent);
    backdrop-filter: blur(3px);
    border: 1px solid var(--border);
    border-radius: 9px; padding: 9px 11px; font-size: 12.5px;
    box-shadow: 0 4px 16px rgba(0,0,0,.13); z-index: 20; min-width: 150px;
  }
  .tip-h { font-weight: 620; margin-bottom: 6px; font-size: 12px; color: var(--text-secondary); }
  .tip-r { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
  .tip-r i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
  .tip-r b { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 620; }

  /* ---- table ---- */
  .tbl-wrap { overflow-x: auto; }
  table { border-collapse: collapse; width: 100%; font-size: 13px; }
  th, td { padding: 8px 10px; text-align: right; white-space: nowrap; }
  th {
    font-size: 11px; font-weight: 620; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--muted); border-bottom: 1px solid var(--axis); text-align: right;
  }
  th:first-child, td:first-child { text-align: left; }
  td { border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
  tbody tr:hover { background: var(--plane); }
  tr.is-bh td { font-weight: 640; background: color-mix(in srgb, var(--s1) 7%, transparent); }
  tr.is-bh td:first-child { box-shadow: inset 2px 0 0 var(--s1); }
  .win { color: var(--good); font-weight: 620; }
  .lose { color: var(--critical); font-weight: 620; }
  .nm { display: inline-flex; align-items: center; gap: 7px; }
  .nm i { width: 9px; height: 9px; border-radius: 50%; flex: none; }

  .toggle-tbl {
    font: inherit; font-size: 12px; font-weight: 560; cursor: pointer;
    background: transparent; border: 1px solid var(--border); border-radius: 7px;
    padding: 5px 11px; color: var(--text-secondary); margin-top: 14px;
  }
  .toggle-tbl:hover { background: var(--plane); color: var(--text-primary); }

  /* ---- heatmap ---- */
  .hm { border-collapse: separate; border-spacing: 2px; font-size: 12.5px; width: auto; }
  .hm td, .hm th { padding: 0; width: 78px; }
  .hm th { font-size: 11px; color: var(--muted); font-weight: 600; padding: 4px 6px; text-align: center; }
  .hm th.rh { text-align: right; padding-right: 9px; width: 62px; }
  .hm .cell {
    width: 78px; height: 40px; border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    font-variant-numeric: tabular-nums; font-weight: 620; cursor: default;
    transition: transform .08s;
  }
  .hm .cell:hover { transform: scale(1.06); }
  .hm .cell.na { background: var(--plane); color: var(--muted); font-weight: 500; font-size: 11.5px; border: 1px dashed var(--axis); }

  .scale-key { display: flex; align-items: center; gap: 9px; margin-top: 14px; font-size: 12px; color: var(--text-secondary); }
  .scale-key .bar { display: flex; border-radius: 3px; overflow: hidden; }
  .scale-key .bar span { width: 26px; height: 11px; }

  .note {
    font-size: 12.5px; color: var(--text-secondary);
    background: var(--plane); border-left: 2px solid var(--axis);
    padding: 11px 14px; border-radius: 0 8px 8px 0; margin-top: 16px;
  }
  .note strong { color: var(--text-primary); font-weight: 620; }

  .two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  @media (max-width: 860px) { .two { grid-template-columns: 1fr; } }

  .footer { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--grid); font-size: 12.5px; color: var(--muted); }
  .footer code { background: var(--plane); padding: 1.5px 5px; border-radius: 4px; font-size: 12px; }
  .footer p { margin: 0 0 7px; }
  .loading { padding: 60px 0; text-align: center; color: var(--muted); font-size: 14px; }
  .err { padding: 20px; border-radius: 10px; background: var(--plane); border-left: 3px solid var(--critical); font-size: 13.5px; }

/* ==================================================== 콘솔 셸
   좌측 고정 사이드바 + 상단바. 가로 탭은 항목이 늘면 화면 밖으로 밀려
   "메뉴가 없는 것처럼" 보인다 — 실제로 설정 탭을 못 찾는 일이 있었다.
   사이드바는 모든 목적지가 항상 보이고, 늘어나도 세로로 쌓인다. */

/* 셸을 쓰면 본문 폭 제한을 콘텐츠 쪽으로 옮긴다 */
.viz-root:has(.shell) { max-width: none; padding: 0; }
/* 푸터는 셸 밖이라 사이드바 폭만큼 들여쓴다(본문과 좌측을 맞춘다) */
.viz-root:has(.shell) > .footer {
  max-width: 1180px; margin-left: 232px; padding: 0 24px 48px;
}
@media (max-width: 900px) {
  .viz-root:has(.shell) > .footer { margin-left: 0; padding: 0 14px 40px; }
}

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 16px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.brand { font-size: 14.5px; font-weight: 650; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.brand-mark { color: var(--s1); font-size: 15px; }
.topbar-sp { flex: 1; }
.topbar-meta, .topbar-user { display: flex; align-items: center; gap: 8px; }

.pill {
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: var(--plane); border: 1px solid var(--border); color: var(--muted);
  white-space: nowrap;
}
.pill.on { color: var(--good); border-color: color-mix(in oklab, var(--good) 40%, transparent); }
.pill.warn { color: var(--warning); border-color: color-mix(in oklab, var(--warning) 45%, transparent); }

.user-chip {
  display: flex; align-items: center; gap: 7px;
  font: inherit; font-size: 12.5px; color: var(--text-secondary);
  padding: 4px 10px 4px 4px; border-radius: 999px;
  background: var(--plane); border: 1px solid var(--border); cursor: pointer;
}
.user-chip:hover { color: var(--text-primary); border-color: var(--axis); }
.avatar {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--s1); color: #fff; font-size: 11px; font-weight: 700;
}
.user-mail { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- 셸 레이아웃 ---- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); align-items: start; }
.shell-main { min-width: 0; padding: 22px 24px 64px; max-width: 1180px; }

.sidenav {
  position: sticky; top: 52px; align-self: start;
  height: calc(100vh - 52px); overflow-y: auto; overscroll-behavior: contain;
  padding: 14px 10px 28px;
  border-right: 1px solid var(--border); background: var(--surface-1);
}
/* 스크롤 영역 + 하단 고정 — 설정은 항상 같은 자리에 있어야 찾기 쉽다 */
.sidenav { display: flex; flex-direction: column; padding: 0; }
.nav-scroll { flex: 1; overflow-y: auto; padding: 8px 10px 12px; }
.nav-foot { border-top: 1px solid var(--border); padding: 8px 10px 14px; }
.nav-foot .nav-group-title { padding-top: 6px; }

.nav-group + .nav-group { margin-top: 4px; }
.nav-group-title {
  font-size: 10.5px; font-weight: 680; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  font: inherit; font-size: 13.5px; font-weight: 500;
  padding: 7px 10px; margin-bottom: 1px;
  border: 0; border-radius: 7px; background: transparent;
  color: var(--text-secondary); cursor: pointer; text-align: left;
}
.nav-item:hover { background: var(--plane); color: var(--text-primary); }
.nav-item[aria-selected=true] {
  background: var(--plane); color: var(--text-primary); font-weight: 620;
  box-shadow: inset 2px 0 0 var(--s1);
}
.nav-item:focus-visible { outline: 2px solid var(--s1); outline-offset: -2px; }
.nav-ico {
  width: 17px; flex: none; text-align: center; font-size: 13px;
  opacity: .75; line-height: 1;
}
.nav-item[aria-selected=true] .nav-ico { opacity: 1; }

/* 상단바 접기 버튼 */
.rail-toggle {
  font: inherit; font-size: 13px; line-height: 1;
  width: 26px; height: 26px; flex: none; border-radius: 6px;
  border: 1px solid var(--border); background: var(--plane);
  color: var(--muted); cursor: pointer;
}
.rail-toggle:hover { color: var(--text-primary); border-color: var(--axis); }

/* 접힌 상태(rail) — 아이콘만 남긴다. 라벨은 title 툴팁으로 본다. */
@media (min-width: 901px) {
  .rail .shell { grid-template-columns: 56px minmax(0, 1fr); }
  .rail .nav-item-name, .rail .nav-group-title { display: none; }
  .rail .nav-item { justify-content: center; padding: 9px 0; gap: 0; }
  .rail .nav-ico { width: auto; font-size: 15px; }
  .rail .nav-group + .nav-group {
    margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border);
  }
  .rail .viz-root:has(.shell) > .footer,
  .viz-root:has(.rail) > .footer { margin-left: 56px; }
}

/* ---- 빵부스러기 ---- */
.crumb {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin-bottom: 18px; font-size: 12.5px; color: var(--muted);
}
.crumb-sec { font-weight: 600; }
.crumb-sep { opacity: .5; }
.crumb-cur { font-size: 19px; font-weight: 640; color: var(--text-primary);
  letter-spacing: -0.01em; }
.crumb-desc { flex-basis: 100%; color: var(--muted); }

/* ---- 모바일 서랍 ---- */
.nav-toggle { display: none; }
.nav-scrim { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle {
    display: grid; place-items: center; width: 32px; height: 32px; flex: none;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--plane); cursor: pointer;
  }
  .nav-burger, .nav-burger::before, .nav-burger::after {
    display: block; width: 14px; height: 1.5px; background: var(--text-primary);
    border-radius: 2px; content: "";
  }
  .nav-burger { position: relative; }
  .nav-burger::before { position: absolute; top: -4.5px; }
  .nav-burger::after { position: absolute; top: 4.5px; }

  .sidenav {
    position: fixed; top: 52px; left: 0; bottom: 0; width: 250px; z-index: 45;
    height: auto; transform: translateX(-100%);
    transition: transform .18s ease;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
  }
  .nav-open .sidenav { transform: none; }
  .nav-scrim {
    display: block; position: fixed; inset: 52px 0 0 0; z-index: 44;
    background: rgba(0,0,0,.38);
  }
  .nav-scrim[hidden] { display: none; }
  .shell-main { padding: 16px 14px 56px; }
}
@media (prefers-reduced-motion: reduce) {
  .sidenav { transition: none; }
}

/* ============================================ 실험실 레이아웃 */
.lab-grid { display: grid; grid-template-columns: 296px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .lab-grid { grid-template-columns: 1fr; } }
.lab-side { position: sticky; top: 12px; }
@media (max-width: 900px) { .lab-side { position: static; } }
.side-card { padding: 18px; }
.side-block { margin-top: 16px; }
.side-block > .side-label {
  display: block; font-size: 11px; font-weight: 620; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); margin-bottom: 8px;
}
.side-block select { width: 100%; }
.strat-desc { font-size: 12px; color: var(--text-secondary); margin-top: 7px; line-height: 1.45; }
.side-actions { display: flex; gap: 8px; margin-top: 18px; }
.side-note { font-size: 11.5px; color: var(--muted); margin-top: 12px; font-variant-numeric: tabular-nums; }

.btn {
  font: inherit; font-size: 12.5px; font-weight: 560; cursor: pointer;
  padding: 7px 13px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--plane); color: var(--text-secondary);
}
.btn:hover { background: var(--grid); color: var(--text-primary); }
.btn-primary { background: var(--s1); color: #fff; border-color: transparent; }
.btn-primary:hover { background: var(--s1); filter: brightness(1.08); color: #fff; }
.btn-sm { font-size: 12px; padding: 5px 11px; margin-top: 14px; }

/* ------------------------------------------- 종목 직접 조회 (tickerPicker) */
.ticker-picker { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ticker-picker select { flex: 1 1 auto; min-width: 120px; }
.ticker-picker .ticker-input {
  flex: 1 1 100px; min-width: 90px; padding: 6px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--plane); color: var(--text-primary);
  font-size: 12.5px;
}
.ticker-picker .btn-sm { margin-top: 0; }
.ticker-picker-msg { flex-basis: 100%; font-size: 12px; color: var(--text-secondary); }
.ticker-picker-msg.err { color: var(--neg-2, #d9534f); }

/* ------------------------------------------- 파라미터 컨트롤 */
.params { display: flex; flex-direction: column; gap: 13px; }
.param label { display: block; }
.param-label { font-size: 12.5px; color: var(--text-secondary); display: block; margin-bottom: 5px; }
.param-input { display: flex; align-items: center; gap: 9px; }
.param-input input[type=range] {
  flex: 1; min-width: 0; accent-color: var(--s1); height: 18px; cursor: pointer;
}
.param-num {
  width: 62px; flex: none; font: inherit; font-size: 12.5px;
  padding: 4px 7px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--plane); color: var(--text-primary);
  font-variant-numeric: tabular-nums; text-align: right;
}
.param-help { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.assume-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.assume-row > span { font-size: 12.5px; color: var(--text-secondary); }
.assume-row .seg button { padding: 4px 9px; font-size: 12px; }

.tiles-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* ------------------------------------------------ 스윕 컨트롤 */
.sweep-controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.sweep-controls .fgroup { display: flex; flex-direction: column; gap: 6px; }
.sweep-controls .fgroup > span {
  font-size: 11px; font-weight: 620; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted);
}

/* ------------------------------------------------------ 리서치 */
.research-bar { display: flex; gap: 9px; margin-bottom: 16px; }
.research-input {
  flex: 1; font: inherit; font-size: 14px; padding: 9px 13px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--plane); color: var(--text-primary);
}
.research-input:focus { outline: 2px solid var(--s1); outline-offset: -1px; }
.empty-state {
  padding: 22px; border-radius: 10px; background: var(--plane);
  border: 1px dashed var(--axis);
}
.empty-title { font-size: 14px; font-weight: 620; margin-bottom: 9px; }
.empty-state p { font-size: 13px; color: var(--text-secondary); margin: 0 0 9px; line-height: 1.55; }
.empty-how { margin-top: 14px !important; font-size: 12.5px !important; }
.empty-note { font-size: 12px !important; color: var(--muted) !important; margin-top: 12px !important; }
.code-block {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  padding: 13px 15px; font-size: 12px; line-height: 1.55; overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-secondary); margin: 0 0 4px;
}
.code-inline {
  display: inline-block; margin-top: 8px; background: var(--surface-1);
  padding: 6px 10px; border-radius: 6px; font-size: 12px;
}
.empty-inline { font-size: 13px; color: var(--muted); padding: 10px 0; }
.muted-cell { color: var(--muted); font-size: 12px; }

.err-inline {
  font-size: 13px; color: var(--text-primary); background: var(--plane);
  border-left: 3px solid var(--warning); padding: 11px 14px; border-radius: 0 8px 8px 0;
}
.verdict-cta { margin-top: 12px !important; font-size: 13px !important; }

/* ------------------------------------------------ 리서치 (DART) */
.research-days {
  font: inherit; font-size: 13px; padding: 9px 11px; flex: none;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--plane); color: var(--text-primary); cursor: pointer;
}
.tag {
  display: inline-block; margin-left: 7px; padding: 1px 6px;
  font-size: 11px; border-radius: 4px; background: var(--grid);
  color: var(--text-secondary); vertical-align: middle; white-space: nowrap;
}
.tag-code { font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
#rqOut a { color: var(--s1); text-decoration: none; }
#rqOut a:hover { text-decoration: underline; }
.cand-list { display: flex; flex-direction: column; gap: 6px; }
.cand {
  display: flex; align-items: center; gap: 8px; width: 100%;
  font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
  padding: 10px 13px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--plane); color: var(--text-primary);
}
.cand:hover { background: var(--grid); }
.cand-name { flex: 1; }
.empty-state a { color: var(--s1); }

/* ============================================================ 모바일
   그리드/플렉스 자식은 기본 min-width:auto 라서 내용보다 작아지지 않는다.
   좁은 화면에서 가로 스크롤이 생기는 주원인이므로 min-width:0을 준다. */
.lab-grid > *, .lab-main > *, .tiles > *, .filters > *, .sweep-controls > * { min-width: 0; }
.card, .tile, .verdict, .side-card { overflow-wrap: anywhere; }

@media (max-width: 640px) {
  .viz-root { padding: 18px 12px 40px; }
  h1 { font-size: 20px; }
  .sub { font-size: 13px; }
  .meta-line { font-size: 11.5px; margin-bottom: 18px; }

  /* 내비: 가로 스크롤로 전환 (줄바꿈보다 손가락 조작에 낫다) */
  .globalnav, .subnav {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .globalnav::-webkit-scrollbar, .subnav::-webkit-scrollbar { display: none; }
  .globalnav button { flex: none; padding: 10px 14px; font-size: 14px; }
  .subnav button { flex: none; padding: 6px 11px; font-size: 12.5px; }

  .card, .verdict, .side-card { padding: 14px; border-radius: 10px; }
  .verdict h3 { font-size: 17px; }
  .verdict p, .card-note { font-size: 12.5px; }

  /* 타일 2열 — 1열은 너무 길어지고 4열은 좁다 */
  .tiles, .tiles-4 { grid-template-columns: 1fr 1fr; gap: 9px; }
  .tile { padding: 12px 13px; }
  .tile-value { font-size: 22px; }
  .tile-label, .tile-sub { font-size: 11px; }

  /* 컨트롤: 세로 스택 + 터치 타깃 확대 */
  .filters, .sweep-controls { flex-direction: column; align-items: stretch; gap: 12px; padding: 12px; }
  .filters .fgroup, .sweep-controls .fgroup { width: 100%; }
  select, .research-input, .research-days {
    width: 100%; font-size: 16px;   /* iOS는 16px 미만이면 포커스 시 확대된다 */
    padding: 10px 12px;
  }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 9px 8px; font-size: 13px; }

  /* 실험실 사이드바는 스티키 해제 (좁은 화면에선 자리만 차지) */
  .lab-side { position: static; }
  .param-input input[type=range] { height: 30px; }   /* 터치 타깃 */
  .param-num { width: 66px; font-size: 15px; padding: 6px 8px; }
  .assume-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .side-actions { flex-direction: column; }
  .side-actions .btn { width: 100%; padding: 11px; }

  /* 표: 가로 스크롤 (열을 줄이면 정보가 사라진다) */
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { font-size: 12px; }
  th, td { padding: 7px 8px; }

  /* 히트맵 셀 축소 */
  .hm td, .hm th { width: 58px; }
  .hm .cell { width: 58px; height: 36px; font-size: 11.5px; }
  .hm th.rh { width: 52px; font-size: 10.5px; padding-right: 6px; }
  .scale-key { flex-wrap: wrap; gap: 6px; font-size: 11px; }
  .scale-key span[style] { margin-left: 0 !important; }

  /* 차트: 좁은 화면에서 폭 제한 해제 */
  .chart-wrap.cap-sm, .chart-wrap.cap-md { max-width: none; }
  .legend { gap: 10px; font-size: 11.5px; }

  /* 리서치 */
  .research-bar { flex-direction: column; gap: 8px; }
  .research-bar .btn { width: 100%; padding: 11px; }
  .cand { padding: 12px 13px; }

  .code-block { font-size: 11px; padding: 10px 11px; }
  .footer { font-size: 11.5px; }
  h2 { font-size: 11px; margin: 28px 0 12px; }
}

/* 아주 좁은 화면(≤380px): 타일 1열 */
@media (max-width: 380px) {
  .tiles, .tiles-4 { grid-template-columns: 1fr; }
}

/* ------------------------------------------- 시장 현황 / 차트 / 비교 */
.scan-tbl th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.scan-tbl th.sortable:hover { color: var(--text-primary); }
.scan-tbl th.on { color: var(--s1); }
.zone-hot { color: var(--critical); font-weight: 620; }
.zone-cold { color: var(--s1); font-weight: 620; }

/* 52주 위치 바 */
.rangebar {
  position: relative; width: 62px; height: 5px; border-radius: 3px;
  background: var(--grid); display: inline-block; vertical-align: middle;
}
.rangebar span {
  position: absolute; top: -3px; width: 3px; height: 11px; border-radius: 2px;
  background: var(--s1); transform: translateX(-50%);
}

/* 차트 오버레이 체크박스 */
.chk-row { display: flex; flex-wrap: wrap; gap: 10px; }
.chk {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 12.5px; color: var(--text-secondary); white-space: nowrap;
}
.chk input { accent-color: var(--s1); cursor: pointer; margin: 0; }
.chk i { width: 12px; height: 2.5px; border-radius: 2px; flex: none; }

.panel-label {
  font-size: 11px; font-weight: 620; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); margin: 14px 0 2px;
}
.tag-up { color: var(--good); }
.tag-down { color: var(--critical); }

@media (max-width: 640px) {
  .chk-row { gap: 8px 12px; }
  .chk { font-size: 12px; }
  .rangebar { width: 44px; }
  .scan-tbl th, .scan-tbl td { padding: 6px 7px; font-size: 11.5px; }
  .panel-label { margin-top: 10px; }
}

/* ------------------------------------------------ 국내 시장 (KIS) */
.watch-edit { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.watch-edit .research-input { flex: 1; max-width: 300px; font-size: 13px; padding: 8px 11px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--plane); }
tr.sel td { background: color-mix(in srgb, var(--s1) 9%, transparent); }
.spark { width: 100%; height: auto; max-width: 340px; }
.dtl-grid { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.dtl-spark { flex: 1; min-width: 220px; }
.dtl-stats { display: flex; gap: 22px; flex-wrap: wrap; }
.dstat { display: flex; flex-direction: column; gap: 3px; }
.dstat span { font-size: 11.5px; color: var(--muted); }
.dstat b { font-size: 17px; font-weight: 620; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .watch-edit { flex-wrap: wrap; }
  .watch-edit .research-input { max-width: none; width: 100%; }
  .dtl-grid { gap: 14px; }
  .dtl-stats { gap: 16px; }
}
/* 국내 시장 관례: 상승=빨강, 하락=파랑 (해외 화면의 win/lose와 반대) */
.kr-up { color: var(--critical); font-weight: 620; }
.kr-dn { color: var(--s1); font-weight: 620; }
.mkt-range { margin: 0 0 14px; }
.mkt-range .seg { display: inline-flex; }

/* ------------------------------------------------- 대기자산 배분 */
.alloc { display: flex; flex-direction: column; gap: 7px; }
.alloc-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.alloc-asset { flex: 1; min-width: 0; font-size: 12.5px; padding: 5px 8px; }
.alloc-w {
  width: 54px; flex: none; font: inherit; font-size: 12.5px; padding: 5px 7px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--plane); color: var(--text-primary);
  font-variant-numeric: tabular-nums; text-align: right;
}
.alloc-pct { font-size: 12px; color: var(--muted); }
.alloc-del {
  font: inherit; font-size: 12px; cursor: pointer; line-height: 1;
  background: transparent; border: 0; color: var(--muted); padding: 4px 5px;
}
.alloc-del:hover { color: var(--critical); }
.alloc-note { flex-basis: 100%; font-size: 11px; color: var(--muted); margin: -2px 0 2px; }
.alloc-foot { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 3px; }
.alloc-foot .btn-sm { margin-top: 0; }
.alloc-total { font-size: 11.5px; color: var(--muted); }
.alloc-total.warn { color: var(--warning); }
.note-warn { border-left-color: var(--warning); }
.alloc-rebal { display: flex; align-items: center; gap: 7px; margin-top: 2px; }
.alloc-rebal > span { font-size: 12px; color: var(--text-secondary); }
.alloc-rebal select { font-size: 12.5px; padding: 4px 7px; flex: 1; min-width: 0; }
.alloc-div { font-size: 11px; color: var(--muted); }

/* ---------------------------------------------------- 투자금 설정 */
.money-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.money-row > span { font-size: 12.5px; color: var(--text-secondary); flex: 1; min-width: 0; }
/* 사이드바(.money-row)뿐 아니라 필터 줄(.fgroup)에 놓인 금액 입력에도 적용된다 —
   전략비교는 세로 사이드바가 없어 필터 줄에 직접 넣는다 */
.money-row input,
.money-input input {
  width: 92px; flex: none; font: inherit; font-size: 12.5px; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--plane); color: var(--text-primary);
  font-variant-numeric: tabular-nums; text-align: right;
}
.money-help { flex-basis: 100%; font-size: 11px; color: var(--muted); margin-top: -3px; }
.money-input { position: relative; display: inline-flex; align-items: center; flex: none; }
.money-input i {
  position: absolute; left: 8px; font-style: normal; font-size: 12px;
  color: var(--muted); pointer-events: none;
}
/* 통화기호가 있을 때만 왼쪽 여백을 준다(단위 없음이면 빈 공간이 생긴다) */
.money-input:has(i) input { padding-left: 20px; }
/* %·배·년처럼 **뒤에** 붙는 단위 — 통화기호와 반대쪽에 둔다 */
.money-input.suffix i { left: auto; right: 8px; }
.money-input.suffix:has(i) input { padding-left: 8px; padding-right: 26px; }
.money-row select { flex: none; width: 92px; font-size: 12.5px; padding: 5px 7px; }
.money-row select.contrib-mode { width: 150px; }

/* ------------------------------------------------- 다자산 전략 */
.params-inline { margin-top: 14px; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 18px; }
.wbar { width: 100%; height: 7px; background: var(--grid); border-radius: 4px; overflow: hidden; }
.wbar span { display: block; height: 100%; background: var(--s2); border-radius: 4px; }
.custom-w { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-top: 8px; }
.cw-row { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-secondary); }
.cw-row span { flex: 1; font-weight: 600; color: var(--text-primary); }
.cw-row input { width: 58px; font: inherit; font-size: 12.5px; padding: 4px 7px; text-align: right;
  border: 1px solid var(--border); border-radius: 6px; background: var(--plane); color: var(--text-primary); }

/* ------------------------------------------------- 매매 마커 */
.trade-mark { cursor: pointer; }
.trade-mark:hover { opacity: 0.75; }
.mark-note { font-size: 12px; color: var(--muted); margin-top: 10px; }
.mk { font-size: 13px; margin-right: 2px; }
.mk-buy { color: var(--good); font-weight: 620; }
.mk-sell { color: var(--critical); font-weight: 620; }
.mk-dep { color: var(--s1); font-weight: 620; }
.trade-mark.deposit { opacity: 0.75; }

/* ------------------------------------------- 매매 마커 툴팁 */
.trade-hit { cursor: pointer; }
.trade-count {
  font-size: 9.5px; font-weight: 700; fill: var(--text-primary);
  paint-order: stroke; stroke: var(--surface-1); stroke-width: 2.5px;
  pointer-events: none;
}
/* 마커 툴팁은 크로스헤어 툴팁보다 넓게 — 여러 건을 나열하므로 */
.tip.tip-trade { min-width: 190px; max-width: 260px; z-index: 30; }
.tip-sub {
  font-size: 11.5px; color: var(--muted); margin: -1px 0 5px 16px;
  font-variant-numeric: tabular-nums;
}
.tip.tip-trade .tip-r { margin-top: 5px; }
.tip.tip-trade .tip-r span { font-size: 12px; }
.tip-div { height: 1px; background: var(--border); margin: 7px 0 5px; }
.tip-bd span { color: var(--text-secondary); }
.tip-nodot { background: transparent !important; }
.tip.tip-wide { min-width: 200px; }

/* ---------------------------------------------- 종목 분석 */
.stock-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.stock-title { display: flex; align-items: baseline; gap: 9px; }
.stock-title strong { font-size: 18px; font-weight: 640; }
.stock-quick { display: flex; gap: 18px; flex-wrap: wrap; margin-left: auto; }
.stock-quick span { display: flex; flex-direction: column; gap: 2px;
  font-size: 14px; font-weight: 620; font-variant-numeric: tabular-nums; }
.stock-quick i { font-style: normal; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* 종목 분석 내부 탭 — 콘솔의 세부 탭 */
.subtabs { display: flex; gap: 2px; flex-wrap: wrap; margin: 0 0 16px; }
.subtabs button {
  font: inherit; font-size: 13px; font-weight: 550; padding: 7px 12px;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  color: var(--text-secondary); cursor: pointer; white-space: nowrap;
}
.subtabs button:hover { background: var(--surface-1); color: var(--text-primary); }
.subtabs button[aria-selected=true] {
  background: var(--surface-1); border-color: var(--border);
  color: var(--s1); font-weight: 620;
}

/* 스타일 스코어 카드 */
.score-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin-top: 4px;
}
.score-card {
  background: var(--plane); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
}
.score-name { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.score-val { font-size: 24px; font-weight: 660; margin: 4px 0 8px;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.score-bar { height: 5px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.score-bar span { display: block; height: 100%; border-radius: 3px; background: var(--s1); }
.score-card.good .score-val { color: var(--good); }
.score-card.good .score-bar span { background: var(--good); }
.score-card.mid .score-val { color: var(--s1); }
.score-card.low .score-val { color: var(--warning); }
.score-card.low .score-bar span { background: var(--warning); }
.score-card.none .score-val { color: var(--muted); }

.hist-row { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: 12px; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--plane);
  color: var(--text-secondary); cursor: pointer;
}
.chip:hover { color: var(--text-primary); border-color: var(--axis); }

/* 내 종목 목록 칩 — 본문 클릭으로 선택, ×로 목록에서 제거 */
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip-row .chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 6px 3px 10px;
}
.chip-row .chip > span:first-child { cursor: pointer; }
.chip-x {
  all: unset; cursor: pointer; padding: 0 5px; border-radius: 999px;
  color: var(--muted); font-size: 13px; line-height: 1.6;
}
.chip-x:hover { color: var(--text-primary); background: var(--surface-1); }

.chart-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.chart-head strong { font-size: 20px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------- 레퍼런스 모델 */
.model-row { display: flex; gap: 6px; flex-wrap: wrap; }
.model-chip {
  font: inherit; font-size: 12.5px; font-weight: 560; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--plane); color: var(--text-secondary); cursor: pointer;
}
.model-chip:hover { color: var(--text-primary); border-color: var(--axis); }
.model-chip.on {
  background: var(--surface-2, var(--surface-1)); color: var(--s1);
  border-color: var(--s1); font-weight: 640;
}
.model-doc { margin-top: 12px; padding: 14px 16px; border-radius: 10px;
  background: var(--plane); border: 1px solid var(--border); }
.model-origin { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.model-doc dl { margin: 0; display: grid; grid-template-columns: 92px 1fr; gap: 8px 14px; }
.model-doc dt { font-size: 11.5px; font-weight: 660; color: var(--muted);
  text-transform: none; padding-top: 1px; }
.model-doc dd { margin: 0; font-size: 13px; color: var(--text-secondary); line-height: 1.55; }
@media (max-width: 640px) { .model-doc dl { grid-template-columns: 1fr; gap: 2px; }
  .model-doc dd { margin-bottom: 8px; } }

/* ---------------------------------------------- 말풍선 피드백 (오버레이) */
/* 플로팅 버튼 — 우하단 고정. z-index를 크게 잡는 이유: 차트 svg·표 헤더
   sticky 등 화면 곳곳에 자체 z-index를 쓰는 요소가 있어, 그 위에 항상
   떠 있으려면 확실히 큰 값이 필요하다. */
.fb-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 9000;
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-1); border: 1px solid var(--border);
  color: var(--text-primary); cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
}
.fb-fab:hover { filter: brightness(1.05); }
.fb-fab.on { background: var(--s1); color: #fff; border-color: transparent; }
.fb-fab .fb-icon { width: 22px; height: 22px; }
.fb-fab-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px;
  padding: 0 4px; border-radius: 999px; background: var(--critical); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* 모드 안내 바 — 상단 중앙에 고정, 모드가 켜진 동안만 존재 */
.fb-mode-bar {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 9000;
  background: var(--s1); color: #fff; font-size: 12.5px; font-weight: 600;
  padding: 7px 16px; border-radius: 999px; box-shadow: 0 4px 16px rgba(0,0,0,.2);
  pointer-events: none;
}

/* 모드일 때 문서 전체 크로스헤어 — 클릭 가능한 지점을 알려준다 */
body.fb-mode, body.fb-mode * { cursor: crosshair !important; }
body.fb-mode .fb-fab, body.fb-mode .fb-pop, body.fb-mode .fb-pop * { cursor: auto !important; }
body.fb-mode .fb-pop button, body.fb-mode .fb-fab { cursor: pointer !important; }

/* 앵커 클릭 시 짧은 하이라이트 — 앵커 요소의 레이아웃은 건드리지 않는다(외곽선만) */
.fb-highlight { outline: 2px solid var(--s1); outline-offset: 2px; transition: outline-color .3s; }

/* 피드백 모드에서 마우스를 올렸을 때 "클릭하면 여기가 앵커가 된다"를 미리
   보여주는 하이라이트. 실제 앵커(가장 하위 의미 요소) 기준이라, 카드
   전체가 아니라 표의 셀 하나·버튼 하나처럼 실제로 좁혀진 범위가 보인다. */
.fb-hover-preview {
  outline: 2px dashed var(--s1); outline-offset: 1px;
}

/* 마커 배지 — 앵커 요소 우상단에 절대배치. 앵커에 padding/size를 더하지
   않으므로 레이아웃은 그대로다. */
.fb-marker {
  position: absolute; top: -8px; right: -8px; z-index: 20;
  font: inherit; font-size: 11px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; gap: 3px;
  padding: 4px 6px; border-radius: 999px; pointer-events: auto;
  background: var(--surface-1); border: 1px solid var(--border);
  color: var(--text-primary); cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.fb-marker:hover { border-color: var(--s1); color: var(--s1); }
.fb-marker .fb-icon { width: 13px; height: 13px; }
.fb-marker-count { line-height: 1; }

/* 오버레이 배치 마커 — 표의 <td>/<tr>이나 너무 작은 요소는 자식으로 배지를
   못 넣으므로(레이아웃 파괴 위험), #tabPanel 기준 절대좌표로 "떠 있는"
   배지를 그린다(JS가 top/left를 px로 계산해 인라인 스타일로 지정). */
.fb-marker-overlay { position: absolute; top: 0; left: 0; }

/* 구조가 바뀌어 path 복원에 실패, 컨테이너로 근사 복원된 마커 — 점선
   테두리로 "정확한 위치가 아님"을 표시한다. */
.fb-marker-approx { border-style: dashed; }

/* 작성/스레드 팝오버 */
.fb-pop {
  position: fixed; z-index: 9500; width: 320px; max-width: calc(100vw - 16px);
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; box-shadow: 0 10px 32px rgba(0,0,0,.25);
  cursor: auto;
  /* 스크린샷 미리보기 등으로 내용이 늘어나면 팝오버 자체가 뷰포트보다
     커질 수 있다 — top만 보고 고정 배치하므로(positionPopover) 높이 제한이
     없으면 저장/취소 버튼이 화면 밖으로 밀려 아예 안 보이게 된다. */
  max-height: calc(100vh - 32px); overflow-y: auto;
}
.fb-pop-title { font-size: 13px; font-weight: 660; margin-bottom: 8px; }
.fb-text {
  width: 100%; min-height: 72px; resize: vertical; font: inherit; font-size: 13px;
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--plane); color: var(--text-primary); box-sizing: border-box;
}
.fb-author {
  width: 100%; margin-top: 8px; font: inherit; font-size: 12.5px;
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--plane); color: var(--text-primary); box-sizing: border-box;
}
.fb-pop-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.fb-pop-err { margin-top: 8px; font-size: 12px; color: var(--critical); }
.fb-pop-err[hidden] { display: none; }

/* 작성 팝오버 — 화면 캡처 첨부 트리거만 여기 있다. 실제 미리보기는 화면
   중앙 모달(.fb-shot-modal-*)로 분리되어 있다 — 좁은 팝오버 안에 작은
   썸네일로 넣으면 내용을 확인하기 어렵고, 팝오버 레이아웃도 늘어난 만큼
   흔들린다. */
.fb-shot-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.fb-shot-status { font-size: 11.5px; color: var(--muted); }

/* 캡처 미리보기 모달 — 백드롭으로 화면 전체를 덮고 중앙에 카드를 띄운다.
   fb-pop보다 z-index를 높여 항상 그 위에 뜨게 한다. */
.fb-shot-modal-backdrop {
  position: fixed; inset: 0; z-index: 9600; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  cursor: pointer;
}
.fb-shot-modal {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
  max-width: min(720px, 100%); max-height: 100%; overflow-y: auto;
  cursor: auto; display: flex; flex-direction: column; gap: 12px;
}
.fb-shot-modal-title { font-size: 13px; font-weight: 660; }
.fb-shot-modal-imgwrap {
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  background: var(--plane); line-height: 0;
}
.fb-shot-modal-imgwrap img { display: block; width: 100%; max-height: 60vh; object-fit: contain; }
.fb-shot-modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.fb-shot-modal-actions .fb-shot-discard { color: var(--critical); }

.fb-thread-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.fb-thread-row { border-top: 1px solid var(--border); padding-top: 9px; }
.fb-thread-row:first-child { border-top: none; padding-top: 0; }
.fb-thread-meta { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.fb-thread-text { font-size: 13px; color: var(--text-primary); line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.fb-thread-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.fb-thread-actions .fb-status-cur { background: var(--s1); color: #fff; border-color: transparent; }
.fb-thread-actions .fb-del { color: var(--critical); }

/* 스크린샷 썸네일 — 스레드 팝오버와 의견 모음 목록 공용 */
.fb-thread-shot {
  display: block; margin: 6px 0; border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; line-height: 0; max-width: 220px;
}
.fb-thread-shot img { display: block; width: 100%; }

@media (max-width: 640px) {
  .fb-fab { right: 14px; bottom: 14px; width: 46px; height: 46px; }
  .fb-fab .fb-icon { width: 19px; height: 19px; }
}

/* 의견 모음(목록 화면) */
.fb-list { display: flex; flex-direction: column; gap: 12px; }
.fb-list-row { border-top: 1px solid var(--border); padding-top: 12px; }
.fb-list-row:first-child { border-top: none; padding-top: 0; }
.fb-list-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.fb-list-text { font-size: 13px; color: var(--text-primary); line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 6px; }
.fb-tag-open { color: var(--s1); border-color: color-mix(in oklab, var(--s1) 40%, transparent); }
.fb-tag-done { color: var(--good); border-color: color-mix(in oklab, var(--good) 40%, transparent); }
.fb-tag-wontfix { color: var(--muted); }

/* 댓글 — 원 의견 아래에 들여쓰기로 딸려 붙는다.
   왼쪽 선으로 "이 의견에 대한 답"임을 시각적으로 묶는다. */
.fb-comments { margin: 10px 0 0 12px; padding-left: 12px;
  border-left: 2px solid var(--border); }
.fb-comment-list { display: flex; flex-direction: column; gap: 8px; }
.fb-comment-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.fb-comment-text { font-size: 13px; color: var(--text-primary); line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere; }
.fb-comment-del { background: none; border: none; padding: 0; cursor: pointer;
  font-size: 11px; color: var(--muted); text-decoration: underline; }
.fb-comment-del:hover { color: var(--critical); }
.fb-comment-del:disabled { opacity: .5; cursor: default; }
.fb-comment-form { display: flex; gap: 6px; margin-top: 10px; }
.fb-comment-form input { flex: 1; min-width: 0; font-size: 13px;
  padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-1); color: var(--text-primary); }
.fb-comment-form input:focus { outline: none;
  border-color: color-mix(in oklab, var(--s1) 55%, transparent); }

/* 말풍선 팝오버(320px)는 좁다 — 여백을 줄이고 등록 버튼도 압축한다.
   같은 commentBlock을 목록/팝오버가 공유하므로 차이는 CSS로만 낸다. */
.fb-thread .fb-comments { margin: 8px 0 0 4px; padding-left: 8px; }
.fb-thread .fb-comment-text { font-size: 12px; }
.fb-thread .fb-comment-meta { font-size: 10px; }
.fb-thread .fb-comment-form { margin-top: 8px; }
.fb-thread .fb-comment-form input { font-size: 12px; padding: 4px 6px; }
.fb-thread .fb-comment-form .btn-sm { padding: 4px 8px; font-size: 12px; }

/* ─────────────────────────────────────────── 공포·탐욕 지수 */
/* 구간 색 — 팔레트의 good/bad 토큰만 쓴다(색각 이상에서도 밝기로 구분되도록
   중간 구간은 채도를 낮춘다). */
.fg-extreme-fear  { color: var(--critical); }
.fg-fear          { color: color-mix(in oklab, var(--critical) 75%, var(--text-primary)); }
.fg-neutral       { color: var(--muted); }
.fg-greed         { color: color-mix(in oklab, var(--good) 75%, var(--text-primary)); }
.fg-extreme-greed { color: var(--good); }

.fg-market { margin: 8px 0 4px; }
.fg-main { display: flex; align-items: baseline; gap: 14px; margin: 6px 0 2px; }
.fg-score { font-size: 54px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.fg-label { font-size: 17px; font-weight: 640; }
.fg-gauge { margin: 4px 0 10px; max-width: 620px; }

/* 지수 아래에 같은 날짜축으로 붙는 시장 지수(S&P500/KOSPI) 라벨.
   위 차트와 한 덩어리로 읽히도록 간격을 좁게 둔다. */
.fg-bench-label {
  margin: 10px 0 -4px; font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary);
}

.fg-prev { display: flex; flex-wrap: wrap; gap: 18px; margin: 10px 0 4px; }
.fg-prev-item { min-width: 78px; }
.fg-prev-label { font-size: 11px; color: var(--muted); }
.fg-prev-score { font-size: 20px; font-weight: 660; font-variant-numeric: tabular-nums; }
.fg-prev-zone { font-size: 11px; color: var(--muted); }

.fg-comps { display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-top: 4px; }
.fg-comp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.fg-comp-label { font-size: 12px; color: var(--text-primary); }
.fg-comp-score { font-size: 15px; font-weight: 660; font-variant-numeric: tabular-nums; }
.fg-comp-bar { height: 6px; border-radius: 3px; background: var(--surface-1);
  overflow: hidden; margin: 5px 0 3px; }
.fg-comp-fill { height: 100%; border-radius: 3px; background: currentColor; }
.fg-comp-zone { font-size: 11px; color: var(--muted); }

/* ─────────────────────────────────────────── 종목 히트맵 */
.hm-legend { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.hm-legend-label { font-size: 11px; color: var(--muted); }
.hm-legend-bar { flex: 0 0 160px; height: 8px; border-radius: 4px;
  background: linear-gradient(to right, var(--critical), var(--surface-1), var(--good)); }

.hm-group-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hm-group-head .card-title { margin: 0; }
.hm-group-avg { font-size: 11px; padding: 2px 8px; border-radius: 10px;
  color: var(--text-primary); }

/* 격자 — 칸 크기는 시총 순위에 따라 3단계.
   정식 트리맵(squarify) 대신 격자를 쓰는 이유는 모듈 주석에 적어뒀다. */
.hm-grid { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.hm-cell { border-radius: 5px; padding: 6px 8px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
  cursor: default; transition: transform .08s ease; }
.hm-cell:hover { transform: scale(1.04); z-index: 1; }
.hm-lg { flex: 0 0 150px; height: 72px; }
.hm-md { flex: 0 0 106px; height: 56px; }
.hm-sm { flex: 0 0 82px; height: 44px; }
.hm-name { font-size: 11px; font-weight: 620; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-lg .hm-name { font-size: 13px; }
.hm-val { font-size: 11px; color: var(--text-primary); opacity: .82;
  font-variant-numeric: tabular-nums; }
.hm-lg .hm-val { font-size: 15px; opacity: .95; }

@media (max-width: 640px) {
  .hm-lg { flex: 0 0 116px; height: 62px; }
  .hm-md { flex: 0 0 88px; height: 50px; }
  .hm-sm { flex: 0 0 72px; height: 42px; }
  .fg-score { font-size: 42px; }
}

/* ─────────────────────────────────────────── 배당 재투자 */
.dr-flow { display: grid; gap: 14px; margin: 6px 0 4px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.dr-flow-label { font-size: 11px; color: var(--muted); }
.dr-flow-value { font-size: 18px; font-weight: 650;
  font-variant-numeric: tabular-nums; color: var(--text-primary); }
.dr-flow-value.lose { color: var(--critical); }

/* ------------------------------------------- 팩터 스크리닝 */
/* 팩터는 여러 개를 함께 고를 수 있다 — 체크박스를 칩처럼 보이게 해서
   "지금 무엇이 켜져 있나"가 한눈에 들어오게 한다. */
.fc-factors {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px;
}
.fc-factor {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 11px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--plane);
  font-size: 12.5px; cursor: pointer;
}
.fc-factor.is-on { border-color: var(--s1); background: var(--grid); }
.fc-factor-name { font-weight: 600; }
.fc-factor-dir { font-size: 11px; color: var(--text-secondary); }

.fc-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.fc-caveat { margin: 12px 0; }

/* 결론 한 줄 — 숫자 표를 읽기 전에 "이겼나 졌나"부터 보이게 */
.fc-verdict {
  font-size: 15px; margin: 6px 0 12px; padding: 10px 13px;
  border-radius: 9px; background: var(--plane);
  border-left: 3px solid var(--muted);
}
.fc-verdict.is-good { border-left-color: var(--good); }
.fc-verdict.is-bad { border-left-color: var(--critical); }

.fc-stats { max-width: 420px; margin-bottom: 14px; }
.fc-stats td:nth-child(2) { font-variant-numeric: tabular-nums; }
.fc-stats td:nth-child(3) { color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.fc-picks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.fc-pick {
  padding: 5px 10px; border-radius: 7px; background: var(--plane);
  border: 1px solid var(--border); font-size: 12.5px;
}
.fc-pick b { color: var(--text-secondary); font-weight: 600; margin-right: 4px; }

/* ------------------------------------------- 종목 분석 > 재무 (stockfin.js) */
.fin-tools { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; align-items: center; }
.fin-tbl th:first-child, .fin-tbl td:first-child { position: sticky; left: 0; background: var(--surface-1); z-index: 1; min-width: 150px; }
.fin-tbl tr.bold td { font-weight: 650; }
.fin-tbl tr.indent td:first-child { padding-left: 22px; color: var(--text-secondary); }
.fin-tbl tr.grp td { background: var(--plane); font-weight: 600; font-size: 12px; color: var(--text-secondary); padding-top: 9px; }
.fin-tbl td.pos { color: var(--good); }
.fin-tbl td.neg { color: var(--critical); }
.fin-tbl .mono { font-family: ui-monospace, Menlo, monospace; font-size: 11px; }
.fin-spark { width: 64px; height: 18px; display: block; }
.fin-flags { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; margin: 8px 0; }
.fin-flag { padding: 10px 12px; border-radius: 9px; background: var(--plane); border-left: 3px solid var(--muted); }
.fin-flag.warn { border-left-color: #d99a2b; }
.fin-flag.bad { border-left-color: var(--critical); }
.fin-flag.good { border-left-color: var(--good); }
.fin-flag-title { font-weight: 650; font-size: 13px; }
.fin-flag-detail { font-size: 12px; color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }
.fin-dupont { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 10px 0 6px; }
.fin-dupont > div { text-align: center; }
.fin-dp-v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fin-dp-l { font-size: 11.5px; color: var(--text-secondary); }
.fin-dp-op { font-size: 20px; color: var(--muted); }
.fin-bars svg { width: 100%; height: auto; }
.fin-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
.fin-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; }

/* 재무 표 — 행 클릭 상세 */
.fin-tbl tr.fin-row { cursor: pointer; }
.fin-tbl tr.fin-row:hover td { background: var(--plane); }
.fin-tbl tr.fin-row.sel td { background: color-mix(in oklab, var(--s1) 10%, var(--surface-1)); }
.fin-tbl tr.fin-detail-row > td { padding: 0; background: var(--plane); position: static; }
.fin-detail { padding: 14px 16px 16px; border-top: 2px solid var(--s1); }
.fin-detail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; font-size: 14px; }
.fin-detail-rel { font-size: 12px; color: var(--text-secondary); display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.fin-chip { border: 1px solid var(--border); background: var(--surface-1); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.fin-chip.on { border-color: var(--s1); background: color-mix(in oklab, var(--s1) 14%, var(--surface-1)); font-weight: 600; }
.fin-chip.off { opacity: 0.45; cursor: not-allowed; }
.fin-detail-close { margin-left: auto; margin-top: 0; }
.fin-detail-sub { margin: 10px 0 6px; }
.fin-detail-sub svg { width: 100%; height: auto; }
.fin-detail-tbl { max-width: 720px; margin-top: 8px; }
.fin-detail-tbl th:first-child, .fin-detail-tbl td:first-child { position: static; min-width: 70px; }
