/* ── Roboto: 숫자 전용 (한/영문은 기존 폰트 유지) ──────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

/* ── 앱 셸 스켈레톤 (JS 로드 전 즉시 표시) ─────────────────────────────── */
.app-skeleton {
  padding: 20px 16px; max-width: 960px; margin: 0 auto;
}
.skel-header {
  display: flex; align-items: center; margin-bottom: 18px;
}
.skel-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px;
}
.skel-card {
  background: #18181b; border-radius: 12px; padding: 16px;
  border: 1px solid #2a2a2e;
}
.skel-pill {
  background: #27272a; border-radius: 6px; height: 14px;
  animation: skel-pulse 1.4s ease-in-out infinite;
}
.skel-bar {
  height: 4px; background: #27272a; border-radius: 2px; margin-top: 14px;
  animation: skel-pulse 1.4s ease-in-out infinite;
}
@keyframes skel-pulse {
  0%, 100% { opacity: .4; }
  50% { opacity: .8; }
}

/* ── 글로벌 다크모드 스크롤바 ──────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: #3f3f46 #18181b; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: #18181b; border-radius: 4px; }
*::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: #52525b; }
*::-webkit-scrollbar-corner { background: #18181b; }

/* ── 기본 리셋 & 변수 ────────────────────────────────────────────────────── */
:root {
  --bg:         #0d0d0f;
  --card:       #18181b;
  --border:     #2a2a2e;
  --border-soft:#222226;
  --text:       #e4e4e7;
  --text-2:     #a1a1aa;
  --text-3:     #71717a;
  --primary:    #a1a1aa;
  --primary-h:  #d4d4d8;
  --up:         #FF5F57;
  --dn:         #567FF0;
  --up-bg:      #1e1e22;
  --dn-bg:      #2d1010;
  --shadow:     0 1px 4px rgba(0,0,0,.5), 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.7);
  --radius:     12px;
  --radius-sm:  8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
canvas { display: block; }

body {
  font-family: 'Roboto', -apple-system, 'Pretendard', 'Apple SD Gothic Neo', BlinkMacSystemFont,
               'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── 헤더 ────────────────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #111114;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 6px rgba(0,0,0,.4);
  transition: transform .25s ease, opacity .2s ease;
}
body.header-hidden .header {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.header-inner {
  position: relative;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.logo-icon { font-size: 22px; display: flex; align-items: center; }
.logo-text  { font-size: 16px; font-weight: 600; color: var(--text); }
.logo-svg   { width: 22px; height: 22px; filter: invert(1); display: block; }
.btn-svg    { width: 15px; height: 15px; filter: invert(1) opacity(0.7); display: block; flex-shrink: 0; }

.search-wrap {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 480px;
  max-width: calc(100% - 360px);
}

.header-right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.btn-charts-link {
  font-size: 15px;
  color: #a1a1aa;
  text-decoration: none;
  border: none;
  background: none;
  padding: 4px 6px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color .15s;
}
.btn-charts-link:hover { color: var(--text); }
.btn-charts-link .btn-svg { margin-top: -3px; vertical-align: unset; }

.search-input {
  width: 100%;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  background: #111114;
  color: var(--text);
}
.search-input:focus { border-color: var(--primary); background: #18181b; }
.search-input::placeholder { color: var(--text-3); }

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #18181b;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 200;
  scrollbar-width: thin;
  scrollbar-color: #3f3f46 #18181b;
}
.search-dropdown::-webkit-scrollbar { width: 8px; }
.search-dropdown::-webkit-scrollbar-track { background: #18181b; border-radius: 4px; }
.search-dropdown::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 4px; }
.search-dropdown::-webkit-scrollbar-thumb:hover { background: #52525b; }
.search-dropdown.hidden { display: none; }
.search-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px 6px;
  border-bottom: 1px solid var(--border);
  background: #111114;
  position: sticky;
  top: 0;
  z-index: 1;
}
.search-dropdown-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.search-dropdown-close {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 15px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color .12s;
}
.search-dropdown-close:hover { color: var(--dn); }

.search-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .1s;
  gap: 12px;
}
.search-item:hover { background: #222226; }

.search-item-rank {
  width: 18px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  text-align: center;
}
.search-item-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #27272a;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -.02em;
}
.search-item-left  { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.search-item-name  {
  font-size: 14px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-item-meta  { font-size: 12px; color: var(--text-2); }
.search-item-right {
  display: flex;
  gap: 6px;
  flex-shrink: 1;
  align-items: center;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  padding: 4px;
  border-radius: 4px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.badge-market  { background: #1e2535; color: #94a3b8; flex-shrink: 0; }
.badge-sector  {
  background: #222226;
  color: var(--text-2);
  border: 1px solid var(--border);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 600px) {
  .badge-sector { max-width: 100px; }
  .search-item-right { gap: 4px; }
}

/* ── 메인 레이아웃 ──────────────────────────────────────────────────────── */
.main {
  max-width: 100%;
  margin: 0 auto;
  padding: 20px 30px 50px
}
@media (max-width: 640px) {
  .main { padding: 20px 10px 50px; }
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

/* 헤더 내부 탭 — 하단 라인에 고정 */
.header-tabs {
  position: absolute;
  left: 50%;
  bottom: -2px;
  transform: translateX(-50%);
  margin-bottom: 0;
  border-bottom: none;
  background: transparent;
  z-index: 1;
}
.header-tabs .tab { padding: 8px 16px; font-size: 14px; margin-bottom: 0; }

.tab {
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 500;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  color: var(--text-2);
  border-radius: 4px 4px 0 0;
  transition: color .15s, border-color .15s;
}
.tab:hover   { color: var(--primary-h); }
.tab.active  { color: var(--text); border-bottom-color: var(--text-2); }

.tab-content { }
.tab-content.hidden { display: none; }


.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  position: sticky;
  top: 50px;
  z-index: 50;
  background: var(--bg);
  padding: 10px 0;
  transition: top .25s ease;
}
body.header-hidden .section-header {
  top: 0;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-badge {
  font-size: 12px;
  background: var(--border);
  color: var(--text-2);
  border-radius: 999px;
  padding: 1px 7px;
  font-weight: 600;
}

.sort-select {
  padding: 5px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-2);
  cursor: pointer;
  outline: none;
  transition: border-color .15s, color .15s;
}
.sort-select:hover, .sort-select:focus { border-color: var(--text-3); color: var(--text); }
.sort-select option { background: var(--card); color: var(--text); }

/* 모바일 정렬 버튼 — PC에선 숨김 */
.sort-select-mobile {
  display: none;
  padding: 4px 10px;
  font-size: 12px; font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-2);
  cursor: pointer;
  transition: border-color .12s;
}
.sort-select-mobile:hover { border-color: var(--text-3); color: var(--text); }

/* 정렬 모달 */
.sort-modal-box { max-width: 300px; padding: 14px 0 8px; }
.sort-opt { justify-content: space-between; }
.sort-check { color: #567FF0; font-weight: 700; }

@media (max-width: 600px) {
  .sort-select-pc { display: none; }
  .sort-select-mobile { display: inline-flex; align-items: center; gap: 4px; }
}

.btn-icon {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
  color: var(--text-2);
  transition: all .15s;
}
.btn-icon:hover { border-color: var(--text-3); color: var(--text); }

.btn-icon-only {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity .15s;
}
.btn-icon-only::before {
  content: '';
  width: 18px;
  height: 18px;
  background-color: var(--text-2);
  -webkit-mask: url('refresh.svg') center / contain no-repeat;
          mask: url('refresh.svg') center / contain no-repeat;
  transition: transform .4s ease;
}
.btn-icon-only:hover { opacity: 1; }
.btn-icon-only:hover::before { background-color: var(--text); }
.btn-icon-only:active::before { transform: rotate(180deg); }

/* ── 카드 그리드 ─────────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

/* 단순 카드 보기: 종목명 · 오늘 · Upside 만 노출 */
.cards-simple .card-ticker-row,
.cards-simple .card-hold-pl,
.cards-simple .card-saved-date,
.cards-simple .card-stale-badge,
.cards-simple .card-note { display: none !important; }

.btn-view-toggle { cursor: pointer; }

.stock-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow .2s, transform .15s, border-color .15s;
  position: relative;
  overflow: hidden;
}
.stock-card:hover {
  box-shadow: var(--shadow);
  border-color: #3f3f46;
  transform: translateY(-2px);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;

}
.card-name  { font-size: 15px; font-weight: 600; line-height: 1.3; flex: 1; }
.card-name.draggable { cursor: grab; }
.card-name.draggable:active { cursor: grabbing; }
.card-del   {
  opacity: 0;
  transition: opacity .15s;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 16px;
  padding: 0 0 0 6px;
  line-height: 1;
}
.stock-card:hover .card-del { opacity: 1; }
.card-del:hover { color: var(--dn); }

.card-ticker { font-size: 11px; color: var(--text-3); }
.card-ticker-row {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.card-ticker-row .card-mktcap { margin: 0; min-height: 0; font-size: 11px; }
.card-price-block {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-top: 6px;
}
.card-price-label { font-size: 11px; color: var(--text-3); flex-shrink: 0; }
.ctc-row-top {
  display: flex; align-items: baseline; justify-content: space-between;

}
.card-sector { margin-top: 0px; }
.card-sector .badge-sector { font-size: 10px; padding: 4px; }
.card-badges  { display: none; }

/* 필터 칩 */
.filter-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  /* 모바일 좌우 드래그 스크롤 */
  -ms-overflow-style: none;
  touch-action: pan-x;
}
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: all .12s;
  flex-shrink: 0;
}
.filter-chip:hover { border-color: var(--text-3); color: var(--text); }
.filter-chip.active {
  background: #567FF0;
  color: #fff;
  border-color: #567FF0;
}
.filter-chip.active:hover { background: #4a6fd9; border-color: #4a6fd9; }
.fc-count {
  font-size: 11px;
  font-weight: 500;
  opacity: .7;
}

/* KPI 바 */
.kpi-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.kpi-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.kpi-label { font-size: 11px; color: var(--text-3); display: flex; align-items: center; gap: 4px; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1.3; }
.kpi-value.up { color: var(--up); }
.kpi-value.dn { color: var(--dn); }
.kpi-sub { font-size: 11px; font-weight: 500; color: var(--text-3); }
.kpi-sub.up { color: var(--up); opacity: .8; }
.kpi-sub.dn { color: var(--dn); opacity: .8; }
.kpi-badge {
  font-size: 9px; padding: 1px 5px; border-radius: 3px;
  background: #27272a; color: var(--text-3); font-weight: 600;
}
.kpi-badge-live { background: rgba(255,95,87,.15); color: var(--up); }
@media (max-width: 600px) {
  /* 가로 스크롤 구조로 전환 */
  .kpi-bar {
    display: flex; flex-wrap: nowrap;
    overflow-x: auto; gap: 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    margin-left: -10px; margin-right: -10px;
    padding: 0 10px 4px;
  }
  .kpi-bar::-webkit-scrollbar { display: none; }
  .kpi-item {
    flex: 0 0 auto; min-width: 160px;
    padding: 10px 14px;
  }
  /* 1.2배 확대 */
  .kpi-label { font-size: 13px; }
  .kpi-value { font-size: 23px; }
  .kpi-sub   { font-size: 13px; }
  .kpi-badge { font-size: 11px; }
}

.card-saved-date {
  display: flex;
  align-items: baseline;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 5px;
}
.card-stale-badge {
  display: flex;
  align-items: baseline;
  font-size: 11px;
  color: #f59e0b;
  margin-top: 5px;
  font-weight: 600;
}
.card-hold-date {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
}

.card-price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  justify-content: flex-end;
}
.card-price  { font-size: 18px; font-weight: 700; }
.card-change { font-size: 13px; font-weight: 500; }
.up { color: var(--up); }
.dn { color: var(--dn); }
.neu { color: var(--text-2); }

.card-loading {
  font-size: 12px;
  color: var(--text-3);
  margin: 0;
  animation: pulse 1.2s infinite;
}


.sparkline-wrap { display: none; }

.card-target-cmp {
  margin-top: 0;
  padding-top: 8px;
}
.ctc-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 11px;
  color: var(--text-2);
}
.ctc-label { color: var(--text-3); }
.ctc-label-ai { color: #FF5F57; font-weight: 400; }
.cmi-label-ai { color: var(--text-3); font-weight: 400; }
.cmi-label-ai-mark { color: #FF5F57; font-weight: 700; }
.ctc-target { color: var(--text); font-weight: 400; margin-left: auto; font-size: 18px;}
.ctc-bar {
  position: relative;
  display: flex;
  height: 6px;
  margin-top: 4px;
  margin-bottom: 4px;
  background: var(--border-soft);
  border-radius: 3px;
  overflow: hidden;
}
.ctc-bar-fill {
  height: 100%;
  width: 0%;
  background: #312b5d;
  border-radius: 3px 0 0 3px;
  transition: width 0.4s ease, background 0.3s ease;
}
.ctc-bar-remain {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #975EF1, #1cbef8, #975EF1);
  background-size: 200% 100%;
  border-radius: 0 3px 3px 0;
  transition: width 0.4s ease;
  animation: ctcBarFlow 5s linear infinite;
}
@keyframes ctcBarFlow {
  0%   { background-position: 100% 50%; }
  100% { background-position: -100% 50%; }
}
.ctc-bar-fill.reached {
  background: #522b29;
  border-radius: 3px;
}
.ctc-bar-top { margin-top: 4px; }

.card-mktcap {
  font-size: 11px;
  color: var(--text-3);
  min-height: 14px;
}
.mktcap-help {
  cursor: help; opacity: .5; font-size: 12px; vertical-align: middle;
}
.mktcap-help:hover { opacity: .9; }

.card-target {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-2);
  border-top: 1px solid var(--border-soft);
  padding-top: 6px;
}
.card-target .target-val { color: var(--text); font-weight: 600; }
/* AI 상승 여력 — 카드 핵심 숫자 */
.card-ai-potential {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin-left: auto;
}
.cap-label {
  font-size: 11px;
  color: var(--text-3);
  flex-shrink: 0;
}
.cap-value {
  font-size: 14px;
  font-weight: 700;
}
.ctc-row-top .ctc-target {
  margin-left: 2px;
  background: linear-gradient(90deg, #0080ad, #4d4cf7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  font-weight: 700;
}
/* Upside 음수 (현재가 > 목표가) 상태일 때 ctc-target 그라데이션 변경 */
.ctc-row-top:has(.card-gap-pct.dn) .ctc-target {
  background: linear-gradient(90deg, #af534e, #4c2829);
  -webkit-background-clip: text;
  background-clip: text;
}
.card-ai-potential { color: #0080ad; }
.card-gap-pct { font-size: 14px; font-weight: 400; }
.card-gap-pct.up { color: #0080ad; }
.card-gap-pct.dn { color: #FF5F57; }

.card-hold-pl {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 11px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.card-hold-pl + .card-hold-pl {
  margin-top: 2px;
  padding-top: 0;
  border-top: none;
}
.card-hold-pl .chp-label  { color: var(--text-3); }
.card-hold-pl .chp-pct    { font-size: 13px; margin-left: auto; }
.card-hold-pl .chp-amount { font-size: 16px; font-weight: 600; margin-left: 5px; }
.card-hold-pl.up { color: var(--up); }
.card-hold-pl.dn { color: var(--dn); }
.card-hold-avg { color: var(--text-2); }
.card-hold-avg .chp-pct,
.card-hold-avg .chp-amount { color: #c2c1d4; font-weight: 400; }
.card-hold-avg .chp-amount { font-size: 16px; font-weight: 600; }

.card-note { display: none; }

/* 검색 결과 카드 (추가 버튼 포함) */
.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}
.btn-add {
  flex: 1;
  padding: 7px;
  font-size: 13px;
  font-weight: 500;
  background: #2a2a2e;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-add:hover { background: #3f3f46; border-color: #3f3f46; }
.btn-add.added { background: #1a1a1d; color: var(--text-3); cursor: default; border-color: var(--border-soft); }

/* 빈 상태 */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-2);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-icon img {
  width: 40px; height: 40px; opacity: .7; vertical-align: middle;
  filter: brightness(0) invert(1);
}
@media (prefers-color-scheme: light) {
  .empty-icon img { filter: none; }
}
.empty-sub  { font-size: 13px; color: var(--text-3); margin-top: 4px; }

/* ── 모달 ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn .15s ease;
  -webkit-overflow-scrolling: touch;
}
.modal-overlay.hidden { display: none; }

/* 가운데 정렬 confirm 류 모달 */
.modal-overlay.confirm-overlay { align-items: center; padding: 16px; }
.modal-box.confirm-box {
  max-width: 380px;
  width: 100%;
  height: auto;
  max-height: 90vh;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  animation: fadeIn .15s ease;
}

/* PC: 검색/그룹관리 모달 — 화면 중앙 팝업, 핸들 숨김 */
@media (min-width: 601px) {
  #searchModal { align-items: flex-start; padding: 100px 16px 16px; }
  #grpMgrModal { align-items: center; padding: 16px; }
  #searchModal .chart-mh-drag,
  #grpMgrModal .chart-mh-drag { display: none; }
  #searchModal .modal-box {
    height: auto;
    max-height: calc(100vh - 120px);
    border: 1px solid var(--border);
    border-radius: 10px;
    animation: fadeIn .15s ease;
  }
  #grpMgrModal .modal-box {
    height: auto;
    max-height: 80vh;
    border: 1px solid var(--border);
    border-radius: 12px;
    animation: fadeIn .15s ease;
  }
  /* 핸들 숨긴 뒤 modal-header sticky 해제 (중앙 팝업에선 불필요) */
  #searchModal .chart-mh-drag + .modal-header,
  #grpMgrModal .chart-mh-drag + .modal-header {
    position: static;
    margin-left: 0; margin-right: 0;
    padding: 0 0 12px 0;
    border-bottom: 1px solid var(--border);
  }
}
/* 모바일: 핸들 표시, 아래→위 시트 (기본 .modal-overlay 스타일 그대로) */
@media (max-width: 600px) {
  #searchModal .chart-mh-drag { display: none; }
  #grpMgrModal .chart-mh-drag { display: flex; }
  #searchModal {
    align-items: stretch;
    padding: 0;
  }
  #searchModal .modal-box {
    border-radius: 0;
    border: none;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    animation: none;
  }
  #searchModal .chart-mh-drag + .modal-header {
    position: static;
    margin: 0;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border);
  }
  #grpMgrModal {
    align-items: flex-end;
    padding: 0;
  }
  #grpMgrModal .modal-box {
    width: 100%;
    max-width: 100%;
    border-radius: 10px 10px 0 0;
    border-bottom: none;
    max-height: 90vh;
    max-height: 90dvh;
  }
}

/* 가운데 정렬 그룹 선택 모달 (addModal) — 그룹 리스트가 최대한 많이 보이도록 */
.modal-box.centered-add-box {
  max-width: 440px;
  width: 100%;
  height: auto;
  max-height: 90vh;
  display: flex; flex-direction: column;
  padding: 20px 22px;
}
.modal-box.centered-add-box .grpmgr-list-lg {
  flex: 1 1 auto;
  max-height: none;          /* 데스크톱에선 박스 높이를 꽉 채움 */
  min-height: 180px;
  overflow-y: auto;
}
@media (max-height: 600px) {
  .modal-box.centered-add-box { max-height: 95vh; }
  .modal-box.centered-add-box .grpmgr-list-lg { min-height: 120px; }
}

.modal-box {
  background: #18181b;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  height: 95vh;
  max-height: 95vh;
  height: 95dvh;
  max-height: 95dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 24px env(safe-area-inset-bottom, 0px) 24px;
  animation: slideUpSheet .25s ease;
  scrollbar-width: none;
}
.modal-box::-webkit-scrollbar { width: 0; height: 0; display: none; }
.modal-wide { max-width: 880px; }

@media (max-width: 640px) {
  .modal-box { max-width: 100%; border-left: none; border-right: none; }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 0 0 12px 0;
}
.modal-title    { font-size: 18px; font-weight: 700; color: var(--text); }
.modal-subtitle { font-size: 13px; color: var(--text-2); margin-top: 2px; }

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-2);
  padding: 0 0 0 12px;
  line-height: 1;
  flex-shrink: 0;
  transition: color .15s;
}
.modal-close:hover { color: var(--dn); }

/* 기간 탭 — 하단 라인 스타일 */
.period-tabs {
  display: flex;
  gap: 18px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.period-btn {
  padding: 8px 2px;
  font-size: 13px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s, border-color .12s;
}
.period-btn:hover  { color: var(--text-2); }
.period-btn.active { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }

/* 현재가 정보 */
.price-info {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.pi-price  { font-size: 26px; font-weight: 700; }
.pi-change { font-size: 14px; font-weight: 600; }
.pi-time   { font-size: 12px; color: var(--text-3); }

/* 차트 영역 */
.chart-area {
  position: relative;
  width: 100%;
  height: 220px;
  margin-bottom: 6px;
  overflow: hidden;
}
.chart-area-vol { height:50px; margin-bottom: 14px; overflow: hidden; }
.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-3);
  background: rgba(13,13,15,.85);
  z-index: 1;
  border-radius: var(--radius-sm);
}

/* 메모/목표가 행 */
.modal-target-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-top: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  margin-bottom: 20px;
}
.modal-target-row.hidden { display: none; }
/* 목표가 행 안의 note-group은 가로 정렬 + 너비 고정 */
.modal-target-row .note-group {
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: unset;
}
.modal-target-row .note-group label {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}

.qt-targets {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  scroll-behavior: smooth;
}
.qt-targets.dragging { cursor: grabbing; scroll-behavior: auto; }
.qt-targets.dragging .qt-chip { pointer-events: none; }
.qt-targets::-webkit-scrollbar { display: none; }
.qt-chip {
  font-size: 12px;
  color: var(--text-2);
  background: #111114;
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 3px 8px;
  white-space: nowrap;
}
.qt-chip .qt-q { color: var(--text-3); margin-right: 3px; }
.qt-chip .qt-v { color: var(--text); font-weight: 400; }
.qt-chip .qt-gap { margin-left: 6px; font-size: 11px; font-weight: 600; }
.qt-chip.up .qt-gap { color: #567FF0; }
.qt-chip.dn .qt-gap { color: #FF5F57; }
.qt-chip.up { border-color: rgba(86,127,240,.45); }
.qt-chip.dn { border-color: rgba(213,88,87,.45); }

/* ── 보유 종목 행 (modal-header 직후) ──────────────────────── */
.modal-hold-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: nowrap;
}
.modal-hold-row.hidden { display: none; }

.hold-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: #8181e1;
  background: rgba(129,129,225,.12);
  border: 1px solid rgba(129,129,225,.3);
  padding: 3px 9px;
  border-radius: 5px;
  letter-spacing: .3px;
}
.hold-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.hold-field label {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}
.hold-input {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #111114;
  color: var(--text);
  font-size: 16px;
  outline: none;
  width: 150px;
  transition: border-color .12s;
}
.hold-input:focus        { border-color: #8181e1; }
.hold-input::placeholder { color: var(--text-3); }
.hold-input-sm           { width: 80px; }
.hold-input-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.hold-input-wrap .hold-input { padding-left: 60px; padding-right: 22px; text-align: right; }
.hold-input-wrap-sm .hold-input { padding-left: 52px; padding-right: 10px; }
.hold-input-prefix {
  position: absolute;
  left: 10px;
  font-size: 12px;
  color: var(--text-3);
  pointer-events: none;
  white-space: nowrap;
}
.hold-input-unit {
  position: absolute;
  right: 10px;
  font-size: 13px;
  color: var(--text-3);
  pointer-events: none;
}
.hold-input { color-scheme: dark; }
.hold-input::-webkit-outer-spin-button,
.hold-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
.hold-input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.hold-total              { margin-left: 4px; }
.hold-total-value {
  font-size: 18px;
  font-weight: 600;
  color: #8181e1;
  white-space: nowrap;
  padding: 6px 0;
}
.hold-profit             { margin-left: 4px; }
.hold-profit-value {
  font-size: 20px;
  font-weight: 400;
  white-space: nowrap;
  padding: 0;
}
.hold-profit-value.hold-profit-pct { font-size: 14px; font-weight: 500; }
.hold-profit-value.up  { color: #FF5F57; }
.hold-profit-value.dn  { color: #567FF0; }

/* ── 메모/업종 행 ─────────────────────────────────────────── */
.modal-note-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
.note-group       { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 120px; }
.note-group label { font-size: 12px; color: var(--text-2); }
.note-input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  width: 100%;
  background: #111114;
  color: var(--text);
  transition: border-color .12s;
}
.note-input:focus { border-color: var(--text-3); }
.note-input-sm { max-width: 120px; }
.note-input::placeholder { color: var(--text-3); }

.btn-save {
  padding: 8px 16px;
  background: #2a2a2e;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn-save:hover { background: #3f3f46; border-color: #3f3f46; }

.btn-more {
  padding: 8px 14px;
  background: none;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn-more:hover { background: #2a2a2e; border-color: #3f3f46; color: var(--text); }

/* AI 목표가 설정 버튼 — 좌→우 그라데이션이 흐르는 애니메이션 border
   흐르는 속도는 --flow-dur (JS 에서 랜덤 주입) */
#moreChartBtn {
  --flow-dur: 3s;
  position: relative;
  padding-left: 15px;
  padding-right: 15px;
  border: 1.5px solid transparent;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    linear-gradient(90deg,
      #a855f7 0%, #3b82f6 25%, #22d3ee 50%,
      #3b82f6 75%, #a855f7 100%) border-box;
  background-size: 100% 100%, 300% 100%;
  animation: gradBorderFlow var(--flow-dur) linear infinite;
  color: #92a9e9;
}
#moreChartBtn:hover {
  color: #92a9e9;
  background:
    linear-gradient(#2a2a2e, #2a2a2e) padding-box,
    linear-gradient(90deg,
      #a855f7 0%, #3b82f6 25%, #22d3ee 50%,
      #3b82f6 75%, #a855f7 100%) border-box;
  background-size: 100% 100%, 300% 100%;
}
@keyframes gradBorderFlow {
  0%   { background-position: 0 0,   0% 50%; }
  100% { background-position: 0 0, 300% 50%; }
}

/* 저장/더보기 버튼 행 (하단 sticky) */
.modal-action-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  position: sticky;
  bottom: 0;
  margin: 14px -24px -24px;
  padding: 14px 24px calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 5;
  /* 하단 빈 공간 방지 — sticky 해제 시에도 모달 바닥까지 채움 */
  box-shadow: 0 40px 0 0 var(--card);
}
.modal-action-row.hidden { display: none; }
.mar-btn {
  height: 38px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #111114;
  color: var(--text-2);
  cursor: pointer;
  transition: all .12s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  box-sizing: border-box;
}
.mar-btn:hover { background: #2a2a2e; color: var(--text); border-color: #3f3f46; }
.mar-btn-close { width: 80px; flex: none; }
.mar-close-mo { display: none; }
@media (max-width: 600px) {
  .mar-btn-close { width: 44px; }
  .mar-close-pc { display: none; }
  .mar-close-mo { display: inline; }
}
.mar-btn-naver { width: 80px; flex: none; color: #03c75a; border-color: rgba(3,199,90,.35); }
.mar-btn-naver:hover { background: rgba(3,199,90,.08); border-color: rgba(3,199,90,.55); color: #03c75a; }
.mar-btn-ai { flex: none; }
.mar-btn-save { width: 80px; flex: none; background: #567FF0; color: #fff; border-color: #567FF0; }
.mar-btn-save:hover { background: #4a6fd9; border-color: #4a6fd9; }
.btn-ext {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 14px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #111114; color: var(--text-2); text-decoration: none;
  transition: all .12s;
}
.btn-ext:hover { color: var(--text); border-color: #3f3f46; background: #1a1a1d; }
.btn-ext-naver { color: #03c75a; border-color: rgba(3,199,90,.35); }
.btn-ext-naver:hover { background: rgba(3,199,90,.08); border-color: rgba(3,199,90,.55); color: #03c75a; }
.modal-action-row .btn-more { padding: 9px 20px; }

/* AI 분석 섹션 (차트 모달 내 임베드) */
.cm-ai-section { margin: 16px 0 14px; }
.cm-ai-section.hidden { display: none; }
.cm-ai-title {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; font-weight: 700; color: var(--text);
  margin-bottom: 10px; letter-spacing: .02em;
}
.cm-ai-date { font-size: 11px; color: var(--text-3); font-weight: 400; }
.cm-ai-date:empty { display: none; }
.cmi-date-label { font-size: 10px; color: var(--text-3); margin-left: 6px; white-space: nowrap; }
.cm-ai-section .tp-chart-wrap {
  position: relative; width: 100%; height: 320px;
  background: #18181b; border-radius: 6px; padding: 8px; margin-bottom: 8px;
}
.cm-ai-section .tp-chart-sub {
  position: relative; width: 100%; height: 80px;
  background: #0e0e14; border-radius: 6px; padding: 8px; margin-bottom: 12px;
}
.cm-ai-section .tp-legend {
  display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px;
  color: var(--text-3); margin-bottom: 8px;
}
.cm-ai-section .tp-legend .sw { display: inline-block; width: 12px; height: 10px; margin-right: 4px; vertical-align: middle; border-radius: 2px; }
.cm-ai-section .tp-legend .ln { display: inline-block; width: 18px; height: 2px; margin-right: 4px; vertical-align: middle; }
/* AI 한 줄 결론 카드 */
.ai-conclusion-card {
  padding: 12px 14px;
  background: rgba(129,129,225,.06);
  border: 1px solid rgba(129,129,225,.2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 12px;
}
.cm-ai-section > label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin: 10px 0 6px;
}
.cm-ai-section .tp-inputs {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.cm-ai-section .tp-inp-box {
  background: #0e0e14; border: 1px solid var(--border);
  border-radius: 6px; padding: 10px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.cm-ai-section .tp-inp-box:hover { border-color: #555; }
.cm-ai-section .tp-inp-box.primary {
  background: #16163a; border-color: #567ff0;
  
  cursor: default;
}
.cm-ai-section .tp-inp-qtr { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.cm-ai-section .tp-inp-qtr .badge {
  font-size: 10px; padding: 1px 5px; border-radius: 3px;
  background: rgba(129,129,225,.2); color: #a3a3f7; margin-left: 4px;
}
.cm-ai-section .tp-inp-row { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.cm-ai-section .tp-inp-row .hold-input-wrap { flex: 1; min-width: 0; }
.cm-ai-section .tp-inp-row .hold-input {
  width: 100%; font-size: 15px;
  padding: 6px 9px; padding-left: 52px; padding-right: 26px;
  text-align: right;
}
.cm-ai-section .tp-inp-row .hold-input-prefix { font-size: 11px; left: 8px; }
.cm-ai-section .tp-inp-row .hold-input-unit   { font-size: 12px; right: 8px; }
.cm-ai-section .cm-ai-memo {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-3);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
@media (max-width: 640px) {
  .cm-ai-section .tp-inputs { grid-template-columns: repeat(2, 1fr); }
}

/* 추가 모달 폼 */
.form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-align: left;
  align-self: flex-start;
}
.form-input {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  background: #111114;
  color: var(--text);
  transition: border-color .12s;
}
.form-input:focus { border-color: var(--text-3); }
.form-input::placeholder { color: var(--text-3); }

.add-group-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 400px;
  overflow-y: auto;
  background: #0b0b0d;
  border: 1px solid #27272a;
  border-radius: var(--radius-sm);
  padding: 6px;
  scrollbar-width: thin;
  scrollbar-color: #3f3f46 #0b0b0d;
}
.add-group-list::-webkit-scrollbar { width: 8px; }
.add-group-list::-webkit-scrollbar-track { background: #0b0b0d; border-radius: 4px; }
.add-group-list::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 4px; }
.add-group-list::-webkit-scrollbar-thumb:hover { background: #52525b; }
.add-group-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #0b0b0d;
  border: 1px solid #0b0b0d;
  cursor: pointer;
  transition: background .1s, border-color .1s;
  user-select: none;
}
.add-group-item + .add-group-item { margin-top: 4px; }
.add-group-item:hover { background: #242428; border-color: #3f3f46; }
.add-group-item:has(input:checked) { background: #1f2937; border-color: #3b82f6; }
.add-group-item input[type="checkbox"] {
  accent-color: var(--text-2);
  width: 14px; height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
.add-group-item span { font-size: 13px; color: var(--text); }
.add-group-empty { font-size: 12px; color: var(--text-3); padding: 2px 0; }

.add-modal-box { max-width: 380px; padding: 20px; position: relative; }
.add-modal-close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; color: var(--text-3);
  font-size: 15px; cursor: pointer; line-height: 1; padding: 4px;
}
.add-modal-close:hover { color: var(--text); }
.add-ticker-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  padding: 4px 24px 14px;
}
.add-note-input { margin-top: 10px; }

.modal-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  margin-bottom: 20px;
}
.btn-cancel {
  padding: 8px 16px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-2);
  transition: all .12s;
}
.btn-cancel:hover { border-color: var(--text-3); color: var(--text); }

.btn-primary {
  padding: 8px 20px;
  background: #2a2a2e;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, border-color .15s;
}
.btn-primary:hover { background: #3f3f46; border-color: #3f3f46; }

/* ── 토스트 알림 ──────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a2a2e;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  z-index: 999;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
  transition: opacity .3s;
}
.toast.hidden { display: none; }

/* ── AI 분석 로딩 오버레이 ──────────────────────────────────────────────── */
.ai-loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s ease;
}
.ai-loading-overlay.hidden { display: none; }
.ai-loading-card {
  background: #18181b;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  max-width: 360px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.ai-loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid #2a2a2e;
  border-top-color: #a855f7;
  border-radius: 50%;
  animation: aiSpin .9s linear infinite;
}
@keyframes aiSpin { to { transform: rotate(360deg); } }
.ai-loading-msg { font-size: 14px; color: var(--text); line-height: 1.6; }
.ai-loading-sub { font-size: 12px; color: var(--text-3); }

/* ── 애니메이션 ──────────────────────────────────────────────────────────── */
@keyframes fadeIn   { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp  { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }
@keyframes slideUpSheet { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pulse    { 0%,100% { opacity: 1 } 50% { opacity: .4 } }

/* ── 관심 종목 그룹 ──────────────────────────────────────────────────────── */
.btn-new-wlg {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  background: #111114;
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .12s;
}
.btn-new-wlg:hover { background: #2a2a2e; color: var(--text); border-color: #3f3f46; }
.btn-new-wlg-link {
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; line-height: 1;
  background: transparent;
  border: none;
  padding: 5px 8px;
  color: var(--text-2);
}
.btn-new-wlg-link:hover { background: transparent; border: none; color: var(--text); }
.btn-new-wlg-link .btn-svg { width: 15px; height: 15px; }

.btn-preset-grp {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  background: #111114;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.btn-preset-grp:hover { background: #2a2a2e; color: var(--text-2); border-color: #3f3f46; }

.preset-group-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
  max-height: 300px;
  overflow-y: auto;
}
.preset-group-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  background: #111114;
  border: 1px solid var(--border);
}
.preset-group-row .pg-idx {
  font-size: 11px;
  color: var(--text-3);
  width: 18px;
  text-align: right;
  flex-shrink: 0;
}
.preset-group-row .pg-name {
  font-size: 13px;
  color: var(--text);
  flex: 1;
}
.preset-group-row .pg-exists {
  font-size: 11px;
  color: var(--text-3);
  background: #1c1c1f;
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.wl-group-section { margin-bottom: 24px; }

.wl-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0px;
  /*background: #0d0d0f;*/
  border-bottom: 1px solid #18181b;
  /*border-radius: var(--radius-sm);*/
  cursor: pointer;
  margin-bottom: 12px;
  user-select: none;
  transition: background .1s;
}
.wl-group-header:hover { background: #18181b; }

.wl-group-arrow {
  font-size: 10px;
  color: var(--text-3);
  transition: transform .2s;
  flex-shrink: 0;
}
.wl-group-header.collapsed .wl-group-arrow { transform: rotate(-90deg); }
.wl-group-name  { font-size: 13px; font-weight: 700; color: var(--text-2); }
.wl-group-count {
  font-size: 12px;
  background: none;
  color: var(--text-3);
  padding: 0;
  margin-left: 2px;
  font-weight: 600;
}
.wl-group-actions { display: flex; gap: 4px; flex-shrink: 0; margin-left: auto; }

.wl-group-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 4px 0 10px;
  font-size: 12px;
}
.wl-group-total .wgt-label  { color: var(--text-3); }
.wl-group-total .wgt-value  { font-size: 14px; font-weight: 600; }
.wl-group-total.up { color: var(--up); }
.wl-group-total.dn { color: var(--dn); }
.wl-group-act-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 5px;
  border-radius: 4px;
  transition: color .12s, background .12s;
  line-height: 1;
}
.wl-group-act-btn:hover       { color: var(--dn); background: rgba(248,113,113,.1); }
.wl-group-act-btn.rename:hover{ color: var(--text); background: #2a2a2e; }

.wl-group-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.drag-handle { display: none; }
.drag-handle:active { cursor: grabbing; }
.stock-card.dragging { opacity: 0.35; box-shadow: none; }
.stock-card.drag-over {
  border-color: var(--primary-h);
  box-shadow: 0 0 0 2px rgba(212,212,216,.2);
}
.wl-group-header.collapsed ~ .wl-group-items,
.wl-group-header.collapsed ~ .wl-group-total { display: none; }

.wl-group-empty {
  color: var(--text-3);
  font-size: 12px;
  padding: 4px 0 8px;
}

.wl-ungrouped-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin: 4px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* 카드 상단 버튼 묶음 */
.card-btns { display: flex; gap: 3px; align-items: center; }

.card-grp-btn {
  opacity: 0;
  transition: opacity .15s;
  background: #1a1a1d;
  border: 1px solid #2a2a2e;
  cursor: pointer;
  color: var(--text-3);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.4;
  white-space: nowrap;
}
.stock-card:hover .card-grp-btn { opacity: 1; }
.card-grp-btn:hover { color: var(--text); border-color: #3f3f46; background: #2a2a2e; }
.cmh-grp-btn { opacity: 1; padding: 2px 10px; font-size: 12px; }
.cmh-sector {
  font-size: 12px; color: var(--text-3);
  white-space: nowrap;
}
.cmh-sector:empty { display: none; }
.cmh-sector:not(:empty)::before { content: ' · '; color: var(--text-3); margin-right: 2px; }

/* 그룹 팝업 */
.wlg-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 600;
}
.wlg-overlay.show { display: block; }

.wlg-popup {
  position: fixed;
  background: #18181b;
  border: 1px solid #2a2a2e;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.7);
  width: 234px;
  max-height: 360px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 601;
  animation: slideUp .15s ease;
}
.wlg-header {
  padding: 11px 14px 8px;
  border-bottom: 1px solid #2a2a2e;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wlg-title { font-size: 13px; font-weight: 700; color: var(--text); }
.wlg-close {
  background: none; border: none; color: var(--text-3);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 0;
}
.wlg-close:hover { color: var(--dn); }
.wlg-subtitle {
  font-size: 14px; color: var(--text-3);
  padding: 8px 14px;
  border-bottom: 1px solid #222226;
}
.wlg-list {
  flex: 1; overflow-y: auto; padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: #3a3a40 transparent;
}
.wlg-list::-webkit-scrollbar { width: 8px; }
.wlg-list::-webkit-scrollbar-track { background: transparent; }
.wlg-list::-webkit-scrollbar-thumb {
  background: #3a3a40;
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.wlg-list::-webkit-scrollbar-thumb:hover { background: #555; background-clip: padding-box; }
.wlg-item {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 14px; cursor: pointer; transition: background .1s;
}
.wlg-item:hover { background: #111114; }
.wlg-cb { accent-color: #a1a1aa; width: 14px; height: 14px; cursor: pointer; }
.wlg-item-name { font-size: 14px; color: var(--text); flex: 1; }
.wlg-empty {
  font-size: 12px; color: var(--text-3);
  padding: 16px 14px; text-align: center; line-height: 1.6;
}
.wlg-footer {
  padding: 8px 10px;
  border-top: 1px solid #2a2a2e;
  display: flex; gap: 6px;
}
.wlg-new-input {
  flex: 1; padding: 5px 8px;
  background: #111114; border: 1px solid #2a2a2e;
  border-radius: 5px; color: var(--text); font-size: 12px; outline: none;
}
.wlg-new-input:focus { border-color: #3f3f46; }
.wlg-new-input::placeholder { color: var(--text-3); }
.wlg-add-btn {
  padding: 5px 10px; font-size: 12px; font-weight: 600;
  background: #2a2a2e; color: var(--text);
  border: 1px solid #3f3f46; border-radius: 5px; cursor: pointer;
  white-space: nowrap;
}
.wlg-add-btn:hover { background: #3f3f46; }

/* ── 그룹 관리 모달 ──────────────────────────────────────────────────────── */
.grpmgr-box { width: 360px; max-width: 96vw; }
@media (max-width: 600px) {
  .grpmgr-box { width: 100%; max-width: 100%; }
}
.grpmgr-add-row {
  display: flex; gap: 8px; align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}
.grpmgr-add-row .form-input { flex: 1; }
.grpmgr-add-row .btn-primary { flex-shrink: 0; padding: 7px 14px; font-size: 13px; }

.grpmgr-hint {
  font-size: 12px;
  color: var(--text-3);
  margin: 0 0 12px;
}

.grpmgr-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #3a3a40 transparent;
}
.grpmgr-list::-webkit-scrollbar { width: 8px; }
.grpmgr-list::-webkit-scrollbar-track { background: transparent; }
.grpmgr-list::-webkit-scrollbar-thumb {
  background: #3a3a40;
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.grpmgr-list::-webkit-scrollbar-thumb:hover { background: #555; background-clip: padding-box; }

.grpmgr-empty {
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
  padding: 20px 0;
}

.grpmgr-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #1a1a1e;
  /*border: 1px solid var(--border);*/
  border-radius: 8px;
  cursor: grab;
  transition: background .12s, border-color .12s;
  user-select: none;
}
.grpmgr-item:hover { background: #111114; border-color: #3f3f46; }
.grpmgr-item.dragging { opacity: .4; }
.grpmgr-item.drag-over { border-color: #6366f1; background: #1e1e2e; }
.grpmgr-item-pick { cursor: pointer; }
.grpmgr-item-pick:has(input:checked) { background: #1f2937; }
.grpmgr-item-pick .add-group-cb {
  width: 16px; height: 16px; cursor: pointer; accent-color: #6366f1; flex-shrink: 0;
}
.grpmgr-item-pick .grpmgr-name { cursor: pointer; }

.grpmgr-handle {
  font-size: 16px;
  color: var(--text-3);
  cursor: grab;
  line-height: 1;
}

.grpmgr-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.grpmgr-count {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}

/* 모바일 순서 변경 화살표 — PC에선 숨김, 모바일에서 표시 */
.grpmgr-arrows { display: none; }
@media (max-width: 600px) {
  .grpmgr-arrows {
    display: flex;
    gap: 4px;
    margin-left: 6px;
  }
  .grpmgr-arrow {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #111114;
    color: var(--text-2);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .12s;
  }
  .grpmgr-arrow:hover:not(:disabled) { background: #2a2a2e; color: var(--text); }
  .grpmgr-arrow:disabled { opacity: .3; cursor: not-allowed; }
  .grpmgr-item { touch-action: pan-y; }
  .grpmgr-handle { display: none; }
}

/* ── 반응형 ──────────────────────────────────────────────────────────────── */
/* 섹션 타이틀 옆 추가 아이콘 */
.btn-section-add {
  margin-left: 6px;
  vertical-align: middle;
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: none; padding: 5px 8px;
  cursor: pointer; opacity: 0.85; transition: opacity .15s, color .15s;
  color: var(--text-2); font-size: 12px; font-weight: 600; line-height: 1;
}
.btn-section-add:hover { opacity: 1; color: var(--text); }
.btn-section-add .btn-svg { width: 15px; height: 15px; }

.btn-refresh {
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; padding: 5px 6px;
  cursor: pointer; opacity: 0.7; transition: opacity .15s, transform .3s;
  color: var(--text-2);
}
.btn-refresh:hover { opacity: 1; }
.btn-refresh:active { transform: rotate(180deg); }
.btn-refresh .btn-svg { width: 16px; height: 16px; }

/* 검색 모달 */
.search-modal-box { max-width: 560px; display: flex; flex-direction: column; max-height: 80vh; }
.search-modal-input-wrap {
  position: relative; display: flex; align-items: center;
  margin: 0 0 8px;
}
.search-modal-icon {
  position: absolute; left: 12px;
  width: 16px; height: 16px; filter: invert(1); opacity: .4; pointer-events: none;
}
.search-modal-input {
  width: 100%; padding: 10px 14px 10px 38px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #111114; color: var(--text); font-size: 15px; outline: none;
  transition: border-color .15s;
}
.search-modal-input:focus { border-color: var(--text-3); }
.search-modal-input::placeholder { color: var(--text-3); }
.search-result-info {
  font-size: 11px; color: var(--text-3); padding: 0 4px 6px;
  letter-spacing: .02em;
}
.search-result-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 4px;
  overflow-y: auto; flex: 1; min-height: 0;
  scrollbar-width: thin; scrollbar-color: #3a3a40 transparent;
}
.search-result-list::-webkit-scrollbar { width: 8px; }
.search-result-list::-webkit-scrollbar-track { background: transparent; }
.search-result-list::-webkit-scrollbar-thumb { background: #3a3a40; border-radius: 4px; border: 2px solid transparent; background-clip: padding-box; }
.search-result-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: #1a1a1e; border-radius: 8px;
  cursor: pointer; transition: background .12s; user-select: none;
}
.search-result-item:hover { background: #222228; }
.search-result-item:active { background: #2a2a30; }
.search-result-rank {
  width: 20px; flex-shrink: 0; font-size: 12px; font-weight: 600;
  color: var(--text-3); text-align: center;
}
.search-result-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #27272a;
  color: var(--text); font-size: 13px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.search-result-body { flex: 1; min-width: 0; }
.search-result-name {
  font-size: 14px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-result-meta { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.search-result-badges { display: flex; gap: 5px; flex-shrink: 0; }
.search-result-empty {
  text-align: center; color: var(--text-3); padding: 30px 0; font-size: 13px;
}

/* iOS Safari 자동 확대 방지 — 모바일 input font-size 16px 이상 강제 */
@media (max-width: 600px) {
  input, textarea, select { font-size: 16px !important; }
}

@media (max-width: 600px) {
  #chartModal .period-tabs { display: none; }
  #searchModal { padding-top: 0px; }
  .search-modal-box { max-height: 90vh; }
  .search-modal-input { font-size: 16px; padding: 9px 12px 9px 36px; }
  .search-result-item { padding: 8px 10px; gap: 8px; }
  .search-result-avatar { width: 28px; height: 28px; font-size: 11px; }
  .search-result-name { font-size: 13px; }
  .search-result-meta { font-size: 11px; }
  .header-inner { padding: 10px 14px; }
  .logo { justify-content: flex-start; }
  .header-right { justify-content: flex-end; gap: 4px; }
  /* 헤더 탭은 모바일에서 좌측 정렬 (로고 옆) */
  .header-tabs {
    position: static;
    transform: none;
    margin-left: 12px;
  }
  .header-tabs .tab { padding: 6px 10px; font-size: 13px; }
  /* 모바일: 헤더에 그룹관리/종목추가 표시, section-header에선 숨김 */
  .section-header { top: 44px; }
  body.header-hidden .section-header { top: 0; }
  /* 스크롤 시 로고 숨기고 탭+버튼만 표시 */
  body.scrolled .header .logo { display: none; }
  body.scrolled .header-inner { padding: 6px 14px; }
  body.scrolled .header-tabs { margin-left: 0; }
  .hu-name { display: none; }
  .btn-new-wlg-link .btn-label,
  .btn-section-add .btn-label { display: none; }
  .btn-new-wlg-link,
  .btn-section-add { padding: 5px 4px; }
  .card-grid,
  .wl-group-items { grid-template-columns: 1fr; gap: 10px; }
  /* 심플 카드 보기 모드: 모바일에서 2열로 표시 */
  .cards-simple .card-grid,
  .cards-simple .wl-group-items { grid-template-columns: 1fr 1fr; gap: 8px; }
  .cards-simple .stock-card { padding: 10px; }
  .cards-simple .card-price-label,
  .cards-simple .ctc-label { display: none; }
  .cards-simple .card-price-block,
  .cards-simple .ctc-row-top { justify-content: flex-end; }
  /* 폰트 축소 (2열 좁은 폭 대응) */
  .cards-simple .stock-card .card-name { font-size: 16px; }
  .cards-simple .stock-card .card-price { font-size: 19px; }
  .cards-simple .stock-card .ctc-target { font-size: 19px; }
  .cards-simple .stock-card .card-change { font-size: 13px; }
  .cards-simple .stock-card .cap-value,
  .cards-simple .stock-card .card-gap-pct { font-size: 14px; }
  .stock-card { padding: 13px; }
  /* 모바일에서 stock-card 내부 폰트 1.3배 확대 */
  .stock-card .card-name { font-size: 20px; }
  .stock-card .card-ticker { font-size: 14px; }
  .stock-card .card-ticker-row .card-mktcap { font-size: 14px; }
  .stock-card .card-price-label { font-size: 12px; }
  .stock-card .card-price { font-size: 23px; }
  .stock-card .card-change { font-size: 17px; }
  .stock-card .ctc-label { font-size: 12px; }
  .stock-card .ctc-target { font-size: 23px; }
  .stock-card .cap-value { font-size: 18px; }
  .stock-card .card-gap-pct { font-size: 18px; }
  .stock-card .chp-label { font-size: 14px; }
  .stock-card .card-hold-pl .chp-pct { font-size: 17px; }
  .stock-card .card-hold-pl .chp-amount { font-size: 21px; }
  .stock-card .card-hold-avg .chp-amount { font-size: 21px; }
  .hold-inputs-row {
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }
  .hold-row-label { flex: 1 1 100%; margin-right: 0; }
  .hold-inputs-row .hold-field { flex: 1 1 100%; }
  .hold-inputs-row .hold-input-wrap,
  .hold-inputs-row #holdPriceInput,
  .hold-inputs-row .hold-input-wrap-sm,
  .hold-inputs-row #holdQtyInput { width: 100%; min-width: 0; box-sizing: border-box; }
  .hold-inputs-row .hold-input { padding-left: 66px; padding-right: 24px; font-size: 16px; text-align: right; }
  .hold-inputs-row .hold-input-wrap-sm .hold-input { padding-left: 56px; padding-right: 10px; }
  .hold-inputs-row .hold-input-prefix { font-size: 11px; left: 8px; }
  .hold-inputs-row .hold-input-unit { font-size: 12px; right: 8px; }
  .hold-save-btn { padding: 8px 16px; font-size: 13px; flex: 1 1 100%; margin-left: 0; }
  .hold-summary-val { font-size: 24px; }
  .cmi-target-wrap { max-width: 100%; }
  .cmi-target-wrap .hold-input { font-size: 18px; padding-left: 52px; padding-right: 22px; }
  .cmi-target-wrap .hold-input-prefix { font-size: 11px; left: 8px; }
  .cmi-target-wrap .hold-input-unit   { font-size: 12px; right: 8px; }
  .cmi-target-row { flex-wrap: wrap; gap: 6px; }
  .cmi-target-row #cmiGapPct { font-size: 15px; }
  .modal-wide { max-width: 100%; }
  .chart-area { display: none; }
  .chart-area-vol { display: none; }
  .stock-card .card-grp-btn,
  .stock-card .card-del { opacity: 1; }
}

/* ── 차트 모달 리디자인 ────────────────────────────────────────── */
/* 드래그 핸들 (swipe-down to close) — 헤더와 틈 없이 연결 */
.chart-mh-drag {
  position: sticky;
  top: -24px;
  margin: -24px -24px 0;
  padding: 8px 0 0;
  display: flex;
  justify-content: center;
  background: #18181b;
  z-index: 6;
  cursor: grab;
  touch-action: none;
}
.chart-mh-drag:active { cursor: grabbing; }
.drag-pill {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #3f3f46;
}

/* 드래그 핸들 뒤따르는 모든 modal-header — 틈 방지 */
.chart-mh-drag + .modal-header {
  position: sticky;
  top: calc(-24px + 12px);
  margin-left: -24px; margin-right: -24px;
  padding: 8px 24px 12px;
  background: #18181b;
  border-bottom: 1px solid var(--border);
  z-index: 5;
}

.chart-mh {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: calc(-24px + 12px);
  margin: 0 -24px 14px;
  padding: 8px 24px 14px;
  background: #18181b;
  border-bottom: 1px solid var(--border);
  z-index: 5;
}
.cmh-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cmh-title .modal-title    { font-size: 18px; font-weight: 700; color: var(--text); }
.cmh-title .modal-subtitle { font-size: 12px; color: var(--text-3); }

.cm-info-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin-bottom: 14px;
}
.cm-hold-card {
  background: #0d0d0f;
  /*border: 1px solid var(--border-soft);*/
  border-radius: 10px;
  padding: 12px 12px;
  margin-bottom: 14px;
}
.cm-hold-wrap { margin-bottom: 14px; }
.cm-hold-wrap.hidden { display: none; }
.cm-hold-wrap .cm-hold-card { margin-bottom: 0; }

.cm-hold-simple {
  display: flex; flex-direction: column; gap: 12px;
}
.hold-merged {
  display: flex; gap: 20px; align-items: stretch;
}
.hold-merged-col { flex: 1; min-width: 0; }
.hold-merged > .hold-merged-col + .hold-merged-col {
  padding-left: 20px; border-left: 1px solid var(--border-soft);
}
@media (max-width: 640px) {
  .hold-merged { flex-direction: column; gap: 10px; }
  .hold-merged > .hold-merged-col + .hold-merged-col {
    padding-left: 0; border-left: none;
    padding-top: 10px; border-top: 1px solid var(--border-soft);
  }
}
.hold-info-stack {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 2px;
}
.hold-info-cell {
  display: contents;
}
.hold-info-cell .hold-info-label {
  font-size: 12px; color: var(--text-3); margin-bottom: 0;
}
.hold-info-cell .hold-info-val {
  font-size: 20px; font-weight: 700; color: #fff;
  line-height: 1.2; margin-left: auto; display: inline-flex; gap: 6px; align-items: baseline;
}
.hold-info-cell:nth-child(2) .hold-info-val {
  font-size: 13px; font-weight: 600;
  flex: 1 1 100%; justify-content: flex-end;
}
.hold-info-cell:nth-child(2) .hold-profit-value { font-size: 16px; font-weight: 600; }
.hold-info-cell:nth-child(2) .hold-profit-value.hold-profit-pct { font-size: 13px; font-weight: 500; }
.hold-info-label { font-size: 11px; color: var(--text-3); }
.hold-info-val   {
  font-size: 22px; font-weight: 600; color: #fff;
  display: inline-flex; gap: 6px; align-items: baseline;
}
#holdFinalAmount {
  background: linear-gradient(90deg, #0080ad, #4d4cf7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.hold-inputs-row {
  display: flex; flex-direction: row; gap: 12px; align-items: flex-end;
  flex-wrap: wrap;
  padding-top: 10px; border-top: 1px solid var(--border-soft);
}
.hold-inputs-row { justify-content: flex-end; }
.hold-inputs-row .hold-field { flex: 0 0 auto; min-width: 0; }
.hold-row-label {
  font-size: 12px; color: var(--text-3);
  align-self: center; margin-right: auto;
  white-space: nowrap;
}
.hold-row-date { color: var(--text-2); margin-left: 4px; }
.hold-inputs-row #holdPriceInput,
.hold-inputs-row .hold-input-wrap { width: 220px; }
.hold-inputs-row .hold-input-wrap-sm,
.hold-inputs-row #holdQtyInput { width: 160px; }
.hold-save-btn {
  padding: 8px 18px;
  font-size: 13px;
  align-self: center;
}
.hidden { display: none !important; }
@media (max-width: 640px) {
  .cm-hold-simple { flex-direction: column; }
  .hold-info-stack {
    flex-direction: column; align-items: flex-start; gap: 0px;
  }
  .hold-info-cell {
    flex-direction: column; align-items: flex-start; gap: 0px;
    width: 100%;
  }
  .hold-info-label { font-size: 12px; }
  .hold-info-val   { font-size: 28px; }
  .hold-profit-value { font-size: 18px; }
  .hold-profit-value.hold-profit-pct { font-size: 13px; }
  .hold-inputs-row {
    padding-left: 0; border-left: none;
    padding-top: 12px; border-top: 1px solid var(--border-soft);
    flex-direction: row; flex-wrap: wrap; gap: 8px;
  }
  .hold-inputs-row .hold-field { flex: 1 1 100%; min-width: 0; }
  .hold-inputs-row .hold-row-label { flex: 1 1 100%; margin-right: 0; }
  .hold-save-btn { flex: 1 1 100%; margin-left: 0; }
}
.cmi-row { display: flex; gap: 24px; align-items: stretch; flex-wrap: wrap; }
.cmi-stack { display: flex; gap: 24px; align-items: stretch; }
.cmi-col {
  flex: 1; min-width: 0;
  padding: 12px 14px; background: #111114;
  border: 1px solid var(--border-soft); border-radius: 8px;
}
@media (max-width: 640px) {
  .cmi-stack { flex-direction: column; gap: 12px; }
}
.cmi-target-col { display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.cmi-label { font-size: 12px; color: var(--text-3); display: block; margin-bottom: 6px; }
.cmi-current { display: flex; flex-wrap: wrap; align-items: baseline; row-gap: 2px; column-gap: 8px; }
.cmi-current .cmi-label { margin-bottom: 0; }
.cmi-label-stack, .hold-info-label-stack {
  display: inline-flex; flex-direction: column; gap: 0px;
  line-height: 1.2;
}
.cmi-label-main, .hold-info-label-main { font-size: 12px; color: var(--text-3); }
.cmi-label-sub,  .hold-info-label-sub  { font-size: 12px; color: var(--text-3); }
.cmi-current-val { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.2; margin-left: auto; }
.cmi-current-pct { font-size: 16px; font-weight: 600; flex: 1 1 100%; text-align: right; }
.cmi-current-pct-rate { font-size: 13px; font-weight: 500; }
.cmi-target-row { display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; }
.cmi-target-row #cmiGapPct { margin-left: auto; text-align: right; font-size: 18px; }
.cmi-target-row .card-gap-pct.up { color: #0080ad; }
.cmi-target-row .card-gap-pct.dn { color: #FF5F57; }
.card-gap-pct .gap-note { color: #71717a; font-weight: 400; font-size: 11px;}
/* 목표가 인풋 — hold-input 스타일 통일 */
.cmi-target-wrap { flex: 1; min-width: 0; max-width: 200px; }
.cmi-target-wrap .hold-input {
  width: 100%; padding-left: 52px; padding-right: 22px;
  text-align: right; font-size: 16px; font-weight: 600;
}
.cmi-target-wrap .hold-input-prefix { font-size: 12px; left: 10px; }
.cmi-target-wrap .hold-input-unit   { font-size: 13px; right: 10px; }
/* hold-input-wrap input 금액 그라데이션 텍스트
   — background-clip:text는 전체 배경을 잘라내므로, 배경은 wrapper로 이동 */
.hold-input-wrap {
  background: #111114;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .12s;
}
.hold-input-wrap:focus-within { border-color: #8181e1; }
.hold-input-wrap .hold-input {
  background: transparent;
  border: none;
  background-image: linear-gradient(90deg, #0080ad, #4d4cf7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  caret-color: #4d4cf7;
}
.hold-input-wrap .hold-input::placeholder {
  -webkit-text-fill-color: var(--text-3);
  color: var(--text-3);
}
/* 매입가/주식수 인풋은 그라데이션 대신 단색 #c2c1d4 */
.hold-inputs-row .hold-input-wrap .hold-input {
  background-image: none;
  -webkit-text-fill-color: #c2c1d4;
  color: #c2c1d4;
}
/* 매입가 숫자와 "원" 사이 간격 4px 추가 */
.hold-inputs-row #holdPriceInput { padding-right: 25px; }

/* 메모 textarea */
.modal-sector-row {
  display: flex; align-items: center; gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  margin-bottom: 10px;
}
.modal-sector-row label { font-size: 12px; color: var(--text-2); min-width: 36px; }

#modalNoteRow {
  display: flex; flex-direction: column; gap: 6px;
  padding-top: 0; border-top: none;
  align-items: stretch;
}
#modalNoteRow label { font-size: 12px; color: var(--text-2); }
.note-textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  padding: 9px 11px;
  background: #111114;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  outline: none;
  transition: border-color .12s;
}
.note-textarea:focus { border-color: var(--text-3); }
.note-textarea::placeholder { color: var(--text-3); }
.note-counter { font-size: 11px; color: var(--text-3); text-align: right; }

/* ── 헤더 사용자 정보 ────────────────────────────────────────── */
.header-user-slot { display: inline-flex; }
.hu-wrap {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .12s;
}
.hu-wrap:hover { border-color: #3f3f46; }
.hu-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.hu-avatar-fallback {
  background: #4f46e5; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.hu-name { font-size: 12px; color: var(--text-2); max-width: 140px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 600px) {
  .hu-wrap { padding: 4px; border: none; background: transparent; }
  .hu-name { display: none; }
}

/* ── 유저 메뉴 모달 ─────────────────────────────────────────── */
.user-menu-box { max-width: 340px; padding: 16px 0 8px; }
.um-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--border);
}
.um-profile {
  display: flex; align-items: center; gap: 10px;
}
.um-profile .hu-avatar { width: 36px; height: 36px; }
.um-profile .hu-avatar-fallback { width: 36px; height: 36px; font-size: 15px; }
.um-profile-info { display: flex; flex-direction: column; gap: 2px; }
.um-profile-name { font-size: 14px; font-weight: 600; color: var(--text); }
.um-profile-email { font-size: 12px; color: var(--text-3); }
.um-list { list-style: none; padding: 8px 0; margin: 0; }
.um-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  font-size: 14px; color: var(--text-2);
  cursor: pointer;
  transition: background .1s, color .1s;
}
.um-item:hover { background: #222226; color: var(--text); }
.um-item svg { flex-shrink: 0; color: var(--text-3); }
.um-item:hover svg { color: var(--text-2); }
.um-item-danger { color: #ef4444; }
.um-item-danger svg { color: #ef4444; }
.um-item-danger:hover { background: rgba(239,68,68,.08); color: #f87171; }
.um-divider { height: 1px; background: var(--border); margin: 4px 16px; }

/* ── 로그인 게이트 ───────────────────────────────────────────── */
.login-gate {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(13,13,15,0.96);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
.login-gate.hidden { display: none; }
.login-card {
  background: #18181b;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 40px;
  max-width: 360px; width: 92%;
  text-align: center;
}
.login-logo { width: 48px; height: 48px; filter: invert(1); margin-bottom: 14px; }
.login-title { font-size: 22px; font-weight: 700; margin: 0 0 6px; color: var(--text); }
.login-sub { font-size: 13px; color: var(--text-3); margin: 0 0 24px; }
.login-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  background: #fff; color: #1f1f1f;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 14px; font-weight: 600;
  text-decoration: none;
  transition: opacity .15s;
}
.login-btn:hover { opacity: 0.9; }
.login-btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: linear-gradient(45deg, #ea4335, #fbbc04, #34a853, #4285f4);
  color: #fff; font-weight: 800; border-radius: 50%;
  font-size: 12px;
}
